Search in sources :

Example 1 with MultiMasterAuthority

use of alluxio.uri.MultiMasterAuthority in project alluxio by Alluxio.

the class AlluxioURITest method plusMultiMasterUri.

@Test
public void plusMultiMasterUri() {
    AlluxioURI uri = new AlluxioURI("alluxio://host1:526+host2:54325+host3:624/xy z/a b c");
    assertTrue(uri.hasAuthority());
    assertTrue(uri.getAuthority() instanceof MultiMasterAuthority);
    MultiMasterAuthority authority = (MultiMasterAuthority) uri.getAuthority();
    assertEquals("host1:526,host2:54325,host3:624", authority.getMasterAddresses());
}
Also used : MultiMasterAuthority(alluxio.uri.MultiMasterAuthority) Test(org.junit.Test)

Example 2 with MultiMasterAuthority

use of alluxio.uri.MultiMasterAuthority in project alluxio by Alluxio.

the class AlluxioURITest method semicolonMultiMasterUri.

@Test
public void semicolonMultiMasterUri() {
    AlluxioURI uri = new AlluxioURI("alluxio://host1:1323;host2:54325;host3:64354/xy z/a b c");
    assertTrue(uri.hasAuthority());
    assertEquals("host1:1323,host2:54325,host3:64354", uri.getAuthority().toString());
    assertTrue(uri.getAuthority() instanceof MultiMasterAuthority);
    MultiMasterAuthority authority = (MultiMasterAuthority) uri.getAuthority();
    assertEquals("host1:1323,host2:54325,host3:64354", authority.getMasterAddresses());
}
Also used : MultiMasterAuthority(alluxio.uri.MultiMasterAuthority) Test(org.junit.Test)

Example 3 with MultiMasterAuthority

use of alluxio.uri.MultiMasterAuthority in project alluxio by Alluxio.

the class FileSystemFactoryTest method multiMasterFileSystemCacheTest.

@Test
public void multiMasterFileSystemCacheTest() {
    try (Closeable p = new SystemPropertyRule(PropertyKey.MASTER_RPC_ADDRESSES.getName(), "192.168.0.1:1234,192.168.0.2:1445,192.168.0.3:9943").toResource()) {
        ConfigurationUtils.reloadProperties();
        InstancedConfiguration conf = new InstancedConfiguration(ConfigurationUtils.defaults());
        MasterInquireClient.ConnectDetails connectDetails = MasterInquireClient.Factory.getConnectDetails(conf);
        // Make sure we have a MultiMaster authority
        assertTrue(connectDetails.toAuthority() instanceof MultiMasterAuthority);
        fileSystemCacheTest();
    } catch (IOException e) {
        fail("Unable to set system properties");
    }
}
Also used : MasterInquireClient(alluxio.master.MasterInquireClient) InstancedConfiguration(alluxio.conf.InstancedConfiguration) MultiMasterAuthority(alluxio.uri.MultiMasterAuthority) SystemPropertyRule(alluxio.SystemPropertyRule) Closeable(java.io.Closeable) IOException(java.io.IOException) Test(org.junit.Test)

Example 4 with MultiMasterAuthority

use of alluxio.uri.MultiMasterAuthority in project alluxio by Alluxio.

the class FileSystem method getConfigurationFromUri.

