Search in sources :

Example 1 with FileSystemContext

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);
}
Also used : FileSystemContext(alluxio.client.file.FileSystemContext)

Example 2 with FileSystemContext

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);
}
Also used : PlanDefinitionRegistry(alluxio.job.plan.PlanDefinitionRegistry) JobServerContext(alluxio.job.JobServerContext) Serializable(java.io.Serializable) CommandManager(alluxio.master.job.command.CommandManager) UfsManager(alluxio.underfs.UfsManager) FileSystem(alluxio.client.file.FileSystem) FileSystemContext(alluxio.client.file.FileSystemContext) WorkerInfo(alluxio.wire.WorkerInfo) JobConfig(alluxio.job.JobConfig) Before(org.junit.Before)

Example 3 with FileSystemContext

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.");
    }
}
Also used : PollingMasterInquireClient(alluxio.master.PollingMasterInquireClient) MasterInquireClient(alluxio.master.MasterInquireClient) FileSystemMasterClient(alluxio.client.file.FileSystemMasterClient) PollingMasterInquireClient(alluxio.master.PollingMasterInquireClient) InetSocketAddress(java.net.InetSocketAddress) ExponentialBackoffRetry(alluxio.retry.ExponentialBackoffRetry) UnavailableException(alluxio.exception.status.UnavailableException) FileSystemContext(alluxio.client.file.FileSystemContext) IOException(java.io.IOException)

Example 4 with FileSystemContext

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);
            }
        }
    }
}
Also used : CreateFilePOptions(alluxio.grpc.CreateFilePOptions) BufferUtils(alluxio.util.io.BufferUtils) BlockLocationPolicy(alluxio.client.block.policy.BlockLocationPolicy) WorkerNetAddress(alluxio.wire.WorkerNetAddress) BlockInfo(alluxio.wire.BlockInfo) BlockWorkerInfo(alluxio.client.block.BlockWorkerInfo) FileSystemTestUtils(alluxio.client.file.FileSystemTestUtils) FileBlockInfo(alluxio.wire.FileBlockInfo) PropertyKey(alluxio.conf.PropertyKey) FileSystem(alluxio.client.file.FileSystem) Constants(alluxio.Constants) AlluxioURI(alluxio.AlluxioURI) FileInStream(alluxio.client.file.FileInStream) AlluxioConfiguration(alluxio.conf.AlluxioConfiguration) StreamSupport(java.util.stream.StreamSupport) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) OutputStream(java.io.OutputStream) WritePType(alluxio.grpc.WritePType) ServerConfiguration(alluxio.conf.ServerConfiguration) LocalAlluxioClusterResource(alluxio.testutils.LocalAlluxioClusterResource) InStreamOptions(alluxio.client.file.options.InStreamOptions) OutStreamOptions(alluxio.client.file.options.OutStreamOptions) Test(org.junit.Test) IOException(java.io.IOException) OpenFilePOptions(alluxio.grpc.OpenFilePOptions) AlluxioBlockStore(alluxio.client.block.AlluxioBlockStore) GetWorkerOptions(alluxio.client.block.policy.options.GetWorkerOptions) IOUtils(org.apache.commons.io.IOUtils) URIStatus(alluxio.client.file.URIStatus) List(java.util.List) FileSystemContext(alluxio.client.file.FileSystemContext) Rule(org.junit.Rule) ByteStreams(com.google.common.io.ByteStreams) WriteType(alluxio.client.WriteType) Assert(org.junit.Assert) Assert.assertEquals(org.junit.Assert.assertEquals) InputStream(java.io.InputStream) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) URIStatus(alluxio.client.file.URIStatus) FileBlockInfo(alluxio.wire.FileBlockInfo) InStreamOptions(alluxio.client.file.options.InStreamOptions) BlockInfo(alluxio.wire.BlockInfo) FileBlockInfo(alluxio.wire.FileBlockInfo) WorkerNetAddress(alluxio.wire.WorkerNetAddress) BlockWorkerInfo(alluxio.client.block.BlockWorkerInfo) FileSystemContext(alluxio.client.file.FileSystemContext) AlluxioBlockStore(alluxio.client.block.AlluxioBlockStore)

Example 5 with FileSystemContext

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);
    }
}
Also used : FileSystemContext(alluxio.client.file.FileSystemContext) AlluxioBlockStore(alluxio.client.block.AlluxioBlockStore) BaseIntegrationTest(alluxio.testutils.BaseIntegrationTest) Test(org.junit.Test)

Aggregations

FileSystemContext (alluxio.client.file.FileSystemContext)28 AlluxioURI (alluxio.AlluxioURI)11 Test (org.junit.Test)9 URIStatus (alluxio.client.file.URIStatus)8 InstancedConfiguration (alluxio.conf.InstancedConfiguration)8 FileSystem (alluxio.client.file.FileSystem)7 WorkerNetAddress (alluxio.wire.WorkerNetAddress)7 IOException (java.io.IOException)7 Before (org.junit.Before)7 AlluxioBlockStore (alluxio.client.block.AlluxioBlockStore)5 BlockWorkerInfo (alluxio.client.block.BlockWorkerInfo)5 FileSystemMasterClient (alluxio.client.file.FileSystemMasterClient)5 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)5 BlockInfo (alluxio.wire.BlockInfo)5 FileBlockInfo (alluxio.wire.FileBlockInfo)5 ClientContext (alluxio.ClientContext)4 InStreamOptions (alluxio.client.file.options.InStreamOptions)4 AlluxioConfiguration (alluxio.conf.AlluxioConfiguration)4 OpenFilePOptions (alluxio.grpc.OpenFilePOptions)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4