use of alluxio.uri.SingleMasterAuthority in project alluxio by Alluxio.
the class AlluxioURITest method basicTwoPartUri.
@Test
public void basicTwoPartUri() {
AlluxioURI uri = new AlluxioURI("scheme:part2://localhost:8000/xy z/a b c");
assertEquals(uri, new AlluxioURI("scheme:part2//localhost:8000/xy z/a b c"));
assertEquals("scheme:part2", uri.getScheme());
assertTrue(uri.hasAuthority());
assertEquals("localhost:8000", uri.getAuthority().toString());
assertTrue(uri.getAuthority() instanceof SingleMasterAuthority);
SingleMasterAuthority authority = (SingleMasterAuthority) uri.getAuthority();
assertEquals("localhost", authority.getHost());
assertEquals(8000, authority.getPort());
assertEquals(2, uri.getDepth());
assertEquals("a b c", uri.getName());
assertEquals("scheme:part2://localhost:8000/xy z", uri.getParent().toString());
assertEquals("scheme:part2://localhost:8000/", uri.getParent().getParent().toString());
assertEquals("/xy z/a b c", uri.getPath());
assertTrue(uri.hasScheme());
assertTrue(uri.isAbsolute());
assertTrue(uri.isPathAbsolute());
assertEquals("scheme:part2://localhost:8000/xy z/a b c/d", uri.join("/d").toString());
assertEquals("scheme:part2://localhost:8000/xy z/a b c/d", uri.join(new AlluxioURI("/d")).toString());
assertEquals("scheme:part2://localhost:8000/xy z/a b c", uri.toString());
}
use of alluxio.uri.SingleMasterAuthority in project alluxio by Alluxio.
the class AlluxioURITest method basicAlluxioUri.
/**
* Tests the {@link AlluxioURI#AlluxioURI(String)} constructor for basic Alluxio paths.
*/
@Test
public void basicAlluxioUri() {
AlluxioURI uri = new AlluxioURI("alluxio://localhost:19998/xy z/a b c");
assertTrue(uri.hasAuthority());
assertEquals("localhost:19998", uri.getAuthority().toString());
assertTrue(uri.getAuthority() instanceof SingleMasterAuthority);
SingleMasterAuthority authority = (SingleMasterAuthority) uri.getAuthority();
assertEquals("localhost", authority.getHost());
assertEquals(19998, authority.getPort());
assertEquals(2, uri.getDepth());
assertEquals("a b c", uri.getName());
assertEquals("alluxio://localhost:19998/xy z", uri.getParent().toString());
assertEquals("alluxio://localhost:19998/", uri.getParent().getParent().toString());
assertEquals("/xy z/a b c", uri.getPath());
assertEquals("alluxio", uri.getScheme());
assertTrue(uri.hasScheme());
assertTrue(uri.isAbsolute());
assertTrue(uri.isPathAbsolute());
assertEquals("alluxio://localhost:19998/xy z/a b c/d", uri.join("/d").toString());
assertEquals("alluxio://localhost:19998/xy z/a b c/d", uri.join(new AlluxioURI("/d")).toString());
assertEquals("alluxio://localhost:19998/xy z/a b c", uri.toString());
}
use of alluxio.uri.SingleMasterAuthority 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.SingleMasterAuthority in project alluxio by Alluxio.
the class AlluxioURITest method basicTests.
/**
* Tests the {@link AlluxioURI#AlluxioURI(String)} constructor for basic paths.
*/
@Test
public void basicTests() {
String[] strs = new String[] { "alluxio://localhost:19998/xyz/abc", "hdfs://localhost:19998/xyz/abc", "s3://localhost:19998/xyz/abc", "alluxio://localhost:19998/xy z/a b c", "hdfs://localhost:19998/xy z/a b c", "s3://localhost:19998/xy z/a b c" };
for (String str : strs) {
AlluxioURI uri = new AlluxioURI(str);
assertEquals(str, uri.toString());
assertEquals(2, uri.getDepth());
assertTrue(uri.getAuthority() instanceof SingleMasterAuthority);
SingleMasterAuthority authority = (SingleMasterAuthority) uri.getAuthority();
assertEquals("localhost", authority.getHost());
assertEquals(19998, authority.getPort());
}
}
use of alluxio.uri.SingleMasterAuthority in project alluxio by Alluxio.
the class AlluxioURITest method basicHdfsUri.
/**
* Tests the {@link AlluxioURI#AlluxioURI(String)} constructor for basic HDFS paths.
*/
@Test
public void basicHdfsUri() {
AlluxioURI uri = new AlluxioURI("hdfs://localhost:8020/xy z/a b c");
assertTrue(uri.hasAuthority());
assertEquals("localhost:8020", uri.getAuthority().toString());
assertTrue(uri.getAuthority() instanceof SingleMasterAuthority);
SingleMasterAuthority authority = (SingleMasterAuthority) uri.getAuthority();
assertEquals("localhost", authority.getHost());
assertEquals(8020, authority.getPort());
assertEquals(2, uri.getDepth());
assertEquals("a b c", uri.getName());
assertEquals("hdfs://localhost:8020/xy z", uri.getParent().toString());
assertEquals("hdfs://localhost:8020/", uri.getParent().getParent().toString());
assertEquals("/xy z/a b c", uri.getPath());
assertEquals("hdfs", uri.getScheme());
assertTrue(uri.hasScheme());
assertTrue(uri.isAbsolute());
assertTrue(uri.isPathAbsolute());
assertEquals("hdfs://localhost:8020/xy z/a b c/d", uri.join("/d").toString());
assertEquals("hdfs://localhost:8020/xy z/a b c/d", uri.join(new AlluxioURI("/d")).toString());
assertEquals("hdfs://localhost:8020/xy z/a b c", uri.toString());
}
Aggregations