public static final Counters getInstance() { if ( counters != null ) { return counters; } counters = new Counters(); return counters; }
public synchronized void clearNextIDCounters() { Counters.getInstance().clear(); }
public synchronized LongObjectId getNextID( String tableName, String fieldName ) throws KettleException { String counterName = tableName + "." + fieldName; Counter counter = Counters.getInstance().getCounter( counterName ); if ( counter == null ) { LongObjectId id = getNextTableID( tableName, fieldName ); counter = new Counter( id.longValue() ); Counters.getInstance().setCounter( counterName, counter ); return new LongObjectId( counter.next() ); } else { return new LongObjectId( counter.next() ); } }
public synchronized void rollback() { try { database.rollback(); // Also, clear the counters, reducing the risk of collisions! // Counters.getInstance().clear(); } catch ( KettleException dbe ) { log.logError( "Error rolling back repository." ); } }
public synchronized void commit() throws KettleException { try { closeJobAttributeInsertPreparedStatement(); closeStepAttributeInsertPreparedStatement(); closeTransAttributeInsertPreparedStatement(); if ( !database.isAutoCommit() ) { database.commit(); } // Also, clear the counters, reducing the risk of collisions! // Counters.getInstance().clear(); } catch ( KettleException dbe ) { throw new KettleException( "Unable to commit repository connection", dbe ); } }