@Override
protected Map<String, Object> getConfigurationFromUri(URI uri, Configuration conf) {
    AlluxioURI alluxioUri = new AlluxioURI(uri.toString());
    Map<String, Object> alluxioConfProperties = new HashMap<>();
    if (alluxioUri.getAuthority() instanceof ZookeeperAuthority) {
        ZookeeperAuthority authority = (ZookeeperAuthority) alluxioUri.getAuthority();
        alluxioConfProperties.put(PropertyKey.ZOOKEEPER_ENABLED.getName(), true);
        alluxioConfProperties.put(PropertyKey.ZOOKEEPER_ADDRESS.getName(), authority.getZookeeperAddress());
    } else if (alluxioUri.getAuthority() instanceof SingleMasterAuthority) {
        SingleMasterAuthority authority = (SingleMasterAuthority) alluxioUri.getAuthority();
        alluxioConfProperties.put(PropertyKey.MASTER_HOSTNAME.getName(), authority.getHost());
        alluxioConfProperties.put(PropertyKey.MASTER_RPC_PORT.getName(), authority.getPort());
        alluxioConfProperties.put(PropertyKey.ZOOKEEPER_ENABLED.getName(), false);
        alluxioConfProperties.put(PropertyKey.ZOOKEEPER_ADDRESS.getName(), null);
        // Unset the embedded journal related configuration
        // to support alluxio URI has the highest priority
        alluxioConfProperties.put(PropertyKey.MASTER_EMBEDDED_JOURNAL_ADDRESSES.getName(), null);
        alluxioConfProperties.put(PropertyKey.MASTER_RPC_ADDRESSES.getName(), null);
    } else if (alluxioUri.getAuthority() instanceof MultiMasterAuthority) {
        MultiMasterAuthority authority = (MultiMasterAuthority) alluxioUri.getAuthority();
        alluxioConfProperties.put(PropertyKey.MASTER_RPC_ADDRESSES.getName(), authority.getMasterAddresses());
        // Unset the zookeeper configuration to support alluxio URI has the highest priority
        alluxioConfProperties.put(PropertyKey.ZOOKEEPER_ENABLED.getName(), false);
        alluxioConfProperties.put(PropertyKey.ZOOKEEPER_ADDRESS.getName(), null);
    } else if (alluxioUri.getAuthority() instanceof EmbeddedLogicalAuthority) {
        EmbeddedLogicalAuthority authority = (EmbeddedLogicalAuthority) alluxioUri.getAuthority();
        String masterNamesConfKey = PropertyKey.Template.MASTER_LOGICAL_NAMESERVICES.format(authority.getLogicalName()).getName();
        String[] masterNames = conf.getTrimmedStrings(masterNamesConfKey);
        Preconditions.checkArgument(masterNames.length != 0, "Invalid uri. You must set %s to use the logical name ", masterNamesConfKey);
        StringJoiner masterRpcAddress = new StringJoiner(",");
        for (String masterName : masterNames) {
            String name = PropertyKey.Template.MASTER_LOGICAL_RPC_ADDRESS.format(authority.getLogicalName(), masterName).getName();
            String address = conf.get(name);
            Preconditions.checkArgument(address != null, "You need to set %s", name);
            masterRpcAddress.add(address);
        }
        alluxioConfProperties.put(PropertyKey.MASTER_RPC_ADDRESSES.getName(), masterRpcAddress.toString());
        alluxioConfProperties.put(PropertyKey.ZOOKEEPER_ENABLED.getName(), false);
        alluxioConfProperties.put(PropertyKey.ZOOKEEPER_ADDRESS.getName(), null);
    } else if (alluxioUri.getAuthority() instanceof ZookeeperLogicalAuthority) {
        ZookeeperLogicalAuthority authority = (ZookeeperLogicalAuthority) alluxioUri.getAuthority();
        String zkNodesConfKey = PropertyKey.Template.MASTER_LOGICAL_ZOOKEEPER_NAMESERVICES.format(authority.getLogicalName()).getName();
        String[] zkNodeNames = conf.getTrimmedStrings(zkNodesConfKey);
        Preconditions.checkArgument(zkNodeNames.length != 0, "Invalid uri. You must set %s to use the logical name", zkNodesConfKey);
        StringJoiner zkAddress = new StringJoiner(",");
        for (String zkName : zkNodeNames) {
            String name = PropertyKey.Template.MASTER_LOGICAL_ZOOKEEPER_ADDRESS.format(authority.getLogicalName(), zkName).getName();
            String address = conf.get(name);
            Preconditions.checkArgument(address != null, "You need to set %s", name);
            zkAddress.add(address);
        }
        alluxioConfProperties.put(PropertyKey.ZOOKEEPER_ENABLED.getName(), true);
        alluxioConfProperties.put(PropertyKey.ZOOKEEPER_ADDRESS.getName(), zkAddress.toString());
    }
    return alluxioConfProperties;
}
Also used : ZookeeperLogicalAuthority(alluxio.uri.ZookeeperLogicalAuthority) ZookeeperAuthority(alluxio.uri.ZookeeperAuthority) MultiMasterAuthority(alluxio.uri.MultiMasterAuthority) HashMap(java.util.HashMap) SingleMasterAuthority(alluxio.uri.SingleMasterAuthority) EmbeddedLogicalAuthority(alluxio.uri.EmbeddedLogicalAuthority) StringJoiner(java.util.StringJoiner) AlluxioURI(alluxio.AlluxioURI)

