@Override public int hashCode() { return toString().hashCode(); }
@Override public boolean equals(Object o) { if (o instanceof ServerServices) return toString().equals(o.toString()); return false; }
private void getZooLock(HostAndPort addr) throws KeeperException, InterruptedException { String path = context.getZooKeeperRoot() + Constants.ZGC_LOCK; LockWatcher lockWatcher = new LockWatcher() { @Override public void lostLock(LockLossReason reason) { Halt.halt("GC lock in zookeeper lost (reason = " + reason + "), exiting!", 1); } @Override public void unableToMonitorLockNode(final Throwable e) { // ACCUMULO-3651 Level changed to error and FATAL added to message for slf4j compatibility Halt.halt(-1, new Runnable() { @Override public void run() { log.error("FATAL: No longer able to monitor lock node ", e); } }); } }; while (true) { lock = new ZooLock(context.getZooReaderWriter(), path); if (lock.tryLock(lockWatcher, new ServerServices(addr.toString(), Service.GC_CLIENT).toString().getBytes())) { log.debug("Got GC ZooKeeper lock"); return; } log.debug("Failed to get GC ZooKeeper lock, will retry"); sleepUninterruptibly(1, TimeUnit.SECONDS); } }
.toString().getBytes(UTF_8); for (int i = 0; i < 120 / 5; i++) { zoo.putPersistentData(zPath, new byte[0], NodeExistsPolicy.SKIP);
@Override public int hashCode() { return toString().hashCode(); }
private void getZooLock(HostAndPort addr) throws KeeperException, InterruptedException { String path = ZooUtil.getRoot(getInstance()) + Constants.ZGC_LOCK; LockWatcher lockWatcher = new LockWatcher() { @Override public void lostLock(LockLossReason reason) { Halt.halt("GC lock in zookeeper lost (reason = " + reason + "), exiting!", 1); } @Override public void unableToMonitorLockNode(final Throwable e) { // ACCUMULO-3651 Level changed to error and FATAL added to message for slf4j compatibility Halt.halt(-1, new Runnable() { @Override public void run() { log.error("FATAL: No longer able to monitor lock node ", e); } }); } }; while (true) { lock = new ZooLock(path); if (lock.tryLock(lockWatcher, new ServerServices(addr.toString(), Service.GC_CLIENT).toString().getBytes())) { log.debug("Got GC ZooKeeper lock"); return; } log.debug("Failed to get GC ZooKeeper lock, will retry"); sleepUninterruptibly(1, TimeUnit.SECONDS); } }
byte[] lockContent = new ServerServices(getClientAddressString(), Service.TSERV_CLIENT).toString().getBytes(UTF_8); for (int i = 0; i < 120 / 5; i++) { zoo.putPersistentData(zPath, new byte[0], NodeExistsPolicy.SKIP);
private void getZooLock(InetSocketAddress addr) throws KeeperException, InterruptedException { String address = AddressUtil.toString(addr); String path = ZooUtil.getRoot(HdfsZooInstance.getInstance()) + Constants.ZGC_LOCK; LockWatcher lockWatcher = new LockWatcher() { public void lostLock(LockLossReason reason) { Halt.halt("GC lock in zookeeper lost (reason = " + reason + "), exiting!"); } @Override public void unableToMonitorLockNode(final Throwable e) { Halt.halt(-1, new Runnable() { @Override public void run() { log.fatal("No longer able to monitor lock node ", e); } }); } }; while (true) { lock = new ZooLock(path); if (lock.tryLock(lockWatcher, new ServerServices(address, Service.GC_CLIENT).toString().getBytes(UTF_8))) { break; } UtilWaitThread.sleep(1000); } }
.toString().getBytes(UTF_8); for (int i = 0; i < 120 / 5; i++) { zoo.putPersistentData(zPath, new byte[0], NodeExistsPolicy.SKIP);
byte[] lockContent = new ServerServices(addressString, Service.TSERV_CLIENT).toString() .getBytes(UTF_8); if (zlock.tryLock(lw, lockContent)) {