mgmt.commit(); return true; } catch (RuntimeException e) {
public void workerIterationEnd(ScanMetrics metrics) { try { if (null != mgmt && mgmt.isOpen()) mgmt.commit(); if (writeTx!=null && writeTx.isOpen()) writeTx.commit(); metrics.incrementCustom(SUCCESS_TX); } catch (RuntimeException e) { log.error("Transaction commit threw runtime exception:", e); metrics.incrementCustom(FAILED_TX); throw e; } }
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); } }; } }
mgmt.commit(); return true; } catch (RuntimeException e) {
mgmt.commit(); return true; } catch (RuntimeException e) {
public void workerIterationEnd(ScanMetrics metrics) { try { if (null != mgmt && mgmt.isOpen()) mgmt.commit(); if (writeTx!=null && writeTx.isOpen()) writeTx.commit(); metrics.incrementCustom(SUCCESS_TX); } catch (RuntimeException e) { log.error("Transaction commit threw runtime exception:", e); metrics.incrementCustom(FAILED_TX); throw e; } }
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); } }; } }
/** * Create in the db model a new property and the class it uses. * * @param propertyName Entry name in the model. * @param c Class for the entry. */ private void makeIfNotExistProperty(String propertyName, Class<?> c) { ManagementSystem manager = (ManagementSystem) getTitanGraph().openManagement(); if (!manager.containsPropertyKey(propertyName)) { manager.makePropertyKey(propertyName).dataType(c).cardinality(Cardinality.SINGLE).make(); System.out.println("adding key " + propertyName); manager.commit(); } else { manager.rollback(); } }