package io.lumify.reindexmr;


import org.apache.hadoop.mapreduce.Mapper;
import org.securegraph.Authorizations;
import org.securegraph.GraphFactory;
import org.securegraph.Vertex;
import org.securegraph.accumulo.AccumuloAuthorizations;
import org.securegraph.accumulo.AccumuloGraph;
import org.securegraph.accumulo.mapreduce.SecureGraphMRUtils;
import org.securegraph.util.MapUtils;

import java.io.IOException;
import java.util.Map;

public class ReindexMRMapper extends Mapper<String, Vertex, Object, Vertex> {
    private AccumuloGraph graph;
    private Authorizations authorizations;

    @Override
    protected void setup(Context context) throws IOException, InterruptedException {
        super.setup(context);
        Map configurationMap = SecureGraphMRUtils.toMap(context.getConfiguration());
        this.graph = (AccumuloGraph) new GraphFactory().createGraph(MapUtils.getAllWithPrefix(configurationMap, "graph"));
        this.authorizations = new AccumuloAuthorizations(context.getConfiguration().getStrings(SecureGraphMRUtils.CONFIG_AUTHORIZATIONS));
    }

    @Override
    protected void cleanup(Context context) throws IOException, InterruptedException {
        graph.shutdown();
        super.cleanup(context);
    }

    @Override
    protected void map(String rowKey, Vertex vertex, Context context) throws IOException, InterruptedException {
        context.setStatus(rowKey);
        graph.getSearchIndex().addElement(graph, vertex, authorizations);
    }
}

@@ -24,16 +24,105 @@
 exmr;%0A%0A%0A
+import io.lumify.core.util.LumifyLogger;%0Aimport io.lumify.core.util.LumifyLoggerFactory;%0A
 import o
@@ -596,16 +596,117 @@
 rtex%3E %7B%0A
+    private static final LumifyLogger LOGGER = LumifyLoggerFactory.getLogger(ReindexMRMapper.class);%0A
     priv
@@ -1585,16 +1585,34 @@
 owKey);%0A
+        try %7B%0A    
         
@@ -1673,20 +1673,130 @@
 rizations);%0A
+        %7D catch (Throwable ex) %7B%0A            LOGGER.error(%22Could not add element: %25s%22, rowKey, ex);%0A        %7D%0A
     %7D%0A%7D%0A

add try/catch around mapper