/** * Attempt to retrieve a leader until one is found */ private void getLeader() { boolean found = getLeaderAttempt(); while (!found) { sleepRandom(); found = getLeaderAttempt(); } }
@Test public void testRestart() throws Exception { OracleClient client = env.getSharedResources().getOracleClient(); long ts1 = client.getStamp().getTxTimestamp(); long ts2 = client.getStamp().getTxTimestamp(); oserver.stop(); oserver.start(); long ts3 = client.getStamp().getTxTimestamp(); long ts4 = client.getStamp().getTxTimestamp(); assertTrue(ts1 + " " + ts2, ts1 < ts2); assertTrue(ts2 + " " + ts3, ts2 < ts3); assertTrue(ts3 + " " + ts4, ts3 < ts4); }
public CompletableFuture<Stamp> getStampAsync() { checkClosed(); TimeRequest tr = new TimeRequest(); CompletableFuture<Stamp> cf = new CompletableFuture<>(); tr.cf = cf; try { queue.put(tr); } catch (InterruptedException e) { throw new RuntimeException(e); } return cf; }
@Override public void run() { OracleClient oclient = env.getSharedResources().getOracleClient(); for (int i = 0; i < numToGet; i++) { try { output.add(oclient.getStamp().getTxTimestamp()); } catch (Exception e) { e.printStackTrace(); } } cdl.countDown(); } }
public TransactionImpl(Environment env, Notification trigger) { this(env, trigger, allocateTimestamp(env).getTxTimestamp()); }
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); } }
public synchronized OracleClient getOracleClient() { checkIfClosed(); if (oracleClient == null) { oracleClient = new OracleClient(env); } return oracleClient; }
/** * Atomically closes current connection and connects to the current leader */ private synchronized void reconnect() throws InterruptedException, TTransportException, KeeperException, IOException { if (transport.isOpen()) { transport.close(); } connect(); }
/** * Return the oracle that the current client is connected to. */ public synchronized String getOracle() { checkClosed(); return currentLeader != null ? currentLeader.getId() : null; }
@Override public Stamps getTimestamps(String id, int num) throws TException { long start = getTimestampsImpl(id, num); // do this outside of sync stampsHistogram.update(num); return new Stamps(start, gcTsTracker.advertisedGcTimetamp); }
public TransactionImpl(Environment env) { this(env, null, allocateTimestamp(env).getTxTimestamp()); }
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); } }
/** * Attempt to retrieve a leader until one is found */ private void getLeader() { boolean found = getLeaderAttempt(); while (!found) { sleepRandom(); found = getLeaderAttempt(); } }
public CompletableFuture<Stamp> getStampAsync() { checkClosed(); TimeRequest tr = new TimeRequest(); CompletableFuture<Stamp> cf = new CompletableFuture<>(); tr.cf = cf; try { queue.put(tr); } catch (InterruptedException e) { throw new RuntimeException(e); } return cf; }
public synchronized OracleClient getOracleClient() { checkIfClosed(); if (oracleClient == null) { oracleClient = new OracleClient(env); } return oracleClient; }
/** * Atomically closes current connection and connects to the current leader */ private synchronized void reconnect() throws InterruptedException, TTransportException, KeeperException, IOException { if (transport.isOpen()) { transport.close(); } connect(); }
/** * Return the oracle that the current client is connected to. */ public synchronized String getOracle() { checkClosed(); return currentLeader != null ? currentLeader.getId() : null; }
@Override public Stamps getTimestamps(String id, int num) throws TException { long start = getTimestampsImpl(id, num); // do this outside of sync stampsHistogram.update(num); return new Stamps(start, gcTsTracker.advertisedGcTimetamp); }
public TransactionImpl(Environment env) { this(env, null, allocateTimestamp(env).getTxTimestamp()); }
public TransactionImpl(Environment env, Notification trigger) { this(env, trigger, allocateTimestamp(env).getTxTimestamp()); }