use of alluxio.ClientContext in project alluxio by Alluxio.
the class GetConfTest method getConf.
@Test
public void getConf() throws Exception {
ServerConfiguration.set(PropertyKey.WORKER_RAMDISK_SIZE, "2048");
ClientContext ctx = ClientContext.create(ServerConfiguration.global());
assertEquals(0, GetConf.getConf(ctx, PropertyKey.WORKER_RAMDISK_SIZE.toString()));
assertEquals("2048\n", mOutputStream.toString());
mOutputStream.reset();
ServerConfiguration.set(PropertyKey.WORKER_RAMDISK_SIZE, "2MB");
ctx = ClientContext.create(ServerConfiguration.global());
assertEquals(0, GetConf.getConf(ctx, PropertyKey.WORKER_RAMDISK_SIZE.toString()));
assertEquals("2MB\n", mOutputStream.toString());
mOutputStream.reset();
ServerConfiguration.set(PropertyKey.WORKER_RAMDISK_SIZE, "Nonsense");
ctx = ClientContext.create(ServerConfiguration.global());
assertEquals(0, GetConf.getConf(ctx, PropertyKey.WORKER_RAMDISK_SIZE.toString()));
assertEquals("Nonsense\n", mOutputStream.toString());
}
use of alluxio.ClientContext in project alluxio by Alluxio.
the class GetConfTest method getConfWithCorrectUnit.
@Test
public void getConfWithCorrectUnit() throws Exception {
ServerConfiguration.set(PropertyKey.WORKER_RAMDISK_SIZE, "2048");
ClientContext ctx = ClientContext.create(ServerConfiguration.global());
assertEquals(0, GetConf.getConf(ctx, "--unit", "B", PropertyKey.WORKER_RAMDISK_SIZE.toString()));
assertEquals("2048\n", mOutputStream.toString());
mOutputStream.reset();
ServerConfiguration.set(PropertyKey.WORKER_RAMDISK_SIZE, "2048");
ctx = ClientContext.create(ServerConfiguration.global());
assertEquals(0, GetConf.getConf(ctx, "--unit", "KB", PropertyKey.WORKER_RAMDISK_SIZE.toString()));
assertEquals("2\n", mOutputStream.toString());
mOutputStream.reset();
ServerConfiguration.set(PropertyKey.WORKER_RAMDISK_SIZE, "2MB");
ctx = ClientContext.create(ServerConfiguration.global());
assertEquals(0, GetConf.getConf(ctx, "--unit", "KB", PropertyKey.WORKER_RAMDISK_SIZE.toString()));
assertEquals("2048\n", mOutputStream.toString());
mOutputStream.reset();
ServerConfiguration.set(PropertyKey.WORKER_RAMDISK_SIZE, "2MB");
ctx = ClientContext.create(ServerConfiguration.global());
assertEquals(0, GetConf.getConf(ctx, "--unit", "MB", PropertyKey.WORKER_RAMDISK_SIZE.toString()));
assertEquals("2\n", mOutputStream.toString());
}
use of alluxio.ClientContext in project alluxio by Alluxio.
the class FileSystemContext method create.
/**
* @param subject the parent subject, set to null if not present
* @param conf Alluxio configuration
* @param blockWorker block worker
* @return a context
*/
public static FileSystemContext create(@Nullable Subject subject, @Nullable AlluxioConfiguration conf, @Nullable BlockWorker blockWorker) {
ClientContext ctx = ClientContext.create(subject, conf);
MasterInquireClient inquireClient = MasterInquireClient.Factory.create(ctx.getClusterConf(), ctx.getUserState());
FileSystemContext context = new FileSystemContext(ctx.getClusterConf(), blockWorker);
context.init(ctx, inquireClient);
return context;
}
use of alluxio.ClientContext in project alluxio by Alluxio.
the class FuseShellTest method before.
@Before
public void before() throws Exception {
mConf.set(PropertyKey.USER_METADATA_CACHE_ENABLED, true);
ClientContext clientContext = ClientContext.create(mConf);
FileSystemContext fileContext = PowerMockito.mock(FileSystemContext.class);
mFileSystemMasterClient = new GetStatusFileSystemMasterClient();
when(fileContext.acquireMasterClientResource()).thenReturn(new CloseableResource<FileSystemMasterClient>(mFileSystemMasterClient) {
@Override
public void closeResource() {
// Noop.
}
});
when(fileContext.getClientContext()).thenReturn(clientContext);
when(fileContext.getClusterConf()).thenReturn(mConf);
when(fileContext.getPathConf(any())).thenReturn(mConf);
when(fileContext.getUriValidationEnabled()).thenReturn(true);
mFileSystem = new MetadataCachingBaseFileSystem(fileContext);
mFuseShell = new FuseShell(mFileSystem, mConf);
mFileStatusMap = new HashMap<>();
mFileStatusMap.put(FILE, FILE_STATUS);
mFileStatusMap.put(DIR, DIR_STATUS);
// Here metadata cache will have two contents.
mFileSystem.getStatus(FILE);
mFileSystem.getStatus(DIR);
// Remove from map, so the result will get from cache.
mFileStatusMap.remove(FILE);
mFileStatusMap.remove(DIR);
}
use of alluxio.ClientContext in project alluxio by Alluxio.
the class FileSystemAdminShell method loadCommands.
@Override
protected Map<String, Command> loadCommands() {
ClientContext ctx = ClientContext.create(mConfiguration);
MasterClientContext masterConfig = MasterClientContext.newBuilder(ctx).build();
JobMasterClientContext jobMasterConfig = JobMasterClientContext.newBuilder(ctx).build();
Context adminContext = new Context(new RetryHandlingFileSystemMasterClient(masterConfig), new RetryHandlingBlockMasterClient(masterConfig), new RetryHandlingMetaMasterClient(masterConfig), new RetryHandlingMetaMasterConfigClient(masterConfig), new RetryHandlingMetricsMasterClient(masterConfig), new RetryHandlingJournalMasterClient(masterConfig), new RetryHandlingJournalMasterClient(jobMasterConfig), new RetryHandlingJobMasterClient(jobMasterConfig), System.out);
return CommandUtils.loadCommands(FileSystemAdminShell.class.getPackage().getName(), new Class[] { Context.class, AlluxioConfiguration.class }, new Object[] { mCloser.register(adminContext), mConfiguration });
}
Aggregations