diff --git a/escheduler-rpc/pom.xml b/escheduler-rpc/pom.xml new file mode 100644 index 0000000000..4c2ac91853 --- /dev/null +++ b/escheduler-rpc/pom.xml @@ -0,0 +1,122 @@ + + + + + escheduler + cn.analysys + 1.0.0 + + 4.0.0 + + escheduler-rpc + + escheduler-rpc + https://github.com/analysys/EasyScheduler + + + UTF-8 + 1.7 + 1.7 + + ${project.basedir}/src/main/java + 3.5.1 + 1.9.0 + + + + + com.google.protobuf + protobuf-java + ${protobuf.version} + + + io.grpc + grpc-netty + ${grpc.version} + + + io.grpc + grpc-protobuf + ${grpc.version} + + + io.grpc + grpc-stub + ${grpc.version} + + + + com.google.guava + guava + + + + + + + kr.motd.maven + os-maven-plugin + 1.5.0.Final + + + + + org.xolstice.maven.plugins + protobuf-maven-plugin + 0.5.0 + + com.google.protobuf:protoc:3.5.1-1:exe:${os.detected.classifier} + grpc-java + io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier} + + + + compile + + compile + + + + compile-custom + + compile-custom + + + ${protobuf.output.directory} + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.7 + + + add-classes + generate-sources + + add-source + + + + ${protobuf.output.directory} + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + ${java.version} + ${java.version} + ${project.build.sourceEncoding} + + + + + diff --git a/escheduler-rpc/src/main/java/cn/escheduler/rpc/LogViewServiceGrpc.java b/escheduler-rpc/src/main/java/cn/escheduler/rpc/LogViewServiceGrpc.java new file mode 100644 index 0000000000..8723eef842 --- /dev/null +++ b/escheduler-rpc/src/main/java/cn/escheduler/rpc/LogViewServiceGrpc.java @@ -0,0 +1,499 @@ +package cn.escheduler.rpc; + +import static io.grpc.MethodDescriptor.generateFullMethodName; +import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; +import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; +import static io.grpc.stub.ClientCalls.asyncUnaryCall; +import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; +import static io.grpc.stub.ClientCalls.blockingUnaryCall; +import static io.grpc.stub.ClientCalls.futureUnaryCall; +import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; +import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnaryCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; + +/** + *
+ **
+ *  log view service
+ * 
+ */ +@javax.annotation.Generated( + value = "by gRPC proto compiler (version 1.9.0)", + comments = "Source: scheduler.proto") +public final class LogViewServiceGrpc { + + private LogViewServiceGrpc() {} + + public static final String SERVICE_NAME = "schduler.LogViewService"; + + // Static method descriptors that strictly reflect the proto. + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getRollViewLogMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_ROLL_VIEW_LOG = getRollViewLogMethod(); + + private static volatile io.grpc.MethodDescriptor getRollViewLogMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getRollViewLogMethod() { + io.grpc.MethodDescriptor getRollViewLogMethod; + if ((getRollViewLogMethod = LogViewServiceGrpc.getRollViewLogMethod) == null) { + synchronized (LogViewServiceGrpc.class) { + if ((getRollViewLogMethod = LogViewServiceGrpc.getRollViewLogMethod) == null) { + LogViewServiceGrpc.getRollViewLogMethod = getRollViewLogMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "schduler.LogViewService", "rollViewLog")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + cn.escheduler.rpc.LogParameter.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + cn.escheduler.rpc.RetStrInfo.getDefaultInstance())) + .setSchemaDescriptor(new LogViewServiceMethodDescriptorSupplier("rollViewLog")) + .build(); + } + } + } + return getRollViewLogMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getViewLogMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_VIEW_LOG = getViewLogMethod(); + + private static volatile io.grpc.MethodDescriptor getViewLogMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getViewLogMethod() { + io.grpc.MethodDescriptor getViewLogMethod; + if ((getViewLogMethod = LogViewServiceGrpc.getViewLogMethod) == null) { + synchronized (LogViewServiceGrpc.class) { + if ((getViewLogMethod = LogViewServiceGrpc.getViewLogMethod) == null) { + LogViewServiceGrpc.getViewLogMethod = getViewLogMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "schduler.LogViewService", "viewLog")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + cn.escheduler.rpc.PathParameter.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + cn.escheduler.rpc.RetStrInfo.getDefaultInstance())) + .setSchemaDescriptor(new LogViewServiceMethodDescriptorSupplier("viewLog")) + .build(); + } + } + } + return getViewLogMethod; + } + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + @java.lang.Deprecated // Use {@link #getGetLogBytesMethod()} instead. + public static final io.grpc.MethodDescriptor METHOD_GET_LOG_BYTES = getGetLogBytesMethod(); + + private static volatile io.grpc.MethodDescriptor getGetLogBytesMethod; + + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static io.grpc.MethodDescriptor getGetLogBytesMethod() { + io.grpc.MethodDescriptor getGetLogBytesMethod; + if ((getGetLogBytesMethod = LogViewServiceGrpc.getGetLogBytesMethod) == null) { + synchronized (LogViewServiceGrpc.class) { + if ((getGetLogBytesMethod = LogViewServiceGrpc.getGetLogBytesMethod) == null) { + LogViewServiceGrpc.getGetLogBytesMethod = getGetLogBytesMethod = + io.grpc.MethodDescriptor.newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName( + "schduler.LogViewService", "getLogBytes")) + .setSampledToLocalTracing(true) + .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + cn.escheduler.rpc.PathParameter.getDefaultInstance())) + .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller( + cn.escheduler.rpc.RetByteInfo.getDefaultInstance())) + .setSchemaDescriptor(new LogViewServiceMethodDescriptorSupplier("getLogBytes")) + .build(); + } + } + } + return getGetLogBytesMethod; + } + + /** + * Creates a new async stub that supports all call types for the service + */ + public static LogViewServiceStub newStub(io.grpc.Channel channel) { + return new LogViewServiceStub(channel); + } + + /** + * Creates a new blocking-style stub that supports unary and streaming output calls on the service + */ + public static LogViewServiceBlockingStub newBlockingStub( + io.grpc.Channel channel) { + return new LogViewServiceBlockingStub(channel); + } + + /** + * Creates a new ListenableFuture-style stub that supports unary calls on the service + */ + public static LogViewServiceFutureStub newFutureStub( + io.grpc.Channel channel) { + return new LogViewServiceFutureStub(channel); + } + + /** + *
+   **
+   *  log view service
+   * 
+ */ + public static abstract class LogViewServiceImplBase implements io.grpc.BindableService { + + /** + *
+     **
+     *  roll view log
+     * 
+ */ + public void rollViewLog(cn.escheduler.rpc.LogParameter request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getRollViewLogMethod(), responseObserver); + } + + /** + *
+     **
+     * view all log
+     * 
+ */ + public void viewLog(cn.escheduler.rpc.PathParameter request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getViewLogMethod(), responseObserver); + } + + /** + *
+     **
+     * get log bytes
+     * 
+ */ + public void getLogBytes(cn.escheduler.rpc.PathParameter request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(getGetLogBytesMethod(), responseObserver); + } + + @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + getRollViewLogMethod(), + asyncUnaryCall( + new MethodHandlers< + cn.escheduler.rpc.LogParameter, + cn.escheduler.rpc.RetStrInfo>( + this, METHODID_ROLL_VIEW_LOG))) + .addMethod( + getViewLogMethod(), + asyncUnaryCall( + new MethodHandlers< + cn.escheduler.rpc.PathParameter, + cn.escheduler.rpc.RetStrInfo>( + this, METHODID_VIEW_LOG))) + .addMethod( + getGetLogBytesMethod(), + asyncUnaryCall( + new MethodHandlers< + cn.escheduler.rpc.PathParameter, + cn.escheduler.rpc.RetByteInfo>( + this, METHODID_GET_LOG_BYTES))) + .build(); + } + } + + /** + *
+   **
+   *  log view service
+   * 
+ */ + public static final class LogViewServiceStub extends io.grpc.stub.AbstractStub { + private LogViewServiceStub(io.grpc.Channel channel) { + super(channel); + } + + private LogViewServiceStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected LogViewServiceStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new LogViewServiceStub(channel, callOptions); + } + + /** + *
+     **
+     *  roll view log
+     * 
+ */ + public void rollViewLog(cn.escheduler.rpc.LogParameter request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getRollViewLogMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     **
+     * view all log
+     * 
+ */ + public void viewLog(cn.escheduler.rpc.PathParameter request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getViewLogMethod(), getCallOptions()), request, responseObserver); + } + + /** + *
+     **
+     * get log bytes
+     * 
+ */ + public void getLogBytes(cn.escheduler.rpc.PathParameter request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(getGetLogBytesMethod(), getCallOptions()), request, responseObserver); + } + } + + /** + *
+   **
+   *  log view service
+   * 
+ */ + public static final class LogViewServiceBlockingStub extends io.grpc.stub.AbstractStub { + private LogViewServiceBlockingStub(io.grpc.Channel channel) { + super(channel); + } + + private LogViewServiceBlockingStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected LogViewServiceBlockingStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new LogViewServiceBlockingStub(channel, callOptions); + } + + /** + *
+     **
+     *  roll view log
+     * 
+ */ + public cn.escheduler.rpc.RetStrInfo rollViewLog(cn.escheduler.rpc.LogParameter request) { + return blockingUnaryCall( + getChannel(), getRollViewLogMethod(), getCallOptions(), request); + } + + /** + *
+     **
+     * view all log
+     * 
+ */ + public cn.escheduler.rpc.RetStrInfo viewLog(cn.escheduler.rpc.PathParameter request) { + return blockingUnaryCall( + getChannel(), getViewLogMethod(), getCallOptions(), request); + } + + /** + *
+     **
+     * get log bytes
+     * 
+ */ + public cn.escheduler.rpc.RetByteInfo getLogBytes(cn.escheduler.rpc.PathParameter request) { + return blockingUnaryCall( + getChannel(), getGetLogBytesMethod(), getCallOptions(), request); + } + } + + /** + *
+   **
+   *  log view service
+   * 
+ */ + public static final class LogViewServiceFutureStub extends io.grpc.stub.AbstractStub { + private LogViewServiceFutureStub(io.grpc.Channel channel) { + super(channel); + } + + private LogViewServiceFutureStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected LogViewServiceFutureStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new LogViewServiceFutureStub(channel, callOptions); + } + + /** + *
+     **
+     *  roll view log
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture rollViewLog( + cn.escheduler.rpc.LogParameter request) { + return futureUnaryCall( + getChannel().newCall(getRollViewLogMethod(), getCallOptions()), request); + } + + /** + *
+     **
+     * view all log
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture viewLog( + cn.escheduler.rpc.PathParameter request) { + return futureUnaryCall( + getChannel().newCall(getViewLogMethod(), getCallOptions()), request); + } + + /** + *
+     **
+     * get log bytes
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture getLogBytes( + cn.escheduler.rpc.PathParameter request) { + return futureUnaryCall( + getChannel().newCall(getGetLogBytesMethod(), getCallOptions()), request); + } + } + + private static final int METHODID_ROLL_VIEW_LOG = 0; + private static final int METHODID_VIEW_LOG = 1; + private static final int METHODID_GET_LOG_BYTES = 2; + + private static final class MethodHandlers implements + io.grpc.stub.ServerCalls.UnaryMethod, + io.grpc.stub.ServerCalls.ServerStreamingMethod, + io.grpc.stub.ServerCalls.ClientStreamingMethod, + io.grpc.stub.ServerCalls.BidiStreamingMethod { + private final LogViewServiceImplBase serviceImpl; + private final int methodId; + + MethodHandlers(LogViewServiceImplBase serviceImpl, int methodId) { + this.serviceImpl = serviceImpl; + this.methodId = methodId; + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + case METHODID_ROLL_VIEW_LOG: + serviceImpl.rollViewLog((cn.escheduler.rpc.LogParameter) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_VIEW_LOG: + serviceImpl.viewLog((cn.escheduler.rpc.PathParameter) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_LOG_BYTES: + serviceImpl.getLogBytes((cn.escheduler.rpc.PathParameter) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + default: + throw new AssertionError(); + } + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public io.grpc.stub.StreamObserver invoke( + io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + default: + throw new AssertionError(); + } + } + } + + private static abstract class LogViewServiceBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier { + LogViewServiceBaseDescriptorSupplier() {} + + @java.lang.Override + public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { + return cn.escheduler.rpc.SchdulerProto.getDescriptor(); + } + + @java.lang.Override + public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { + return getFileDescriptor().findServiceByName("LogViewService"); + } + } + + private static final class LogViewServiceFileDescriptorSupplier + extends LogViewServiceBaseDescriptorSupplier { + LogViewServiceFileDescriptorSupplier() {} + } + + private static final class LogViewServiceMethodDescriptorSupplier + extends LogViewServiceBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { + private final String methodName; + + LogViewServiceMethodDescriptorSupplier(String methodName) { + this.methodName = methodName; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { + return getServiceDescriptor().findMethodByName(methodName); + } + } + + private static volatile io.grpc.ServiceDescriptor serviceDescriptor; + + public static io.grpc.ServiceDescriptor getServiceDescriptor() { + io.grpc.ServiceDescriptor result = serviceDescriptor; + if (result == null) { + synchronized (LogViewServiceGrpc.class) { + result = serviceDescriptor; + if (result == null) { + serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) + .setSchemaDescriptor(new LogViewServiceFileDescriptorSupplier()) + .addMethod(getRollViewLogMethod()) + .addMethod(getViewLogMethod()) + .addMethod(getGetLogBytesMethod()) + .build(); + } + } + } + return result; + } +} diff --git a/escheduler-rpc/src/main/proto/scheduler.proto b/escheduler-rpc/src/main/proto/scheduler.proto new file mode 100644 index 0000000000..7f1129740d --- /dev/null +++ b/escheduler-rpc/src/main/proto/scheduler.proto @@ -0,0 +1,83 @@ +syntax = "proto3"; + +package schduler; + +option java_multiple_files = true; +option java_package = "cn.escheduler.rpc"; +option java_outer_classname = "SchdulerProto"; + + +/** + * return str info + */ +message RetStrInfo { + /** + * str msg info + */ + string msg = 1 ; +} + +/** + * return byte info + */ +message RetByteInfo { + /** + * byte data info + */ + bytes data = 1; +} + +/** + * log parameter + */ +message LogParameter { + + /** + * path + */ + string path = 1 ; + + /** + * skip line num + */ + int32 skipLineNum = 2 ; + + /** + * display limt num + */ + int32 limit = 3 ; +} + + +/** + * path parameter + */ +message PathParameter { + + /** + * path + */ + string path = 1 ; +} + +/** + * log view service + */ +service LogViewService { + + /** + * roll view log + */ + rpc rollViewLog(LogParameter) returns (RetStrInfo) {}; + + /** + * view all log + */ + rpc viewLog(PathParameter) returns (RetStrInfo) {}; + + /** + * get log bytes + */ + rpc getLogBytes(PathParameter) returns (RetByteInfo) {}; +} +