Refine search
/** * Provides a gRPC {@link MethodDescriptor} for a RPC method/message of Avro {@link Protocol}. * * @param methodType gRPC type for the method. * @return a {@link MethodDescriptor} */ public MethodDescriptor<Object[], Object> getMethod(String methodName, MethodDescriptor .MethodType methodType) { return methods.computeIfAbsent(methodName, key -> MethodDescriptor.<Object[], Object>newBuilder() .setFullMethodName(generateFullMethodName(serviceName, methodName)) .setType(methodType) .setRequestMarshaller(new AvroRequestMarshaller(protocol.getMessages().get(methodName))) .setResponseMarshaller( new AvroResponseMarshaller(protocol.getMessages().get(methodName))) .build()); } }
/** Returns the span name of the request. Defaults to the full grpc method name. */ protected <ReqT, RespT> String spanName(MethodDescriptor<ReqT, RespT> methodDescriptor) { return methodDescriptor.getFullMethodName(); }
public static MethodDescriptor convertJsonDescriptor(MethodDescriptor oldDesc, Class req, Class res){ MethodDescriptor.Marshaller reqMarshaller = getJsonMarshaller(req); MethodDescriptor.Marshaller resMarshaller = getJsonMarshaller(res); if(reqMarshaller != null && resMarshaller != null){ return MethodDescriptor.create(oldDesc.getType(), oldDesc.getFullMethodName(), reqMarshaller, resMarshaller); } return null; }
/** * {@inheritDoc} */ @Override public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall( final MethodDescriptor<ReqT, RespT> method, final CallOptions callOptions, final Channel next ) { final String methodType = method.getType().toString(); final String methodName = method.getFullMethodName(); final int channelId = next.hashCode(); log.info("gRPC {} call: {} (channel: {})", methodType, methodName, channelId); return next.newCall(method, callOptions); } }
@io.grpc.stub.annotations.RpcMethod( fullMethodName = SERVICE_NAME + '/' + "Free", requestType = alluxio.grpc.FreePRequest.class, responseType = alluxio.grpc.FreePResponse.class, methodType = io.grpc.MethodDescriptor.MethodType.UNARY) public static io.grpc.MethodDescriptor<alluxio.grpc.FreePRequest, alluxio.grpc.FreePResponse> getFreeMethod() { io.grpc.MethodDescriptor<alluxio.grpc.FreePRequest, alluxio.grpc.FreePResponse> getFreeMethod; if ((getFreeMethod = FileSystemMasterClientServiceGrpc.getFreeMethod) == null) { synchronized (FileSystemMasterClientServiceGrpc.class) { if ((getFreeMethod = FileSystemMasterClientServiceGrpc.getFreeMethod) == null) { FileSystemMasterClientServiceGrpc.getFreeMethod = getFreeMethod = io.grpc.MethodDescriptor.<alluxio.grpc.FreePRequest, alluxio.grpc.FreePResponse>newBuilder() .setType(io.grpc.MethodDescriptor.MethodType.UNARY) .setFullMethodName(generateFullMethodName( "alluxio.grpc.file.FileSystemMasterClientService", "Free")) .setSampledToLocalTracing(true) .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( alluxio.grpc.FreePRequest.getDefaultInstance())) .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( alluxio.grpc.FreePResponse.getDefaultInstance())) .setSchemaDescriptor(new FileSystemMasterClientServiceMethodDescriptorSupplier("Free")) .build(); } } } return getFreeMethod; }
MethodType methodType = methodDesc.getType(); switch (methodType) { case UNARY:
@io.grpc.stub.annotations.RpcMethod( fullMethodName = SERVICE_NAME + '/' + "Rename", requestType = alluxio.grpc.RenamePRequest.class, responseType = alluxio.grpc.RenamePResponse.class, methodType = io.grpc.MethodDescriptor.MethodType.UNARY) public static io.grpc.MethodDescriptor<alluxio.grpc.RenamePRequest, alluxio.grpc.RenamePResponse> getRenameMethod() { io.grpc.MethodDescriptor<alluxio.grpc.RenamePRequest, alluxio.grpc.RenamePResponse> getRenameMethod; if ((getRenameMethod = FileSystemMasterClientServiceGrpc.getRenameMethod) == null) { synchronized (FileSystemMasterClientServiceGrpc.class) { if ((getRenameMethod = FileSystemMasterClientServiceGrpc.getRenameMethod) == null) { FileSystemMasterClientServiceGrpc.getRenameMethod = getRenameMethod = io.grpc.MethodDescriptor.<alluxio.grpc.RenamePRequest, alluxio.grpc.RenamePResponse>newBuilder() .setType(io.grpc.MethodDescriptor.MethodType.UNARY) .setFullMethodName(generateFullMethodName( "alluxio.grpc.file.FileSystemMasterClientService", "Rename")) .setSampledToLocalTracing(true) .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( alluxio.grpc.RenamePRequest.getDefaultInstance())) .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( alluxio.grpc.RenamePResponse.getDefaultInstance())) .setSchemaDescriptor(new FileSystemMasterClientServiceMethodDescriptorSupplier("Rename")) .build(); } } } return getRenameMethod; }
@io.grpc.stub.annotations.RpcMethod( fullMethodName = SERVICE_NAME + '/' + "SetAttribute", requestType = alluxio.grpc.SetAttributePRequest.class, responseType = alluxio.grpc.SetAttributePResponse.class, methodType = io.grpc.MethodDescriptor.MethodType.UNARY) public static io.grpc.MethodDescriptor<alluxio.grpc.SetAttributePRequest, alluxio.grpc.SetAttributePResponse> getSetAttributeMethod() { io.grpc.MethodDescriptor<alluxio.grpc.SetAttributePRequest, alluxio.grpc.SetAttributePResponse> getSetAttributeMethod; if ((getSetAttributeMethod = FileSystemMasterClientServiceGrpc.getSetAttributeMethod) == null) { synchronized (FileSystemMasterClientServiceGrpc.class) { if ((getSetAttributeMethod = FileSystemMasterClientServiceGrpc.getSetAttributeMethod) == null) { FileSystemMasterClientServiceGrpc.getSetAttributeMethod = getSetAttributeMethod = io.grpc.MethodDescriptor.<alluxio.grpc.SetAttributePRequest, alluxio.grpc.SetAttributePResponse>newBuilder() .setType(io.grpc.MethodDescriptor.MethodType.UNARY) .setFullMethodName(generateFullMethodName( "alluxio.grpc.file.FileSystemMasterClientService", "SetAttribute")) .setSampledToLocalTracing(true) .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( alluxio.grpc.SetAttributePRequest.getDefaultInstance())) .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( alluxio.grpc.SetAttributePResponse.getDefaultInstance())) .setSchemaDescriptor(new FileSystemMasterClientServiceMethodDescriptorSupplier("SetAttribute")) .build(); } } } return getSetAttributeMethod; }
void log(String message) { logger.log( level, "{0}[{1}]: {2}", new Object[] { method.getFullMethodName(), Integer.toHexString(System.identityHashCode(this)), message }); }
@io.grpc.stub.annotations.RpcMethod( fullMethodName = SERVICE_NAME + '/' + "StopSync", requestType = alluxio.grpc.StopSyncPRequest.class, responseType = alluxio.grpc.StopSyncPResponse.class, methodType = io.grpc.MethodDescriptor.MethodType.UNARY) public static io.grpc.MethodDescriptor<alluxio.grpc.StopSyncPRequest, alluxio.grpc.StopSyncPResponse> getStopSyncMethod() { io.grpc.MethodDescriptor<alluxio.grpc.StopSyncPRequest, alluxio.grpc.StopSyncPResponse> getStopSyncMethod; if ((getStopSyncMethod = FileSystemMasterClientServiceGrpc.getStopSyncMethod) == null) { synchronized (FileSystemMasterClientServiceGrpc.class) { if ((getStopSyncMethod = FileSystemMasterClientServiceGrpc.getStopSyncMethod) == null) { FileSystemMasterClientServiceGrpc.getStopSyncMethod = getStopSyncMethod = io.grpc.MethodDescriptor.<alluxio.grpc.StopSyncPRequest, alluxio.grpc.StopSyncPResponse>newBuilder() .setType(io.grpc.MethodDescriptor.MethodType.UNARY) .setFullMethodName(generateFullMethodName( "alluxio.grpc.file.FileSystemMasterClientService", "StopSync")) .setSampledToLocalTracing(true) .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( alluxio.grpc.StopSyncPRequest.getDefaultInstance())) .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( alluxio.grpc.StopSyncPResponse.getDefaultInstance())) .setSchemaDescriptor(new FileSystemMasterClientServiceMethodDescriptorSupplier("StopSync")) .build(); } } } return getStopSyncMethod; }
/** * Returns a {@link RpcRequest} corresponding to the given {@link MethodDescriptor}. */ public static RpcRequest rpcRequest(MethodDescriptor<?, ?> method, Object message) { // We don't actually use the RpcRequest for request processing since it doesn't fit well with streaming. // We still populate it with a reasonable method name for use in logging. The service type is currently // arbitrarily set as gRPC doesn't use Class<?> to represent services - if this becomes a problem, we // would need to refactor it to take a Object instead. return RpcRequest.of(GrpcLogUtil.class, method.getFullMethodName(), message); }
@io.grpc.stub.annotations.RpcMethod( fullMethodName = SERVICE_NAME + '/' + "MasterHeartbeat", requestType = alluxio.grpc.MasterHeartbeatPRequest.class, responseType = alluxio.grpc.MasterHeartbeatPResponse.class, methodType = io.grpc.MethodDescriptor.MethodType.UNARY) public static io.grpc.MethodDescriptor<alluxio.grpc.MasterHeartbeatPRequest, alluxio.grpc.MasterHeartbeatPResponse> getMasterHeartbeatMethod() { io.grpc.MethodDescriptor<alluxio.grpc.MasterHeartbeatPRequest, alluxio.grpc.MasterHeartbeatPResponse> getMasterHeartbeatMethod; if ((getMasterHeartbeatMethod = MetaMasterMasterServiceGrpc.getMasterHeartbeatMethod) == null) { synchronized (MetaMasterMasterServiceGrpc.class) { if ((getMasterHeartbeatMethod = MetaMasterMasterServiceGrpc.getMasterHeartbeatMethod) == null) { MetaMasterMasterServiceGrpc.getMasterHeartbeatMethod = getMasterHeartbeatMethod = io.grpc.MethodDescriptor.<alluxio.grpc.MasterHeartbeatPRequest, alluxio.grpc.MasterHeartbeatPResponse>newBuilder() .setType(io.grpc.MethodDescriptor.MethodType.UNARY) .setFullMethodName(generateFullMethodName( "alluxio.grpc.meta.MetaMasterMasterService", "MasterHeartbeat")) .setSampledToLocalTracing(true) .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( alluxio.grpc.MasterHeartbeatPRequest.getDefaultInstance())) .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( alluxio.grpc.MasterHeartbeatPResponse.getDefaultInstance())) .setSchemaDescriptor(new MetaMasterMasterServiceMethodDescriptorSupplier("MasterHeartbeat")) .build(); } } } return getMasterHeartbeatMethod; }
/** * Returns a {@link RpcRequest} corresponding to the given {@link MethodDescriptor}. */ public static RpcRequest rpcRequest(MethodDescriptor<?, ?> method) { // See below to learn why we use GrpcLogUtil.class here. return RpcRequest.of(GrpcLogUtil.class, method.getFullMethodName()); }
@io.grpc.stub.annotations.RpcMethod( fullMethodName = SERVICE_NAME + '/' + "GetBlockMasterInfo", requestType = alluxio.grpc.GetBlockMasterInfoPOptions.class, responseType = alluxio.grpc.GetBlockMasterInfoPResponse.class, methodType = io.grpc.MethodDescriptor.MethodType.UNARY) public static io.grpc.MethodDescriptor<alluxio.grpc.GetBlockMasterInfoPOptions, alluxio.grpc.GetBlockMasterInfoPResponse> getGetBlockMasterInfoMethod() { io.grpc.MethodDescriptor<alluxio.grpc.GetBlockMasterInfoPOptions, alluxio.grpc.GetBlockMasterInfoPResponse> getGetBlockMasterInfoMethod; if ((getGetBlockMasterInfoMethod = BlockMasterClientServiceGrpc.getGetBlockMasterInfoMethod) == null) { synchronized (BlockMasterClientServiceGrpc.class) { if ((getGetBlockMasterInfoMethod = BlockMasterClientServiceGrpc.getGetBlockMasterInfoMethod) == null) { BlockMasterClientServiceGrpc.getGetBlockMasterInfoMethod = getGetBlockMasterInfoMethod = io.grpc.MethodDescriptor.<alluxio.grpc.GetBlockMasterInfoPOptions, alluxio.grpc.GetBlockMasterInfoPResponse>newBuilder() .setType(io.grpc.MethodDescriptor.MethodType.UNARY) .setFullMethodName(generateFullMethodName( "alluxio.grpc.block.BlockMasterClientService", "GetBlockMasterInfo")) .setSampledToLocalTracing(true) .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( alluxio.grpc.GetBlockMasterInfoPOptions.getDefaultInstance())) .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( alluxio.grpc.GetBlockMasterInfoPResponse.getDefaultInstance())) .setSchemaDescriptor(new BlockMasterClientServiceMethodDescriptorSupplier("GetBlockMasterInfo")) .build(); } } } return getGetBlockMasterInfoMethod; }
public void removeService(ServerServiceDefinition service) { if (service != null) { for (ServerMethodDefinition<?, ?> method : service.getMethods()) { methods.remove(method.getMethodDescriptor().getFullMethodName()); } } }
@io.grpc.stub.annotations.RpcMethod( fullMethodName = SERVICE_NAME + '/' + "CommitBlock", requestType = alluxio.grpc.CommitBlockPRequest.class, responseType = alluxio.grpc.CommitBlockPResponse.class, methodType = io.grpc.MethodDescriptor.MethodType.UNARY) public static io.grpc.MethodDescriptor<alluxio.grpc.CommitBlockPRequest, alluxio.grpc.CommitBlockPResponse> getCommitBlockMethod() { io.grpc.MethodDescriptor<alluxio.grpc.CommitBlockPRequest, alluxio.grpc.CommitBlockPResponse> getCommitBlockMethod; if ((getCommitBlockMethod = BlockMasterWorkerServiceGrpc.getCommitBlockMethod) == null) { synchronized (BlockMasterWorkerServiceGrpc.class) { if ((getCommitBlockMethod = BlockMasterWorkerServiceGrpc.getCommitBlockMethod) == null) { BlockMasterWorkerServiceGrpc.getCommitBlockMethod = getCommitBlockMethod = io.grpc.MethodDescriptor.<alluxio.grpc.CommitBlockPRequest, alluxio.grpc.CommitBlockPResponse>newBuilder() .setType(io.grpc.MethodDescriptor.MethodType.UNARY) .setFullMethodName(generateFullMethodName( "alluxio.grpc.block.BlockMasterWorkerService", "CommitBlock")) .setSampledToLocalTracing(true) .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( alluxio.grpc.CommitBlockPRequest.getDefaultInstance())) .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( alluxio.grpc.CommitBlockPResponse.getDefaultInstance())) .setSchemaDescriptor(new BlockMasterWorkerServiceMethodDescriptorSupplier("CommitBlock")) .build(); } } } return getCommitBlockMethod; }
@Override public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(ServerCall<ReqT, RespT> call, Metadata headers, ServerCallHandler<ReqT, RespT> next) { System.out.println(call.getMethodDescriptor().getFullMethodName()); log.info(call.getMethodDescriptor().getFullMethodName()); return next.startCall(call, headers); } }
@io.grpc.stub.annotations.RpcMethod( fullMethodName = SERVICE_NAME + '/' + "FileSystemHeartbeat", requestType = alluxio.grpc.FileSystemHeartbeatPRequest.class, responseType = alluxio.grpc.FileSystemHeartbeatPResponse.class, methodType = io.grpc.MethodDescriptor.MethodType.UNARY) public static io.grpc.MethodDescriptor<alluxio.grpc.FileSystemHeartbeatPRequest, alluxio.grpc.FileSystemHeartbeatPResponse> getFileSystemHeartbeatMethod() { io.grpc.MethodDescriptor<alluxio.grpc.FileSystemHeartbeatPRequest, alluxio.grpc.FileSystemHeartbeatPResponse> getFileSystemHeartbeatMethod; if ((getFileSystemHeartbeatMethod = FileSystemMasterWorkerServiceGrpc.getFileSystemHeartbeatMethod) == null) { synchronized (FileSystemMasterWorkerServiceGrpc.class) { if ((getFileSystemHeartbeatMethod = FileSystemMasterWorkerServiceGrpc.getFileSystemHeartbeatMethod) == null) { FileSystemMasterWorkerServiceGrpc.getFileSystemHeartbeatMethod = getFileSystemHeartbeatMethod = io.grpc.MethodDescriptor.<alluxio.grpc.FileSystemHeartbeatPRequest, alluxio.grpc.FileSystemHeartbeatPResponse>newBuilder() .setType(io.grpc.MethodDescriptor.MethodType.UNARY) .setFullMethodName(generateFullMethodName( "alluxio.grpc.file.FileSystemMasterWorkerService", "FileSystemHeartbeat")) .setSampledToLocalTracing(true) .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( alluxio.grpc.FileSystemHeartbeatPRequest.getDefaultInstance())) .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( alluxio.grpc.FileSystemHeartbeatPResponse.getDefaultInstance())) .setSchemaDescriptor(new FileSystemMasterWorkerServiceMethodDescriptorSupplier("FileSystemHeartbeat")) .build(); } } } return getFileSystemHeartbeatMethod; }
HandlerRegistry build() { final ImmutableMap.Builder<String, ServerMethodDefinition<?, ?>> mapBuilder = ImmutableMap.builder(); for (ServerServiceDefinition service : services.values()) { for (ServerMethodDefinition<?, ?> method : service.getMethods()) { mapBuilder.put(method.getMethodDescriptor().getFullMethodName(), method); } } return new HandlerRegistry(ImmutableList.copyOf(services.values()), mapBuilder.build()); } }
@io.grpc.stub.annotations.RpcMethod( fullMethodName = SERVICE_NAME + '/' + "GetPinnedFileIds", requestType = alluxio.grpc.GetPinnedFileIdsPRequest.class, responseType = alluxio.grpc.GetPinnedFileIdsPResponse.class, methodType = io.grpc.MethodDescriptor.MethodType.UNARY) public static io.grpc.MethodDescriptor<alluxio.grpc.GetPinnedFileIdsPRequest, alluxio.grpc.GetPinnedFileIdsPResponse> getGetPinnedFileIdsMethod() { io.grpc.MethodDescriptor<alluxio.grpc.GetPinnedFileIdsPRequest, alluxio.grpc.GetPinnedFileIdsPResponse> getGetPinnedFileIdsMethod; if ((getGetPinnedFileIdsMethod = FileSystemMasterWorkerServiceGrpc.getGetPinnedFileIdsMethod) == null) { synchronized (FileSystemMasterWorkerServiceGrpc.class) { if ((getGetPinnedFileIdsMethod = FileSystemMasterWorkerServiceGrpc.getGetPinnedFileIdsMethod) == null) { FileSystemMasterWorkerServiceGrpc.getGetPinnedFileIdsMethod = getGetPinnedFileIdsMethod = io.grpc.MethodDescriptor.<alluxio.grpc.GetPinnedFileIdsPRequest, alluxio.grpc.GetPinnedFileIdsPResponse>newBuilder() .setType(io.grpc.MethodDescriptor.MethodType.UNARY) .setFullMethodName(generateFullMethodName( "alluxio.grpc.file.FileSystemMasterWorkerService", "GetPinnedFileIds")) .setSampledToLocalTracing(true) .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( alluxio.grpc.GetPinnedFileIdsPRequest.getDefaultInstance())) .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( alluxio.grpc.GetPinnedFileIdsPResponse.getDefaultInstance())) .setSchemaDescriptor(new FileSystemMasterWorkerServiceMethodDescriptorSupplier("GetPinnedFileIds")) .build(); } } } return getGetPinnedFileIdsMethod; }