diff --git a/pom.xml b/pom.xml index 291198413f12e1bc86e09578c8dba93a704ef593..04e1a9054d1c7b2ba3fd05ae67bbc390f795a09d 100644 --- a/pom.xml +++ b/pom.xml @@ -21,9 +21,6 @@ earth whatsmars-spring whatsmars-spring-boot - whatsmars-grpc-interface - whatsmars-grpc-service - whatsmars-grpc-client whatsmars-dbrouter whatsmars-worker whatsmars-rpc diff --git a/whatsmars-grpc-client/pom.xml b/whatsmars-grpc-client/pom.xml deleted file mode 100644 index f2304cc91d0ac2bbaa50151d37d39dd6a94fee7b..0000000000000000000000000000000000000000 --- a/whatsmars-grpc-client/pom.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - whatsmars-parent - com.itlong - 1.0-SNAPSHOT - - 4.0.0 - - whatsmars-grpc-client - jar - ${project.artifactId} - http://maven.apache.org - - - - io.grpc - grpc-netty - 1.0.0 - - - io.grpc - grpc-protobuf - 1.0.0 - - - io.grpc - grpc-stub - 1.0.0 - - - com.itlong - whatsmars-grpc-interface - 1.0-SNAPSHOT - - - - - ${project.artifactId} - - - kr.motd.maven - os-maven-plugin - 1.4.1.Final - - - - - org.xolstice.maven.plugins - protobuf-maven-plugin - 0.5.0 - - com.google.protobuf:protoc:3.0.0:exe:${os.detected.classifier} - grpc-java - io.grpc:protoc-gen-grpc-java:1.0.0:exe:${os.detected.classifier} - - - - - compile - compile-custom - - - - - - - - \ No newline at end of file diff --git a/whatsmars-grpc-client/src/main/java/com/itlong/whatsmars/grpc/client/HelloWorldClient.java b/whatsmars-grpc-client/src/main/java/com/itlong/whatsmars/grpc/client/HelloWorldClient.java deleted file mode 100644 index e00f0eaad0d9962a1535bf3d0172531f0f39747e..0000000000000000000000000000000000000000 --- a/whatsmars-grpc-client/src/main/java/com/itlong/whatsmars/grpc/client/HelloWorldClient.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.itlong.whatsmars.grpc.client; - -import com.itlong.whatsmars.grpc.service.HelloRequest; -import com.itlong.whatsmars.grpc.service.HelloResponse; -import com.itlong.whatsmars.grpc.service.HelloServiceGrpc; -import io.grpc.ManagedChannel; -import io.grpc.ManagedChannelBuilder; - -import java.util.concurrent.TimeUnit; - -/** - * Created by shenhongxi on 2017/5/5. - */ -public class HelloWorldClient { - - private final ManagedChannel channel; - private final HelloServiceGrpc.HelloServiceBlockingStub blockingStub; - - public HelloWorldClient(String host, int port){ - channel = ManagedChannelBuilder.forAddress(host, port) - .usePlaintext(true) - .build(); - - blockingStub = HelloServiceGrpc.newBlockingStub(channel); - } - - public void shutdown() throws InterruptedException { - channel.shutdown().awaitTermination(5, TimeUnit.SECONDS); - } - - public void greet(String name){ - HelloRequest request = HelloRequest.newBuilder().setName(name).build(); - HelloResponse response = blockingStub.sayHello(request); - System.out.println(response.getMessage()); - } - - public static void main(String[] args) throws InterruptedException { - HelloWorldClient client = new HelloWorldClient("127.0.0.1", 50051); - for(int i = 0; i < 5; i++) { - client.greet("world:" + i); - } - client.shutdown(); - } -} diff --git a/whatsmars-grpc-interface/pom.xml b/whatsmars-grpc-interface/pom.xml deleted file mode 100644 index bf46b262e9fc2abf1e6d3f78589ea40c2a47d315..0000000000000000000000000000000000000000 --- a/whatsmars-grpc-interface/pom.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - whatsmars-parent - com.itlong - 1.0-SNAPSHOT - - 4.0.0 - - whatsmars-grpc-interface - jar - ${project.artifactId} - http://maven.apache.org - - - - io.grpc - grpc-netty - 1.0.0 - - - io.grpc - grpc-protobuf - 1.0.0 - - - io.grpc - grpc-stub - 1.0.0 - - - - - ${project.artifactId} - - - kr.motd.maven - os-maven-plugin - 1.4.1.Final - - - - - org.xolstice.maven.plugins - protobuf-maven-plugin - 0.5.0 - - com.google.protobuf:protoc:3.0.0:exe:${os.detected.classifier} - grpc-java - io.grpc:protoc-gen-grpc-java:1.0.0:exe:${os.detected.classifier} - - - - - compile - compile-custom - - - - - - - - \ No newline at end of file diff --git a/whatsmars-grpc-interface/src/main/proto/helloworld.proto b/whatsmars-grpc-interface/src/main/proto/helloworld.proto deleted file mode 100644 index cd7d96c8fa52d50de7af77b5b0894fe5c3402fc0..0000000000000000000000000000000000000000 --- a/whatsmars-grpc-interface/src/main/proto/helloworld.proto +++ /dev/null @@ -1,24 +0,0 @@ -syntax = "proto3"; - -option java_multiple_files = true; -option java_package = "com.itlong.whatsmars.grpc.service"; -option java_outer_classname = "HelloWorldProto"; -option objc_class_prefix = "HLW"; - -package helloworld; - -// The greeting service definition. -service HelloService { - // Sends a greeting - rpc sayHello (HelloRequest) returns (HelloResponse) {} -} - -// The request message containing the user's name. -message HelloRequest { - string name = 1; -} - -// The response message containing the greetings -message HelloResponse { - string message = 1; -} \ No newline at end of file diff --git a/whatsmars-grpc-service/pom.xml b/whatsmars-grpc-service/pom.xml deleted file mode 100644 index c892a43a7afd45e3097b675cb8af5bab76da2d43..0000000000000000000000000000000000000000 --- a/whatsmars-grpc-service/pom.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - whatsmars-parent - com.itlong - 1.0-SNAPSHOT - - 4.0.0 - - whatsmars-grpc-service - jar - ${project.artifactId} - http://maven.apache.org - - - - io.grpc - grpc-netty - 1.0.0 - - - io.grpc - grpc-protobuf - 1.0.0 - - - io.grpc - grpc-stub - 1.0.0 - - - com.itlong - whatsmars-grpc-interface - 1.0-SNAPSHOT - - - - - ${project.artifactId} - - - \ No newline at end of file diff --git a/whatsmars-grpc-service/src/main/java/com/itlong/whatsmars/grpc/server/HelloWorldServer.java b/whatsmars-grpc-service/src/main/java/com/itlong/whatsmars/grpc/server/HelloWorldServer.java deleted file mode 100644 index ebb436eff17e73b6de5aabcc483c44d1af7e061d..0000000000000000000000000000000000000000 --- a/whatsmars-grpc-service/src/main/java/com/itlong/whatsmars/grpc/server/HelloWorldServer.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.itlong.whatsmars.grpc.server; - -import com.itlong.whatsmars.grpc.service.impl.HelloServiceImpl; -import io.grpc.Server; -import io.grpc.ServerBuilder; - -import java.io.IOException; - -/** - * Created by shenhongxi on 2017/5/5. - */ -public class HelloWorldServer { - - private int port = 50051; - private Server server; - - private void start() throws IOException { - server = ServerBuilder.forPort(port) - .addService(new HelloServiceImpl()) - .build() - .start(); - - System.out.println("service start..."); - - Runtime.getRuntime().addShutdownHook(new Thread() { - - @Override - public void run() { - - System.err.println("*** shutting down gRPC server since JVM is shutting down"); - HelloWorldServer.this.stop(); - System.err.println("*** server shut down"); - } - }); - } - - private void stop() { - if (server != null) { - server.shutdown(); - } - } - - // block 一直到退出程序 - private void blockUntilShutdown() throws InterruptedException { - if (server != null) { - server.awaitTermination(); - } - } - - public static void main(String[] args) throws IOException, InterruptedException { - final HelloWorldServer server = new HelloWorldServer(); - server.start(); - server.blockUntilShutdown(); - } - -} diff --git a/whatsmars-grpc-service/src/main/java/com/itlong/whatsmars/grpc/service/impl/HelloServiceImpl.java b/whatsmars-grpc-service/src/main/java/com/itlong/whatsmars/grpc/service/impl/HelloServiceImpl.java deleted file mode 100644 index 224ff60c9404f086914e36f72a794a74a056f0c1..0000000000000000000000000000000000000000 --- a/whatsmars-grpc-service/src/main/java/com/itlong/whatsmars/grpc/service/impl/HelloServiceImpl.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.itlong.whatsmars.grpc.service.impl; - -import com.itlong.whatsmars.grpc.service.HelloRequest; -import com.itlong.whatsmars.grpc.service.HelloResponse; -import com.itlong.whatsmars.grpc.service.HelloServiceGrpc; -import io.grpc.stub.StreamObserver; - -/** - * Created by shenhongxi on 2017/5/5. - */ -public class HelloServiceImpl extends HelloServiceGrpc.HelloServiceImplBase { - - public void sayHello(HelloRequest req, StreamObserver responseObserver) { - System.out.println("service:" + req.getName()); - HelloResponse response = HelloResponse.newBuilder().setMessage(("Hello: " + req.getName())).build(); - responseObserver.onNext(response); - responseObserver.onCompleted(); - } -}