@Override public void lock(Duration timeout) { boolean success = false; try { success = super.tryLock(timeout.toNanos(), TimeUnit.NANOSECONDS); } catch (InterruptedException e) { log.warn("Interrupted waiting for lock: {}",e); } if (!success) throw new TitanException("Possible dead lock detected. Waited for transaction lock without success"); }
public Log getSystemMgmtLog() { try { return mgmtLogManager.openLog(SYSTEM_MGMT_LOG_NAME); } catch (BackendException e) { throw new TitanException("Could not re-open management log", e); } }
@Override public void add(StaticBuffer key, Entry cell) { try { kcvs.mutateEntries(key, Lists.newArrayList(cell), KCVSCache.NO_DELETIONS,tx); } catch (BackendException e) { throw new TitanException("Unexpected storage exception in log persistence against cache",e); } } }
public static final<V> V execute(Callable<V> exe, Duration totalWaitTime) throws TitanException { try { return executeDirect(exe,totalWaitTime); } catch (BackendException e) { throw new TitanException("Could not execute operation due to backend exception",e); } }
public KCVSLog getSystemTxLog() { try { return txLogManager.openLog(SYSTEM_TX_LOG_NAME); } catch (BackendException e) { throw new TitanException("Could not re-open transaction log", e); } }
private AdminMask getAdminInterface() { try { return cnx.getAdmin(); } catch (IOException e) { throw new TitanException(e); } }
public void closeLogManager(String logManagerName) { if (logManagers.containsKey(logManagerName)) { try { logManagers.remove(logManagerName).close(); } catch (BackendException e) { throw new TitanException("Could not close log manager " + logManagerName,e); } } }
@Override public synchronized void close() { closed=true; try { waitForIDBlockGetter(); } catch (InterruptedException e) { throw new TitanException("Interrupted while waiting for id renewer thread to finish", e); } for (Future<?> closeBlocker : closeBlockers) { try { closeBlocker.get(); } catch (InterruptedException e) { throw new TitanException("Interrupted while waiting for runaway ID renewer task " + closeBlocker, e); } catch (ExecutionException e) { log.debug("Runaway ID renewer task completed with exception", e); } } exec.shutdownNow(); }
@Override public synchronized void shutdown() throws TitanException { if (!isOpen) return; isOpen = false; try { try { for (Log log : processorLogs.values()) { log.close(); } processorLogs.clear(); } finally { } } catch (BackendException e) { throw new TitanException(e); } }
@Override public String getJobFailureString(Job j) { try { JobStatus js = j.getStatus(); return String.format("state=%s, failureinfo=%s", js.getState(), js.getFailureInfo()); } catch (IOException e) { throw new TitanException(e); } catch (InterruptedException e) { throw new TitanException(e); } } }
private void closeLogs() { try { for (LogManager lm : logManagers.values()) lm.close(); logManagers.clear(); if (logStoreManager!=null) { logStoreManager.close(); logStoreManager=null; } } catch (BackendException e) { throw new TitanException(e); } }
@Override public synchronized boolean removeLogProcessor(String logIdentifier) { checkOpen(); if (processorLogs.containsKey(logIdentifier)) { try { processorLogs.get(logIdentifier).close(); } catch (BackendException e) { throw new TitanException("Could not close transaction log: "+ logIdentifier,e); } processorLogs.remove(logIdentifier); return true; } else return false; }
public final Partitioner getPartitioner() { if (partitioner == null) { try { partitioner = Partitioner.getPartitioner(getCassandraPartitioner()); } catch (BackendException e) { throw new TitanException("Could not connect to Cassandra to read partitioner information. Please check the connection", e); } } assert partitioner != null; return partitioner; }
@Override public synchronized Future<Message> add(StaticBuffer content) { TestMessage msg = new TestMessage(content); FutureMessage<TestMessage> fmsg = new FutureMessage<TestMessage>(msg); if (failAdds) { System.out.println("Failed message add"); throw new TitanException("Log unavailable"); } if (readers.isEmpty()) { messageBacklog.add(fmsg); } else { process(fmsg); } return fmsg; }
public StandardTitanTx newTransaction(final TransactionConfiguration configuration) { if (!isOpen) ExceptionFactory.graphShutdown(); try { StandardTitanTx tx = new StandardTitanTx(this, configuration); tx.setBackendTransaction(openBackendTransaction(tx)); openTransactions.add(tx); return tx; } catch (BackendException e) { throw new TitanException("Could not start new transaction", e); } }
@Override public void close() { try { store.close(); txProvider.close(); IOUtils.closeQuietly(serializer); } catch (BackendException e) { throw new TitanException("Could not close configuration store",e); } }
private static KCVSConfiguration getConfiguration(final BackendOperation.TransactionalProvider txProvider, final KeyColumnValueStore store, final String identifier, final Configuration config) { try { KCVSConfiguration kcvsConfig = new KCVSConfiguration(txProvider,config,store,identifier); kcvsConfig.setMaxOperationWaitTime(config.get(SETUP_WAITTIME)); return kcvsConfig; } catch (BackendException e) { throw new TitanException("Could not open global configuration",e); } }
public static KCVSConfiguration getStandaloneGlobalConfiguration(final KeyColumnValueStoreManager manager, final Configuration config) { try { final StoreFeatures features = manager.getFeatures(); return getGlobalConfiguration(new BackendOperation.TransactionalProvider() { @Override public StoreTransaction openTx() throws BackendException { return manager.beginTransaction(StandardBaseTransactionConfig.of(config.get(TIMESTAMP_PROVIDER),features.getKeyConsistentTxConfig())); } @Override public void close() throws BackendException { manager.close(); } },manager.openDatabase(SYSTEM_PROPERTIES_STORE_NAME),config); } catch (BackendException e) { throw new TitanException("Could not open global configuration",e); } }
@Override public synchronized void rollback() { Preconditions.checkArgument(isOpen(), "The transaction has already been closed"); boolean success = false; if (null != config.getGroupName()) { MetricManager.INSTANCE.getCounter(config.getGroupName(), "tx", "rollback").inc(); } try { txHandle.rollback(); success = true; } catch (Exception e) { throw new TitanException("Could not rollback transaction due to exception", e); } finally { releaseTransaction(); if (null != config.getGroupName() && !success) { MetricManager.INSTANCE.getCounter(config.getGroupName(), "tx", "rollback.exceptions").inc(); } } }
@Override public synchronized long nextID() { assert currentIndex <= currentBlock.numIds(); if (currentIndex == currentBlock.numIds()) { try { nextBlock(); } catch (InterruptedException e) { throw new TitanException("Could not renew id block due to interruption", e); } } if (currentIndex == renewBlockIndex) { startIDBlockGetter(); } long returnId = currentBlock.getId(currentIndex); currentIndex++; if (returnId >= idUpperBound) throw new IDPoolExhaustedException("Reached id upper bound of " + idUpperBound); log.trace("partition({})-namespace({}) Returned id: {}", partition, idNamespace, returnId); return returnId; }