ServerServices services = new ServerServices(new String(lockData, UTF_8)); HostAndPort client = services.getAddress(ServerServices.Service.TSERV_CLIENT); TServerInstance instance = new TServerInstance(client, stat.getEphemeralOwner());
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); } }
public HostAndPort getAddress(Service service) { return AddressUtil.parseAddress(getAddressString(service), false); }
@Override public int hashCode() { return toString().hashCode(); }
if (!strData.equals("master")) servers.add(new ThriftTransportKey( new ServerServices(strData).getAddress(Service.TSERV_CLIENT), rpcTimeout, context));
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);
@Override public boolean equals(Object o) { if (o instanceof ServerServices) return toString().equals(o.toString()); return false; }
public HostAndPort getAddress(Service service) { return AddressUtil.parseAddress(getAddressString(service), false); }
private static GCStatus fetchGcStatus() { GCStatus result = null; HostAndPort address = null; try { // Read the gc location from its lock ZooReaderWriter zk = context.getZooReaderWriter(); String path = context.getZooKeeperRoot() + Constants.ZGC_LOCK; List<String> locks = zk.getChildren(path, null); if (locks != null && locks.size() > 0) { Collections.sort(locks); address = new ServerServices(new String(zk.getData(path + "/" + locks.get(0), null), UTF_8)) .getAddress(Service.GC_CLIENT); GCMonitorService.Client client = ThriftUtil.getClient(new GCMonitorService.Client.Factory(), address, context); try { result = client.getStatus(Tracer.traceInfo(), getContext().rpcCreds()); } finally { ThriftUtil.returnClient(client); } } } catch (Exception ex) { log.warn("Unable to contact the garbage collector at " + address, ex); } return result; }
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); } }
ServerServices services = new ServerServices(new String(lockData, UTF_8)); HostAndPort client = services.getAddress(ServerServices.Service.TSERV_CLIENT); TServerInstance instance = new TServerInstance(client, stat.getEphemeralOwner());
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); } }
ServerServices services = new ServerServices(new String(lockData, UTF_8)); InetSocketAddress client = services.getAddress(ServerServices.Service.TSERV_CLIENT); InetSocketAddress addr = AddressUtil.parseAddress(server, Property.TSERV_CLIENTPORT); TServerInstance instance = new TServerInstance(client, stat.getEphemeralOwner());
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);
@Override public int hashCode() { return toString().hashCode(); }
private static GCStatus fetchGcStatus() { GCStatus result = null; InetSocketAddress address = null; try { // Read the gc location from its lock ZooReaderWriter zk = ZooReaderWriter.getInstance(); String path = ZooUtil.getRoot(instance) + Constants.ZGC_LOCK; List<String> locks = zk.getChildren(path, null); if (locks != null && locks.size() > 0) { Collections.sort(locks); address = new ServerServices(new String(zk.getData(path + "/" + locks.get(0), null), UTF_8)).getAddress(Service.GC_CLIENT); GCMonitorService.Client client = ThriftUtil.getClient(new GCMonitorService.Client.Factory(), address, config.getConfiguration()); try { result = client.getStatus(Tracer.traceInfo(), SecurityConstants.getSystemCredentials()); } finally { ThriftUtil.returnClient(client); } } } catch (Exception ex) { log.warn("Unable to contact the garbage collector at " + address, ex); } return result; }
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);