summaryrefslogtreecommitdiff
path: root/same
diff options
context:
space:
mode:
Diffstat (limited to 'same')
-rw-r--r--same/src/main/java/com/orbekk/same/Client.java101
-rw-r--r--same/src/main/java/com/orbekk/same/ClientService.java2
-rw-r--r--same/src/main/java/com/orbekk/same/Services.java1789
-rw-r--r--same/src/main/java/com/orbekk/same/benchmark/Example.java290
-rw-r--r--same/src/main/java/com/orbekk/same/services.proto24
-rw-r--r--same/src/test/java/com/orbekk/same/ClientTest.java10
-rw-r--r--same/src/test/java/com/orbekk/same/MasterTest.java6
7 files changed, 2087 insertions, 135 deletions
diff --git a/same/src/main/java/com/orbekk/same/Client.java b/same/src/main/java/com/orbekk/same/Client.java
index 53d0ac8..704dc8e 100644
--- a/same/src/main/java/com/orbekk/same/Client.java
+++ b/same/src/main/java/com/orbekk/same/Client.java
@@ -11,7 +11,11 @@ import java.util.concurrent.Future;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.protobuf.RpcCallback;
+import com.google.protobuf.RpcController;
import com.orbekk.paxos.MasterProposer;
+import com.orbekk.same.Services.Empty;
+import com.orbekk.same.Services.MasterState;
import com.orbekk.same.State.Component;
import com.orbekk.util.DelayedOperation;
import com.orbekk.util.WorkQueue;
@@ -94,58 +98,87 @@ public class Client {
private ClientInterface clientInterface = new ClientInterfaceImpl();
- private ClientService serviceImpl = new ClientService() {
- @Override
- public void setState(String component, String data, long revision) throws Exception {
- boolean status = state.update(component, data, revision);
+ private Services.Client newServiceImpl = new Services.Client() {
+ @Override public void setState(RpcController controller,
+ Services.Component request, RpcCallback<Empty> done) {
+ boolean status = state.update(request.getId(), request.getData(),
+ request.getRevision());
if (status) {
for (StateChangedListener listener : stateListeners) {
- listener.stateChanged(state.getComponent(component));
+ listener.stateChanged(state.getComponent(request.getId()));
}
} else {
logger.warn("Ignoring update: {) => {}",
- state.getComponent(component),
- new State.Component(component, revision, data));
- }
- }
-
- @Override
- public void notifyNetwork(String networkName, String masterUrl) throws Exception {
- logger.info("NotifyNetwork(networkName={}, masterUrl={})",
- networkName, masterUrl);
- if (networkListener != null) {
- networkListener.notifyNetwork(networkName, masterUrl);
- }
+ state.getComponent(request.getId()),
+ new State.Component(request.getId(), request.getRevision(),
+ request.getData()));
+ }
}
- @Override
- public synchronized void masterTakeover(String masterUrl, String networkName,
- int masterId) throws Exception {
- logger.info("MasterTakeover({}, {}, {})",
- new Object[]{masterUrl, networkName, masterId});
- if (masterId <= Client.this.masterId) {
- logger.warn("{}:{} tried to take over, but current master is " +
- "{}:{}. Ignoring", new Object[]{masterUrl, masterId,
- state.getDataOf(".masterUrl"),
- Client.this.masterId});
+ @Override public void masterTakeover(RpcController controller,
+ MasterState request, RpcCallback<Empty> done) {
+ logger.info("MasterTakeover({})", request);
+ if (request.getMasterId() <= Client.this.masterId) {
+ logger.warn("{} tried to take over, but current master is " +
+ "{}:{}. Ignoring", new Object[]{request,
+ state.getDataOf(".masterUrl"),
+ Client.this.masterId});
return;
}
abortMasterElection();
- Client.this.masterUrl = masterUrl;
- Client.this.masterId = masterId;
+ Client.this.masterUrl = request.getMasterUrl();
+ Client.this.masterId = request.getMasterId();
connectionState = ConnectionState.STABLE;
}
- @Override
- public void masterDown(int masterId) throws Exception {
- if (masterId < Client.this.masterId) {
+ @Override public void masterDown(RpcController controller, MasterState request,
+ RpcCallback<Empty> done) {
+ if (request.getMasterId() < Client.this.masterId) {
logger.info("Master {} is down, but current master is {}. Ignoring.",
- masterId, Client.this.masterId);
+ request.getMasterId(), Client.this.masterId);
return;
}
logger.warn("Master down.");
connectionState = ConnectionState.UNSTABLE;
- tryBecomeMaster(masterId);
+ tryBecomeMaster(request.getMasterId());
+ }
+ };
+
+ private ClientService serviceImpl = new ClientService() {
+ RpcCallback<Empty> noOp = new RpcCallback<Empty>() {
+ @Override public void run(Empty unused) {
+ }
+ };
+
+ @Override
+ public void setState(String component, String data, long revision) throws Exception {
+ Services.Component request = Services.Component.newBuilder()
+ .setId(component)
+ .setData(data)
+ .setRevision(revision)
+ .build();
+ newServiceImpl.setState(null, request, noOp);
+ }
+
+ @Override
+ public synchronized void masterTakeover(String masterUrl, String networkName,
+ int masterId) throws Exception {
+ Services.MasterState request = Services.MasterState.newBuilder()
+ .setMasterUrl(masterUrl)
+ .setNetworkName(networkName)
+ .setMasterId(masterId)
+ .build();
+ newServiceImpl.masterTakeover(null, request, noOp);
+ }
+
+ @Override
+ public void masterDown(int masterId) throws Exception {
+ Services.MasterState request = Services.MasterState.newBuilder()
+ .setMasterUrl(masterUrl)
+ .setNetworkName(state.getDataOf(".networkName"))
+ .setMasterId(masterId)
+ .build();
+ newServiceImpl.masterDown(null, request, noOp);
}
};
diff --git a/same/src/main/java/com/orbekk/same/ClientService.java b/same/src/main/java/com/orbekk/same/ClientService.java
index 8d460db..97215e0 100644
--- a/same/src/main/java/com/orbekk/same/ClientService.java
+++ b/same/src/main/java/com/orbekk/same/ClientService.java
@@ -1,8 +1,6 @@
package com.orbekk.same;
public interface ClientService {
- void notifyNetwork(String networkName, String masterUrl) throws Exception;
-
void setState(String component, String data, long revision) throws Exception;
/** A new master takes over.
diff --git a/same/src/main/java/com/orbekk/same/Services.java b/same/src/main/java/com/orbekk/same/Services.java
new file mode 100644
index 0000000..90017a6
--- /dev/null
+++ b/same/src/main/java/com/orbekk/same/Services.java
@@ -0,0 +1,1789 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: src/main/java/com/orbekk/same/services.proto
+
+package com.orbekk.same;
+
+public final class Services {
+ private Services() {}
+ public static void registerAllExtensions(
+ com.google.protobuf.ExtensionRegistry registry) {
+ }
+ public interface EmptyOrBuilder
+ extends com.google.protobuf.MessageOrBuilder {
+ }
+ public static final class Empty extends
+ com.google.protobuf.GeneratedMessage
+ implements EmptyOrBuilder {
+ // Use Empty.newBuilder() to construct.
+ private Empty(Builder builder) {
+ super(builder);
+ }
+ private Empty(boolean noInit) {}
+
+ private static final Empty defaultInstance;
+ public static Empty getDefaultInstance() {
+ return defaultInstance;
+ }
+
+ public Empty getDefaultInstanceForType() {
+ return defaultInstance;
+ }
+
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return com.orbekk.same.Services.internal_static_com_orbekk_same_Empty_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return com.orbekk.same.Services.internal_static_com_orbekk_same_Empty_fieldAccessorTable;
+ }
+
+ private void initFields() {
+ }
+ private byte memoizedIsInitialized = -1;
+ public final boolean isInitialized() {
+ byte isInitialized = memoizedIsInitialized;
+ if (isInitialized != -1) return isInitialized == 1;
+
+ memoizedIsInitialized = 1;
+ return true;
+ }
+
+ public void writeTo(com.google.protobuf.CodedOutputStream output)
+ throws java.io.IOException {
+ getSerializedSize();
+ getUnknownFields().writeTo(output);
+ }
+
+ private int memoizedSerializedSize = -1;
+ public int getSerializedSize() {
+ int size = memoizedSerializedSize;
+ if (size != -1) return size;
+
+ size = 0;
+ size += getUnknownFields().getSerializedSize();
+ memoizedSerializedSize = size;
+ return size;
+ }
+
+ private static final long serialVersionUID = 0L;
+ @java.lang.Override
+ protected java.lang.Object writeReplace()
+ throws java.io.ObjectStreamException {
+ return super.writeReplace();
+ }
+
+ public static com.orbekk.same.Services.Empty parseFrom(
+ com.google.protobuf.ByteString data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data).buildParsed();
+ }
+ public static com.orbekk.same.Services.Empty parseFrom(
+ com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data, extensionRegistry)
+ .buildParsed();
+ }
+ public static com.orbekk.same.Services.Empty parseFrom(byte[] data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data).buildParsed();
+ }
+ public static com.orbekk.same.Services.Empty parseFrom(
+ byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data, extensionRegistry)
+ .buildParsed();
+ }
+ public static com.orbekk.same.Services.Empty parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input).buildParsed();
+ }
+ public static com.orbekk.same.Services.Empty parseFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input, extensionRegistry)
+ .buildParsed();
+ }
+ public static com.orbekk.same.Services.Empty parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ Builder builder = newBuilder();
+ if (builder.mergeDelimitedFrom(input)) {
+ return builder.buildParsed();
+ } else {
+ return null;
+ }
+ }
+ public static com.orbekk.same.Services.Empty parseDelimitedFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ Builder builder = newBuilder();
+ if (builder.mergeDelimitedFrom(input, extensionRegistry)) {
+ return builder.buildParsed();
+ } else {
+ return null;
+ }
+ }
+ public static com.orbekk.same.Services.Empty parseFrom(
+ com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input).buildParsed();
+ }
+ public static com.orbekk.same.Services.Empty parseFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input, extensionRegistry)
+ .buildParsed();
+ }
+
+ public static Builder newBuilder() { return Builder.create(); }
+ public Builder newBuilderForType() { return newBuilder(); }
+ public static Builder newBuilder(com.orbekk.same.Services.Empty prototype) {
+ return newBuilder().mergeFrom(prototype);
+ }
+ public Builder toBuilder() { return newBuilder(this); }
+
+ @java.lang.Override
+ protected Builder newBuilderForType(
+ com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+ Builder builder = new Builder(parent);
+ return builder;
+ }
+ public static final class Builder extends
+ com.google.protobuf.GeneratedMessage.Builder<Builder>
+ implements com.orbekk.same.Services.EmptyOrBuilder {
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return com.orbekk.same.Services.internal_static_com_orbekk_same_Empty_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return com.orbekk.same.Services.internal_static_com_orbekk_same_Empty_fieldAccessorTable;
+ }
+
+ // Construct using com.orbekk.same.Services.Empty.newBuilder()
+ private Builder() {
+ maybeForceBuilderInitialization();
+ }
+
+ private Builder(BuilderParent parent) {
+ super(parent);
+ maybeForceBuilderInitialization();
+ }
+ private void maybeForceBuilderInitialization() {
+ if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
+ }
+ }
+ private static Builder create() {
+ return new Builder();
+ }
+
+ public Builder clear() {
+ super.clear();
+ return this;
+ }
+
+ public Builder clone() {
+ return create().mergeFrom(buildPartial());
+ }
+
+ public com.google.protobuf.Descriptors.Descriptor
+ getDescriptorForType() {
+ return com.orbekk.same.Services.Empty.getDescriptor();
+ }
+
+ public com.orbekk.same.Services.Empty getDefaultInstanceForType() {
+ return com.orbekk.same.Services.Empty.getDefaultInstance();
+ }
+
+ public com.orbekk.same.Services.Empty build() {
+ com.orbekk.same.Services.Empty result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return result;
+ }
+
+ private com.orbekk.same.Services.Empty buildParsed()
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ com.orbekk.same.Services.Empty result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(
+ result).asInvalidProtocolBufferException();
+ }
+ return result;
+ }
+
+ public com.orbekk.same.Services.Empty buildPartial() {
+ com.orbekk.same.Services.Empty result = new com.orbekk.same.Services.Empty(this);
+ onBuilt();
+ return result;
+ }
+
+ public Builder mergeFrom(com.google.protobuf.Message other) {
+ if (other instanceof com.orbekk.same.Services.Empty) {
+ return mergeFrom((com.orbekk.same.Services.Empty)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(com.orbekk.same.Services.Empty other) {
+ if (other == com.orbekk.same.Services.Empty.getDefaultInstance()) return this;
+ this.mergeUnknownFields(other.getUnknownFields());
+ return this;
+ }
+
+ public final boolean isInitialized() {
+ return true;
+ }
+
+ public Builder mergeFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ com.google.protobuf.UnknownFieldSet.Builder unknownFields =
+ com.google.protobuf.UnknownFieldSet.newBuilder(
+ this.getUnknownFields());
+ while (true) {
+ int tag = input.readTag();
+ switch (tag) {
+ case 0:
+ this.setUnknownFields(unknownFields.build());
+ onChanged();
+ return this;
+ default: {
+ if (!parseUnknownField(input, unknownFields,
+ extensionRegistry, tag)) {
+ this.setUnknownFields(unknownFields.build());
+ onChanged();
+ return this;
+ }
+ break;
+ }
+ }
+ }
+ }
+
+
+ // @@protoc_insertion_point(builder_scope:com.orbekk.same.Empty)
+ }
+
+ static {
+ defaultInstance = new Empty(true);
+ defaultInstance.initFields();
+ }
+
+ // @@protoc_insertion_point(class_scope:com.orbekk.same.Empty)
+ }
+
+ public interface ComponentOrBuilder
+ extends com.google.protobuf.MessageOrBuilder {
+
+ // required string id = 1;
+ boolean hasId();
+ String getId();
+
+ // required string data = 2;
+ boolean hasData();
+ String getData();
+
+ // required int64 revision = 3;
+ boolean hasRevision();
+ long getRevision();
+ }
+ public static final class Component extends
+ com.google.protobuf.GeneratedMessage
+ implements ComponentOrBuilder {
+ // Use Component.newBuilder() to construct.
+ private Component(Builder builder) {
+ super(builder);
+ }
+ private Component(boolean noInit) {}
+
+ private static final Component defaultInstance;
+ public static Component getDefaultInstance() {
+ return defaultInstance;
+ }
+
+ public Component getDefaultInstanceForType() {
+ return defaultInstance;
+ }
+
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return com.orbekk.same.Services.internal_static_com_orbekk_same_Component_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return com.orbekk.same.Services.internal_static_com_orbekk_same_Component_fieldAccessorTable;
+ }
+
+ private int bitField0_;
+ // required string id = 1;
+ public static final int ID_FIELD_NUMBER = 1;
+ private java.lang.Object id_;
+ public boolean hasId() {
+ return ((bitField0_ & 0x00000001) == 0x00000001);
+ }
+ public String getId() {
+ java.lang.Object ref = id_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ if (com.google.protobuf.Internal.isValidUtf8(bs)) {
+ id_ = s;
+ }
+ return s;
+ }
+ }
+ private com.google.protobuf.ByteString getIdBytes() {
+ java.lang.Object ref = id_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8((String) ref);
+ id_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ // required string data = 2;
+ public static final int DATA_FIELD_NUMBER = 2;
+ private java.lang.Object data_;
+ public boolean hasData() {
+ return ((bitField0_ & 0x00000002) == 0x00000002);
+ }
+ public String getData() {
+ java.lang.Object ref = data_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ if (com.google.protobuf.Internal.isValidUtf8(bs)) {
+ data_ = s;
+ }
+ return s;
+ }
+ }
+ private com.google.protobuf.ByteString getDataBytes() {
+ java.lang.Object ref = data_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8((String) ref);
+ data_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ // required int64 revision = 3;
+ public static final int REVISION_FIELD_NUMBER = 3;
+ private long revision_;
+ public boolean hasRevision() {
+ return ((bitField0_ & 0x00000004) == 0x00000004);
+ }
+ public long getRevision() {
+ return revision_;
+ }
+
+ private void initFields() {
+ id_ = "";
+ data_ = "";
+ revision_ = 0L;
+ }
+ private byte memoizedIsInitialized = -1;
+ public final boolean isInitialized() {
+ byte isInitialized = memoizedIsInitialized;
+ if (isInitialized != -1) return isInitialized == 1;
+
+ if (!hasId()) {
+ memoizedIsInitialized = 0;
+ return false;
+ }
+ if (!hasData()) {
+ memoizedIsInitialized = 0;
+ return false;
+ }
+ if (!hasRevision()) {
+ memoizedIsInitialized = 0;
+ return false;
+ }
+ memoizedIsInitialized = 1;
+ return true;
+ }
+
+ public void writeTo(com.google.protobuf.CodedOutputStream output)
+ throws java.io.IOException {
+ getSerializedSize();
+ if (((bitField0_ & 0x00000001) == 0x00000001)) {
+ output.writeBytes(1, getIdBytes());
+ }
+ if (((bitField0_ & 0x00000002) == 0x00000002)) {
+ output.writeBytes(2, getDataBytes());
+ }
+ if (((bitField0_ & 0x00000004) == 0x00000004)) {
+ output.writeInt64(3, revision_);
+ }
+ getUnknownFields().writeTo(output);
+ }
+
+ private int memoizedSerializedSize = -1;
+ public int getSerializedSize() {
+ int size = memoizedSerializedSize;
+ if (size != -1) return size;
+
+ size = 0;
+ if (((bitField0_ & 0x00000001) == 0x00000001)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeBytesSize(1, getIdBytes());
+ }
+ if (((bitField0_ & 0x00000002) == 0x00000002)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeBytesSize(2, getDataBytes());
+ }
+ if (((bitField0_ & 0x00000004) == 0x00000004)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeInt64Size(3, revision_);
+ }
+ size += getUnknownFields().getSerializedSize();
+ memoizedSerializedSize = size;
+ return size;
+ }
+
+ private static final long serialVersionUID = 0L;
+ @java.lang.Override
+ protected java.lang.Object writeReplace()
+ throws java.io.ObjectStreamException {
+ return super.writeReplace();
+ }
+
+ public static com.orbekk.same.Services.Component parseFrom(
+ com.google.protobuf.ByteString data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data).buildParsed();
+ }
+ public static com.orbekk.same.Services.Component parseFrom(
+ com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data, extensionRegistry)
+ .buildParsed();
+ }
+ public static com.orbekk.same.Services.Component parseFrom(byte[] data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data).buildParsed();
+ }
+ public static com.orbekk.same.Services.Component parseFrom(
+ byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data, extensionRegistry)
+ .buildParsed();
+ }
+ public static com.orbekk.same.Services.Component parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input).buildParsed();
+ }
+ public static com.orbekk.same.Services.Component parseFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input, extensionRegistry)
+ .buildParsed();
+ }
+ public static com.orbekk.same.Services.Component parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ Builder builder = newBuilder();
+ if (builder.mergeDelimitedFrom(input)) {
+ return builder.buildParsed();
+ } else {
+ return null;
+ }
+ }
+ public static com.orbekk.same.Services.Component parseDelimitedFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ Builder builder = newBuilder();
+ if (builder.mergeDelimitedFrom(input, extensionRegistry)) {
+ return builder.buildParsed();
+ } else {
+ return null;
+ }
+ }
+ public static com.orbekk.same.Services.Component parseFrom(
+ com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input).buildParsed();
+ }
+ public static com.orbekk.same.Services.Component parseFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input, extensionRegistry)
+ .buildParsed();
+ }
+
+ public static Builder newBuilder() { return Builder.create(); }
+ public Builder newBuilderForType() { return newBuilder(); }
+ public static Builder newBuilder(com.orbekk.same.Services.Component prototype) {
+ return newBuilder().mergeFrom(prototype);
+ }
+ public Builder toBuilder() { return newBuilder(this); }
+
+ @java.lang.Override
+ protected Builder newBuilderForType(
+ com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+ Builder builder = new Builder(parent);
+ return builder;
+ }
+ public static final class Builder extends
+ com.google.protobuf.GeneratedMessage.Builder<Builder>
+ implements com.orbekk.same.Services.ComponentOrBuilder {
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return com.orbekk.same.Services.internal_static_com_orbekk_same_Component_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return com.orbekk.same.Services.internal_static_com_orbekk_same_Component_fieldAccessorTable;
+ }
+
+ // Construct using com.orbekk.same.Services.Component.newBuilder()
+ private Builder() {
+ maybeForceBuilderInitialization();
+ }
+
+ private Builder(BuilderParent parent) {
+ super(parent);
+ maybeForceBuilderInitialization();
+ }
+ private void maybeForceBuilderInitialization() {
+ if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
+ }
+ }
+ private static Builder create() {
+ return new Builder();
+ }
+
+ public Builder clear() {
+ super.clear();
+ id_ = "";
+ bitField0_ = (bitField0_ & ~0x00000001);
+ data_ = "";
+ bitField0_ = (bitField0_ & ~0x00000002);
+ revision_ = 0L;
+ bitField0_ = (bitField0_ & ~0x00000004);
+ return this;
+ }
+
+ public Builder clone() {
+ return create().mergeFrom(buildPartial());
+ }
+
+ public com.google.protobuf.Descriptors.Descriptor
+ getDescriptorForType() {
+ return com.orbekk.same.Services.Component.getDescriptor();
+ }
+
+ public com.orbekk.same.Services.Component getDefaultInstanceForType() {
+ return com.orbekk.same.Services.Component.getDefaultInstance();
+ }
+
+ public com.orbekk.same.Services.Component build() {
+ com.orbekk.same.Services.Component result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return result;
+ }
+
+ private com.orbekk.same.Services.Component buildParsed()
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ com.orbekk.same.Services.Component result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(
+ result).asInvalidProtocolBufferException();
+ }
+ return result;
+ }
+
+ public com.orbekk.same.Services.Component buildPartial() {
+ com.orbekk.same.Services.Component result = new com.orbekk.same.Services.Component(this);
+ int from_bitField0_ = bitField0_;
+ int to_bitField0_ = 0;
+ if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
+ to_bitField0_ |= 0x00000001;
+ }
+ result.id_ = id_;
+ if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
+ to_bitField0_ |= 0x00000002;
+ }
+ result.data_ = data_;
+ if (((from_bitField0_ & 0x00000004) == 0x00000004)) {
+ to_bitField0_ |= 0x00000004;
+ }
+ result.revision_ = revision_;
+ result.bitField0_ = to_bitField0_;
+ onBuilt();
+ return result;
+ }
+
+ public Builder mergeFrom(com.google.protobuf.Message other) {
+ if (other instanceof com.orbekk.same.Services.Component) {
+ return mergeFrom((com.orbekk.same.Services.Component)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(com.orbekk.same.Services.Component other) {
+ if (other == com.orbekk.same.Services.Component.getDefaultInstance()) return this;
+ if (other.hasId()) {
+ setId(other.getId());
+ }
+ if (other.hasData()) {
+ setData(other.getData());
+ }
+ if (other.hasRevision()) {
+ setRevision(other.getRevision());
+ }
+ this.mergeUnknownFields(other.getUnknownFields());
+ return this;
+ }
+
+ public final boolean isInitialized() {
+ if (!hasId()) {
+
+ return false;
+ }
+ if (!hasData()) {
+
+ return false;
+ }
+ if (!hasRevision()) {
+
+ return false;
+ }
+ return true;
+ }
+
+ public Builder mergeFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ com.google.protobuf.UnknownFieldSet.Builder unknownFields =
+ com.google.protobuf.UnknownFieldSet.newBuilder(
+ this.getUnknownFields());
+ while (true) {
+ int tag = input.readTag();
+ switch (tag) {
+ case 0:
+ this.setUnknownFields(unknownFields.build());
+ onChanged();
+ return this;
+ default: {
+ if (!parseUnknownField(input, unknownFields,
+ extensionRegistry, tag)) {
+ this.setUnknownFields(unknownFields.build());
+ onChanged();
+ return this;
+ }
+ break;
+ }
+ case 10: {
+ bitField0_ |= 0x00000001;
+ id_ = input.readBytes();
+ break;
+ }
+ case 18: {
+ bitField0_ |= 0x00000002;
+ data_ = input.readBytes();
+ break;
+ }
+ case 24: {
+ bitField0_ |= 0x00000004;
+ revision_ = input.readInt64();
+ break;
+ }
+ }
+ }
+ }
+
+ private int bitField0_;
+
+ // required string id = 1;
+ private java.lang.Object id_ = "";
+ public boolean hasId() {
+ return ((bitField0_ & 0x00000001) == 0x00000001);
+ }
+ public String getId() {
+ java.lang.Object ref = id_;
+ if (!(ref instanceof String)) {
+ String s = ((com.google.protobuf.ByteString) ref).toStringUtf8();
+ id_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ public Builder setId(String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ bitField0_ |= 0x00000001;
+ id_ = value;
+ onChanged();
+ return this;
+ }
+ public Builder clearId() {
+ bitField0_ = (bitField0_ & ~0x00000001);
+ id_ = getDefaultInstance().getId();
+ onChanged();
+ return this;
+ }
+ void setId(com.google.protobuf.ByteString value) {
+ bitField0_ |= 0x00000001;
+ id_ = value;
+ onChanged();
+ }
+
+ // required string data = 2;
+ private java.lang.Object data_ = "";
+ public boolean hasData() {
+ return ((bitField0_ & 0x00000002) == 0x00000002);
+ }
+ public String getData() {
+ java.lang.Object ref = data_;
+ if (!(ref instanceof String)) {
+ String s = ((com.google.protobuf.ByteString) ref).toStringUtf8();
+ data_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ public Builder setData(String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ bitField0_ |= 0x00000002;
+ data_ = value;
+ onChanged();
+ return this;
+ }
+ public Builder clearData() {
+ bitField0_ = (bitField0_ & ~0x00000002);
+ data_ = getDefaultInstance().getData();
+ onChanged();
+ return this;
+ }
+ void setData(com.google.protobuf.ByteString value) {
+ bitField0_ |= 0x00000002;
+ data_ = value;
+ onChanged();
+ }
+
+ // required int64 revision = 3;
+ private long revision_ ;
+ public boolean hasRevision() {
+ return ((bitField0_ & 0x00000004) == 0x00000004);
+ }
+ public long getRevision() {
+ return revision_;
+ }
+ public Builder setRevision(long value) {
+ bitField0_ |= 0x00000004;
+ revision_ = value;
+ onChanged();
+ return this;
+ }
+ public Builder clearRevision() {
+ bitField0_ = (bitField0_ & ~0x00000004);
+ revision_ = 0L;
+ onChanged();
+ return this;
+ }
+
+ // @@protoc_insertion_point(builder_scope:com.orbekk.same.Component)
+ }
+
+ static {
+ defaultInstance = new Component(true);
+ defaultInstance.initFields();
+ }
+
+ // @@protoc_insertion_point(class_scope:com.orbekk.same.Component)
+ }
+
+ public interface MasterStateOrBuilder
+ extends com.google.protobuf.MessageOrBuilder {
+
+ // optional string master_url = 1;
+ boolean hasMasterUrl();
+ String getMasterUrl();
+
+ // optional int32 master_id = 2;
+ boolean hasMasterId();
+ int getMasterId();
+
+ // optional string network_name = 3;
+ boolean hasNetworkName();
+ String getNetworkName();
+ }
+ public static final class MasterState extends
+ com.google.protobuf.GeneratedMessage
+ implements MasterStateOrBuilder {
+ // Use MasterState.newBuilder() to construct.
+ private MasterState(Builder builder) {
+ super(builder);
+ }
+ private MasterState(boolean noInit) {}
+
+ private static final MasterState defaultInstance;
+ public static MasterState getDefaultInstance() {
+ return defaultInstance;
+ }
+
+ public MasterState getDefaultInstanceForType() {
+ return defaultInstance;
+ }
+
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return com.orbekk.same.Services.internal_static_com_orbekk_same_MasterState_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return com.orbekk.same.Services.internal_static_com_orbekk_same_MasterState_fieldAccessorTable;
+ }
+
+ private int bitField0_;
+ // optional string master_url = 1;
+ public static final int MASTER_URL_FIELD_NUMBER = 1;
+ private java.lang.Object masterUrl_;
+ public boolean hasMasterUrl() {
+ return ((bitField0_ & 0x00000001) == 0x00000001);
+ }
+ public String getMasterUrl() {
+ java.lang.Object ref = masterUrl_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ if (com.google.protobuf.Internal.isValidUtf8(bs)) {
+ masterUrl_ = s;
+ }
+ return s;
+ }
+ }
+ private com.google.protobuf.ByteString getMasterUrlBytes() {
+ java.lang.Object ref = masterUrl_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8((String) ref);
+ masterUrl_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ // optional int32 master_id = 2;
+ public static final int MASTER_ID_FIELD_NUMBER = 2;
+ private int masterId_;
+ public boolean hasMasterId() {
+ return ((bitField0_ & 0x00000002) == 0x00000002);
+ }
+ public int getMasterId() {
+ return masterId_;
+ }
+
+ // optional string network_name = 3;
+ public static final int NETWORK_NAME_FIELD_NUMBER = 3;
+ private java.lang.Object networkName_;
+ public boolean hasNetworkName() {
+ return ((bitField0_ & 0x00000004) == 0x00000004);
+ }
+ public String getNetworkName() {
+ java.lang.Object ref = networkName_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ if (com.google.protobuf.Internal.isValidUtf8(bs)) {
+ networkName_ = s;
+ }
+ return s;
+ }
+ }
+ private com.google.protobuf.ByteString getNetworkNameBytes() {
+ java.lang.Object ref = networkName_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8((String) ref);
+ networkName_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ private void initFields() {
+ masterUrl_ = "";
+ masterId_ = 0;
+ networkName_ = "";
+ }
+ private byte memoizedIsInitialized = -1;
+ public final boolean isInitialized() {
+ byte isInitialized = memoizedIsInitialized;
+ if (isInitialized != -1) return isInitialized == 1;
+
+ memoizedIsInitialized = 1;
+ return true;
+ }
+
+ public void writeTo(com.google.protobuf.CodedOutputStream output)
+ throws java.io.IOException {
+ getSerializedSize();
+ if (((bitField0_ & 0x00000001) == 0x00000001)) {
+ output.writeBytes(1, getMasterUrlBytes());
+ }
+ if (((bitField0_ & 0x00000002) == 0x00000002)) {
+ output.writeInt32(2, masterId_);
+ }
+ if (((bitField0_ & 0x00000004) == 0x00000004)) {
+ output.writeBytes(3, getNetworkNameBytes());
+ }
+ getUnknownFields().writeTo(output);
+ }
+
+ private int memoizedSerializedSize = -1;
+ public int getSerializedSize() {
+ int size = memoizedSerializedSize;
+ if (size != -1) return size;
+
+ size = 0;
+ if (((bitField0_ & 0x00000001) == 0x00000001)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeBytesSize(1, getMasterUrlBytes());
+ }
+ if (((bitField0_ & 0x00000002) == 0x00000002)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeInt32Size(2, masterId_);
+ }
+ if (((bitField0_ & 0x00000004) == 0x00000004)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeBytesSize(3, getNetworkNameBytes());
+ }
+ size += getUnknownFields().getSerializedSize();
+ memoizedSerializedSize = size;
+ return size;
+ }
+
+ private static final long serialVersionUID = 0L;
+ @java.lang.Override
+ protected java.lang.Object writeReplace()
+ throws java.io.ObjectStreamException {
+ return super.writeReplace();
+ }
+
+ public static com.orbekk.same.Services.MasterState parseFrom(
+ com.google.protobuf.ByteString data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data).buildParsed();
+ }
+ public static com.orbekk.same.Services.MasterState parseFrom(
+ com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data, extensionRegistry)
+ .buildParsed();
+ }
+ public static com.orbekk.same.Services.MasterState parseFrom(byte[] data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data).buildParsed();
+ }
+ public static com.orbekk.same.Services.MasterState parseFrom(
+ byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data, extensionRegistry)
+ .buildParsed();
+ }
+ public static com.orbekk.same.Services.MasterState parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input).buildParsed();
+ }
+ public static com.orbekk.same.Services.MasterState parseFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input, extensionRegistry)
+ .buildParsed();
+ }
+ public static com.orbekk.same.Services.MasterState parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ Builder builder = newBuilder();
+ if (builder.mergeDelimitedFrom(input)) {
+ return builder.buildParsed();
+ } else {
+ return null;
+ }
+ }
+ public static com.orbekk.same.Services.MasterState parseDelimitedFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ Builder builder = newBuilder();
+ if (builder.mergeDelimitedFrom(input, extensionRegistry)) {
+ return builder.buildParsed();
+ } else {
+ return null;
+ }
+ }
+ public static com.orbekk.same.Services.MasterState parseFrom(
+ com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input).buildParsed();
+ }
+ public static com.orbekk.same.Services.MasterState parseFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input, extensionRegistry)
+ .buildParsed();
+ }
+
+ public static Builder newBuilder() { return Builder.create(); }
+ public Builder newBuilderForType() { return newBuilder(); }
+ public static Builder newBuilder(com.orbekk.same.Services.MasterState prototype) {
+ return newBuilder().mergeFrom(prototype);
+ }
+ public Builder toBuilder() { return newBuilder(this); }
+
+ @java.lang.Override
+ protected Builder newBuilderForType(
+ com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+ Builder builder = new Builder(parent);
+ return builder;
+ }
+ public static final class Builder extends
+ com.google.protobuf.GeneratedMessage.Builder<Builder>
+ implements com.orbekk.same.Services.MasterStateOrBuilder {
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return com.orbekk.same.Services.internal_static_com_orbekk_same_MasterState_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return com.orbekk.same.Services.internal_static_com_orbekk_same_MasterState_fieldAccessorTable;
+ }
+
+ // Construct using com.orbekk.same.Services.MasterState.newBuilder()
+ private Builder() {
+ maybeForceBuilderInitialization();
+ }
+
+ private Builder(BuilderParent parent) {
+ super(parent);
+ maybeForceBuilderInitialization();
+ }
+ private void maybeForceBuilderInitialization() {
+ if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
+ }
+ }
+ private static Builder create() {
+ return new Builder();
+ }
+
+ public Builder clear() {
+ super.clear();
+ masterUrl_ = "";
+ bitField0_ = (bitField0_ & ~0x00000001);
+ masterId_ = 0;
+ bitField0_ = (bitField0_ & ~0x00000002);
+ networkName_ = "";
+ bitField0_ = (bitField0_ & ~0x00000004);
+ return this;
+ }
+
+ public Builder clone() {
+ return create().mergeFrom(buildPartial());
+ }
+
+ public com.google.protobuf.Descriptors.Descriptor
+ getDescriptorForType() {
+ return com.orbekk.same.Services.MasterState.getDescriptor();
+ }
+
+ public com.orbekk.same.Services.MasterState getDefaultInstanceForType() {
+ return com.orbekk.same.Services.MasterState.getDefaultInstance();
+ }
+
+ public com.orbekk.same.Services.MasterState build() {
+ com.orbekk.same.Services.MasterState result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return result;
+ }
+
+ private com.orbekk.same.Services.MasterState buildParsed()
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ com.orbekk.same.Services.MasterState result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(
+ result).asInvalidProtocolBufferException();
+ }
+ return result;
+ }
+
+ public com.orbekk.same.Services.MasterState buildPartial() {
+ com.orbekk.same.Services.MasterState result = new com.orbekk.same.Services.MasterState(this);
+ int from_bitField0_ = bitField0_;
+ int to_bitField0_ = 0;
+ if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
+ to_bitField0_ |= 0x00000001;
+ }
+ result.masterUrl_ = masterUrl_;
+ if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
+ to_bitField0_ |= 0x00000002;
+ }
+ result.masterId_ = masterId_;
+ if (((from_bitField0_ & 0x00000004) == 0x00000004)) {
+ to_bitField0_ |= 0x00000004;
+ }
+ result.networkName_ = networkName_;
+ result.bitField0_ = to_bitField0_;
+ onBuilt();
+ return result;
+ }
+
+ public Builder mergeFrom(com.google.protobuf.Message other) {
+ if (other instanceof com.orbekk.same.Services.MasterState) {
+ return mergeFrom((com.orbekk.same.Services.MasterState)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(com.orbekk.same.Services.MasterState other) {
+ if (other == com.orbekk.same.Services.MasterState.getDefaultInstance()) return this;
+ if (other.hasMasterUrl()) {
+ setMasterUrl(other.getMasterUrl());
+ }
+ if (other.hasMasterId()) {
+ setMasterId(other.getMasterId());
+ }
+ if (other.hasNetworkName()) {
+ setNetworkName(other.getNetworkName());
+ }
+ this.mergeUnknownFields(other.getUnknownFields());
+ return this;
+ }
+
+ public final boolean isInitialized() {
+ return true;
+ }
+
+ public Builder mergeFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ com.google.protobuf.UnknownFieldSet.Builder unknownFields =
+ com.google.protobuf.UnknownFieldSet.newBuilder(
+ this.getUnknownFields());
+ while (true) {
+ int tag = input.readTag();
+ switch (tag) {
+ case 0:
+ this.setUnknownFields(unknownFields.build());
+ onChanged();
+ return this;
+ default: {
+ if (!parseUnknownField(input, unknownFields,
+ extensionRegistry, tag)) {
+ this.setUnknownFields(unknownFields.build());
+ onChanged();
+ return this;
+ }
+ break;
+ }
+ case 10: {
+ bitField0_ |= 0x00000001;
+ masterUrl_ = input.readBytes();
+ break;
+ }
+ case 16: {
+ bitField0_ |= 0x00000002;
+ masterId_ = input.readInt32();
+ break;
+ }
+ case 26: {
+ bitField0_ |= 0x00000004;
+ networkName_ = input.readBytes();
+ break;
+ }
+ }
+ }
+ }
+
+ private int bitField0_;
+
+ // optional string master_url = 1;
+ private java.lang.Object masterUrl_ = "";
+ public boolean hasMasterUrl() {
+ return ((bitField0_ & 0x00000001) == 0x00000001);
+ }
+ public String getMasterUrl() {
+ java.lang.Object ref = masterUrl_;
+ if (!(ref instanceof String)) {
+ String s = ((com.google.protobuf.ByteString) ref).toStringUtf8();
+ masterUrl_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ public Builder setMasterUrl(String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ bitField0_ |= 0x00000001;
+ masterUrl_ = value;
+ onChanged();
+ return this;
+ }
+ public Builder clearMasterUrl() {
+ bitField0_ = (bitField0_ & ~0x00000001);
+ masterUrl_ = getDefaultInstance().getMasterUrl();
+ onChanged();
+ return this;
+ }
+ void setMasterUrl(com.google.protobuf.ByteString value) {
+ bitField0_ |= 0x00000001;
+ masterUrl_ = value;
+ onChanged();
+ }
+
+ // optional int32 master_id = 2;
+ private int masterId_ ;
+ public boolean hasMasterId() {
+ return ((bitField0_ & 0x00000002) == 0x00000002);
+ }
+ public int getMasterId() {
+ return masterId_;
+ }
+ public Builder setMasterId(int value) {
+ bitField0_ |= 0x00000002;
+ masterId_ = value;
+ onChanged();
+ return this;
+ }
+ public Builder clearMasterId() {
+ bitField0_ = (bitField0_ & ~0x00000002);
+ masterId_ = 0;
+ onChanged();
+ return this;
+ }
+
+ // optional string network_name = 3;
+ private java.lang.Object networkName_ = "";
+ public boolean hasNetworkName() {
+ return ((bitField0_ & 0x00000004) == 0x00000004);
+ }
+ public String getNetworkName() {
+ java.lang.Object ref = networkName_;
+ if (!(ref instanceof String)) {
+ String s = ((com.google.protobuf.ByteString) ref).toStringUtf8();
+ networkName_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ public Builder setNetworkName(String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ bitField0_ |= 0x00000004;
+ networkName_ = value;
+ onChanged();
+ return this;
+ }
+ public Builder clearNetworkName() {
+ bitField0_ = (bitField0_ & ~0x00000004);
+ networkName_ = getDefaultInstance().getNetworkName();
+ onChanged();
+ return this;
+ }
+ void setNetworkName(com.google.protobuf.ByteString value) {
+ bitField0_ |= 0x00000004;
+ networkName_ = value;
+ onChanged();
+ }
+
+ // @@protoc_insertion_point(builder_scope:com.orbekk.same.MasterState)
+ }
+
+ static {
+ defaultInstance = new MasterState(true);
+ defaultInstance.initFields();
+ }
+
+ // @@protoc_insertion_point(class_scope:com.orbekk.same.MasterState)
+ }
+
+ public static abstract class Client
+ implements com.google.protobuf.Service {
+ protected Client() {}
+
+ public interface Interface {
+ public abstract void setState(
+ com.google.protobuf.RpcController controller,
+ com.orbekk.same.Services.Component request,
+ com.google.protobuf.RpcCallback<com.orbekk.same.Services.Empty> done);
+
+ public abstract void masterTakeover(
+ com.google.protobuf.RpcController controller,
+ com.orbekk.same.Services.MasterState request,
+ com.google.protobuf.RpcCallback<com.orbekk.same.Services.Empty> done);
+
+ public abstract void masterDown(
+ com.google.protobuf.RpcController controller,
+ com.orbekk.same.Services.MasterState request,
+ com.google.protobuf.RpcCallback<com.orbekk.same.Services.Empty> done);
+
+ }
+
+ public static com.google.protobuf.Service newReflectiveService(
+ final Interface impl) {
+ return new Client() {
+ @java.lang.Override
+ public void setState(
+ com.google.protobuf.RpcController controller,
+ com.orbekk.same.Services.Component request,
+ com.google.protobuf.RpcCallback<com.orbekk.same.Services.Empty> done) {
+ impl.setState(controller, request, done);
+ }
+
+ @java.lang.Override
+ public void masterTakeover(
+ com.google.protobuf.RpcController controller,
+ com.orbekk.same.Services.MasterState request,
+ com.google.protobuf.RpcCallback<com.orbekk.same.Services.Empty> done) {
+ impl.masterTakeover(controller, request, done);
+ }
+
+ @java.lang.Override
+ public void masterDown(
+ com.google.protobuf.RpcController controller,
+ com.orbekk.same.Services.MasterState request,
+ com.google.protobuf.RpcCallback<com.orbekk.same.Services.Empty> done) {
+ impl.masterDown(controller, request, done);
+ }
+
+ };
+ }
+
+ public static com.google.protobuf.BlockingService
+ newReflectiveBlockingService(final BlockingInterface impl) {
+ return new com.google.protobuf.BlockingService() {
+ public final com.google.protobuf.Descriptors.ServiceDescriptor
+ getDescriptorForType() {
+ return getDescriptor();
+ }
+
+ public final com.google.protobuf.Message callBlockingMethod(
+ com.google.protobuf.Descriptors.MethodDescriptor method,
+ com.google.protobuf.RpcController controller,
+ com.google.protobuf.Message request)
+ throws com.google.protobuf.ServiceException {
+ if (method.getService() != getDescriptor()) {
+ throw new java.lang.IllegalArgumentException(
+ "Service.callBlockingMethod() given method descriptor for " +
+ "wrong service type.");
+ }
+ switch(method.getIndex()) {
+ case 0:
+ return impl.setState(controller, (com.orbekk.same.Services.Component)request);
+ case 1:
+ return impl.masterTakeover(controller, (com.orbekk.same.Services.MasterState)request);
+ case 2:
+ return impl.masterDown(controller, (com.orbekk.same.Services.MasterState)request);
+ default:
+ throw new java.lang.AssertionError("Can't get here.");
+ }
+ }
+
+ public final com.google.protobuf.Message
+ getRequestPrototype(
+ com.google.protobuf.Descriptors.MethodDescriptor method) {
+ if (method.getService() != getDescriptor()) {
+ throw new java.lang.IllegalArgumentException(
+ "Service.getRequestPrototype() given method " +
+ "descriptor for wrong service type.");
+ }
+ switch(method.getIndex()) {
+ case 0:
+ return com.orbekk.same.Services.Component.getDefaultInstance();
+ case 1:
+ return com.orbekk.same.Services.MasterState.getDefaultInstance();
+ case 2:
+ return com.orbekk.same.Services.MasterState.getDefaultInstance();
+ default:
+ throw new java.lang.AssertionError("Can't get here.");
+ }
+ }
+
+ public final com.google.protobuf.Message
+ getResponsePrototype(
+ com.google.protobuf.Descriptors.MethodDescriptor method) {
+ if (method.getService() != getDescriptor()) {
+ throw new java.lang.IllegalArgumentException(
+ "Service.getResponsePrototype() given method " +
+ "descriptor for wrong service type.");
+ }
+ switch(method.getIndex()) {
+ case 0:
+ return com.orbekk.same.Services.Empty.getDefaultInstance();
+ case 1:
+ return com.orbekk.same.Services.Empty.getDefaultInstance();
+ case 2:
+ return com.orbekk.same.Services.Empty.getDefaultInstance();
+ default:
+ throw new java.lang.AssertionError("Can't get here.");
+ }
+ }
+
+ };
+ }
+
+ public abstract void setState(
+ com.google.protobuf.RpcController controller,
+ com.orbekk.same.Services.Component request,
+ com.google.protobuf.RpcCallback<com.orbekk.same.Services.Empty> done);
+
+ public abstract void masterTakeover(
+ com.google.protobuf.RpcController controller,
+ com.orbekk.same.Services.MasterState request,
+ com.google.protobuf.RpcCallback<com.orbekk.same.Services.Empty> done);
+
+ public abstract void masterDown(
+ com.google.protobuf.RpcController controller,
+ com.orbekk.same.Services.MasterState request,
+ com.google.protobuf.RpcCallback<com.orbekk.same.Services.Empty> done);
+
+ public static final
+ com.google.protobuf.Descriptors.ServiceDescriptor
+ getDescriptor() {
+ return com.orbekk.same.Services.getDescriptor().getServices().get(0);
+ }
+ public final com.google.protobuf.Descriptors.ServiceDescriptor
+ getDescriptorForType() {
+ return getDescriptor();
+ }
+
+ public final void callMethod(
+ com.google.protobuf.Descriptors.MethodDescriptor method,
+ com.google.protobuf.RpcController controller,
+ com.google.protobuf.Message request,
+ com.google.protobuf.RpcCallback<
+ com.google.protobuf.Message> done) {
+ if (method.getService() != getDescriptor()) {
+ throw new java.lang.IllegalArgumentException(
+ "Service.callMethod() given method descriptor for wrong " +
+ "service type.");
+ }
+ switch(method.getIndex()) {
+ case 0:
+ this.setState(controller, (com.orbekk.same.Services.Component)request,
+ com.google.protobuf.RpcUtil.<com.orbekk.same.Services.Empty>specializeCallback(
+ done));
+ return;
+ case 1:
+ this.masterTakeover(controller, (com.orbekk.same.Services.MasterState)request,
+ com.google.protobuf.RpcUtil.<com.orbekk.same.Services.Empty>specializeCallback(
+ done));
+ return;
+ case 2:
+ this.masterDown(controller, (com.orbekk.same.Services.MasterState)request,
+ com.google.protobuf.RpcUtil.<com.orbekk.same.Services.Empty>specializeCallback(
+ done));
+ return;
+ default:
+ throw new java.lang.AssertionError("Can't get here.");
+ }
+ }
+
+ public final com.google.protobuf.Message
+ getRequestPrototype(
+ com.google.protobuf.Descriptors.MethodDescriptor method) {
+ if (method.getService() != getDescriptor()) {
+ throw new java.lang.IllegalArgumentException(
+ "Service.getRequestPrototype() given method " +
+ "descriptor for wrong service type.");
+ }
+ switch(method.getIndex()) {
+ case 0:
+ return com.orbekk.same.Services.Component.getDefaultInstance();
+ case 1:
+ return com.orbekk.same.Services.MasterState.getDefaultInstance();
+ case 2:
+ return com.orbekk.same.Services.MasterState.getDefaultInstance();
+ default:
+ throw new java.lang.AssertionError("Can't get here.");
+ }
+ }
+
+ public final com.google.protobuf.Message
+ getResponsePrototype(
+ com.google.protobuf.Descriptors.MethodDescriptor method) {
+ if (method.getService() != getDescriptor()) {
+ throw new java.lang.IllegalArgumentException(
+ "Service.getResponsePrototype() given method " +
+ "descriptor for wrong service type.");
+ }
+ switch(method.getIndex()) {
+ case 0:
+ return com.orbekk.same.Services.Empty.getDefaultInstance();
+ case 1:
+ return com.orbekk.same.Services.Empty.getDefaultInstance();
+ case 2:
+ return com.orbekk.same.Services.Empty.getDefaultInstance();
+ default:
+ throw new java.lang.AssertionError("Can't get here.");
+ }
+ }
+
+ public static Stub newStub(
+ com.google.protobuf.RpcChannel channel) {
+ return new Stub(channel);
+ }
+
+ public static final class Stub extends com.orbekk.same.Services.Client implements Interface {
+ private Stub(com.google.protobuf.RpcChannel channel) {
+ this.channel = channel;
+ }
+
+ private final com.google.protobuf.RpcChannel channel;
+
+ public com.google.protobuf.RpcChannel getChannel() {
+ return channel;
+ }
+
+ public void setState(
+ com.google.protobuf.RpcController controller,
+ com.orbekk.same.Services.Component request,
+ com.google.protobuf.RpcCallback<com.orbekk.same.Services.Empty> done) {
+ channel.callMethod(
+ getDescriptor().getMethods().get(0),
+ controller,
+ request,
+ com.orbekk.same.Services.Empty.getDefaultInstance(),
+ com.google.protobuf.RpcUtil.generalizeCallback(
+ done,
+ com.orbekk.same.Services.Empty.class,
+ com.orbekk.same.Services.Empty.getDefaultInstance()));
+ }
+
+ public void masterTakeover(
+ com.google.protobuf.RpcController controller,
+ com.orbekk.same.Services.MasterState request,
+ com.google.protobuf.RpcCallback<com.orbekk.same.Services.Empty> done) {
+ channel.callMethod(
+ getDescriptor().getMethods().get(1),
+ controller,
+ request,
+ com.orbekk.same.Services.Empty.getDefaultInstance(),
+ com.google.protobuf.RpcUtil.generalizeCallback(
+ done,
+ com.orbekk.same.Services.Empty.class,
+ com.orbekk.same.Services.Empty.getDefaultInstance()));
+ }
+
+ public void masterDown(
+ com.google.protobuf.RpcController controller,
+ com.orbekk.same.Services.MasterState request,
+ com.google.protobuf.RpcCallback<com.orbekk.same.Services.Empty> done) {
+ channel.callMethod(
+ getDescriptor().getMethods().get(2),
+ controller,
+ request,
+ com.orbekk.same.Services.Empty.getDefaultInstance(),
+ com.google.protobuf.RpcUtil.generalizeCallback(
+ done,
+ com.orbekk.same.Services.Empty.class,
+ com.orbekk.same.Services.Empty.getDefaultInstance()));
+ }
+ }
+
+ public static BlockingInterface newBlockingStub(
+ com.google.protobuf.BlockingRpcChannel channel) {
+ return new BlockingStub(channel);
+ }
+
+ public interface BlockingInterface {
+ public com.orbekk.same.Services.Empty setState(
+ com.google.protobuf.RpcController controller,
+ com.orbekk.same.Services.Component request)
+ throws com.google.protobuf.ServiceException;
+
+ public com.orbekk.same.Services.Empty masterTakeover(
+ com.google.protobuf.RpcController controller,
+ com.orbekk.same.Services.MasterState request)
+ throws com.google.protobuf.ServiceException;
+
+ public com.orbekk.same.Services.Empty masterDown(
+ com.google.protobuf.RpcController controller,
+ com.orbekk.same.Services.MasterState request)
+ throws com.google.protobuf.ServiceException;
+ }
+
+ private static final class BlockingStub implements BlockingInterface {
+ private BlockingStub(com.google.protobuf.BlockingRpcChannel channel) {
+ this.channel = channel;
+ }
+
+ private final com.google.protobuf.BlockingRpcChannel channel;
+
+ public com.orbekk.same.Services.Empty setState(
+ com.google.protobuf.RpcController controller,
+ com.orbekk.same.Services.Component request)
+ throws com.google.protobuf.ServiceException {
+ return (com.orbekk.same.Services.Empty) channel.callBlockingMethod(
+ getDescriptor().getMethods().get(0),
+ controller,
+ request,
+ com.orbekk.same.Services.Empty.getDefaultInstance());
+ }
+
+
+ public com.orbekk.same.Services.Empty masterTakeover(
+ com.google.protobuf.RpcController controller,
+ com.orbekk.same.Services.MasterState request)
+ throws com.google.protobuf.ServiceException {
+ return (com.orbekk.same.Services.Empty) channel.callBlockingMethod(
+ getDescriptor().getMethods().get(1),
+ controller,
+ request,
+ com.orbekk.same.Services.Empty.getDefaultInstance());
+ }
+
+
+ public com.orbekk.same.Services.Empty masterDown(
+ com.google.protobuf.RpcController controller,
+ com.orbekk.same.Services.MasterState request)
+ throws com.google.protobuf.ServiceException {
+ return (com.orbekk.same.Services.Empty) channel.callBlockingMethod(
+ getDescriptor().getMethods().get(2),
+ controller,
+ request,
+ com.orbekk.same.Services.Empty.getDefaultInstance());
+ }
+
+ }
+ }
+
+ private static com.google.protobuf.Descriptors.Descriptor
+ internal_static_com_orbekk_same_Empty_descriptor;
+ private static
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internal_static_com_orbekk_same_Empty_fieldAccessorTable;
+ private static com.google.protobuf.Descriptors.Descriptor
+ internal_static_com_orbekk_same_Component_descriptor;
+ private static
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internal_static_com_orbekk_same_Component_fieldAccessorTable;
+ private static com.google.protobuf.Descriptors.Descriptor
+ internal_static_com_orbekk_same_MasterState_descriptor;
+ private static
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internal_static_com_orbekk_same_MasterState_fieldAccessorTable;
+
+ public static com.google.protobuf.Descriptors.FileDescriptor
+ getDescriptor() {
+ return descriptor;
+ }
+ private static com.google.protobuf.Descriptors.FileDescriptor
+ descriptor;
+ static {
+ java.lang.String[] descriptorData = {
+ "\n,src/main/java/com/orbekk/same/services" +
+ ".proto\022\017com.orbekk.same\"\007\n\005Empty\"7\n\tComp" +
+ "onent\022\n\n\002id\030\001 \002(\t\022\014\n\004data\030\002 \002(\t\022\020\n\010revis" +
+ "ion\030\003 \002(\003\"J\n\013MasterState\022\022\n\nmaster_url\030\001" +
+ " \001(\t\022\021\n\tmaster_id\030\002 \001(\005\022\024\n\014network_name\030" +
+ "\003 \001(\t2\324\001\n\006Client\022>\n\010SetState\022\032.com.orbek" +
+ "k.same.Component\032\026.com.orbekk.same.Empty" +
+ "\022F\n\016MasterTakeover\022\034.com.orbekk.same.Mas" +
+ "terState\032\026.com.orbekk.same.Empty\022B\n\nMast" +
+ "erDown\022\034.com.orbekk.same.MasterState\032\026.c",
+ "om.orbekk.same.EmptyB\003\210\001\001"
+ };
+ 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;
+ internal_static_com_orbekk_same_Empty_descriptor =
+ getDescriptor().getMessageTypes().get(0);
+ internal_static_com_orbekk_same_Empty_fieldAccessorTable = new
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable(
+ internal_static_com_orbekk_same_Empty_descriptor,
+ new java.lang.String[] { },
+ com.orbekk.same.Services.Empty.class,
+ com.orbekk.same.Services.Empty.Builder.class);
+ internal_static_com_orbekk_same_Component_descriptor =
+ getDescriptor().getMessageTypes().get(1);
+ internal_static_com_orbekk_same_Component_fieldAccessorTable = new
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable(
+ internal_static_com_orbekk_same_Component_descriptor,
+ new java.lang.String[] { "Id", "Data", "Revision", },
+ com.orbekk.same.Services.Component.class,
+ com.orbekk.same.Services.Component.Builder.class);
+ internal_static_com_orbekk_same_MasterState_descriptor =
+ getDescriptor().getMessageTypes().get(2);
+ internal_static_com_orbekk_same_MasterState_fieldAccessorTable = new
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable(
+ internal_static_com_orbekk_same_MasterState_descriptor,
+ new java.lang.String[] { "MasterUrl", "MasterId", "NetworkName", },
+ com.orbekk.same.Services.MasterState.class,
+ com.orbekk.same.Services.MasterState.Builder.class);
+ return null;
+ }
+ };
+ com.google.protobuf.Descriptors.FileDescriptor
+ .internalBuildGeneratedFileFrom(descriptorData,
+ new com.google.protobuf.Descriptors.FileDescriptor[] {
+ }, assigner);
+ }
+
+ // @@protoc_insertion_point(outer_class_scope)
+}
diff --git a/same/src/main/java/com/orbekk/same/benchmark/Example.java b/same/src/main/java/com/orbekk/same/benchmark/Example.java
index c71ed0a..5b75620 100644
--- a/same/src/main/java/com/orbekk/same/benchmark/Example.java
+++ b/same/src/main/java/com/orbekk/same/benchmark/Example.java
@@ -8,11 +8,27 @@ public final class Example {
public static void registerAllExtensions(
com.google.protobuf.ExtensionRegistry registry) {
}
+ public interface DataOrBuilder
+ extends com.google.protobuf.MessageOrBuilder {
+
+ // optional string message = 1;
+ boolean hasMessage();
+ String getMessage();
+
+ // optional int32 arg1 = 2;
+ boolean hasArg1();
+ int getArg1();
+
+ // optional int32 arg2 = 3;
+ boolean hasArg2();
+ int getArg2();
+ }
public static final class Data extends
- com.google.protobuf.GeneratedMessage {
+ com.google.protobuf.GeneratedMessage
+ implements DataOrBuilder {
// Use Data.newBuilder() to construct.
- private Data() {
- initFields();
+ private Data(Builder builder) {
+ super(builder);
}
private Data(boolean noInit) {}
@@ -35,44 +51,84 @@ public final class Example {
return com.orbekk.same.benchmark.Example.internal_static_com_orbekk_same_benchmark_Data_fieldAccessorTable;
}
+ private int bitField0_;
// optional string message = 1;
public static final int MESSAGE_FIELD_NUMBER = 1;
- private boolean hasMessage;
- private java.lang.String message_ = "";
- public boolean hasMessage() { return hasMessage; }
- public java.lang.String getMessage() { return message_; }
+ private java.lang.Object message_;
+ public boolean hasMessage() {
+ return ((bitField0_ & 0x00000001) == 0x00000001);
+ }
+ public String getMessage() {
+ java.lang.Object ref = message_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ if (com.google.protobuf.Internal.isValidUtf8(bs)) {
+ message_ = s;
+ }
+ return s;
+ }
+ }
+ private com.google.protobuf.ByteString getMessageBytes() {
+ java.lang.Object ref = message_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8((String) ref);
+ message_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
// optional int32 arg1 = 2;
public static final int ARG1_FIELD_NUMBER = 2;
- private boolean hasArg1;
- private int arg1_ = 0;
- public boolean hasArg1() { return hasArg1; }
- public int getArg1() { return arg1_; }
+ private int arg1_;
+ public boolean hasArg1() {
+ return ((bitField0_ & 0x00000002) == 0x00000002);
+ }
+ public int getArg1() {
+ return arg1_;
+ }
// optional int32 arg2 = 3;
public static final int ARG2_FIELD_NUMBER = 3;
- private boolean hasArg2;
- private int arg2_ = 0;
- public boolean hasArg2() { return hasArg2; }
- public int getArg2() { return arg2_; }
+ private int arg2_;
+ public boolean hasArg2() {
+ return ((bitField0_ & 0x00000004) == 0x00000004);
+ }
+ public int getArg2() {
+ return arg2_;
+ }
private void initFields() {
+ message_ = "";
+ arg1_ = 0;
+ arg2_ = 0;
}
+ private byte memoizedIsInitialized = -1;
public final boolean isInitialized() {
+ byte isInitialized = memoizedIsInitialized;
+ if (isInitialized != -1) return isInitialized == 1;
+
+ memoizedIsInitialized = 1;
return true;
}
public void writeTo(com.google.protobuf.CodedOutputStream output)
throws java.io.IOException {
getSerializedSize();
- if (hasMessage()) {
- output.writeString(1, getMessage());
+ if (((bitField0_ & 0x00000001) == 0x00000001)) {
+ output.writeBytes(1, getMessageBytes());
}
- if (hasArg1()) {
- output.writeInt32(2, getArg1());
+ if (((bitField0_ & 0x00000002) == 0x00000002)) {
+ output.writeInt32(2, arg1_);
}
- if (hasArg2()) {
- output.writeInt32(3, getArg2());
+ if (((bitField0_ & 0x00000004) == 0x00000004)) {
+ output.writeInt32(3, arg2_);
}
getUnknownFields().writeTo(output);
}
@@ -83,23 +139,30 @@ public final class Example {
if (size != -1) return size;
size = 0;
- if (hasMessage()) {
+ if (((bitField0_ & 0x00000001) == 0x00000001)) {
size += com.google.protobuf.CodedOutputStream
- .computeStringSize(1, getMessage());
+ .computeBytesSize(1, getMessageBytes());
}
- if (hasArg1()) {
+ if (((bitField0_ & 0x00000002) == 0x00000002)) {
size += com.google.protobuf.CodedOutputStream
- .computeInt32Size(2, getArg1());
+ .computeInt32Size(2, arg1_);
}
- if (hasArg2()) {
+ if (((bitField0_ & 0x00000004) == 0x00000004)) {
size += com.google.protobuf.CodedOutputStream
- .computeInt32Size(3, getArg2());
+ .computeInt32Size(3, arg2_);
}
size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size;
return size;
}
+ private static final long serialVersionUID = 0L;
+ @java.lang.Override
+ protected java.lang.Object writeReplace()
+ throws java.io.ObjectStreamException {
+ return super.writeReplace();
+ }
+
public static com.orbekk.same.benchmark.Example.Data parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
@@ -174,34 +237,55 @@ public final class Example {
}
public Builder toBuilder() { return newBuilder(this); }
+ @java.lang.Override
+ protected Builder newBuilderForType(
+ com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+ Builder builder = new Builder(parent);
+ return builder;
+ }
public static final class Builder extends
- com.google.protobuf.GeneratedMessage.Builder<Builder> {
- private com.orbekk.same.benchmark.Example.Data result;
+ com.google.protobuf.GeneratedMessage.Builder<Builder>
+ implements com.orbekk.same.benchmark.Example.DataOrBuilder {
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return com.orbekk.same.benchmark.Example.internal_static_com_orbekk_same_benchmark_Data_descriptor;
+ }
- // Construct using com.orbekk.same.benchmark.Example.Data.newBuilder()
- private Builder() {}
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return com.orbekk.same.benchmark.Example.internal_static_com_orbekk_same_benchmark_Data_fieldAccessorTable;
+ }
- private static Builder create() {
- Builder builder = new Builder();
- builder.result = new com.orbekk.same.benchmark.Example.Data();
- return builder;
+ // Construct using com.orbekk.same.benchmark.Example.Data.newBuilder()
+ private Builder() {
+ maybeForceBuilderInitialization();
}
- protected com.orbekk.same.benchmark.Example.Data internalGetResult() {
- return result;
+ private Builder(BuilderParent parent) {
+ super(parent);
+ maybeForceBuilderInitialization();
+ }
+ private void maybeForceBuilderInitialization() {
+ if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
+ }
+ }
+ private static Builder create() {
+ return new Builder();
}
public Builder clear() {
- if (result == null) {
- throw new IllegalStateException(
- "Cannot call clear() after build().");
- }
- result = new com.orbekk.same.benchmark.Example.Data();
+ super.clear();
+ message_ = "";
+ bitField0_ = (bitField0_ & ~0x00000001);
+ arg1_ = 0;
+ bitField0_ = (bitField0_ & ~0x00000002);
+ arg2_ = 0;
+ bitField0_ = (bitField0_ & ~0x00000004);
return this;
}
public Builder clone() {
- return create().mergeFrom(result);
+ return create().mergeFrom(buildPartial());
}
public com.google.protobuf.Descriptors.Descriptor
@@ -213,33 +297,43 @@ public final class Example {
return com.orbekk.same.benchmark.Example.Data.getDefaultInstance();
}
- public boolean isInitialized() {
- return result.isInitialized();
- }
public com.orbekk.same.benchmark.Example.Data build() {
- if (result != null && !isInitialized()) {
+ com.orbekk.same.benchmark.Example.Data result = buildPartial();
+ if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
- return buildPartial();
+ return result;
}
private com.orbekk.same.benchmark.Example.Data buildParsed()
throws com.google.protobuf.InvalidProtocolBufferException {
- if (!isInitialized()) {
+ com.orbekk.same.benchmark.Example.Data result = buildPartial();
+ if (!result.isInitialized()) {
throw newUninitializedMessageException(
result).asInvalidProtocolBufferException();
}
- return buildPartial();
+ return result;
}
public com.orbekk.same.benchmark.Example.Data buildPartial() {
- if (result == null) {
- throw new IllegalStateException(
- "build() has already been called on this Builder.");
+ com.orbekk.same.benchmark.Example.Data result = new com.orbekk.same.benchmark.Example.Data(this);
+ int from_bitField0_ = bitField0_;
+ int to_bitField0_ = 0;
+ if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
+ to_bitField0_ |= 0x00000001;
+ }
+ result.message_ = message_;
+ if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
+ to_bitField0_ |= 0x00000002;
+ }
+ result.arg1_ = arg1_;
+ if (((from_bitField0_ & 0x00000004) == 0x00000004)) {
+ to_bitField0_ |= 0x00000004;
}
- com.orbekk.same.benchmark.Example.Data returnMe = result;
- result = null;
- return returnMe;
+ result.arg2_ = arg2_;
+ result.bitField0_ = to_bitField0_;
+ onBuilt();
+ return result;
}
public Builder mergeFrom(com.google.protobuf.Message other) {
@@ -266,6 +360,10 @@ public final class Example {
return this;
}
+ public final boolean isInitialized() {
+ return true;
+ }
+
public Builder mergeFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
@@ -278,86 +376,113 @@ public final class Example {
switch (tag) {
case 0:
this.setUnknownFields(unknownFields.build());
+ onChanged();
return this;
default: {
if (!parseUnknownField(input, unknownFields,
extensionRegistry, tag)) {
this.setUnknownFields(unknownFields.build());
+ onChanged();
return this;
}
break;
}
case 10: {
- setMessage(input.readString());
+ bitField0_ |= 0x00000001;
+ message_ = input.readBytes();
break;
}
case 16: {
- setArg1(input.readInt32());
+ bitField0_ |= 0x00000002;
+ arg1_ = input.readInt32();
break;
}
case 24: {
- setArg2(input.readInt32());
+ bitField0_ |= 0x00000004;
+ arg2_ = input.readInt32();
break;
}
}
}
}
+ private int bitField0_;
// optional string message = 1;
+ private java.lang.Object message_ = "";
public boolean hasMessage() {
- return result.hasMessage();
- }
- public java.lang.String getMessage() {
- return result.getMessage();
+ return ((bitField0_ & 0x00000001) == 0x00000001);
+ }
+ public String getMessage() {
+ java.lang.Object ref = message_;
+ if (!(ref instanceof String)) {
+ String s = ((com.google.protobuf.ByteString) ref).toStringUtf8();
+ message_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
}
- public Builder setMessage(java.lang.String value) {
+ public Builder setMessage(String value) {
if (value == null) {
throw new NullPointerException();
}
- result.hasMessage = true;
- result.message_ = value;
+ bitField0_ |= 0x00000001;
+ message_ = value;
+ onChanged();
return this;
}
public Builder clearMessage() {
- result.hasMessage = false;
- result.message_ = getDefaultInstance().getMessage();
+ bitField0_ = (bitField0_ & ~0x00000001);
+ message_ = getDefaultInstance().getMessage();
+ onChanged();
return this;
}
+ void setMessage(com.google.protobuf.ByteString value) {
+ bitField0_ |= 0x00000001;
+ message_ = value;
+ onChanged();
+ }
// optional int32 arg1 = 2;
+ private int arg1_ ;
public boolean hasArg1() {
- return result.hasArg1();
+ return ((bitField0_ & 0x00000002) == 0x00000002);
}
public int getArg1() {
- return result.getArg1();
+ return arg1_;
}
public Builder setArg1(int value) {
- result.hasArg1 = true;
- result.arg1_ = value;
+ bitField0_ |= 0x00000002;
+ arg1_ = value;
+ onChanged();
return this;
}
public Builder clearArg1() {
- result.hasArg1 = false;
- result.arg1_ = 0;
+ bitField0_ = (bitField0_ & ~0x00000002);
+ arg1_ = 0;
+ onChanged();
return this;
}
// optional int32 arg2 = 3;
+ private int arg2_ ;
public boolean hasArg2() {
- return result.hasArg2();
+ return ((bitField0_ & 0x00000004) == 0x00000004);
}
public int getArg2() {
- return result.getArg2();
+ return arg2_;
}
public Builder setArg2(int value) {
- result.hasArg2 = true;
- result.arg2_ = value;
+ bitField0_ |= 0x00000004;
+ arg2_ = value;
+ onChanged();
return this;
}
public Builder clearArg2() {
- result.hasArg2 = false;
- result.arg2_ = 0;
+ bitField0_ = (bitField0_ & ~0x00000004);
+ arg2_ = 0;
+ onChanged();
return this;
}
@@ -366,7 +491,6 @@ public final class Example {
static {
defaultInstance = new Data(true);
- com.orbekk.same.benchmark.Example.internalForceInit();
defaultInstance.initFields();
}
@@ -388,7 +512,7 @@ public final class Example {
public static com.google.protobuf.Service newReflectiveService(
final Interface impl) {
return new Service() {
- @Override
+ @java.lang.Override
public void methodA(
com.google.protobuf.RpcController controller,
com.orbekk.same.benchmark.Example.Data request,
@@ -637,7 +761,5 @@ public final class Example {
}, assigner);
}
- public static void internalForceInit() {}
-
// @@protoc_insertion_point(outer_class_scope)
}
diff --git a/same/src/main/java/com/orbekk/same/services.proto b/same/src/main/java/com/orbekk/same/services.proto
new file mode 100644
index 0000000..0ecba66
--- /dev/null
+++ b/same/src/main/java/com/orbekk/same/services.proto
@@ -0,0 +1,24 @@
+package com.orbekk.same;
+
+option java_generic_services = true;
+
+message Empty {
+}
+
+message Component {
+ required string id = 1;
+ required string data = 2;
+ required int64 revision = 3;
+}
+
+message MasterState {
+ optional string master_url = 1;
+ optional int32 master_id = 2;
+ optional string network_name = 3;
+}
+
+service Client {
+ rpc SetState (Component) returns (Empty);
+ rpc MasterTakeover (MasterState) returns (Empty);
+ rpc MasterDown (MasterState) returns (Empty);
+}
diff --git a/same/src/test/java/com/orbekk/same/ClientTest.java b/same/src/test/java/com/orbekk/same/ClientTest.java
index 6c617be..d494fe7 100644
--- a/same/src/test/java/com/orbekk/same/ClientTest.java
+++ b/same/src/test/java/com/orbekk/same/ClientTest.java
@@ -33,7 +33,7 @@ public class ClientTest {
}
@Test public void connectedUpdateWorks() throws Exception {
- clientS.masterTakeover("master", null, 1);
+ clientS.masterTakeover("master", "MyNetwork", 1);
ClientInterface clientI = client.getInterface();
State.Component component = new State.Component(
"TestVariable", 1, "meow");
@@ -49,14 +49,6 @@ public class ClientTest {
assertEquals("Test data", state.getDataOf("TestState"));
}
- @Test public void testNetworkListener() throws Exception {
- NetworkNotificationListener listener =
- mock(NetworkNotificationListener.class);
- client.setNetworkListener(listener);
- clientS.notifyNetwork("MyNetwork", "MasterUrl");
- verify(listener).notifyNetwork("MyNetwork", "MasterUrl");
- }
-
@Test public void stateListenerReceivesUpdate() throws Exception {
StateChangedListener listener = mock(StateChangedListener.class);
client.getInterface().addStateListener(listener);
diff --git a/same/src/test/java/com/orbekk/same/MasterTest.java b/same/src/test/java/com/orbekk/same/MasterTest.java
index f369d06..39bee1f 100644
--- a/same/src/test/java/com/orbekk/same/MasterTest.java
+++ b/same/src/test/java/com/orbekk/same/MasterTest.java
@@ -18,12 +18,6 @@ public class MasterTest {
public static class UnreachableClient implements ClientService {
@Override
- public void notifyNetwork(String networkName, String masterUrl)
- throws Exception {
- throw new Exception("Unreachable client");
- }
-
- @Override
public void setState(String component, String data, long revision)
throws Exception {
throw new Exception("Unreachable client");