diff --git a/akka-remote/src/main/java/akka/remote/ContainerFormats.java b/akka-remote/src/main/java/akka/remote/ContainerFormats.java new file mode 100644 index 0000000000..448a06ad0b --- /dev/null +++ b/akka-remote/src/main/java/akka/remote/ContainerFormats.java @@ -0,0 +1,1350 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: ContainerFormats.proto + +package akka.remote; + +public final class ContainerFormats { + private ContainerFormats() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + } + public enum PatternType + implements com.google.protobuf.ProtocolMessageEnum { + PARENT(0, 0), + CHILD_NAME(1, 1), + CHILD_PATTERN(2, 2), + ; + + public static final int PARENT_VALUE = 0; + public static final int CHILD_NAME_VALUE = 1; + public static final int CHILD_PATTERN_VALUE = 2; + + + public final int getNumber() { return value; } + + public static PatternType valueOf(int value) { + switch (value) { + case 0: return PARENT; + case 1: return CHILD_NAME; + case 2: return CHILD_PATTERN; + default: return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + private static com.google.protobuf.Internal.EnumLiteMap + internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public PatternType findValueByNumber(int number) { + return PatternType.valueOf(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor + getValueDescriptor() { + return getDescriptor().getValues().get(index); + } + public final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptorForType() { + return getDescriptor(); + } + public static final com.google.protobuf.Descriptors.EnumDescriptor + getDescriptor() { + return akka.remote.ContainerFormats.getDescriptor().getEnumTypes().get(0); + } + + private static final PatternType[] VALUES = { + PARENT, CHILD_NAME, CHILD_PATTERN, + }; + + public static PatternType valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException( + "EnumValueDescriptor is not for this type."); + } + return VALUES[desc.getIndex()]; + } + + private final int index; + private final int value; + + private PatternType(int index, int value) { + this.index = index; + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:PatternType) + } + + public interface SelectionEnvelopeOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // required bytes enclosedMessage = 1; + boolean hasEnclosedMessage(); + com.google.protobuf.ByteString getEnclosedMessage(); + + // required int32 serializerId = 2; + boolean hasSerializerId(); + int getSerializerId(); + + // repeated .Selection pattern = 3; + java.util.List + getPatternList(); + akka.remote.ContainerFormats.Selection getPattern(int index); + int getPatternCount(); + java.util.List + getPatternOrBuilderList(); + akka.remote.ContainerFormats.SelectionOrBuilder getPatternOrBuilder( + int index); + + // optional bytes messageManifest = 4; + boolean hasMessageManifest(); + com.google.protobuf.ByteString getMessageManifest(); + } + public static final class SelectionEnvelope extends + com.google.protobuf.GeneratedMessage + implements SelectionEnvelopeOrBuilder { + // Use SelectionEnvelope.newBuilder() to construct. + private SelectionEnvelope(Builder builder) { + super(builder); + } + private SelectionEnvelope(boolean noInit) {} + + private static final SelectionEnvelope defaultInstance; + public static SelectionEnvelope getDefaultInstance() { + return defaultInstance; + } + + public SelectionEnvelope getDefaultInstanceForType() { + return defaultInstance; + } + + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return akka.remote.ContainerFormats.internal_static_SelectionEnvelope_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return akka.remote.ContainerFormats.internal_static_SelectionEnvelope_fieldAccessorTable; + } + + private int bitField0_; + // required bytes enclosedMessage = 1; + public static final int ENCLOSEDMESSAGE_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString enclosedMessage_; + public boolean hasEnclosedMessage() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + public com.google.protobuf.ByteString getEnclosedMessage() { + return enclosedMessage_; + } + + // required int32 serializerId = 2; + public static final int SERIALIZERID_FIELD_NUMBER = 2; + private int serializerId_; + public boolean hasSerializerId() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + public int getSerializerId() { + return serializerId_; + } + + // repeated .Selection pattern = 3; + public static final int PATTERN_FIELD_NUMBER = 3; + private java.util.List pattern_; + public java.util.List getPatternList() { + return pattern_; + } + public java.util.List + getPatternOrBuilderList() { + return pattern_; + } + public int getPatternCount() { + return pattern_.size(); + } + public akka.remote.ContainerFormats.Selection getPattern(int index) { + return pattern_.get(index); + } + public akka.remote.ContainerFormats.SelectionOrBuilder getPatternOrBuilder( + int index) { + return pattern_.get(index); + } + + // optional bytes messageManifest = 4; + public static final int MESSAGEMANIFEST_FIELD_NUMBER = 4; + private com.google.protobuf.ByteString messageManifest_; + public boolean hasMessageManifest() { + return ((bitField0_ & 0x00000004) == 0x00000004); + } + public com.google.protobuf.ByteString getMessageManifest() { + return messageManifest_; + } + + private void initFields() { + enclosedMessage_ = com.google.protobuf.ByteString.EMPTY; + serializerId_ = 0; + pattern_ = java.util.Collections.emptyList(); + messageManifest_ = com.google.protobuf.ByteString.EMPTY; + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + if (!hasEnclosedMessage()) { + memoizedIsInitialized = 0; + return false; + } + if (!hasSerializerId()) { + memoizedIsInitialized = 0; + return false; + } + for (int i = 0; i < getPatternCount(); i++) { + if (!getPattern(i).isInitialized()) { + 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, enclosedMessage_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeInt32(2, serializerId_); + } + for (int i = 0; i < pattern_.size(); i++) { + output.writeMessage(3, pattern_.get(i)); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + output.writeBytes(4, messageManifest_); + } + 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, enclosedMessage_); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream + .computeInt32Size(2, serializerId_); + } + for (int i = 0; i < pattern_.size(); i++) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(3, pattern_.get(i)); + } + if (((bitField0_ & 0x00000004) == 0x00000004)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(4, messageManifest_); + } + 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 akka.remote.ContainerFormats.SelectionEnvelope parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data).buildParsed(); + } + public static akka.remote.ContainerFormats.SelectionEnvelope parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data, extensionRegistry) + .buildParsed(); + } + public static akka.remote.ContainerFormats.SelectionEnvelope parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data).buildParsed(); + } + public static akka.remote.ContainerFormats.SelectionEnvelope parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data, extensionRegistry) + .buildParsed(); + } + public static akka.remote.ContainerFormats.SelectionEnvelope parseFrom(java.io.InputStream input) + throws java.io.IOException { + return newBuilder().mergeFrom(input).buildParsed(); + } + public static akka.remote.ContainerFormats.SelectionEnvelope parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return newBuilder().mergeFrom(input, extensionRegistry) + .buildParsed(); + } + public static akka.remote.ContainerFormats.SelectionEnvelope parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + Builder builder = newBuilder(); + if (builder.mergeDelimitedFrom(input)) { + return builder.buildParsed(); + } else { + return null; + } + } + public static akka.remote.ContainerFormats.SelectionEnvelope 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 akka.remote.ContainerFormats.SelectionEnvelope parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return newBuilder().mergeFrom(input).buildParsed(); + } + public static akka.remote.ContainerFormats.SelectionEnvelope 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(akka.remote.ContainerFormats.SelectionEnvelope 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 + implements akka.remote.ContainerFormats.SelectionEnvelopeOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return akka.remote.ContainerFormats.internal_static_SelectionEnvelope_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return akka.remote.ContainerFormats.internal_static_SelectionEnvelope_fieldAccessorTable; + } + + // Construct using akka.remote.ContainerFormats.SelectionEnvelope.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getPatternFieldBuilder(); + } + } + private static Builder create() { + return new Builder(); + } + + public Builder clear() { + super.clear(); + enclosedMessage_ = com.google.protobuf.ByteString.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + serializerId_ = 0; + bitField0_ = (bitField0_ & ~0x00000002); + if (patternBuilder_ == null) { + pattern_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + } else { + patternBuilder_.clear(); + } + messageManifest_ = com.google.protobuf.ByteString.EMPTY; + bitField0_ = (bitField0_ & ~0x00000008); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return akka.remote.ContainerFormats.SelectionEnvelope.getDescriptor(); + } + + public akka.remote.ContainerFormats.SelectionEnvelope getDefaultInstanceForType() { + return akka.remote.ContainerFormats.SelectionEnvelope.getDefaultInstance(); + } + + public akka.remote.ContainerFormats.SelectionEnvelope build() { + akka.remote.ContainerFormats.SelectionEnvelope result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + private akka.remote.ContainerFormats.SelectionEnvelope buildParsed() + throws com.google.protobuf.InvalidProtocolBufferException { + akka.remote.ContainerFormats.SelectionEnvelope result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException( + result).asInvalidProtocolBufferException(); + } + return result; + } + + public akka.remote.ContainerFormats.SelectionEnvelope buildPartial() { + akka.remote.ContainerFormats.SelectionEnvelope result = new akka.remote.ContainerFormats.SelectionEnvelope(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.enclosedMessage_ = enclosedMessage_; + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + result.serializerId_ = serializerId_; + if (patternBuilder_ == null) { + if (((bitField0_ & 0x00000004) == 0x00000004)) { + pattern_ = java.util.Collections.unmodifiableList(pattern_); + bitField0_ = (bitField0_ & ~0x00000004); + } + result.pattern_ = pattern_; + } else { + result.pattern_ = patternBuilder_.build(); + } + if (((from_bitField0_ & 0x00000008) == 0x00000008)) { + to_bitField0_ |= 0x00000004; + } + result.messageManifest_ = messageManifest_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof akka.remote.ContainerFormats.SelectionEnvelope) { + return mergeFrom((akka.remote.ContainerFormats.SelectionEnvelope)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(akka.remote.ContainerFormats.SelectionEnvelope other) { + if (other == akka.remote.ContainerFormats.SelectionEnvelope.getDefaultInstance()) return this; + if (other.hasEnclosedMessage()) { + setEnclosedMessage(other.getEnclosedMessage()); + } + if (other.hasSerializerId()) { + setSerializerId(other.getSerializerId()); + } + if (patternBuilder_ == null) { + if (!other.pattern_.isEmpty()) { + if (pattern_.isEmpty()) { + pattern_ = other.pattern_; + bitField0_ = (bitField0_ & ~0x00000004); + } else { + ensurePatternIsMutable(); + pattern_.addAll(other.pattern_); + } + onChanged(); + } + } else { + if (!other.pattern_.isEmpty()) { + if (patternBuilder_.isEmpty()) { + patternBuilder_.dispose(); + patternBuilder_ = null; + pattern_ = other.pattern_; + bitField0_ = (bitField0_ & ~0x00000004); + patternBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? + getPatternFieldBuilder() : null; + } else { + patternBuilder_.addAllMessages(other.pattern_); + } + } + } + if (other.hasMessageManifest()) { + setMessageManifest(other.getMessageManifest()); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + if (!hasEnclosedMessage()) { + + return false; + } + if (!hasSerializerId()) { + + return false; + } + for (int i = 0; i < getPatternCount(); i++) { + if (!getPattern(i).isInitialized()) { + + 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; + enclosedMessage_ = input.readBytes(); + break; + } + case 16: { + bitField0_ |= 0x00000002; + serializerId_ = input.readInt32(); + break; + } + case 26: { + akka.remote.ContainerFormats.Selection.Builder subBuilder = akka.remote.ContainerFormats.Selection.newBuilder(); + input.readMessage(subBuilder, extensionRegistry); + addPattern(subBuilder.buildPartial()); + break; + } + case 34: { + bitField0_ |= 0x00000008; + messageManifest_ = input.readBytes(); + break; + } + } + } + } + + private int bitField0_; + + // required bytes enclosedMessage = 1; + private com.google.protobuf.ByteString enclosedMessage_ = com.google.protobuf.ByteString.EMPTY; + public boolean hasEnclosedMessage() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + public com.google.protobuf.ByteString getEnclosedMessage() { + return enclosedMessage_; + } + public Builder setEnclosedMessage(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + enclosedMessage_ = value; + onChanged(); + return this; + } + public Builder clearEnclosedMessage() { + bitField0_ = (bitField0_ & ~0x00000001); + enclosedMessage_ = getDefaultInstance().getEnclosedMessage(); + onChanged(); + return this; + } + + // required int32 serializerId = 2; + private int serializerId_ ; + public boolean hasSerializerId() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + public int getSerializerId() { + return serializerId_; + } + public Builder setSerializerId(int value) { + bitField0_ |= 0x00000002; + serializerId_ = value; + onChanged(); + return this; + } + public Builder clearSerializerId() { + bitField0_ = (bitField0_ & ~0x00000002); + serializerId_ = 0; + onChanged(); + return this; + } + + // repeated .Selection pattern = 3; + private java.util.List pattern_ = + java.util.Collections.emptyList(); + private void ensurePatternIsMutable() { + if (!((bitField0_ & 0x00000004) == 0x00000004)) { + pattern_ = new java.util.ArrayList(pattern_); + bitField0_ |= 0x00000004; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + akka.remote.ContainerFormats.Selection, akka.remote.ContainerFormats.Selection.Builder, akka.remote.ContainerFormats.SelectionOrBuilder> patternBuilder_; + + public java.util.List getPatternList() { + if (patternBuilder_ == null) { + return java.util.Collections.unmodifiableList(pattern_); + } else { + return patternBuilder_.getMessageList(); + } + } + public int getPatternCount() { + if (patternBuilder_ == null) { + return pattern_.size(); + } else { + return patternBuilder_.getCount(); + } + } + public akka.remote.ContainerFormats.Selection getPattern(int index) { + if (patternBuilder_ == null) { + return pattern_.get(index); + } else { + return patternBuilder_.getMessage(index); + } + } + public Builder setPattern( + int index, akka.remote.ContainerFormats.Selection value) { + if (patternBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePatternIsMutable(); + pattern_.set(index, value); + onChanged(); + } else { + patternBuilder_.setMessage(index, value); + } + return this; + } + public Builder setPattern( + int index, akka.remote.ContainerFormats.Selection.Builder builderForValue) { + if (patternBuilder_ == null) { + ensurePatternIsMutable(); + pattern_.set(index, builderForValue.build()); + onChanged(); + } else { + patternBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + public Builder addPattern(akka.remote.ContainerFormats.Selection value) { + if (patternBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePatternIsMutable(); + pattern_.add(value); + onChanged(); + } else { + patternBuilder_.addMessage(value); + } + return this; + } + public Builder addPattern( + int index, akka.remote.ContainerFormats.Selection value) { + if (patternBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePatternIsMutable(); + pattern_.add(index, value); + onChanged(); + } else { + patternBuilder_.addMessage(index, value); + } + return this; + } + public Builder addPattern( + akka.remote.ContainerFormats.Selection.Builder builderForValue) { + if (patternBuilder_ == null) { + ensurePatternIsMutable(); + pattern_.add(builderForValue.build()); + onChanged(); + } else { + patternBuilder_.addMessage(builderForValue.build()); + } + return this; + } + public Builder addPattern( + int index, akka.remote.ContainerFormats.Selection.Builder builderForValue) { + if (patternBuilder_ == null) { + ensurePatternIsMutable(); + pattern_.add(index, builderForValue.build()); + onChanged(); + } else { + patternBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + public Builder addAllPattern( + java.lang.Iterable values) { + if (patternBuilder_ == null) { + ensurePatternIsMutable(); + super.addAll(values, pattern_); + onChanged(); + } else { + patternBuilder_.addAllMessages(values); + } + return this; + } + public Builder clearPattern() { + if (patternBuilder_ == null) { + pattern_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + } else { + patternBuilder_.clear(); + } + return this; + } + public Builder removePattern(int index) { + if (patternBuilder_ == null) { + ensurePatternIsMutable(); + pattern_.remove(index); + onChanged(); + } else { + patternBuilder_.remove(index); + } + return this; + } + public akka.remote.ContainerFormats.Selection.Builder getPatternBuilder( + int index) { + return getPatternFieldBuilder().getBuilder(index); + } + public akka.remote.ContainerFormats.SelectionOrBuilder getPatternOrBuilder( + int index) { + if (patternBuilder_ == null) { + return pattern_.get(index); } else { + return patternBuilder_.getMessageOrBuilder(index); + } + } + public java.util.List + getPatternOrBuilderList() { + if (patternBuilder_ != null) { + return patternBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(pattern_); + } + } + public akka.remote.ContainerFormats.Selection.Builder addPatternBuilder() { + return getPatternFieldBuilder().addBuilder( + akka.remote.ContainerFormats.Selection.getDefaultInstance()); + } + public akka.remote.ContainerFormats.Selection.Builder addPatternBuilder( + int index) { + return getPatternFieldBuilder().addBuilder( + index, akka.remote.ContainerFormats.Selection.getDefaultInstance()); + } + public java.util.List + getPatternBuilderList() { + return getPatternFieldBuilder().getBuilderList(); + } + private com.google.protobuf.RepeatedFieldBuilder< + akka.remote.ContainerFormats.Selection, akka.remote.ContainerFormats.Selection.Builder, akka.remote.ContainerFormats.SelectionOrBuilder> + getPatternFieldBuilder() { + if (patternBuilder_ == null) { + patternBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< + akka.remote.ContainerFormats.Selection, akka.remote.ContainerFormats.Selection.Builder, akka.remote.ContainerFormats.SelectionOrBuilder>( + pattern_, + ((bitField0_ & 0x00000004) == 0x00000004), + getParentForChildren(), + isClean()); + pattern_ = null; + } + return patternBuilder_; + } + + // optional bytes messageManifest = 4; + private com.google.protobuf.ByteString messageManifest_ = com.google.protobuf.ByteString.EMPTY; + public boolean hasMessageManifest() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + public com.google.protobuf.ByteString getMessageManifest() { + return messageManifest_; + } + public Builder setMessageManifest(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000008; + messageManifest_ = value; + onChanged(); + return this; + } + public Builder clearMessageManifest() { + bitField0_ = (bitField0_ & ~0x00000008); + messageManifest_ = getDefaultInstance().getMessageManifest(); + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:SelectionEnvelope) + } + + static { + defaultInstance = new SelectionEnvelope(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:SelectionEnvelope) + } + + public interface SelectionOrBuilder + extends com.google.protobuf.MessageOrBuilder { + + // required .PatternType type = 1; + boolean hasType(); + akka.remote.ContainerFormats.PatternType getType(); + + // optional string matcher = 2; + boolean hasMatcher(); + String getMatcher(); + } + public static final class Selection extends + com.google.protobuf.GeneratedMessage + implements SelectionOrBuilder { + // Use Selection.newBuilder() to construct. + private Selection(Builder builder) { + super(builder); + } + private Selection(boolean noInit) {} + + private static final Selection defaultInstance; + public static Selection getDefaultInstance() { + return defaultInstance; + } + + public Selection getDefaultInstanceForType() { + return defaultInstance; + } + + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return akka.remote.ContainerFormats.internal_static_Selection_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return akka.remote.ContainerFormats.internal_static_Selection_fieldAccessorTable; + } + + private int bitField0_; + // required .PatternType type = 1; + public static final int TYPE_FIELD_NUMBER = 1; + private akka.remote.ContainerFormats.PatternType type_; + public boolean hasType() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + public akka.remote.ContainerFormats.PatternType getType() { + return type_; + } + + // optional string matcher = 2; + public static final int MATCHER_FIELD_NUMBER = 2; + private java.lang.Object matcher_; + public boolean hasMatcher() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + public String getMatcher() { + java.lang.Object ref = matcher_; + 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)) { + matcher_ = s; + } + return s; + } + } + private com.google.protobuf.ByteString getMatcherBytes() { + java.lang.Object ref = matcher_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((String) ref); + matcher_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private void initFields() { + type_ = akka.remote.ContainerFormats.PatternType.PARENT; + matcher_ = ""; + } + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized != -1) return isInitialized == 1; + + if (!hasType()) { + 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.writeEnum(1, type_.getNumber()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + output.writeBytes(2, getMatcherBytes()); + } + 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 + .computeEnumSize(1, type_.getNumber()); + } + if (((bitField0_ & 0x00000002) == 0x00000002)) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(2, getMatcherBytes()); + } + 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 akka.remote.ContainerFormats.Selection parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data).buildParsed(); + } + public static akka.remote.ContainerFormats.Selection parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data, extensionRegistry) + .buildParsed(); + } + public static akka.remote.ContainerFormats.Selection parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data).buildParsed(); + } + public static akka.remote.ContainerFormats.Selection parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data, extensionRegistry) + .buildParsed(); + } + public static akka.remote.ContainerFormats.Selection parseFrom(java.io.InputStream input) + throws java.io.IOException { + return newBuilder().mergeFrom(input).buildParsed(); + } + public static akka.remote.ContainerFormats.Selection parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return newBuilder().mergeFrom(input, extensionRegistry) + .buildParsed(); + } + public static akka.remote.ContainerFormats.Selection parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + Builder builder = newBuilder(); + if (builder.mergeDelimitedFrom(input)) { + return builder.buildParsed(); + } else { + return null; + } + } + public static akka.remote.ContainerFormats.Selection 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 akka.remote.ContainerFormats.Selection parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return newBuilder().mergeFrom(input).buildParsed(); + } + public static akka.remote.ContainerFormats.Selection 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(akka.remote.ContainerFormats.Selection 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 + implements akka.remote.ContainerFormats.SelectionOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return akka.remote.ContainerFormats.internal_static_Selection_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return akka.remote.ContainerFormats.internal_static_Selection_fieldAccessorTable; + } + + // Construct using akka.remote.ContainerFormats.Selection.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(); + type_ = akka.remote.ContainerFormats.PatternType.PARENT; + bitField0_ = (bitField0_ & ~0x00000001); + matcher_ = ""; + bitField0_ = (bitField0_ & ~0x00000002); + return this; + } + + public Builder clone() { + return create().mergeFrom(buildPartial()); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return akka.remote.ContainerFormats.Selection.getDescriptor(); + } + + public akka.remote.ContainerFormats.Selection getDefaultInstanceForType() { + return akka.remote.ContainerFormats.Selection.getDefaultInstance(); + } + + public akka.remote.ContainerFormats.Selection build() { + akka.remote.ContainerFormats.Selection result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + private akka.remote.ContainerFormats.Selection buildParsed() + throws com.google.protobuf.InvalidProtocolBufferException { + akka.remote.ContainerFormats.Selection result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException( + result).asInvalidProtocolBufferException(); + } + return result; + } + + public akka.remote.ContainerFormats.Selection buildPartial() { + akka.remote.ContainerFormats.Selection result = new akka.remote.ContainerFormats.Selection(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) == 0x00000001)) { + to_bitField0_ |= 0x00000001; + } + result.type_ = type_; + if (((from_bitField0_ & 0x00000002) == 0x00000002)) { + to_bitField0_ |= 0x00000002; + } + result.matcher_ = matcher_; + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof akka.remote.ContainerFormats.Selection) { + return mergeFrom((akka.remote.ContainerFormats.Selection)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(akka.remote.ContainerFormats.Selection other) { + if (other == akka.remote.ContainerFormats.Selection.getDefaultInstance()) return this; + if (other.hasType()) { + setType(other.getType()); + } + if (other.hasMatcher()) { + setMatcher(other.getMatcher()); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public final boolean isInitialized() { + if (!hasType()) { + + 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 8: { + int rawValue = input.readEnum(); + akka.remote.ContainerFormats.PatternType value = akka.remote.ContainerFormats.PatternType.valueOf(rawValue); + if (value == null) { + unknownFields.mergeVarintField(1, rawValue); + } else { + bitField0_ |= 0x00000001; + type_ = value; + } + break; + } + case 18: { + bitField0_ |= 0x00000002; + matcher_ = input.readBytes(); + break; + } + } + } + } + + private int bitField0_; + + // required .PatternType type = 1; + private akka.remote.ContainerFormats.PatternType type_ = akka.remote.ContainerFormats.PatternType.PARENT; + public boolean hasType() { + return ((bitField0_ & 0x00000001) == 0x00000001); + } + public akka.remote.ContainerFormats.PatternType getType() { + return type_; + } + public Builder setType(akka.remote.ContainerFormats.PatternType value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + type_ = value; + onChanged(); + return this; + } + public Builder clearType() { + bitField0_ = (bitField0_ & ~0x00000001); + type_ = akka.remote.ContainerFormats.PatternType.PARENT; + onChanged(); + return this; + } + + // optional string matcher = 2; + private java.lang.Object matcher_ = ""; + public boolean hasMatcher() { + return ((bitField0_ & 0x00000002) == 0x00000002); + } + public String getMatcher() { + java.lang.Object ref = matcher_; + if (!(ref instanceof String)) { + String s = ((com.google.protobuf.ByteString) ref).toStringUtf8(); + matcher_ = s; + return s; + } else { + return (String) ref; + } + } + public Builder setMatcher(String value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + matcher_ = value; + onChanged(); + return this; + } + public Builder clearMatcher() { + bitField0_ = (bitField0_ & ~0x00000002); + matcher_ = getDefaultInstance().getMatcher(); + onChanged(); + return this; + } + void setMatcher(com.google.protobuf.ByteString value) { + bitField0_ |= 0x00000002; + matcher_ = value; + onChanged(); + } + + // @@protoc_insertion_point(builder_scope:Selection) + } + + static { + defaultInstance = new Selection(true); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:Selection) + } + + private static com.google.protobuf.Descriptors.Descriptor + internal_static_SelectionEnvelope_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_SelectionEnvelope_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_Selection_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_Selection_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\026ContainerFormats.proto\"x\n\021SelectionEnv" + + "elope\022\027\n\017enclosedMessage\030\001 \002(\014\022\024\n\014serial" + + "izerId\030\002 \002(\005\022\033\n\007pattern\030\003 \003(\0132\n.Selectio" + + "n\022\027\n\017messageManifest\030\004 \001(\014\"8\n\tSelection\022" + + "\032\n\004type\030\001 \002(\0162\014.PatternType\022\017\n\007matcher\030\002" + + " \001(\t*<\n\013PatternType\022\n\n\006PARENT\020\000\022\016\n\nCHILD" + + "_NAME\020\001\022\021\n\rCHILD_PATTERN\020\002B\017\n\013akka.remot" + + "eH\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_SelectionEnvelope_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_SelectionEnvelope_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_SelectionEnvelope_descriptor, + new java.lang.String[] { "EnclosedMessage", "SerializerId", "Pattern", "MessageManifest", }, + akka.remote.ContainerFormats.SelectionEnvelope.class, + akka.remote.ContainerFormats.SelectionEnvelope.Builder.class); + internal_static_Selection_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_Selection_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_Selection_descriptor, + new java.lang.String[] { "Type", "Matcher", }, + akka.remote.ContainerFormats.Selection.class, + akka.remote.ContainerFormats.Selection.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/akka-remote/src/main/protocol/ContainerFormats.proto b/akka-remote/src/main/protocol/ContainerFormats.proto new file mode 100644 index 0000000000..7829169c1f --- /dev/null +++ b/akka-remote/src/main/protocol/ContainerFormats.proto @@ -0,0 +1,36 @@ +/** + * Copyright (C) 2009-2013 Typesafe Inc. + */ + +option java_package = "akka.remote"; +option optimize_for = SPEED; + +/****************************************** + Compile with: + cd ./akka-remote/src/main/protocol + protoc ContainerFormats.proto --java_out ../java + cd ../../../.. + ./scripts/fix-protobuf.sh +*******************************************/ + +/****************************************** + ActorSelection related formats +*******************************************/ + +message SelectionEnvelope { + required bytes enclosedMessage = 1; + required int32 serializerId = 2; + repeated Selection pattern = 3; + optional bytes messageManifest = 4; +} + +enum PatternType { + PARENT = 0; + CHILD_NAME = 1; + CHILD_PATTERN = 2; +} + +message Selection { + required PatternType type = 1; + optional string matcher = 2; +} \ No newline at end of file diff --git a/akka-remote/src/main/resources/reference.conf b/akka-remote/src/main/resources/reference.conf index fdb1927cb4..71eaedb118 100644 --- a/akka-remote/src/main/resources/reference.conf +++ b/akka-remote/src/main/resources/reference.conf @@ -13,6 +13,7 @@ akka { actor { serializers { + akka-containers = "akka.remote.serialization.MessageContainerSerializer" proto = "akka.remote.serialization.ProtobufSerializer" daemon-create = "akka.remote.serialization.DaemonMsgCreateSerializer" } @@ -22,6 +23,7 @@ akka { # Since com.google.protobuf.Message does not extend Serializable but # GeneratedMessage does, need to use the more specific one here in order # to avoid ambiguity + "akka.actor.SelectionPath" = akka-containers "com.google.protobuf.GeneratedMessage" = proto "akka.remote.DaemonMsgCreate" = daemon-create } diff --git a/akka-remote/src/main/scala/akka/remote/serialization/MessageContainerSerializer.scala b/akka-remote/src/main/scala/akka/remote/serialization/MessageContainerSerializer.scala new file mode 100644 index 0000000000..21c865d3d4 --- /dev/null +++ b/akka-remote/src/main/scala/akka/remote/serialization/MessageContainerSerializer.scala @@ -0,0 +1,82 @@ +/** + * Copyright (C) 2009-2013 Typesafe Inc. + */ +package akka.remote.serialization + +import akka.serialization.{ SerializationExtension, Serializer } +import akka.actor._ +import scala.annotation.tailrec +import akka.remote.ContainerFormats +import akka.remote.ContainerFormats.SelectionEnvelope +import akka.remote.WireFormats.SerializedMessage +import com.google.protobuf.ByteString +import akka.actor.SelectChildPattern +import akka.actor.SelectParent +import akka.actor.SelectChildName +import scala.Some +import java.util.regex.Pattern + +class MessageContainerSerializer(val system: ExtendedActorSystem) extends Serializer { + + def identifier: Int = 6 + + def includeManifest: Boolean = false + + def toBinary(obj: AnyRef): Array[Byte] = obj match { + case path: SelectionPath ⇒ + val builder = ContainerFormats.SelectionEnvelope.newBuilder() + serializeSelectionPath(path, builder) + builder.build().toByteArray + case _ ⇒ throw new IllegalArgumentException(s"Cannot serialize object of type [${obj.getClass.getName}]") + } + + import ContainerFormats.PatternType._ + + @tailrec + private def serializeSelectionPath(path: Any, builder: SelectionEnvelope.Builder): Unit = path match { + case SelectChildName(name, next) ⇒ + serializeSelectionPath(next, builder.addPattern(buildPattern(Some(name), CHILD_NAME))) + case SelectChildPattern(pattern, next) ⇒ + serializeSelectionPath(next, builder.addPattern(buildPattern(Some(pattern.toString), CHILD_PATTERN))) + case SelectParent(next) ⇒ + serializeSelectionPath(next, builder.addPattern(buildPattern(None, PARENT))) + case message: AnyRef ⇒ + val serializer = SerializationExtension(system).findSerializerFor(message) + builder + .setEnclosedMessage(ByteString.copyFrom(serializer.toBinary(message))) + .setSerializerId(serializer.identifier) + if (serializer.includeManifest) + builder.setMessageManifest(ByteString.copyFromUtf8(message.getClass.getName)) + builder + } + + private def buildPattern(matcher: Option[String], tpe: ContainerFormats.PatternType): ContainerFormats.Selection.Builder = { + val builder = ContainerFormats.Selection.newBuilder().setType(tpe) + matcher foreach builder.setMatcher + builder + } + + def fromBinary(bytes: Array[Byte], manifest: Option[Class[_]]): AnyRef = { + val selectionEnvelope = ContainerFormats.SelectionEnvelope.parseFrom(bytes) + val msg = SerializationExtension(system).deserialize( + selectionEnvelope.getEnclosedMessage.toByteArray, + selectionEnvelope.getSerializerId, + if (selectionEnvelope.hasMessageManifest) + Some(system.dynamicAccess.getClassFor[AnyRef](selectionEnvelope.getMessageManifest.toStringUtf8).get) else None).get + + @tailrec + def reconstruct(remaining: Seq[ContainerFormats.Selection], nextLink: AnyRef): AnyRef = remaining match { + case Nil ⇒ nextLink + case sel :: tail ⇒ + val next = sel.getType match { + case CHILD_NAME ⇒ SelectChildName(sel.getMatcher, nextLink) + case CHILD_PATTERN ⇒ SelectChildPattern(Pattern.compile(sel.getMatcher), nextLink) + case PARENT ⇒ SelectParent(nextLink) + } + reconstruct(tail, next) + } + + import scala.collection.JavaConverters._ + reconstruct(selectionEnvelope.getPatternList.asScala.toList.reverse, msg) + } +}