if (get) { try (Table table = sharedConnection.getTable(tableName)){ Stopwatch stopWatch = Stopwatch.createStarted(); for (int i = 0; i < namespaceSpan; i++) { byte [] b = format(rd.nextLong()); Stopwatch stopWatch = Stopwatch.createStarted(); for (int i = 0; i < namespaceSpan; i++) { byte [] b = format(rd.nextLong());
/** * Ensure passed zookeeper is connected. * @param timeout Time to wait on established Connection */ public static ZooKeeper ensureConnectedZooKeeper(ZooKeeper zookeeper, int timeout) throws ZooKeeperConnectionException { if (zookeeper.getState().isConnected()) { return zookeeper; } Stopwatch stopWatch = Stopwatch.createStarted(); // Make sure we are connected before we hand it back. while(!zookeeper.getState().isConnected()) { Threads.sleep(1); if (stopWatch.elapsed(TimeUnit.MILLISECONDS) > timeout) { throw new ZooKeeperConnectionException("Failed connect after waiting " + stopWatch.elapsed(TimeUnit.MILLISECONDS) + "ms (zk session timeout); " + zookeeper); } } return zookeeper; } }
@Override protected int doWork() throws Exception { generateRegionsAndServers(); String methodName = "roundRobinAssignment"; LOG.info("Calling " + methodName); Stopwatch watch = Stopwatch.createStarted(); loadBalancer.roundRobinAssignment(regions, servers); System.out.print(formatResults(methodName, watch.elapsed(TimeUnit.MILLISECONDS))); methodName = "retainAssignment"; LOG.info("Calling " + methodName); watch.reset().start(); loadBalancer.retainAssignment(regionServerMap, servers); System.out.print(formatResults(methodName, watch.elapsed(TimeUnit.MILLISECONDS))); methodName = "balanceCluster"; LOG.info("Calling " + methodName); watch.reset().start(); loadBalancer.balanceCluster(serverRegionMap); System.out.print(formatResults(methodName, watch.elapsed(TimeUnit.MILLISECONDS))); return EXIT_SUCCESS; }
if (get) { try (Table table = sharedConnection.getTable(tableName)){ Stopwatch stopWatch = Stopwatch.createStarted(); for (int i = 0; i < namespaceSpan; i++) { byte [] b = format(rd.nextLong()); Stopwatch stopWatch = Stopwatch.createStarted(); for (int i = 0; i < namespaceSpan; i++) { byte [] b = format(rd.nextLong());
/** * Ensure passed zookeeper is connected. * @param timeout Time to wait on established Connection */ public static ZooKeeper ensureConnectedZooKeeper(ZooKeeper zookeeper, int timeout) throws ZooKeeperConnectionException { if (zookeeper.getState().isConnected()) { return zookeeper; } Stopwatch stopWatch = Stopwatch.createStarted(); // Make sure we are connected before we hand it back. while(!zookeeper.getState().isConnected()) { Threads.sleep(1); if (stopWatch.elapsed(TimeUnit.MILLISECONDS) > timeout) { throw new ZooKeeperConnectionException("Failed connect after waiting " + stopWatch.elapsed(TimeUnit.MILLISECONDS) + "ms (zk session timeout); " + zookeeper); } } return zookeeper; } }
public static final SleepingStopwatch createFromSystemTimer() { return new SleepingStopwatch() { final Stopwatch stopwatch = Stopwatch.createStarted(); @Override protected long readMicros() { return stopwatch.elapsed(MICROSECONDS); } @Override protected void sleepMicrosUninterruptibly(long micros) { if (micros > 0) { Uninterruptibles.sleepUninterruptibly(micros, MICROSECONDS); } } }; } }
/** * Attempts to start the timer immediately prior to the service being started via * {@link Service#startAsync()}. */ void tryStartTiming(Service service) { monitor.enter(); try { Stopwatch stopwatch = startupTimers.get(service); if (stopwatch == null) { startupTimers.put(service, Stopwatch.createStarted()); } } finally { monitor.leave(); } }
checkNotNull(loader); checkNotNull(keys); Stopwatch stopwatch = Stopwatch.createStarted(); Map<K, V> result; boolean success = false;
/** * Ensure passed zookeeper is connected. * @param timeout Time to wait on established Connection */ public static ZooKeeper ensureConnectedZooKeeper(ZooKeeper zookeeper, int timeout) throws ZooKeeperConnectionException { if (zookeeper.getState().isConnected()) { return zookeeper; } Stopwatch stopWatch = Stopwatch.createStarted(); // Make sure we are connected before we hand it back. while(!zookeeper.getState().isConnected()) { Threads.sleep(1); if (stopWatch.elapsed(TimeUnit.MILLISECONDS) > timeout) { throw new ZooKeeperConnectionException("Failed connect after waiting " + stopWatch.elapsed(TimeUnit.MILLISECONDS) + "ms (zk session timeout); " + zookeeper); } } return zookeeper; } }
@Override protected int doWork() throws Exception { generateRegionsAndServers(); String methodName = "roundRobinAssignment"; LOG.info("Calling " + methodName); Stopwatch watch = Stopwatch.createStarted(); loadBalancer.roundRobinAssignment(regions, servers); System.out.print(formatResults(methodName, watch.elapsed(TimeUnit.MILLISECONDS))); methodName = "retainAssignment"; LOG.info("Calling " + methodName); watch.reset().start(); loadBalancer.retainAssignment(regionServerMap, servers); System.out.print(formatResults(methodName, watch.elapsed(TimeUnit.MILLISECONDS))); methodName = "balanceCluster"; LOG.info("Calling " + methodName); watch.reset().start(); loadBalancer.balanceCluster(serverRegionMap); System.out.print(formatResults(methodName, watch.elapsed(TimeUnit.MILLISECONDS))); return EXIT_SUCCESS; }
if (stopwatch == null) { stopwatch = Stopwatch.createStarted(); startupTimers.put(service, stopwatch);