@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(); } }
private Stamp getTimestamp() { return env.getSharedResources().getOracleClient().getStamp(); }
protected CompletableFuture<Stamp> getStampOp() { return env.getSharedResources().getOracleClient().getStampAsync(); }
private Stamp getTimestamp() { return env.getSharedResources().getOracleClient().getStamp(); }
protected CompletableFuture<Stamp> getStampOp() { return env.getSharedResources().getOracleClient().getStampAsync(); }
/** * Test that bogus input into the oracle server doesn't cause an OOM exception. This essentially * tests for THRIFT-602 */ @Test public void bogusDataTest() throws Exception { Socket socket = new Socket(); socket.connect(new InetSocketAddress(HostUtil.getHostName(), oserver.getPort())); OutputStream outstream = socket.getOutputStream(); try (PrintWriter out = new PrintWriter(outstream)) { out.print("abcd"); out.flush(); } socket.close(); OracleClient client = env.getSharedResources().getOracleClient(); assertEquals(2, client.getStamp().getTxTimestamp()); }
public void waitUntilFinished(FluoConfiguration config) { try (Environment env = new Environment(config)) { 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!"); break; } try { long sleepSec = calculateSleep(ntfyCount, org.apache.fluo.cluster.util.FluoYarnConfig.getWorkerInstances(config)); log.info("{} notifications are still outstanding. Will try again in {} seconds...", ntfyCount, sleepSec); Thread.sleep(1000 * sleepSec); } catch (InterruptedException e) { log.error("Sleep was interrupted! Exiting..."); System.exit(-1); } } } catch (FluoException e) { log.error(e.getMessage()); System.exit(-1); } catch (Exception e) { log.error("An exception was thrown -", e); System.exit(-1); } }
public void waitUntilFinished(FluoConfiguration config) { try (Environment env = new Environment(config)) { 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!"); break; } try { long sleepSec = calculateSleep(ntfyCount, org.apache.fluo.cluster.util.FluoYarnConfig.getWorkerInstances(config)); log.info("{} notifications are still outstanding. Will try again in {} seconds...", ntfyCount, sleepSec); Thread.sleep(1000 * sleepSec); } catch (InterruptedException e) { log.error("Sleep was interrupted! Exiting..."); System.exit(-1); } } } catch (FluoException e) { log.error(e.getMessage()); System.exit(-1); } catch (Exception e) { log.error("An exception was thrown -", e); System.exit(-1); } }
@Override public void waitForObservers() { try { Scanner scanner = env.getConnector().createScanner(env.getTable(), env.getAuthorizations()); Notification.configureScanner(scanner); while (true) { long ts1 = env.getSharedResources().getOracleClient().getStamp().getTxTimestamp(); long ntfyCount = Iterables.size(scanner); long ts2 = env.getSharedResources().getOracleClient().getStamp().getTxTimestamp(); if (ntfyCount == 0 && ts1 == (ts2 - 1)) { break; } long sleepTime = ntfyCount / 2; sleepTime = Math.min(Math.max(10, sleepTime), 10000); Uninterruptibles.sleepUninterruptibly(sleepTime, TimeUnit.MILLISECONDS); } } catch (Exception e) { throw new RuntimeException(e); } }
@Override public void waitForObservers() { try { Scanner scanner = env.getAccumuloClient().createScanner(env.getTable(), env.getAuthorizations()); Notification.configureScanner(scanner); while (true) { long ts1 = env.getSharedResources().getOracleClient().getStamp().getTxTimestamp(); long ntfyCount = Iterables.size(scanner); long ts2 = env.getSharedResources().getOracleClient().getStamp().getTxTimestamp(); if (ntfyCount == 0 && ts1 == (ts2 - 1)) { break; } long sleepTime = ntfyCount / 2; sleepTime = Math.min(Math.max(10, sleepTime), 10000); Uninterruptibles.sleepUninterruptibly(sleepTime, TimeUnit.MILLISECONDS); } } catch (Exception e) { throw new RuntimeException(e); } }
/** * Wait until a scan of the table completes without seeing notifications AND without the Oracle * issuing any timestamps during the scan. */ private static void waitUntilFinished(FluoConfiguration config) { try (Environment env = new Environment(config)) { List<TableRange> ranges = getRanges(env); outer: while (true) { long ts1 = env.getSharedResources().getOracleClient().getStamp().getTxTimestamp(); for (TableRange range : ranges) { boolean sawNotifications = waitTillNoNotifications(env, range); if (sawNotifications) { ranges = getRanges(env); // This range had notifications. Processing those notifications may have created // notifications in previously scanned ranges, so start over. continue outer; } } long ts2 = env.getSharedResources().getOracleClient().getStamp().getTxTimestamp(); // Check to ensure the Oracle issued no timestamps during the scan for notifications. if (ts2 - ts1 == 1) { break; } } } catch (Exception e) { log.error("An exception was thrown -", e); System.exit(-1); } }
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); } }
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); } }
private TransactorNode partiallyCommit(Consumer<TransactionBase> action, boolean commitPrimary, boolean closeTransactor) throws Exception { TransactorNode t2 = new TransactorNode(env); TestTransaction tx2 = new TestTransaction(env, t2); action.accept(tx2); CommitData cd = tx2.createCommitData(); Assert.assertTrue(tx2.preCommit(cd)); if (commitPrimary) { Stamp commitTs = env.getSharedResources().getOracleClient().getStamp(); Assert.assertTrue(tx2.commitPrimaryColumn(cd, commitTs)); } if (closeTransactor) { t2.close(); } return t2; }
/** * If an {@link OracleServer} goes away and comes back, the client should automatically reconnect * and start a new block of timestamps (making sure that no timestamp should ever go backwards). */ @Test public void singleOracle_goesAwayAndComesBack() throws Exception { sleepUntil(oserver::isConnected); OracleClient client = env.getSharedResources().getOracleClient(); long timestamp; for (long i = 2; i <= 7; i++) { timestamp = client.getStamp().getTxTimestamp(); assertEquals(i, timestamp); } oserver.stop(); sleepWhile(oserver::isConnected); while (client.getOracle() != null) { Thread.sleep(100); } assertNull(client.getOracle()); oserver.start(); sleepUntil(oserver::isConnected); assertEquals(1002, client.getStamp().getTxTimestamp()); assertTrue(client.getOracle().endsWith(Integer.toString(oserver.getPort()))); oserver.stop(); }
@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); }
Assert.assertTrue(tx6.preCommit(cd6)); Stamp commitTs5 = env.getSharedResources().getOracleClient().getStamp(); Assert.assertTrue(tx5.commitPrimaryColumn(cd5, commitTs5)); Stamp commitTs6 = env.getSharedResources().getOracleClient().getStamp(); Assert.assertTrue(tx6.commitPrimaryColumn(cd6, commitTs6));
@Test public void testAck2() throws Exception { final TestTransaction tx = new TestTransaction(env); final Column addrCol = new Column("account", "addr"); tx.set("bob", BALANCE, "10"); tx.set("joe", BALANCE, "20"); tx.set("jill", BALANCE, "60"); tx.done(); final TestTransaction tx1 = new TestTransaction(env, "bob", BALANCE); final TestTransaction tx2 = new TestTransaction(env, "bob", BALANCE); final TestTransaction tx3 = new TestTransaction(env, "bob", BALANCE); tx1.gets("bob", BALANCE); tx2.gets("bob", BALANCE); tx1.gets("bob", addrCol); tx2.gets("bob", addrCol); tx1.set("bob", addrCol, "1 loop pl"); tx2.set("bob", addrCol, "1 loop pl"); // this test overlaps the commits of two transactions w/ the same trigger CommitData cd = tx1.createCommitData(); Assert.assertTrue(tx1.preCommit(cd)); assertCommitFails(tx2); Stamp commitTs = env.getSharedResources().getOracleClient().getStamp(); Assert.assertTrue(tx1.commitPrimaryColumn(cd, commitTs)); tx1.finishCommit(cd, commitTs); tx1.close(); tx3.set("bob", addrCol, "2 loop pl"); assertAAck(tx3); }
Assert.assertTrue(tx.preCommit(cd)); Assert.assertTrue( tx.commitPrimaryColumn(cd, env.getSharedResources().getOracleClient().getStamp())); tx.close();
Stamp commitTs = env.getSharedResources().getOracleClient().getStamp(); tx3.commitPrimaryColumn(cd3, commitTs);