This is an automated email from the ASF dual-hosted git repository. victory pushed a commit to branch cloud-native in repository https://gitbox.apache.org/repos/asf/dubbo.git
commit d7ed829fe79849fa5805e4c8001e25822534c034 Author: cvictory <shenglic...@gmail.com> AuthorDate: Thu Aug 8 10:48:23 2019 +0800 init project --- .../bootstrap/DubboServiceProvider2Bootstrap.java | 39 + .../dubbo-metadata-definition-protobuf/pom.xml | 42 - ...e.dubbo.metadata.definition.builder.TypeBuilder | 1 - .../definition/protobuf/model/GooglePB.java | 3431 -------------------- .../org/apache/dubbo/metadata/MetadataUtil.java | 33 + .../metadata/store/etcd/EtcdMetadataReport.java | 3 +- .../registry/consul/AbstractConsulRegistry.java | 27 + .../dubbo/registry/consul/ConsulRegistry.java | 23 +- .../registry/consul/ConsulServiceDiscovery.java | 196 ++ .../consul/ConsulServiceDiscoveryFactory.java | 16 +- .../dubbo/registry/etcd/EtcdServiceDiscovery.java | 12 +- 11 files changed, 320 insertions(+), 3503 deletions(-) diff --git a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/DubboServiceProvider2Bootstrap.java b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/DubboServiceProvider2Bootstrap.java new file mode 100644 index 0000000..cc2948e --- /dev/null +++ b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/DubboServiceProvider2Bootstrap.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dubbo.bootstrap; + +/** + * Dubbo Provider Bootstrap + * + * @since 2.7.4 + */ +public class DubboServiceProvider2Bootstrap { + + public static void main(String[] args) { + new DubboBootstrap() + .application("dubbo-provider-demo") + // Zookeeper in service registry type + .registry("zookeeper", builder -> builder.address("zookeeper://127.0.0.1:2181?registry-type=service")) + // Nacos +// .registry("nacos", builder -> builder.address("nacos://127.0.0.1:8848?registry-type=service")) +// .registry(RegistryBuilder.newBuilder().address("etcd3://127.0.0.1:2379?registry-type=service").build()) + .protocol(builder -> builder.port(20885).name("dubbo")) + .service(builder -> builder.id("test").interfaceClass(EchoService.class).ref(new EchoServiceImpl())) + .start() + .await(); + } +} diff --git a/dubbo-metadata-report/dubbo-metadata-definition-protobuf/pom.xml b/dubbo-metadata-report/dubbo-metadata-definition-protobuf/pom.xml deleted file mode 100644 index 219694a..0000000 --- a/dubbo-metadata-report/dubbo-metadata-definition-protobuf/pom.xml +++ /dev/null @@ -1,42 +0,0 @@ -<!-- - Licensed to the Apache Software Foundation (ASF) under one or more - contributor license agreements. See the NOTICE file distributed with - this work for additional information regarding copyright ownership. - The ASF licenses this file to You under the Apache License, Version 2.0 - (the "License"); you may not use this file except in compliance with - the License. You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <parent> - <artifactId>dubbo-metadata-report</artifactId> - <groupId>org.apache.dubbo</groupId> - <version>${revision}</version> - </parent> - <modelVersion>4.0.0</modelVersion> - <artifactId>dubbo-metadata-definition-protobuf</artifactId> - - - <dependencies> - <dependency> - <groupId>com.google.protobuf</groupId> - <artifactId>protobuf-java</artifactId> - </dependency> - <dependency> - <groupId>com.google.protobuf</groupId> - <artifactId>protobuf-java-util</artifactId> - </dependency> - <dependency> - <groupId>org.apache.dubbo</groupId> - <artifactId>dubbo-metadata-definition</artifactId> - <version>${project.parent.version}</version> - </dependency> - </dependencies> -</project> diff --git a/dubbo-metadata-report/dubbo-metadata-definition-protobuf/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.metadata.definition.builder.TypeBuilder b/dubbo-metadata-report/dubbo-metadata-definition-protobuf/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.metadata.definition.builder.TypeBuilder deleted file mode 100644 index 615ed7e..0000000 --- a/dubbo-metadata-report/dubbo-metadata-definition-protobuf/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.metadata.definition.builder.TypeBuilder +++ /dev/null @@ -1 +0,0 @@ -protobuf=org.apache.dubbo.metadata.definition.protobuf.ProtobufTypeBuilder diff --git a/dubbo-metadata-report/dubbo-metadata-definition-protobuf/src/test/java/org/apache/dubbo/metadata/definition/protobuf/model/GooglePB.java b/dubbo-metadata-report/dubbo-metadata-definition-protobuf/src/test/java/org/apache/dubbo/metadata/definition/protobuf/model/GooglePB.java deleted file mode 100644 index d662339..0000000 --- a/dubbo-metadata-report/dubbo-metadata-definition-protobuf/src/test/java/org/apache/dubbo/metadata/definition/protobuf/model/GooglePB.java +++ /dev/null @@ -1,3431 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: GooglePB.proto - -package org.apache.dubbo.metadata.definition.protobuf.model; - -public final class GooglePB { - private GooglePB() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistryLite registry) { - } - - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - registerAllExtensions( - (com.google.protobuf.ExtensionRegistryLite) registry); - } - /** - * Protobuf enum {@code org.apache.dubbo.common.serialize.protobuf.model.PhoneType} - */ - public enum PhoneType - implements com.google.protobuf.ProtocolMessageEnum { - /** - * <code>MOBILE = 0;</code> - */ - MOBILE(0), - /** - * <code>HOME = 1;</code> - */ - HOME(1), - /** - * <code>WORK = 2;</code> - */ - WORK(2), - ; - - /** - * <code>MOBILE = 0;</code> - */ - public static final int MOBILE_VALUE = 0; - /** - * <code>HOME = 1;</code> - */ - public static final int HOME_VALUE = 1; - /** - * <code>WORK = 2;</code> - */ - public static final int WORK_VALUE = 2; - - - public final int getNumber() { - return value; - } - - /** - * @deprecated Use {@link #forNumber(int)} instead. - */ - @Deprecated - public static PhoneType valueOf(int value) { - return forNumber(value); - } - - public static PhoneType forNumber(int value) { - switch (value) { - case 0: return MOBILE; - case 1: return HOME; - case 2: return WORK; - default: return null; - } - } - - public static com.google.protobuf.Internal.EnumLiteMap<PhoneType> - internalGetValueMap() { - return internalValueMap; - } - private static final com.google.protobuf.Internal.EnumLiteMap< - PhoneType> internalValueMap = - new com.google.protobuf.Internal.EnumLiteMap<PhoneType>() { - public PhoneType findValueByNumber(int number) { - return PhoneType.forNumber(number); - } - }; - - public final com.google.protobuf.Descriptors.EnumValueDescriptor - getValueDescriptor() { - return getDescriptor().getValues().get(ordinal()); - } - public final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptorForType() { - return getDescriptor(); - } - public static final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptor() { - return GooglePB.getDescriptor().getEnumTypes().get(0); - } - - private static final PhoneType[] VALUES = values(); - - public static PhoneType valueOf( - com.google.protobuf.Descriptors.EnumValueDescriptor desc) { - if (desc.getType() != getDescriptor()) { - throw new IllegalArgumentException( - "EnumValueDescriptor is not for this type."); - } - return VALUES[desc.getIndex()]; - } - - private final int value; - - private PhoneType(int value) { - this.value = value; - } - - // @@protoc_insertion_point(enum_scope:org.apache.dubbo.common.serialize.protobuf.model.PhoneType) - } - - public interface PBRequestTypeOrBuilder extends - // @@protoc_insertion_point(interface_extends:org.apache.dubbo.common.serialize.protobuf.model.PBRequestType) - com.google.protobuf.MessageOrBuilder { - - /** - * <code>optional double money = 1;</code> - */ - boolean hasMoney(); - /** - * <code>optional double money = 1;</code> - */ - double getMoney(); - - /** - * <code>optional float cash = 2;</code> - */ - boolean hasCash(); - /** - * <code>optional float cash = 2;</code> - */ - float getCash(); - - /** - * <code>optional int32 age = 3;</code> - */ - boolean hasAge(); - /** - * <code>optional int32 age = 3;</code> - */ - int getAge(); - - /** - * <code>optional int64 num = 4;</code> - */ - boolean hasNum(); - /** - * <code>optional int64 num = 4;</code> - */ - long getNum(); - - /** - * <code>optional bool sex = 5;</code> - */ - boolean hasSex(); - /** - * <code>optional bool sex = 5;</code> - */ - boolean getSex(); - - /** - * <code>optional string name = 6;</code> - */ - boolean hasName(); - /** - * <code>optional string name = 6;</code> - */ - String getName(); - /** - * <code>optional string name = 6;</code> - */ - com.google.protobuf.ByteString - getNameBytes(); - - /** - * <code>optional bytes msg = 7;</code> - */ - boolean hasMsg(); - /** - * <code>optional bytes msg = 7;</code> - */ - com.google.protobuf.ByteString getMsg(); - - /** - * <code>repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8;</code> - */ - java.util.List<PhoneNumber> - getPhoneList(); - /** - * <code>repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8;</code> - */ - GooglePB.PhoneNumber getPhone(int index); - /** - * <code>repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8;</code> - */ - int getPhoneCount(); - /** - * <code>repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8;</code> - */ - java.util.List<? extends PhoneNumberOrBuilder> - getPhoneOrBuilderList(); - /** - * <code>repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8;</code> - */ - GooglePB.PhoneNumberOrBuilder getPhoneOrBuilder( - int index); - - /** - * <code>map<string, .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber> doubleMap = 9;</code> - */ - int getDoubleMapCount(); - /** - * <code>map<string, .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber> doubleMap = 9;</code> - */ - boolean containsDoubleMap( - String key); - /** - * Use {@link #getDoubleMapMap()} instead. - */ - @Deprecated - java.util.Map<String, PhoneNumber> - getDoubleMap(); - /** - * <code>map<string, .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber> doubleMap = 9;</code> - */ - java.util.Map<String, PhoneNumber> - getDoubleMapMap(); - /** - * <code>map<string, .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber> doubleMap = 9;</code> - */ - - GooglePB.PhoneNumber getDoubleMapOrDefault( - String key, - GooglePB.PhoneNumber defaultValue); - /** - * <code>map<string, .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber> doubleMap = 9;</code> - */ - - GooglePB.PhoneNumber getDoubleMapOrThrow( - String key); - } - /** - * Protobuf type {@code org.apache.dubbo.common.serialize.protobuf.model.PBRequestType} - */ - public static final class PBRequestType extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:org.apache.dubbo.common.serialize.protobuf.model.PBRequestType) - PBRequestTypeOrBuilder { - private static final long serialVersionUID = 0L; - // Use PBRequestType.newBuilder() to construct. - private PBRequestType(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) { - super(builder); - } - private PBRequestType() { - money_ = 0D; - cash_ = 0F; - age_ = 0; - num_ = 0L; - sex_ = false; - name_ = ""; - msg_ = com.google.protobuf.ByteString.EMPTY; - phone_ = java.util.Collections.emptyList(); - } - - @Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private PBRequestType( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - case 9: { - bitField0_ |= 0x00000001; - money_ = input.readDouble(); - break; - } - case 21: { - bitField0_ |= 0x00000002; - cash_ = input.readFloat(); - break; - } - case 24: { - bitField0_ |= 0x00000004; - age_ = input.readInt32(); - break; - } - case 32: { - bitField0_ |= 0x00000008; - num_ = input.readInt64(); - break; - } - case 40: { - bitField0_ |= 0x00000010; - sex_ = input.readBool(); - break; - } - case 50: { - com.google.protobuf.ByteString bs = input.readBytes(); - bitField0_ |= 0x00000020; - name_ = bs; - break; - } - case 58: { - bitField0_ |= 0x00000040; - msg_ = input.readBytes(); - break; - } - case 66: { - if (!((mutable_bitField0_ & 0x00000080) == 0x00000080)) { - phone_ = new java.util.ArrayList<PhoneNumber>(); - mutable_bitField0_ |= 0x00000080; - } - phone_.add( - input.readMessage(GooglePB.PhoneNumber.PARSER, extensionRegistry)); - break; - } - case 74: { - if (!((mutable_bitField0_ & 0x00000100) == 0x00000100)) { - doubleMap_ = com.google.protobuf.MapField.newMapField( - DoubleMapDefaultEntryHolder.defaultEntry); - mutable_bitField0_ |= 0x00000100; - } - com.google.protobuf.MapEntry<String, PhoneNumber> - doubleMap__ = input.readMessage( - DoubleMapDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); - doubleMap_.getMutableMap().put( - doubleMap__.getKey(), doubleMap__.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 { - if (((mutable_bitField0_ & 0x00000080) == 0x00000080)) { - phone_ = java.util.Collections.unmodifiableList(phone_); - } - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return GooglePB.internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBRequestType_descriptor; - } - - @SuppressWarnings({"rawtypes"}) - protected com.google.protobuf.MapField internalGetMapField( - int number) { - switch (number) { - case 9: - return internalGetDoubleMap(); - default: - throw new RuntimeException( - "Invalid map field number: " + number); - } - } - protected FieldAccessorTable - internalGetFieldAccessorTable() { - return GooglePB.internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBRequestType_fieldAccessorTable - .ensureFieldAccessorsInitialized( - GooglePB.PBRequestType.class, GooglePB.PBRequestType.Builder.class); - } - - private int bitField0_; - public static final int MONEY_FIELD_NUMBER = 1; - private double money_; - /** - * <code>optional double money = 1;</code> - */ - public boolean hasMoney() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * <code>optional double money = 1;</code> - */ - public double getMoney() { - return money_; - } - - public static final int CASH_FIELD_NUMBER = 2; - private float cash_; - /** - * <code>optional float cash = 2;</code> - */ - public boolean hasCash() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * <code>optional float cash = 2;</code> - */ - public float getCash() { - return cash_; - } - - public static final int AGE_FIELD_NUMBER = 3; - private int age_; - /** - * <code>optional int32 age = 3;</code> - */ - public boolean hasAge() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - /** - * <code>optional int32 age = 3;</code> - */ - public int getAge() { - return age_; - } - - public static final int NUM_FIELD_NUMBER = 4; - private long num_; - /** - * <code>optional int64 num = 4;</code> - */ - public boolean hasNum() { - return ((bitField0_ & 0x00000008) == 0x00000008); - } - /** - * <code>optional int64 num = 4;</code> - */ - public long getNum() { - return num_; - } - - public static final int SEX_FIELD_NUMBER = 5; - private boolean sex_; - /** - * <code>optional bool sex = 5;</code> - */ - public boolean hasSex() { - return ((bitField0_ & 0x00000010) == 0x00000010); - } - /** - * <code>optional bool sex = 5;</code> - */ - public boolean getSex() { - return sex_; - } - - public static final int NAME_FIELD_NUMBER = 6; - private volatile Object name_; - /** - * <code>optional string name = 6;</code> - */ - public boolean hasName() { - return ((bitField0_ & 0x00000020) == 0x00000020); - } - /** - * <code>optional string name = 6;</code> - */ - 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(); - if (bs.isValidUtf8()) { - name_ = s; - } - return s; - } - } - /** - * <code>optional string name = 6;</code> - */ - 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 MSG_FIELD_NUMBER = 7; - private com.google.protobuf.ByteString msg_; - /** - * <code>optional bytes msg = 7;</code> - */ - public boolean hasMsg() { - return ((bitField0_ & 0x00000040) == 0x00000040); - } - /** - * <code>optional bytes msg = 7;</code> - */ - public com.google.protobuf.ByteString getMsg() { - return msg_; - } - - public static final int PHONE_FIELD_NUMBER = 8; - private java.util.List<PhoneNumber> phone_; - /** - * <code>repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8;</code> - */ - public java.util.List<PhoneNumber> getPhoneList() { - return phone_; - } - /** - * <code>repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8;</code> - */ - public java.util.List<? extends PhoneNumberOrBuilder> - getPhoneOrBuilderList() { - return phone_; - } - /** - * <code>repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8;</code> - */ - public int getPhoneCount() { - return phone_.size(); - } - /** - * <code>repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8;</code> - */ - public GooglePB.PhoneNumber getPhone(int index) { - return phone_.get(index); - } - /** - * <code>repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8;</code> - */ - public GooglePB.PhoneNumberOrBuilder getPhoneOrBuilder( - int index) { - return phone_.get(index); - } - - public static final int DOUBLEMAP_FIELD_NUMBER = 9; - private static final class DoubleMapDefaultEntryHolder { - static final com.google.protobuf.MapEntry< - String, PhoneNumber> defaultEntry = - com.google.protobuf.MapEntry - .<String, GooglePB.PhoneNumber>newDefaultInstance( - GooglePB.internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBRequestType_DoubleMapEntry_descriptor, - com.google.protobuf.WireFormat.FieldType.STRING, - "", - com.google.protobuf.WireFormat.FieldType.MESSAGE, - GooglePB.PhoneNumber.getDefaultInstance()); - } - private com.google.protobuf.MapField< - String, PhoneNumber> doubleMap_; - private com.google.protobuf.MapField<String, PhoneNumber> - internalGetDoubleMap() { - if (doubleMap_ == null) { - return com.google.protobuf.MapField.emptyMapField( - DoubleMapDefaultEntryHolder.defaultEntry); - } - return doubleMap_; - } - - public int getDoubleMapCount() { - return internalGetDoubleMap().getMap().size(); - } - /** - * <code>map<string, .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber> doubleMap = 9;</code> - */ - - public boolean containsDoubleMap( - String key) { - if (key == null) { throw new NullPointerException(); } - return internalGetDoubleMap().getMap().containsKey(key); - } - /** - * Use {@link #getDoubleMapMap()} instead. - */ - @Deprecated - public java.util.Map<String, PhoneNumber> getDoubleMap() { - return getDoubleMapMap(); - } - /** - * <code>map<string, .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber> doubleMap = 9;</code> - */ - - public java.util.Map<String, PhoneNumber> getDoubleMapMap() { - return internalGetDoubleMap().getMap(); - } - /** - * <code>map<string, .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber> doubleMap = 9;</code> - */ - - public GooglePB.PhoneNumber getDoubleMapOrDefault( - String key, - GooglePB.PhoneNumber defaultValue) { - if (key == null) { throw new NullPointerException(); } - java.util.Map<String, PhoneNumber> map = - internalGetDoubleMap().getMap(); - return map.containsKey(key) ? map.get(key) : defaultValue; - } - /** - * <code>map<string, .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber> doubleMap = 9;</code> - */ - - public GooglePB.PhoneNumber getDoubleMapOrThrow( - String key) { - if (key == null) { throw new NullPointerException(); } - java.util.Map<String, PhoneNumber> map = - internalGetDoubleMap().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; - - for (int i = 0; i < getPhoneCount(); i++) { - if (!getPhone(i).isInitialized()) { - memoizedIsInitialized = 0; - return false; - } - } - for (GooglePB.PhoneNumber item : getDoubleMapMap().values()) { - if (!item.isInitialized()) { - memoizedIsInitialized = 0; - return false; - } - } - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (((bitField0_ & 0x00000001) == 0x00000001)) { - output.writeDouble(1, money_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeFloat(2, cash_); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - output.writeInt32(3, age_); - } - if (((bitField0_ & 0x00000008) == 0x00000008)) { - output.writeInt64(4, num_); - } - if (((bitField0_ & 0x00000010) == 0x00000010)) { - output.writeBool(5, sex_); - } - if (((bitField0_ & 0x00000020) == 0x00000020)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 6, name_); - } - if (((bitField0_ & 0x00000040) == 0x00000040)) { - output.writeBytes(7, msg_); - } - for (int i = 0; i < phone_.size(); i++) { - output.writeMessage(8, phone_.get(i)); - } - com.google.protobuf.GeneratedMessageV3 - .serializeStringMapTo( - output, - internalGetDoubleMap(), - DoubleMapDefaultEntryHolder.defaultEntry, - 9); - unknownFields.writeTo(output); - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.CodedOutputStream - .computeDoubleSize(1, money_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.CodedOutputStream - .computeFloatSize(2, cash_); - } - if (((bitField0_ & 0x00000004) == 0x00000004)) { - size += com.google.protobuf.CodedOutputStream - .computeInt32Size(3, age_); - } - if (((bitField0_ & 0x00000008) == 0x00000008)) { - size += com.google.protobuf.CodedOutputStream - .computeInt64Size(4, num_); - } - if (((bitField0_ & 0x00000010) == 0x00000010)) { - size += com.google.protobuf.CodedOutputStream - .computeBoolSize(5, sex_); - } - if (((bitField0_ & 0x00000020) == 0x00000020)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, name_); - } - if (((bitField0_ & 0x00000040) == 0x00000040)) { - size += com.google.protobuf.CodedOutputStream - .computeBytesSize(7, msg_); - } - for (int i = 0; i < phone_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(8, phone_.get(i)); - } - for (java.util.Map.Entry<String, PhoneNumber> entry - : internalGetDoubleMap().getMap().entrySet()) { - com.google.protobuf.MapEntry<String, PhoneNumber> - doubleMap__ = DoubleMapDefaultEntryHolder.defaultEntry.newBuilderForType() - .setKey(entry.getKey()) - .setValue(entry.getValue()) - .build(); - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(9, doubleMap__); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @Override - public boolean equals(final Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof GooglePB.PBRequestType)) { - return super.equals(obj); - } - GooglePB.PBRequestType other = (GooglePB.PBRequestType) obj; - - boolean result = true; - result = result && (hasMoney() == other.hasMoney()); - if (hasMoney()) { - result = result && ( - Double.doubleToLongBits(getMoney()) - == Double.doubleToLongBits( - other.getMoney())); - } - result = result && (hasCash() == other.hasCash()); - if (hasCash()) { - result = result && ( - Float.floatToIntBits(getCash()) - == Float.floatToIntBits( - other.getCash())); - } - result = result && (hasAge() == other.hasAge()); - if (hasAge()) { - result = result && (getAge() - == other.getAge()); - } - result = result && (hasNum() == other.hasNum()); - if (hasNum()) { - result = result && (getNum() - == other.getNum()); - } - result = result && (hasSex() == other.hasSex()); - if (hasSex()) { - result = result && (getSex() - == other.getSex()); - } - result = result && (hasName() == other.hasName()); - if (hasName()) { - result = result && getName() - .equals(other.getName()); - } - result = result && (hasMsg() == other.hasMsg()); - if (hasMsg()) { - result = result && getMsg() - .equals(other.getMsg()); - } - result = result && getPhoneList() - .equals(other.getPhoneList()); - result = result && internalGetDoubleMap().equals( - other.internalGetDoubleMap()); - result = result && unknownFields.equals(other.unknownFields); - return result; - } - - @Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - if (hasMoney()) { - hash = (37 * hash) + MONEY_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashLong( - Double.doubleToLongBits(getMoney())); - } - if (hasCash()) { - hash = (37 * hash) + CASH_FIELD_NUMBER; - hash = (53 * hash) + Float.floatToIntBits( - getCash()); - } - if (hasAge()) { - hash = (37 * hash) + AGE_FIELD_NUMBER; - hash = (53 * hash) + getAge(); - } - if (hasNum()) { - hash = (37 * hash) + NUM_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashLong( - getNum()); - } - if (hasSex()) { - hash = (37 * hash) + SEX_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean( - getSex()); - } - if (hasName()) { - hash = (37 * hash) + NAME_FIELD_NUMBER; - hash = (53 * hash) + getName().hashCode(); - } - if (hasMsg()) { - hash = (37 * hash) + MSG_FIELD_NUMBER; - hash = (53 * hash) + getMsg().hashCode(); - } - if (getPhoneCount() > 0) { - hash = (37 * hash) + PHONE_FIELD_NUMBER; - hash = (53 * hash) + getPhoneList().hashCode(); - } - if (!internalGetDoubleMap().getMap().isEmpty()) { - hash = (37 * hash) + DOUBLEMAP_FIELD_NUMBER; - hash = (53 * hash) + internalGetDoubleMap().hashCode(); - } - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static GooglePB.PBRequestType parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static GooglePB.PBRequestType parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static GooglePB.PBRequestType parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static GooglePB.PBRequestType parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static GooglePB.PBRequestType parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static GooglePB.PBRequestType parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static GooglePB.PBRequestType parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static GooglePB.PBRequestType 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 GooglePB.PBRequestType parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - public static GooglePB.PBRequestType 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 GooglePB.PBRequestType parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static GooglePB.PBRequestType 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(GooglePB.PBRequestType 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 org.apache.dubbo.common.serialize.protobuf.model.PBRequestType} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements - // @@protoc_insertion_point(builder_implements:org.apache.dubbo.common.serialize.protobuf.model.PBRequestType) - GooglePB.PBRequestTypeOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return GooglePB.internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBRequestType_descriptor; - } - - @SuppressWarnings({"rawtypes"}) - protected com.google.protobuf.MapField internalGetMapField( - int number) { - switch (number) { - case 9: - return internalGetDoubleMap(); - default: - throw new RuntimeException( - "Invalid map field number: " + number); - } - } - @SuppressWarnings({"rawtypes"}) - protected com.google.protobuf.MapField internalGetMutableMapField( - int number) { - switch (number) { - case 9: - return internalGetMutableDoubleMap(); - default: - throw new RuntimeException( - "Invalid map field number: " + number); - } - } - protected FieldAccessorTable - internalGetFieldAccessorTable() { - return GooglePB.internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBRequestType_fieldAccessorTable - .ensureFieldAccessorsInitialized( - GooglePB.PBRequestType.class, GooglePB.PBRequestType.Builder.class); - } - - // Construct using org.apache.dubbo.common.serialize.protobuf.model.GooglePB.PBRequestType.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - getPhoneFieldBuilder(); - } - } - public Builder clear() { - super.clear(); - money_ = 0D; - bitField0_ = (bitField0_ & ~0x00000001); - cash_ = 0F; - bitField0_ = (bitField0_ & ~0x00000002); - age_ = 0; - bitField0_ = (bitField0_ & ~0x00000004); - num_ = 0L; - bitField0_ = (bitField0_ & ~0x00000008); - sex_ = false; - bitField0_ = (bitField0_ & ~0x00000010); - name_ = ""; - bitField0_ = (bitField0_ & ~0x00000020); - msg_ = com.google.protobuf.ByteString.EMPTY; - bitField0_ = (bitField0_ & ~0x00000040); - if (phoneBuilder_ == null) { - phone_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000080); - } else { - phoneBuilder_.clear(); - } - internalGetMutableDoubleMap().clear(); - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return GooglePB.internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBRequestType_descriptor; - } - - public GooglePB.PBRequestType getDefaultInstanceForType() { - return GooglePB.PBRequestType.getDefaultInstance(); - } - - public GooglePB.PBRequestType build() { - GooglePB.PBRequestType result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public GooglePB.PBRequestType buildPartial() { - GooglePB.PBRequestType result = new GooglePB.PBRequestType(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.money_ = money_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000002; - } - result.cash_ = cash_; - if (((from_bitField0_ & 0x00000004) == 0x00000004)) { - to_bitField0_ |= 0x00000004; - } - result.age_ = age_; - if (((from_bitField0_ & 0x00000008) == 0x00000008)) { - to_bitField0_ |= 0x00000008; - } - result.num_ = num_; - if (((from_bitField0_ & 0x00000010) == 0x00000010)) { - to_bitField0_ |= 0x00000010; - } - result.sex_ = sex_; - if (((from_bitField0_ & 0x00000020) == 0x00000020)) { - to_bitField0_ |= 0x00000020; - } - result.name_ = name_; - if (((from_bitField0_ & 0x00000040) == 0x00000040)) { - to_bitField0_ |= 0x00000040; - } - result.msg_ = msg_; - if (phoneBuilder_ == null) { - if (((bitField0_ & 0x00000080) == 0x00000080)) { - phone_ = java.util.Collections.unmodifiableList(phone_); - bitField0_ = (bitField0_ & ~0x00000080); - } - result.phone_ = phone_; - } else { - result.phone_ = phoneBuilder_.build(); - } - result.doubleMap_ = internalGetDoubleMap(); - result.doubleMap_.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 GooglePB.PBRequestType) { - return mergeFrom((GooglePB.PBRequestType)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(GooglePB.PBRequestType other) { - if (other == GooglePB.PBRequestType.getDefaultInstance()) return this; - if (other.hasMoney()) { - setMoney(other.getMoney()); - } - if (other.hasCash()) { - setCash(other.getCash()); - } - if (other.hasAge()) { - setAge(other.getAge()); - } - if (other.hasNum()) { - setNum(other.getNum()); - } - if (other.hasSex()) { - setSex(other.getSex()); - } - if (other.hasName()) { - bitField0_ |= 0x00000020; - name_ = other.name_; - onChanged(); - } - if (other.hasMsg()) { - setMsg(other.getMsg()); - } - if (phoneBuilder_ == null) { - if (!other.phone_.isEmpty()) { - if (phone_.isEmpty()) { - phone_ = other.phone_; - bitField0_ = (bitField0_ & ~0x00000080); - } else { - ensurePhoneIsMutable(); - phone_.addAll(other.phone_); - } - onChanged(); - } - } else { - if (!other.phone_.isEmpty()) { - if (phoneBuilder_.isEmpty()) { - phoneBuilder_.dispose(); - phoneBuilder_ = null; - phone_ = other.phone_; - bitField0_ = (bitField0_ & ~0x00000080); - phoneBuilder_ = - com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? - getPhoneFieldBuilder() : null; - } else { - phoneBuilder_.addAllMessages(other.phone_); - } - } - } - internalGetMutableDoubleMap().mergeFrom( - other.internalGetDoubleMap()); - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - public final boolean isInitialized() { - for (int i = 0; i < getPhoneCount(); i++) { - if (!getPhone(i).isInitialized()) { - return false; - } - } - for (GooglePB.PhoneNumber item : getDoubleMapMap().values()) { - if (!item.isInitialized()) { - return false; - } - } - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - GooglePB.PBRequestType parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (GooglePB.PBRequestType) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private double money_ ; - /** - * <code>optional double money = 1;</code> - */ - public boolean hasMoney() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * <code>optional double money = 1;</code> - */ - public double getMoney() { - return money_; - } - /** - * <code>optional double money = 1;</code> - */ - public Builder setMoney(double value) { - bitField0_ |= 0x00000001; - money_ = value; - onChanged(); - return this; - } - /** - * <code>optional double money = 1;</code> - */ - public Builder clearMoney() { - bitField0_ = (bitField0_ & ~0x00000001); - money_ = 0D; - onChanged(); - return this; - } - - private float cash_ ; - /** - * <code>optional float cash = 2;</code> - */ - public boolean hasCash() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * <code>optional float cash = 2;</code> - */ - public float getCash() { - return cash_; - } - /** - * <code>optional float cash = 2;</code> - */ - public Builder setCash(float value) { - bitField0_ |= 0x00000002; - cash_ = value; - onChanged(); - return this; - } - /** - * <code>optional float cash = 2;</code> - */ - public Builder clearCash() { - bitField0_ = (bitField0_ & ~0x00000002); - cash_ = 0F; - onChanged(); - return this; - } - - private int age_ ; - /** - * <code>optional int32 age = 3;</code> - */ - public boolean hasAge() { - return ((bitField0_ & 0x00000004) == 0x00000004); - } - /** - * <code>optional int32 age = 3;</code> - */ - public int getAge() { - return age_; - } - /** - * <code>optional int32 age = 3;</code> - */ - public Builder setAge(int value) { - bitField0_ |= 0x00000004; - age_ = value; - onChanged(); - return this; - } - /** - * <code>optional int32 age = 3;</code> - */ - public Builder clearAge() { - bitField0_ = (bitField0_ & ~0x00000004); - age_ = 0; - onChanged(); - return this; - } - - private long num_ ; - /** - * <code>optional int64 num = 4;</code> - */ - public boolean hasNum() { - return ((bitField0_ & 0x00000008) == 0x00000008); - } - /** - * <code>optional int64 num = 4;</code> - */ - public long getNum() { - return num_; - } - /** - * <code>optional int64 num = 4;</code> - */ - public Builder setNum(long value) { - bitField0_ |= 0x00000008; - num_ = value; - onChanged(); - return this; - } - /** - * <code>optional int64 num = 4;</code> - */ - public Builder clearNum() { - bitField0_ = (bitField0_ & ~0x00000008); - num_ = 0L; - onChanged(); - return this; - } - - private boolean sex_ ; - /** - * <code>optional bool sex = 5;</code> - */ - public boolean hasSex() { - return ((bitField0_ & 0x00000010) == 0x00000010); - } - /** - * <code>optional bool sex = 5;</code> - */ - public boolean getSex() { - return sex_; - } - /** - * <code>optional bool sex = 5;</code> - */ - public Builder setSex(boolean value) { - bitField0_ |= 0x00000010; - sex_ = value; - onChanged(); - return this; - } - /** - * <code>optional bool sex = 5;</code> - */ - public Builder clearSex() { - bitField0_ = (bitField0_ & ~0x00000010); - sex_ = false; - onChanged(); - return this; - } - - private Object name_ = ""; - /** - * <code>optional string name = 6;</code> - */ - public boolean hasName() { - return ((bitField0_ & 0x00000020) == 0x00000020); - } - /** - * <code>optional string name = 6;</code> - */ - public String getName() { - Object ref = name_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - name_ = s; - } - return s; - } else { - return (String) ref; - } - } - /** - * <code>optional string name = 6;</code> - */ - 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; - } - } - /** - * <code>optional string name = 6;</code> - */ - public Builder setName( - String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000020; - name_ = value; - onChanged(); - return this; - } - /** - * <code>optional string name = 6;</code> - */ - public Builder clearName() { - bitField0_ = (bitField0_ & ~0x00000020); - name_ = getDefaultInstance().getName(); - onChanged(); - return this; - } - /** - * <code>optional string name = 6;</code> - */ - public Builder setNameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000020; - name_ = value; - onChanged(); - return this; - } - - private com.google.protobuf.ByteString msg_ = com.google.protobuf.ByteString.EMPTY; - /** - * <code>optional bytes msg = 7;</code> - */ - public boolean hasMsg() { - return ((bitField0_ & 0x00000040) == 0x00000040); - } - /** - * <code>optional bytes msg = 7;</code> - */ - public com.google.protobuf.ByteString getMsg() { - return msg_; - } - /** - * <code>optional bytes msg = 7;</code> - */ - public Builder setMsg(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000040; - msg_ = value; - onChanged(); - return this; - } - /** - * <code>optional bytes msg = 7;</code> - */ - public Builder clearMsg() { - bitField0_ = (bitField0_ & ~0x00000040); - msg_ = getDefaultInstance().getMsg(); - onChanged(); - return this; - } - - private java.util.List<PhoneNumber> phone_ = - java.util.Collections.emptyList(); - private void ensurePhoneIsMutable() { - if (!((bitField0_ & 0x00000080) == 0x00000080)) { - phone_ = new java.util.ArrayList<PhoneNumber>(phone_); - bitField0_ |= 0x00000080; - } - } - - private com.google.protobuf.RepeatedFieldBuilderV3< - PhoneNumber, PhoneNumber.Builder, PhoneNumberOrBuilder> phoneBuilder_; - - /** - * <code>repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8;</code> - */ - public java.util.List<PhoneNumber> getPhoneList() { - if (phoneBuilder_ == null) { - return java.util.Collections.unmodifiableList(phone_); - } else { - return phoneBuilder_.getMessageList(); - } - } - /** - * <code>repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8;</code> - */ - public int getPhoneCount() { - if (phoneBuilder_ == null) { - return phone_.size(); - } else { - return phoneBuilder_.getCount(); - } - } - /** - * <code>repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8;</code> - */ - public GooglePB.PhoneNumber getPhone(int index) { - if (phoneBuilder_ == null) { - return phone_.get(index); - } else { - return phoneBuilder_.getMessage(index); - } - } - /** - * <code>repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8;</code> - */ - public Builder setPhone( - int index, GooglePB.PhoneNumber value) { - if (phoneBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensurePhoneIsMutable(); - phone_.set(index, value); - onChanged(); - } else { - phoneBuilder_.setMessage(index, value); - } - return this; - } - /** - * <code>repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8;</code> - */ - public Builder setPhone( - int index, GooglePB.PhoneNumber.Builder builderForValue) { - if (phoneBuilder_ == null) { - ensurePhoneIsMutable(); - phone_.set(index, builderForValue.build()); - onChanged(); - } else { - phoneBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * <code>repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8;</code> - */ - public Builder addPhone(GooglePB.PhoneNumber value) { - if (phoneBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensurePhoneIsMutable(); - phone_.add(value); - onChanged(); - } else { - phoneBuilder_.addMessage(value); - } - return this; - } - /** - * <code>repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8;</code> - */ - public Builder addPhone( - int index, GooglePB.PhoneNumber value) { - if (phoneBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensurePhoneIsMutable(); - phone_.add(index, value); - onChanged(); - } else { - phoneBuilder_.addMessage(index, value); - } - return this; - } - /** - * <code>repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8;</code> - */ - public Builder addPhone( - GooglePB.PhoneNumber.Builder builderForValue) { - if (phoneBuilder_ == null) { - ensurePhoneIsMutable(); - phone_.add(builderForValue.build()); - onChanged(); - } else { - phoneBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * <code>repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8;</code> - */ - public Builder addPhone( - int index, GooglePB.PhoneNumber.Builder builderForValue) { - if (phoneBuilder_ == null) { - ensurePhoneIsMutable(); - phone_.add(index, builderForValue.build()); - onChanged(); - } else { - phoneBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * <code>repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8;</code> - */ - public Builder addAllPhone( - Iterable<? extends PhoneNumber> values) { - if (phoneBuilder_ == null) { - ensurePhoneIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, phone_); - onChanged(); - } else { - phoneBuilder_.addAllMessages(values); - } - return this; - } - /** - * <code>repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8;</code> - */ - public Builder clearPhone() { - if (phoneBuilder_ == null) { - phone_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000080); - onChanged(); - } else { - phoneBuilder_.clear(); - } - return this; - } - /** - * <code>repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8;</code> - */ - public Builder removePhone(int index) { - if (phoneBuilder_ == null) { - ensurePhoneIsMutable(); - phone_.remove(index); - onChanged(); - } else { - phoneBuilder_.remove(index); - } - return this; - } - /** - * <code>repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8;</code> - */ - public GooglePB.PhoneNumber.Builder getPhoneBuilder( - int index) { - return getPhoneFieldBuilder().getBuilder(index); - } - /** - * <code>repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8;</code> - */ - public GooglePB.PhoneNumberOrBuilder getPhoneOrBuilder( - int index) { - if (phoneBuilder_ == null) { - return phone_.get(index); } else { - return phoneBuilder_.getMessageOrBuilder(index); - } - } - /** - * <code>repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8;</code> - */ - public java.util.List<? extends PhoneNumberOrBuilder> - getPhoneOrBuilderList() { - if (phoneBuilder_ != null) { - return phoneBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(phone_); - } - } - /** - * <code>repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8;</code> - */ - public GooglePB.PhoneNumber.Builder addPhoneBuilder() { - return getPhoneFieldBuilder().addBuilder( - GooglePB.PhoneNumber.getDefaultInstance()); - } - /** - * <code>repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8;</code> - */ - public GooglePB.PhoneNumber.Builder addPhoneBuilder( - int index) { - return getPhoneFieldBuilder().addBuilder( - index, GooglePB.PhoneNumber.getDefaultInstance()); - } - /** - * <code>repeated .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber phone = 8;</code> - */ - public java.util.List<PhoneNumber.Builder> - getPhoneBuilderList() { - return getPhoneFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilderV3< - PhoneNumber, PhoneNumber.Builder, PhoneNumberOrBuilder> - getPhoneFieldBuilder() { - if (phoneBuilder_ == null) { - phoneBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< - PhoneNumber, PhoneNumber.Builder, PhoneNumberOrBuilder>( - phone_, - ((bitField0_ & 0x00000080) == 0x00000080), - getParentForChildren(), - isClean()); - phone_ = null; - } - return phoneBuilder_; - } - - private com.google.protobuf.MapField< - String, PhoneNumber> doubleMap_; - private com.google.protobuf.MapField<String, PhoneNumber> - internalGetDoubleMap() { - if (doubleMap_ == null) { - return com.google.protobuf.MapField.emptyMapField( - DoubleMapDefaultEntryHolder.defaultEntry); - } - return doubleMap_; - } - private com.google.protobuf.MapField<String, PhoneNumber> - internalGetMutableDoubleMap() { - onChanged();; - if (doubleMap_ == null) { - doubleMap_ = com.google.protobuf.MapField.newMapField( - DoubleMapDefaultEntryHolder.defaultEntry); - } - if (!doubleMap_.isMutable()) { - doubleMap_ = doubleMap_.copy(); - } - return doubleMap_; - } - - public int getDoubleMapCount() { - return internalGetDoubleMap().getMap().size(); - } - /** - * <code>map<string, .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber> doubleMap = 9;</code> - */ - - public boolean containsDoubleMap( - String key) { - if (key == null) { throw new NullPointerException(); } - return internalGetDoubleMap().getMap().containsKey(key); - } - /** - * Use {@link #getDoubleMapMap()} instead. - */ - @Deprecated - public java.util.Map<String, PhoneNumber> getDoubleMap() { - return getDoubleMapMap(); - } - /** - * <code>map<string, .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber> doubleMap = 9;</code> - */ - - public java.util.Map<String, PhoneNumber> getDoubleMapMap() { - return internalGetDoubleMap().getMap(); - } - /** - * <code>map<string, .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber> doubleMap = 9;</code> - */ - - public GooglePB.PhoneNumber getDoubleMapOrDefault( - String key, - GooglePB.PhoneNumber defaultValue) { - if (key == null) { throw new NullPointerException(); } - java.util.Map<String, PhoneNumber> map = - internalGetDoubleMap().getMap(); - return map.containsKey(key) ? map.get(key) : defaultValue; - } - /** - * <code>map<string, .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber> doubleMap = 9;</code> - */ - - public GooglePB.PhoneNumber getDoubleMapOrThrow( - String key) { - if (key == null) { throw new NullPointerException(); } - java.util.Map<String, PhoneNumber> map = - internalGetDoubleMap().getMap(); - if (!map.containsKey(key)) { - throw new IllegalArgumentException(); - } - return map.get(key); - } - - public Builder clearDoubleMap() { - internalGetMutableDoubleMap().getMutableMap() - .clear(); - return this; - } - /** - * <code>map<string, .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber> doubleMap = 9;</code> - */ - - public Builder removeDoubleMap( - String key) { - if (key == null) { throw new NullPointerException(); } - internalGetMutableDoubleMap().getMutableMap() - .remove(key); - return this; - } - /** - * Use alternate mutation accessors instead. - */ - @Deprecated - public java.util.Map<String, PhoneNumber> - getMutableDoubleMap() { - return internalGetMutableDoubleMap().getMutableMap(); - } - /** - * <code>map<string, .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber> doubleMap = 9;</code> - */ - public Builder putDoubleMap( - String key, - GooglePB.PhoneNumber value) { - if (key == null) { throw new NullPointerException(); } - if (value == null) { throw new NullPointerException(); } - internalGetMutableDoubleMap().getMutableMap() - .put(key, value); - return this; - } - /** - * <code>map<string, .org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber> doubleMap = 9;</code> - */ - - public Builder putAllDoubleMap( - java.util.Map<String, PhoneNumber> values) { - internalGetMutableDoubleMap().getMutableMap() - .putAll(values); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:org.apache.dubbo.common.serialize.protobuf.model.PBRequestType) - } - - // @@protoc_insertion_point(class_scope:org.apache.dubbo.common.serialize.protobuf.model.PBRequestType) - private static final GooglePB.PBRequestType DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new GooglePB.PBRequestType(); - } - - public static GooglePB.PBRequestType getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - @Deprecated public static final com.google.protobuf.Parser<PBRequestType> - PARSER = new com.google.protobuf.AbstractParser<PBRequestType>() { - public PBRequestType parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new PBRequestType(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser<PBRequestType> parser() { - return PARSER; - } - - @Override - public com.google.protobuf.Parser<PBRequestType> getParserForType() { - return PARSER; - } - - public GooglePB.PBRequestType getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - } - - public interface PBResponseTypeOrBuilder extends - // @@protoc_insertion_point(interface_extends:org.apache.dubbo.common.serialize.protobuf.model.PBResponseType) - com.google.protobuf.MessageOrBuilder { - - /** - * <code>optional string msg = 1;</code> - */ - boolean hasMsg(); - /** - * <code>optional string msg = 1;</code> - */ - String getMsg(); - /** - * <code>optional string msg = 1;</code> - */ - com.google.protobuf.ByteString - getMsgBytes(); - - /** - * <code>optional .org.apache.dubbo.common.serialize.protobuf.model.PBRequestType CDubboPBRequestType = 3;</code> - */ - boolean hasCDubboPBRequestType(); - /** - * <code>optional .org.apache.dubbo.common.serialize.protobuf.model.PBRequestType CDubboPBRequestType = 3;</code> - */ - GooglePB.PBRequestType getCDubboPBRequestType(); - /** - * <code>optional .org.apache.dubbo.common.serialize.protobuf.model.PBRequestType CDubboPBRequestType = 3;</code> - */ - GooglePB.PBRequestTypeOrBuilder getCDubboPBRequestTypeOrBuilder(); - } - /** - * Protobuf type {@code org.apache.dubbo.common.serialize.protobuf.model.PBResponseType} - */ - public static final class PBResponseType extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:org.apache.dubbo.common.serialize.protobuf.model.PBResponseType) - PBResponseTypeOrBuilder { - private static final long serialVersionUID = 0L; - // Use PBResponseType.newBuilder() to construct. - private PBResponseType(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) { - super(builder); - } - private PBResponseType() { - msg_ = ""; - } - - @Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private PBResponseType( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - com.google.protobuf.ByteString bs = input.readBytes(); - bitField0_ |= 0x00000001; - msg_ = bs; - break; - } - case 26: { - GooglePB.PBRequestType.Builder subBuilder = null; - if (((bitField0_ & 0x00000002) == 0x00000002)) { - subBuilder = cDubboPBRequestType_.toBuilder(); - } - cDubboPBRequestType_ = input.readMessage(GooglePB.PBRequestType.PARSER, extensionRegistry); - if (subBuilder != null) { - subBuilder.mergeFrom(cDubboPBRequestType_); - cDubboPBRequestType_ = subBuilder.buildPartial(); - } - bitField0_ |= 0x00000002; - 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 { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return GooglePB.internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBResponseType_descriptor; - } - - protected FieldAccessorTable - internalGetFieldAccessorTable() { - return GooglePB.internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBResponseType_fieldAccessorTable - .ensureFieldAccessorsInitialized( - GooglePB.PBResponseType.class, GooglePB.PBResponseType.Builder.class); - } - - private int bitField0_; - public static final int MSG_FIELD_NUMBER = 1; - private volatile Object msg_; - /** - * <code>optional string msg = 1;</code> - */ - public boolean hasMsg() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * <code>optional string msg = 1;</code> - */ - public String getMsg() { - Object ref = msg_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - msg_ = s; - } - return s; - } - } - /** - * <code>optional string msg = 1;</code> - */ - public com.google.protobuf.ByteString - getMsgBytes() { - Object ref = msg_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - msg_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int CDUBBOPBREQUESTTYPE_FIELD_NUMBER = 3; - private GooglePB.PBRequestType cDubboPBRequestType_; - /** - * <code>optional .org.apache.dubbo.common.serialize.protobuf.model.PBRequestType CDubboPBRequestType = 3;</code> - */ - public boolean hasCDubboPBRequestType() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * <code>optional .org.apache.dubbo.common.serialize.protobuf.model.PBRequestType CDubboPBRequestType = 3;</code> - */ - public GooglePB.PBRequestType getCDubboPBRequestType() { - return cDubboPBRequestType_ == null ? GooglePB.PBRequestType.getDefaultInstance() : cDubboPBRequestType_; - } - /** - * <code>optional .org.apache.dubbo.common.serialize.protobuf.model.PBRequestType CDubboPBRequestType = 3;</code> - */ - public GooglePB.PBRequestTypeOrBuilder getCDubboPBRequestTypeOrBuilder() { - return cDubboPBRequestType_ == null ? GooglePB.PBRequestType.getDefaultInstance() : cDubboPBRequestType_; - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - if (hasCDubboPBRequestType()) { - if (!getCDubboPBRequestType().isInitialized()) { - memoizedIsInitialized = 0; - return false; - } - } - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (((bitField0_ & 0x00000001) == 0x00000001)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, msg_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeMessage(3, getCDubboPBRequestType()); - } - unknownFields.writeTo(output); - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, msg_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(3, getCDubboPBRequestType()); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @Override - public boolean equals(final Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof GooglePB.PBResponseType)) { - return super.equals(obj); - } - GooglePB.PBResponseType other = (GooglePB.PBResponseType) obj; - - boolean result = true; - result = result && (hasMsg() == other.hasMsg()); - if (hasMsg()) { - result = result && getMsg() - .equals(other.getMsg()); - } - result = result && (hasCDubboPBRequestType() == other.hasCDubboPBRequestType()); - if (hasCDubboPBRequestType()) { - result = result && getCDubboPBRequestType() - .equals(other.getCDubboPBRequestType()); - } - result = result && unknownFields.equals(other.unknownFields); - return result; - } - - @Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - if (hasMsg()) { - hash = (37 * hash) + MSG_FIELD_NUMBER; - hash = (53 * hash) + getMsg().hashCode(); - } - if (hasCDubboPBRequestType()) { - hash = (37 * hash) + CDUBBOPBREQUESTTYPE_FIELD_NUMBER; - hash = (53 * hash) + getCDubboPBRequestType().hashCode(); - } - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static GooglePB.PBResponseType parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static GooglePB.PBResponseType parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static GooglePB.PBResponseType parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static GooglePB.PBResponseType parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static GooglePB.PBResponseType parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static GooglePB.PBResponseType parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static GooglePB.PBResponseType parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static GooglePB.PBResponseType 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 GooglePB.PBResponseType parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - public static GooglePB.PBResponseType 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 GooglePB.PBResponseType parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static GooglePB.PBResponseType 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(GooglePB.PBResponseType 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 org.apache.dubbo.common.serialize.protobuf.model.PBResponseType} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements - // @@protoc_insertion_point(builder_implements:org.apache.dubbo.common.serialize.protobuf.model.PBResponseType) - GooglePB.PBResponseTypeOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return GooglePB.internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBResponseType_descriptor; - } - - protected FieldAccessorTable - internalGetFieldAccessorTable() { - return GooglePB.internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBResponseType_fieldAccessorTable - .ensureFieldAccessorsInitialized( - GooglePB.PBResponseType.class, GooglePB.PBResponseType.Builder.class); - } - - // Construct using org.apache.dubbo.common.serialize.protobuf.model.GooglePB.PBResponseType.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - getCDubboPBRequestTypeFieldBuilder(); - } - } - public Builder clear() { - super.clear(); - msg_ = ""; - bitField0_ = (bitField0_ & ~0x00000001); - if (cDubboPBRequestTypeBuilder_ == null) { - cDubboPBRequestType_ = null; - } else { - cDubboPBRequestTypeBuilder_.clear(); - } - bitField0_ = (bitField0_ & ~0x00000002); - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return GooglePB.internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBResponseType_descriptor; - } - - public GooglePB.PBResponseType getDefaultInstanceForType() { - return GooglePB.PBResponseType.getDefaultInstance(); - } - - public GooglePB.PBResponseType build() { - GooglePB.PBResponseType result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public GooglePB.PBResponseType buildPartial() { - GooglePB.PBResponseType result = new GooglePB.PBResponseType(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.msg_ = msg_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000002; - } - if (cDubboPBRequestTypeBuilder_ == null) { - result.cDubboPBRequestType_ = cDubboPBRequestType_; - } else { - result.cDubboPBRequestType_ = cDubboPBRequestTypeBuilder_.build(); - } - 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 GooglePB.PBResponseType) { - return mergeFrom((GooglePB.PBResponseType)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(GooglePB.PBResponseType other) { - if (other == GooglePB.PBResponseType.getDefaultInstance()) return this; - if (other.hasMsg()) { - bitField0_ |= 0x00000001; - msg_ = other.msg_; - onChanged(); - } - if (other.hasCDubboPBRequestType()) { - mergeCDubboPBRequestType(other.getCDubboPBRequestType()); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - public final boolean isInitialized() { - if (hasCDubboPBRequestType()) { - if (!getCDubboPBRequestType().isInitialized()) { - return false; - } - } - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - GooglePB.PBResponseType parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (GooglePB.PBResponseType) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private Object msg_ = ""; - /** - * <code>optional string msg = 1;</code> - */ - public boolean hasMsg() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * <code>optional string msg = 1;</code> - */ - public String getMsg() { - Object ref = msg_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - msg_ = s; - } - return s; - } else { - return (String) ref; - } - } - /** - * <code>optional string msg = 1;</code> - */ - public com.google.protobuf.ByteString - getMsgBytes() { - Object ref = msg_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - msg_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * <code>optional string msg = 1;</code> - */ - public Builder setMsg( - String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000001; - msg_ = value; - onChanged(); - return this; - } - /** - * <code>optional string msg = 1;</code> - */ - public Builder clearMsg() { - bitField0_ = (bitField0_ & ~0x00000001); - msg_ = getDefaultInstance().getMsg(); - onChanged(); - return this; - } - /** - * <code>optional string msg = 1;</code> - */ - public Builder setMsgBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000001; - msg_ = value; - onChanged(); - return this; - } - - private GooglePB.PBRequestType cDubboPBRequestType_ = null; - private com.google.protobuf.SingleFieldBuilderV3< - PBRequestType, PBRequestType.Builder, PBRequestTypeOrBuilder> cDubboPBRequestTypeBuilder_; - /** - * <code>optional .org.apache.dubbo.common.serialize.protobuf.model.PBRequestType CDubboPBRequestType = 3;</code> - */ - public boolean hasCDubboPBRequestType() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * <code>optional .org.apache.dubbo.common.serialize.protobuf.model.PBRequestType CDubboPBRequestType = 3;</code> - */ - public GooglePB.PBRequestType getCDubboPBRequestType() { - if (cDubboPBRequestTypeBuilder_ == null) { - return cDubboPBRequestType_ == null ? GooglePB.PBRequestType.getDefaultInstance() : cDubboPBRequestType_; - } else { - return cDubboPBRequestTypeBuilder_.getMessage(); - } - } - /** - * <code>optional .org.apache.dubbo.common.serialize.protobuf.model.PBRequestType CDubboPBRequestType = 3;</code> - */ - public Builder setCDubboPBRequestType(GooglePB.PBRequestType value) { - if (cDubboPBRequestTypeBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - cDubboPBRequestType_ = value; - onChanged(); - } else { - cDubboPBRequestTypeBuilder_.setMessage(value); - } - bitField0_ |= 0x00000002; - return this; - } - /** - * <code>optional .org.apache.dubbo.common.serialize.protobuf.model.PBRequestType CDubboPBRequestType = 3;</code> - */ - public Builder setCDubboPBRequestType( - GooglePB.PBRequestType.Builder builderForValue) { - if (cDubboPBRequestTypeBuilder_ == null) { - cDubboPBRequestType_ = builderForValue.build(); - onChanged(); - } else { - cDubboPBRequestTypeBuilder_.setMessage(builderForValue.build()); - } - bitField0_ |= 0x00000002; - return this; - } - /** - * <code>optional .org.apache.dubbo.common.serialize.protobuf.model.PBRequestType CDubboPBRequestType = 3;</code> - */ - public Builder mergeCDubboPBRequestType(GooglePB.PBRequestType value) { - if (cDubboPBRequestTypeBuilder_ == null) { - if (((bitField0_ & 0x00000002) == 0x00000002) && - cDubboPBRequestType_ != null && - cDubboPBRequestType_ != GooglePB.PBRequestType.getDefaultInstance()) { - cDubboPBRequestType_ = - GooglePB.PBRequestType.newBuilder(cDubboPBRequestType_).mergeFrom(value).buildPartial(); - } else { - cDubboPBRequestType_ = value; - } - onChanged(); - } else { - cDubboPBRequestTypeBuilder_.mergeFrom(value); - } - bitField0_ |= 0x00000002; - return this; - } - /** - * <code>optional .org.apache.dubbo.common.serialize.protobuf.model.PBRequestType CDubboPBRequestType = 3;</code> - */ - public Builder clearCDubboPBRequestType() { - if (cDubboPBRequestTypeBuilder_ == null) { - cDubboPBRequestType_ = null; - onChanged(); - } else { - cDubboPBRequestTypeBuilder_.clear(); - } - bitField0_ = (bitField0_ & ~0x00000002); - return this; - } - /** - * <code>optional .org.apache.dubbo.common.serialize.protobuf.model.PBRequestType CDubboPBRequestType = 3;</code> - */ - public GooglePB.PBRequestType.Builder getCDubboPBRequestTypeBuilder() { - bitField0_ |= 0x00000002; - onChanged(); - return getCDubboPBRequestTypeFieldBuilder().getBuilder(); - } - /** - * <code>optional .org.apache.dubbo.common.serialize.protobuf.model.PBRequestType CDubboPBRequestType = 3;</code> - */ - public GooglePB.PBRequestTypeOrBuilder getCDubboPBRequestTypeOrBuilder() { - if (cDubboPBRequestTypeBuilder_ != null) { - return cDubboPBRequestTypeBuilder_.getMessageOrBuilder(); - } else { - return cDubboPBRequestType_ == null ? - GooglePB.PBRequestType.getDefaultInstance() : cDubboPBRequestType_; - } - } - /** - * <code>optional .org.apache.dubbo.common.serialize.protobuf.model.PBRequestType CDubboPBRequestType = 3;</code> - */ - private com.google.protobuf.SingleFieldBuilderV3< - PBRequestType, PBRequestType.Builder, PBRequestTypeOrBuilder> - getCDubboPBRequestTypeFieldBuilder() { - if (cDubboPBRequestTypeBuilder_ == null) { - cDubboPBRequestTypeBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< - PBRequestType, PBRequestType.Builder, PBRequestTypeOrBuilder>( - getCDubboPBRequestType(), - getParentForChildren(), - isClean()); - cDubboPBRequestType_ = null; - } - return cDubboPBRequestTypeBuilder_; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:org.apache.dubbo.common.serialize.protobuf.model.PBResponseType) - } - - // @@protoc_insertion_point(class_scope:org.apache.dubbo.common.serialize.protobuf.model.PBResponseType) - private static final GooglePB.PBResponseType DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new GooglePB.PBResponseType(); - } - - public static GooglePB.PBResponseType getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - @Deprecated public static final com.google.protobuf.Parser<PBResponseType> - PARSER = new com.google.protobuf.AbstractParser<PBResponseType>() { - public PBResponseType parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new PBResponseType(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser<PBResponseType> parser() { - return PARSER; - } - - @Override - public com.google.protobuf.Parser<PBResponseType> getParserForType() { - return PARSER; - } - - public GooglePB.PBResponseType getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - } - - public interface PhoneNumberOrBuilder extends - // @@protoc_insertion_point(interface_extends:org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber) - com.google.protobuf.MessageOrBuilder { - - /** - * <code>required string number = 1;</code> - */ - boolean hasNumber(); - /** - * <code>required string number = 1;</code> - */ - String getNumber(); - /** - * <code>required string number = 1;</code> - */ - com.google.protobuf.ByteString - getNumberBytes(); - - /** - * <code>optional .org.apache.dubbo.common.serialize.protobuf.model.PhoneType type = 2 [default = HOME];</code> - */ - boolean hasType(); - /** - * <code>optional .org.apache.dubbo.common.serialize.protobuf.model.PhoneType type = 2 [default = HOME];</code> - */ - GooglePB.PhoneType getType(); - } - /** - * Protobuf type {@code org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber} - */ - public static final class PhoneNumber extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber) - PhoneNumberOrBuilder { - private static final long serialVersionUID = 0L; - // Use PhoneNumber.newBuilder() to construct. - private PhoneNumber(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) { - super(builder); - } - private PhoneNumber() { - number_ = ""; - type_ = 1; - } - - @Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private PhoneNumber( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!parseUnknownField( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - case 10: { - com.google.protobuf.ByteString bs = input.readBytes(); - bitField0_ |= 0x00000001; - number_ = bs; - break; - } - case 16: { - int rawValue = input.readEnum(); - GooglePB.PhoneType value = GooglePB.PhoneType.valueOf(rawValue); - if (value == null) { - unknownFields.mergeVarintField(2, rawValue); - } else { - bitField0_ |= 0x00000002; - type_ = rawValue; - } - 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 { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return GooglePB.internal_static_org_apache_dubbo_common_serialize_protobuf_model_PhoneNumber_descriptor; - } - - protected FieldAccessorTable - internalGetFieldAccessorTable() { - return GooglePB.internal_static_org_apache_dubbo_common_serialize_protobuf_model_PhoneNumber_fieldAccessorTable - .ensureFieldAccessorsInitialized( - GooglePB.PhoneNumber.class, GooglePB.PhoneNumber.Builder.class); - } - - private int bitField0_; - public static final int NUMBER_FIELD_NUMBER = 1; - private volatile Object number_; - /** - * <code>required string number = 1;</code> - */ - public boolean hasNumber() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * <code>required string number = 1;</code> - */ - public String getNumber() { - Object ref = number_; - if (ref instanceof String) { - return (String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - number_ = s; - } - return s; - } - } - /** - * <code>required string number = 1;</code> - */ - public com.google.protobuf.ByteString - getNumberBytes() { - Object ref = number_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - number_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int TYPE_FIELD_NUMBER = 2; - private int type_; - /** - * <code>optional .org.apache.dubbo.common.serialize.protobuf.model.PhoneType type = 2 [default = HOME];</code> - */ - public boolean hasType() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * <code>optional .org.apache.dubbo.common.serialize.protobuf.model.PhoneType type = 2 [default = HOME];</code> - */ - public GooglePB.PhoneType getType() { - GooglePB.PhoneType result = GooglePB.PhoneType.valueOf(type_); - return result == null ? GooglePB.PhoneType.HOME : result; - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - if (!hasNumber()) { - memoizedIsInitialized = 0; - return false; - } - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (((bitField0_ & 0x00000001) == 0x00000001)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, number_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - output.writeEnum(2, type_); - } - unknownFields.writeTo(output); - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (((bitField0_ & 0x00000001) == 0x00000001)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, number_); - } - if (((bitField0_ & 0x00000002) == 0x00000002)) { - size += com.google.protobuf.CodedOutputStream - .computeEnumSize(2, type_); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @Override - public boolean equals(final Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof GooglePB.PhoneNumber)) { - return super.equals(obj); - } - GooglePB.PhoneNumber other = (GooglePB.PhoneNumber) obj; - - boolean result = true; - result = result && (hasNumber() == other.hasNumber()); - if (hasNumber()) { - result = result && getNumber() - .equals(other.getNumber()); - } - result = result && (hasType() == other.hasType()); - if (hasType()) { - result = result && type_ == other.type_; - } - result = result && unknownFields.equals(other.unknownFields); - return result; - } - - @Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - if (hasNumber()) { - hash = (37 * hash) + NUMBER_FIELD_NUMBER; - hash = (53 * hash) + getNumber().hashCode(); - } - if (hasType()) { - hash = (37 * hash) + TYPE_FIELD_NUMBER; - hash = (53 * hash) + type_; - } - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static GooglePB.PhoneNumber parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static GooglePB.PhoneNumber parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static GooglePB.PhoneNumber parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static GooglePB.PhoneNumber parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static GooglePB.PhoneNumber parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static GooglePB.PhoneNumber parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static GooglePB.PhoneNumber parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static GooglePB.PhoneNumber 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 GooglePB.PhoneNumber parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - public static GooglePB.PhoneNumber 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 GooglePB.PhoneNumber parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static GooglePB.PhoneNumber 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(GooglePB.PhoneNumber 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 org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements - // @@protoc_insertion_point(builder_implements:org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber) - GooglePB.PhoneNumberOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return GooglePB.internal_static_org_apache_dubbo_common_serialize_protobuf_model_PhoneNumber_descriptor; - } - - protected FieldAccessorTable - internalGetFieldAccessorTable() { - return GooglePB.internal_static_org_apache_dubbo_common_serialize_protobuf_model_PhoneNumber_fieldAccessorTable - .ensureFieldAccessorsInitialized( - GooglePB.PhoneNumber.class, GooglePB.PhoneNumber.Builder.class); - } - - // Construct using org.apache.dubbo.common.serialize.protobuf.model.GooglePB.PhoneNumber.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(); - number_ = ""; - bitField0_ = (bitField0_ & ~0x00000001); - type_ = 1; - bitField0_ = (bitField0_ & ~0x00000002); - return this; - } - - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return GooglePB.internal_static_org_apache_dubbo_common_serialize_protobuf_model_PhoneNumber_descriptor; - } - - public GooglePB.PhoneNumber getDefaultInstanceForType() { - return GooglePB.PhoneNumber.getDefaultInstance(); - } - - public GooglePB.PhoneNumber build() { - GooglePB.PhoneNumber result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - public GooglePB.PhoneNumber buildPartial() { - GooglePB.PhoneNumber result = new GooglePB.PhoneNumber(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - if (((from_bitField0_ & 0x00000001) == 0x00000001)) { - to_bitField0_ |= 0x00000001; - } - result.number_ = number_; - if (((from_bitField0_ & 0x00000002) == 0x00000002)) { - to_bitField0_ |= 0x00000002; - } - result.type_ = type_; - 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 GooglePB.PhoneNumber) { - return mergeFrom((GooglePB.PhoneNumber)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(GooglePB.PhoneNumber other) { - if (other == GooglePB.PhoneNumber.getDefaultInstance()) return this; - if (other.hasNumber()) { - bitField0_ |= 0x00000001; - number_ = other.number_; - onChanged(); - } - if (other.hasType()) { - setType(other.getType()); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - public final boolean isInitialized() { - if (!hasNumber()) { - return false; - } - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - GooglePB.PhoneNumber parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (GooglePB.PhoneNumber) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private Object number_ = ""; - /** - * <code>required string number = 1;</code> - */ - public boolean hasNumber() { - return ((bitField0_ & 0x00000001) == 0x00000001); - } - /** - * <code>required string number = 1;</code> - */ - public String getNumber() { - Object ref = number_; - if (!(ref instanceof String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - String s = bs.toStringUtf8(); - if (bs.isValidUtf8()) { - number_ = s; - } - return s; - } else { - return (String) ref; - } - } - /** - * <code>required string number = 1;</code> - */ - public com.google.protobuf.ByteString - getNumberBytes() { - Object ref = number_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (String) ref); - number_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * <code>required string number = 1;</code> - */ - public Builder setNumber( - String value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000001; - number_ = value; - onChanged(); - return this; - } - /** - * <code>required string number = 1;</code> - */ - public Builder clearNumber() { - bitField0_ = (bitField0_ & ~0x00000001); - number_ = getDefaultInstance().getNumber(); - onChanged(); - return this; - } - /** - * <code>required string number = 1;</code> - */ - public Builder setNumberBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000001; - number_ = value; - onChanged(); - return this; - } - - private int type_ = 1; - /** - * <code>optional .org.apache.dubbo.common.serialize.protobuf.model.PhoneType type = 2 [default = HOME];</code> - */ - public boolean hasType() { - return ((bitField0_ & 0x00000002) == 0x00000002); - } - /** - * <code>optional .org.apache.dubbo.common.serialize.protobuf.model.PhoneType type = 2 [default = HOME];</code> - */ - public GooglePB.PhoneType getType() { - GooglePB.PhoneType result = GooglePB.PhoneType.valueOf(type_); - return result == null ? GooglePB.PhoneType.HOME : result; - } - /** - * <code>optional .org.apache.dubbo.common.serialize.protobuf.model.PhoneType type = 2 [default = HOME];</code> - */ - public Builder setType(GooglePB.PhoneType value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - type_ = value.getNumber(); - onChanged(); - return this; - } - /** - * <code>optional .org.apache.dubbo.common.serialize.protobuf.model.PhoneType type = 2 [default = HOME];</code> - */ - public Builder clearType() { - bitField0_ = (bitField0_ & ~0x00000002); - type_ = 1; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber) - } - - // @@protoc_insertion_point(class_scope:org.apache.dubbo.common.serialize.protobuf.model.PhoneNumber) - private static final GooglePB.PhoneNumber DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new GooglePB.PhoneNumber(); - } - - public static GooglePB.PhoneNumber getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - @Deprecated public static final com.google.protobuf.Parser<PhoneNumber> - PARSER = new com.google.protobuf.AbstractParser<PhoneNumber>() { - public PhoneNumber parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new PhoneNumber(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser<PhoneNumber> parser() { - return PARSER; - } - - @Override - public com.google.protobuf.Parser<PhoneNumber> getParserForType() { - return PARSER; - } - - public GooglePB.PhoneNumber getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - } - - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBRequestType_descriptor; - private static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBRequestType_fieldAccessorTable; - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBRequestType_DoubleMapEntry_descriptor; - private static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBRequestType_DoubleMapEntry_fieldAccessorTable; - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBResponseType_descriptor; - private static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBResponseType_fieldAccessorTable; - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_org_apache_dubbo_common_serialize_protobuf_model_PhoneNumber_descriptor; - private static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_org_apache_dubbo_common_serialize_protobuf_model_PhoneNumber_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - static { - String[] descriptorData = { - "\n\016GooglePB.proto\0220org.apache.dubbo.commo" + - "n.serialize.protobuf.model\"\220\003\n\rPBRequest" + - "Type\022\r\n\005money\030\001 \001(\001\022\014\n\004cash\030\002 \001(\002\022\013\n\003age" + - "\030\003 \001(\005\022\013\n\003num\030\004 \001(\003\022\013\n\003sex\030\005 \001(\010\022\014\n\004name" + - "\030\006 \001(\t\022\013\n\003msg\030\007 \001(\014\022L\n\005phone\030\010 \003(\0132=.org" + - ".apache.dubbo.common.serialize.protobuf." + - "model.PhoneNumber\022a\n\tdoubleMap\030\t \003(\0132N.o" + - "rg.apache.dubbo.common.serialize.protobu" + - "f.model.PBRequestType.DoubleMapEntry\032o\n\016" + - "DoubleMapEntry\022\013\n\003key\030\001 \001(\t\022L\n\005value\030\002 \001", - "(\0132=.org.apache.dubbo.common.serialize.p" + - "rotobuf.model.PhoneNumber:\0028\001\"{\n\016PBRespo" + - "nseType\022\013\n\003msg\030\001 \001(\t\022\\\n\023CDubboPBRequestT" + - "ype\030\003 \001(\0132?.org.apache.dubbo.common.seri" + - "alize.protobuf.model.PBRequestType\"n\n\013Ph" + - "oneNumber\022\016\n\006number\030\001 \002(\t\022O\n\004type\030\002 \001(\0162" + - ";.org.apache.dubbo.common.serialize.prot" + - "obuf.model.PhoneType:\004HOME*+\n\tPhoneType\022" + - "\n\n\006MOBILE\020\000\022\010\n\004HOME\020\001\022\010\n\004WORK\020\0022\241\001\n\017CDub" + - "boPBService\022\215\001\n\010sayHello\022?.org.apache.du", - "bbo.common.serialize.protobuf.model.PBRe" + - "questType\0...@.org.apache.dubbo.common.seri" + - "alize.protobuf.model.PBResponseType" - }; - 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_org_apache_dubbo_common_serialize_protobuf_model_PBRequestType_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBRequestType_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBRequestType_descriptor, - new String[] { "Money", "Cash", "Age", "Num", "Sex", "Name", "Msg", "Phone", "DoubleMap", }); - internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBRequestType_DoubleMapEntry_descriptor = - internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBRequestType_descriptor.getNestedTypes().get(0); - internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBRequestType_DoubleMapEntry_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBRequestType_DoubleMapEntry_descriptor, - new String[] { "Key", "Value", }); - internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBResponseType_descriptor = - getDescriptor().getMessageTypes().get(1); - internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBResponseType_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_org_apache_dubbo_common_serialize_protobuf_model_PBResponseType_descriptor, - new String[] { "Msg", "CDubboPBRequestType", }); - internal_static_org_apache_dubbo_common_serialize_protobuf_model_PhoneNumber_descriptor = - getDescriptor().getMessageTypes().get(2); - internal_static_org_apache_dubbo_common_serialize_protobuf_model_PhoneNumber_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_org_apache_dubbo_common_serialize_protobuf_model_PhoneNumber_descriptor, - new String[] { "Number", "Type", }); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/MetadataUtil.java b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/MetadataUtil.java new file mode 100644 index 0000000..6418571 --- /dev/null +++ b/dubbo-metadata/dubbo-metadata-api/src/main/java/org/apache/dubbo/metadata/MetadataUtil.java @@ -0,0 +1,33 @@ +package org.apache.dubbo.metadata; + +/** + * FIXME + * 2019-07-31 + */ +public class MetadataUtil { + +// public static String getMetadataKey(URL url, KeyTypeEnum keyType){ +// +// } +// +// private String getIdentifierKey() { +// return serviceInterface +// + SEPARATOR + (version == null ? "" : version) +// + SEPARATOR + (group == null ? "" : group) +// + SEPARATOR + (side == null ? "" : side) +// + SEPARATOR + application; +// } +// +// private String getFilePathKey() { +// return getFilePathKey(DEFAULT_PATH_TAG); +// } +// +// private String getFilePathKey(String pathTag) { +// return pathTag +// + (StringUtils.isEmpty(toServicePath()) ? "" : (PATH_SEPARATOR + toServicePath())) +// + (version == null ? "" : (PATH_SEPARATOR + version)) +// + (group == null ? "" : (PATH_SEPARATOR + group)) +// + (side == null ? "" : (PATH_SEPARATOR + side)) +// + (getApplication() == null ? "" : (PATH_SEPARATOR + getApplication())); +// } +} diff --git a/dubbo-metadata/dubbo-metadata-report-etcd/src/main/java/org/apache/dubbo/metadata/store/etcd/EtcdMetadataReport.java b/dubbo-metadata/dubbo-metadata-report-etcd/src/main/java/org/apache/dubbo/metadata/store/etcd/EtcdMetadataReport.java index 25d58c6..d01e02d 100644 --- a/dubbo-metadata/dubbo-metadata-report-etcd/src/main/java/org/apache/dubbo/metadata/store/etcd/EtcdMetadataReport.java +++ b/dubbo-metadata/dubbo-metadata-report-etcd/src/main/java/org/apache/dubbo/metadata/store/etcd/EtcdMetadataReport.java @@ -84,8 +84,7 @@ public class EtcdMetadataReport extends AbstractMetadataReport { @Override protected void doSaveMetadata(URL url) { - -// storeMetadata(consumerMetadataIdentifier, url.toFullString()); + throw new UnsupportedOperationException("This extension does not support working as a remote metadata center."); } @Override diff --git a/dubbo-registry/dubbo-registry-consul/src/main/java/org/apache/dubbo/registry/consul/AbstractConsulRegistry.java b/dubbo-registry/dubbo-registry-consul/src/main/java/org/apache/dubbo/registry/consul/AbstractConsulRegistry.java new file mode 100644 index 0000000..b8de1a8 --- /dev/null +++ b/dubbo-registry/dubbo-registry-consul/src/main/java/org/apache/dubbo/registry/consul/AbstractConsulRegistry.java @@ -0,0 +1,27 @@ +package org.apache.dubbo.registry.consul; + +import org.apache.dubbo.common.URL; + +import com.ecwid.consul.v1.agent.model.NewService; + +/** + * @author cvictory ON 2019-08-02 + */ +public class AbstractConsulRegistry { + + static final String SERVICE_TAG = "dubbo"; + static final String URL_META_KEY = "url"; + static final String WATCH_TIMEOUT = "consul-watch-timeout"; + static final String CHECK_PASS_INTERVAL = "consul-check-pass-interval"; + static final String DEREGISTER_AFTER = "consul-deregister-critical-service-after"; + + static final int DEFAULT_PORT = 8500; + // default watch timeout in millisecond + static final int DEFAULT_WATCH_TIMEOUT = 60 * 1000; + // default time-to-live in millisecond + static final long DEFAULT_CHECK_PASS_INTERVAL = 16000L; + // default deregister critical server after + static final String DEFAULT_DEREGISTER_TIME = "20s"; + + +} diff --git a/dubbo-registry/dubbo-registry-consul/src/main/java/org/apache/dubbo/registry/consul/ConsulRegistry.java b/dubbo-registry/dubbo-registry-consul/src/main/java/org/apache/dubbo/registry/consul/ConsulRegistry.java index e4832ac..0aae184 100644 --- a/dubbo-registry/dubbo-registry-consul/src/main/java/org/apache/dubbo/registry/consul/ConsulRegistry.java +++ b/dubbo-registry/dubbo-registry-consul/src/main/java/org/apache/dubbo/registry/consul/ConsulRegistry.java @@ -55,6 +55,15 @@ import static org.apache.dubbo.common.constants.RegistryConstants.CATEGORY_KEY; import static org.apache.dubbo.common.constants.RegistryConstants.EMPTY_PROTOCOL; import static org.apache.dubbo.registry.Constants.CONSUMER_PROTOCOL; import static org.apache.dubbo.registry.Constants.PROVIDER_PROTOCOL; +import static org.apache.dubbo.registry.consul.AbstractConsulRegistry.CHECK_PASS_INTERVAL; +import static org.apache.dubbo.registry.consul.AbstractConsulRegistry.DEFAULT_CHECK_PASS_INTERVAL; +import static org.apache.dubbo.registry.consul.AbstractConsulRegistry.DEFAULT_DEREGISTER_TIME; +import static org.apache.dubbo.registry.consul.AbstractConsulRegistry.DEFAULT_PORT; +import static org.apache.dubbo.registry.consul.AbstractConsulRegistry.DEFAULT_WATCH_TIMEOUT; +import static org.apache.dubbo.registry.consul.AbstractConsulRegistry.DEREGISTER_AFTER; +import static org.apache.dubbo.registry.consul.AbstractConsulRegistry.SERVICE_TAG; +import static org.apache.dubbo.registry.consul.AbstractConsulRegistry.URL_META_KEY; +import static org.apache.dubbo.registry.consul.AbstractConsulRegistry.WATCH_TIMEOUT; /** * registry center implementation for consul @@ -62,20 +71,6 @@ import static org.apache.dubbo.registry.Constants.PROVIDER_PROTOCOL; public class ConsulRegistry extends FailbackRegistry { private static final Logger logger = LoggerFactory.getLogger(ConsulRegistry.class); - private static final String SERVICE_TAG = "dubbo"; - private static final String URL_META_KEY = "url"; - private static final String WATCH_TIMEOUT = "consul-watch-timeout"; - private static final String CHECK_PASS_INTERVAL = "consul-check-pass-interval"; - private static final String DEREGISTER_AFTER = "consul-deregister-critical-service-after"; - - private static final int DEFAULT_PORT = 8500; - // default watch timeout in millisecond - private static final int DEFAULT_WATCH_TIMEOUT = 60 * 1000; - // default time-to-live in millisecond - private static final long DEFAULT_CHECK_PASS_INTERVAL = 16000L; - // default deregister critical server after - private static final String DEFAULT_DEREGISTER_TIME = "20s"; - private ConsulClient client; private long checkPassInterval; private ExecutorService notifierExecutor = newCachedThreadPool( diff --git a/dubbo-registry/dubbo-registry-consul/src/main/java/org/apache/dubbo/registry/consul/ConsulServiceDiscovery.java b/dubbo-registry/dubbo-registry-consul/src/main/java/org/apache/dubbo/registry/consul/ConsulServiceDiscovery.java new file mode 100644 index 0000000..17925e7 --- /dev/null +++ b/dubbo-registry/dubbo-registry-consul/src/main/java/org/apache/dubbo/registry/consul/ConsulServiceDiscovery.java @@ -0,0 +1,196 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dubbo.registry.consul; + +import org.apache.dubbo.common.URL; +import org.apache.dubbo.common.utils.NamedThreadFactory; +import org.apache.dubbo.event.EventDispatcher; +import org.apache.dubbo.event.EventListener; +import org.apache.dubbo.registry.NotifyListener; +import org.apache.dubbo.registry.client.ServiceDiscovery; +import org.apache.dubbo.registry.client.ServiceInstance; +import org.apache.dubbo.registry.client.event.ServiceInstancesChangedEvent; +import org.apache.dubbo.registry.client.event.listener.ServiceInstancesChangedListener; + +import com.ecwid.consul.v1.ConsulClient; +import com.ecwid.consul.v1.Response; +import com.ecwid.consul.v1.agent.model.NewService; +import com.ecwid.consul.v1.health.model.HealthService; + +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +import static java.util.concurrent.Executors.newCachedThreadPool; +import static org.apache.dubbo.common.constants.CommonConstants.ANY_VALUE; +import static org.apache.dubbo.registry.consul.AbstractConsulRegistry.CHECK_PASS_INTERVAL; +import static org.apache.dubbo.registry.consul.AbstractConsulRegistry.DEFAULT_CHECK_PASS_INTERVAL; +import static org.apache.dubbo.registry.consul.AbstractConsulRegistry.DEFAULT_DEREGISTER_TIME; +import static org.apache.dubbo.registry.consul.AbstractConsulRegistry.DEFAULT_PORT; +import static org.apache.dubbo.registry.consul.AbstractConsulRegistry.DEFAULT_WATCH_TIMEOUT; +import static org.apache.dubbo.registry.consul.AbstractConsulRegistry.DEREGISTER_AFTER; +import static org.apache.dubbo.registry.consul.AbstractConsulRegistry.SERVICE_TAG; +import static org.apache.dubbo.registry.consul.AbstractConsulRegistry.URL_META_KEY; +import static org.apache.dubbo.registry.consul.AbstractConsulRegistry.WATCH_TIMEOUT; + +/** + * 2019-07-31 + */ +public class ConsulServiceDiscovery implements ServiceDiscovery, EventListener<ServiceInstancesChangedEvent> { + + private ConsulClient client; + private long checkPassInterval; + private ExecutorService notifierExecutor = newCachedThreadPool( + new NamedThreadFactory("dubbo-consul-notifier", true)); + private ScheduledExecutorService ttlConsulCheckExecutor; + + + public ConsulServiceDiscovery(URL url) { + String host = url.getHost(); + int port = url.getPort() != 0 ? url.getPort() : DEFAULT_PORT; + client = new ConsulClient(host, port); + checkPassInterval = url.getParameter(CHECK_PASS_INTERVAL, DEFAULT_CHECK_PASS_INTERVAL); + ttlConsulCheckExecutor = Executors.newSingleThreadScheduledExecutor(); +// ttlConsulCheckExecutor.scheduleAtFixedRate(this::checkPass, checkPassInterval / 8, +// checkPassInterval / 8, TimeUnit.MILLISECONDS); + } + + @Override + public void onEvent(ServiceInstancesChangedEvent event) { + + } + + @Override + public void start() { + + } + + @Override + public void stop() { + + } + + @Override + public void register(ServiceInstance serviceInstance) throws RuntimeException { + client.agentServiceRegister(buildService(serviceInstance)); + } + + @Override + public void update(ServiceInstance serviceInstance) throws RuntimeException { + + } + + @Override + public void unregister(ServiceInstance serviceInstance) throws RuntimeException { + client.agentServiceDeregister(buildId(serviceInstance)); + } + + @Override + public Set<String> getServices() { + return null; + } + + @Override + public void addServiceInstancesChangedListener(String serviceName, ServiceInstancesChangedListener listener) throws NullPointerException, IllegalArgumentException { + + } + + private NewService buildService(ServiceInstance serviceInstance) { + NewService service = new NewService(); + service.setAddress(serviceInstance.getHost()); + service.setPort(serviceInstance.getPort()); + service.setId(buildId(serviceInstance)); + service.setName(serviceInstance.getServiceName()); + service.setCheck(buildCheck(serviceInstance)); + service.setTags(buildTags(serviceInstance)); + service.setMeta(Collections.singletonMap(URL_META_KEY, serviceInstance.toString())); + return service; + } + + private String buildId(ServiceInstance serviceInstance) { + // let's simply use url's hashcode to generate unique service id for now + return Integer.toHexString(serviceInstance.hashCode()); + } + + private List<String> buildTags(ServiceInstance serviceInstance) { + Map<String, String> params = serviceInstance.getMetadata(); + List<String> tags = params.keySet().stream() + .map(k -> k + "=" + params.get(k)) + .collect(Collectors.toList()); + tags.add(SERVICE_TAG); + return tags; + } + + private NewService.Check buildCheck(ServiceInstance serviceInstance) { + NewService.Check check = new NewService.Check(); + check.setTtl((checkPassInterval / 1000) + "s"); + String deregister = serviceInstance.getMetadata().get(DEREGISTER_AFTER); + check.setDeregisterCriticalServiceAfter(deregister == null ? DEFAULT_DEREGISTER_TIME : deregister); + + return check; + } + + private int buildWatchTimeout(URL url) { + return url.getParameter(WATCH_TIMEOUT, DEFAULT_WATCH_TIMEOUT) / 1000; + } + + + private class ConsulNotifier implements Runnable { + private ServiceInstance serviceInstance; + private long consulIndex; + private boolean running; + + ConsulNotifier(ServiceInstance serviceInstance, long consulIndex) { + this.serviceInstance = serviceInstance; + this.consulIndex = consulIndex; + this.running = true; + } + + @Override + public void run() { + while (this.running) { + processService(); + } + } + + private void processService() { + String service = url.getServiceKey(); + Response<List<HealthService>> response = getHealthServices(service, consulIndex, buildWatchTimeout(url)); + Long currentIndex = response.getConsulIndex(); + if (currentIndex != null && currentIndex > consulIndex) { + consulIndex = currentIndex; + List<HealthService> services = response.getValue(); + List<URL> urls = convert(services, url); + for (NotifyListener listener : getSubscribed().get(url)) { + doNotify(url, listener, urls); + } + } + } + + void stop() { + this.running = false; + } + } +} diff --git a/dubbo-metadata-report/dubbo-metadata-definition-protobuf/src/test/java/org/apache/dubbo/metadata/definition/protobuf/model/ServiceInterface.java b/dubbo-registry/dubbo-registry-consul/src/main/java/org/apache/dubbo/registry/consul/ConsulServiceDiscoveryFactory.java similarity index 64% rename from dubbo-metadata-report/dubbo-metadata-definition-protobuf/src/test/java/org/apache/dubbo/metadata/definition/protobuf/model/ServiceInterface.java rename to dubbo-registry/dubbo-registry-consul/src/main/java/org/apache/dubbo/registry/consul/ConsulServiceDiscoveryFactory.java index 9c4f234..189642b 100644 --- a/dubbo-metadata-report/dubbo-metadata-definition-protobuf/src/test/java/org/apache/dubbo/metadata/definition/protobuf/model/ServiceInterface.java +++ b/dubbo-registry/dubbo-registry-consul/src/main/java/org/apache/dubbo/registry/consul/ConsulServiceDiscoveryFactory.java @@ -14,8 +14,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.dubbo.metadata.definition.protobuf.model; +package org.apache.dubbo.registry.consul; -public interface ServiceInterface { - GooglePB.PBResponseType sayHello(GooglePB.PBRequestType requestType); +import org.apache.dubbo.common.URL; +import org.apache.dubbo.registry.client.ServiceDiscovery; +import org.apache.dubbo.registry.client.ServiceDiscoveryFactory; + +/** + * 2019-07-31 + */ +public class ConsulServiceDiscoveryFactory implements ServiceDiscoveryFactory { + @Override + public ServiceDiscovery create(URL connectionURL) { + return new ConsulServiceDiscovery(connectionURL); + } } diff --git a/dubbo-registry/dubbo-registry-etcd3/src/main/java/org/apache/dubbo/registry/etcd/EtcdServiceDiscovery.java b/dubbo-registry/dubbo-registry-etcd3/src/main/java/org/apache/dubbo/registry/etcd/EtcdServiceDiscovery.java index 4cce645..a684c2c 100644 --- a/dubbo-registry/dubbo-registry-etcd3/src/main/java/org/apache/dubbo/registry/etcd/EtcdServiceDiscovery.java +++ b/dubbo-registry/dubbo-registry-etcd3/src/main/java/org/apache/dubbo/registry/etcd/EtcdServiceDiscovery.java @@ -38,17 +38,12 @@ import com.google.gson.Gson; import java.io.File; import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; -import static org.apache.dubbo.common.constants.RegistryConstants.DYNAMIC_KEY; - /** * 2019-07-08 */ @@ -174,11 +169,8 @@ public class EtcdServiceDiscovery implements ServiceDiscovery, EventListener<Ser }); etcdClient.create(path); - /* - * at the first time, we want to pull already category and then watch their direct children, - * eg: /dubbo/interface/providers, /dubbo/interface/consumers and so on. - */ - List<String> children = etcdClient.addChildListener(path, childListener); + + etcdClient.addChildListener(path, childListener); } private void recover() throws Exception {