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());
}
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());
}
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");
}
}
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;
}
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));
}
Aggregations