use of alluxio.ClientContext in project alluxio by Alluxio.
the class OutStreamOptionsTest method fields.
/**
* Tests getting and setting fields.
*/
@Test
public void fields() throws Exception {
Random random = new Random();
long blockSize = random.nextLong();
BlockLocationPolicy locationPolicy = new RoundRobinPolicy(mConf);
String owner = CommonUtils.randomAlphaNumString(10);
String group = CommonUtils.randomAlphaNumString(10);
Mode mode = new Mode((short) random.nextInt());
int ttl = 5;
TtlAction ttlAction = TtlAction.FREE;
int writeTier = random.nextInt();
WriteType writeType = WriteType.NONE;
mConf.set(PropertyKey.USER_FILE_CREATE_TTL, ttl);
mConf.set(PropertyKey.USER_FILE_CREATE_TTL_ACTION, ttlAction);
ClientContext clientContext = ClientContext.create(mConf);
OutStreamOptions options = OutStreamOptions.defaults(clientContext);
options.setBlockSizeBytes(blockSize);
options.setLocationPolicy(locationPolicy);
options.setOwner(owner);
options.setGroup(group);
options.setMode(mode);
options.setWriteTier(writeTier);
options.setWriteType(writeType);
assertEquals(blockSize, options.getBlockSizeBytes());
assertEquals(locationPolicy, options.getLocationPolicy());
assertEquals(owner, options.getOwner());
assertEquals(group, options.getGroup());
assertEquals(mode, options.getMode());
assertEquals(ttl, options.getCommonOptions().getTtl());
assertEquals(ttlAction, options.getCommonOptions().getTtlAction());
assertEquals(writeTier, options.getWriteTier());
assertEquals(writeType.getAlluxioStorageType(), options.getAlluxioStorageType());
assertEquals(writeType.getUnderStorageType(), options.getUnderStorageType());
}
use of alluxio.ClientContext in project alluxio by Alluxio.
the class MetricsHeartbeatContextTest method testExecutorInitialized.
@Test
public void testExecutorInitialized() {
InstancedConfiguration conf = ConfigurationTestUtils.defaults();
conf.set(PropertyKey.MASTER_HOSTNAME, "localhost");
conf.set(PropertyKey.USER_RPC_RETRY_MAX_DURATION, "1s");
ClientContext ctx = ClientContext.create(conf);
MasterInquireClient client = MasterInquireClient.Factory.create(ctx.getClusterConf(), ctx.getUserState());
// Add and delete a single context, make sure it is non null after adding, and then null after
// removing
MetricsHeartbeatContext.addHeartbeat(ctx, client);
assertNotNull(getInternalExecutor());
MetricsHeartbeatContext.removeHeartbeat(ctx);
assertNull(getInternalExecutor());
// Add a few, then remove and check for the state in between
MetricsHeartbeatContext.addHeartbeat(ctx, client);
MetricsHeartbeatContext.addHeartbeat(ctx, client);
MetricsHeartbeatContext.addHeartbeat(ctx, client);
MetricsHeartbeatContext.addHeartbeat(ctx, client);
assertNotNull(getInternalExecutor());
MetricsHeartbeatContext.removeHeartbeat(ctx);
assertNotNull(getInternalExecutor());
MetricsHeartbeatContext.removeHeartbeat(ctx);
assertNotNull(getInternalExecutor());
MetricsHeartbeatContext.removeHeartbeat(ctx);
assertNotNull(getInternalExecutor());
MetricsHeartbeatContext.removeHeartbeat(ctx);
assertNull(getInternalExecutor());
}
use of alluxio.ClientContext in project alluxio by Alluxio.
the class StressJobServiceBench method prepare.
@Override
public void prepare() throws Exception {
mFsContext = FileSystemContext.create(new InstancedConfiguration(ConfigurationUtils.defaults()));
final ClientContext clientContext = mFsContext.getClientContext();
mJobMasterClient = JobMasterClient.Factory.create(JobMasterClientContext.newBuilder(clientContext).build());
}
use of alluxio.ClientContext in project alluxio by Alluxio.
the class FileSystemMasterClientPoolTest method create.
@Test
public void create() throws Exception {
AlluxioConfiguration conf = ConfigurationTestUtils.defaults();
FileSystemMasterClient expectedClient = Mockito.mock(FileSystemMasterClient.class);
PowerMockito.mockStatic(FileSystemMasterClient.Factory.class);
Mockito.when(FileSystemMasterClient.Factory.create(Mockito.any(MasterClientContext.class))).thenReturn(expectedClient);
FileSystemMasterClient client;
ClientContext clientContext = ClientContext.create(conf);
MasterInquireClient masterInquireClient = MasterInquireClient.Factory.create(conf, clientContext.getUserState());
MasterClientContext masterClientContext = MasterClientContext.newBuilder(clientContext).setMasterInquireClient(masterInquireClient).build();
try (FileSystemMasterClientPool pool = new FileSystemMasterClientPool(masterClientContext)) {
client = pool.acquire();
assertEquals(expectedClient, client);
pool.release(client);
}
Mockito.verify(client).close();
}
use of alluxio.ClientContext in project alluxio by Alluxio.
the class BlockMasterClientPoolTest method create.
@Test
public void create() throws Exception {
BlockMasterClient expectedClient = mock(BlockMasterClient.class);
PowerMockito.mockStatic(BlockMasterClient.Factory.class);
when(BlockMasterClient.Factory.create(any(MasterClientContext.class))).thenReturn(expectedClient);
BlockMasterClient client;
ClientContext clientContext = ClientContext.create(mConf);
MasterInquireClient masterInquireClient = MasterInquireClient.Factory.create(mConf, clientContext.getUserState());
MasterClientContext masterClientContext = MasterClientContext.newBuilder(clientContext).setMasterInquireClient(masterInquireClient).build();
try (BlockMasterClientPool pool = new BlockMasterClientPool(masterClientContext)) {
client = pool.acquire();
assertEquals(expectedClient, client);
pool.release(client);
}
verify(client).close();
}
Aggregations