@Override public void close() { try { if (oserver != null) { notificationFinder.stop(); mnp.close(); oserver.stop(); env.close(); reporter.close(); if (cluster != null) { cluster.stop(); } } } catch (Exception e) { throw new RuntimeException(e); } }
private synchronized long getTimestampsImpl(String id, int num) throws TException { if (!started) { throw new IllegalStateException("Received timestamp request but Oracle has not started"); } if (!id.equals(env.getFluoApplicationID())) { throw new IllegalArgumentException("Received timestamp request with a Fluo application ID [" + id + "] that does not match the application ID [" + env.getFluoApplicationID() + "] of the Oracle"); } if (!isLeader) { throw new IllegalStateException("Received timestamp request but Oracle is not leader"); } try { while (num + currentTs >= maxTs) { allocateTimestamp(); } long tmp = currentTs; currentTs += num; return tmp; } catch (Exception e) { throw new TException(e); } }
@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); }
env.getConfiguration().print(); OracleServer server = new OracleServer(env); server.start(); server.stop();
public MiniFluoImpl(FluoConfiguration fluoConfig) { if (!fluoConfig.hasRequiredMiniFluoProps()) { throw new IllegalArgumentException("MiniFluo configuration is not valid"); } config = fluoConfig; try { if (config.getMiniStartAccumulo()) { startMiniAccumulo(); } config.setProperty(FluoConfigurationImpl.MIN_SLEEP_TIME_PROP, 50); config.setProperty(FluoConfigurationImpl.MAX_SLEEP_TIME_PROP, 100); env = new Environment(config); reporter = FluoClientImpl.setupReporters(env, "mini", reporterCounter); oserver = new OracleServer(env); oserver.start(); mnp = new MiniNotificationProcessor(env); notificationFinder = NotificationFinderFactory.newNotificationFinder(env.getConfiguration()); notificationFinder.init(env, mnp); notificationFinder.start(); } catch (Exception e) { throw new RuntimeException(e); } }
@Override public void childEvent(CuratorFramework curatorFramework, PathChildrenCacheEvent event) throws Exception { try { if (isConnected() && (event.getType().equals(PathChildrenCacheEvent.Type.CHILD_ADDED) || event.getType().equals(PathChildrenCacheEvent.Type.CHILD_REMOVED) || event .getType().equals(PathChildrenCacheEvent.Type.CHILD_UPDATED))) { synchronized (this) { Participant participant = leaderSelector.getLeader(); if (isLeader(participant) && !leaderSelector.hasLeadership()) { // in case current instance becomes leader, we want to know who came before it. currentLeader = participant; } } } } catch (InterruptedException e) { log.warn("Oracle leadership watcher has been interrupted unexpectedly"); } }
int port = Integer.parseInt(address[1]); OracleService.Client client = getOracleClient(host, port); if (client != null) { try {
public synchronized void start() throws Exception { if (started) { throw new IllegalStateException(); } final InetSocketAddress addr = startServer(); curatorFramework = CuratorUtil.newAppCurator(env.getConfiguration()); curatorFramework.getConnectionStateListenable().addListener(cnxnListener); curatorFramework.start(); while (!cnxnListener.isConnected()) { Thread.sleep(200); } leaderSelector = new LeaderSelector(curatorFramework, ZookeeperPath.ORACLE_SERVER, this); String leaderId = HostUtil.getHostName() + ":" + addr.getPort(); leaderSelector.setId(leaderId); log.info("Leader ID = " + leaderId); leaderSelector.start(); pathChildrenCache = new PathChildrenCache(curatorFramework, oraclePath, true); pathChildrenCache.getListenable().addListener(this); pathChildrenCache.start(); while (!cnxnListener.isConnected()) { Thread.sleep(200); } log.info("Listening " + addr); started = true; }