@Test public void singleMasterConnectString() throws Exception { String host = "testhost"; int port = 123; try (Closeable c = new ConfigurationRule(new HashMap<PropertyKey, String>() { { put(PropertyKey.MASTER_HOSTNAME, host); put(PropertyKey.MASTER_RPC_PORT, Integer.toString(port)); } }, mConfiguration).toResource()) { ConnectDetails cs = new SingleMasterConnectDetails(new InetSocketAddress(host, port)); assertCurrentConnectString(cs); assertEquals("testhost:123", cs.toString()); } }
@Test public void defaultConnectString() { ConnectDetails cs = new SingleMasterConnectDetails( NetworkAddressUtils.getConnectAddress(ServiceType.MASTER_RPC, mConfiguration)); assertCurrentConnectString(cs); assertEquals(NetworkAddressUtils.getConnectHost(ServiceType.MASTER_RPC, mConfiguration) + ":" + NetworkAddressUtils.getPort(ServiceType.MASTER_RPC, mConfiguration), cs.toString()); }
@Test public void zkConnectString() throws Exception { String zkAddr = "zkAddr:1234"; String leaderPath = "/my/leader/path"; try (Closeable c = new ConfigurationRule(new HashMap<PropertyKey, String>() { { put(PropertyKey.ZOOKEEPER_ADDRESS, zkAddr); put(PropertyKey.ZOOKEEPER_LEADER_PATH, leaderPath); } }, mConfiguration).toResource()) { ConnectDetails singleConnect = new SingleMasterConnectDetails( NetworkAddressUtils.getConnectAddress(ServiceType.MASTER_RPC, mConfiguration)); assertCurrentConnectString(singleConnect); try (Closeable c2 = new ConfigurationRule(PropertyKey.ZOOKEEPER_ENABLED, "true", mConfiguration) .toResource()) { ConnectDetails zkConnect = new ZkMasterConnectDetails(zkAddr, leaderPath); assertCurrentConnectString(zkConnect); assertEquals("zk@zkAddr:1234/my/leader/path", zkConnect.toString()); } } }
/** * @param conf configuration for creating the master inquire client * @return the connect string represented by the configuration */ public static ConnectDetails getConnectDetails(AlluxioConfiguration conf) { if (conf.getBoolean(PropertyKey.ZOOKEEPER_ENABLED)) { return new ZkMasterConnectDetails(conf.get(PropertyKey.ZOOKEEPER_ADDRESS), conf.get(PropertyKey.ZOOKEEPER_LEADER_PATH)); } else { return new SingleMasterConnectDetails( NetworkAddressUtils.getConnectAddress(ServiceType.MASTER_RPC, conf)); } }
/** * @param address the master address */ public SingleMasterInquireClient(InetSocketAddress address) { mConnectDetails = new SingleMasterConnectDetails(address); }
/** * @param conf configuration for creating the master inquire client * @return the connect string represented by the configuration */ public static ConnectDetails getConnectDetails(AlluxioConfiguration conf) { if (conf.getBoolean(PropertyKey.ZOOKEEPER_ENABLED)) { return new ZkMasterConnectDetails(conf.get(PropertyKey.ZOOKEEPER_ADDRESS), conf.get(PropertyKey.ZOOKEEPER_LEADER_PATH)); } else { return new SingleMasterConnectDetails( NetworkAddressUtils.getConnectAddress(ServiceType.MASTER_RPC, conf)); } }
/** * @param address the master address */ public SingleMasterInquireClient(InetSocketAddress address) { mConnectDetails = new SingleMasterConnectDetails(address); }