Search in sources :

Example 16 with ClientContext

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());
}
Also used : ClientContext(alluxio.ClientContext) Test(org.junit.Test)

Example 17 with ClientContext

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());
}
Also used : ClientContext(alluxio.ClientContext) Test(org.junit.Test)

Example 18 with ClientContext

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;
}
Also used : MasterInquireClient(alluxio.master.MasterInquireClient) ClientContext(alluxio.ClientContext) MasterClientContext(alluxio.master.MasterClientContext)

Example 19 with ClientContext

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);
}
Also used : FileSystemMasterClient(alluxio.client.file.FileSystemMasterClient) MetadataCachingBaseFileSystem(alluxio.client.file.MetadataCachingBaseFileSystem) ClientContext(alluxio.ClientContext) FuseShell(alluxio.cli.FuseShell) FileSystemContext(alluxio.client.file.FileSystemContext) Before(org.junit.Before)

Example 20 with ClientContext

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 });
}
Also used : Context(alluxio.cli.fsadmin.command.Context) MasterClientContext(alluxio.master.MasterClientContext) ClientContext(alluxio.ClientContext) JobMasterClientContext(alluxio.worker.job.JobMasterClientContext) RetryHandlingFileSystemMasterClient(alluxio.client.file.RetryHandlingFileSystemMasterClient) RetryHandlingJournalMasterClient(alluxio.client.journal.RetryHandlingJournalMasterClient) RetryHandlingJobMasterClient(alluxio.client.job.RetryHandlingJobMasterClient) JobMasterClientContext(alluxio.worker.job.JobMasterClientContext) MasterClientContext(alluxio.master.MasterClientContext) ClientContext(alluxio.ClientContext) JobMasterClientContext(alluxio.worker.job.JobMasterClientContext) MasterClientContext(alluxio.master.MasterClientContext) JobMasterClientContext(alluxio.worker.job.JobMasterClientContext) RetryHandlingMetaMasterClient(alluxio.client.meta.RetryHandlingMetaMasterClient) RetryHandlingMetaMasterConfigClient(alluxio.client.meta.RetryHandlingMetaMasterConfigClient) RetryHandlingMetricsMasterClient(alluxio.client.metrics.RetryHandlingMetricsMasterClient) RetryHandlingBlockMasterClient(alluxio.client.block.RetryHandlingBlockMasterClient)

Aggregations

ClientContext (alluxio.ClientContext)20 Test (org.junit.Test)12 MasterClientContext (alluxio.master.MasterClientContext)7 MasterInquireClient (alluxio.master.MasterInquireClient)6 InstancedConfiguration (alluxio.conf.InstancedConfiguration)4 JobMasterClientContext (alluxio.worker.job.JobMasterClientContext)3 IOException (java.io.IOException)3 BlockMasterClient (alluxio.client.block.BlockMasterClient)2 FileSystemContext (alluxio.client.file.FileSystemContext)2 BlockMasterInfo (alluxio.wire.BlockMasterInfo)2 HashSet (java.util.HashSet)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 SystemPropertyRule (alluxio.SystemPropertyRule)1 FuseShell (alluxio.cli.FuseShell)1 Context (alluxio.cli.fsadmin.command.Context)1 AlluxioStorageType (alluxio.client.AlluxioStorageType)1 UnderStorageType (alluxio.client.UnderStorageType)1 WriteType (alluxio.client.WriteType)1 BlockWorkerInfo (alluxio.client.block.BlockWorkerInfo)1 RetryHandlingBlockMasterClient (alluxio.client.block.RetryHandlingBlockMasterClient)1