use of alluxio.ConfigurationRule in project alluxio by Alluxio.
the class AlluxioBlockStoreTest method getInStreamUfsMockLocaltion.
@Test
public void getInStreamUfsMockLocaltion() throws Exception {
try (Closeable c = new ConfigurationRule(PropertyKey.USER_UFS_BLOCK_READ_LOCATION_POLICY, MockBlockLocationPolicy.class.getTypeName(), sConf).toResource()) {
WorkerNetAddress worker1 = new WorkerNetAddress().setHost("worker1");
WorkerNetAddress worker2 = new WorkerNetAddress().setHost("worker2");
BlockInfo info = new BlockInfo().setBlockId(0);
URIStatus dummyStatus = new URIStatus(new FileInfo().setPersisted(true).setBlockIds(Collections.singletonList(0L)).setFileBlockInfos(Collections.singletonList(new FileBlockInfo().setBlockInfo(info))));
OpenFilePOptions readOptions = OpenFilePOptions.newBuilder().build();
InStreamOptions options = new InStreamOptions(dummyStatus, readOptions, sConf);
((MockBlockLocationPolicy) options.getUfsReadLocationPolicy()).setHosts(Arrays.asList(worker1, worker2));
when(mMasterClient.getBlockInfo(BLOCK_ID)).thenReturn(new BlockInfo());
when(mContext.getCachedWorkers()).thenReturn(Lists.newArrayList(new BlockWorkerInfo(worker1, -1, -1), new BlockWorkerInfo(worker2, -1, -1)));
// Location policy chooses worker1 first.
assertEquals(worker1, mBlockStore.getInStream(BLOCK_ID, options).getAddress());
// Location policy chooses worker2 second.
assertEquals(worker2, mBlockStore.getInStream(BLOCK_ID, options).getAddress());
}
}
use of alluxio.ConfigurationRule in project alluxio by Alluxio.
the class AbstractFileSystemTest method hadoopShouldLoadFileSystemWhenConfigured.
@Test
public void hadoopShouldLoadFileSystemWhenConfigured() throws Exception {
org.apache.hadoop.conf.Configuration conf = getConf();
URI uri = URI.create(Constants.HEADER + "localhost:19998/tmp/path.txt");
Map<PropertyKey, Object> properties = new HashMap<>();
properties.put(PropertyKey.MASTER_HOSTNAME, uri.getHost());
properties.put(PropertyKey.MASTER_RPC_PORT, Integer.toString(uri.getPort()));
properties.put(PropertyKey.ZOOKEEPER_ENABLED, false);
properties.put(PropertyKey.ZOOKEEPER_ADDRESS, null);
try (Closeable c = new ConfigurationRule(properties, mConfiguration).toResource()) {
final org.apache.hadoop.fs.FileSystem fs = org.apache.hadoop.fs.FileSystem.get(uri, conf);
assertTrue(fs instanceof FileSystem);
}
}
use of alluxio.ConfigurationRule in project alluxio by Alluxio.
the class AbstractFileSystemTest method getBlockLocationsNoUfsLocationsWithFallback.
@Test
public void getBlockLocationsNoUfsLocationsWithFallback() throws Exception {
WorkerNetAddress worker1 = new WorkerNetAddress().setHost("worker1").setDataPort(1234);
WorkerNetAddress worker2 = new WorkerNetAddress().setHost("worker2").setDataPort(1234);
List<WorkerNetAddress> blockWorkers = Arrays.asList();
List<String> ufsLocations = Arrays.asList();
List<WorkerNetAddress> allWorkers = Arrays.asList(worker1, worker2);
List<WorkerNetAddress> expectedWorkers = Arrays.asList(worker1, worker2);
try (Closeable conf = new ConfigurationRule(PropertyKey.USER_UFS_BLOCK_LOCATION_ALL_FALLBACK_ENABLED, true, mConfiguration).toResource()) {
verifyBlockLocations(blockWorkers, ufsLocations, allWorkers, expectedWorkers);
}
}
use of alluxio.ConfigurationRule in project alluxio by Alluxio.
the class TieredIdentityFactoryTest method fromScript.
@Test
public void fromScript() throws Exception {
String scriptPath = setupScript("node=myhost,rack=myrack,custom=mycustom", mFolder.newFile());
try (Closeable c = new ConfigurationRule(ImmutableMap.of(PropertyKey.LOCALITY_ORDER, "node,rack,custom", PropertyKey.LOCALITY_SCRIPT, scriptPath), mConfiguration).toResource()) {
TieredIdentity identity = TieredIdentityFactory.create(mConfiguration);
TieredIdentity expected = new TieredIdentity(Arrays.asList(new LocalityTier("node", "myhost"), new LocalityTier("rack", "myrack"), new LocalityTier("custom", "mycustom")));
assertEquals(expected, identity);
}
}
use of alluxio.ConfigurationRule in project alluxio by Alluxio.
the class TieredIdentityFactoryTest method overrideScript.
@Test
public void overrideScript() throws Exception {
String scriptPath = setupScript("node=myhost,rack=myrack,custom=mycustom", mFolder.newFile());
try (Closeable c = new ConfigurationRule(ImmutableMap.of(Template.LOCALITY_TIER.format("node"), "overridden", PropertyKey.LOCALITY_ORDER, "node,rack,custom", PropertyKey.LOCALITY_SCRIPT, scriptPath), mConfiguration).toResource()) {
TieredIdentity identity = TieredIdentityFactory.create(mConfiguration);
TieredIdentity expected = new TieredIdentity(Arrays.asList(new LocalityTier("node", "overridden"), new LocalityTier("rack", "myrack"), new LocalityTier("custom", "mycustom")));
assertEquals(expected, identity);
}
}
Aggregations