private Stamp getTimestamp() { return env.getSharedResources().getOracleClient().getStamp(); }
public synchronized OracleClient getOracleClient() { checkIfClosed(); if (oracleClient == null) { oracleClient = new OracleClient(env); } return oracleClient; }
/** * Return the oracle that the current client is connected to. */ public synchronized String getOracle() { checkClosed(); return currentLeader != null ? currentLeader.getId() : null; }
@Override public synchronized void close() { isClosed = true; if (tnode != null) { tnode.close(); } if (tsTracker != null) { tsTracker.close(); } if (transactorCache != null) { transactorCache.close(); } if (oracleClient != null) { oracleClient.close(); } cw.close(); bulkCw.close(); sbw.close(); try { bw.close(); } catch (MutationsRejectedException e) { throw new RuntimeException(e); } curator.close(); }
private synchronized void connect() throws IOException, KeeperException, InterruptedException, TTransportException { getLeader(); while (true) { log.debug("Connecting to oracle at " + currentLeader.getId()); String[] hostAndPort = currentLeader.getId().split(":"); String host = hostAndPort[0]; int port = Integer.parseInt(hostAndPort[1]); try { transport = new TFastFramedTransport(new TSocket(host, port)); transport.open(); TProtocol protocol = new TCompactProtocol(transport); client = new OracleService.Client(protocol); log.info("Connected to oracle at " + getOracle()); break; } catch (TTransportException e) { sleepRandom(); getLeader(); } catch (Exception e) { throw new RuntimeException(e); } } }
log.info("The wait command will exit when all notifications are processed"); while (true) { long ts1 = env.getSharedResources().getOracleClient().getStamp().getTxTimestamp(); long ntfyCount = countNotifications(env); long ts2 = env.getSharedResources().getOracleClient().getStamp().getTxTimestamp(); if (ntfyCount == 0 && ts1 == (ts2 - 1)) { log.info("All processing has finished!");
checkClosed(); long waitTotal = 0; while (!tr.cdl.await(waitPeriod, TimeUnit.SECONDS)) { checkClosed(); waitTotal += waitPeriod; if (waitPeriod < MAX_ORACLE_WAIT_PERIOD) {
Stamp commitStamp = env.getSharedResources().getOracleClient().getStamp(); if (commitPrimaryColumn(cd, commitStamp)) { long t3 = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
private synchronized void close(boolean checkForStaleScan) { if (status != TxStatus.CLOSED) { status = TxStatus.CLOSED; if (checkForStaleScan && !commitAttempted) { Stamp stamp = env.getSharedResources().getOracleClient().getStamp(); if (startTs < stamp.getGcTimestamp()) { throw new StaleScanException(); } } env.getSharedResources().getTimestampTracker().removeTimestamp(startTs); } }