IndexIdentifier indexId = new IndexIdentifier(index); StandardScanner.Builder builder; IndexJobFuture future; case REINDEX: builder = graph.getBackend().buildEdgeScanJob(); builder.setFinishJob(indexId.getIndexJobFinisher(graph, SchemaAction.ENABLE_INDEX)); builder.setJobId(indexId); builder.setJob(VertexJobConverter.convert(graph, new IndexRepairJob(indexId.indexName, indexId.relationTypeName))); builder = graph.getBackend().buildGraphIndexScanJob(); builder.setFinishJob(indexId.getIndexJobFinisher()); builder.setJobId(indexId); builder.setJob(new IndexRemoveJob(graph, indexId.indexName, indexId.relationTypeName));
public Consumer<ScanMetrics> getIndexJobFinisher(final TitanGraph graph, final SchemaAction action) { Preconditions.checkArgument((graph != null && action != null) || (graph == null && action == null)); return metrics -> { try { if (metrics.get(ScanMetrics.Metric.FAILURE) == 0) { if (action != null) { ManagementSystem mgmt = (ManagementSystem) graph.openManagement(); try { TitanIndex index = retrieve(mgmt); mgmt.updateIndex(index, action); } finally { mgmt.commit(); } } LOGGER.info("Index update job successful for [{}]", IndexIdentifier.this.toString()); } else { LOGGER.error("Index update job unsuccessful for [{}]. Check logs", IndexIdentifier.this.toString()); } } catch (Throwable e) { LOGGER.error("Error encountered when updating index after job finished [" + IndexIdentifier.this.toString() + "]: ", e); } }; } }
IndexIdentifier indexId = new IndexIdentifier(index); StandardScanner.Builder builder; IndexJobFuture future; case REINDEX: builder = graph.getBackend().buildEdgeScanJob(); builder.setFinishJob(indexId.getIndexJobFinisher(graph, SchemaAction.ENABLE_INDEX)); builder.setJobId(indexId); builder.setJob(VertexJobConverter.convert(graph, new IndexRepairJob(indexId.indexName, indexId.relationTypeName))); builder = graph.getBackend().buildGraphIndexScanJob(); builder.setFinishJob(indexId.getIndexJobFinisher()); builder.setJobId(indexId); builder.setJob(new IndexRemoveJob(graph, indexId.indexName, indexId.relationTypeName));
public Consumer<ScanMetrics> getIndexJobFinisher(final TitanGraph graph, final SchemaAction action) { Preconditions.checkArgument((graph != null && action != null) || (graph == null && action == null)); return metrics -> { try { if (metrics.get(ScanMetrics.Metric.FAILURE) == 0) { if (action != null) { ManagementSystem mgmt = (ManagementSystem) graph.openManagement(); try { TitanIndex index = retrieve(mgmt); mgmt.updateIndex(index, action); } finally { mgmt.commit(); } } LOGGER.info("Index update job successful for [{}]", IndexIdentifier.this.toString()); } else { LOGGER.error("Index update job unsuccessful for [{}]. Check logs", IndexIdentifier.this.toString()); } } catch (Throwable e) { LOGGER.error("Error encountered when updating index after job finished [" + IndexIdentifier.this.toString() + "]: ", e); } }; } }
public Consumer<ScanMetrics> getIndexJobFinisher() { return getIndexJobFinisher(null, null); }
@Override public IndexJobFuture getIndexJobStatus(TitanIndex index) { IndexIdentifier indexId = new IndexIdentifier(index); return graph.getBackend().getScanJobStatus(indexId); }
public Consumer<ScanMetrics> getIndexJobFinisher() { return getIndexJobFinisher(null, null); }
@Override public IndexJobFuture getIndexJobStatus(TitanIndex index) { IndexIdentifier indexId = new IndexIdentifier(index); return graph.getBackend().getScanJobStatus(indexId); }