@Override public R call() throws Exception { return execute(exe,provider,times); } @Override
public static<R> R execute(final Transactional<R> exe, final TransactionalProvider provider, final TimestampProvider times, Duration maxTime) throws JanusGraphException { return execute(new Callable<R>() { @Override public R call() throws Exception { return execute(exe,provider,times); } @Override public String toString() { return exe.toString(); } },maxTime); }
private int persist(final Map<String, Map<StaticBuffer, KCVMutation>> subMutations) { BackendOperation.execute(new Callable<Boolean>() { @Override public Boolean call() throws Exception { manager.mutateMany(subMutations, tx); return true; } @Override public String toString() { return "CacheMutation"; } }, maxWriteTime); subMutations.clear(); return 0; }
private <V> V executeRead(Callable<V> exe) throws JanusGraphException { try { return BackendOperation.execute(exe, maxReadTime); } catch (JanusGraphException e) { // support traversal interruption // TODO: Refactor to allow direct propagation of underlying interrupt exception if (Thread.interrupted()) throw new TraversalInterruptedException(); throw e; } }
private void flushInternal() throws BackendException { if (mutations!=null && !mutations.isEmpty()) { //Consolidate all mutations prior to persistence to ensure that no addition accidentally gets swallowed by a delete for (Map<String, IndexMutation> store : mutations.values()) { for (IndexMutation mut : store.values()) mut.consolidate(); } BackendOperation.execute(new Callable<Boolean>() { @Override public Boolean call() throws Exception { index.mutate(mutations, keyInformation, indexTx); return true; } @Override public String toString() { return "IndexMutation"; } }, maxWriteTime); mutations=null; } }
boolean success=BackendOperation.execute(new BackendOperation.Transactional<Boolean>() { @Override public Boolean call(StoreTransaction txh) throws BackendException {
private void writeSetting(String identifier, final StaticBuffer column, long value) { final StaticBuffer key = getSettingKey(identifier); final Entry add = StaticArrayEntry.of(column, BufferUtil.getLongBuffer(value)); Boolean status = BackendOperation.execute(new BackendOperation.Transactional<Boolean>() { @Override public Boolean call(StoreTransaction txh) throws BackendException { store.mutate(key,ImmutableList.of(add),KeyColumnValueStore.NO_DELETIONS,txh); return Boolean.TRUE; } @Override public String toString() { return "writingLogSetting"; } },this, times, maxWriteTime); Preconditions.checkState(status); }
private long readSetting(String identifier, final StaticBuffer column, long defaultValue) { final StaticBuffer key = getSettingKey(identifier); StaticBuffer value = BackendOperation.execute(new BackendOperation.Transactional<StaticBuffer>() { @Override public StaticBuffer call(StoreTransaction txh) throws BackendException { return KCVSUtil.get(store,key,column,txh); } @Override public String toString() { return "readingLogSetting"; } },this,times,maxReadTime); if (value==null) return defaultValue; else { Preconditions.checkArgument(value.length()==8); return value.getLong(0); } }
BackendOperation.execute(new BackendOperation.Transactional<Boolean>() { @Override public Boolean call(StoreTransaction txh) throws BackendException {
private Map<String,Object> toMap() { Map<String,Object> entries = Maps.newHashMap(); List<Entry> result = BackendOperation.execute(new BackendOperation.Transactional<List<Entry>>() { @Override public List<Entry> call(StoreTransaction txh) throws BackendException { return store.getSlice(new KeySliceQuery(rowKey, BufferUtil.zeroBuffer(1), BufferUtil.oneBuffer(128)),txh); } @Override public String toString() { return "setConfiguration"; } },txProvider, times, maxOperationWaitTime); for (Entry entry : result) { String key = staticBuffer2String(entry.getColumnAs(StaticBuffer.STATIC_FACTORY)); Object value = staticBuffer2Object(entry.getValueAs(StaticBuffer.STATIC_FACTORY), Object.class); entries.put(key,value); } return entries; }
private long getCurrentID(final StaticBuffer partitionKey) throws BackendException { final List<Entry> blocks = BackendOperation.execute( (BackendOperation.Transactional<List<Entry>>) txh -> idStore.getSlice(new KeySliceQuery(partitionKey, LOWER_SLICE, UPPER_SLICE).setLimit(5), txh),this,times); if (blocks == null) throw new TemporaryBackendException("Could not read from storage"); long latest = BASE_ID; for (Entry e : blocks) { long counterVal = getBlockValue(e); if (latest < counterVal) { latest = counterVal; } } return latest; }
TransactionLogHeader txHeader = new TransactionLogHeader(txCounter.incrementAndGet(),times.getTime(), times); final StaticBuffer userLogContent = txHeader.serializeUserLog(serializer,commitEntry,txId); BackendOperation.execute(() -> { final Log userLog = graph.getBackend().getUserLog(logTxIdentifier); final Future<Message> env = userLog.add(userLogContent);
/** * Reads the configuration property for this StoreManager * * @param key Key identifying the configuration property * @return Value stored for the key or null if the configuration property has not (yet) been defined. */ @Override public <O> O get(final String key, final Class<O> dataType) { StaticBuffer column = string2StaticBuffer(key); final KeySliceQuery query = new KeySliceQuery(rowKey,column, BufferUtil.nextBiggerBuffer(column)); StaticBuffer result = BackendOperation.execute(new BackendOperation.Transactional<StaticBuffer>() { @Override public StaticBuffer call(StoreTransaction txh) throws BackendException { List<Entry> entries = store.getSlice(query,txh); if (entries.isEmpty()) return null; return entries.get(0).getValueAs(StaticBuffer.STATIC_FACTORY); } @Override public String toString() { return "getConfiguration"; } }, txProvider, times, maxOperationWaitTime); if (result==null) return null; return staticBuffer2Object(result, dataType); }
log.trace("Converted MessagePuller time window to {}", query); List<Entry> entries= BackendOperation.execute(getOperation(query),KCVSLog.this,times,maxReadTime); prepareMessageProcessing(entries); if (entries.size()>=maxReadMsg) { List<Entry> extraEntries = BackendOperation.execute(getOperation(query),KCVSLog.this,times,maxReadTime); prepareMessageProcessing(extraEntries);
target = getBlockApplication(nextEnd, writeTimer.getStartTime()); final StaticBuffer finalTarget = target; // copy for the inner class BackendOperation.execute(txh -> { idStore.mutate(partitionKey, Collections.singletonList(StaticArrayEntry.of(finalTarget)), KeyColumnValueStore.NO_DELETIONS, txh); return true; final List<Entry> blocks = BackendOperation.execute( (BackendOperation.Transactional<List<Entry>>) txh -> idStore.getSlice(new KeySliceQuery(partitionKey, slice[0], slice[1]), txh),this,times); if (blocks == null) throw new TemporaryBackendException("Could not read from storage"); try { final StaticBuffer finalTarget = target; // copy for the inner class BackendOperation.execute(txh -> { idStore.mutate(partitionKey, KeyColumnValueStore.NO_ADDITIONS, Collections.singletonList(finalTarget), txh); return true;
private void restoreExternalIndexes(Predicate<String> isFailedIndex, TransactionLogHeader.Entry entry) { BackendOperation.execute(() -> { final StandardJanusGraphTx tx = (StandardJanusGraphTx) graph.newTransaction(); try { BackendTransaction btx = tx.getTxHandle(); final IndexTransaction indexTx = btx.getIndexTransaction(indexName); BackendOperation.execute(new Callable<Boolean>() { @Override public Boolean call() throws Exception {