public static<R> R execute(Transactional<R> exe, TransactionalProvider provider, TimestampProvider times) throws BackendException { StoreTransaction txh = null; try { txh = provider.openTx(); if (!txh.getConfiguration().hasCommitTime()) txh.getConfiguration().setCommitTime(times.getTime()); return exe.call(txh); } catch (BackendException e) { if (txh!=null) txh.rollback(); txh=null; throw e; } finally { if (txh!=null) txh.commit(); } }
tx.commit(); Assert.assertEquals(ttls.length - 1, result.size()); tx.rollback(); result = store.getSlice(new KeySliceQuery(key, columnStart, columnEnd).setLimit(ttls.length), tx); tx.rollback(); result = store.getSlice(new KeySliceQuery(key, columnStart, columnEnd).setLimit(ttls.length), tx); tx.rollback(); result = store.getSlice(new KeySliceQuery(key, columnStart, columnEnd).setLimit(ttls.length), tx);
@Override public BaseTransactionConfig getConfiguration() { return inconsistentTx.getConfiguration(); }
@Override public void rollback() throws BackendException { clear(); tx.rollback(); }
@Override public BaseTransactionConfig getConfiguration() { return tx.getConfiguration(); }
@Override public void commit() throws BackendException { flushInternal(); tx.commit(); }
private void cleanup() throws BackendException { if (!hasCompleted) { hasCompleted = true; if (pullThreads!=null) { for (DataPuller pullThread : pullThreads) { if (pullThread.isAlive()) { pullThread.interrupt(); } } } storeTx.rollback(); } }
public MaskedTimestamp(StoreTransaction txh) { this(txh.getConfiguration().getCommitTime()); }
public void newTx() throws BackendException { if (tx!=null) tx.commit(); tx = startTx(); }
return executor; } catch (Throwable e) { storeTx.rollback(); throw e;
private Lock getLock(StoreTransaction txh) { Boolean txOn = txh.getConfiguration().getCustomOption(STORAGE_TRANSACTIONAL); if (null != txOn && txOn) { ReentrantLock result = lock; if (result == null) { synchronized (this) { result = lock; if (result == null) { lock = result = new ReentrantLock(); } } } return result; } else return NoLock.INSTANCE; }
public void close() throws BackendException { if (tx != null) tx.commit(); store.close(); manager.close(); }
public void checkSlice(String[][] values, Set<KeyColumn> removed, int key, int start, int end, int limit) throws BackendException { tx.rollback(); tx = startTx(); List<Entry> entries; if (limit <= 0) entries = store.getSlice(new KeySliceQuery(KeyValueStoreUtil.getBuffer(key), KeyValueStoreUtil.getBuffer(start), KeyValueStoreUtil.getBuffer(end)), tx); else entries = store.getSlice(new KeySliceQuery(KeyValueStoreUtil.getBuffer(key), KeyValueStoreUtil.getBuffer(start), KeyValueStoreUtil.getBuffer(end)).setLimit(limit), tx); int pos = 0; for (int i = start; i < end; i++) { if (removed.contains(new KeyColumn(key, i))) { log.debug("Skipping deleted ({},{})", key, i); continue; } if (limit <= 0 || pos < limit) { log.debug("Checking k={}[c_start={},c_end={}](limit={}): column index={}/pos={}", key, start, end, limit, i, pos); Assert.assertTrue(entries.size() > pos); Entry entry = entries.get(pos); int col = KeyValueStoreUtil.getID(entry.getColumn()); String str = KeyValueStoreUtil.getString(entry.getValueAs(StaticBuffer.STATIC_FACTORY)); Assert.assertEquals(i, col); Assert.assertEquals(values[key][i], str); } pos++; } Assert.assertNotNull(entries); if (limit > 0 && pos > limit) Assert.assertEquals(limit, entries.size()); else Assert.assertEquals(pos, entries.size()); }
private void recordSliceMetrics(StoreTransaction txh, List<Entry> row) { if (!txh.getConfiguration().hasGroupName()) return; String p = txh.getConfiguration().getGroupName(); final MetricManager mgr = MetricManager.INSTANCE; mgr.getCounter(p, metricsStoreName, M_GET_SLICE, M_ENTRIES_COUNT).inc(row.size()); mgr.getHistogram(p, metricsStoreName, M_GET_SLICE, M_ENTRIES_HISTO).update(row.size()); }
public void close() throws BackendException { if (tx != null) tx.commit(); if (null != store) store.close(); if (null != manager) manager.close(); }
protected void incActionBy(int by, CacheMetricsAction action, StoreTransaction txh) { assert by>=1; if (metricsName!=null && txh.getConfiguration().hasGroupName()) { MetricManager.INSTANCE.getCounter(txh.getConfiguration().getGroupName(), metricsName, action.getName()).inc(by); } }
public void close() throws BackendException { for (int i = 0; i < CONCURRENCY; i++) { store[i].close(); for (int j = 0; j < NUM_TX; j++) { log.debug("Committing tx[{}][{}] = {}", i, j, tx[i][j]); if (tx[i][j] != null) tx[i][j].commit(); } manager[i].close(); } LocalLockMediators.INSTANCE.clear(); }
@Override public KeyIterator getKeys(final SliceQuery query, final StoreTransaction txh) throws BackendException { return runWithMetrics(txh, metricsStoreName, M_GET_KEYS, () -> { final KeyIterator ki = backend.getKeys(query, txh); if (txh.getConfiguration().hasGroupName()) { return MetricInstrumentedIterator.of(ki, txh.getConfiguration().getGroupName(), metricsStoreName, M_GET_KEYS, M_ITERATOR); } else { return ki; } }); }