Search in sources :

Example 1 with OZONE_OM_SERVICE_IDS_KEY

use of org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_SERVICE_IDS_KEY in project ozone by apache.

the class TestOmUtils method testGetOmHAAddressesById.

@Test
public void testGetOmHAAddressesById() {
    OzoneConfiguration conf = new OzoneConfiguration();
    conf.set(OZONE_OM_SERVICE_IDS_KEY, "ozone1");
    conf.set("ozone.om.nodes.ozone1", "node1,node2,node3");
    conf.set("ozone.om.address.ozone1.node1", "1.1.1.1");
    conf.set("ozone.om.address.ozone1.node2", "1.1.1.2");
    conf.set("ozone.om.address.ozone1.node3", "1.1.1.3");
    Map<String, List<InetSocketAddress>> addresses = OmUtils.getOmHAAddressesById(conf);
    assertFalse(addresses.isEmpty());
    List<InetSocketAddress> rpcAddrs = addresses.get("ozone1");
    assertFalse(rpcAddrs.isEmpty());
    assertTrue(rpcAddrs.stream().anyMatch(a -> a.getAddress().getHostAddress().equals("1.1.1.1")));
    assertTrue(rpcAddrs.stream().anyMatch(a -> a.getAddress().getHostAddress().equals("1.1.1.2")));
    assertTrue(rpcAddrs.stream().anyMatch(a -> a.getAddress().getHostAddress().equals("1.1.1.3")));
}
Also used : OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) OmUtils.getOzoneManagerServiceId(org.apache.hadoop.ozone.OmUtils.getOzoneManagerServiceId) OZONE_OM_SERVICE_IDS_KEY(org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_SERVICE_IDS_KEY) Set(java.util.Set) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) OmUtils.getOmHostsFromConfig(org.apache.hadoop.ozone.OmUtils.getOmHostsFromConfig) Test(org.junit.Test) InetSocketAddress(java.net.InetSocketAddress) File(java.io.File) List(java.util.List) OZONE_OM_ADDRESS_KEY(org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_ADDRESS_KEY) OZONE_OM_NODES_KEY(org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_NODES_KEY) Assert.assertNull(org.junit.Assert.assertNull) Rule(org.junit.Rule) Assert.assertFalse(org.junit.Assert.assertFalse) Map(java.util.Map) Timeout(org.junit.rules.Timeout) Assume.assumeTrue(org.junit.Assume.assumeTrue) OZONE_OM_INTERNAL_SERVICE_ID(org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_INTERNAL_SERVICE_ID) Assert(org.junit.Assert) Assert.assertEquals(org.junit.Assert.assertEquals) TemporaryFolder(org.junit.rules.TemporaryFolder) InetSocketAddress(java.net.InetSocketAddress) OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) List(java.util.List) Test(org.junit.Test)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)1 OmUtils.getOmHostsFromConfig (org.apache.hadoop.ozone.OmUtils.getOmHostsFromConfig)1 OmUtils.getOzoneManagerServiceId (org.apache.hadoop.ozone.OmUtils.getOzoneManagerServiceId)1 OZONE_OM_ADDRESS_KEY (org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_ADDRESS_KEY)1 OZONE_OM_INTERNAL_SERVICE_ID (org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_INTERNAL_SERVICE_ID)1 OZONE_OM_NODES_KEY (org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_NODES_KEY)1 OZONE_OM_SERVICE_IDS_KEY (org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_SERVICE_IDS_KEY)1 Assert (org.junit.Assert)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertFalse (org.junit.Assert.assertFalse)1 Assert.assertNull (org.junit.Assert.assertNull)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 Assume.assumeTrue (org.junit.Assume.assumeTrue)1 Rule (org.junit.Rule)1