gcTsTracker = new GcTimestampTracker(); gcTsTracker.start();
private void updateGcTimestamp() throws Exception { List<String> children; try { children = curator.getChildren().forPath(ZookeeperPath.TRANSACTOR_TIMESTAMPS); } catch (NoNodeException nne) { children = Collections.emptyList(); } long oldestTs = Long.MAX_VALUE; boolean nodeFound = false; for (String child : children) { Long ts = LongUtil.fromByteArray( curator.getData().forPath(ZookeeperPath.TRANSACTOR_TIMESTAMPS + "/" + child)); nodeFound = true; if (ts < oldestTs) { oldestTs = ts; } } if (nodeFound) { updateAdvertisedGcTimestamp(oldestTs); } else { updateAdvertisedGcTimestamp(currentTs); } }
gcTsTracker = new GcTimestampTracker(); gcTsTracker.start();
public synchronized void stop() throws Exception { if (started) { isLeader = false; server.stop(); serverThread.join(); if (gcTsTracker != null) { gcTsTracker.stop(); } started = false; currentLeader = null; if (curatorFramework.getState().equals(CuratorFrameworkState.STARTED)) { pathChildrenCache.getListenable().removeListener(this); pathChildrenCache.close(); leaderLatch.close(); execService.shutdown(); execService.awaitTermination(10, TimeUnit.SECONDS); curatorFramework.getConnectionStateListenable().removeListener(cnxnListener); // leaderLatch.close() schedules a background delete, give it a chance to process before // closing curator... this is done to avoid spurious exceptions, see CURATOR-467 Uninterruptibles.sleepUninterruptibly(250, TimeUnit.MILLISECONDS); curatorFramework.close(); } log.info("Oracle server has been stopped."); } }
private void updateGcTimestamp() throws Exception { List<String> children; try { children = curator.getChildren().forPath(ZookeeperPath.TRANSACTOR_TIMESTAMPS); } catch (NoNodeException nne) { children = Collections.emptyList(); } long oldestTs = Long.MAX_VALUE; boolean nodeFound = false; for (String child : children) { Long ts = LongUtil.fromByteArray( curator.getData().forPath(ZookeeperPath.TRANSACTOR_TIMESTAMPS + "/" + child)); nodeFound = true; if (ts < oldestTs) { oldestTs = ts; } } if (nodeFound) { updateAdvertisedGcTimestamp(oldestTs); } else { updateAdvertisedGcTimestamp(currentTs); } }
public synchronized void stop() throws Exception { if (started) { server.stop(); serverThread.join(); if (gcTsTracker != null) { gcTsTracker.stop(); } started = false; currentLeader = null; if (curatorFramework.getState().equals(CuratorFrameworkState.STARTED)) { pathChildrenCache.getListenable().removeListener(this); pathChildrenCache.close(); leaderSelector.close(); curatorFramework.getConnectionStateListenable().removeListener(this); curatorFramework.close(); } log.info("Oracle server has been stopped."); } }