/** * Returns a list of the host names of the currently running masters. */ @Override public List<String> getRunningMasters() { final ZooKeeperClient client = provider.get("getRunningMasters"); try { final List<String> masters = client.getChildren(Paths.statusMaster()); final ImmutableList.Builder<String> upMasters = ImmutableList.builder(); for (final String master : masters) { if (client.exists(Paths.statusMasterUp(master)) != null) { upMasters.add(master); } } return upMasters.build(); } catch (KeeperException e) { throw new HeliosRuntimeException("listing masters failed", e); } }
/** * Simple test to make sure nodes created by master use the ACLs provided by the ACL provider. */ @Test public void testMasterCreatedNodesHaveAcls() throws Exception { startDefaultMaster(); Polling.await(WAIT_TIMEOUT_SECONDS, TimeUnit.SECONDS, new Callable<Boolean>() { @Override public Boolean call() throws Exception { return defaultClient().listMasters().get().isEmpty() ? null : true; } }); final CuratorFramework curator = zk().curatorWithSuperAuth(); final String path = Paths.statusMasterUp(TEST_MASTER); final List<ACL> acls = curator.getACL().forPath(path); assertEquals( Sets.newHashSet(aclProvider.getAclForPath(path)), Sets.newHashSet(acls)); } }
@Override public boolean tryToRegister(final ZooKeeperClient client) throws KeeperException { client.ensurePath(Paths.configHosts()); client.ensurePath(Paths.configJobs()); client.ensurePath(Paths.configJobRefs()); client.ensurePath(Paths.statusHosts()); client.ensurePath(Paths.statusMasters()); client.ensurePath(Paths.historyJobs()); client.ensurePath(Paths.configDeploymentGroups()); client.ensurePath(Paths.statusDeploymentGroups()); if (upNode == null) { final String upPath = Paths.statusMasterUp(name); client.ensurePath(upPath, true); upNode = client.persistentEphemeralNode(upPath, Mode.EPHEMERAL, new byte[]{}); upNode.start(); } log.info("ZooKeeper registration complete"); return true; } }
/** * Returns a list of the host names of the currently running masters. */ @Override public List<String> getRunningMasters() { final ZooKeeperClient client = provider.get("getRunningMasters"); try { final List<String> masters = client.getChildren(Paths.statusMaster()); final ImmutableList.Builder<String> upMasters = ImmutableList.builder(); for (final String master : masters) { if (client.exists(Paths.statusMasterUp(master)) != null) { upMasters.add(master); } } return upMasters.build(); } catch (KeeperException e) { throw new HeliosRuntimeException("listing masters failed", e); } }
@Override public void tryToRegister(final ZooKeeperClient client) throws KeeperException { client.ensurePath(Paths.configHosts()); client.ensurePath(Paths.configJobs()); client.ensurePath(Paths.configJobRefs()); client.ensurePath(Paths.statusHosts()); client.ensurePath(Paths.statusMasters()); client.ensurePath(Paths.historyJobs()); client.ensurePath(Paths.configDeploymentGroups()); client.ensurePath(Paths.statusDeploymentGroups()); if (upNode == null) { final String upPath = Paths.statusMasterUp(name); upNode = client.persistentEphemeralNode(upPath, Mode.EPHEMERAL, new byte[]{}); upNode.start(); } log.info("ZooKeeper registration complete"); } }