Example 5 with MultiMasterAuthority

use of alluxio.uri.MultiMasterAuthority in project alluxio by Alluxio.

the class LogLevelTest method parseEmbeddedHAMasterTarget.

@Test
public void parseEmbeddedHAMasterTarget() throws Exception {
    String masterAddresses = "masters-1:19200,masters-2:19200";
    mConf.set(PropertyKey.MASTER_EMBEDDED_JOURNAL_ADDRESSES, masterAddresses);
    CommandLine mockCommandLine = mock(CommandLine.class);
    String[] mockArgs = new String[] { "--target", "master" };
    when(mockCommandLine.getArgs()).thenReturn(mockArgs);
    when(mockCommandLine.hasOption(LogLevel.TARGET_OPTION_NAME)).thenReturn(true);
    when(mockCommandLine.getOptionValue(LogLevel.TARGET_OPTION_NAME)).thenReturn(mockArgs[1]);
    PowerMockito.mockStatic(MasterInquireClient.Factory.class);
    MasterInquireClient mockInquireClient = mock(MasterInquireClient.class);
    when(mockInquireClient.getPrimaryRpcAddress()).thenReturn(new InetSocketAddress("masters-1", mConf.getInt(PropertyKey.MASTER_RPC_PORT)));
    when(mockInquireClient.getConnectDetails()).thenReturn(() -> new MultiMasterAuthority(masterAddresses));
    when(MasterInquireClient.Factory.create(any(), any())).thenReturn(mockInquireClient);
    List<LogLevel.TargetInfo> targets = LogLevel.parseOptTarget(mockCommandLine, mConf);
    assertEquals(1, targets.size());
    assertEquals(new LogLevel.TargetInfo("masters-1", MASTER_WEB_PORT, "master"), targets.get(0));
}
Also used : MasterInquireClient(alluxio.master.MasterInquireClient) CommandLine(org.apache.commons.cli.CommandLine) MultiMasterAuthority(alluxio.uri.MultiMasterAuthority) InetSocketAddress(java.net.InetSocketAddress) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

MultiMasterAuthority (alluxio.uri.MultiMasterAuthority)5 Test (org.junit.Test)4 MasterInquireClient (alluxio.master.MasterInquireClient)2 AlluxioURI (alluxio.AlluxioURI)1 SystemPropertyRule (alluxio.SystemPropertyRule)1 InstancedConfiguration (alluxio.conf.InstancedConfiguration)1 EmbeddedLogicalAuthority (alluxio.uri.EmbeddedLogicalAuthority)1 SingleMasterAuthority (alluxio.uri.SingleMasterAuthority)1 ZookeeperAuthority (alluxio.uri.ZookeeperAuthority)1 ZookeeperLogicalAuthority (alluxio.uri.ZookeeperLogicalAuthority)1 Closeable (java.io.Closeable)1 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 HashMap (java.util.HashMap)1 StringJoiner (java.util.StringJoiner)1 CommandLine (org.apache.commons.cli.CommandLine)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1