use of alluxio.uri.ZookeeperLogicalAuthority 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;
}
Aggregations