Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static class TestReducer implements Reducer<Text, Text, LongWritable, MapWritable> {
- private Node node;
- private Client client;
- public void configure(JobConf job) {
- node = nodeBuilder().client(false).clusterName("hadoopTest").node();
- client = node.client();
- Map<String, Object> settings = new HashMap<>();
- settings.put("location", "/tmp/es_hadoop_backups/my_backup");
- settings.put("compress", true);
- PutRepositoryResponse putRepositoryResponse = client.admin().cluster().preparePutRepository("my_backup")
- .setType("fs").setSettings(settings).get();
- boolean success = putRepositoryResponse.isAcknowledged();
- client = node.client();
- }
- public void reduce(Text segmentId, Iterator<Text> segmentRestObjects, OutputCollector<LongWritable, MapWritable> output, Reporter reporter) throws IOException {
- String json = ".....";
- client.prepareIndex("drewmarch4", "conversation").setSource(json).execute().actionGet();
- }
- public void close() throws IOException {
- CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("my_backup", "test-snap6").setWaitForCompletion(true).setIndices("drew*").get();
- node.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement