@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"); }
@Override public String toString() { return super.toString() + " [" + element.toString() + "]"; }
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 String toString() { return super.toString() + " [" + element.toString() + "]"; }
@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); } } }
@Override public String toString() { return super.toString() + " [" + element.toString() + "]"; }
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; }
@Override public IDBlock call() { Stopwatch running = Stopwatch.createStarted(); try { if (stopRequested) { log.debug("Aborting ID block retrieval on partition({})-namespace({}) after " + "graceful shutdown was requested, exec time {}, exec+q time {}", partition, idNamespace, running.stop(), alive.stop()); throw new TitanException("ID block retrieval aborted by caller"); } IDBlock idBlock = idAuthority.getIDBlock(partition, idNamespace, renewTimeout); log.debug("Retrieved ID block from authority on partition({})-namespace({}), " + "exec time {}, exec+q time {}", partition, idNamespace, running.stop(), alive.stop()); Preconditions.checkArgument(idBlock!=null && idBlock.numIds()>0); return idBlock; } catch (BackendException e) { throw new TitanException("Could not acquire new ID block from storage", e); } catch (IDPoolExhaustedException e) { return ID_POOL_EXHAUSTION; } } }
String msg = String.format("ID block allocation on partition(%d)-namespace(%d) failed with an exception in %s", partition, idNamespace, sw.stop()); throw new TitanException(msg, e); } catch (TimeoutException e) { String msg = String.format("ID block allocation on partition(%d)-namespace(%d) timed out in %s", throw new TitanException(msg, e); } catch (CancellationException e) { String msg = String.format("ID block allocation on partition(%d)-namespace(%d) was cancelled after %s", partition, idNamespace, sw.stop()); throw new TitanException(msg, e); } finally { idBlockFuture = null;
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; }
subresult = call.call(sublimit); } catch (Exception e) { throw new TitanException("Could not process individual retrieval call ", e);