diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..bb1df59 --- /dev/null +++ b/build.gradle @@ -0,0 +1,17 @@ +group 'com.dingding.octopus' +version '1.0-SNAPSHOT' + +apply plugin: "maven" +apply plugin: 'maven-publish' + +apply plugin: 'java' + +sourceCompatibility = 1.8 + +repositories { + mavenCentral() +} + +dependencies { + testCompile group: 'junit', name: 'junit', version: '4.11' +} diff --git a/octopus-rpc-core/build.gradle b/octopus-rpc-core/build.gradle new file mode 100644 index 0000000..e1d384b --- /dev/null +++ b/octopus-rpc-core/build.gradle @@ -0,0 +1,45 @@ +buildscript { + ext { + springBootVersion = '1.3.5.RELEASE' + } + repositories { + mavenCentral() + maven { url 'http://repo.spring.io/plugins-release' } + maven { url "http://repo.spring.io/libs-release" } + maven { url "http://repo.spring.io/milestone" } + maven { url "http://repo.spring.io/snapshot" } + } + dependencies { + //classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") + //classpath('org.springframework.build.gradle:propdeps-plugin:0.0.7') + } +} + +apply plugin: 'java' +apply plugin: 'eclipse' +//apply plugin: 'spring-boot' +//apply plugin: 'propdeps' +//apply plugin: 'propdeps-maven' +//apply plugin: 'propdeps-idea' + + +repositories { + mavenCentral() + maven { url "http://repo.spring.io/libs-release" } + maven { url "http://repo.spring.io/milestone" } + maven { url "http://repo.spring.io/snapshot" } +} + + +dependencies { + compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.21' + compile('io.grpc:grpc-netty:1.0.1') + compile('io.grpc:grpc-protobuf:1.0.1') + compile('io.grpc:grpc-stub:1.0.1') + compile('org.projectlombok:lombok:1.16.8') + //compile('org.springframework.boot:spring-boot-starter') + //testCompile('org.springframework.boot:spring-boot-starter-test') + //optional ('org.springframework.boot:spring-boot-configuration-processor') +} + +//compileJava.dependsOn(processResources) \ No newline at end of file diff --git a/octopus-rpc-core/src/main/java/com/dingding/octopus/rpc/client/AdvancedLBChannel.java b/octopus-rpc-core/src/main/java/com/dingding/octopus/rpc/client/AdvancedLBChannel.java new file mode 100644 index 0000000..574e1ac --- /dev/null +++ b/octopus-rpc-core/src/main/java/com/dingding/octopus/rpc/client/AdvancedLBChannel.java @@ -0,0 +1,233 @@ +package com.dingding.octopus.rpc.client; + +import com.dingding.octopus.rpc.common.CoreUtilProto; +import com.dingding.octopus.rpc.common.DetectUtils; +import com.dingding.octopus.rpc.common.HeartBeatMessageType; +import com.dingding.octopus.rpc.common.RpcServerUtilGrpc; +import io.grpc.*; +import io.grpc.stub.StreamObserver; +import io.netty.handler.ssl.SslProvider; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; + +import java.util.*; +import java.util.concurrent.*; + +/** + * XD + * Created by guna on 16/9/16. + */ + +@Slf4j +public class AdvancedLBChannel extends Channel{ + + + private final Map> methodMap= new ConcurrentHashMap<>(); + private final Set channelSet = new CopyOnWriteArraySet<>(); + private final Random rand = new Random(); + private static final TL tl = new TL(); + + public AdvancedLBChannel(){ + log.info("Create main LBC Channel..."); + new Thread(()->{ + while (tl.isRunning()){ + try { + Thread.sleep(10000); + } catch (InterruptedException ignore) { + return; + } + + long current = System.currentTimeMillis(); + channelSet.forEach((channel)->{ + ChannelConfig config = channel.getConfig(); + if(current - config.getLastPingSuccessTime() > 30000){ + closeChannel(channel); + } + if(!config.isConnecting()){ + StreamObserver observer = channel.getObserver(); + if(observer != null){ + if (!tl.isRunning()){ + return; + } + observer.onNext(CoreUtilProto.ClientInformation.newBuilder() + .setId(config.getId()).setSeq(config.getLastPingSuccessSeq() + 1).setName(config.getName()) + .setType(HeartBeatMessageType.HEART_BEAT).setTime(current) + .build()); + } + } + + + }); + } + }).start(); + + } + + public Map> getMethodMap() { + return methodMap; + } + + public void addChannel(ChannelConfig config,boolean waitForConnect){ + //Blind and ask for + + CoreUtilProto.ClientInformation clientInformation = CoreUtilProto.ClientInformation.newBuilder().setId(config.getId()).setType(HeartBeatMessageType.CONNECT) + .setName(config.getName()).setSeq(0).setTime(System.currentTimeMillis()).build(); + TrackedChannel channel = new TrackedChannel(config); + config.setConnecting(true); + config.setLastPingSuccessSeq(0); + config.setLastPingSuccessTime(System.currentTimeMillis()); + channelSet.add(channel); + CompletableFuture completableFuture = new CompletableFuture<>(); + StreamObserver observer = RpcServerUtilGrpc.newStub(channel).heartBeat(new StreamObserver() { + @Override + public void onNext(CoreUtilProto.ServerInformation value) { + switch (value.getType()){ + case HeartBeatMessageType.CONNECT_ACCEPT: + Map servicesMap = value.getServicesMap(); + log.info("Connection accepted,server {} ({}:{})", config.getName(),config.getAddress(),config.getPort() ); + if(servicesMap != null){ + //Loop + servicesMap.forEach((k,v) -> { + //v:Method Name + List channels = methodMap.get(v); + if(channels == null){ + channels = new ArrayList<>(); + methodMap.put(v,channels); + } + channels.add(channel); + config.setConnecting(false); + config.setRetryCount(0); + }); + } + if (waitForConnect){ + completableFuture.complete(channel); + }else { + EventBus.oneChannelConnected(); + } + break; + + case HeartBeatMessageType.HEART_BEAT: + onHeartBeat(value,channel); + break; + + default: + log.warn("Unknown message type {}",value.getType()); + + } + } + + @Override + public void onError(Throwable t) { + log.info("Remote Server Channel error..",t); + } + + @Override + public void onCompleted() { + closeChannel(channel); + } + }); + channel.setObserver(observer); + observer.onNext(clientInformation); + if (waitForConnect){ + try { + completableFuture.get(2000, TimeUnit.MILLISECONDS); + } catch (InterruptedException e) { + log.error("InterruptedException when add services.",e); + } catch (ExecutionException e) { + log.error("ExecutionException when add services.",e); + } catch (TimeoutException e) { + log.error("Wait Channel {} timed out",channel.toString(),e); + } + } + + } + + @Override + public ClientCall newCall(MethodDescriptor methodDescriptor, CallOptions callOptions) { + List channels = methodMap.get(methodDescriptor.getFullMethodName()); + if(channels == null || channels.size() < 1){ + log.error("No Server can handle request {}",methodDescriptor.getFullMethodName()); + throw new RuntimeException("No Server can handle request " + methodDescriptor.getFullMethodName()); + } + return channels.get(rand.nextInt(channels.size())).newCall(methodDescriptor, callOptions); + } + + @Override + public String authority() { + return null; + } + + + private void onHeartBeat(CoreUtilProto.ServerInformation serverInformation,TrackedChannel channel){ + ChannelConfig channelConfig = channel.getConfig(); + channelConfig.setLastPingSuccessSeq(serverInformation.getSeq()); + channelConfig.setLastPingSuccessTime(System.currentTimeMillis()); + channelConfig.setConnecting(false); + channelConfig.setRetryCount(0); + + } + + private void closeChannel(TrackedChannel channel){ + log.info("Remote Server Channel closed.."); + EventBus.oneChannelDisconnected(); + synchronized (methodMap){ + methodMap.forEach((k,v)-> v.remove(channel)); + + methodMap.forEach((k,v)->{ + if(v.size() < 1){ + methodMap.remove(k); + } + }); + channelSet.remove(channel); + log.info("Remote Server Channel left..{}",channelSet.size()); + new Thread(()->{ + try { + Thread.sleep(2000); + }catch (Exception ignore){ + + } + if(tl.isRunning()) { + retryConnection(channel.getConfig()); + } + }).start(); + + } + + //TODO : Retry?? + + } + + public void close(){ + tl.setRunning(false); + log.info("Sending close info to server.."); + channelSet.forEach((v)->{ + StreamObserver observer = v.getObserver(); + if(observer != null){ + try { + observer.onCompleted(); + }catch (Exception ignore){ + + } + } + }); + try { + log.info("Wait 2000ms to ensure closed."); + Thread.sleep(2000); + }catch (Exception ignore){ + + } + + } + + private void retryConnection(ChannelConfig config){ + config.setConnecting(true); + config.setRetryCount(0); + config.setReconnectTime(System.currentTimeMillis()); + log.info("Retrying Connection {} , on {}:{}",config.getName(),config.getAddress(),config.getPort()); + addChannel(config,false); + } +} +@Data +class TL{ + private boolean running = true; +} \ No newline at end of file diff --git a/octopus-rpc-core/src/main/java/com/dingding/octopus/rpc/client/ChannelConfig.java b/octopus-rpc-core/src/main/java/com/dingding/octopus/rpc/client/ChannelConfig.java new file mode 100644 index 0000000..f0a2d0d --- /dev/null +++ b/octopus-rpc-core/src/main/java/com/dingding/octopus/rpc/client/ChannelConfig.java @@ -0,0 +1,21 @@ +package com.dingding.octopus.rpc.client; + +import lombok.Data; + +/** + * Channel Config + * Created by guna on 16/9/17. + */ +@Data +public class ChannelConfig { + private String address; + private String name; + private String id; + private int port; + private long lastPingSuccessTime; + private long lastPingSuccessSeq; + private long reconnectTime; + private int retryCount; + private boolean connecting; + private boolean ssl; +} diff --git a/octopus-rpc-core/src/main/java/com/dingding/octopus/rpc/client/EventBus.java b/octopus-rpc-core/src/main/java/com/dingding/octopus/rpc/client/EventBus.java new file mode 100644 index 0000000..febf110 --- /dev/null +++ b/octopus-rpc-core/src/main/java/com/dingding/octopus/rpc/client/EventBus.java @@ -0,0 +1,37 @@ +package com.dingding.octopus.rpc.client; + +import java.util.ArrayList; +import java.util.List; + +/** + * EC + * Created by guna on 16/9/19. + */ +public class EventBus { + + private static List listeners = new ArrayList<>(); + + static void oneChannelConnected(){ + listeners.forEach((v)->{ + try { + v.onOneChannelConnect(); + }catch (Exception ignore){ + + } + }); + } + + static void oneChannelDisconnected(){ + listeners.forEach((v)->{ + try { + v.onOneChannelDisconnect(); + }catch (Exception ignore){ + + } + }); + } + + public void addListener(MainChannelListener listener){ + listeners.add(listener); + } +} diff --git a/octopus-rpc-core/src/main/java/com/dingding/octopus/rpc/client/MainChannelListener.java b/octopus-rpc-core/src/main/java/com/dingding/octopus/rpc/client/MainChannelListener.java new file mode 100644 index 0000000..d003558 --- /dev/null +++ b/octopus-rpc-core/src/main/java/com/dingding/octopus/rpc/client/MainChannelListener.java @@ -0,0 +1,11 @@ +package com.dingding.octopus.rpc.client; + +/** + * + * Created by guna on 16/9/20. + */ +public interface MainChannelListener { + void onMainChannelInit(); + void onOneChannelDisconnect(); + void onOneChannelConnect(); +} \ No newline at end of file diff --git a/octopus-rpc-core/src/main/java/com/dingding/octopus/rpc/client/TrackedChannel.java b/octopus-rpc-core/src/main/java/com/dingding/octopus/rpc/client/TrackedChannel.java new file mode 100644 index 0000000..3f072cf --- /dev/null +++ b/octopus-rpc-core/src/main/java/com/dingding/octopus/rpc/client/TrackedChannel.java @@ -0,0 +1,60 @@ +package com.dingding.octopus.rpc.client; + +import com.dingding.octopus.rpc.common.CoreUtilProto; +import com.dingding.octopus.rpc.common.DetectUtils; +import io.grpc.*; +import io.grpc.stub.StreamObserver; +import io.netty.handler.ssl.SslProvider; +import lombok.extern.slf4j.Slf4j; + +/** + * HoHo + * Created by guna on 16/9/17. + */ +@Slf4j +public class TrackedChannel extends Channel{ + + private Channel innerChannel; + + public StreamObserver getObserver() { + return observer; + } + + public void setObserver(StreamObserver observer) { + this.observer = observer; + } + + private StreamObserver observer; + + public ChannelConfig getConfig() { + return config; + } + + private ChannelConfig config; + public TrackedChannel(ChannelConfig channelConfig){ + ManagedChannelBuilder builder = ManagedChannelBuilder.forAddress(channelConfig.getAddress(), channelConfig.getPort()); + SslProvider sslProvider = DetectUtils.selectApplicationProtocolConfig(); + if(channelConfig.isSsl()){ + if (sslProvider == null) { + log.warn("You configured SSL but sslProvider not found"); + builder.usePlaintext(true); + }else { + builder.usePlaintext(false); + } + }else{ + builder.usePlaintext(true); + } + innerChannel = builder.build(); + config = channelConfig; + } + @Override + public ClientCall newCall(MethodDescriptor methodDescriptor, CallOptions callOptions) { + return innerChannel.newCall(methodDescriptor, callOptions); + } + + @Override + public String authority() { + return innerChannel.authority(); + } + +} diff --git a/octopus-rpc-core/src/main/java/com/dingding/octopus/rpc/common/CoreUtilProto.java b/octopus-rpc-core/src/main/java/com/dingding/octopus/rpc/common/CoreUtilProto.java new file mode 100644 index 0000000..07f36a5 --- /dev/null +++ b/octopus-rpc-core/src/main/java/com/dingding/octopus/rpc/common/CoreUtilProto.java @@ -0,0 +1,2712 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: core_util.proto + +package com.dingding.octopus.rpc.common; + +public final class CoreUtilProto { + private CoreUtilProto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + public interface ServerInformationOrBuilder extends + // @@protoc_insertion_point(interface_extends:core.ServerInformation) + com.google.protobuf.MessageOrBuilder { + + /** + *
+     *Server UUId
+     * 
+ * + * optional string id = 1; + */ + String getId(); + /** + *
+     *Server UUId
+     * 
+ * + * optional string id = 1; + */ + com.google.protobuf.ByteString + getIdBytes(); + + /** + * optional int32 type = 2; + */ + int getType(); + + /** + *
+     *Server name
+     * 
+ * + * optional string name = 3; + */ + String getName(); + /** + *
+     *Server name
+     * 
+ * + * optional string name = 3; + */ + com.google.protobuf.ByteString + getNameBytes(); + + /** + *
+     *Server current time
+     * 
+ * + * optional int64 time = 4; + */ + long getTime(); + + /** + *
+     *Server message seq
+     * 
+ * + * optional int64 seq = 5; + */ + long getSeq(); + + /** + *
+     *Server load
+     * 
+ * + * optional int32 load = 6; + */ + int getLoad(); + + /** + *
+     *Addon message
+     * 
+ * + * optional string message = 7; + */ + String getMessage(); + /** + *
+     *Addon message
+     * 
+ * + * optional string message = 7; + */ + com.google.protobuf.ByteString + getMessageBytes(); + + /** + * map<string, string> services = 8; + */ + int getServicesCount(); + /** + * map<string, string> services = 8; + */ + boolean containsServices( + String key); + /** + * Use {@link #getServicesMap()} instead. + */ + @Deprecated + java.util.Map + getServices(); + /** + * map<string, string> services = 8; + */ + java.util.Map + getServicesMap(); + /** + * map<string, string> services = 8; + */ + + String getServicesOrDefault( + String key, + String defaultValue); + /** + * map<string, string> services = 8; + */ + + String getServicesOrThrow( + String key); + } + /** + * Protobuf type {@code core.ServerInformation} + */ + public static final class ServerInformation extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:core.ServerInformation) + ServerInformationOrBuilder { + // Use ServerInformation.newBuilder() to construct. + private ServerInformation(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ServerInformation() { + id_ = ""; + type_ = 0; + name_ = ""; + time_ = 0L; + seq_ = 0L; + load_ = 0; + message_ = ""; + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private ServerInformation( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + id_ = s; + break; + } + case 16: { + + type_ = input.readInt32(); + break; + } + case 26: { + String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + case 32: { + + time_ = input.readInt64(); + break; + } + case 40: { + + seq_ = input.readInt64(); + break; + } + case 48: { + + load_ = input.readInt32(); + break; + } + case 58: { + String s = input.readStringRequireUtf8(); + + message_ = s; + break; + } + case 66: { + if (!((mutable_bitField0_ & 0x00000080) == 0x00000080)) { + services_ = com.google.protobuf.MapField.newMapField( + ServicesDefaultEntryHolder.defaultEntry); + mutable_bitField0_ |= 0x00000080; + } + com.google.protobuf.MapEntry + services = input.readMessage( + ServicesDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); + services_.getMutableMap().put(services.getKey(), services.getValue()); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return CoreUtilProto.internal_static_core_ServerInformation_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMapField( + int number) { + switch (number) { + case 8: + return internalGetServices(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return CoreUtilProto.internal_static_core_ServerInformation_fieldAccessorTable + .ensureFieldAccessorsInitialized( + ServerInformation.class, Builder.class); + } + + private int bitField0_; + public static final int ID_FIELD_NUMBER = 1; + private volatile Object id_; + /** + *
+     *Server UUId
+     * 
+ * + * optional string id = 1; + */ + public String getId() { + Object ref = id_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + id_ = s; + return s; + } + } + /** + *
+     *Server UUId
+     * 
+ * + * optional string id = 1; + */ + public com.google.protobuf.ByteString + getIdBytes() { + Object ref = id_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + id_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TYPE_FIELD_NUMBER = 2; + private int type_; + /** + * optional int32 type = 2; + */ + public int getType() { + return type_; + } + + public static final int NAME_FIELD_NUMBER = 3; + private volatile Object name_; + /** + *
+     *Server name
+     * 
+ * + * optional string name = 3; + */ + public String getName() { + Object ref = name_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + *
+     *Server name
+     * 
+ * + * optional string name = 3; + */ + public com.google.protobuf.ByteString + getNameBytes() { + Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TIME_FIELD_NUMBER = 4; + private long time_; + /** + *
+     *Server current time
+     * 
+ * + * optional int64 time = 4; + */ + public long getTime() { + return time_; + } + + public static final int SEQ_FIELD_NUMBER = 5; + private long seq_; + /** + *
+     *Server message seq
+     * 
+ * + * optional int64 seq = 5; + */ + public long getSeq() { + return seq_; + } + + public static final int LOAD_FIELD_NUMBER = 6; + private int load_; + /** + *
+     *Server load
+     * 
+ * + * optional int32 load = 6; + */ + public int getLoad() { + return load_; + } + + public static final int MESSAGE_FIELD_NUMBER = 7; + private volatile Object message_; + /** + *
+     *Addon message
+     * 
+ * + * optional string message = 7; + */ + public String getMessage() { + Object ref = message_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + message_ = s; + return s; + } + } + /** + *
+     *Addon message
+     * 
+ * + * optional string message = 7; + */ + public com.google.protobuf.ByteString + getMessageBytes() { + Object ref = message_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + message_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SERVICES_FIELD_NUMBER = 8; + private static final class ServicesDefaultEntryHolder { + static final com.google.protobuf.MapEntry< + String, String> defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + CoreUtilProto.internal_static_core_ServerInformation_ServicesEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.STRING, + ""); + } + private com.google.protobuf.MapField< + String, String> services_; + private com.google.protobuf.MapField + internalGetServices() { + if (services_ == null) { + return com.google.protobuf.MapField.emptyMapField( + ServicesDefaultEntryHolder.defaultEntry); + } + return services_; + } + + public int getServicesCount() { + return internalGetServices().getMap().size(); + } + /** + * map<string, string> services = 8; + */ + + public boolean containsServices( + String key) { + if (key == null) { throw new NullPointerException(); } + return internalGetServices().getMap().containsKey(key); + } + /** + * Use {@link #getServicesMap()} instead. + */ + @Deprecated + public java.util.Map getServices() { + return getServicesMap(); + } + /** + * map<string, string> services = 8; + */ + + public java.util.Map getServicesMap() { + return internalGetServices().getMap(); + } + /** + * map<string, string> services = 8; + */ + + public String getServicesOrDefault( + String key, + String defaultValue) { + if (key == null) { throw new NullPointerException(); } + java.util.Map map = + internalGetServices().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, string> services = 8; + */ + + public String getServicesOrThrow( + String key) { + if (key == null) { throw new NullPointerException(); } + java.util.Map map = + internalGetServices().getMap(); + if (!map.containsKey(key)) { + throw new IllegalArgumentException(); + } + return map.get(key); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getIdBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, id_); + } + if (type_ != 0) { + output.writeInt32(2, type_); + } + if (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, name_); + } + if (time_ != 0L) { + output.writeInt64(4, time_); + } + if (seq_ != 0L) { + output.writeInt64(5, seq_); + } + if (load_ != 0) { + output.writeInt32(6, load_); + } + if (!getMessageBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 7, message_); + } + for (java.util.Map.Entry entry + : internalGetServices().getMap().entrySet()) { + com.google.protobuf.MapEntry + services = ServicesDefaultEntryHolder.defaultEntry.newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + output.writeMessage(8, services); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getIdBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, id_); + } + if (type_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(2, type_); + } + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, name_); + } + if (time_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(4, time_); + } + if (seq_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(5, seq_); + } + if (load_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(6, load_); + } + if (!getMessageBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(7, message_); + } + for (java.util.Map.Entry entry + : internalGetServices().getMap().entrySet()) { + com.google.protobuf.MapEntry + services = ServicesDefaultEntryHolder.defaultEntry.newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(8, services); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof ServerInformation)) { + return super.equals(obj); + } + ServerInformation other = (ServerInformation) obj; + + boolean result = true; + result = result && getId() + .equals(other.getId()); + result = result && (getType() + == other.getType()); + result = result && getName() + .equals(other.getName()); + result = result && (getTime() + == other.getTime()); + result = result && (getSeq() + == other.getSeq()); + result = result && (getLoad() + == other.getLoad()); + result = result && getMessage() + .equals(other.getMessage()); + result = result && internalGetServices().equals( + other.internalGetServices()); + return result; + } + + @Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptorForType().hashCode(); + hash = (37 * hash) + ID_FIELD_NUMBER; + hash = (53 * hash) + getId().hashCode(); + hash = (37 * hash) + TYPE_FIELD_NUMBER; + hash = (53 * hash) + getType(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (37 * hash) + TIME_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getTime()); + hash = (37 * hash) + SEQ_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getSeq()); + hash = (37 * hash) + LOAD_FIELD_NUMBER; + hash = (53 * hash) + getLoad(); + hash = (37 * hash) + MESSAGE_FIELD_NUMBER; + hash = (53 * hash) + getMessage().hashCode(); + if (!internalGetServices().getMap().isEmpty()) { + hash = (37 * hash) + SERVICES_FIELD_NUMBER; + hash = (53 * hash) + internalGetServices().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static ServerInformation parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static ServerInformation parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static ServerInformation parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static ServerInformation parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static ServerInformation parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static ServerInformation parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static ServerInformation parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static ServerInformation parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static ServerInformation parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static ServerInformation parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(ServerInformation prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code core.ServerInformation} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:core.ServerInformation) + ServerInformationOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return CoreUtilProto.internal_static_core_ServerInformation_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMapField( + int number) { + switch (number) { + case 8: + return internalGetServices(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMutableMapField( + int number) { + switch (number) { + case 8: + return internalGetMutableServices(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return CoreUtilProto.internal_static_core_ServerInformation_fieldAccessorTable + .ensureFieldAccessorsInitialized( + ServerInformation.class, Builder.class); + } + + // Construct using com.dingding.octopus.rpc.common.CoreUtilProto.ServerInformation.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + id_ = ""; + + type_ = 0; + + name_ = ""; + + time_ = 0L; + + seq_ = 0L; + + load_ = 0; + + message_ = ""; + + internalGetMutableServices().clear(); + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return CoreUtilProto.internal_static_core_ServerInformation_descriptor; + } + + public ServerInformation getDefaultInstanceForType() { + return ServerInformation.getDefaultInstance(); + } + + public ServerInformation build() { + ServerInformation result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public ServerInformation buildPartial() { + ServerInformation result = new ServerInformation(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.id_ = id_; + result.type_ = type_; + result.name_ = name_; + result.time_ = time_; + result.seq_ = seq_; + result.load_ = load_; + result.message_ = message_; + result.services_ = internalGetServices(); + result.services_.makeImmutable(); + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof ServerInformation) { + return mergeFrom((ServerInformation)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(ServerInformation other) { + if (other == ServerInformation.getDefaultInstance()) return this; + if (!other.getId().isEmpty()) { + id_ = other.id_; + onChanged(); + } + if (other.getType() != 0) { + setType(other.getType()); + } + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + if (other.getTime() != 0L) { + setTime(other.getTime()); + } + if (other.getSeq() != 0L) { + setSeq(other.getSeq()); + } + if (other.getLoad() != 0) { + setLoad(other.getLoad()); + } + if (!other.getMessage().isEmpty()) { + message_ = other.message_; + onChanged(); + } + internalGetMutableServices().mergeFrom( + other.internalGetServices()); + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + ServerInformation parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (ServerInformation) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private Object id_ = ""; + /** + *
+       *Server UUId
+       * 
+ * + * optional string id = 1; + */ + public String getId() { + Object ref = id_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + id_ = s; + return s; + } else { + return (String) ref; + } + } + /** + *
+       *Server UUId
+       * 
+ * + * optional string id = 1; + */ + public com.google.protobuf.ByteString + getIdBytes() { + Object ref = id_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + id_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       *Server UUId
+       * 
+ * + * optional string id = 1; + */ + public Builder setId( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + id_ = value; + onChanged(); + return this; + } + /** + *
+       *Server UUId
+       * 
+ * + * optional string id = 1; + */ + public Builder clearId() { + + id_ = getDefaultInstance().getId(); + onChanged(); + return this; + } + /** + *
+       *Server UUId
+       * 
+ * + * optional string id = 1; + */ + public Builder setIdBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + id_ = value; + onChanged(); + return this; + } + + private int type_ ; + /** + * optional int32 type = 2; + */ + public int getType() { + return type_; + } + /** + * optional int32 type = 2; + */ + public Builder setType(int value) { + + type_ = value; + onChanged(); + return this; + } + /** + * optional int32 type = 2; + */ + public Builder clearType() { + + type_ = 0; + onChanged(); + return this; + } + + private Object name_ = ""; + /** + *
+       *Server name
+       * 
+ * + * optional string name = 3; + */ + public String getName() { + Object ref = name_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (String) ref; + } + } + /** + *
+       *Server name
+       * 
+ * + * optional string name = 3; + */ + public com.google.protobuf.ByteString + getNameBytes() { + Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       *Server name
+       * 
+ * + * optional string name = 3; + */ + public Builder setName( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + *
+       *Server name
+       * 
+ * + * optional string name = 3; + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + *
+       *Server name
+       * 
+ * + * optional string name = 3; + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + + private long time_ ; + /** + *
+       *Server current time
+       * 
+ * + * optional int64 time = 4; + */ + public long getTime() { + return time_; + } + /** + *
+       *Server current time
+       * 
+ * + * optional int64 time = 4; + */ + public Builder setTime(long value) { + + time_ = value; + onChanged(); + return this; + } + /** + *
+       *Server current time
+       * 
+ * + * optional int64 time = 4; + */ + public Builder clearTime() { + + time_ = 0L; + onChanged(); + return this; + } + + private long seq_ ; + /** + *
+       *Server message seq
+       * 
+ * + * optional int64 seq = 5; + */ + public long getSeq() { + return seq_; + } + /** + *
+       *Server message seq
+       * 
+ * + * optional int64 seq = 5; + */ + public Builder setSeq(long value) { + + seq_ = value; + onChanged(); + return this; + } + /** + *
+       *Server message seq
+       * 
+ * + * optional int64 seq = 5; + */ + public Builder clearSeq() { + + seq_ = 0L; + onChanged(); + return this; + } + + private int load_ ; + /** + *
+       *Server load
+       * 
+ * + * optional int32 load = 6; + */ + public int getLoad() { + return load_; + } + /** + *
+       *Server load
+       * 
+ * + * optional int32 load = 6; + */ + public Builder setLoad(int value) { + + load_ = value; + onChanged(); + return this; + } + /** + *
+       *Server load
+       * 
+ * + * optional int32 load = 6; + */ + public Builder clearLoad() { + + load_ = 0; + onChanged(); + return this; + } + + private Object message_ = ""; + /** + *
+       *Addon message
+       * 
+ * + * optional string message = 7; + */ + public String getMessage() { + Object ref = message_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + message_ = s; + return s; + } else { + return (String) ref; + } + } + /** + *
+       *Addon message
+       * 
+ * + * optional string message = 7; + */ + public com.google.protobuf.ByteString + getMessageBytes() { + Object ref = message_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + message_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       *Addon message
+       * 
+ * + * optional string message = 7; + */ + public Builder setMessage( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + message_ = value; + onChanged(); + return this; + } + /** + *
+       *Addon message
+       * 
+ * + * optional string message = 7; + */ + public Builder clearMessage() { + + message_ = getDefaultInstance().getMessage(); + onChanged(); + return this; + } + /** + *
+       *Addon message
+       * 
+ * + * optional string message = 7; + */ + public Builder setMessageBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + message_ = value; + onChanged(); + return this; + } + + private com.google.protobuf.MapField< + String, String> services_; + private com.google.protobuf.MapField + internalGetServices() { + if (services_ == null) { + return com.google.protobuf.MapField.emptyMapField( + ServicesDefaultEntryHolder.defaultEntry); + } + return services_; + } + private com.google.protobuf.MapField + internalGetMutableServices() { + onChanged();; + if (services_ == null) { + services_ = com.google.protobuf.MapField.newMapField( + ServicesDefaultEntryHolder.defaultEntry); + } + if (!services_.isMutable()) { + services_ = services_.copy(); + } + return services_; + } + + public int getServicesCount() { + return internalGetServices().getMap().size(); + } + /** + * map<string, string> services = 8; + */ + + public boolean containsServices( + String key) { + if (key == null) { throw new NullPointerException(); } + return internalGetServices().getMap().containsKey(key); + } + /** + * Use {@link #getServicesMap()} instead. + */ + @Deprecated + public java.util.Map getServices() { + return getServicesMap(); + } + /** + * map<string, string> services = 8; + */ + + public java.util.Map getServicesMap() { + return internalGetServices().getMap(); + } + /** + * map<string, string> services = 8; + */ + + public String getServicesOrDefault( + String key, + String defaultValue) { + if (key == null) { throw new NullPointerException(); } + java.util.Map map = + internalGetServices().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, string> services = 8; + */ + + public String getServicesOrThrow( + String key) { + if (key == null) { throw new NullPointerException(); } + java.util.Map map = + internalGetServices().getMap(); + if (!map.containsKey(key)) { + throw new IllegalArgumentException(); + } + return map.get(key); + } + + public Builder clearServices() { + getMutableServices().clear(); + return this; + } + /** + * map<string, string> services = 8; + */ + + public Builder removeServices( + String key) { + if (key == null) { throw new NullPointerException(); } + getMutableServices().remove(key); + return this; + } + /** + * Use alternate mutation accessors instead. + */ + @Deprecated + public java.util.Map + getMutableServices() { + return internalGetMutableServices().getMutableMap(); + } + /** + * map<string, string> services = 8; + */ + public Builder putServices( + String key, + String value) { + if (key == null) { throw new NullPointerException(); } + if (value == null) { throw new NullPointerException(); } + getMutableServices().put(key, value); + return this; + } + /** + * map<string, string> services = 8; + */ + + public Builder putAllServices( + java.util.Map values) { + getMutableServices().putAll(values); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:core.ServerInformation) + } + + // @@protoc_insertion_point(class_scope:core.ServerInformation) + private static final ServerInformation DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new ServerInformation(); + } + + public static ServerInformation getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ServerInformation parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ServerInformation(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public ServerInformation getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface ClientInformationOrBuilder extends + // @@protoc_insertion_point(interface_extends:core.ClientInformation) + com.google.protobuf.MessageOrBuilder { + + /** + *
+     *Client UUId
+     * 
+ * + * optional string id = 1; + */ + String getId(); + /** + *
+     *Client UUId
+     * 
+ * + * optional string id = 1; + */ + com.google.protobuf.ByteString + getIdBytes(); + + /** + * optional int32 type = 2; + */ + int getType(); + + /** + *
+     *Client name
+     * 
+ * + * optional string name = 3; + */ + String getName(); + /** + *
+     *Client name
+     * 
+ * + * optional string name = 3; + */ + com.google.protobuf.ByteString + getNameBytes(); + + /** + *
+     *Client current time
+     * 
+ * + * optional int64 time = 4; + */ + long getTime(); + + /** + *
+     *Client message seq
+     * 
+ * + * optional int64 seq = 5; + */ + long getSeq(); + + /** + *
+     *Addon message
+     * 
+ * + * optional string message = 6; + */ + String getMessage(); + /** + *
+     *Addon message
+     * 
+ * + * optional string message = 6; + */ + com.google.protobuf.ByteString + getMessageBytes(); + } + /** + * Protobuf type {@code core.ClientInformation} + */ + public static final class ClientInformation extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:core.ClientInformation) + ClientInformationOrBuilder { + // Use ClientInformation.newBuilder() to construct. + private ClientInformation(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ClientInformation() { + id_ = ""; + type_ = 0; + name_ = ""; + time_ = 0L; + seq_ = 0L; + message_ = ""; + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private ClientInformation( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + id_ = s; + break; + } + case 16: { + + type_ = input.readInt32(); + break; + } + case 26: { + String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + case 32: { + + time_ = input.readInt64(); + break; + } + case 40: { + + seq_ = input.readInt64(); + break; + } + case 50: { + String s = input.readStringRequireUtf8(); + + message_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return CoreUtilProto.internal_static_core_ClientInformation_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return CoreUtilProto.internal_static_core_ClientInformation_fieldAccessorTable + .ensureFieldAccessorsInitialized( + ClientInformation.class, Builder.class); + } + + public static final int ID_FIELD_NUMBER = 1; + private volatile Object id_; + /** + *
+     *Client UUId
+     * 
+ * + * optional string id = 1; + */ + public String getId() { + Object ref = id_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + id_ = s; + return s; + } + } + /** + *
+     *Client UUId
+     * 
+ * + * optional string id = 1; + */ + public com.google.protobuf.ByteString + getIdBytes() { + Object ref = id_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + id_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TYPE_FIELD_NUMBER = 2; + private int type_; + /** + * optional int32 type = 2; + */ + public int getType() { + return type_; + } + + public static final int NAME_FIELD_NUMBER = 3; + private volatile Object name_; + /** + *
+     *Client name
+     * 
+ * + * optional string name = 3; + */ + public String getName() { + Object ref = name_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + *
+     *Client name
+     * 
+ * + * optional string name = 3; + */ + public com.google.protobuf.ByteString + getNameBytes() { + Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TIME_FIELD_NUMBER = 4; + private long time_; + /** + *
+     *Client current time
+     * 
+ * + * optional int64 time = 4; + */ + public long getTime() { + return time_; + } + + public static final int SEQ_FIELD_NUMBER = 5; + private long seq_; + /** + *
+     *Client message seq
+     * 
+ * + * optional int64 seq = 5; + */ + public long getSeq() { + return seq_; + } + + public static final int MESSAGE_FIELD_NUMBER = 6; + private volatile Object message_; + /** + *
+     *Addon message
+     * 
+ * + * optional string message = 6; + */ + public String getMessage() { + Object ref = message_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + message_ = s; + return s; + } + } + /** + *
+     *Addon message
+     * 
+ * + * optional string message = 6; + */ + public com.google.protobuf.ByteString + getMessageBytes() { + Object ref = message_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + message_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getIdBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, id_); + } + if (type_ != 0) { + output.writeInt32(2, type_); + } + if (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, name_); + } + if (time_ != 0L) { + output.writeInt64(4, time_); + } + if (seq_ != 0L) { + output.writeInt64(5, seq_); + } + if (!getMessageBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 6, message_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getIdBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, id_); + } + if (type_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(2, type_); + } + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, name_); + } + if (time_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(4, time_); + } + if (seq_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(5, seq_); + } + if (!getMessageBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, message_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof ClientInformation)) { + return super.equals(obj); + } + ClientInformation other = (ClientInformation) obj; + + boolean result = true; + result = result && getId() + .equals(other.getId()); + result = result && (getType() + == other.getType()); + result = result && getName() + .equals(other.getName()); + result = result && (getTime() + == other.getTime()); + result = result && (getSeq() + == other.getSeq()); + result = result && getMessage() + .equals(other.getMessage()); + return result; + } + + @Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptorForType().hashCode(); + hash = (37 * hash) + ID_FIELD_NUMBER; + hash = (53 * hash) + getId().hashCode(); + hash = (37 * hash) + TYPE_FIELD_NUMBER; + hash = (53 * hash) + getType(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (37 * hash) + TIME_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getTime()); + hash = (37 * hash) + SEQ_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getSeq()); + hash = (37 * hash) + MESSAGE_FIELD_NUMBER; + hash = (53 * hash) + getMessage().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static ClientInformation parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static ClientInformation parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static ClientInformation parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static ClientInformation parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static ClientInformation parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static ClientInformation parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static ClientInformation parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static ClientInformation parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static ClientInformation parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static ClientInformation parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(ClientInformation prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code core.ClientInformation} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:core.ClientInformation) + ClientInformationOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return CoreUtilProto.internal_static_core_ClientInformation_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return CoreUtilProto.internal_static_core_ClientInformation_fieldAccessorTable + .ensureFieldAccessorsInitialized( + ClientInformation.class, Builder.class); + } + + // Construct using com.dingding.octopus.rpc.common.CoreUtilProto.ClientInformation.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + id_ = ""; + + type_ = 0; + + name_ = ""; + + time_ = 0L; + + seq_ = 0L; + + message_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return CoreUtilProto.internal_static_core_ClientInformation_descriptor; + } + + public ClientInformation getDefaultInstanceForType() { + return ClientInformation.getDefaultInstance(); + } + + public ClientInformation build() { + ClientInformation result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public ClientInformation buildPartial() { + ClientInformation result = new ClientInformation(this); + result.id_ = id_; + result.type_ = type_; + result.name_ = name_; + result.time_ = time_; + result.seq_ = seq_; + result.message_ = message_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof ClientInformation) { + return mergeFrom((ClientInformation)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(ClientInformation other) { + if (other == ClientInformation.getDefaultInstance()) return this; + if (!other.getId().isEmpty()) { + id_ = other.id_; + onChanged(); + } + if (other.getType() != 0) { + setType(other.getType()); + } + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + if (other.getTime() != 0L) { + setTime(other.getTime()); + } + if (other.getSeq() != 0L) { + setSeq(other.getSeq()); + } + if (!other.getMessage().isEmpty()) { + message_ = other.message_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + ClientInformation parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (ClientInformation) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private Object id_ = ""; + /** + *
+       *Client UUId
+       * 
+ * + * optional string id = 1; + */ + public String getId() { + Object ref = id_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + id_ = s; + return s; + } else { + return (String) ref; + } + } + /** + *
+       *Client UUId
+       * 
+ * + * optional string id = 1; + */ + public com.google.protobuf.ByteString + getIdBytes() { + Object ref = id_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + id_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       *Client UUId
+       * 
+ * + * optional string id = 1; + */ + public Builder setId( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + id_ = value; + onChanged(); + return this; + } + /** + *
+       *Client UUId
+       * 
+ * + * optional string id = 1; + */ + public Builder clearId() { + + id_ = getDefaultInstance().getId(); + onChanged(); + return this; + } + /** + *
+       *Client UUId
+       * 
+ * + * optional string id = 1; + */ + public Builder setIdBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + id_ = value; + onChanged(); + return this; + } + + private int type_ ; + /** + * optional int32 type = 2; + */ + public int getType() { + return type_; + } + /** + * optional int32 type = 2; + */ + public Builder setType(int value) { + + type_ = value; + onChanged(); + return this; + } + /** + * optional int32 type = 2; + */ + public Builder clearType() { + + type_ = 0; + onChanged(); + return this; + } + + private Object name_ = ""; + /** + *
+       *Client name
+       * 
+ * + * optional string name = 3; + */ + public String getName() { + Object ref = name_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (String) ref; + } + } + /** + *
+       *Client name
+       * 
+ * + * optional string name = 3; + */ + public com.google.protobuf.ByteString + getNameBytes() { + Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       *Client name
+       * 
+ * + * optional string name = 3; + */ + public Builder setName( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + *
+       *Client name
+       * 
+ * + * optional string name = 3; + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + *
+       *Client name
+       * 
+ * + * optional string name = 3; + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + + private long time_ ; + /** + *
+       *Client current time
+       * 
+ * + * optional int64 time = 4; + */ + public long getTime() { + return time_; + } + /** + *
+       *Client current time
+       * 
+ * + * optional int64 time = 4; + */ + public Builder setTime(long value) { + + time_ = value; + onChanged(); + return this; + } + /** + *
+       *Client current time
+       * 
+ * + * optional int64 time = 4; + */ + public Builder clearTime() { + + time_ = 0L; + onChanged(); + return this; + } + + private long seq_ ; + /** + *
+       *Client message seq
+       * 
+ * + * optional int64 seq = 5; + */ + public long getSeq() { + return seq_; + } + /** + *
+       *Client message seq
+       * 
+ * + * optional int64 seq = 5; + */ + public Builder setSeq(long value) { + + seq_ = value; + onChanged(); + return this; + } + /** + *
+       *Client message seq
+       * 
+ * + * optional int64 seq = 5; + */ + public Builder clearSeq() { + + seq_ = 0L; + onChanged(); + return this; + } + + private Object message_ = ""; + /** + *
+       *Addon message
+       * 
+ * + * optional string message = 6; + */ + public String getMessage() { + Object ref = message_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + message_ = s; + return s; + } else { + return (String) ref; + } + } + /** + *
+       *Addon message
+       * 
+ * + * optional string message = 6; + */ + public com.google.protobuf.ByteString + getMessageBytes() { + Object ref = message_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + message_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       *Addon message
+       * 
+ * + * optional string message = 6; + */ + public Builder setMessage( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + message_ = value; + onChanged(); + return this; + } + /** + *
+       *Addon message
+       * 
+ * + * optional string message = 6; + */ + public Builder clearMessage() { + + message_ = getDefaultInstance().getMessage(); + onChanged(); + return this; + } + /** + *
+       *Addon message
+       * 
+ * + * optional string message = 6; + */ + public Builder setMessageBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + message_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:core.ClientInformation) + } + + // @@protoc_insertion_point(class_scope:core.ClientInformation) + private static final ClientInformation DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new ClientInformation(); + } + + public static ClientInformation getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ClientInformation parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ClientInformation(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public ClientInformation getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_core_ServerInformation_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_core_ServerInformation_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_core_ServerInformation_ServicesEntry_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_core_ServerInformation_ServicesEntry_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_core_ClientInformation_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_core_ClientInformation_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + String[] descriptorData = { + "\n\017core_util.proto\022\004core\"\337\001\n\021ServerInform" + + "ation\022\n\n\002id\030\001 \001(\t\022\014\n\004type\030\002 \001(\005\022\014\n\004name\030" + + "\003 \001(\t\022\014\n\004time\030\004 \001(\003\022\013\n\003seq\030\005 \001(\003\022\014\n\004load" + + "\030\006 \001(\005\022\017\n\007message\030\007 \001(\t\0227\n\010services\030\010 \003(" + + "\0132%.core.ServerInformation.ServicesEntry" + + "\032/\n\rServicesEntry\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030" + + "\002 \001(\t:\0028\001\"g\n\021ClientInformation\022\n\n\002id\030\001 \001" + + "(\t\022\014\n\004type\030\002 \001(\005\022\014\n\004name\030\003 \001(\t\022\014\n\004time\030\004" + + " \001(\003\022\013\n\003seq\030\005 \001(\003\022\017\n\007message\030\006 \001(\t2T\n\rRp" + + "cServerUtil\022C\n\tHeartBeat\022\027.core.ClientIn", + "formation\032\027.core.ServerInformation\"\000(\0010\001" + + "B7\n\037com.dingding.octopus.rpc.commonB\rCor" + + "eUtilProtoP\000\242\002\002CUb\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + internal_static_core_ServerInformation_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_core_ServerInformation_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_core_ServerInformation_descriptor, + new String[] { "Id", "Type", "Name", "Time", "Seq", "Load", "Message", "Services", }); + internal_static_core_ServerInformation_ServicesEntry_descriptor = + internal_static_core_ServerInformation_descriptor.getNestedTypes().get(0); + internal_static_core_ServerInformation_ServicesEntry_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_core_ServerInformation_ServicesEntry_descriptor, + new String[] { "Key", "Value", }); + internal_static_core_ClientInformation_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_core_ClientInformation_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_core_ClientInformation_descriptor, + new String[] { "Id", "Type", "Name", "Time", "Seq", "Message", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/octopus-rpc-core/src/main/java/com/dingding/octopus/rpc/common/DetectUtils.java b/octopus-rpc-core/src/main/java/com/dingding/octopus/rpc/common/DetectUtils.java new file mode 100644 index 0000000..01c3ec3 --- /dev/null +++ b/octopus-rpc-core/src/main/java/com/dingding/octopus/rpc/common/DetectUtils.java @@ -0,0 +1,72 @@ +package com.dingding.octopus.rpc.common; + +import io.netty.handler.ssl.ApplicationProtocolConfig; +import io.netty.handler.ssl.OpenSsl; +import io.netty.handler.ssl.SslProvider; + +/** + * Created by herui on 16/6/19. + */ +public class DetectUtils { + private static SslProvider defaultSslProvider() { + return OpenSsl.isAvailable() ? SslProvider.OPENSSL : SslProvider.JDK; + } + + public static SslProvider selectApplicationProtocolConfig(){ + return selectApplicationProtocolConfig(defaultSslProvider()); + } + + public static SslProvider selectApplicationProtocolConfig(SslProvider provider) { + switch (provider) { + case JDK: { + if (isJettyAlpnConfigured()) { + return provider; + } + if (isJettyNpnConfigured()) { + return provider; + } + return null; + //throw new IllegalArgumentException("Jetty ALPN/NPN has not been properly configured."); + } + case OPENSSL: { + if (!OpenSsl.isAvailable()) { + //log.warn("OpenSSL is not installed on the system."); + return null; + } + + if (OpenSsl.isAlpnSupported()) { + return provider; + } else { + return provider; + } + } + default: + throw new IllegalArgumentException("Unsupported provider: " + provider); + } + } + + /** + * Indicates whether or not the Jetty ALPN jar is installed in the boot classloader. + */ + static boolean isJettyAlpnConfigured() { + try { + Class.forName("org.eclipse.jetty.alpn.ALPN", true, null); + return true; + } catch (ClassNotFoundException e) { + return false; + } + } + + /** + * Indicates whether or not the Jetty NPN jar is installed in the boot classloader. + */ + static boolean isJettyNpnConfigured() { + try { + Class.forName("org.eclipse.jetty.npn.NextProtoNego", true, null); + return true; + } catch (ClassNotFoundException e) { + return false; + } + } +} + diff --git a/octopus-rpc-core/src/main/java/com/dingding/octopus/rpc/common/HeartBeatMessageType.java b/octopus-rpc-core/src/main/java/com/dingding/octopus/rpc/common/HeartBeatMessageType.java new file mode 100644 index 0000000..7bf86c9 --- /dev/null +++ b/octopus-rpc-core/src/main/java/com/dingding/octopus/rpc/common/HeartBeatMessageType.java @@ -0,0 +1,18 @@ +package com.dingding.octopus.rpc.common; + +/** + * HB + * Created by herui on 16/6/18. + */ +public class HeartBeatMessageType { + public static final int CONNECT = 0; + public static final int CONNECT_ACCEPT = 1; + public static final int HEART_BEAT = 2; + public static final int SERVICE_UPDATE_REQ = 5; + public static final int SERVICE_UPDATE_RESPONSE = 6; + + public static final int CLIENT_CLOSE = 11; + public static final int SERVER_CLOSE = 12; + + +} diff --git a/octopus-rpc-core/src/main/java/com/dingding/octopus/rpc/common/RpcServerUtilGrpc.java b/octopus-rpc-core/src/main/java/com/dingding/octopus/rpc/common/RpcServerUtilGrpc.java new file mode 100644 index 0000000..b25a901 --- /dev/null +++ b/octopus-rpc-core/src/main/java/com/dingding/octopus/rpc/common/RpcServerUtilGrpc.java @@ -0,0 +1,195 @@ +package com.dingding.octopus.rpc.common; + +import static io.grpc.stub.ClientCalls.asyncUnaryCall; +import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; +import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; +import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ClientCalls.blockingUnaryCall; +import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; +import static io.grpc.stub.ClientCalls.futureUnaryCall; +import static io.grpc.MethodDescriptor.generateFullMethodName; +import static io.grpc.stub.ServerCalls.asyncUnaryCall; +import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; +import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; +import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; + +/** + */ +@javax.annotation.Generated( + value = "by gRPC proto compiler (version 1.0.0)", + comments = "Source: core_util.proto") +public class RpcServerUtilGrpc { + + private RpcServerUtilGrpc() {} + + public static final String SERVICE_NAME = "core.RpcServerUtil"; + + // Static method descriptors that strictly reflect the proto. + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static final io.grpc.MethodDescriptor METHOD_HEART_BEAT = + io.grpc.MethodDescriptor.create( + io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING, + generateFullMethodName( + "core.RpcServerUtil", "HeartBeat"), + io.grpc.protobuf.ProtoUtils.marshaller(CoreUtilProto.ClientInformation.getDefaultInstance()), + io.grpc.protobuf.ProtoUtils.marshaller(CoreUtilProto.ServerInformation.getDefaultInstance())); + + /** + * Creates a new async stub that supports all call types for the service + */ + public static RpcServerUtilStub newStub(io.grpc.Channel channel) { + return new RpcServerUtilStub(channel); + } + + /** + * Creates a new blocking-style stub that supports unary and streaming output calls on the service + */ + public static RpcServerUtilBlockingStub newBlockingStub( + io.grpc.Channel channel) { + return new RpcServerUtilBlockingStub(channel); + } + + /** + * Creates a new ListenableFuture-style stub that supports unary and streaming output calls on the service + */ + public static RpcServerUtilFutureStub newFutureStub( + io.grpc.Channel channel) { + return new RpcServerUtilFutureStub(channel); + } + + /** + */ + public static abstract class RpcServerUtilImplBase implements io.grpc.BindableService { + + /** + */ + public io.grpc.stub.StreamObserver heartBeat( + io.grpc.stub.StreamObserver responseObserver) { + return asyncUnimplementedStreamingCall(METHOD_HEART_BEAT, responseObserver); + } + + @Override public io.grpc.ServerServiceDefinition bindService() { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + METHOD_HEART_BEAT, + asyncBidiStreamingCall( + new MethodHandlers< + CoreUtilProto.ClientInformation, + CoreUtilProto.ServerInformation>( + this, METHODID_HEART_BEAT))) + .build(); + } + } + + /** + */ + public static final class RpcServerUtilStub extends io.grpc.stub.AbstractStub { + private RpcServerUtilStub(io.grpc.Channel channel) { + super(channel); + } + + private RpcServerUtilStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @Override + protected RpcServerUtilStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new RpcServerUtilStub(channel, callOptions); + } + + /** + */ + public io.grpc.stub.StreamObserver heartBeat( + io.grpc.stub.StreamObserver responseObserver) { + return asyncBidiStreamingCall( + getChannel().newCall(METHOD_HEART_BEAT, getCallOptions()), responseObserver); + } + } + + /** + */ + public static final class RpcServerUtilBlockingStub extends io.grpc.stub.AbstractStub { + private RpcServerUtilBlockingStub(io.grpc.Channel channel) { + super(channel); + } + + private RpcServerUtilBlockingStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @Override + protected RpcServerUtilBlockingStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new RpcServerUtilBlockingStub(channel, callOptions); + } + } + + /** + */ + public static final class RpcServerUtilFutureStub extends io.grpc.stub.AbstractStub { + private RpcServerUtilFutureStub(io.grpc.Channel channel) { + super(channel); + } + + private RpcServerUtilFutureStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @Override + protected RpcServerUtilFutureStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new RpcServerUtilFutureStub(channel, callOptions); + } + } + + private static final int METHODID_HEART_BEAT = 0; + + private static 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 RpcServerUtilImplBase serviceImpl; + private final int methodId; + + public MethodHandlers(RpcServerUtilImplBase serviceImpl, int methodId) { + this.serviceImpl = serviceImpl; + this.methodId = methodId; + } + + @Override + @SuppressWarnings("unchecked") + public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + default: + throw new AssertionError(); + } + } + + @Override + @SuppressWarnings("unchecked") + public io.grpc.stub.StreamObserver invoke( + io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + case METHODID_HEART_BEAT: + return (io.grpc.stub.StreamObserver) serviceImpl.heartBeat( + (io.grpc.stub.StreamObserver) responseObserver); + default: + throw new AssertionError(); + } + } + } + + public static io.grpc.ServiceDescriptor getServiceDescriptor() { + return new io.grpc.ServiceDescriptor(SERVICE_NAME, + METHOD_HEART_BEAT); + } + +} diff --git a/octopus-rpc-core/src/main/java/com/dingding/octopus/rpc/common/RpcTestUtilGrpc.java b/octopus-rpc-core/src/main/java/com/dingding/octopus/rpc/common/RpcTestUtilGrpc.java new file mode 100644 index 0000000..a7fe647 --- /dev/null +++ b/octopus-rpc-core/src/main/java/com/dingding/octopus/rpc/common/RpcTestUtilGrpc.java @@ -0,0 +1,263 @@ +package com.dingding.octopus.rpc.common; + +import static io.grpc.stub.ClientCalls.asyncUnaryCall; +import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; +import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; +import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ClientCalls.blockingUnaryCall; +import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; +import static io.grpc.stub.ClientCalls.futureUnaryCall; +import static io.grpc.MethodDescriptor.generateFullMethodName; +import static io.grpc.stub.ServerCalls.asyncUnaryCall; +import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; +import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; +import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; + +/** + */ +@javax.annotation.Generated( + value = "by gRPC proto compiler (version 1.0.0)", + comments = "Source: test_util.proto") +public class RpcTestUtilGrpc { + + private RpcTestUtilGrpc() {} + + public static final String SERVICE_NAME = "core.RpcTestUtil"; + + // Static method descriptors that strictly reflect the proto. + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static final io.grpc.MethodDescriptor METHOD_NETWORK_TEST = + io.grpc.MethodDescriptor.create( + io.grpc.MethodDescriptor.MethodType.UNARY, + generateFullMethodName( + "core.RpcTestUtil", "NetworkTest"), + io.grpc.protobuf.ProtoUtils.marshaller(TestUtilProto.ClientTestRequest.getDefaultInstance()), + io.grpc.protobuf.ProtoUtils.marshaller(TestUtilProto.ServerTestResponse.getDefaultInstance())); + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901") + public static final io.grpc.MethodDescriptor METHOD_NETWORK_TEST_ASYNC = + io.grpc.MethodDescriptor.create( + io.grpc.MethodDescriptor.MethodType.UNARY, + generateFullMethodName( + "core.RpcTestUtil", "NetworkTestAsync"), + io.grpc.protobuf.ProtoUtils.marshaller(TestUtilProto.ClientTestRequest.getDefaultInstance()), + io.grpc.protobuf.ProtoUtils.marshaller(TestUtilProto.ServerTestResponse.getDefaultInstance())); + + /** + * Creates a new async stub that supports all call types for the service + */ + public static RpcTestUtilStub newStub(io.grpc.Channel channel) { + return new RpcTestUtilStub(channel); + } + + /** + * Creates a new blocking-style stub that supports unary and streaming output calls on the service + */ + public static RpcTestUtilBlockingStub newBlockingStub( + io.grpc.Channel channel) { + return new RpcTestUtilBlockingStub(channel); + } + + /** + * Creates a new ListenableFuture-style stub that supports unary and streaming output calls on the service + */ + public static RpcTestUtilFutureStub newFutureStub( + io.grpc.Channel channel) { + return new RpcTestUtilFutureStub(channel); + } + + /** + */ + public static abstract class RpcTestUtilImplBase implements io.grpc.BindableService { + + /** + */ + public void networkTest(TestUtilProto.ClientTestRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(METHOD_NETWORK_TEST, responseObserver); + } + + /** + */ + public void networkTestAsync(TestUtilProto.ClientTestRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(METHOD_NETWORK_TEST_ASYNC, responseObserver); + } + + @Override public io.grpc.ServerServiceDefinition bindService() { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + METHOD_NETWORK_TEST, + asyncUnaryCall( + new MethodHandlers< + TestUtilProto.ClientTestRequest, + TestUtilProto.ServerTestResponse>( + this, METHODID_NETWORK_TEST))) + .addMethod( + METHOD_NETWORK_TEST_ASYNC, + asyncUnaryCall( + new MethodHandlers< + TestUtilProto.ClientTestRequest, + TestUtilProto.ServerTestResponse>( + this, METHODID_NETWORK_TEST_ASYNC))) + .build(); + } + } + + /** + */ + public static final class RpcTestUtilStub extends io.grpc.stub.AbstractStub { + private RpcTestUtilStub(io.grpc.Channel channel) { + super(channel); + } + + private RpcTestUtilStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @Override + protected RpcTestUtilStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new RpcTestUtilStub(channel, callOptions); + } + + /** + */ + public void networkTest(TestUtilProto.ClientTestRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(METHOD_NETWORK_TEST, getCallOptions()), request, responseObserver); + } + + /** + */ + public void networkTestAsync(TestUtilProto.ClientTestRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(METHOD_NETWORK_TEST_ASYNC, getCallOptions()), request, responseObserver); + } + } + + /** + */ + public static final class RpcTestUtilBlockingStub extends io.grpc.stub.AbstractStub { + private RpcTestUtilBlockingStub(io.grpc.Channel channel) { + super(channel); + } + + private RpcTestUtilBlockingStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @Override + protected RpcTestUtilBlockingStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new RpcTestUtilBlockingStub(channel, callOptions); + } + + /** + */ + public TestUtilProto.ServerTestResponse networkTest(TestUtilProto.ClientTestRequest request) { + return blockingUnaryCall( + getChannel(), METHOD_NETWORK_TEST, getCallOptions(), request); + } + + /** + */ + public TestUtilProto.ServerTestResponse networkTestAsync(TestUtilProto.ClientTestRequest request) { + return blockingUnaryCall( + getChannel(), METHOD_NETWORK_TEST_ASYNC, getCallOptions(), request); + } + } + + /** + */ + public static final class RpcTestUtilFutureStub extends io.grpc.stub.AbstractStub { + private RpcTestUtilFutureStub(io.grpc.Channel channel) { + super(channel); + } + + private RpcTestUtilFutureStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @Override + protected RpcTestUtilFutureStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new RpcTestUtilFutureStub(channel, callOptions); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture networkTest( + TestUtilProto.ClientTestRequest request) { + return futureUnaryCall( + getChannel().newCall(METHOD_NETWORK_TEST, getCallOptions()), request); + } + + /** + */ + public com.google.common.util.concurrent.ListenableFuture networkTestAsync( + TestUtilProto.ClientTestRequest request) { + return futureUnaryCall( + getChannel().newCall(METHOD_NETWORK_TEST_ASYNC, getCallOptions()), request); + } + } + + private static final int METHODID_NETWORK_TEST = 0; + private static final int METHODID_NETWORK_TEST_ASYNC = 1; + + private static 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 RpcTestUtilImplBase serviceImpl; + private final int methodId; + + public MethodHandlers(RpcTestUtilImplBase serviceImpl, int methodId) { + this.serviceImpl = serviceImpl; + this.methodId = methodId; + } + + @Override + @SuppressWarnings("unchecked") + public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + case METHODID_NETWORK_TEST: + serviceImpl.networkTest((TestUtilProto.ClientTestRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_NETWORK_TEST_ASYNC: + serviceImpl.networkTestAsync((TestUtilProto.ClientTestRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + default: + throw new AssertionError(); + } + } + + @Override + @SuppressWarnings("unchecked") + public io.grpc.stub.StreamObserver invoke( + io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + default: + throw new AssertionError(); + } + } + } + + public static io.grpc.ServiceDescriptor getServiceDescriptor() { + return new io.grpc.ServiceDescriptor(SERVICE_NAME, + METHOD_NETWORK_TEST, + METHOD_NETWORK_TEST_ASYNC); + } + +} diff --git a/octopus-rpc-core/src/main/java/com/dingding/octopus/rpc/common/TestUtilProto.java b/octopus-rpc-core/src/main/java/com/dingding/octopus/rpc/common/TestUtilProto.java new file mode 100644 index 0000000..a066f63 --- /dev/null +++ b/octopus-rpc-core/src/main/java/com/dingding/octopus/rpc/common/TestUtilProto.java @@ -0,0 +1,2096 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: test_util.proto + +package com.dingding.octopus.rpc.common; + +public final class TestUtilProto { + private TestUtilProto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + public interface ServerTestResponseOrBuilder extends + // @@protoc_insertion_point(interface_extends:core.ServerTestResponse) + com.google.protobuf.MessageOrBuilder { + + /** + *
+     *Server UUId
+     * 
+ * + * optional string id = 1; + */ + String getId(); + /** + *
+     *Server UUId
+     * 
+ * + * optional string id = 1; + */ + com.google.protobuf.ByteString + getIdBytes(); + + /** + *
+     *Server name
+     * 
+ * + * optional string name = 3; + */ + String getName(); + /** + *
+     *Server name
+     * 
+ * + * optional string name = 3; + */ + com.google.protobuf.ByteString + getNameBytes(); + + /** + *
+     *Server current time
+     * 
+ * + * optional int64 time = 4; + */ + long getTime(); + + /** + *
+     *Server load
+     * 
+ * + * optional int32 load = 6; + */ + int getLoad(); + + /** + *
+     *Addon message
+     * 
+ * + * optional string message = 7; + */ + String getMessage(); + /** + *
+     *Addon message
+     * 
+ * + * optional string message = 7; + */ + com.google.protobuf.ByteString + getMessageBytes(); + } + /** + * Protobuf type {@code core.ServerTestResponse} + */ + public static final class ServerTestResponse extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:core.ServerTestResponse) + ServerTestResponseOrBuilder { + // Use ServerTestResponse.newBuilder() to construct. + private ServerTestResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ServerTestResponse() { + id_ = ""; + name_ = ""; + time_ = 0L; + load_ = 0; + message_ = ""; + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private ServerTestResponse( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + id_ = s; + break; + } + case 26: { + String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + case 32: { + + time_ = input.readInt64(); + break; + } + case 48: { + + load_ = input.readInt32(); + break; + } + case 58: { + String s = input.readStringRequireUtf8(); + + message_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return TestUtilProto.internal_static_core_ServerTestResponse_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return TestUtilProto.internal_static_core_ServerTestResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + ServerTestResponse.class, Builder.class); + } + + public static final int ID_FIELD_NUMBER = 1; + private volatile Object id_; + /** + *
+     *Server UUId
+     * 
+ * + * optional string id = 1; + */ + public String getId() { + Object ref = id_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + id_ = s; + return s; + } + } + /** + *
+     *Server UUId
+     * 
+ * + * optional string id = 1; + */ + public com.google.protobuf.ByteString + getIdBytes() { + Object ref = id_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + id_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int NAME_FIELD_NUMBER = 3; + private volatile Object name_; + /** + *
+     *Server name
+     * 
+ * + * optional string name = 3; + */ + public String getName() { + Object ref = name_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + *
+     *Server name
+     * 
+ * + * optional string name = 3; + */ + public com.google.protobuf.ByteString + getNameBytes() { + Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TIME_FIELD_NUMBER = 4; + private long time_; + /** + *
+     *Server current time
+     * 
+ * + * optional int64 time = 4; + */ + public long getTime() { + return time_; + } + + public static final int LOAD_FIELD_NUMBER = 6; + private int load_; + /** + *
+     *Server load
+     * 
+ * + * optional int32 load = 6; + */ + public int getLoad() { + return load_; + } + + public static final int MESSAGE_FIELD_NUMBER = 7; + private volatile Object message_; + /** + *
+     *Addon message
+     * 
+ * + * optional string message = 7; + */ + public String getMessage() { + Object ref = message_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + message_ = s; + return s; + } + } + /** + *
+     *Addon message
+     * 
+ * + * optional string message = 7; + */ + public com.google.protobuf.ByteString + getMessageBytes() { + Object ref = message_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + message_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getIdBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, id_); + } + if (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, name_); + } + if (time_ != 0L) { + output.writeInt64(4, time_); + } + if (load_ != 0) { + output.writeInt32(6, load_); + } + if (!getMessageBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 7, message_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getIdBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, id_); + } + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, name_); + } + if (time_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(4, time_); + } + if (load_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(6, load_); + } + if (!getMessageBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(7, message_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof ServerTestResponse)) { + return super.equals(obj); + } + ServerTestResponse other = (ServerTestResponse) obj; + + boolean result = true; + result = result && getId() + .equals(other.getId()); + result = result && getName() + .equals(other.getName()); + result = result && (getTime() + == other.getTime()); + result = result && (getLoad() + == other.getLoad()); + result = result && getMessage() + .equals(other.getMessage()); + return result; + } + + @Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptorForType().hashCode(); + hash = (37 * hash) + ID_FIELD_NUMBER; + hash = (53 * hash) + getId().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (37 * hash) + TIME_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getTime()); + hash = (37 * hash) + LOAD_FIELD_NUMBER; + hash = (53 * hash) + getLoad(); + hash = (37 * hash) + MESSAGE_FIELD_NUMBER; + hash = (53 * hash) + getMessage().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static ServerTestResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static ServerTestResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static ServerTestResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static ServerTestResponse parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static ServerTestResponse parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static ServerTestResponse parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static ServerTestResponse parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static ServerTestResponse parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static ServerTestResponse parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static ServerTestResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(ServerTestResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code core.ServerTestResponse} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:core.ServerTestResponse) + ServerTestResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return TestUtilProto.internal_static_core_ServerTestResponse_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return TestUtilProto.internal_static_core_ServerTestResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + ServerTestResponse.class, Builder.class); + } + + // Construct using com.dingding.octopus.rpc.common.TestUtilProto.ServerTestResponse.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + id_ = ""; + + name_ = ""; + + time_ = 0L; + + load_ = 0; + + message_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return TestUtilProto.internal_static_core_ServerTestResponse_descriptor; + } + + public ServerTestResponse getDefaultInstanceForType() { + return ServerTestResponse.getDefaultInstance(); + } + + public ServerTestResponse build() { + ServerTestResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public ServerTestResponse buildPartial() { + ServerTestResponse result = new ServerTestResponse(this); + result.id_ = id_; + result.name_ = name_; + result.time_ = time_; + result.load_ = load_; + result.message_ = message_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof ServerTestResponse) { + return mergeFrom((ServerTestResponse)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(ServerTestResponse other) { + if (other == ServerTestResponse.getDefaultInstance()) return this; + if (!other.getId().isEmpty()) { + id_ = other.id_; + onChanged(); + } + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + if (other.getTime() != 0L) { + setTime(other.getTime()); + } + if (other.getLoad() != 0) { + setLoad(other.getLoad()); + } + if (!other.getMessage().isEmpty()) { + message_ = other.message_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + ServerTestResponse parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (ServerTestResponse) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private Object id_ = ""; + /** + *
+       *Server UUId
+       * 
+ * + * optional string id = 1; + */ + public String getId() { + Object ref = id_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + id_ = s; + return s; + } else { + return (String) ref; + } + } + /** + *
+       *Server UUId
+       * 
+ * + * optional string id = 1; + */ + public com.google.protobuf.ByteString + getIdBytes() { + Object ref = id_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + id_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       *Server UUId
+       * 
+ * + * optional string id = 1; + */ + public Builder setId( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + id_ = value; + onChanged(); + return this; + } + /** + *
+       *Server UUId
+       * 
+ * + * optional string id = 1; + */ + public Builder clearId() { + + id_ = getDefaultInstance().getId(); + onChanged(); + return this; + } + /** + *
+       *Server UUId
+       * 
+ * + * optional string id = 1; + */ + public Builder setIdBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + id_ = value; + onChanged(); + return this; + } + + private Object name_ = ""; + /** + *
+       *Server name
+       * 
+ * + * optional string name = 3; + */ + public String getName() { + Object ref = name_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (String) ref; + } + } + /** + *
+       *Server name
+       * 
+ * + * optional string name = 3; + */ + public com.google.protobuf.ByteString + getNameBytes() { + Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       *Server name
+       * 
+ * + * optional string name = 3; + */ + public Builder setName( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + *
+       *Server name
+       * 
+ * + * optional string name = 3; + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + *
+       *Server name
+       * 
+ * + * optional string name = 3; + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + + private long time_ ; + /** + *
+       *Server current time
+       * 
+ * + * optional int64 time = 4; + */ + public long getTime() { + return time_; + } + /** + *
+       *Server current time
+       * 
+ * + * optional int64 time = 4; + */ + public Builder setTime(long value) { + + time_ = value; + onChanged(); + return this; + } + /** + *
+       *Server current time
+       * 
+ * + * optional int64 time = 4; + */ + public Builder clearTime() { + + time_ = 0L; + onChanged(); + return this; + } + + private int load_ ; + /** + *
+       *Server load
+       * 
+ * + * optional int32 load = 6; + */ + public int getLoad() { + return load_; + } + /** + *
+       *Server load
+       * 
+ * + * optional int32 load = 6; + */ + public Builder setLoad(int value) { + + load_ = value; + onChanged(); + return this; + } + /** + *
+       *Server load
+       * 
+ * + * optional int32 load = 6; + */ + public Builder clearLoad() { + + load_ = 0; + onChanged(); + return this; + } + + private Object message_ = ""; + /** + *
+       *Addon message
+       * 
+ * + * optional string message = 7; + */ + public String getMessage() { + Object ref = message_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + message_ = s; + return s; + } else { + return (String) ref; + } + } + /** + *
+       *Addon message
+       * 
+ * + * optional string message = 7; + */ + public com.google.protobuf.ByteString + getMessageBytes() { + Object ref = message_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + message_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       *Addon message
+       * 
+ * + * optional string message = 7; + */ + public Builder setMessage( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + message_ = value; + onChanged(); + return this; + } + /** + *
+       *Addon message
+       * 
+ * + * optional string message = 7; + */ + public Builder clearMessage() { + + message_ = getDefaultInstance().getMessage(); + onChanged(); + return this; + } + /** + *
+       *Addon message
+       * 
+ * + * optional string message = 7; + */ + public Builder setMessageBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + message_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:core.ServerTestResponse) + } + + // @@protoc_insertion_point(class_scope:core.ServerTestResponse) + private static final ServerTestResponse DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new ServerTestResponse(); + } + + public static ServerTestResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ServerTestResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ServerTestResponse(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public ServerTestResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface ClientTestRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:core.ClientTestRequest) + com.google.protobuf.MessageOrBuilder { + + /** + *
+     *Client UUId
+     * 
+ * + * optional string id = 1; + */ + String getId(); + /** + *
+     *Client UUId
+     * 
+ * + * optional string id = 1; + */ + com.google.protobuf.ByteString + getIdBytes(); + + /** + *
+     *Client name
+     * 
+ * + * optional string name = 3; + */ + String getName(); + /** + *
+     *Client name
+     * 
+ * + * optional string name = 3; + */ + com.google.protobuf.ByteString + getNameBytes(); + + /** + *
+     *Client current time
+     * 
+ * + * optional int64 time = 4; + */ + long getTime(); + + /** + *
+     *Addon message
+     * 
+ * + * optional string message = 6; + */ + String getMessage(); + /** + *
+     *Addon message
+     * 
+ * + * optional string message = 6; + */ + com.google.protobuf.ByteString + getMessageBytes(); + } + /** + * Protobuf type {@code core.ClientTestRequest} + */ + public static final class ClientTestRequest extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:core.ClientTestRequest) + ClientTestRequestOrBuilder { + // Use ClientTestRequest.newBuilder() to construct. + private ClientTestRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private ClientTestRequest() { + id_ = ""; + name_ = ""; + time_ = 0L; + message_ = ""; + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private ClientTestRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + id_ = s; + break; + } + case 26: { + String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + case 32: { + + time_ = input.readInt64(); + break; + } + case 50: { + String s = input.readStringRequireUtf8(); + + message_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return TestUtilProto.internal_static_core_ClientTestRequest_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return TestUtilProto.internal_static_core_ClientTestRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + ClientTestRequest.class, Builder.class); + } + + public static final int ID_FIELD_NUMBER = 1; + private volatile Object id_; + /** + *
+     *Client UUId
+     * 
+ * + * optional string id = 1; + */ + public String getId() { + Object ref = id_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + id_ = s; + return s; + } + } + /** + *
+     *Client UUId
+     * 
+ * + * optional string id = 1; + */ + public com.google.protobuf.ByteString + getIdBytes() { + Object ref = id_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + id_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int NAME_FIELD_NUMBER = 3; + private volatile Object name_; + /** + *
+     *Client name
+     * 
+ * + * optional string name = 3; + */ + public String getName() { + Object ref = name_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + *
+     *Client name
+     * 
+ * + * optional string name = 3; + */ + public com.google.protobuf.ByteString + getNameBytes() { + Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TIME_FIELD_NUMBER = 4; + private long time_; + /** + *
+     *Client current time
+     * 
+ * + * optional int64 time = 4; + */ + public long getTime() { + return time_; + } + + public static final int MESSAGE_FIELD_NUMBER = 6; + private volatile Object message_; + /** + *
+     *Addon message
+     * 
+ * + * optional string message = 6; + */ + public String getMessage() { + Object ref = message_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + message_ = s; + return s; + } + } + /** + *
+     *Addon message
+     * 
+ * + * optional string message = 6; + */ + public com.google.protobuf.ByteString + getMessageBytes() { + Object ref = message_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + message_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getIdBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, id_); + } + if (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, name_); + } + if (time_ != 0L) { + output.writeInt64(4, time_); + } + if (!getMessageBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 6, message_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getIdBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, id_); + } + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, name_); + } + if (time_ != 0L) { + size += com.google.protobuf.CodedOutputStream + .computeInt64Size(4, time_); + } + if (!getMessageBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, message_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + @Override + public boolean equals(final Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof ClientTestRequest)) { + return super.equals(obj); + } + ClientTestRequest other = (ClientTestRequest) obj; + + boolean result = true; + result = result && getId() + .equals(other.getId()); + result = result && getName() + .equals(other.getName()); + result = result && (getTime() + == other.getTime()); + result = result && getMessage() + .equals(other.getMessage()); + return result; + } + + @Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptorForType().hashCode(); + hash = (37 * hash) + ID_FIELD_NUMBER; + hash = (53 * hash) + getId().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (37 * hash) + TIME_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong( + getTime()); + hash = (37 * hash) + MESSAGE_FIELD_NUMBER; + hash = (53 * hash) + getMessage().hashCode(); + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static ClientTestRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static ClientTestRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static ClientTestRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static ClientTestRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static ClientTestRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static ClientTestRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static ClientTestRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static ClientTestRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static ClientTestRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static ClientTestRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(ClientTestRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code core.ClientTestRequest} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:core.ClientTestRequest) + ClientTestRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return TestUtilProto.internal_static_core_ClientTestRequest_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return TestUtilProto.internal_static_core_ClientTestRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + ClientTestRequest.class, Builder.class); + } + + // Construct using com.dingding.octopus.rpc.common.TestUtilProto.ClientTestRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + id_ = ""; + + name_ = ""; + + time_ = 0L; + + message_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return TestUtilProto.internal_static_core_ClientTestRequest_descriptor; + } + + public ClientTestRequest getDefaultInstanceForType() { + return ClientTestRequest.getDefaultInstance(); + } + + public ClientTestRequest build() { + ClientTestRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public ClientTestRequest buildPartial() { + ClientTestRequest result = new ClientTestRequest(this); + result.id_ = id_; + result.name_ = name_; + result.time_ = time_; + result.message_ = message_; + onBuilt(); + return result; + } + + public Builder clone() { + return (Builder) super.clone(); + } + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.setField(field, value); + } + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return (Builder) super.clearField(field); + } + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return (Builder) super.clearOneof(oneof); + } + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, Object value) { + return (Builder) super.setRepeatedField(field, index, value); + } + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + Object value) { + return (Builder) super.addRepeatedField(field, value); + } + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof ClientTestRequest) { + return mergeFrom((ClientTestRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(ClientTestRequest other) { + if (other == ClientTestRequest.getDefaultInstance()) return this; + if (!other.getId().isEmpty()) { + id_ = other.id_; + onChanged(); + } + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + if (other.getTime() != 0L) { + setTime(other.getTime()); + } + if (!other.getMessage().isEmpty()) { + message_ = other.message_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + ClientTestRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (ClientTestRequest) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private Object id_ = ""; + /** + *
+       *Client UUId
+       * 
+ * + * optional string id = 1; + */ + public String getId() { + Object ref = id_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + id_ = s; + return s; + } else { + return (String) ref; + } + } + /** + *
+       *Client UUId
+       * 
+ * + * optional string id = 1; + */ + public com.google.protobuf.ByteString + getIdBytes() { + Object ref = id_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + id_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       *Client UUId
+       * 
+ * + * optional string id = 1; + */ + public Builder setId( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + id_ = value; + onChanged(); + return this; + } + /** + *
+       *Client UUId
+       * 
+ * + * optional string id = 1; + */ + public Builder clearId() { + + id_ = getDefaultInstance().getId(); + onChanged(); + return this; + } + /** + *
+       *Client UUId
+       * 
+ * + * optional string id = 1; + */ + public Builder setIdBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + id_ = value; + onChanged(); + return this; + } + + private Object name_ = ""; + /** + *
+       *Client name
+       * 
+ * + * optional string name = 3; + */ + public String getName() { + Object ref = name_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (String) ref; + } + } + /** + *
+       *Client name
+       * 
+ * + * optional string name = 3; + */ + public com.google.protobuf.ByteString + getNameBytes() { + Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       *Client name
+       * 
+ * + * optional string name = 3; + */ + public Builder setName( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + *
+       *Client name
+       * 
+ * + * optional string name = 3; + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + *
+       *Client name
+       * 
+ * + * optional string name = 3; + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + + private long time_ ; + /** + *
+       *Client current time
+       * 
+ * + * optional int64 time = 4; + */ + public long getTime() { + return time_; + } + /** + *
+       *Client current time
+       * 
+ * + * optional int64 time = 4; + */ + public Builder setTime(long value) { + + time_ = value; + onChanged(); + return this; + } + /** + *
+       *Client current time
+       * 
+ * + * optional int64 time = 4; + */ + public Builder clearTime() { + + time_ = 0L; + onChanged(); + return this; + } + + private Object message_ = ""; + /** + *
+       *Addon message
+       * 
+ * + * optional string message = 6; + */ + public String getMessage() { + Object ref = message_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + message_ = s; + return s; + } else { + return (String) ref; + } + } + /** + *
+       *Addon message
+       * 
+ * + * optional string message = 6; + */ + public com.google.protobuf.ByteString + getMessageBytes() { + Object ref = message_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + message_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + *
+       *Addon message
+       * 
+ * + * optional string message = 6; + */ + public Builder setMessage( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + message_ = value; + onChanged(); + return this; + } + /** + *
+       *Addon message
+       * 
+ * + * optional string message = 6; + */ + public Builder clearMessage() { + + message_ = getDefaultInstance().getMessage(); + onChanged(); + return this; + } + /** + *
+       *Addon message
+       * 
+ * + * optional string message = 6; + */ + public Builder setMessageBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + message_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:core.ClientTestRequest) + } + + // @@protoc_insertion_point(class_scope:core.ClientTestRequest) + private static final ClientTestRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new ClientTestRequest(); + } + + public static ClientTestRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public ClientTestRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new ClientTestRequest(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public ClientTestRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_core_ServerTestResponse_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_core_ServerTestResponse_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor + internal_static_core_ClientTestRequest_descriptor; + private static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_core_ClientTestRequest_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + String[] descriptorData = { + "\n\017test_util.proto\022\004core\"[\n\022ServerTestRes" + + "ponse\022\n\n\002id\030\001 \001(\t\022\014\n\004name\030\003 \001(\t\022\014\n\004time\030" + + "\004 \001(\003\022\014\n\004load\030\006 \001(\005\022\017\n\007message\030\007 \001(\t\"L\n\021" + + "ClientTestRequest\022\n\n\002id\030\001 \001(\t\022\014\n\004name\030\003 " + + "\001(\t\022\014\n\004time\030\004 \001(\003\022\017\n\007message\030\006 \001(\t2\232\001\n\013R" + + "pcTestUtil\022B\n\013NetworkTest\022\027.core.ClientT" + + "estRequest\032\030.core.ServerTestResponse\"\000\022G" + + "\n\020NetworkTestAsync\022\027.core.ClientTestRequ" + + "est\032\030.core.ServerTestResponse\"\000B7\n\037com.d" + + "ingding.octopus.rpc.commonB\rTestUtilProt", + "oP\000\242\002\002CUb\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + internal_static_core_ServerTestResponse_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_core_ServerTestResponse_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_core_ServerTestResponse_descriptor, + new String[] { "Id", "Name", "Time", "Load", "Message", }); + internal_static_core_ClientTestRequest_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_core_ClientTestRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_core_ClientTestRequest_descriptor, + new String[] { "Id", "Name", "Time", "Message", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/octopus-rpc-core/src/main/java/examples/RouteGuideUtil.java b/octopus-rpc-core/src/main/java/examples/RouteGuideUtil.java new file mode 100644 index 0000000..839edb9 --- /dev/null +++ b/octopus-rpc-core/src/main/java/examples/RouteGuideUtil.java @@ -0,0 +1,690 @@ +package examples; + +import com.google.protobuf.util.JsonFormat; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; + +import io.grpc.examples.routeguide.Feature; +import io.grpc.examples.routeguide.FeatureDatabase; +import io.grpc.examples.routeguide.Point; + +/** + * Common utilities for the RouteGuide demo. + */ +public class RouteGuideUtil { + private static final double COORD_FACTOR = 1e7; + + private static final String JSON_DATA = "{\n" + + " \"feature\": [{\n" + + " \"location\": {\n" + + " \"latitude\": 407838351,\n" + + " \"longitude\": -746143763\n" + + " },\n" + + " \"name\": \"Patriots Path, Mendham, NJ 07945, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 408122808,\n" + + " \"longitude\": -743999179\n" + + " },\n" + + " \"name\": \"101 New Jersey 10, Whippany, NJ 07981, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 413628156,\n" + + " \"longitude\": -749015468\n" + + " },\n" + + " \"name\": \"U.S. 6, Shohola, PA 18458, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 419999544,\n" + + " \"longitude\": -740371136\n" + + " },\n" + + " \"name\": \"5 Conners Road, Kingston, NY 12401, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 414008389,\n" + + " \"longitude\": -743951297\n" + + " },\n" + + " \"name\": \"Mid Hudson Psychiatric Center, New Hampton, NY 10958, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 419611318,\n" + + " \"longitude\": -746524769\n" + + " },\n" + + " \"name\": \"287 Flugertown Road, Livingston Manor, NY 12758, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 406109563,\n" + + " \"longitude\": -742186778\n" + + " },\n" + + " \"name\": \"4001 Tremley Point Road, Linden, NJ 07036, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 416802456,\n" + + " \"longitude\": -742370183\n" + + " },\n" + + " \"name\": \"352 South Mountain Road, Wallkill, NY 12589, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 412950425,\n" + + " \"longitude\": -741077389\n" + + " },\n" + + " \"name\": \"Bailey Turn Road, Harriman, NY 10926, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 412144655,\n" + + " \"longitude\": -743949739\n" + + " },\n" + + " \"name\": \"193-199 Wawayanda Road, Hewitt, NJ 07421, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 415736605,\n" + + " \"longitude\": -742847522\n" + + " },\n" + + " \"name\": \"406-496 Ward Avenue, Pine Bush, NY 12566, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 413843930,\n" + + " \"longitude\": -740501726\n" + + " },\n" + + " \"name\": \"162 Merrill Road, Highland Mills, NY 10930, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 410873075,\n" + + " \"longitude\": -744459023\n" + + " },\n" + + " \"name\": \"Clinton Road, West Milford, NJ 07480, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 412346009,\n" + + " \"longitude\": -744026814\n" + + " },\n" + + " \"name\": \"16 Old Brook Lane, Warwick, NY 10990, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 402948455,\n" + + " \"longitude\": -747903913\n" + + " },\n" + + " \"name\": \"3 Drake Lane, Pennington, NJ 08534, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 406337092,\n" + + " \"longitude\": -740122226\n" + + " },\n" + + " \"name\": \"6324 8th Avenue, Brooklyn, NY 11220, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 406421967,\n" + + " \"longitude\": -747727624\n" + + " },\n" + + " \"name\": \"1 Merck Access Road, Whitehouse Station, NJ 08889, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 416318082,\n" + + " \"longitude\": -749677716\n" + + " },\n" + + " \"name\": \"78-98 Schalck Road, Narrowsburg, NY 12764, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 415301720,\n" + + " \"longitude\": -748416257\n" + + " },\n" + + " \"name\": \"282 Lakeview Drive Road, Highland Lake, NY 12743, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 402647019,\n" + + " \"longitude\": -747071791\n" + + " },\n" + + " \"name\": \"330 Evelyn Avenue, Hamilton Township, NJ 08619, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 412567807,\n" + + " \"longitude\": -741058078\n" + + " },\n" + + " \"name\": \"New York State Reference Route 987E, Southfields, NY 10975, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 416855156,\n" + + " \"longitude\": -744420597\n" + + " },\n" + + " \"name\": \"103-271 Tempaloni Road, Ellenville, NY 12428, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 404663628,\n" + + " \"longitude\": -744820157\n" + + " },\n" + + " \"name\": \"1300 Airport Road, North Brunswick Township, NJ 08902, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 407113723,\n" + + " \"longitude\": -749746483\n" + + " },\n" + + " \"name\": \"\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 402133926,\n" + + " \"longitude\": -743613249\n" + + " },\n" + + " \"name\": \"\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 400273442,\n" + + " \"longitude\": -741220915\n" + + " },\n" + + " \"name\": \"\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 411236786,\n" + + " \"longitude\": -744070769\n" + + " },\n" + + " \"name\": \"\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 411633782,\n" + + " \"longitude\": -746784970\n" + + " },\n" + + " \"name\": \"211-225 Plains Road, Augusta, NJ 07822, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 415830701,\n" + + " \"longitude\": -742952812\n" + + " },\n" + + " \"name\": \"\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 413447164,\n" + + " \"longitude\": -748712898\n" + + " },\n" + + " \"name\": \"165 Pedersen Ridge Road, Milford, PA 18337, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 405047245,\n" + + " \"longitude\": -749800722\n" + + " },\n" + + " \"name\": \"100-122 Locktown Road, Frenchtown, NJ 08825, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 418858923,\n" + + " \"longitude\": -746156790\n" + + " },\n" + + " \"name\": \"\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 417951888,\n" + + " \"longitude\": -748484944\n" + + " },\n" + + " \"name\": \"650-652 Willi Hill Road, Swan Lake, NY 12783, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 407033786,\n" + + " \"longitude\": -743977337\n" + + " },\n" + + " \"name\": \"26 East 3rd Street, New Providence, NJ 07974, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 417548014,\n" + + " \"longitude\": -740075041\n" + + " },\n" + + " \"name\": \"\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 410395868,\n" + + " \"longitude\": -744972325\n" + + " },\n" + + " \"name\": \"\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 404615353,\n" + + " \"longitude\": -745129803\n" + + " },\n" + + " \"name\": \"\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 406589790,\n" + + " \"longitude\": -743560121\n" + + " },\n" + + " \"name\": \"611 Lawrence Avenue, Westfield, NJ 07090, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 414653148,\n" + + " \"longitude\": -740477477\n" + + " },\n" + + " \"name\": \"18 Lannis Avenue, New Windsor, NY 12553, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 405957808,\n" + + " \"longitude\": -743255336\n" + + " },\n" + + " \"name\": \"82-104 Amherst Avenue, Colonia, NJ 07067, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 411733589,\n" + + " \"longitude\": -741648093\n" + + " },\n" + + " \"name\": \"170 Seven Lakes Drive, Sloatsburg, NY 10974, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 412676291,\n" + + " \"longitude\": -742606606\n" + + " },\n" + + " \"name\": \"1270 Lakes Road, Monroe, NY 10950, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 409224445,\n" + + " \"longitude\": -748286738\n" + + " },\n" + + " \"name\": \"509-535 Alphano Road, Great Meadows, NJ 07838, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 406523420,\n" + + " \"longitude\": -742135517\n" + + " },\n" + + " \"name\": \"652 Garden Street, Elizabeth, NJ 07202, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 401827388,\n" + + " \"longitude\": -740294537\n" + + " },\n" + + " \"name\": \"349 Sea Spray Court, Neptune City, NJ 07753, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 410564152,\n" + + " \"longitude\": -743685054\n" + + " },\n" + + " \"name\": \"13-17 Stanley Street, West Milford, NJ 07480, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 408472324,\n" + + " \"longitude\": -740726046\n" + + " },\n" + + " \"name\": \"47 Industrial Avenue, Teterboro, NJ 07608, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 412452168,\n" + + " \"longitude\": -740214052\n" + + " },\n" + + " \"name\": \"5 White Oak Lane, Stony Point, NY 10980, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 409146138,\n" + + " \"longitude\": -746188906\n" + + " },\n" + + " \"name\": \"Berkshire Valley Management Area Trail, Jefferson, NJ, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 404701380,\n" + + " \"longitude\": -744781745\n" + + " },\n" + + " \"name\": \"1007 Jersey Avenue, New Brunswick, NJ 08901, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 409642566,\n" + + " \"longitude\": -746017679\n" + + " },\n" + + " \"name\": \"6 East Emerald Isle Drive, Lake Hopatcong, NJ 07849, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 408031728,\n" + + " \"longitude\": -748645385\n" + + " },\n" + + " \"name\": \"1358-1474 New Jersey 57, Port Murray, NJ 07865, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 413700272,\n" + + " \"longitude\": -742135189\n" + + " },\n" + + " \"name\": \"367 Prospect Road, Chester, NY 10918, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 404310607,\n" + + " \"longitude\": -740282632\n" + + " },\n" + + " \"name\": \"10 Simon Lake Drive, Atlantic Highlands, NJ 07716, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 409319800,\n" + + " \"longitude\": -746201391\n" + + " },\n" + + " \"name\": \"11 Ward Street, Mount Arlington, NJ 07856, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 406685311,\n" + + " \"longitude\": -742108603\n" + + " },\n" + + " \"name\": \"300-398 Jefferson Avenue, Elizabeth, NJ 07201, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 419018117,\n" + + " \"longitude\": -749142781\n" + + " },\n" + + " \"name\": \"43 Dreher Road, Roscoe, NY 12776, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 412856162,\n" + + " \"longitude\": -745148837\n" + + " },\n" + + " \"name\": \"Swan Street, Pine Island, NY 10969, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 416560744,\n" + + " \"longitude\": -746721964\n" + + " },\n" + + " \"name\": \"66 Pleasantview Avenue, Monticello, NY 12701, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 405314270,\n" + + " \"longitude\": -749836354\n" + + " },\n" + + " \"name\": \"\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 414219548,\n" + + " \"longitude\": -743327440\n" + + " },\n" + + " \"name\": \"\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 415534177,\n" + + " \"longitude\": -742900616\n" + + " },\n" + + " \"name\": \"565 Winding Hills Road, Montgomery, NY 12549, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 406898530,\n" + + " \"longitude\": -749127080\n" + + " },\n" + + " \"name\": \"231 Rocky Run Road, Glen Gardner, NJ 08826, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 407586880,\n" + + " \"longitude\": -741670168\n" + + " },\n" + + " \"name\": \"100 Mount Pleasant Avenue, Newark, NJ 07104, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 400106455,\n" + + " \"longitude\": -742870190\n" + + " },\n" + + " \"name\": \"517-521 Huntington Drive, Manchester Township, NJ 08759, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 400066188,\n" + + " \"longitude\": -746793294\n" + + " },\n" + + " \"name\": \"\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 418803880,\n" + + " \"longitude\": -744102673\n" + + " },\n" + + " \"name\": \"40 Mountain Road, Napanoch, NY 12458, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 414204288,\n" + + " \"longitude\": -747895140\n" + + " },\n" + + " \"name\": \"\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 414777405,\n" + + " \"longitude\": -740615601\n" + + " },\n" + + " \"name\": \"\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 415464475,\n" + + " \"longitude\": -747175374\n" + + " },\n" + + " \"name\": \"48 North Road, Forestburgh, NY 12777, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 404062378,\n" + + " \"longitude\": -746376177\n" + + " },\n" + + " \"name\": \"\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 405688272,\n" + + " \"longitude\": -749285130\n" + + " },\n" + + " \"name\": \"\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 400342070,\n" + + " \"longitude\": -748788996\n" + + " },\n" + + " \"name\": \"\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 401809022,\n" + + " \"longitude\": -744157964\n" + + " },\n" + + " \"name\": \"\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 404226644,\n" + + " \"longitude\": -740517141\n" + + " },\n" + + " \"name\": \"9 Thompson Avenue, Leonardo, NJ 07737, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 410322033,\n" + + " \"longitude\": -747871659\n" + + " },\n" + + " \"name\": \"\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 407100674,\n" + + " \"longitude\": -747742727\n" + + " },\n" + + " \"name\": \"\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 418811433,\n" + + " \"longitude\": -741718005\n" + + " },\n" + + " \"name\": \"213 Bush Road, Stone Ridge, NY 12484, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 415034302,\n" + + " \"longitude\": -743850945\n" + + " },\n" + + " \"name\": \"\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 411349992,\n" + + " \"longitude\": -743694161\n" + + " },\n" + + " \"name\": \"\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 404839914,\n" + + " \"longitude\": -744759616\n" + + " },\n" + + " \"name\": \"1-17 Bergen Court, New Brunswick, NJ 08901, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 414638017,\n" + + " \"longitude\": -745957854\n" + + " },\n" + + " \"name\": \"35 Oakland Valley Road, Cuddebackville, NY 12729, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 412127800,\n" + + " \"longitude\": -740173578\n" + + " },\n" + + " \"name\": \"\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 401263460,\n" + + " \"longitude\": -747964303\n" + + " },\n" + + " \"name\": \"\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 412843391,\n" + + " \"longitude\": -749086026\n" + + " },\n" + + " \"name\": \"\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 418512773,\n" + + " \"longitude\": -743067823\n" + + " },\n" + + " \"name\": \"\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 404318328,\n" + + " \"longitude\": -740835638\n" + + " },\n" + + " \"name\": \"42-102 Main Street, Belford, NJ 07718, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 419020746,\n" + + " \"longitude\": -741172328\n" + + " },\n" + + " \"name\": \"\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 404080723,\n" + + " \"longitude\": -746119569\n" + + " },\n" + + " \"name\": \"\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 401012643,\n" + + " \"longitude\": -744035134\n" + + " },\n" + + " \"name\": \"\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 404306372,\n" + + " \"longitude\": -741079661\n" + + " },\n" + + " \"name\": \"\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 403966326,\n" + + " \"longitude\": -748519297\n" + + " },\n" + + " \"name\": \"\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 405002031,\n" + + " \"longitude\": -748407866\n" + + " },\n" + + " \"name\": \"\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 409532885,\n" + + " \"longitude\": -742200683\n" + + " },\n" + + " \"name\": \"\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 416851321,\n" + + " \"longitude\": -742674555\n" + + " },\n" + + " \"name\": \"\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 406411633,\n" + + " \"longitude\": -741722051\n" + + " },\n" + + " \"name\": \"3387 Richmond Terrace, Staten Island, NY 10303, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 413069058,\n" + + " \"longitude\": -744597778\n" + + " },\n" + + " \"name\": \"261 Van Sickle Road, Goshen, NY 10924, USA\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 418465462,\n" + + " \"longitude\": -746859398\n" + + " },\n" + + " \"name\": \"\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 411733222,\n" + + " \"longitude\": -744228360\n" + + " },\n" + + " \"name\": \"\"\n" + + " }, {\n" + + " \"location\": {\n" + + " \"latitude\": 410248224,\n" + + " \"longitude\": -747127767\n" + + " },\n" + + " \"name\": \"3 Hasta Way, Newton, NJ 07860, USA\"\n" + + " }]\n" + + "}"; + /** + * Gets the latitude for the given point. + */ + public static double getLatitude(Point location) { + return location.getLatitude() / COORD_FACTOR; + } + + /** + * Gets the longitude for the given point. + */ + + public static double getLongitude(Point location) { + return location.getLongitude() / COORD_FACTOR; + } + + /** + * Gets the default features file from classpath. + */ + /* + public static URL getDefaultFeaturesFile() { + return RouteGuideServer.class.getResource("route_guide_db.json"); + } + */ + + /** + * Parses the JSON input file containing the list of features. + */ + /* + public static List parseFeatures(URL file) throws IOException { + InputStream input = file.openStream(); + try { + Reader reader = new InputStreamReader(input); + try { + FeatureDatabase.Builder database = FeatureDatabase.newBuilder(); + JsonFormat.parser().merge(reader, database); + return database.getFeatureList(); + } finally { + reader.close(); + } + } finally { + input.close(); + } + } + */ + + public static List parseFeatures() { + + try { + FeatureDatabase.Builder database = FeatureDatabase.newBuilder(); + JsonFormat.parser().merge(JSON_DATA, database); + return database.getFeatureList(); + } catch (Exception e){ + //reader.close(); + return new ArrayList<>(); + } + + } + + /** + * Indicates whether the given feature exists (i.e. has a valid name). + */ + public static boolean exists(Feature feature) { + return feature != null && !feature.getName().isEmpty(); + } +} \ No newline at end of file diff --git a/octopus-rpc-core/src/main/java/io/grpc/examples/helloworld/GreeterGrpc.java b/octopus-rpc-core/src/main/java/io/grpc/examples/helloworld/GreeterGrpc.java new file mode 100755 index 0000000..064ee12 --- /dev/null +++ b/octopus-rpc-core/src/main/java/io/grpc/examples/helloworld/GreeterGrpc.java @@ -0,0 +1,252 @@ +package io.grpc.examples.helloworld; + +import static io.grpc.stub.ClientCalls.asyncUnaryCall; +import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; +import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; +import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ClientCalls.blockingUnaryCall; +import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; +import static io.grpc.stub.ClientCalls.futureUnaryCall; +import static io.grpc.MethodDescriptor.generateFullMethodName; +import static io.grpc.stub.ServerCalls.asyncUnaryCall; +import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; +import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; +import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; + +/** + *
+ * The greeting service definition.
+ * 
+ */ +@javax.annotation.Generated( + value = "by gRPC proto compiler (version 0.15.0-SNAPSHOT)", + comments = "Source: helloworld.proto") +public class GreeterGrpc { + + private GreeterGrpc() {} + + public static final String SERVICE_NAME = "helloworld.Greeter"; + + // Static method descriptors that strictly reflect the proto. + @io.grpc.ExperimentalApi + public static final io.grpc.MethodDescriptor METHOD_SAY_HELLO = + io.grpc.MethodDescriptor.create( + io.grpc.MethodDescriptor.MethodType.UNARY, + generateFullMethodName( + "helloworld.Greeter", "SayHello"), + io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.examples.helloworld.HelloRequest.getDefaultInstance()), + io.grpc.protobuf.ProtoUtils.marshaller(HelloReply.getDefaultInstance())); + + /** + * Creates a new async stub that supports all call types for the service + */ + public static GreeterStub newStub(io.grpc.Channel channel) { + return new GreeterStub(channel); + } + + /** + * Creates a new blocking-style stub that supports unary and streaming output calls on the service + */ + public static GreeterBlockingStub newBlockingStub( + io.grpc.Channel channel) { + return new GreeterBlockingStub(channel); + } + + /** + * Creates a new ListenableFuture-style stub that supports unary and streaming output calls on the service + */ + public static GreeterFutureStub newFutureStub( + io.grpc.Channel channel) { + return new GreeterFutureStub(channel); + } + + /** + *
+     * The greeting service definition.
+     * 
+ */ + public static interface Greeter { + + /** + *
+         * Sends a greeting
+         * 
+ */ + public void sayHello(io.grpc.examples.helloworld.HelloRequest request, + io.grpc.stub.StreamObserver responseObserver); + } + + @io.grpc.ExperimentalApi + public static abstract class AbstractGreeter implements Greeter, io.grpc.BindableService { + + @Override + public void sayHello(io.grpc.examples.helloworld.HelloRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(METHOD_SAY_HELLO, responseObserver); + } + + @Override public io.grpc.ServerServiceDefinition bindService() { + return GreeterGrpc.bindService(this); + } + } + + /** + *
+     * The greeting service definition.
+     * 
+ */ + public static interface GreeterBlockingClient { + + /** + *
+         * Sends a greeting
+         * 
+ */ + public HelloReply sayHello(io.grpc.examples.helloworld.HelloRequest request); + } + + /** + *
+     * The greeting service definition.
+     * 
+ */ + public static interface GreeterFutureClient { + + /** + *
+         * Sends a greeting
+         * 
+ */ + public com.google.common.util.concurrent.ListenableFuture sayHello( + io.grpc.examples.helloworld.HelloRequest request); + } + + public static class GreeterStub extends io.grpc.stub.AbstractStub + implements Greeter { + private GreeterStub(io.grpc.Channel channel) { + super(channel); + } + + private GreeterStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @Override + protected GreeterStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new GreeterStub(channel, callOptions); + } + + @Override + public void sayHello(io.grpc.examples.helloworld.HelloRequest request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(METHOD_SAY_HELLO, getCallOptions()), request, responseObserver); + } + } + + public static class GreeterBlockingStub extends io.grpc.stub.AbstractStub + implements GreeterBlockingClient { + private GreeterBlockingStub(io.grpc.Channel channel) { + super(channel); + } + + private GreeterBlockingStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @Override + protected GreeterBlockingStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new GreeterBlockingStub(channel, callOptions); + } + + @Override + public HelloReply sayHello(io.grpc.examples.helloworld.HelloRequest request) { + return blockingUnaryCall( + getChannel(), METHOD_SAY_HELLO, getCallOptions(), request); + } + } + + public static class GreeterFutureStub extends io.grpc.stub.AbstractStub + implements GreeterFutureClient { + private GreeterFutureStub(io.grpc.Channel channel) { + super(channel); + } + + private GreeterFutureStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @Override + protected GreeterFutureStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new GreeterFutureStub(channel, callOptions); + } + + @Override + public com.google.common.util.concurrent.ListenableFuture sayHello( + io.grpc.examples.helloworld.HelloRequest request) { + return futureUnaryCall( + getChannel().newCall(METHOD_SAY_HELLO, getCallOptions()), request); + } + } + + private static final int METHODID_SAY_HELLO = 0; + + private static 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 Greeter serviceImpl; + private final int methodId; + + public MethodHandlers(Greeter serviceImpl, int methodId) { + this.serviceImpl = serviceImpl; + this.methodId = methodId; + } + + @Override + @SuppressWarnings("unchecked") + public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + case METHODID_SAY_HELLO: + serviceImpl.sayHello((io.grpc.examples.helloworld.HelloRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + default: + throw new AssertionError(); + } + } + + @Override + @SuppressWarnings("unchecked") + public io.grpc.stub.StreamObserver invoke( + io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + default: + throw new AssertionError(); + } + } + } + + public static io.grpc.ServerServiceDefinition bindService( + final Greeter serviceImpl) { + return io.grpc.ServerServiceDefinition.builder(SERVICE_NAME) + .addMethod( + METHOD_SAY_HELLO, + asyncUnaryCall( + new MethodHandlers< + io.grpc.examples.helloworld.HelloRequest, + HelloReply>( + serviceImpl, METHODID_SAY_HELLO))) + .build(); + } +} \ No newline at end of file diff --git a/octopus-rpc-core/src/main/java/io/grpc/examples/helloworld/HelloReply.java b/octopus-rpc-core/src/main/java/io/grpc/examples/helloworld/HelloReply.java new file mode 100644 index 0000000..1640824 --- /dev/null +++ b/octopus-rpc-core/src/main/java/io/grpc/examples/helloworld/HelloReply.java @@ -0,0 +1,447 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: helloworld.proto + +package io.grpc.examples.helloworld; + +/** + * Protobuf type {@code helloworld.HelloReply} + * + *
+ * The response message containing the greetings
+ * 
+ */ +public final class HelloReply extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:helloworld.HelloReply) + HelloReplyOrBuilder { + // Use HelloReply.newBuilder() to construct. + private HelloReply(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private HelloReply() { + message_ = ""; + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private HelloReply( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + message_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.grpc.examples.helloworld.HelloWorldProto.internal_static_helloworld_HelloReply_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return io.grpc.examples.helloworld.HelloWorldProto.internal_static_helloworld_HelloReply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + HelloReply.class, Builder.class); + } + + public static final int MESSAGE_FIELD_NUMBER = 1; + private volatile Object message_; + /** + * optional string message = 1; + */ + public String getMessage() { + Object ref = message_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + message_ = s; + return s; + } + } + /** + * optional string message = 1; + */ + public com.google.protobuf.ByteString + getMessageBytes() { + Object ref = message_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + message_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getMessageBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, message_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getMessageBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, message_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static HelloReply parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static HelloReply parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static HelloReply parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static HelloReply parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static HelloReply parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static HelloReply parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static HelloReply parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static HelloReply parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static HelloReply parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static HelloReply parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(HelloReply prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code helloworld.HelloReply} + * + *
+     * The response message containing the greetings
+     * 
+ */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:helloworld.HelloReply) + io.grpc.examples.helloworld.HelloReplyOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.grpc.examples.helloworld.HelloWorldProto.internal_static_helloworld_HelloReply_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return io.grpc.examples.helloworld.HelloWorldProto.internal_static_helloworld_HelloReply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + HelloReply.class, Builder.class); + } + + // Construct using io.grpc.examples.helloworld.HelloReply.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + message_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return io.grpc.examples.helloworld.HelloWorldProto.internal_static_helloworld_HelloReply_descriptor; + } + + public HelloReply getDefaultInstanceForType() { + return HelloReply.getDefaultInstance(); + } + + public HelloReply build() { + HelloReply result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public HelloReply buildPartial() { + HelloReply result = new HelloReply(this); + result.message_ = message_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof HelloReply) { + return mergeFrom((HelloReply)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(HelloReply other) { + if (other == HelloReply.getDefaultInstance()) return this; + if (!other.getMessage().isEmpty()) { + message_ = other.message_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + HelloReply parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (HelloReply) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private Object message_ = ""; + /** + * optional string message = 1; + */ + public String getMessage() { + Object ref = message_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + message_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * optional string message = 1; + */ + public com.google.protobuf.ByteString + getMessageBytes() { + Object ref = message_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + message_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string message = 1; + */ + public Builder setMessage( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + message_ = value; + onChanged(); + return this; + } + /** + * optional string message = 1; + */ + public Builder clearMessage() { + + message_ = getDefaultInstance().getMessage(); + onChanged(); + return this; + } + /** + * optional string message = 1; + */ + public Builder setMessageBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + message_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:helloworld.HelloReply) + } + + // @@protoc_insertion_point(class_scope:helloworld.HelloReply) + private static final HelloReply DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new HelloReply(); + } + + public static HelloReply getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public HelloReply parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new HelloReply(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public HelloReply getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} diff --git a/octopus-rpc-core/src/main/java/io/grpc/examples/helloworld/HelloReplyOrBuilder.java b/octopus-rpc-core/src/main/java/io/grpc/examples/helloworld/HelloReplyOrBuilder.java new file mode 100644 index 0000000..20c9c8c --- /dev/null +++ b/octopus-rpc-core/src/main/java/io/grpc/examples/helloworld/HelloReplyOrBuilder.java @@ -0,0 +1,19 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: helloworld.proto + +package io.grpc.examples.helloworld; + +public interface HelloReplyOrBuilder extends + // @@protoc_insertion_point(interface_extends:helloworld.HelloReply) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string message = 1; + */ + String getMessage(); + /** + * optional string message = 1; + */ + com.google.protobuf.ByteString + getMessageBytes(); +} \ No newline at end of file diff --git a/octopus-rpc-core/src/main/java/io/grpc/examples/helloworld/HelloRequest.java b/octopus-rpc-core/src/main/java/io/grpc/examples/helloworld/HelloRequest.java new file mode 100644 index 0000000..a43eb7f --- /dev/null +++ b/octopus-rpc-core/src/main/java/io/grpc/examples/helloworld/HelloRequest.java @@ -0,0 +1,447 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: helloworld.proto + +package io.grpc.examples.helloworld; + +/** + * Protobuf type {@code helloworld.HelloRequest} + * + *
+ * The request message containing the user's name.
+ * 
+ */ +public final class HelloRequest extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:helloworld.HelloRequest) + HelloRequestOrBuilder { + // Use HelloRequest.newBuilder() to construct. + private HelloRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private HelloRequest() { + name_ = ""; + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private HelloRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.grpc.examples.helloworld.HelloWorldProto.internal_static_helloworld_HelloRequest_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return io.grpc.examples.helloworld.HelloWorldProto.internal_static_helloworld_HelloRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + HelloRequest.class, Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + private volatile Object name_; + /** + * optional string name = 1; + */ + public String getName() { + Object ref = name_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * optional string name = 1; + */ + public com.google.protobuf.ByteString + getNameBytes() { + Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static HelloRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static HelloRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static HelloRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static HelloRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static HelloRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static HelloRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static HelloRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static HelloRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static HelloRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static HelloRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(HelloRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code helloworld.HelloRequest} + * + *
+     * The request message containing the user's name.
+     * 
+ */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:helloworld.HelloRequest) + io.grpc.examples.helloworld.HelloRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.grpc.examples.helloworld.HelloWorldProto.internal_static_helloworld_HelloRequest_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return io.grpc.examples.helloworld.HelloWorldProto.internal_static_helloworld_HelloRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + HelloRequest.class, Builder.class); + } + + // Construct using io.grpc.examples.helloworld.HelloRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + name_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return io.grpc.examples.helloworld.HelloWorldProto.internal_static_helloworld_HelloRequest_descriptor; + } + + public HelloRequest getDefaultInstanceForType() { + return HelloRequest.getDefaultInstance(); + } + + public HelloRequest build() { + HelloRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public HelloRequest buildPartial() { + HelloRequest result = new HelloRequest(this); + result.name_ = name_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof HelloRequest) { + return mergeFrom((HelloRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(HelloRequest other) { + if (other == HelloRequest.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + HelloRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (HelloRequest) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private Object name_ = ""; + /** + * optional string name = 1; + */ + public String getName() { + Object ref = name_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * optional string name = 1; + */ + public com.google.protobuf.ByteString + getNameBytes() { + Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string name = 1; + */ + public Builder setName( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + * optional string name = 1; + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + * optional string name = 1; + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:helloworld.HelloRequest) + } + + // @@protoc_insertion_point(class_scope:helloworld.HelloRequest) + private static final HelloRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new HelloRequest(); + } + + public static HelloRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public HelloRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new HelloRequest(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public HelloRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} diff --git a/octopus-rpc-core/src/main/java/io/grpc/examples/helloworld/HelloRequestOrBuilder.java b/octopus-rpc-core/src/main/java/io/grpc/examples/helloworld/HelloRequestOrBuilder.java new file mode 100644 index 0000000..d1464da --- /dev/null +++ b/octopus-rpc-core/src/main/java/io/grpc/examples/helloworld/HelloRequestOrBuilder.java @@ -0,0 +1,19 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: helloworld.proto + +package io.grpc.examples.helloworld; + +public interface HelloRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:helloworld.HelloRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string name = 1; + */ + String getName(); + /** + * optional string name = 1; + */ + com.google.protobuf.ByteString + getNameBytes(); +} \ No newline at end of file diff --git a/octopus-rpc-core/src/main/java/io/grpc/examples/helloworld/HelloWorldProto.java b/octopus-rpc-core/src/main/java/io/grpc/examples/helloworld/HelloWorldProto.java new file mode 100644 index 0000000..94ff608 --- /dev/null +++ b/octopus-rpc-core/src/main/java/io/grpc/examples/helloworld/HelloWorldProto.java @@ -0,0 +1,64 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: helloworld.proto + +package io.grpc.examples.helloworld; + +public final class HelloWorldProto { + private HelloWorldProto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + static com.google.protobuf.Descriptors.Descriptor + internal_static_helloworld_HelloRequest_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_helloworld_HelloRequest_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_helloworld_HelloReply_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_helloworld_HelloReply_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + String[] descriptorData = { + "\n\020helloworld.proto\022\nhelloworld\"\034\n\014HelloR" + + "equest\022\014\n\004name\030\001 \001(\t\"\035\n\nHelloReply\022\017\n\007me" + + "ssage\030\001 \001(\t2I\n\007Greeter\022>\n\010SayHello\022\030.hel" + + "loworld.HelloRequest\032\026.helloworld.HelloR" + + "eply\"\000B6\n\033io.grpc.examples.helloworldB\017H" + + "elloWorldProtoP\001\242\002\003HLWb\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + internal_static_helloworld_HelloRequest_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_helloworld_HelloRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_helloworld_HelloRequest_descriptor, + new String[] { "Name", }); + internal_static_helloworld_HelloReply_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_helloworld_HelloReply_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_helloworld_HelloReply_descriptor, + new String[] { "Message", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} \ No newline at end of file diff --git a/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/Feature.java b/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/Feature.java new file mode 100755 index 0000000..c38f2ad --- /dev/null +++ b/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/Feature.java @@ -0,0 +1,698 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: route_guide.proto + +package io.grpc.examples.routeguide; + +/** + * Protobuf type {@code routeguide.Feature} + * + *
+ * A feature names something at a given point.
+ * If a feature could not be named, the name is empty.
+ * 
+ */ +public final class Feature extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:routeguide.Feature) + FeatureOrBuilder { + // Use Feature.newBuilder() to construct. + private Feature(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private Feature() { + name_ = ""; + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private Feature( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + case 18: { + io.grpc.examples.routeguide.Point.Builder subBuilder = null; + if (location_ != null) { + subBuilder = location_.toBuilder(); + } + location_ = input.readMessage(io.grpc.examples.routeguide.Point.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(location_); + location_ = subBuilder.buildPartial(); + } + + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.grpc.examples.routeguide.RouteGuideProto.internal_static_routeguide_Feature_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return io.grpc.examples.routeguide.RouteGuideProto.internal_static_routeguide_Feature_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Feature.class, Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + private volatile Object name_; + /** + * optional string name = 1; + * + *
+   * The name of the feature.
+   * 
+ */ + public String getName() { + Object ref = name_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * optional string name = 1; + * + *
+   * The name of the feature.
+   * 
+ */ + public com.google.protobuf.ByteString + getNameBytes() { + Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int LOCATION_FIELD_NUMBER = 2; + private io.grpc.examples.routeguide.Point location_; + /** + * optional .routeguide.Point location = 2; + * + *
+   * The point where the feature is detected.
+   * 
+ */ + public boolean hasLocation() { + return location_ != null; + } + /** + * optional .routeguide.Point location = 2; + * + *
+   * The point where the feature is detected.
+   * 
+ */ + public io.grpc.examples.routeguide.Point getLocation() { + return location_ == null ? io.grpc.examples.routeguide.Point.getDefaultInstance() : location_; + } + /** + * optional .routeguide.Point location = 2; + * + *
+   * The point where the feature is detected.
+   * 
+ */ + public io.grpc.examples.routeguide.PointOrBuilder getLocationOrBuilder() { + return getLocation(); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + if (location_ != null) { + output.writeMessage(2, getLocation()); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + if (location_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, getLocation()); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static Feature parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Feature parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Feature parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Feature parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Feature parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static Feature parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static Feature parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static Feature parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static Feature parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static Feature parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(Feature prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code routeguide.Feature} + * + *
+   * A feature names something at a given point.
+   * If a feature could not be named, the name is empty.
+   * 
+ */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:routeguide.Feature) + io.grpc.examples.routeguide.FeatureOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.grpc.examples.routeguide.RouteGuideProto.internal_static_routeguide_Feature_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return io.grpc.examples.routeguide.RouteGuideProto.internal_static_routeguide_Feature_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Feature.class, Builder.class); + } + + // Construct using io.grpc.examples.routeguide.Feature.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + name_ = ""; + + if (locationBuilder_ == null) { + location_ = null; + } else { + location_ = null; + locationBuilder_ = null; + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return io.grpc.examples.routeguide.RouteGuideProto.internal_static_routeguide_Feature_descriptor; + } + + public Feature getDefaultInstanceForType() { + return Feature.getDefaultInstance(); + } + + public Feature build() { + Feature result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public Feature buildPartial() { + Feature result = new Feature(this); + result.name_ = name_; + if (locationBuilder_ == null) { + result.location_ = location_; + } else { + result.location_ = locationBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof Feature) { + return mergeFrom((Feature)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(Feature other) { + if (other == Feature.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + if (other.hasLocation()) { + mergeLocation(other.getLocation()); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + Feature parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (Feature) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private Object name_ = ""; + /** + * optional string name = 1; + * + *
+     * The name of the feature.
+     * 
+ */ + public String getName() { + Object ref = name_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * optional string name = 1; + * + *
+     * The name of the feature.
+     * 
+ */ + public com.google.protobuf.ByteString + getNameBytes() { + Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string name = 1; + * + *
+     * The name of the feature.
+     * 
+ */ + public Builder setName( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + * optional string name = 1; + * + *
+     * The name of the feature.
+     * 
+ */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + * optional string name = 1; + * + *
+     * The name of the feature.
+     * 
+ */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + + private io.grpc.examples.routeguide.Point location_ = null; + private com.google.protobuf.SingleFieldBuilder< + io.grpc.examples.routeguide.Point, io.grpc.examples.routeguide.Point.Builder, io.grpc.examples.routeguide.PointOrBuilder> locationBuilder_; + /** + * optional .routeguide.Point location = 2; + * + *
+     * The point where the feature is detected.
+     * 
+ */ + public boolean hasLocation() { + return locationBuilder_ != null || location_ != null; + } + /** + * optional .routeguide.Point location = 2; + * + *
+     * The point where the feature is detected.
+     * 
+ */ + public io.grpc.examples.routeguide.Point getLocation() { + if (locationBuilder_ == null) { + return location_ == null ? io.grpc.examples.routeguide.Point.getDefaultInstance() : location_; + } else { + return locationBuilder_.getMessage(); + } + } + /** + * optional .routeguide.Point location = 2; + * + *
+     * The point where the feature is detected.
+     * 
+ */ + public Builder setLocation(io.grpc.examples.routeguide.Point value) { + if (locationBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + location_ = value; + onChanged(); + } else { + locationBuilder_.setMessage(value); + } + + return this; + } + /** + * optional .routeguide.Point location = 2; + * + *
+     * The point where the feature is detected.
+     * 
+ */ + public Builder setLocation( + io.grpc.examples.routeguide.Point.Builder builderForValue) { + if (locationBuilder_ == null) { + location_ = builderForValue.build(); + onChanged(); + } else { + locationBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * optional .routeguide.Point location = 2; + * + *
+     * The point where the feature is detected.
+     * 
+ */ + public Builder mergeLocation(io.grpc.examples.routeguide.Point value) { + if (locationBuilder_ == null) { + if (location_ != null) { + location_ = + io.grpc.examples.routeguide.Point.newBuilder(location_).mergeFrom(value).buildPartial(); + } else { + location_ = value; + } + onChanged(); + } else { + locationBuilder_.mergeFrom(value); + } + + return this; + } + /** + * optional .routeguide.Point location = 2; + * + *
+     * The point where the feature is detected.
+     * 
+ */ + public Builder clearLocation() { + if (locationBuilder_ == null) { + location_ = null; + onChanged(); + } else { + location_ = null; + locationBuilder_ = null; + } + + return this; + } + /** + * optional .routeguide.Point location = 2; + * + *
+     * The point where the feature is detected.
+     * 
+ */ + public io.grpc.examples.routeguide.Point.Builder getLocationBuilder() { + + onChanged(); + return getLocationFieldBuilder().getBuilder(); + } + /** + * optional .routeguide.Point location = 2; + * + *
+     * The point where the feature is detected.
+     * 
+ */ + public io.grpc.examples.routeguide.PointOrBuilder getLocationOrBuilder() { + if (locationBuilder_ != null) { + return locationBuilder_.getMessageOrBuilder(); + } else { + return location_ == null ? + io.grpc.examples.routeguide.Point.getDefaultInstance() : location_; + } + } + /** + * optional .routeguide.Point location = 2; + * + *
+     * The point where the feature is detected.
+     * 
+ */ + private com.google.protobuf.SingleFieldBuilder< + io.grpc.examples.routeguide.Point, io.grpc.examples.routeguide.Point.Builder, io.grpc.examples.routeguide.PointOrBuilder> + getLocationFieldBuilder() { + if (locationBuilder_ == null) { + locationBuilder_ = new com.google.protobuf.SingleFieldBuilder< + io.grpc.examples.routeguide.Point, io.grpc.examples.routeguide.Point.Builder, io.grpc.examples.routeguide.PointOrBuilder>( + getLocation(), + getParentForChildren(), + isClean()); + location_ = null; + } + return locationBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:routeguide.Feature) + } + + // @@protoc_insertion_point(class_scope:routeguide.Feature) + private static final Feature DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new Feature(); + } + + public static Feature getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Feature parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new Feature(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public Feature getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/FeatureDatabase.java b/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/FeatureDatabase.java new file mode 100755 index 0000000..7b06125 --- /dev/null +++ b/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/FeatureDatabase.java @@ -0,0 +1,663 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: route_guide.proto + +package io.grpc.examples.routeguide; + +/** + * Protobuf type {@code routeguide.FeatureDatabase} + * + *
+ * Not used in the RPC.  Instead, this is here for the form serialized to disk.
+ * 
+ */ +public final class FeatureDatabase extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:routeguide.FeatureDatabase) + FeatureDatabaseOrBuilder { + // Use FeatureDatabase.newBuilder() to construct. + private FeatureDatabase(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private FeatureDatabase() { + feature_ = java.util.Collections.emptyList(); + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private FeatureDatabase( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + feature_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000001; + } + feature_.add(input.readMessage(Feature.parser(), extensionRegistry)); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) { + feature_ = java.util.Collections.unmodifiableList(feature_); + } + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.grpc.examples.routeguide.RouteGuideProto.internal_static_routeguide_FeatureDatabase_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return io.grpc.examples.routeguide.RouteGuideProto.internal_static_routeguide_FeatureDatabase_fieldAccessorTable + .ensureFieldAccessorsInitialized( + FeatureDatabase.class, Builder.class); + } + + public static final int FEATURE_FIELD_NUMBER = 1; + private java.util.List feature_; + /** + * repeated .routeguide.Feature feature = 1; + */ + public java.util.List getFeatureList() { + return feature_; + } + /** + * repeated .routeguide.Feature feature = 1; + */ + public java.util.List + getFeatureOrBuilderList() { + return feature_; + } + /** + * repeated .routeguide.Feature feature = 1; + */ + public int getFeatureCount() { + return feature_.size(); + } + /** + * repeated .routeguide.Feature feature = 1; + */ + public Feature getFeature(int index) { + return feature_.get(index); + } + /** + * repeated .routeguide.Feature feature = 1; + */ + public io.grpc.examples.routeguide.FeatureOrBuilder getFeatureOrBuilder( + int index) { + return feature_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < feature_.size(); i++) { + output.writeMessage(1, feature_.get(i)); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < feature_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, feature_.get(i)); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static FeatureDatabase parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static FeatureDatabase parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static FeatureDatabase parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static FeatureDatabase parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static FeatureDatabase parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static FeatureDatabase parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static FeatureDatabase parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static FeatureDatabase parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static FeatureDatabase parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static FeatureDatabase parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(FeatureDatabase prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code routeguide.FeatureDatabase} + * + *
+   * Not used in the RPC.  Instead, this is here for the form serialized to disk.
+   * 
+ */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:routeguide.FeatureDatabase) + io.grpc.examples.routeguide.FeatureDatabaseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.grpc.examples.routeguide.RouteGuideProto.internal_static_routeguide_FeatureDatabase_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return io.grpc.examples.routeguide.RouteGuideProto.internal_static_routeguide_FeatureDatabase_fieldAccessorTable + .ensureFieldAccessorsInitialized( + FeatureDatabase.class, Builder.class); + } + + // Construct using io.grpc.examples.routeguide.FeatureDatabase.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getFeatureFieldBuilder(); + } + } + public Builder clear() { + super.clear(); + if (featureBuilder_ == null) { + feature_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + } else { + featureBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return io.grpc.examples.routeguide.RouteGuideProto.internal_static_routeguide_FeatureDatabase_descriptor; + } + + public FeatureDatabase getDefaultInstanceForType() { + return FeatureDatabase.getDefaultInstance(); + } + + public FeatureDatabase build() { + FeatureDatabase result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public FeatureDatabase buildPartial() { + FeatureDatabase result = new FeatureDatabase(this); + int from_bitField0_ = bitField0_; + if (featureBuilder_ == null) { + if (((bitField0_ & 0x00000001) == 0x00000001)) { + feature_ = java.util.Collections.unmodifiableList(feature_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.feature_ = feature_; + } else { + result.feature_ = featureBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof FeatureDatabase) { + return mergeFrom((FeatureDatabase)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(FeatureDatabase other) { + if (other == FeatureDatabase.getDefaultInstance()) return this; + if (featureBuilder_ == null) { + if (!other.feature_.isEmpty()) { + if (feature_.isEmpty()) { + feature_ = other.feature_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureFeatureIsMutable(); + feature_.addAll(other.feature_); + } + onChanged(); + } + } else { + if (!other.feature_.isEmpty()) { + if (featureBuilder_.isEmpty()) { + featureBuilder_.dispose(); + featureBuilder_ = null; + feature_ = other.feature_; + bitField0_ = (bitField0_ & ~0x00000001); + featureBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getFeatureFieldBuilder() : null; + } else { + featureBuilder_.addAllMessages(other.feature_); + } + } + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + FeatureDatabase parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (FeatureDatabase) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private java.util.List feature_ = + java.util.Collections.emptyList(); + private void ensureFeatureIsMutable() { + if (!((bitField0_ & 0x00000001) == 0x00000001)) { + feature_ = new java.util.ArrayList(feature_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + Feature, Feature.Builder, io.grpc.examples.routeguide.FeatureOrBuilder> featureBuilder_; + + /** + * repeated .routeguide.Feature feature = 1; + */ + public java.util.List getFeatureList() { + if (featureBuilder_ == null) { + return java.util.Collections.unmodifiableList(feature_); + } else { + return featureBuilder_.getMessageList(); + } + } + /** + * repeated .routeguide.Feature feature = 1; + */ + public int getFeatureCount() { + if (featureBuilder_ == null) { + return feature_.size(); + } else { + return featureBuilder_.getCount(); + } + } + /** + * repeated .routeguide.Feature feature = 1; + */ + public Feature getFeature(int index) { + if (featureBuilder_ == null) { + return feature_.get(index); + } else { + return featureBuilder_.getMessage(index); + } + } + /** + * repeated .routeguide.Feature feature = 1; + */ + public Builder setFeature( + int index, Feature value) { + if (featureBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFeatureIsMutable(); + feature_.set(index, value); + onChanged(); + } else { + featureBuilder_.setMessage(index, value); + } + return this; + } + /** + * repeated .routeguide.Feature feature = 1; + */ + public Builder setFeature( + int index, Feature.Builder builderForValue) { + if (featureBuilder_ == null) { + ensureFeatureIsMutable(); + feature_.set(index, builderForValue.build()); + onChanged(); + } else { + featureBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .routeguide.Feature feature = 1; + */ + public Builder addFeature(Feature value) { + if (featureBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFeatureIsMutable(); + feature_.add(value); + onChanged(); + } else { + featureBuilder_.addMessage(value); + } + return this; + } + /** + * repeated .routeguide.Feature feature = 1; + */ + public Builder addFeature( + int index, Feature value) { + if (featureBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFeatureIsMutable(); + feature_.add(index, value); + onChanged(); + } else { + featureBuilder_.addMessage(index, value); + } + return this; + } + /** + * repeated .routeguide.Feature feature = 1; + */ + public Builder addFeature( + Feature.Builder builderForValue) { + if (featureBuilder_ == null) { + ensureFeatureIsMutable(); + feature_.add(builderForValue.build()); + onChanged(); + } else { + featureBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * repeated .routeguide.Feature feature = 1; + */ + public Builder addFeature( + int index, Feature.Builder builderForValue) { + if (featureBuilder_ == null) { + ensureFeatureIsMutable(); + feature_.add(index, builderForValue.build()); + onChanged(); + } else { + featureBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * repeated .routeguide.Feature feature = 1; + */ + public Builder addAllFeature( + Iterable values) { + if (featureBuilder_ == null) { + ensureFeatureIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, feature_); + onChanged(); + } else { + featureBuilder_.addAllMessages(values); + } + return this; + } + /** + * repeated .routeguide.Feature feature = 1; + */ + public Builder clearFeature() { + if (featureBuilder_ == null) { + feature_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + featureBuilder_.clear(); + } + return this; + } + /** + * repeated .routeguide.Feature feature = 1; + */ + public Builder removeFeature(int index) { + if (featureBuilder_ == null) { + ensureFeatureIsMutable(); + feature_.remove(index); + onChanged(); + } else { + featureBuilder_.remove(index); + } + return this; + } + /** + * repeated .routeguide.Feature feature = 1; + */ + public Feature.Builder getFeatureBuilder( + int index) { + return getFeatureFieldBuilder().getBuilder(index); + } + /** + * repeated .routeguide.Feature feature = 1; + */ + public io.grpc.examples.routeguide.FeatureOrBuilder getFeatureOrBuilder( + int index) { + if (featureBuilder_ == null) { + return feature_.get(index); } else { + return featureBuilder_.getMessageOrBuilder(index); + } + } + /** + * repeated .routeguide.Feature feature = 1; + */ + public java.util.List + getFeatureOrBuilderList() { + if (featureBuilder_ != null) { + return featureBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(feature_); + } + } + /** + * repeated .routeguide.Feature feature = 1; + */ + public Feature.Builder addFeatureBuilder() { + return getFeatureFieldBuilder().addBuilder( + Feature.getDefaultInstance()); + } + /** + * repeated .routeguide.Feature feature = 1; + */ + public Feature.Builder addFeatureBuilder( + int index) { + return getFeatureFieldBuilder().addBuilder( + index, Feature.getDefaultInstance()); + } + /** + * repeated .routeguide.Feature feature = 1; + */ + public java.util.List + getFeatureBuilderList() { + return getFeatureFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + Feature, Feature.Builder, io.grpc.examples.routeguide.FeatureOrBuilder> + getFeatureFieldBuilder() { + if (featureBuilder_ == null) { + featureBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + Feature, Feature.Builder, io.grpc.examples.routeguide.FeatureOrBuilder>( + feature_, + ((bitField0_ & 0x00000001) == 0x00000001), + getParentForChildren(), + isClean()); + feature_ = null; + } + return featureBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:routeguide.FeatureDatabase) + } + + // @@protoc_insertion_point(class_scope:routeguide.FeatureDatabase) + private static final FeatureDatabase DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new FeatureDatabase(); + } + + public static FeatureDatabase getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public FeatureDatabase parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new FeatureDatabase(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public FeatureDatabase getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/FeatureDatabaseOrBuilder.java b/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/FeatureDatabaseOrBuilder.java new file mode 100755 index 0000000..fb5f493 --- /dev/null +++ b/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/FeatureDatabaseOrBuilder.java @@ -0,0 +1,33 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: route_guide.proto + +package io.grpc.examples.routeguide; + +public interface FeatureDatabaseOrBuilder extends + // @@protoc_insertion_point(interface_extends:routeguide.FeatureDatabase) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated .routeguide.Feature feature = 1; + */ + java.util.List + getFeatureList(); + /** + * repeated .routeguide.Feature feature = 1; + */ + Feature getFeature(int index); + /** + * repeated .routeguide.Feature feature = 1; + */ + int getFeatureCount(); + /** + * repeated .routeguide.Feature feature = 1; + */ + java.util.List + getFeatureOrBuilderList(); + /** + * repeated .routeguide.Feature feature = 1; + */ + io.grpc.examples.routeguide.FeatureOrBuilder getFeatureOrBuilder( + int index); +} diff --git a/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/FeatureOrBuilder.java b/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/FeatureOrBuilder.java new file mode 100755 index 0000000..23a885d --- /dev/null +++ b/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/FeatureOrBuilder.java @@ -0,0 +1,52 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: route_guide.proto + +package io.grpc.examples.routeguide; + +public interface FeatureOrBuilder extends + // @@protoc_insertion_point(interface_extends:routeguide.Feature) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string name = 1; + * + *
+   * The name of the feature.
+   * 
+ */ + String getName(); + /** + * optional string name = 1; + * + *
+   * The name of the feature.
+   * 
+ */ + com.google.protobuf.ByteString + getNameBytes(); + + /** + * optional .routeguide.Point location = 2; + * + *
+   * The point where the feature is detected.
+   * 
+ */ + boolean hasLocation(); + /** + * optional .routeguide.Point location = 2; + * + *
+   * The point where the feature is detected.
+   * 
+ */ + io.grpc.examples.routeguide.Point getLocation(); + /** + * optional .routeguide.Point location = 2; + * + *
+   * The point where the feature is detected.
+   * 
+ */ + io.grpc.examples.routeguide.PointOrBuilder getLocationOrBuilder(); +} diff --git a/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/Point.java b/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/Point.java new file mode 100755 index 0000000..de4ca80 --- /dev/null +++ b/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/Point.java @@ -0,0 +1,439 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: route_guide.proto + +package io.grpc.examples.routeguide; + +/** + * Protobuf type {@code routeguide.Point} + * + *
+ * Points are represented as latitude-longitude pairs in the E7 representation
+ * (degrees multiplied by 10**7 and rounded to the nearest integer).
+ * Latitudes should be in the range +/- 90 degrees and longitude should be in
+ * the range +/- 180 degrees (inclusive).
+ * 
+ */ +public final class Point extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:routeguide.Point) + PointOrBuilder { + // Use Point.newBuilder() to construct. + private Point(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private Point() { + latitude_ = 0; + longitude_ = 0; + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private Point( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 8: { + + latitude_ = input.readInt32(); + break; + } + case 16: { + + longitude_ = input.readInt32(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.grpc.examples.routeguide.RouteGuideProto.internal_static_routeguide_Point_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return io.grpc.examples.routeguide.RouteGuideProto.internal_static_routeguide_Point_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Point.class, Builder.class); + } + + public static final int LATITUDE_FIELD_NUMBER = 1; + private int latitude_; + /** + * optional int32 latitude = 1; + */ + public int getLatitude() { + return latitude_; + } + + public static final int LONGITUDE_FIELD_NUMBER = 2; + private int longitude_; + /** + * optional int32 longitude = 2; + */ + public int getLongitude() { + return longitude_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (latitude_ != 0) { + output.writeInt32(1, latitude_); + } + if (longitude_ != 0) { + output.writeInt32(2, longitude_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (latitude_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(1, latitude_); + } + if (longitude_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(2, longitude_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static Point parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Point parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Point parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Point parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Point parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static Point parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static Point parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static Point parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static Point parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static Point parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(Point prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code routeguide.Point} + * + *
+   * Points are represented as latitude-longitude pairs in the E7 representation
+   * (degrees multiplied by 10**7 and rounded to the nearest integer).
+   * Latitudes should be in the range +/- 90 degrees and longitude should be in
+   * the range +/- 180 degrees (inclusive).
+   * 
+ */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:routeguide.Point) + io.grpc.examples.routeguide.PointOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.grpc.examples.routeguide.RouteGuideProto.internal_static_routeguide_Point_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return io.grpc.examples.routeguide.RouteGuideProto.internal_static_routeguide_Point_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Point.class, Builder.class); + } + + // Construct using io.grpc.examples.routeguide.Point.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + latitude_ = 0; + + longitude_ = 0; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return io.grpc.examples.routeguide.RouteGuideProto.internal_static_routeguide_Point_descriptor; + } + + public Point getDefaultInstanceForType() { + return Point.getDefaultInstance(); + } + + public Point build() { + Point result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public Point buildPartial() { + Point result = new Point(this); + result.latitude_ = latitude_; + result.longitude_ = longitude_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof Point) { + return mergeFrom((Point)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(Point other) { + if (other == Point.getDefaultInstance()) return this; + if (other.getLatitude() != 0) { + setLatitude(other.getLatitude()); + } + if (other.getLongitude() != 0) { + setLongitude(other.getLongitude()); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + Point parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (Point) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int latitude_ ; + /** + * optional int32 latitude = 1; + */ + public int getLatitude() { + return latitude_; + } + /** + * optional int32 latitude = 1; + */ + public Builder setLatitude(int value) { + + latitude_ = value; + onChanged(); + return this; + } + /** + * optional int32 latitude = 1; + */ + public Builder clearLatitude() { + + latitude_ = 0; + onChanged(); + return this; + } + + private int longitude_ ; + /** + * optional int32 longitude = 2; + */ + public int getLongitude() { + return longitude_; + } + /** + * optional int32 longitude = 2; + */ + public Builder setLongitude(int value) { + + longitude_ = value; + onChanged(); + return this; + } + /** + * optional int32 longitude = 2; + */ + public Builder clearLongitude() { + + longitude_ = 0; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:routeguide.Point) + } + + // @@protoc_insertion_point(class_scope:routeguide.Point) + private static final Point DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new Point(); + } + + public static Point getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Point parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new Point(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public Point getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/PointOrBuilder.java b/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/PointOrBuilder.java new file mode 100755 index 0000000..0ae9ac0 --- /dev/null +++ b/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/PointOrBuilder.java @@ -0,0 +1,19 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: route_guide.proto + +package io.grpc.examples.routeguide; + +public interface PointOrBuilder extends + // @@protoc_insertion_point(interface_extends:routeguide.Point) + com.google.protobuf.MessageOrBuilder { + + /** + * optional int32 latitude = 1; + */ + int getLatitude(); + + /** + * optional int32 longitude = 2; + */ + int getLongitude(); +} diff --git a/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/Rectangle.java b/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/Rectangle.java new file mode 100755 index 0000000..f5b40b6 --- /dev/null +++ b/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/Rectangle.java @@ -0,0 +1,767 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: route_guide.proto + +package io.grpc.examples.routeguide; + +/** + * Protobuf type {@code routeguide.Rectangle} + * + *
+ * A latitude-longitude rectangle, represented as two diagonally opposite
+ * points "lo" and "hi".
+ * 
+ */ +public final class Rectangle extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:routeguide.Rectangle) + RectangleOrBuilder { + // Use Rectangle.newBuilder() to construct. + private Rectangle(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private Rectangle() { + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private Rectangle( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + Point.Builder subBuilder = null; + if (lo_ != null) { + subBuilder = lo_.toBuilder(); + } + lo_ = input.readMessage(Point.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(lo_); + lo_ = subBuilder.buildPartial(); + } + + break; + } + case 18: { + Point.Builder subBuilder = null; + if (hi_ != null) { + subBuilder = hi_.toBuilder(); + } + hi_ = input.readMessage(Point.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(hi_); + hi_ = subBuilder.buildPartial(); + } + + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.grpc.examples.routeguide.RouteGuideProto.internal_static_routeguide_Rectangle_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return io.grpc.examples.routeguide.RouteGuideProto.internal_static_routeguide_Rectangle_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Rectangle.class, Builder.class); + } + + public static final int LO_FIELD_NUMBER = 1; + private Point lo_; + /** + * optional .routeguide.Point lo = 1; + * + *
+   * One corner of the rectangle.
+   * 
+ */ + public boolean hasLo() { + return lo_ != null; + } + /** + * optional .routeguide.Point lo = 1; + * + *
+   * One corner of the rectangle.
+   * 
+ */ + public Point getLo() { + return lo_ == null ? Point.getDefaultInstance() : lo_; + } + /** + * optional .routeguide.Point lo = 1; + * + *
+   * One corner of the rectangle.
+   * 
+ */ + public PointOrBuilder getLoOrBuilder() { + return getLo(); + } + + public static final int HI_FIELD_NUMBER = 2; + private Point hi_; + /** + * optional .routeguide.Point hi = 2; + * + *
+   * The other corner of the rectangle.
+   * 
+ */ + public boolean hasHi() { + return hi_ != null; + } + /** + * optional .routeguide.Point hi = 2; + * + *
+   * The other corner of the rectangle.
+   * 
+ */ + public Point getHi() { + return hi_ == null ? Point.getDefaultInstance() : hi_; + } + /** + * optional .routeguide.Point hi = 2; + * + *
+   * The other corner of the rectangle.
+   * 
+ */ + public PointOrBuilder getHiOrBuilder() { + return getHi(); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (lo_ != null) { + output.writeMessage(1, getLo()); + } + if (hi_ != null) { + output.writeMessage(2, getHi()); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (lo_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getLo()); + } + if (hi_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(2, getHi()); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static Rectangle parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Rectangle parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Rectangle parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static Rectangle parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static Rectangle parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static Rectangle parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static Rectangle parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static Rectangle parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static Rectangle parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static Rectangle parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(Rectangle prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code routeguide.Rectangle} + * + *
+   * A latitude-longitude rectangle, represented as two diagonally opposite
+   * points "lo" and "hi".
+   * 
+ */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:routeguide.Rectangle) + io.grpc.examples.routeguide.RectangleOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.grpc.examples.routeguide.RouteGuideProto.internal_static_routeguide_Rectangle_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return io.grpc.examples.routeguide.RouteGuideProto.internal_static_routeguide_Rectangle_fieldAccessorTable + .ensureFieldAccessorsInitialized( + Rectangle.class, Builder.class); + } + + // Construct using io.grpc.examples.routeguide.Rectangle.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + if (loBuilder_ == null) { + lo_ = null; + } else { + lo_ = null; + loBuilder_ = null; + } + if (hiBuilder_ == null) { + hi_ = null; + } else { + hi_ = null; + hiBuilder_ = null; + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return io.grpc.examples.routeguide.RouteGuideProto.internal_static_routeguide_Rectangle_descriptor; + } + + public Rectangle getDefaultInstanceForType() { + return Rectangle.getDefaultInstance(); + } + + public Rectangle build() { + Rectangle result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public Rectangle buildPartial() { + Rectangle result = new Rectangle(this); + if (loBuilder_ == null) { + result.lo_ = lo_; + } else { + result.lo_ = loBuilder_.build(); + } + if (hiBuilder_ == null) { + result.hi_ = hi_; + } else { + result.hi_ = hiBuilder_.build(); + } + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof Rectangle) { + return mergeFrom((Rectangle)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(Rectangle other) { + if (other == Rectangle.getDefaultInstance()) return this; + if (other.hasLo()) { + mergeLo(other.getLo()); + } + if (other.hasHi()) { + mergeHi(other.getHi()); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + Rectangle parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (Rectangle) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private Point lo_ = null; + private com.google.protobuf.SingleFieldBuilder< + Point, Point.Builder, PointOrBuilder> loBuilder_; + /** + * optional .routeguide.Point lo = 1; + * + *
+     * One corner of the rectangle.
+     * 
+ */ + public boolean hasLo() { + return loBuilder_ != null || lo_ != null; + } + /** + * optional .routeguide.Point lo = 1; + * + *
+     * One corner of the rectangle.
+     * 
+ */ + public Point getLo() { + if (loBuilder_ == null) { + return lo_ == null ? Point.getDefaultInstance() : lo_; + } else { + return loBuilder_.getMessage(); + } + } + /** + * optional .routeguide.Point lo = 1; + * + *
+     * One corner of the rectangle.
+     * 
+ */ + public Builder setLo(Point value) { + if (loBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + lo_ = value; + onChanged(); + } else { + loBuilder_.setMessage(value); + } + + return this; + } + /** + * optional .routeguide.Point lo = 1; + * + *
+     * One corner of the rectangle.
+     * 
+ */ + public Builder setLo( + Point.Builder builderForValue) { + if (loBuilder_ == null) { + lo_ = builderForValue.build(); + onChanged(); + } else { + loBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * optional .routeguide.Point lo = 1; + * + *
+     * One corner of the rectangle.
+     * 
+ */ + public Builder mergeLo(Point value) { + if (loBuilder_ == null) { + if (lo_ != null) { + lo_ = + Point.newBuilder(lo_).mergeFrom(value).buildPartial(); + } else { + lo_ = value; + } + onChanged(); + } else { + loBuilder_.mergeFrom(value); + } + + return this; + } + /** + * optional .routeguide.Point lo = 1; + * + *
+     * One corner of the rectangle.
+     * 
+ */ + public Builder clearLo() { + if (loBuilder_ == null) { + lo_ = null; + onChanged(); + } else { + lo_ = null; + loBuilder_ = null; + } + + return this; + } + /** + * optional .routeguide.Point lo = 1; + * + *
+     * One corner of the rectangle.
+     * 
+ */ + public Point.Builder getLoBuilder() { + + onChanged(); + return getLoFieldBuilder().getBuilder(); + } + /** + * optional .routeguide.Point lo = 1; + * + *
+     * One corner of the rectangle.
+     * 
+ */ + public PointOrBuilder getLoOrBuilder() { + if (loBuilder_ != null) { + return loBuilder_.getMessageOrBuilder(); + } else { + return lo_ == null ? + Point.getDefaultInstance() : lo_; + } + } + /** + * optional .routeguide.Point lo = 1; + * + *
+     * One corner of the rectangle.
+     * 
+ */ + private com.google.protobuf.SingleFieldBuilder< + Point, Point.Builder, PointOrBuilder> + getLoFieldBuilder() { + if (loBuilder_ == null) { + loBuilder_ = new com.google.protobuf.SingleFieldBuilder< + Point, Point.Builder, PointOrBuilder>( + getLo(), + getParentForChildren(), + isClean()); + lo_ = null; + } + return loBuilder_; + } + + private Point hi_ = null; + private com.google.protobuf.SingleFieldBuilder< + Point, Point.Builder, PointOrBuilder> hiBuilder_; + /** + * optional .routeguide.Point hi = 2; + * + *
+     * The other corner of the rectangle.
+     * 
+ */ + public boolean hasHi() { + return hiBuilder_ != null || hi_ != null; + } + /** + * optional .routeguide.Point hi = 2; + * + *
+     * The other corner of the rectangle.
+     * 
+ */ + public Point getHi() { + if (hiBuilder_ == null) { + return hi_ == null ? Point.getDefaultInstance() : hi_; + } else { + return hiBuilder_.getMessage(); + } + } + /** + * optional .routeguide.Point hi = 2; + * + *
+     * The other corner of the rectangle.
+     * 
+ */ + public Builder setHi(Point value) { + if (hiBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + hi_ = value; + onChanged(); + } else { + hiBuilder_.setMessage(value); + } + + return this; + } + /** + * optional .routeguide.Point hi = 2; + * + *
+     * The other corner of the rectangle.
+     * 
+ */ + public Builder setHi( + Point.Builder builderForValue) { + if (hiBuilder_ == null) { + hi_ = builderForValue.build(); + onChanged(); + } else { + hiBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * optional .routeguide.Point hi = 2; + * + *
+     * The other corner of the rectangle.
+     * 
+ */ + public Builder mergeHi(Point value) { + if (hiBuilder_ == null) { + if (hi_ != null) { + hi_ = + Point.newBuilder(hi_).mergeFrom(value).buildPartial(); + } else { + hi_ = value; + } + onChanged(); + } else { + hiBuilder_.mergeFrom(value); + } + + return this; + } + /** + * optional .routeguide.Point hi = 2; + * + *
+     * The other corner of the rectangle.
+     * 
+ */ + public Builder clearHi() { + if (hiBuilder_ == null) { + hi_ = null; + onChanged(); + } else { + hi_ = null; + hiBuilder_ = null; + } + + return this; + } + /** + * optional .routeguide.Point hi = 2; + * + *
+     * The other corner of the rectangle.
+     * 
+ */ + public Point.Builder getHiBuilder() { + + onChanged(); + return getHiFieldBuilder().getBuilder(); + } + /** + * optional .routeguide.Point hi = 2; + * + *
+     * The other corner of the rectangle.
+     * 
+ */ + public PointOrBuilder getHiOrBuilder() { + if (hiBuilder_ != null) { + return hiBuilder_.getMessageOrBuilder(); + } else { + return hi_ == null ? + Point.getDefaultInstance() : hi_; + } + } + /** + * optional .routeguide.Point hi = 2; + * + *
+     * The other corner of the rectangle.
+     * 
+ */ + private com.google.protobuf.SingleFieldBuilder< + Point, Point.Builder, PointOrBuilder> + getHiFieldBuilder() { + if (hiBuilder_ == null) { + hiBuilder_ = new com.google.protobuf.SingleFieldBuilder< + Point, Point.Builder, PointOrBuilder>( + getHi(), + getParentForChildren(), + isClean()); + hi_ = null; + } + return hiBuilder_; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:routeguide.Rectangle) + } + + // @@protoc_insertion_point(class_scope:routeguide.Rectangle) + private static final Rectangle DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new Rectangle(); + } + + public static Rectangle getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public Rectangle parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new Rectangle(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public Rectangle getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/RectangleOrBuilder.java b/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/RectangleOrBuilder.java new file mode 100755 index 0000000..c6455ca --- /dev/null +++ b/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/RectangleOrBuilder.java @@ -0,0 +1,59 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: route_guide.proto + +package io.grpc.examples.routeguide; + +public interface RectangleOrBuilder extends + // @@protoc_insertion_point(interface_extends:routeguide.Rectangle) + com.google.protobuf.MessageOrBuilder { + + /** + * optional .routeguide.Point lo = 1; + * + *
+   * One corner of the rectangle.
+   * 
+ */ + boolean hasLo(); + /** + * optional .routeguide.Point lo = 1; + * + *
+   * One corner of the rectangle.
+   * 
+ */ + Point getLo(); + /** + * optional .routeguide.Point lo = 1; + * + *
+   * One corner of the rectangle.
+   * 
+ */ + PointOrBuilder getLoOrBuilder(); + + /** + * optional .routeguide.Point hi = 2; + * + *
+   * The other corner of the rectangle.
+   * 
+ */ + boolean hasHi(); + /** + * optional .routeguide.Point hi = 2; + * + *
+   * The other corner of the rectangle.
+   * 
+ */ + Point getHi(); + /** + * optional .routeguide.Point hi = 2; + * + *
+   * The other corner of the rectangle.
+   * 
+ */ + PointOrBuilder getHiOrBuilder(); +} diff --git a/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/RouteGuideGrpc.java b/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/RouteGuideGrpc.java new file mode 100644 index 0000000..5a8e0a4 --- /dev/null +++ b/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/RouteGuideGrpc.java @@ -0,0 +1,412 @@ +package io.grpc.examples.routeguide; + +import static io.grpc.stub.ClientCalls.asyncUnaryCall; +import static io.grpc.stub.ClientCalls.asyncServerStreamingCall; +import static io.grpc.stub.ClientCalls.asyncClientStreamingCall; +import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ClientCalls.blockingUnaryCall; +import static io.grpc.stub.ClientCalls.blockingServerStreamingCall; +import static io.grpc.stub.ClientCalls.futureUnaryCall; +import static io.grpc.MethodDescriptor.generateFullMethodName; +import static io.grpc.stub.ServerCalls.asyncUnaryCall; +import static io.grpc.stub.ServerCalls.asyncServerStreamingCall; +import static io.grpc.stub.ServerCalls.asyncClientStreamingCall; +import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall; +import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall; + +/** + *
+ * Interface exported by the server.
+ * 
+ */ +@javax.annotation.Generated( + value = "by gRPC proto compiler (version 0.14.2-SNAPSHOT)", + comments = "Source: route_guide.proto") +public class RouteGuideGrpc { + + private RouteGuideGrpc() {} + + public static final String SERVICE_NAME = "routeguide.RouteGuide"; + + // Static method descriptors that strictly reflect the proto. + @io.grpc.ExperimentalApi + public static final io.grpc.MethodDescriptor METHOD_GET_FEATURE = + io.grpc.MethodDescriptor.create( + io.grpc.MethodDescriptor.MethodType.UNARY, + generateFullMethodName( + "routeguide.RouteGuide", "GetFeature"), + io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.examples.routeguide.Point.getDefaultInstance()), + io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.examples.routeguide.Feature.getDefaultInstance())); + @io.grpc.ExperimentalApi + public static final io.grpc.MethodDescriptor METHOD_LIST_FEATURES = + io.grpc.MethodDescriptor.create( + io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING, + generateFullMethodName( + "routeguide.RouteGuide", "ListFeatures"), + io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.examples.routeguide.Rectangle.getDefaultInstance()), + io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.examples.routeguide.Feature.getDefaultInstance())); + @io.grpc.ExperimentalApi + public static final io.grpc.MethodDescriptor METHOD_RECORD_ROUTE = + io.grpc.MethodDescriptor.create( + io.grpc.MethodDescriptor.MethodType.CLIENT_STREAMING, + generateFullMethodName( + "routeguide.RouteGuide", "RecordRoute"), + io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.examples.routeguide.Point.getDefaultInstance()), + io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.examples.routeguide.RouteSummary.getDefaultInstance())); + @io.grpc.ExperimentalApi + public static final io.grpc.MethodDescriptor METHOD_ROUTE_CHAT = + io.grpc.MethodDescriptor.create( + io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING, + generateFullMethodName( + "routeguide.RouteGuide", "RouteChat"), + io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.examples.routeguide.RouteNote.getDefaultInstance()), + io.grpc.protobuf.ProtoUtils.marshaller(io.grpc.examples.routeguide.RouteNote.getDefaultInstance())); + + /** + * Creates a new async stub that supports all call types for the service + */ + public static RouteGuideStub newStub(io.grpc.Channel channel) { + return new RouteGuideStub(channel); + } + + /** + * Creates a new blocking-style stub that supports unary and streaming output calls on the service + */ + public static RouteGuideBlockingStub newBlockingStub( + io.grpc.Channel channel) { + return new RouteGuideBlockingStub(channel); + } + + /** + * Creates a new ListenableFuture-style stub that supports unary and streaming output calls on the service + */ + public static RouteGuideFutureStub newFutureStub( + io.grpc.Channel channel) { + return new RouteGuideFutureStub(channel); + } + + /** + *
+     * Interface exported by the server.
+     * 
+ */ + public static interface RouteGuide { + + /** + *
+         * A simple RPC.
+         * Obtains the feature at a given position.
+         * A feature with an empty name is returned if there's no feature at the given
+         * position.
+         * 
+ */ + public void getFeature(io.grpc.examples.routeguide.Point request, + io.grpc.stub.StreamObserver responseObserver); + + /** + *
+         * A server-to-client streaming RPC.
+         * Obtains the Features available within the given Rectangle.  Results are
+         * streamed rather than returned at once (e.g. in a response message with a
+         * repeated field), as the rectangle may cover a large area and contain a
+         * huge number of features.
+         * 
+ */ + public void listFeatures(io.grpc.examples.routeguide.Rectangle request, + io.grpc.stub.StreamObserver responseObserver); + + /** + *
+         * A client-to-server streaming RPC.
+         * Accepts a stream of Points on a route being traversed, returning a
+         * RouteSummary when traversal is completed.
+         * 
+ */ + public io.grpc.stub.StreamObserver recordRoute( + io.grpc.stub.StreamObserver responseObserver); + + /** + *
+         * A Bidirectional streaming RPC.
+         * Accepts a stream of RouteNotes sent while a route is being traversed,
+         * while receiving other RouteNotes (e.g. from other users).
+         * 
+ */ + public io.grpc.stub.StreamObserver routeChat( + io.grpc.stub.StreamObserver responseObserver); + } + + @io.grpc.ExperimentalApi + public static abstract class AbstractRouteGuide implements RouteGuide, io.grpc.BindableService { + + @java.lang.Override + public void getFeature(io.grpc.examples.routeguide.Point request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(METHOD_GET_FEATURE, responseObserver); + } + + @java.lang.Override + public void listFeatures(io.grpc.examples.routeguide.Rectangle request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnimplementedUnaryCall(METHOD_LIST_FEATURES, responseObserver); + } + + @java.lang.Override + public io.grpc.stub.StreamObserver recordRoute( + io.grpc.stub.StreamObserver responseObserver) { + return asyncUnimplementedStreamingCall(METHOD_RECORD_ROUTE, responseObserver); + } + + @java.lang.Override + public io.grpc.stub.StreamObserver routeChat( + io.grpc.stub.StreamObserver responseObserver) { + return asyncUnimplementedStreamingCall(METHOD_ROUTE_CHAT, responseObserver); + } + + @java.lang.Override public io.grpc.ServerServiceDefinition bindService() { + return RouteGuideGrpc.bindService(this); + } + } + + /** + *
+     * Interface exported by the server.
+     * 
+ */ + public static interface RouteGuideBlockingClient { + + /** + *
+         * A simple RPC.
+         * Obtains the feature at a given position.
+         * A feature with an empty name is returned if there's no feature at the given
+         * position.
+         * 
+ */ + public io.grpc.examples.routeguide.Feature getFeature(io.grpc.examples.routeguide.Point request); + + /** + *
+         * A server-to-client streaming RPC.
+         * Obtains the Features available within the given Rectangle.  Results are
+         * streamed rather than returned at once (e.g. in a response message with a
+         * repeated field), as the rectangle may cover a large area and contain a
+         * huge number of features.
+         * 
+ */ + public java.util.Iterator listFeatures( + io.grpc.examples.routeguide.Rectangle request); + } + + /** + *
+     * Interface exported by the server.
+     * 
+ */ + public static interface RouteGuideFutureClient { + + /** + *
+         * A simple RPC.
+         * Obtains the feature at a given position.
+         * A feature with an empty name is returned if there's no feature at the given
+         * position.
+         * 
+ */ + public com.google.common.util.concurrent.ListenableFuture getFeature( + io.grpc.examples.routeguide.Point request); + } + + public static class RouteGuideStub extends io.grpc.stub.AbstractStub + implements RouteGuide { + private RouteGuideStub(io.grpc.Channel channel) { + super(channel); + } + + private RouteGuideStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected RouteGuideStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new RouteGuideStub(channel, callOptions); + } + + @java.lang.Override + public void getFeature(io.grpc.examples.routeguide.Point request, + io.grpc.stub.StreamObserver responseObserver) { + asyncUnaryCall( + getChannel().newCall(METHOD_GET_FEATURE, getCallOptions()), request, responseObserver); + } + + @java.lang.Override + public void listFeatures(io.grpc.examples.routeguide.Rectangle request, + io.grpc.stub.StreamObserver responseObserver) { + asyncServerStreamingCall( + getChannel().newCall(METHOD_LIST_FEATURES, getCallOptions()), request, responseObserver); + } + + @java.lang.Override + public io.grpc.stub.StreamObserver recordRoute( + io.grpc.stub.StreamObserver responseObserver) { + return asyncClientStreamingCall( + getChannel().newCall(METHOD_RECORD_ROUTE, getCallOptions()), responseObserver); + } + + @java.lang.Override + public io.grpc.stub.StreamObserver routeChat( + io.grpc.stub.StreamObserver responseObserver) { + return asyncBidiStreamingCall( + getChannel().newCall(METHOD_ROUTE_CHAT, getCallOptions()), responseObserver); + } + } + + public static class RouteGuideBlockingStub extends io.grpc.stub.AbstractStub + implements RouteGuideBlockingClient { + private RouteGuideBlockingStub(io.grpc.Channel channel) { + super(channel); + } + + private RouteGuideBlockingStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected RouteGuideBlockingStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new RouteGuideBlockingStub(channel, callOptions); + } + + @java.lang.Override + public io.grpc.examples.routeguide.Feature getFeature(io.grpc.examples.routeguide.Point request) { + return blockingUnaryCall( + getChannel(), METHOD_GET_FEATURE, getCallOptions(), request); + } + + @java.lang.Override + public java.util.Iterator listFeatures( + io.grpc.examples.routeguide.Rectangle request) { + return blockingServerStreamingCall( + getChannel(), METHOD_LIST_FEATURES, getCallOptions(), request); + } + } + + public static class RouteGuideFutureStub extends io.grpc.stub.AbstractStub + implements RouteGuideFutureClient { + private RouteGuideFutureStub(io.grpc.Channel channel) { + super(channel); + } + + private RouteGuideFutureStub(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected RouteGuideFutureStub build(io.grpc.Channel channel, + io.grpc.CallOptions callOptions) { + return new RouteGuideFutureStub(channel, callOptions); + } + + @java.lang.Override + public com.google.common.util.concurrent.ListenableFuture getFeature( + io.grpc.examples.routeguide.Point request) { + return futureUnaryCall( + getChannel().newCall(METHOD_GET_FEATURE, getCallOptions()), request); + } + } + + private static final int METHODID_GET_FEATURE = 0; + private static final int METHODID_LIST_FEATURES = 1; + private static final int METHODID_RECORD_ROUTE = 2; + private static final int METHODID_ROUTE_CHAT = 3; + + private static 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 RouteGuide serviceImpl; + private final int methodId; + + public MethodHandlers(RouteGuide 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_GET_FEATURE: + serviceImpl.getFeature((io.grpc.examples.routeguide.Point) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_LIST_FEATURES: + serviceImpl.listFeatures((io.grpc.examples.routeguide.Rectangle) 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) { + case METHODID_RECORD_ROUTE: + return (io.grpc.stub.StreamObserver) serviceImpl.recordRoute( + (io.grpc.stub.StreamObserver) responseObserver); + case METHODID_ROUTE_CHAT: + return (io.grpc.stub.StreamObserver) serviceImpl.routeChat( + (io.grpc.stub.StreamObserver) responseObserver); + default: + throw new AssertionError(); + } + } + } + + public static io.grpc.ServerServiceDefinition bindService( + final RouteGuide serviceImpl) { + return io.grpc.ServerServiceDefinition.builder(SERVICE_NAME) + .addMethod( + METHOD_GET_FEATURE, + asyncUnaryCall( + new MethodHandlers< + io.grpc.examples.routeguide.Point, + io.grpc.examples.routeguide.Feature>( + serviceImpl, METHODID_GET_FEATURE))) + .addMethod( + METHOD_LIST_FEATURES, + asyncServerStreamingCall( + new MethodHandlers< + io.grpc.examples.routeguide.Rectangle, + io.grpc.examples.routeguide.Feature>( + serviceImpl, METHODID_LIST_FEATURES))) + .addMethod( + METHOD_RECORD_ROUTE, + asyncClientStreamingCall( + new MethodHandlers< + io.grpc.examples.routeguide.Point, + io.grpc.examples.routeguide.RouteSummary>( + serviceImpl, METHODID_RECORD_ROUTE))) + .addMethod( + METHOD_ROUTE_CHAT, + asyncBidiStreamingCall( + new MethodHandlers< + io.grpc.examples.routeguide.RouteNote, + io.grpc.examples.routeguide.RouteNote>( + serviceImpl, METHODID_ROUTE_CHAT))) + .build(); + } +} \ No newline at end of file diff --git a/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/RouteGuideProto.java b/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/RouteGuideProto.java new file mode 100755 index 0000000..542215b --- /dev/null +++ b/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/RouteGuideProto.java @@ -0,0 +1,122 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: route_guide.proto + +package io.grpc.examples.routeguide; + +public final class RouteGuideProto { + private RouteGuideProto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + static com.google.protobuf.Descriptors.Descriptor + internal_static_routeguide_Point_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_routeguide_Point_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_routeguide_Rectangle_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_routeguide_Rectangle_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_routeguide_Feature_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_routeguide_Feature_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_routeguide_FeatureDatabase_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_routeguide_FeatureDatabase_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_routeguide_RouteNote_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_routeguide_RouteNote_fieldAccessorTable; + static com.google.protobuf.Descriptors.Descriptor + internal_static_routeguide_RouteSummary_descriptor; + static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_routeguide_RouteSummary_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + String[] descriptorData = { + "\n\021route_guide.proto\022\nrouteguide\",\n\005Point" + + "\022\020\n\010latitude\030\001 \001(\005\022\021\n\tlongitude\030\002 \001(\005\"I\n" + + "\tRectangle\022\035\n\002lo\030\001 \001(\0132\021.routeguide.Poin" + + "t\022\035\n\002hi\030\002 \001(\0132\021.routeguide.Point\"<\n\007Feat" + + "ure\022\014\n\004name\030\001 \001(\t\022#\n\010location\030\002 \001(\0132\021.ro" + + "uteguide.Point\"7\n\017FeatureDatabase\022$\n\007fea" + + "ture\030\001 \003(\0132\023.routeguide.Feature\"A\n\tRoute" + + "Note\022#\n\010location\030\001 \001(\0132\021.routeguide.Poin" + + "t\022\017\n\007message\030\002 \001(\t\"b\n\014RouteSummary\022\023\n\013po" + + "int_count\030\001 \001(\005\022\025\n\rfeature_count\030\002 \001(\005\022\020", + "\n\010distance\030\003 \001(\005\022\024\n\014elapsed_time\030\004 \001(\0052\205" + + "\002\n\nRouteGuide\0226\n\nGetFeature\022\021.routeguide" + + ".Point\032\023.routeguide.Feature\"\000\022>\n\014ListFea" + + "tures\022\025.routeguide.Rectangle\032\023.routeguid" + + "e.Feature\"\0000\001\022>\n\013RecordRoute\022\021.routeguid" + + "e.Point\032\030.routeguide.RouteSummary\"\000(\001\022?\n" + + "\tRouteChat\022\025.routeguide.RouteNote\032\025.rout" + + "eguide.RouteNote\"\000(\0010\001B6\n\033io.grpc.exampl" + + "es.routeguideB\017RouteGuideProtoP\001\242\002\003RTGb\006" + + "proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + internal_static_routeguide_Point_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_routeguide_Point_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_routeguide_Point_descriptor, + new String[] { "Latitude", "Longitude", }); + internal_static_routeguide_Rectangle_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_routeguide_Rectangle_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_routeguide_Rectangle_descriptor, + new String[] { "Lo", "Hi", }); + internal_static_routeguide_Feature_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_routeguide_Feature_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_routeguide_Feature_descriptor, + new String[] { "Name", "Location", }); + internal_static_routeguide_FeatureDatabase_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_routeguide_FeatureDatabase_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_routeguide_FeatureDatabase_descriptor, + new String[] { "Feature", }); + internal_static_routeguide_RouteNote_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_routeguide_RouteNote_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_routeguide_RouteNote_descriptor, + new String[] { "Location", "Message", }); + internal_static_routeguide_RouteSummary_descriptor = + getDescriptor().getMessageTypes().get(5); + internal_static_routeguide_RouteSummary_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_routeguide_RouteSummary_descriptor, + new String[] { "PointCount", "FeatureCount", "Distance", "ElapsedTime", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/RouteNote.java b/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/RouteNote.java new file mode 100755 index 0000000..9b7ffe9 --- /dev/null +++ b/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/RouteNote.java @@ -0,0 +1,696 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: route_guide.proto + +package io.grpc.examples.routeguide; + +/** + * Protobuf type {@code routeguide.RouteNote} + * + *
+ * A RouteNote is a message sent while at a given point.
+ * 
+ */ +public final class RouteNote extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:routeguide.RouteNote) + RouteNoteOrBuilder { + // Use RouteNote.newBuilder() to construct. + private RouteNote(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private RouteNote() { + message_ = ""; + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private RouteNote( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + Point.Builder subBuilder = null; + if (location_ != null) { + subBuilder = location_.toBuilder(); + } + location_ = input.readMessage(Point.parser(), extensionRegistry); + if (subBuilder != null) { + subBuilder.mergeFrom(location_); + location_ = subBuilder.buildPartial(); + } + + break; + } + case 18: { + String s = input.readStringRequireUtf8(); + + message_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return RouteGuideProto.internal_static_routeguide_RouteNote_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return RouteGuideProto.internal_static_routeguide_RouteNote_fieldAccessorTable + .ensureFieldAccessorsInitialized( + RouteNote.class, Builder.class); + } + + public static final int LOCATION_FIELD_NUMBER = 1; + private Point location_; + /** + * optional .routeguide.Point location = 1; + * + *
+   * The location from which the message is sent.
+   * 
+ */ + public boolean hasLocation() { + return location_ != null; + } + /** + * optional .routeguide.Point location = 1; + * + *
+   * The location from which the message is sent.
+   * 
+ */ + public Point getLocation() { + return location_ == null ? Point.getDefaultInstance() : location_; + } + /** + * optional .routeguide.Point location = 1; + * + *
+   * The location from which the message is sent.
+   * 
+ */ + public PointOrBuilder getLocationOrBuilder() { + return getLocation(); + } + + public static final int MESSAGE_FIELD_NUMBER = 2; + private volatile Object message_; + /** + * optional string message = 2; + * + *
+   * The message to be sent.
+   * 
+ */ + public String getMessage() { + Object ref = message_; + if (ref instanceof String) { + return (String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + message_ = s; + return s; + } + } + /** + * optional string message = 2; + * + *
+   * The message to be sent.
+   * 
+ */ + public com.google.protobuf.ByteString + getMessageBytes() { + Object ref = message_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + message_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (location_ != null) { + output.writeMessage(1, getLocation()); + } + if (!getMessageBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, message_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (location_ != null) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, getLocation()); + } + if (!getMessageBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, message_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static RouteNote parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static RouteNote parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static RouteNote parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static RouteNote parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static RouteNote parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static RouteNote parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static RouteNote parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static RouteNote parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static RouteNote parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static RouteNote parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(RouteNote prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code routeguide.RouteNote} + * + *
+   * A RouteNote is a message sent while at a given point.
+   * 
+ */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:routeguide.RouteNote) + io.grpc.examples.routeguide.RouteNoteOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return RouteGuideProto.internal_static_routeguide_RouteNote_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return RouteGuideProto.internal_static_routeguide_RouteNote_fieldAccessorTable + .ensureFieldAccessorsInitialized( + RouteNote.class, Builder.class); + } + + // Construct using io.grpc.examples.routeguide.RouteNote.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + if (locationBuilder_ == null) { + location_ = null; + } else { + location_ = null; + locationBuilder_ = null; + } + message_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return RouteGuideProto.internal_static_routeguide_RouteNote_descriptor; + } + + public RouteNote getDefaultInstanceForType() { + return RouteNote.getDefaultInstance(); + } + + public RouteNote build() { + RouteNote result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public RouteNote buildPartial() { + RouteNote result = new RouteNote(this); + if (locationBuilder_ == null) { + result.location_ = location_; + } else { + result.location_ = locationBuilder_.build(); + } + result.message_ = message_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof RouteNote) { + return mergeFrom((RouteNote)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(RouteNote other) { + if (other == RouteNote.getDefaultInstance()) return this; + if (other.hasLocation()) { + mergeLocation(other.getLocation()); + } + if (!other.getMessage().isEmpty()) { + message_ = other.message_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + RouteNote parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (RouteNote) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private Point location_ = null; + private com.google.protobuf.SingleFieldBuilder< + Point, Point.Builder, PointOrBuilder> locationBuilder_; + /** + * optional .routeguide.Point location = 1; + * + *
+     * The location from which the message is sent.
+     * 
+ */ + public boolean hasLocation() { + return locationBuilder_ != null || location_ != null; + } + /** + * optional .routeguide.Point location = 1; + * + *
+     * The location from which the message is sent.
+     * 
+ */ + public Point getLocation() { + if (locationBuilder_ == null) { + return location_ == null ? Point.getDefaultInstance() : location_; + } else { + return locationBuilder_.getMessage(); + } + } + /** + * optional .routeguide.Point location = 1; + * + *
+     * The location from which the message is sent.
+     * 
+ */ + public Builder setLocation(Point value) { + if (locationBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + location_ = value; + onChanged(); + } else { + locationBuilder_.setMessage(value); + } + + return this; + } + /** + * optional .routeguide.Point location = 1; + * + *
+     * The location from which the message is sent.
+     * 
+ */ + public Builder setLocation( + Point.Builder builderForValue) { + if (locationBuilder_ == null) { + location_ = builderForValue.build(); + onChanged(); + } else { + locationBuilder_.setMessage(builderForValue.build()); + } + + return this; + } + /** + * optional .routeguide.Point location = 1; + * + *
+     * The location from which the message is sent.
+     * 
+ */ + public Builder mergeLocation(Point value) { + if (locationBuilder_ == null) { + if (location_ != null) { + location_ = + Point.newBuilder(location_).mergeFrom(value).buildPartial(); + } else { + location_ = value; + } + onChanged(); + } else { + locationBuilder_.mergeFrom(value); + } + + return this; + } + /** + * optional .routeguide.Point location = 1; + * + *
+     * The location from which the message is sent.
+     * 
+ */ + public Builder clearLocation() { + if (locationBuilder_ == null) { + location_ = null; + onChanged(); + } else { + location_ = null; + locationBuilder_ = null; + } + + return this; + } + /** + * optional .routeguide.Point location = 1; + * + *
+     * The location from which the message is sent.
+     * 
+ */ + public Point.Builder getLocationBuilder() { + + onChanged(); + return getLocationFieldBuilder().getBuilder(); + } + /** + * optional .routeguide.Point location = 1; + * + *
+     * The location from which the message is sent.
+     * 
+ */ + public PointOrBuilder getLocationOrBuilder() { + if (locationBuilder_ != null) { + return locationBuilder_.getMessageOrBuilder(); + } else { + return location_ == null ? + Point.getDefaultInstance() : location_; + } + } + /** + * optional .routeguide.Point location = 1; + * + *
+     * The location from which the message is sent.
+     * 
+ */ + private com.google.protobuf.SingleFieldBuilder< + Point, Point.Builder, PointOrBuilder> + getLocationFieldBuilder() { + if (locationBuilder_ == null) { + locationBuilder_ = new com.google.protobuf.SingleFieldBuilder< + Point, Point.Builder, PointOrBuilder>( + getLocation(), + getParentForChildren(), + isClean()); + location_ = null; + } + return locationBuilder_; + } + + private Object message_ = ""; + /** + * optional string message = 2; + * + *
+     * The message to be sent.
+     * 
+ */ + public String getMessage() { + Object ref = message_; + if (!(ref instanceof String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + String s = bs.toStringUtf8(); + message_ = s; + return s; + } else { + return (String) ref; + } + } + /** + * optional string message = 2; + * + *
+     * The message to be sent.
+     * 
+ */ + public com.google.protobuf.ByteString + getMessageBytes() { + Object ref = message_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (String) ref); + message_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string message = 2; + * + *
+     * The message to be sent.
+     * 
+ */ + public Builder setMessage( + String value) { + if (value == null) { + throw new NullPointerException(); + } + + message_ = value; + onChanged(); + return this; + } + /** + * optional string message = 2; + * + *
+     * The message to be sent.
+     * 
+ */ + public Builder clearMessage() { + + message_ = getDefaultInstance().getMessage(); + onChanged(); + return this; + } + /** + * optional string message = 2; + * + *
+     * The message to be sent.
+     * 
+ */ + public Builder setMessageBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + message_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:routeguide.RouteNote) + } + + // @@protoc_insertion_point(class_scope:routeguide.RouteNote) + private static final RouteNote DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new RouteNote(); + } + + public static RouteNote getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public RouteNote parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new RouteNote(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public RouteNote getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/RouteNoteOrBuilder.java b/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/RouteNoteOrBuilder.java new file mode 100755 index 0000000..551b195 --- /dev/null +++ b/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/RouteNoteOrBuilder.java @@ -0,0 +1,52 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: route_guide.proto + +package io.grpc.examples.routeguide; + +public interface RouteNoteOrBuilder extends + // @@protoc_insertion_point(interface_extends:routeguide.RouteNote) + com.google.protobuf.MessageOrBuilder { + + /** + * optional .routeguide.Point location = 1; + * + *
+   * The location from which the message is sent.
+   * 
+ */ + boolean hasLocation(); + /** + * optional .routeguide.Point location = 1; + * + *
+   * The location from which the message is sent.
+   * 
+ */ + Point getLocation(); + /** + * optional .routeguide.Point location = 1; + * + *
+   * The location from which the message is sent.
+   * 
+ */ + PointOrBuilder getLocationOrBuilder(); + + /** + * optional string message = 2; + * + *
+   * The message to be sent.
+   * 
+ */ + String getMessage(); + /** + * optional string message = 2; + * + *
+   * The message to be sent.
+   * 
+ */ + com.google.protobuf.ByteString + getMessageBytes(); +} diff --git a/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/RouteSummary.java b/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/RouteSummary.java new file mode 100755 index 0000000..ea58a32 --- /dev/null +++ b/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/RouteSummary.java @@ -0,0 +1,611 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: route_guide.proto + +package io.grpc.examples.routeguide; + +/** + * Protobuf type {@code routeguide.RouteSummary} + * + *
+ * A RouteSummary is received in response to a RecordRoute rpc.
+ * It contains the number of individual points received, the number of
+ * detected features, and the total distance covered as the cumulative sum of
+ * the distance between each point.
+ * 
+ */ +public final class RouteSummary extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:routeguide.RouteSummary) + RouteSummaryOrBuilder { + // Use RouteSummary.newBuilder() to construct. + private RouteSummary(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private RouteSummary() { + pointCount_ = 0; + featureCount_ = 0; + distance_ = 0; + elapsedTime_ = 0; + } + + @Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private RouteSummary( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 8: { + + pointCount_ = input.readInt32(); + break; + } + case 16: { + + featureCount_ = input.readInt32(); + break; + } + case 24: { + + distance_ = input.readInt32(); + break; + } + case 32: { + + elapsedTime_ = input.readInt32(); + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw new RuntimeException(e.setUnfinishedMessage(this)); + } catch (java.io.IOException e) { + throw new RuntimeException( + new com.google.protobuf.InvalidProtocolBufferException( + e.getMessage()).setUnfinishedMessage(this)); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return RouteGuideProto.internal_static_routeguide_RouteSummary_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return RouteGuideProto.internal_static_routeguide_RouteSummary_fieldAccessorTable + .ensureFieldAccessorsInitialized( + RouteSummary.class, Builder.class); + } + + public static final int POINT_COUNT_FIELD_NUMBER = 1; + private int pointCount_; + /** + * optional int32 point_count = 1; + * + *
+   * The number of points received.
+   * 
+ */ + public int getPointCount() { + return pointCount_; + } + + public static final int FEATURE_COUNT_FIELD_NUMBER = 2; + private int featureCount_; + /** + * optional int32 feature_count = 2; + * + *
+   * The number of known features passed while traversing the route.
+   * 
+ */ + public int getFeatureCount() { + return featureCount_; + } + + public static final int DISTANCE_FIELD_NUMBER = 3; + private int distance_; + /** + * optional int32 distance = 3; + * + *
+   * The distance covered in metres.
+   * 
+ */ + public int getDistance() { + return distance_; + } + + public static final int ELAPSED_TIME_FIELD_NUMBER = 4; + private int elapsedTime_; + /** + * optional int32 elapsed_time = 4; + * + *
+   * The duration of the traversal in seconds.
+   * 
+ */ + public int getElapsedTime() { + return elapsedTime_; + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (pointCount_ != 0) { + output.writeInt32(1, pointCount_); + } + if (featureCount_ != 0) { + output.writeInt32(2, featureCount_); + } + if (distance_ != 0) { + output.writeInt32(3, distance_); + } + if (elapsedTime_ != 0) { + output.writeInt32(4, elapsedTime_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (pointCount_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(1, pointCount_); + } + if (featureCount_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(2, featureCount_); + } + if (distance_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(3, distance_); + } + if (elapsedTime_ != 0) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(4, elapsedTime_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static RouteSummary parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static RouteSummary parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static RouteSummary parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static RouteSummary parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static RouteSummary parseFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static RouteSummary parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + public static RouteSummary parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input); + } + public static RouteSummary parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseDelimitedFrom(input, extensionRegistry); + } + public static RouteSummary parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return PARSER.parseFrom(input); + } + public static RouteSummary parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return PARSER.parseFrom(input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(RouteSummary prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @Override + protected Builder newBuilderForType( + BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code routeguide.RouteSummary} + * + *
+   * A RouteSummary is received in response to a RecordRoute rpc.
+   * It contains the number of individual points received, the number of
+   * detected features, and the total distance covered as the cumulative sum of
+   * the distance between each point.
+   * 
+ */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:routeguide.RouteSummary) + io.grpc.examples.routeguide.RouteSummaryOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return RouteGuideProto.internal_static_routeguide_RouteSummary_descriptor; + } + + protected FieldAccessorTable + internalGetFieldAccessorTable() { + return RouteGuideProto.internal_static_routeguide_RouteSummary_fieldAccessorTable + .ensureFieldAccessorsInitialized( + RouteSummary.class, Builder.class); + } + + // Construct using io.grpc.examples.routeguide.RouteSummary.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + pointCount_ = 0; + + featureCount_ = 0; + + distance_ = 0; + + elapsedTime_ = 0; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return RouteGuideProto.internal_static_routeguide_RouteSummary_descriptor; + } + + public RouteSummary getDefaultInstanceForType() { + return RouteSummary.getDefaultInstance(); + } + + public RouteSummary build() { + RouteSummary result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public RouteSummary buildPartial() { + RouteSummary result = new RouteSummary(this); + result.pointCount_ = pointCount_; + result.featureCount_ = featureCount_; + result.distance_ = distance_; + result.elapsedTime_ = elapsedTime_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof RouteSummary) { + return mergeFrom((RouteSummary)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(RouteSummary other) { + if (other == RouteSummary.getDefaultInstance()) return this; + if (other.getPointCount() != 0) { + setPointCount(other.getPointCount()); + } + if (other.getFeatureCount() != 0) { + setFeatureCount(other.getFeatureCount()); + } + if (other.getDistance() != 0) { + setDistance(other.getDistance()); + } + if (other.getElapsedTime() != 0) { + setElapsedTime(other.getElapsedTime()); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + RouteSummary parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (RouteSummary) e.getUnfinishedMessage(); + throw e; + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int pointCount_ ; + /** + * optional int32 point_count = 1; + * + *
+     * The number of points received.
+     * 
+ */ + public int getPointCount() { + return pointCount_; + } + /** + * optional int32 point_count = 1; + * + *
+     * The number of points received.
+     * 
+ */ + public Builder setPointCount(int value) { + + pointCount_ = value; + onChanged(); + return this; + } + /** + * optional int32 point_count = 1; + * + *
+     * The number of points received.
+     * 
+ */ + public Builder clearPointCount() { + + pointCount_ = 0; + onChanged(); + return this; + } + + private int featureCount_ ; + /** + * optional int32 feature_count = 2; + * + *
+     * The number of known features passed while traversing the route.
+     * 
+ */ + public int getFeatureCount() { + return featureCount_; + } + /** + * optional int32 feature_count = 2; + * + *
+     * The number of known features passed while traversing the route.
+     * 
+ */ + public Builder setFeatureCount(int value) { + + featureCount_ = value; + onChanged(); + return this; + } + /** + * optional int32 feature_count = 2; + * + *
+     * The number of known features passed while traversing the route.
+     * 
+ */ + public Builder clearFeatureCount() { + + featureCount_ = 0; + onChanged(); + return this; + } + + private int distance_ ; + /** + * optional int32 distance = 3; + * + *
+     * The distance covered in metres.
+     * 
+ */ + public int getDistance() { + return distance_; + } + /** + * optional int32 distance = 3; + * + *
+     * The distance covered in metres.
+     * 
+ */ + public Builder setDistance(int value) { + + distance_ = value; + onChanged(); + return this; + } + /** + * optional int32 distance = 3; + * + *
+     * The distance covered in metres.
+     * 
+ */ + public Builder clearDistance() { + + distance_ = 0; + onChanged(); + return this; + } + + private int elapsedTime_ ; + /** + * optional int32 elapsed_time = 4; + * + *
+     * The duration of the traversal in seconds.
+     * 
+ */ + public int getElapsedTime() { + return elapsedTime_; + } + /** + * optional int32 elapsed_time = 4; + * + *
+     * The duration of the traversal in seconds.
+     * 
+ */ + public Builder setElapsedTime(int value) { + + elapsedTime_ = value; + onChanged(); + return this; + } + /** + * optional int32 elapsed_time = 4; + * + *
+     * The duration of the traversal in seconds.
+     * 
+ */ + public Builder clearElapsedTime() { + + elapsedTime_ = 0; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:routeguide.RouteSummary) + } + + // @@protoc_insertion_point(class_scope:routeguide.RouteSummary) + private static final RouteSummary DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new RouteSummary(); + } + + public static RouteSummary getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public RouteSummary parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + try { + return new RouteSummary(input, extensionRegistry); + } catch (RuntimeException e) { + if (e.getCause() instanceof + com.google.protobuf.InvalidProtocolBufferException) { + throw (com.google.protobuf.InvalidProtocolBufferException) + e.getCause(); + } + throw e; + } + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public RouteSummary getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/RouteSummaryOrBuilder.java b/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/RouteSummaryOrBuilder.java new file mode 100755 index 0000000..bdffc55 --- /dev/null +++ b/octopus-rpc-core/src/main/java/io/grpc/examples/routeguide/RouteSummaryOrBuilder.java @@ -0,0 +1,45 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: route_guide.proto + +package io.grpc.examples.routeguide; + +public interface RouteSummaryOrBuilder extends + // @@protoc_insertion_point(interface_extends:routeguide.RouteSummary) + com.google.protobuf.MessageOrBuilder { + + /** + * optional int32 point_count = 1; + * + *
+   * The number of points received.
+   * 
+ */ + int getPointCount(); + + /** + * optional int32 feature_count = 2; + * + *
+   * The number of known features passed while traversing the route.
+   * 
+ */ + int getFeatureCount(); + + /** + * optional int32 distance = 3; + * + *
+   * The distance covered in metres.
+   * 
+ */ + int getDistance(); + + /** + * optional int32 elapsed_time = 4; + * + *
+   * The duration of the traversal in seconds.
+   * 
+ */ + int getElapsedTime(); +} diff --git a/octopus-rpc-core/src/main/proto/chat_room.proto b/octopus-rpc-core/src/main/proto/chat_room.proto new file mode 100644 index 0000000..fe6a86c --- /dev/null +++ b/octopus-rpc-core/src/main/proto/chat_room.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; + +option java_multiple_files = false; +option java_package = "com.dingding.domain.chat.chatroom"; +option java_outer_classname = "ChatRoomProto"; +option objc_class_prefix = "CTR"; + +package chat; + +service ChatRoom { + rpc ChatBrocast(stream ChatMessage) returns (stream ChatMessage) {} +} + +message ChatMessage { + string id = 1; + string ip = 2; + uint32 uid = 3; + int32 type = 4; + int64 time = 5; + int32 code = 6; + string message = 7; +} \ No newline at end of file diff --git a/octopus-rpc-core/src/main/proto/helloreply.js b/octopus-rpc-core/src/main/proto/helloreply.js new file mode 100644 index 0000000..86b603c --- /dev/null +++ b/octopus-rpc-core/src/main/proto/helloreply.js @@ -0,0 +1,92 @@ +/** + * @fileoverview + * @enhanceable + * @public + */ +// GENERATED CODE -- DO NOT EDIT! + +goog.provide('proto.helloworld.HelloReply'); + +goog.require('jspb.Message'); + + +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.helloworld.HelloReply = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.helloworld.HelloReply, jspb.Message); +if (goog.DEBUG && !COMPILED) { + proto.helloworld.HelloReply.displayName = 'proto.helloworld.HelloReply'; +} + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto suitable for use in Soy templates. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.helloworld.HelloReply.prototype.toObject = function(opt_includeInstance) { + return proto.helloworld.HelloReply.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.helloworld.HelloReply} msg The msg instance to transform. + * @return {!Object} + */ +proto.helloworld.HelloReply.toObject = function(includeInstance, msg) { + var f, obj = { + message: msg.getMessage() + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Creates a deep clone of this proto. No data is shared with the original. + * @return {!proto.helloworld.HelloReply} The clone. + */ +proto.helloworld.HelloReply.prototype.cloneMessage = function() { + return /** @type {!proto.helloworld.HelloReply} */ (jspb.Message.cloneMessage(this)); +}; + + +/** + * optional string message = 1; + * @return {string} + */ +proto.helloworld.HelloReply.prototype.getMessage = function() { + return /** @type {string} */ (jspb.Message.getFieldProto3(this, 1, "")); +}; + + +/** @param {string} value */ +proto.helloworld.HelloReply.prototype.setMessage = function(value) { + jspb.Message.setField(this, 1, value); +}; + + diff --git a/octopus-rpc-core/src/main/proto/hellorequest.js b/octopus-rpc-core/src/main/proto/hellorequest.js new file mode 100644 index 0000000..995c99b --- /dev/null +++ b/octopus-rpc-core/src/main/proto/hellorequest.js @@ -0,0 +1,92 @@ +/** + * @fileoverview + * @enhanceable + * @public + */ +// GENERATED CODE -- DO NOT EDIT! + +goog.provide('proto.helloworld.HelloRequest'); + +goog.require('jspb.Message'); + + +/** + * Generated by JsPbCodeGenerator. + * @param {Array=} opt_data Optional initial data array, typically from a + * server response, or constructed directly in Javascript. The array is used + * in place and becomes part of the constructed object. It is not cloned. + * If no data is provided, the constructed object will be empty, but still + * valid. + * @extends {jspb.Message} + * @constructor + */ +proto.helloworld.HelloRequest = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.helloworld.HelloRequest, jspb.Message); +if (goog.DEBUG && !COMPILED) { + proto.helloworld.HelloRequest.displayName = 'proto.helloworld.HelloRequest'; +} + + +if (jspb.Message.GENERATE_TO_OBJECT) { +/** + * Creates an object representation of this proto suitable for use in Soy templates. + * Field names that are reserved in JavaScript and will be renamed to pb_name. + * To access a reserved field use, foo.pb_, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.helloworld.HelloRequest.prototype.toObject = function(opt_includeInstance) { + return proto.helloworld.HelloRequest.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.helloworld.HelloRequest} msg The msg instance to transform. + * @return {!Object} + */ +proto.helloworld.HelloRequest.toObject = function(includeInstance, msg) { + var f, obj = { + name: msg.getName() + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Creates a deep clone of this proto. No data is shared with the original. + * @return {!proto.helloworld.HelloRequest} The clone. + */ +proto.helloworld.HelloRequest.prototype.cloneMessage = function() { + return /** @type {!proto.helloworld.HelloRequest} */ (jspb.Message.cloneMessage(this)); +}; + + +/** + * optional string name = 1; + * @return {string} + */ +proto.helloworld.HelloRequest.prototype.getName = function() { + return /** @type {string} */ (jspb.Message.getFieldProto3(this, 1, "")); +}; + + +/** @param {string} value */ +proto.helloworld.HelloRequest.prototype.setName = function(value) { + jspb.Message.setField(this, 1, value); +}; + + diff --git a/octopus-rpc-core/src/main/proto/helloworld.proto b/octopus-rpc-core/src/main/proto/helloworld.proto new file mode 100644 index 0000000..a35276e --- /dev/null +++ b/octopus-rpc-core/src/main/proto/helloworld.proto @@ -0,0 +1,53 @@ +// Copyright 2015, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +syntax = "proto3"; + +option java_multiple_files = true; +option java_package = "io.grpc.examples.helloworld"; +option java_outer_classname = "HelloWorldProto"; +option objc_class_prefix = "HLW"; + +package helloworld; + +// The greeting service definition. +service Greeter { + // Sends a greeting + rpc SayHello (HelloRequest) returns (HelloReply) {} +} + +// The request message containing the user's name. +message HelloRequest { + string name = 1; +} + +// The response message containing the greetings +message HelloReply { + string message = 1; +} \ No newline at end of file diff --git a/octopus-rpc-core/src/main/proto/io/grpc/examples/helloworld/HelloReply.java b/octopus-rpc-core/src/main/proto/io/grpc/examples/helloworld/HelloReply.java new file mode 100644 index 0000000..c45f263 --- /dev/null +++ b/octopus-rpc-core/src/main/proto/io/grpc/examples/helloworld/HelloReply.java @@ -0,0 +1,445 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: helloworld.proto + +package io.grpc.examples.helloworld; + +/** + *
+ * The response message containing the greetings
+ * 
+ * + * Protobuf type {@code helloworld.HelloReply} + */ +public final class HelloReply extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:helloworld.HelloReply) + HelloReplyOrBuilder { + // Use HelloReply.newBuilder() to construct. + private HelloReply(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private HelloReply() { + message_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private HelloReply( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + message_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.grpc.examples.helloworld.HelloWorldProto.internal_static_helloworld_HelloReply_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.grpc.examples.helloworld.HelloWorldProto.internal_static_helloworld_HelloReply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.grpc.examples.helloworld.HelloReply.class, io.grpc.examples.helloworld.HelloReply.Builder.class); + } + + public static final int MESSAGE_FIELD_NUMBER = 1; + private volatile java.lang.Object message_; + /** + * optional string message = 1; + */ + public java.lang.String getMessage() { + java.lang.Object ref = message_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + message_ = s; + return s; + } + } + /** + * optional string message = 1; + */ + public com.google.protobuf.ByteString + getMessageBytes() { + java.lang.Object ref = message_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + message_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getMessageBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, message_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getMessageBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, message_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static io.grpc.examples.helloworld.HelloReply parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.grpc.examples.helloworld.HelloReply parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.grpc.examples.helloworld.HelloReply parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.grpc.examples.helloworld.HelloReply parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.grpc.examples.helloworld.HelloReply parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + public static io.grpc.examples.helloworld.HelloReply parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static io.grpc.examples.helloworld.HelloReply parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input); + } + public static io.grpc.examples.helloworld.HelloReply parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static io.grpc.examples.helloworld.HelloReply parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + public static io.grpc.examples.helloworld.HelloReply parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(io.grpc.examples.helloworld.HelloReply prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+   * The response message containing the greetings
+   * 
+ * + * Protobuf type {@code helloworld.HelloReply} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:helloworld.HelloReply) + io.grpc.examples.helloworld.HelloReplyOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.grpc.examples.helloworld.HelloWorldProto.internal_static_helloworld_HelloReply_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.grpc.examples.helloworld.HelloWorldProto.internal_static_helloworld_HelloReply_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.grpc.examples.helloworld.HelloReply.class, io.grpc.examples.helloworld.HelloReply.Builder.class); + } + + // Construct using io.grpc.examples.helloworld.HelloReply.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + message_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return io.grpc.examples.helloworld.HelloWorldProto.internal_static_helloworld_HelloReply_descriptor; + } + + public io.grpc.examples.helloworld.HelloReply getDefaultInstanceForType() { + return io.grpc.examples.helloworld.HelloReply.getDefaultInstance(); + } + + public io.grpc.examples.helloworld.HelloReply build() { + io.grpc.examples.helloworld.HelloReply result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public io.grpc.examples.helloworld.HelloReply buildPartial() { + io.grpc.examples.helloworld.HelloReply result = new io.grpc.examples.helloworld.HelloReply(this); + result.message_ = message_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof io.grpc.examples.helloworld.HelloReply) { + return mergeFrom((io.grpc.examples.helloworld.HelloReply)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(io.grpc.examples.helloworld.HelloReply other) { + if (other == io.grpc.examples.helloworld.HelloReply.getDefaultInstance()) return this; + if (!other.getMessage().isEmpty()) { + message_ = other.message_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + io.grpc.examples.helloworld.HelloReply parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (io.grpc.examples.helloworld.HelloReply) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object message_ = ""; + /** + * optional string message = 1; + */ + public java.lang.String getMessage() { + java.lang.Object ref = message_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + message_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string message = 1; + */ + public com.google.protobuf.ByteString + getMessageBytes() { + java.lang.Object ref = message_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + message_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string message = 1; + */ + public Builder setMessage( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + message_ = value; + onChanged(); + return this; + } + /** + * optional string message = 1; + */ + public Builder clearMessage() { + + message_ = getDefaultInstance().getMessage(); + onChanged(); + return this; + } + /** + * optional string message = 1; + */ + public Builder setMessageBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + message_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:helloworld.HelloReply) + } + + // @@protoc_insertion_point(class_scope:helloworld.HelloReply) + private static final io.grpc.examples.helloworld.HelloReply DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new io.grpc.examples.helloworld.HelloReply(); + } + + public static io.grpc.examples.helloworld.HelloReply getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public HelloReply parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new HelloReply(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public io.grpc.examples.helloworld.HelloReply getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/octopus-rpc-core/src/main/proto/io/grpc/examples/helloworld/HelloReplyOrBuilder.java b/octopus-rpc-core/src/main/proto/io/grpc/examples/helloworld/HelloReplyOrBuilder.java new file mode 100644 index 0000000..c5313e2 --- /dev/null +++ b/octopus-rpc-core/src/main/proto/io/grpc/examples/helloworld/HelloReplyOrBuilder.java @@ -0,0 +1,19 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: helloworld.proto + +package io.grpc.examples.helloworld; + +public interface HelloReplyOrBuilder extends + // @@protoc_insertion_point(interface_extends:helloworld.HelloReply) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string message = 1; + */ + java.lang.String getMessage(); + /** + * optional string message = 1; + */ + com.google.protobuf.ByteString + getMessageBytes(); +} diff --git a/octopus-rpc-core/src/main/proto/io/grpc/examples/helloworld/HelloRequest.java b/octopus-rpc-core/src/main/proto/io/grpc/examples/helloworld/HelloRequest.java new file mode 100644 index 0000000..bb5d252 --- /dev/null +++ b/octopus-rpc-core/src/main/proto/io/grpc/examples/helloworld/HelloRequest.java @@ -0,0 +1,445 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: helloworld.proto + +package io.grpc.examples.helloworld; + +/** + *
+ * The request message containing the user's name.
+ * 
+ * + * Protobuf type {@code helloworld.HelloRequest} + */ +public final class HelloRequest extends + com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:helloworld.HelloRequest) + HelloRequestOrBuilder { + // Use HelloRequest.newBuilder() to construct. + private HelloRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + private HelloRequest() { + name_ = ""; + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } + private HelloRequest( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + name_ = s; + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.grpc.examples.helloworld.HelloWorldProto.internal_static_helloworld_HelloRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.grpc.examples.helloworld.HelloWorldProto.internal_static_helloworld_HelloRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.grpc.examples.helloworld.HelloRequest.class, io.grpc.examples.helloworld.HelloRequest.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + private volatile java.lang.Object name_; + /** + * optional string name = 1; + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * optional string name = 1; + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (!getNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!getNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + public static io.grpc.examples.helloworld.HelloRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.grpc.examples.helloworld.HelloRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.grpc.examples.helloworld.HelloRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static io.grpc.examples.helloworld.HelloRequest parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static io.grpc.examples.helloworld.HelloRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + public static io.grpc.examples.helloworld.HelloRequest parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static io.grpc.examples.helloworld.HelloRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input); + } + public static io.grpc.examples.helloworld.HelloRequest parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static io.grpc.examples.helloworld.HelloRequest parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input); + } + public static io.grpc.examples.helloworld.HelloRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage + .parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(io.grpc.examples.helloworld.HelloRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + *
+   * The request message containing the user's name.
+   * 
+ * + * Protobuf type {@code helloworld.HelloRequest} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:helloworld.HelloRequest) + io.grpc.examples.helloworld.HelloRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return io.grpc.examples.helloworld.HelloWorldProto.internal_static_helloworld_HelloRequest_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return io.grpc.examples.helloworld.HelloWorldProto.internal_static_helloworld_HelloRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + io.grpc.examples.helloworld.HelloRequest.class, io.grpc.examples.helloworld.HelloRequest.Builder.class); + } + + // Construct using io.grpc.examples.helloworld.HelloRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + public Builder clear() { + super.clear(); + name_ = ""; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return io.grpc.examples.helloworld.HelloWorldProto.internal_static_helloworld_HelloRequest_descriptor; + } + + public io.grpc.examples.helloworld.HelloRequest getDefaultInstanceForType() { + return io.grpc.examples.helloworld.HelloRequest.getDefaultInstance(); + } + + public io.grpc.examples.helloworld.HelloRequest build() { + io.grpc.examples.helloworld.HelloRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public io.grpc.examples.helloworld.HelloRequest buildPartial() { + io.grpc.examples.helloworld.HelloRequest result = new io.grpc.examples.helloworld.HelloRequest(this); + result.name_ = name_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof io.grpc.examples.helloworld.HelloRequest) { + return mergeFrom((io.grpc.examples.helloworld.HelloRequest)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(io.grpc.examples.helloworld.HelloRequest other) { + if (other == io.grpc.examples.helloworld.HelloRequest.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + onChanged(); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + io.grpc.examples.helloworld.HelloRequest parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (io.grpc.examples.helloworld.HelloRequest) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object name_ = ""; + /** + * optional string name = 1; + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * optional string name = 1; + */ + public com.google.protobuf.ByteString + getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * optional string name = 1; + */ + public Builder setName( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + name_ = value; + onChanged(); + return this; + } + /** + * optional string name = 1; + */ + public Builder clearName() { + + name_ = getDefaultInstance().getName(); + onChanged(); + return this; + } + /** + * optional string name = 1; + */ + public Builder setNameBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + name_ = value; + onChanged(); + return this; + } + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + + // @@protoc_insertion_point(builder_scope:helloworld.HelloRequest) + } + + // @@protoc_insertion_point(class_scope:helloworld.HelloRequest) + private static final io.grpc.examples.helloworld.HelloRequest DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new io.grpc.examples.helloworld.HelloRequest(); + } + + public static io.grpc.examples.helloworld.HelloRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + public HelloRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new HelloRequest(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public io.grpc.examples.helloworld.HelloRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/octopus-rpc-core/src/main/proto/io/grpc/examples/helloworld/HelloRequestOrBuilder.java b/octopus-rpc-core/src/main/proto/io/grpc/examples/helloworld/HelloRequestOrBuilder.java new file mode 100644 index 0000000..2db6d24 --- /dev/null +++ b/octopus-rpc-core/src/main/proto/io/grpc/examples/helloworld/HelloRequestOrBuilder.java @@ -0,0 +1,19 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: helloworld.proto + +package io.grpc.examples.helloworld; + +public interface HelloRequestOrBuilder extends + // @@protoc_insertion_point(interface_extends:helloworld.HelloRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * optional string name = 1; + */ + java.lang.String getName(); + /** + * optional string name = 1; + */ + com.google.protobuf.ByteString + getNameBytes(); +} diff --git a/octopus-rpc-core/src/main/proto/io/grpc/examples/helloworld/HelloWorldProto.java b/octopus-rpc-core/src/main/proto/io/grpc/examples/helloworld/HelloWorldProto.java new file mode 100644 index 0000000..32704fe --- /dev/null +++ b/octopus-rpc-core/src/main/proto/io/grpc/examples/helloworld/HelloWorldProto.java @@ -0,0 +1,64 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: helloworld.proto + +package io.grpc.examples.helloworld; + +public final class HelloWorldProto { + private HelloWorldProto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + static final com.google.protobuf.Descriptors.Descriptor + internal_static_helloworld_HelloRequest_descriptor; + static final + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_helloworld_HelloRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_helloworld_HelloReply_descriptor; + static final + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_helloworld_HelloReply_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n\020helloworld.proto\022\nhelloworld\"\034\n\014HelloR" + + "equest\022\014\n\004name\030\001 \001(\t\"\035\n\nHelloReply\022\017\n\007me" + + "ssage\030\001 \001(\t2I\n\007Greeter\022>\n\010SayHello\022\030.hel" + + "loworld.HelloRequest\032\026.helloworld.HelloR" + + "eply\"\000B6\n\033io.grpc.examples.helloworldB\017H" + + "elloWorldProtoP\001\242\002\003HLWb\006proto3" + }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = + new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors( + com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }, assigner); + internal_static_helloworld_HelloRequest_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_helloworld_HelloRequest_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_helloworld_HelloRequest_descriptor, + new java.lang.String[] { "Name", }); + internal_static_helloworld_HelloReply_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_helloworld_HelloReply_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_helloworld_HelloReply_descriptor, + new java.lang.String[] { "Message", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/octopus-rpc-core/src/main/resources/application.yml b/octopus-rpc-core/src/main/resources/application.yml new file mode 100644 index 0000000..47ac47e --- /dev/null +++ b/octopus-rpc-core/src/main/resources/application.yml @@ -0,0 +1,5 @@ +####################Server Config###################### + +# gRPC config +grpc: + port: 8964 \ No newline at end of file diff --git a/octopus-rpc-core/src/main/resources/banner.txt b/octopus-rpc-core/src/main/resources/banner.txt new file mode 100644 index 0000000..9ea6067 --- /dev/null +++ b/octopus-rpc-core/src/main/resources/banner.txt @@ -0,0 +1,19 @@ + +o . ___---___ . + . .--\ --. . . + ./.;_.\ __/~ \. + /; / `-' __\ . \ + . . / ,--' / . .; \ | + | .| / __ | -O- . + |__/ __ | . ; \ | . | | + | / \\_ . ;| \___| + . o | \ .~\\___,--' | . + | | . ; ~~~~\_ __| + | \ \ . . ; \ /_/ . + -O- . \ / . | ~/ . + | . ~\ \ . / /~ o + . ~--___ ; ___--~ + . --- . + + + Octopus RPC Server \ No newline at end of file diff --git a/octopus-rpc-server/build.gradle b/octopus-rpc-server/build.gradle new file mode 100644 index 0000000..b7d20d0 --- /dev/null +++ b/octopus-rpc-server/build.gradle @@ -0,0 +1,42 @@ +buildscript { + ext { + springBootVersion = '1.3.5.RELEASE' + } + repositories { + mavenCentral() + // maven { url 'http://repo.spring.io/plugins-release' } + // maven { + // url "http://dl.bintray.com/kotlin/exposed" + //} + } + dependencies { + //classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") + //classpath('org.springframework.build.gradle:propdeps-plugin:0.0.7') + } +} + +apply plugin: 'java' +apply plugin: 'eclipse' + + +sourceCompatibility = 1.8 +targetCompatibility = 1.8 + +repositories { + mavenCentral() +} + + +dependencies { + compile project (':octopus-rpc-core') + //compile('io.grpc:grpc-netty:0.14.0') + //compile('io.grpc:grpc-protobuf:0.14.0') + //compile('io.grpc:grpc-stub:0.14.0') + //compile('org.projectlombok:lombok:1.16.8') + compile('org.springframework.boot:spring-boot-starter:1.4.1.RELEASE') + //testCompile('org.springframework.boot:spring-boot-starter-test') + //optional ('org.springframework.boot:spring-boot-configuration-processor') +} + + +//compileJava.dependsOn(processResources) diff --git a/octopus-rpc-server/src/main/java/com/dingding/octopus/rpc/RpcStartApplication.java b/octopus-rpc-server/src/main/java/com/dingding/octopus/rpc/RpcStartApplication.java new file mode 100644 index 0000000..2b85ebe --- /dev/null +++ b/octopus-rpc-server/src/main/java/com/dingding/octopus/rpc/RpcStartApplication.java @@ -0,0 +1,20 @@ +package com.dingding.octopus.rpc; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +@SpringBootApplication +public class RpcStartApplication { + + public static void main(String[] args) { + + SpringApplication.run(RpcStartApplication.class, args); + //try { + // Http2Server.remain(args); + //} catch (Exception e) { + // e.printStackTrace(); + //} + //while (true){} + } +} diff --git a/octopus-rpc-server/src/main/java/com/dingding/octopus/rpc/config/ApplicationConfig.java b/octopus-rpc-server/src/main/java/com/dingding/octopus/rpc/config/ApplicationConfig.java new file mode 100644 index 0000000..ce009b8 --- /dev/null +++ b/octopus-rpc-server/src/main/java/com/dingding/octopus/rpc/config/ApplicationConfig.java @@ -0,0 +1,27 @@ +package com.dingding.octopus.rpc.config; + +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; + +/** + * Config at top level + * Created by guna on 16/9/16. + */ +public class ApplicationConfig { + private static final Map registeredService = new ConcurrentHashMap<>(); + public static Map getRegisteredService(){ + return registeredService; + } + private static String serverName ="unknown"; + private static final String serverId = UUID.randomUUID().toString(); + public static String getServerName() { + return serverName; + } + public static void setServerName(String serverName) { + ApplicationConfig.serverName = serverName; + } + public static String getServerId(){ + return serverId; + } +} diff --git a/octopus-rpc-server/src/main/java/com/dingding/octopus/rpc/service/DisposableService.java b/octopus-rpc-server/src/main/java/com/dingding/octopus/rpc/service/DisposableService.java new file mode 100644 index 0000000..058cde5 --- /dev/null +++ b/octopus-rpc-server/src/main/java/com/dingding/octopus/rpc/service/DisposableService.java @@ -0,0 +1,9 @@ +package com.dingding.octopus.rpc.service; + +/** + * D + * Created by guna on 16/9/17. + */ +public interface DisposableService { + void beforeClose(); +} diff --git a/octopus-rpc-server/src/main/java/com/dingding/octopus/rpc/service/ServerUtilService.java b/octopus-rpc-server/src/main/java/com/dingding/octopus/rpc/service/ServerUtilService.java new file mode 100644 index 0000000..200e0cb --- /dev/null +++ b/octopus-rpc-server/src/main/java/com/dingding/octopus/rpc/service/ServerUtilService.java @@ -0,0 +1,89 @@ +package com.dingding.octopus.rpc.service; + +import com.dingding.octopus.rpc.common.CoreUtilProto; +import com.dingding.octopus.rpc.common.HeartBeatMessageType; +import com.dingding.octopus.rpc.common.RpcServerUtilGrpc; +import com.dingding.octopus.rpc.config.ApplicationConfig; +import com.dingding.octopus.rpc.support.GRpcService; +import io.grpc.stub.StreamObserver; +import lombok.extern.slf4j.Slf4j; + +import java.util.Set; +import java.util.concurrent.ConcurrentSkipListSet; +import java.util.concurrent.CopyOnWriteArraySet; + +/** + * Comm servers. + * Created by guna on 16/9/16. + */ +@GRpcService(grpcServiceOuterClass = CoreUtilProto.class) +@Slf4j +public class ServerUtilService extends RpcServerUtilGrpc.RpcServerUtilImplBase{ + + private Set> observers = new CopyOnWriteArraySet<>(); + + private CoreUtilProto.ServerInformation buildConnectServerInfo(CoreUtilProto.ClientInformation clientInformation){ + return CoreUtilProto.ServerInformation.newBuilder() + .setType(HeartBeatMessageType.CONNECT_ACCEPT) + .setId(ApplicationConfig.getServerId()) + .setLoad(0).setName(ApplicationConfig.getServerName()) + .setSeq(0).setTime(System.currentTimeMillis()).putAllServices(ApplicationConfig.getRegisteredService() + ).build(); + } + + private CoreUtilProto.ServerInformation buildHeartBeatServerInfo(CoreUtilProto.ClientInformation clientInformation){ + return CoreUtilProto.ServerInformation.newBuilder() + .setType(HeartBeatMessageType.HEART_BEAT) + .setId(ApplicationConfig.getServerId()) + .setLoad(0).setName(ApplicationConfig.getServerName()) + .setSeq(clientInformation.getSeq() + 1).setTime(System.currentTimeMillis()).build(); + } + + @Override + public StreamObserver heartBeat(StreamObserver responseObserver) { + observers.add(responseObserver); + return new StreamObserver() { + + @Override + public void onNext(CoreUtilProto.ClientInformation value) { + switch (value.getType()) { + case HeartBeatMessageType.CONNECT: + log.info("New client connect..."); + responseObserver.onNext(buildConnectServerInfo(value)); + break; + case HeartBeatMessageType.HEART_BEAT: + responseObserver.onNext(buildHeartBeatServerInfo(value)); + break; + default: + log.warn("Unknown message type {}", value.getType()); + } + + } + + @Override + public void onError(Throwable t) { + log.error("Received Client Error : {}", t); + } + + @Override + public void onCompleted() { + observers.remove(responseObserver); + log.info("Connection closed from client. {} left.",observers.size()); + } + }; + + } + + + //@Override + public void close() { + log.info("Sending closing info to client channel {}",observers.size()); + observers.forEach((v)->{ + try{ + v.onCompleted(); + }catch (Exception ignore){ + + } + }); + } +} diff --git a/octopus-rpc-server/src/main/java/com/dingding/octopus/rpc/service/TestUtilService.java b/octopus-rpc-server/src/main/java/com/dingding/octopus/rpc/service/TestUtilService.java new file mode 100644 index 0000000..95dd881 --- /dev/null +++ b/octopus-rpc-server/src/main/java/com/dingding/octopus/rpc/service/TestUtilService.java @@ -0,0 +1,36 @@ +package com.dingding.octopus.rpc.service; + +import com.dingding.octopus.rpc.common.RpcTestUtilGrpc; +import com.dingding.octopus.rpc.common.TestUtilProto; +import com.dingding.octopus.rpc.config.ApplicationConfig; +import com.dingding.octopus.rpc.support.GRpcService; +import io.grpc.stub.StreamObserver; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * XD + * Created by guna on 16/9/18. + */ +@GRpcService(grpcServiceOuterClass = TestUtilProto.class) +public class TestUtilService extends RpcTestUtilGrpc.RpcTestUtilImplBase{ + @Override + public void networkTest(TestUtilProto.ClientTestRequest request, StreamObserver responseObserver) { + responseObserver.onNext(createResponse(request)); + responseObserver.onCompleted(); + } + + @Override + public void networkTestAsync(TestUtilProto.ClientTestRequest request, StreamObserver responseObserver) { + responseObserver.onNext(createResponse(request)); + responseObserver.onCompleted(); + } + + private TestUtilProto.ServerTestResponse createResponse(TestUtilProto.ClientTestRequest request){ + return TestUtilProto.ServerTestResponse.newBuilder() + .setId(ApplicationConfig.getServerId()) + .setName(ApplicationConfig.getServerName()) + .setTime(System.currentTimeMillis()) + .setLoad(0).setMessage(request.getMessage()).build(); + } + +} diff --git a/octopus-rpc-server/src/main/java/com/dingding/octopus/rpc/support/GRpcServerRunner.java b/octopus-rpc-server/src/main/java/com/dingding/octopus/rpc/support/GRpcServerRunner.java new file mode 100644 index 0000000..2e694a4 --- /dev/null +++ b/octopus-rpc-server/src/main/java/com/dingding/octopus/rpc/support/GRpcServerRunner.java @@ -0,0 +1,217 @@ +package com.dingding.octopus.rpc.support; + +import com.dingding.octopus.rpc.common.DetectUtils; +import com.dingding.octopus.rpc.config.ApplicationConfig; +import com.dingding.octopus.rpc.service.DisposableService; +import com.dingding.octopus.rpc.service.ServerUtilService; +import com.dingding.octopus.rpc.support.autoconfigure.GRpcServerProperties; +import io.grpc.*; +import io.grpc.netty.NettyServerBuilder; +import io.netty.handler.ssl.SslProvider; +import io.netty.handler.ssl.util.SelfSignedCertificate; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.DisposableBean; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.CommandLineRunner; +import org.springframework.context.ApplicationContext; +import org.springframework.core.annotation.AnnotationUtils; +import org.springframework.stereotype.Repository; +import org.springframework.stereotype.Service; +import org.springframework.util.ReflectionUtils; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.*; +import java.util.concurrent.Callable; + +/** + * Hosts embedded gRPC server. + */ +@Slf4j +//@Service +public class GRpcServerRunner implements CommandLineRunner,DisposableBean { + + /** + * Name of static function of gRPC service-outer class that creates {@link ServerServiceDefinition}. + */ + final private static String bindServiceMethodName = "bindService"; + + + @Autowired + private ApplicationContext applicationContext; + + @Autowired + private GRpcServerProperties gRpcServerProperties; + + + private Server server; + + public GRpcServerRunner(){ + log.info("gRPC Runner init ..."); + } + + @Override + @SuppressWarnings("unchecked") + public void run(String... args) throws Exception { + + //final ServerBuilder serverBuilder = ServerBuilder.forPort(gRpcServerProperties.getPort()); + final NettyServerBuilder serverBuilder = NettyServerBuilder.forPort(gRpcServerProperties.getPort()); + + log.info("Starting gRPC Server using {} ...",serverBuilder.getClass().getName()); + + //TLS? + + if(gRpcServerProperties.isSsl()){ + log.info("Starting SSL Server..."); + //Check if can enable TLS... + + SslProvider sslProvider = DetectUtils.selectApplicationProtocolConfig(); + if(sslProvider == null){ + log.warn("Failed to load ssl provider"); + } + else { + SelfSignedCertificate ssc = new SelfSignedCertificate(); + serverBuilder.useTransportSecurity(ssc.certificate(),ssc.privateKey()); + log.info("Use SelfSignedCertificate to start TLS..."); + } + } + + // find and register all GRpcService-enabled beans + for(Object grpcService : applicationContext.getBeansWithAnnotation(GRpcService.class).values()) { + /* + final Class grpcServiceOuterClass = AnnotationUtils.findAnnotation(grpcService.getClass(), GRpcService.class).grpcServiceOuterClass(); + + // find 'bindService' method on outer class. + final Optional bindServiceMethod = Arrays.asList(ReflectionUtils.getAllDeclaredMethods(grpcServiceOuterClass)).stream().filter( + method -> bindServiceMethodName.equals(method.getName()) && 1 == method.getParameterCount() && method.getParameterTypes()[0].isAssignableFrom(grpcService.getClass()) + ).findFirst(); + + // register service + // May be there's two or more grpc services? + if (bindServiceMethod.isPresent()) { + ServerServiceDefinition serviceDefinition = (ServerServiceDefinition) bindServiceMethod.get().invoke(null, grpcService); + serverBuilder.addService(serviceDefinition); + log.info("'{}' service has been registered.", serviceDefinition.getName()); + } else { + throw new IllegalArgumentException(String.format("Failed to find '%s' method on class %s.\r\n" + + "Please make sure you've provided correct 'grpcServiceOuterClass' attribute for '%s' annotation.\r\n" + + "It should be the protoc-generated outer class of your service." + , bindServiceMethodName,grpcServiceOuterClass.getName(), GRpcService.class.getName())); + } + */ + //Finding Services... + + //grpcService instanceof + Class aClass = grpcService.getClass(); + GRpcService annotation = aClass.getAnnotation(GRpcService.class); + // Load Inceptors + List interceptors = new ArrayList<>(); + if(annotation != null){ + Class[] classes = annotation.serverInterceptors(); + if(classes.length > 0){ + for (Class c:classes){ + if(c.isInterface()){ + continue; + } + try { + ServerInterceptor serverInterceptor = c.newInstance(); + interceptors.add(serverInterceptor); + log.info("ServerInterceptor {} defined for {}.",c.getName(),aClass.getName()); + }catch (Exception e){ + //serverBuilder.addService(serverServiceDefinition); + log.warn("Initialize interceptor {} failed." , c.getName(),e); + } + } + } + } + // + if(grpcService instanceof ServerServiceDefinition){ + ServerServiceDefinition serverServiceDefinition = (ServerServiceDefinition) grpcService; + serverBuilder.addService(interceptors.size() > 0 ? ServerInterceptors + .intercept(serverServiceDefinition,interceptors) : serverServiceDefinition); + log.info("Add ServerServiceDefinition {}",aClass.getName()); + }else if (grpcService instanceof BindableService ){ + BindableService bindableService = (BindableService) grpcService; + serverBuilder.addService(interceptors.size() > 0 ? ServerInterceptors.intercept(bindableService.bindService(),interceptors) : bindableService.bindService()); + log.info("Add BindableService {}",aClass.getName()); + }else{ + log.warn("Cannot recognise service {}",aClass.getName()); + } + } + server = serverBuilder.build().start(); + + ApplicationConfig.setServerName(gRpcServerProperties.getServerName()); + log.info("gRPC Server {} started, listening on port {}.",gRpcServerProperties.getServerName(), gRpcServerProperties.getPort()); + boolean checkSuccess = false; + Map registeredService = ApplicationConfig.getRegisteredService(); + for (Field f:server.getClass().getDeclaredFields()) { + //log.info("{}",f.getName()); + if(f.getName().equals("registry")) + { + try { + f.setAccessible(true); + Object o = f.get(server); + if(o!= null){ + for (Field n:o.getClass().getDeclaredFields()){ + if(n.getName().equals("methods")){ + n.setAccessible(true); + Object methods = n.get(o); + //log.info("Methods {}",methods.getClass().getName()); + if(methods instanceof Map){ + //ImmutableMap> + Map> map = (Map>)methods; + map.forEach((k,v) ->{ + registeredService.put(k,v.getMethodDescriptor().getFullMethodName()); + }); + checkSuccess = true; + } + break; + } + } + } + }catch (Exception e){ + log.error("Init Services failed. ",e); + } + break; + } + }; + if(!checkSuccess){ + log.warn("Check Registered Services failed."); + } + startDaemonAwaitThread(); + + } + + private void startDaemonAwaitThread() { + Thread awaitThread = new Thread(()-> { + try { + GRpcServerRunner.this.server.awaitTermination(); + } catch (InterruptedException e) { + log.error("gRPC server stopped.",e); + } + }); + awaitThread.setDaemon(false); + awaitThread.start(); + } + @Override + public void destroy() throws Exception { + Map beansOfType = applicationContext.getBeansOfType(DisposableService.class); + if(beansOfType != null){ + log.info("Sending close to {} channel ...",beansOfType.size()); + beansOfType.forEach((k,v)->v.beforeClose()); + } + ServerUtilService bean = applicationContext.getBean(ServerUtilService.class); + if(bean != null){ + bean.close(); + } + try { + log.info("Wait 1000 ms to make sure main util service connection close..."); + Thread.sleep(1000); + }catch (Exception e) { + log.info("Shutting down main util service exception.",e); + } + log.info("Shutting down gRPC server ..."); + Optional.ofNullable(server).ifPresent(Server::shutdown); + log.info("gRPC server stopped."); + } +} \ No newline at end of file diff --git a/octopus-rpc-server/src/main/java/com/dingding/octopus/rpc/support/GRpcService.java b/octopus-rpc-server/src/main/java/com/dingding/octopus/rpc/support/GRpcService.java new file mode 100644 index 0000000..840f49e --- /dev/null +++ b/octopus-rpc-server/src/main/java/com/dingding/octopus/rpc/support/GRpcService.java @@ -0,0 +1,27 @@ +package com.dingding.octopus.rpc.support; + +import io.grpc.ServerInterceptor; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; + +import java.lang.annotation.*; + +/** + * + * Marks the annotated class to be registered as grpc-service bean; + * @author Furer Alexander + * @since 0.0.1 + */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Service +public @interface GRpcService { + /** + * + * @return protoc-generated class that creates {@link io.grpc.ServerServiceDefinition} via static bindService function. + */ + Class grpcServiceOuterClass(); + + Class[] serverInterceptors() default {}; +} \ No newline at end of file diff --git a/octopus-rpc-server/src/main/java/com/dingding/octopus/rpc/support/autoconfigure/GRpcAutoConfiguration.java b/octopus-rpc-server/src/main/java/com/dingding/octopus/rpc/support/autoconfigure/GRpcAutoConfiguration.java new file mode 100644 index 0000000..d3f5c52 --- /dev/null +++ b/octopus-rpc-server/src/main/java/com/dingding/octopus/rpc/support/autoconfigure/GRpcAutoConfiguration.java @@ -0,0 +1,24 @@ +package com.dingding.octopus.rpc.support.autoconfigure; + +import com.dingding.octopus.rpc.support.GRpcServerRunner; +import com.dingding.octopus.rpc.support.GRpcService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * GRPC CONFIG + * Created by herui on 16/6/4. + */ +@Slf4j +@Configuration +@EnableConfigurationProperties(GRpcServerProperties.class) +public class GRpcAutoConfiguration { + @Bean + @ConditionalOnBean(annotation = GRpcService.class) + GRpcServerRunner grpcServerRunner(){ + return new GRpcServerRunner(); + } +} \ No newline at end of file diff --git a/octopus-rpc-server/src/main/java/com/dingding/octopus/rpc/support/autoconfigure/GRpcServerProperties.java b/octopus-rpc-server/src/main/java/com/dingding/octopus/rpc/support/autoconfigure/GRpcServerProperties.java new file mode 100644 index 0000000..656f8cd --- /dev/null +++ b/octopus-rpc-server/src/main/java/com/dingding/octopus/rpc/support/autoconfigure/GRpcServerProperties.java @@ -0,0 +1,22 @@ +package com.dingding.octopus.rpc.support.autoconfigure; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * Config + * Created by herui on 16/6/4. + */ +@ConfigurationProperties("grpc") +@Data +public class GRpcServerProperties { + /** + * gRPC server port + */ + private int port = 6565; + + private boolean ssl = false; + + private String serverName = "gRpc Server"; + +} \ No newline at end of file diff --git a/octopus-rpc-server/src/main/resources/application.yml b/octopus-rpc-server/src/main/resources/application.yml new file mode 100644 index 0000000..8471ca6 --- /dev/null +++ b/octopus-rpc-server/src/main/resources/application.yml @@ -0,0 +1,7 @@ +####################Server Config###################### + +# gRPC config +grpc: + port: 8964 + ssl: false + serverName: "RPC" \ No newline at end of file diff --git a/octopus-rpc-server/src/main/resources/banner.txt b/octopus-rpc-server/src/main/resources/banner.txt new file mode 100644 index 0000000..9ea6067 --- /dev/null +++ b/octopus-rpc-server/src/main/resources/banner.txt @@ -0,0 +1,19 @@ + +o . ___---___ . + . .--\ --. . . + ./.;_.\ __/~ \. + /; / `-' __\ . \ + . . / ,--' / . .; \ | + | .| / __ | -O- . + |__/ __ | . ; \ | . | | + | / \\_ . ;| \___| + . o | \ .~\\___,--' | . + | | . ; ~~~~\_ __| + | \ \ . . ; \ /_/ . + -O- . \ / . | ~/ . + | . ~\ \ . / /~ o + . ~--___ ; ___--~ + . --- . + + + Octopus RPC Server \ No newline at end of file diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..495975b --- /dev/null +++ b/settings.gradle @@ -0,0 +1,4 @@ +rootProject.name = 'octopus' + +include 'octopus-rpc-core' +include 'octopus-rpc-server' \ No newline at end of file