Search in sources :

Example 6 with GetTableMetadataResponse

use of com.scalar.db.rpc.GetTableMetadataResponse in project scalardb by scalar-labs.

the class DistributedStorageAdminService method getTableMetadata.

@Override
public void getTableMetadata(GetTableMetadataRequest request, StreamObserver<GetTableMetadataResponse> responseObserver) {
    execute(() -> {
        TableMetadata tableMetadata = admin.getTableMetadata(request.getNamespace(), request.getTable());
        GetTableMetadataResponse.Builder builder = GetTableMetadataResponse.newBuilder();
        if (tableMetadata != null) {
            builder.setTableMetadata(ProtoUtils.toTableMetadata(tableMetadata));
        }
        responseObserver.onNext(builder.build());
        responseObserver.onCompleted();
    }, responseObserver, "get_table_metadata");
}
Also used : TableMetadata(com.scalar.db.api.TableMetadata) GetTableMetadataResponse(com.scalar.db.rpc.GetTableMetadataResponse)

Example 7 with GetTableMetadataResponse

use of com.scalar.db.rpc.GetTableMetadataResponse in project scalardb by scalar-labs.

the class GrpcAdminTest method getTableMetadata_IsCalledWithProperArguments_MetadataManagerShouldBeCalledProperly.

@Test
public void getTableMetadata_IsCalledWithProperArguments_MetadataManagerShouldBeCalledProperly() throws ExecutionException {
    // Arrange
    String namespace = "namespace";
    String table = "table";
    GetTableMetadataResponse response = mock(GetTableMetadataResponse.class);
    when(stub.getTableMetadata(any())).thenReturn(response);
    // Act
    admin.getTableMetadata(namespace, table);
    // Assert
    verify(stub).getTableMetadata(any());
}
Also used : GetTableMetadataResponse(com.scalar.db.rpc.GetTableMetadataResponse) Test(org.junit.Test)

Aggregations

GetTableMetadataResponse (com.scalar.db.rpc.GetTableMetadataResponse)7 TableMetadata (com.scalar.db.api.TableMetadata)5 Test (org.junit.jupiter.api.Test)4 GetTableMetadataRequest (com.scalar.db.rpc.GetTableMetadataRequest)2 Test (org.junit.Test)1