Search in sources :

Example 46 with FileSystem

use of alluxio.client.file.FileSystem in project alluxio by Alluxio.

the class ManagerProcessContextTest method testApplyNewMount.

@Test
public void testApplyNewMount() throws Exception {
    FileSystem mockFs = mock(FileSystem.class);
    Map<String, MountPointInfo> mpi = new HashMap<>();
    mpi.put("/", new MountPointInfo().setUfsUri("hdfs://localhost:9000/").setReadOnly(true).setUfsType("hdfs").setUfsCapacityBytes(9001));
    doReturn(mockFs).when(mContext).getFileSystem();
    doReturn(mpi).when(mockFs).getMountTable();
    ApplyMountPointRequest vr = ApplyMountPointRequest.newBuilder().setPayload(ApplyMountPointRequest.Payload.newBuilder().setNew(mContext.getMountPointList().getMountPointList().get(0))).build();
    mContext.applyMount(vr);
}
Also used : MountPointInfo(alluxio.wire.MountPointInfo) HashMap(java.util.HashMap) FileSystem(alluxio.client.file.FileSystem) ApplyMountPointRequest(alluxio.hub.proto.ApplyMountPointRequest) BaseHubTest(alluxio.hub.test.BaseHubTest) Test(org.junit.Test)

Example 47 with FileSystem

use of alluxio.client.file.FileSystem in project alluxio by Alluxio.

the class MultiProcessCluster method getPrimaryMasterIndex.

/**
 * Gets the index of the primary master.
 *
 * @param timeoutMs maximum amount of time to wait, in milliseconds
 * @return the index of the primary master
 */
public synchronized int getPrimaryMasterIndex(int timeoutMs) throws TimeoutException, InterruptedException {
    final FileSystem fs = getFileSystemClient();
    final MasterInquireClient inquireClient = getMasterInquireClient();
    CommonUtils.waitFor("a primary master to be serving", () -> {
        try {
            // Make sure the leader is serving.
            fs.getStatus(new AlluxioURI("/"));
            return true;
        } catch (Exception e) {
            LOG.error("Failed to get status of root directory:", e);
            return false;
        }
    }, WaitForOptions.defaults().setTimeoutMs(timeoutMs));
    int primaryRpcPort;
    try {
        primaryRpcPort = inquireClient.getPrimaryRpcAddress().getPort();
    } catch (UnavailableException e) {
        throw new RuntimeException(e);
    }
    // Returns the master whose RPC port matches the primary RPC port.
    for (int i = 0; i < mMasterAddresses.size(); i++) {
        if (mMasterAddresses.get(i).getRpcPort() == primaryRpcPort) {
            return i;
        }
    }
    throw new RuntimeException(String.format("No master found with RPC port %d. Master addresses: %s", primaryRpcPort, mMasterAddresses));
}
Also used : SingleMasterInquireClient(alluxio.master.SingleMasterInquireClient) PollingMasterInquireClient(alluxio.master.PollingMasterInquireClient) ZkMasterInquireClient(alluxio.master.ZkMasterInquireClient) MasterInquireClient(alluxio.master.MasterInquireClient) FileSystem(alluxio.client.file.FileSystem) UnavailableException(alluxio.exception.status.UnavailableException) TimeoutException(java.util.concurrent.TimeoutException) UnavailableException(alluxio.exception.status.UnavailableException) IOException(java.io.IOException) AlluxioURI(alluxio.AlluxioURI)

Example 48 with FileSystem

use of alluxio.client.file.FileSystem in project alluxio by Alluxio.

the class BasicNonByteBufferOperations method call.

@Override
public Boolean call() throws Exception {
    FileSystem alluxioClient = FileSystem.Factory.create(mFsContext);
    write(alluxioClient);
    return read(alluxioClient);
}
Also used : FileSystem(alluxio.client.file.FileSystem)

Example 49 with FileSystem

use of alluxio.client.file.FileSystem in project alluxio by Alluxio.

the class BasicCheckpoint method call.

@Override
public Boolean call() throws Exception {
    FileSystem fs = FileSystem.Factory.create(mFsContext);
    writeFile(fs);
    return readFile(fs);
}
Also used : FileSystem(alluxio.client.file.FileSystem)

Example 50 with FileSystem

use of alluxio.client.file.FileSystem in project alluxio by Alluxio.

the class BasicOperations method call.

@Override
public Boolean call() throws Exception {
    FileSystem fs = FileSystem.Factory.create(mFsContext);
    writeFile(fs);
    return readFile(fs);
}
Also used : FileSystem(alluxio.client.file.FileSystem)

Aggregations

FileSystem (alluxio.client.file.FileSystem)122 AlluxioURI (alluxio.AlluxioURI)90 Test (org.junit.Test)75 URIStatus (alluxio.client.file.URIStatus)42 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)22 FileInStream (alluxio.client.file.FileInStream)13 IOException (java.io.IOException)12 AbstractFileSystemShellTest (alluxio.client.cli.fs.AbstractFileSystemShellTest)11 ArrayList (java.util.ArrayList)11 FileOutStream (alluxio.client.file.FileOutStream)10 AlluxioException (alluxio.exception.AlluxioException)9 File (java.io.File)9 Path (javax.ws.rs.Path)9 FileDoesNotExistException (alluxio.exception.FileDoesNotExistException)8 HashMap (java.util.HashMap)8 FileSystemContext (alluxio.client.file.FileSystemContext)7 FileAlreadyExistsException (alluxio.exception.FileAlreadyExistsException)6 CreateFilePOptions (alluxio.grpc.CreateFilePOptions)6 TestUserState (alluxio.security.user.TestUserState)6 InstancedConfiguration (alluxio.conf.InstancedConfiguration)5