use of alluxio.ConfigurationRule in project alluxio by Alluxio.
the class BlockInStreamTest method createShortCircuitDisabled.
@Test
public void createShortCircuitDisabled() throws Exception {
try (Closeable c = new ConfigurationRule(PropertyKey.USER_SHORT_CIRCUIT_ENABLED, false, mConf).toResource()) {
WorkerNetAddress dataSource = new WorkerNetAddress();
when(mMockContext.getClientContext()).thenReturn(ClientContext.create(mConf));
BlockInStream.BlockInStreamSource dataSourceType = BlockInStream.BlockInStreamSource.NODE_LOCAL;
BlockInStream stream = BlockInStream.create(mMockContext, mInfo, dataSource, dataSourceType, mOptions);
assertEquals(GrpcDataReader.Factory.class.getName(), stream.getDataReaderFactory().getClass().getName());
}
}
use of alluxio.ConfigurationRule in project alluxio by Alluxio.
the class FormatTest method formatWorkerDeleteFileSameName.
@Test
public void formatWorkerDeleteFileSameName() throws Exception {
final int storageLevels = 3;
String workerDataFolder;
final File[] dirs = new File[] { mTemporaryFolder.newFolder("level0"), mTemporaryFolder.newFolder("level1"), mTemporaryFolder.newFolder("level2") };
// Have files of same name as the target worker data dir in each tier
for (File dir : dirs) {
workerDataFolder = CommonUtils.getWorkerDataDirectory(dir.getPath(), ServerConfiguration.global());
FileUtils.createFile(workerDataFolder);
}
try (Closeable r = new ConfigurationRule(new HashMap<PropertyKey, Object>() {
{
put(PropertyKey.WORKER_TIERED_STORE_LEVEL0_DIRS_PATH, dirs[0].getPath());
put(PropertyKey.WORKER_TIERED_STORE_LEVEL1_DIRS_PATH, dirs[1].getPath());
put(PropertyKey.WORKER_TIERED_STORE_LEVEL2_DIRS_PATH, dirs[2].getPath());
put(PropertyKey.WORKER_TIERED_STORE_LEVELS, storageLevels);
}
}, ServerConfiguration.global()).toResource()) {
final String perms = ServerConfiguration.getString(PropertyKey.WORKER_DATA_FOLDER_PERMISSIONS);
Format.format(Format.Mode.WORKER, ServerConfiguration.global());
for (File dir : dirs) {
workerDataFolder = CommonUtils.getWorkerDataDirectory(dir.getPath(), ServerConfiguration.global());
assertTrue(Files.isDirectory(Paths.get(workerDataFolder)));
assertEquals(PosixFilePermissions.fromString(perms), Files.getPosixFilePermissions(Paths.get(workerDataFolder)));
try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(Paths.get(workerDataFolder))) {
for (Path child : directoryStream) {
fail("No sub dirs or files are expected in " + child.toString());
}
}
}
}
}
use of alluxio.ConfigurationRule in project alluxio by Alluxio.
the class FormatTest method formatWorker.
@Test
public void formatWorker() throws Exception {
final int storageLevels = 3;
final String perms = "rwx------";
String workerDataFolder;
final File[] dirs = new File[] { mTemporaryFolder.newFolder("level0"), mTemporaryFolder.newFolder("level1"), mTemporaryFolder.newFolder("level2") };
for (File dir : dirs) {
workerDataFolder = CommonUtils.getWorkerDataDirectory(dir.getPath(), ServerConfiguration.global());
FileUtils.createDir(PathUtils.concatPath(workerDataFolder, "subdir"));
FileUtils.createFile(PathUtils.concatPath(workerDataFolder, "file"));
}
try (Closeable r = new ConfigurationRule(new HashMap<PropertyKey, Object>() {
{
put(PropertyKey.WORKER_TIERED_STORE_LEVEL0_DIRS_PATH, dirs[0].getPath());
put(PropertyKey.WORKER_TIERED_STORE_LEVEL1_DIRS_PATH, dirs[1].getPath());
put(PropertyKey.WORKER_TIERED_STORE_LEVEL2_DIRS_PATH, dirs[2].getPath());
put(PropertyKey.WORKER_TIERED_STORE_LEVELS, String.valueOf(storageLevels));
put(PropertyKey.WORKER_DATA_FOLDER_PERMISSIONS, perms);
}
}, ServerConfiguration.global()).toResource()) {
Format.format(Format.Mode.WORKER, ServerConfiguration.global());
for (File dir : dirs) {
workerDataFolder = CommonUtils.getWorkerDataDirectory(dir.getPath(), ServerConfiguration.global());
assertTrue(FileUtils.exists(dir.getPath()));
assertTrue(FileUtils.exists(workerDataFolder));
assertEquals(PosixFilePermissions.fromString(perms), Files.getPosixFilePermissions(Paths.get(workerDataFolder)));
try (DirectoryStream<Path> directoryStream = Files.newDirectoryStream(Paths.get(workerDataFolder))) {
for (Path child : directoryStream) {
fail("No sub dirs or files are expected in " + child.toString());
}
}
}
}
}
use of alluxio.ConfigurationRule in project alluxio by Alluxio.
the class S3AUnderFileSystemTest method createCredentialsFromConf.
@Test
public void createCredentialsFromConf() throws Exception {
Map<PropertyKey, Object> conf = new HashMap<>();
conf.put(PropertyKey.S3A_ACCESS_KEY, "key1");
conf.put(PropertyKey.S3A_SECRET_KEY, "key2");
try (Closeable c = new ConfigurationRule(conf, sConf).toResource()) {
UnderFileSystemConfiguration ufsConf = UnderFileSystemConfiguration.defaults(sConf);
AWSCredentialsProvider credentialsProvider = S3AUnderFileSystem.createAwsCredentialsProvider(ufsConf);
Assert.assertEquals("key1", credentialsProvider.getCredentials().getAWSAccessKeyId());
Assert.assertEquals("key2", credentialsProvider.getCredentials().getAWSSecretKey());
Assert.assertTrue(credentialsProvider instanceof AWSStaticCredentialsProvider);
}
}
use of alluxio.ConfigurationRule in project alluxio by Alluxio.
the class S3AUnderFileSystemTest method createCredentialsFromDefault.
@Test
public void createCredentialsFromDefault() throws Exception {
// Unset AWS properties if present
Map<PropertyKey, Object> conf = new HashMap<>();
conf.put(PropertyKey.S3A_ACCESS_KEY, null);
conf.put(PropertyKey.S3A_SECRET_KEY, null);
try (Closeable c = new ConfigurationRule(conf, sConf).toResource()) {
UnderFileSystemConfiguration ufsConf = UnderFileSystemConfiguration.defaults(sConf);
AWSCredentialsProvider credentialsProvider = S3AUnderFileSystem.createAwsCredentialsProvider(ufsConf);
Assert.assertTrue(credentialsProvider instanceof DefaultAWSCredentialsProviderChain);
}
}
Aggregations