use of alluxio.client.file.FileSystemContext in project SSM by Intel-bigdata.
the class AlluxioUtil method getAlluxioFs.
public static FileSystem getAlluxioFs(SmartContext context) throws IOException {
String alluxioMaster = context.getConf().get(SmartConfKeys.SMART_ALLUXIO_MASTER_HOSTNAME_KEY, "localhost");
Configuration.set(PropertyKey.MASTER_HOSTNAME, alluxioMaster);
FileSystemContext fsContext = FileSystemContext.create();
return FileSystem.Factory.get(fsContext);
}
use of alluxio.client.file.FileSystemContext in project alluxio by Alluxio.
the class PlanCoordinatorTest method before.
@Before
public void before() throws Exception {
mCommandManager = new CommandManager();
// Create mock JobServerContext
FileSystem fs = mock(FileSystem.class);
FileSystemContext fsCtx = PowerMockito.mock(FileSystemContext.class);
UfsManager ufsManager = Mockito.mock(UfsManager.class);
mJobServerContext = new JobServerContext(fs, fsCtx, ufsManager);
// Create mock job info.
mJobconfig = Mockito.mock(JobConfig.class, Mockito.withSettings().serializable());
Mockito.when(mJobconfig.getName()).thenReturn("mock");
mJobId = 1;
// Create mock job definition.
@SuppressWarnings("unchecked") PlanDefinition<JobConfig, Serializable, Serializable> mockPlanDefinition = Mockito.mock(PlanDefinition.class);
PlanDefinitionRegistry singleton = PowerMockito.mock(PlanDefinitionRegistry.class);
Whitebox.setInternalState(PlanDefinitionRegistry.class, "INSTANCE", singleton);
Mockito.when(singleton.getJobDefinition(mJobconfig)).thenReturn(mockPlanDefinition);
mPlanDefinition = mockPlanDefinition;
// Create test worker.
mWorkerInfo = new WorkerInfo();
mWorkerInfo.setId(0);
mWorkerInfoList = Lists.newArrayList(mWorkerInfo);
}
use of alluxio.client.file.FileSystemContext in project alluxio by Alluxio.
the class FileSystemAdminShellUtils method checkMasterClientService.
/**
* Checks if the master client service is available.
* Throws an exception if fails to determine that the master client service is running.
*
* @param alluxioConf Alluxio configuration
*/
public static void checkMasterClientService(AlluxioConfiguration alluxioConf) throws IOException {
try (FileSystemContext context = FileSystemContext.create(ClientContext.create(alluxioConf));
CloseableResource<FileSystemMasterClient> client = context.acquireMasterClientResource()) {
InetSocketAddress address = client.get().getAddress();
List<InetSocketAddress> addresses = Arrays.asList(address);
MasterInquireClient inquireClient = new PollingMasterInquireClient(addresses, () -> new ExponentialBackoffRetry(50, 100, 2), alluxioConf);
inquireClient.getPrimaryRpcAddress();
} catch (UnavailableException e) {
throw new IOException("Cannot connect to Alluxio leader master.");
}
}
use of alluxio.client.file.FileSystemContext in project alluxio by Alluxio.
the class MultiWorkerIntegrationTest method replicateFileBlocks.
private void replicateFileBlocks(AlluxioURI filePath) throws Exception {
FileSystemContext fsContext = FileSystemContext.create(ServerConfiguration.global());
AlluxioBlockStore store = AlluxioBlockStore.create(fsContext);
URIStatus status = mResource.get().getClient().getStatus(filePath);
List<FileBlockInfo> blocks = status.getFileBlockInfos();
List<BlockWorkerInfo> workers = fsContext.getCachedWorkers();
for (FileBlockInfo block : blocks) {
BlockInfo blockInfo = block.getBlockInfo();
WorkerNetAddress src = blockInfo.getLocations().get(0).getWorkerAddress();
WorkerNetAddress dest = workers.stream().filter(candidate -> !candidate.getNetAddress().equals(src)).findFirst().get().getNetAddress();
try (OutputStream outStream = store.getOutStream(blockInfo.getBlockId(), blockInfo.getLength(), dest, OutStreamOptions.defaults(fsContext.getClientContext()).setBlockSizeBytes(8 * Constants.MB).setWriteType(WriteType.MUST_CACHE))) {
try (InputStream inStream = store.getInStream(blockInfo.getBlockId(), new InStreamOptions(status, ServerConfiguration.global()))) {
ByteStreams.copy(inStream, outStream);
}
}
}
}
use of alluxio.client.file.FileSystemContext in project alluxio by Alluxio.
the class MasterFaultToleranceIntegrationTest method workerReRegister.
@Test
public void workerReRegister() throws Exception {
for (int kills = 0; kills < MASTERS - 1; kills++) {
assertTrue(mMultiMasterLocalAlluxioCluster.stopLeader());
mMultiMasterLocalAlluxioCluster.waitForNewMaster(CLUSTER_WAIT_TIMEOUT_MS);
FileSystemContext context = FileSystemContext.create(ServerConfiguration.global());
AlluxioBlockStore store = AlluxioBlockStore.create(context);
waitForWorkerRegistration(context, 1, 1 * Constants.MINUTE_MS);
// If worker is successfully re-registered, the capacity bytes should not change.
long capacityFound = store.getCapacityBytes();
assertEquals(WORKER_CAPACITY_BYTES, capacityFound);
}
}
Aggregations