private void waitForGcTime(long expectedTime) throws Exception { env.getSharedResources().getTimestampTracker().updateZkNode(); long oldestTs = ZookeeperUtil.getGcTimestamp(config.getAppZookeepers()); while (oldestTs < expectedTime) { Thread.sleep(500); oldestTs = ZookeeperUtil.getGcTimestamp(config.getAppZookeepers()); } }
public static boolean isInitialized(FluoConfiguration config) { try (CuratorFramework rootCurator = CuratorUtil.newRootFluoCurator(config)) { rootCurator.start(); String appRootDir = ZookeeperUtil.parseRoot(config.getAppZookeepers()); return rootCurator.checkExists().forPath(appRootDir) != null; } catch (Exception e) { throw new IllegalStateException(e); } }
/** * Creates a curator built using Fluo's zookeeper connection string. Root path will start at root * "/" of Zookeeper. */ public static CuratorFramework newRootFluoCurator(FluoConfiguration config) { return newCurator(ZookeeperUtil.parseServers(config.getInstanceZookeepers()), config.getZookeeperTimeout(), config.getZookeeperSecret()); }
/** * Creates a curator built using Fluo's zookeeper connection string. Root path will start at root * "/" of Zookeeper. */ public static CuratorFramework newRootFluoCurator(FluoConfiguration config) { return newCurator(ZookeeperUtil.parseServers(config.getInstanceZookeepers()), config.getZookeeperTimeout(), config.getZookeeperSecret()); }
public static boolean isInitialized(FluoConfiguration config) { try (CuratorFramework rootCurator = CuratorUtil.newRootFluoCurator(config)) { rootCurator.start(); String appRootDir = ZookeeperUtil.parseRoot(config.getAppZookeepers()); return rootCurator.checkExists().forPath(appRootDir) != null; } catch (Exception e) { throw new IllegalStateException(e); } }
@Override public void init(SortedKeyValueIterator<Key, Value> source, Map<String, String> options, IteratorEnvironment env) throws IOException { if (env.getIteratorScope() == IteratorScope.scan) { throw new IllegalArgumentException(); } this.source = source; isFullMajc = env.getIteratorScope() == IteratorScope.majc && env.isFullMajorCompaction(); String oats = options.get(GC_TIMESTAMP_OPT); if (oats != null) { gcTimestamp = Long.valueOf(oats); } else { String zookeepers = options.get(ZOOKEEPER_CONNECT_OPT); if (zookeepers == null) { throw new IllegalArgumentException("A configuration item for GC iterator was not set"); } gcTimestamp = ZookeeperUtil.getGcTimestamp(zookeepers); } }
public FluoAdminImpl(FluoConfiguration config) { this.config = config; appRootDir = ZookeeperUtil.parseRoot(config.getAppZookeepers()); rootCurator = CuratorUtil.newRootFluoCurator(config); rootCurator.start(); }
@Test public void testGetOldestTimestamp() throws Exception { // we are expecting an error in this test final Level curLevel = Logger.getLogger(ZookeeperUtil.class).getLevel(); Logger.getLogger(ZookeeperUtil.class).setLevel(Level.FATAL); // verify that oracle initial current ts Assert.assertEquals(0, ZookeeperUtil.getGcTimestamp(config.getAppZookeepers())); // delete the oracle current timestamp path env.getSharedResources().getCurator().delete().forPath(ZookeeperPath.ORACLE_GC_TIMESTAMP); // verify that oldest possible is returned Assert.assertEquals(ZookeeperUtil.OLDEST_POSSIBLE, ZookeeperUtil.getGcTimestamp(config.getAppZookeepers())); // set level back Logger.getLogger(ZookeeperUtil.class).setLevel(curLevel); }
public FluoAdminImpl(FluoConfiguration config) { this.config = config; appRootDir = ZookeeperUtil.parseRoot(config.getAppZookeepers()); rootCurator = CuratorUtil.newRootFluoCurator(config); rootCurator.start(); }
long oldestTS = ZookeeperUtil.getGcTimestamp(config.getAppZookeepers()); oldestTS = ZookeeperUtil.getGcTimestamp(config.getAppZookeepers());
@Test public void testInitializeLongChroot() throws Exception { // stop oracle to avoid spurious exceptions when initializing oserver.stop(); String zk = config.getAppZookeepers(); String longPath = "/very/long/path"; config.setInstanceZookeepers(zk + longPath); InitializationOptions opts = new InitializationOptions(); opts.setClearZookeeper(true).setClearTable(true); try (FluoAdmin admin = new FluoAdminImpl(config)) { admin.initialize(opts); } try (CuratorFramework curator = CuratorUtil.newRootFluoCurator(config)) { curator.start(); Assert.assertNotNull(curator.checkExists().forPath(ZookeeperUtil.parseRoot(zk + longPath))); } String longPath2 = "/very/long/path2"; config.setInstanceZookeepers(zk + longPath2); try (FluoAdmin admin = new FluoAdminImpl(config)) { admin.initialize(opts); } try (CuratorFramework curator = CuratorUtil.newRootFluoCurator(config)) { curator.start(); Assert.assertNotNull(curator.checkExists().forPath(ZookeeperUtil.parseRoot(zk + longPath2))); Assert.assertNotNull(curator.checkExists().forPath(ZookeeperUtil.parseRoot(zk + longPath))); } }
LongUtil.toByteArray(nextTs)); long gcTs = ZookeeperUtil.getGcTimestamp(config.getAppZookeepers()); while (gcTs < nextTs) { Thread.sleep(500); gcTs = ZookeeperUtil.getGcTimestamp(config.getAppZookeepers());
!ZookeeperUtil.parseRoot(config.getInstanceZookeepers()).equals("/"), "The Zookeeper connection string (set by 'fluo.connection.zookeepers') " + " must have a chroot suffix.");
public void testVerifyAfterGC() throws Exception { final TestTransaction tx1 = new TestTransaction(env); BankUtil.setBalance(tx1, "bob", 10); BankUtil.setBalance(tx1, "joe", 20); BankUtil.setBalance(tx1, "jill", 60); tx1.done(); BankUtil.transfer(env, "joe", "jill", 1); BankUtil.transfer(env, "joe", "bob", 1); BankUtil.transfer(env, "bob", "joe", 2); BankUtil.transfer(env, "jill", "joe", 2); final TestTransaction tx2 = new TestTransaction(env); waitForGcTime(tx2.getStartTimestamp()); long oldestTs = ZookeeperUtil.getGcTimestamp(config.getAppZookeepers()); Assert.assertEquals(tx2.getStartTs(), oldestTs); // Force a garbage collection aClient.tableOperations().flush(table, null, null, true); verify(oldestTs); final TestTransaction tx3 = new TestTransaction(env); Assert.assertEquals(9, BankUtil.getBalance(tx3, "bob")); Assert.assertEquals(22, BankUtil.getBalance(tx3, "joe")); Assert.assertEquals(59, BankUtil.getBalance(tx3, "jill")); tx3.done(); tx2.done(); }
!ZookeeperUtil.parseRoot(config.getInstanceZookeepers()).equals("/"), "The Zookeeper connection string (set by 'fluo.connection.zookeepers') " + " must have a chroot suffix.");
!ZookeeperUtil.parseRoot(config.getInstanceZookeepers()).equals("/"), "The Zookeeper connection string (set by 'fluo.connection.zookeepers') " + " must have a chroot suffix.");
!ZookeeperUtil.parseRoot(config.getInstanceZookeepers()).equals("/"), "The Zookeeper connection string (set by 'fluo.connection.zookeepers') " + " must have a chroot suffix.");