Search in sources :

Example 1 with GetStatusPOptions

use of alluxio.grpc.GetStatusPOptions in project alluxio by Alluxio.

the class FileSystemMasterClientServiceHandler method getStatus.

@Override
public void getStatus(GetStatusPRequest request, StreamObserver<GetStatusPResponse> responseObserver) {
    GetStatusPOptions options = request.getOptions();
    RpcUtils.call(LOG, () -> {
        AlluxioURI pathUri = getAlluxioURI(request.getPath());
        return GetStatusPResponse.newBuilder().setFileInfo(GrpcUtils.toProto(mFileSystemMaster.getFileInfo(pathUri, GetStatusContext.create(options.toBuilder()).withTracker(new GrpcCallTracker(responseObserver))))).build();
    }, "GetStatus", true, "request=%s", responseObserver, request);
}
Also used : GrpcCallTracker(alluxio.master.file.contexts.GrpcCallTracker) GetStatusPOptions(alluxio.grpc.GetStatusPOptions) AlluxioURI(alluxio.AlluxioURI)

Example 2 with GetStatusPOptions

use of alluxio.grpc.GetStatusPOptions in project alluxio by Alluxio.

the class GetStatusContext method mergeFrom.

/**
 * Merges and embeds the given {@link GetStatusPOptions} with the corresponding master options.
 *
 * @param optionsBuilder Builder for proto {@link GetStatusPOptions} to merge with defaults
 * @return the instance of {@link GetStatusContext} with default values for master
 */
public static GetStatusContext mergeFrom(GetStatusPOptions.Builder optionsBuilder) {
    GetStatusPOptions masterOptions = FileSystemOptions.getStatusDefaults(ServerConfiguration.global());
    GetStatusPOptions.Builder mergedOptionsBuilder = masterOptions.toBuilder().mergeFrom(optionsBuilder.build());
    return create(mergedOptionsBuilder);
}
Also used : GetStatusPOptions(alluxio.grpc.GetStatusPOptions)

Example 3 with GetStatusPOptions

use of alluxio.grpc.GetStatusPOptions in project alluxio by Alluxio.

the class BaseFileSystemTest method getStatus.

/**
 * Tests for the {@link BaseFileSystem#getStatus(AlluxioURI, GetStatusPOptions)} method.
 */
@Test
public void getStatus() throws Exception {
    AlluxioURI file = new AlluxioURI("/file");
    URIStatus status = new URIStatus(new FileInfo());
    GetStatusPOptions getStatusOptions = GetStatusPOptions.getDefaultInstance();
    when(mFileSystemMasterClient.getStatus(file, FileSystemOptions.getStatusDefaults(mConf).toBuilder().mergeFrom(getStatusOptions).build())).thenReturn(status);
    assertSame(status, mFileSystem.getStatus(file, getStatusOptions));
    verify(mFileSystemMasterClient).getStatus(file, FileSystemOptions.getStatusDefaults(mConf).toBuilder().mergeFrom(getStatusOptions).build());
    verifyFilesystemContextAcquiredAndReleased();
}
Also used : FileInfo(alluxio.wire.FileInfo) GetStatusPOptions(alluxio.grpc.GetStatusPOptions) AlluxioURI(alluxio.AlluxioURI) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 4 with GetStatusPOptions

use of alluxio.grpc.GetStatusPOptions in project alluxio by Alluxio.

the class BaseFileSystemTest method getStatusException.

/**
 * Ensures that an exception is propagated correctly when retrieving information.
 */
@Test
public void getStatusException() throws Exception {
    AlluxioURI file = new AlluxioURI("/file");
    GetStatusPOptions getStatusOptions = GetStatusPOptions.getDefaultInstance();
    when(mFileSystemMasterClient.getStatus(file, FileSystemOptions.getStatusDefaults(mConf).toBuilder().mergeFrom(getStatusOptions).build())).thenThrow(EXCEPTION);
    try {
        mFileSystem.getStatus(file, getStatusOptions);
        fail(SHOULD_HAVE_PROPAGATED_MESSAGE);
    } catch (Exception e) {
        assertSame(EXCEPTION, e);
    }
    verifyFilesystemContextAcquiredAndReleased();
}
Also used : GetStatusPOptions(alluxio.grpc.GetStatusPOptions) AlluxioURI(alluxio.AlluxioURI) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 5 with GetStatusPOptions

use of alluxio.grpc.GetStatusPOptions in project alluxio by Alluxio.

the class BaseFileSystemTest method openException.

/**
 * Ensures that an exception is propagated successfully when opening a file.
 */
@Test
public void openException() throws Exception {
    AlluxioURI file = new AlluxioURI("/file");
    GetStatusPOptions getStatusOptions = getOpenOptions(GetStatusPOptions.getDefaultInstance());
    when(mFileSystemMasterClient.getStatus(file, getStatusOptions)).thenThrow(EXCEPTION);
    try {
        mFileSystem.openFile(file, OpenFilePOptions.getDefaultInstance());
        fail(SHOULD_HAVE_PROPAGATED_MESSAGE);
    } catch (Exception e) {
        assertSame(EXCEPTION, e);
    }
    verifyFilesystemContextAcquiredAndReleased();
}
Also used : GetStatusPOptions(alluxio.grpc.GetStatusPOptions) AlluxioURI(alluxio.AlluxioURI) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

GetStatusPOptions (alluxio.grpc.GetStatusPOptions)38 Test (org.junit.Test)34 BaseIntegrationTest (alluxio.testutils.BaseIntegrationTest)26 AlluxioURI (alluxio.AlluxioURI)17 URIStatus (alluxio.client.file.URIStatus)12 File (java.io.File)9 ListStatusPOptions (alluxio.grpc.ListStatusPOptions)6 AbstractFileSystemShellTest (alluxio.client.cli.fs.AbstractFileSystemShellTest)4 DeletePOptions (alluxio.grpc.DeletePOptions)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 FileInfo (alluxio.wire.FileInfo)2 AlluxioConfiguration (alluxio.conf.AlluxioConfiguration)1 AlluxioException (alluxio.exception.AlluxioException)1 SetAttributePOptions (alluxio.grpc.SetAttributePOptions)1 GrpcCallTracker (alluxio.master.file.contexts.GrpcCallTracker)1 Mode (alluxio.security.authorization.Mode)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1