diff --git a/akka-core/src/main/scala/actor/Actor.scala b/akka-core/src/main/scala/actor/Actor.scala index ec4cd938ad..321095d84c 100644 --- a/akka-core/src/main/scala/actor/Actor.scala +++ b/akka-core/src/main/scala/actor/Actor.scala @@ -11,8 +11,10 @@ import se.scalablesolutions.akka.config.ScalaConfig._ import se.scalablesolutions.akka.stm.Transaction.Global._ import se.scalablesolutions.akka.stm.TransactionManagement._ import se.scalablesolutions.akka.stm.TransactionManagement -import se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.RemoteRequest -import se.scalablesolutions.akka.remote.{RemoteNode, RemoteServer, RemoteClient, RemoteProtocolBuilder, RemoteRequestIdFactory} +import se.scalablesolutions.akka.remote.protobuf.RemoteProtocol +import se.scalablesolutions.akka.remote.{RemoteNode, RemoteServer, RemoteClient, + RemoteActorProxy, RemoteProtocolBuilder, + RemoteRequestIdFactory} import se.scalablesolutions.akka.serialization.Serializer import se.scalablesolutions.akka.util.{HashCode, Logging, UUID} @@ -242,10 +244,34 @@ object Actor extends Logging { } +/** + * The ActorID object can be used to create ActorID instances out of its binary + * protobuf based representation. + *
+ *   val actorRef = ActorID.fromBinary(bytes)
+ *   actorRef ! message // send message to remote actor through its reference
+ * 
+ * + * @author Jonas Bonér + */ +object ActorID { + def fromBinary(bytes: Array[Byte]): ActorID = { + val actorRefProto = RemoteProtocol.ActorRef.newBuilder.mergeFrom(bytes).build + RemoteActorProxy( + actorRefProto.getUuid, + actorRefProto.getActorClassName, + actorRefProto.getSourceHostname, + actorRefProto.getSourcePort, + actorRefProto.getTimeout) + } +} + /** * ActorID is an immutable and serializable handle to an Actor. + *

* Create an ActorID for an Actor by using the factory method on the Actor object. - * Here is an example: + *

+ * Here is an example on how to create an actor with a default constructor. *

  *   import Actor._
  * 
@@ -254,24 +280,23 @@ object Actor extends Logging {
  *   actor ! message
  *   actor.stop
  * 
+ * Here is an example on how to create an actor with a non-default constructor. + *
+ *   import Actor._
+ * 
+ *   val actor = newActor(() => new MyActor(...))
+ *   actor.start
+ *   actor ! message
+ *   actor.stop
+ * 
* * @author Jonas Bonér */ final class ActorID private[akka] () { - private[akka] var newActorFactory: Either[Option[Class[_ <: Actor]], Option[() => Actor]] = Left(None) + private[akka] var actorFactory: Either[Option[Class[_ <: Actor]], Option[() => Actor]] = Left(None) - private[akka] def this(clazz: Class[_ <: Actor]) = { - this() - newActorFactory = Left(Some(clazz)) - } - - private[akka] def this(factory: () => Actor) = { - this() - newActorFactory = Right(Some(factory)) - } - private[akka] lazy val actor: Actor = { - val actor = newActorFactory match { + val actor = actorFactory match { case Left(Some(clazz)) => try { clazz.newInstance @@ -290,6 +315,30 @@ final class ActorID private[akka] () { actor } + private[akka] def this(clazz: Class[_ <: Actor]) = { + this() + actorFactory = Left(Some(clazz)) + } + + private[akka] def this(factory: () => Actor) = { + this() + actorFactory = Right(Some(factory)) + } + + def toBinary: Array[Byte] = { + if (!actor._registeredInRemoteNodeDuringSerialization) { + RemoteNode.register(uuid, this) + actor._registeredInRemoteNodeDuringSerialization = true + } + RemoteProtocol.ActorRef.newBuilder + .setUuid(uuid) + .setActorClassName(actorClass.getName) + .setSourceHostname(RemoteServer.HOSTNAME) + .setSourcePort(RemoteServer.PORT) + .setTimeout(timeout) + .build.toByteArray + } + /** * Returns the class for the Actor instance that is managed by the ActorID. */ @@ -546,6 +595,7 @@ trait Actor extends TransactionManagement with Logging { @volatile private[this] var _isSuspended = true @volatile private[this] var _isShutDown = false @volatile private[akka] var _isKilled = false + @volatile private[akka] var _registeredInRemoteNodeDuringSerialization = true private var _hotswap: Option[PartialFunction[Any, Unit]] = None private[akka] var _remoteAddress: Option[InetSocketAddress] = None private[akka] var _linkedActors: Option[HashSet[ActorID]] = None @@ -755,6 +805,7 @@ trait Actor extends TransactionManagement with Logging { shutdown ActorRegistry.unregister(self) _remoteAddress.foreach(address => RemoteClient.unregister(address.getHostName, address.getPort, uuid)) + RemoteNode.unregister(self) } } @@ -1011,7 +1062,7 @@ trait Actor extends TransactionManagement with Logging { joinTransaction(message) if (_remoteAddress.isDefined) { - val requestBuilder = RemoteRequest.newBuilder + val requestBuilder = RemoteProtocol.RemoteRequest.newBuilder .setId(RemoteRequestIdFactory.nextId) .setTarget(this.getClass.getName) .setTimeout(this.timeout) @@ -1062,7 +1113,7 @@ trait Actor extends TransactionManagement with Logging { joinTransaction(message) if (_remoteAddress.isDefined) { - val requestBuilder = RemoteRequest.newBuilder + val requestBuilder = RemoteProtocol.RemoteRequest.newBuilder .setId(RemoteRequestIdFactory.nextId) .setTarget(this.getClass.getName) .setTimeout(this.timeout) @@ -1079,7 +1130,8 @@ trait Actor extends TransactionManagement with Logging { } else { val future = if (senderFuture.isDefined) senderFuture.get else new DefaultCompletableFuture[T](timeout) - val invocation = new MessageInvocation(self, message, Some(Right(future.asInstanceOf[CompletableFuture[Any]])), transactionSet.get) + val invocation = new MessageInvocation( + self, message, Some(Right(future.asInstanceOf[CompletableFuture[Any]])), transactionSet.get) if (messageDispatcher.usesActorMailbox) _mailbox.add(invocation) diff --git a/akka-core/src/main/scala/actor/ActorIdProtobufSpec.proto b/akka-core/src/main/scala/actor/ActorIdProtobufSpec.proto new file mode 100644 index 0000000000..e69de29bb2 diff --git a/akka-core/src/main/scala/remote/RemoteClient.scala b/akka-core/src/main/scala/remote/RemoteClient.scala index 9c03683771..4948b3cb72 100644 --- a/akka-core/src/main/scala/remote/RemoteClient.scala +++ b/akka-core/src/main/scala/remote/RemoteClient.scala @@ -27,6 +27,8 @@ import java.util.concurrent.atomic.AtomicLong import scala.collection.mutable.{HashSet, HashMap} /** + * Atomic remote request/reply message id generator. + * * @author Jonas Bonér */ object RemoteRequestIdFactory { @@ -41,6 +43,69 @@ case class RemoteClientError(cause: Throwable) extends RemoteClientLifeCycleEven case class RemoteClientDisconnected(host: String, port: Int) extends RemoteClientLifeCycleEvent case class RemoteClientConnected(host: String, port: Int) extends RemoteClientLifeCycleEvent +/** + * Remote Actor proxy factory. + * + * @author Jonas Bonér + */ +private[akka] object RemoteActorProxy { + def apply(uuid: String, className: String, hostname: String, port: Int, timeout: Long): ActorID = + new ActorID(() => new RemoteActorProxy(uuid, className, hostname, port, timeout)) +} + +/** + * Remote Actor proxy. + * + * @author Jonas Bonér + */ +private[akka] class RemoteActorProxy private ( + uuid: String, className: String, hostname: String, port: Int, timeOut: Long) extends Actor { + start + val remoteClient = RemoteClient.clientFor(hostname, port) + + override def postMessageToMailbox(message: Any, senderOption: Option[ActorID]): Unit = { + val requestBuilder = RemoteRequest.newBuilder + .setId(RemoteRequestIdFactory.nextId) + .setTarget(className) + .setTimeout(timeOut) + .setUuid(uuid) + .setIsActor(true) + .setIsOneWay(true) + .setIsEscaped(false) + if (senderOption.isDefined) { + val sender = senderOption.get.actor + requestBuilder.setSourceTarget(sender.getClass.getName) + requestBuilder.setSourceUuid(sender.uuid) + val (host, port) = sender._replyToAddress.map(address => + (address.getHostName, address.getPort)).getOrElse((Actor.HOSTNAME, Actor.PORT)) + requestBuilder.setSourceHostname(host) + requestBuilder.setSourcePort(port) + } + RemoteProtocolBuilder.setMessage(message, requestBuilder) + remoteClient.send[Any](requestBuilder.build, None) + } + + override def postMessageToMailboxAndCreateFutureResultWithTimeout[T]( + message: Any, + timeout: Long, + senderFuture: Option[CompletableFuture[T]]): CompletableFuture[T] = { + val requestBuilder = RemoteRequest.newBuilder + .setId(RemoteRequestIdFactory.nextId) + .setTarget(className) + .setTimeout(timeout) + .setUuid(uuid) + .setIsActor(true) + .setIsOneWay(false) + .setIsEscaped(false) + RemoteProtocolBuilder.setMessage(message, requestBuilder) + val future = remoteClient.send(requestBuilder.build, senderFuture) + if (future.isDefined) future.get + else throw new IllegalStateException("Expected a future from remote call to actor " + toString) + } + + def receive = {case _ => {}} +} + /** * @author Jonas Bonér */ @@ -62,53 +127,8 @@ object RemoteClient extends Logging { def actorFor(className: String, timeout: Long, hostname: String, port: Int): ActorID = actorFor(className, className, timeout, hostname, port) - def actorFor(actorId: String, className: String, timeout: Long, hostname: String, port: Int): ActorID = new ActorID(() => - new Actor { - start - val remoteClient = RemoteClient.clientFor(hostname, port) - - override def postMessageToMailbox(message: Any, sender: Option[ActorID]): Unit = { - val requestBuilder = RemoteRequest.newBuilder - .setId(RemoteRequestIdFactory.nextId) - .setTarget(className) - .setTimeout(timeout) - .setUuid(actorId) - .setIsActor(true) - .setIsOneWay(true) - .setIsEscaped(false) - if (sender.isDefined) { - val sndr = sender.get.actor - requestBuilder.setSourceTarget(sndr.getClass.getName) - requestBuilder.setSourceUuid(sndr.uuid) - val (host, port) = sndr._replyToAddress.map(a => (a.getHostName, a.getPort)).getOrElse((Actor.HOSTNAME, Actor.PORT)) - requestBuilder.setSourceHostname(host) - requestBuilder.setSourcePort(port) - } - RemoteProtocolBuilder.setMessage(message, requestBuilder) - remoteClient.send[Any](requestBuilder.build, None) - } - - override def postMessageToMailboxAndCreateFutureResultWithTimeout[T]( - message: Any, - timeout: Long, - senderFuture: Option[CompletableFuture[T]]): CompletableFuture[T] = { - val requestBuilder = RemoteRequest.newBuilder - .setId(RemoteRequestIdFactory.nextId) - .setTarget(className) - .setTimeout(timeout) - .setUuid(actorId) - .setIsActor(true) - .setIsOneWay(false) - .setIsEscaped(false) - RemoteProtocolBuilder.setMessage(message, requestBuilder) - val future = remoteClient.send(requestBuilder.build, senderFuture) - if (future.isDefined) future.get - else throw new IllegalStateException("Expected a future from remote call to actor " + toString) - } - - def receive = {case _ => {}} - } - ) + def actorFor(actorId: String, className: String, timeout: Long, hostname: String, port: Int): ActorID = + RemoteActorProxy(actorId, className, hostname, port, timeout) def clientFor(hostname: String, port: Int): RemoteClient = clientFor(new InetSocketAddress(hostname, port)) diff --git a/akka-core/src/main/scala/remote/RemoteServer.scala b/akka-core/src/main/scala/remote/RemoteServer.scala index 64e72f3fe8..f84a7a9ad9 100644 --- a/akka-core/src/main/scala/remote/RemoteServer.scala +++ b/akka-core/src/main/scala/remote/RemoteServer.scala @@ -168,7 +168,8 @@ class RemoteServer extends Logging { log.info("Starting remote server at [%s:%s]", hostname, port) RemoteServer.register(hostname, port, this) val remoteActorSet = RemoteServer.actorsFor(RemoteServer.Address(hostname, port)) - val pipelineFactory = new RemoteServerPipelineFactory(name, openChannels, loader, remoteActorSet.actors, remoteActorSet.activeObjects) + val pipelineFactory = new RemoteServerPipelineFactory( + name, openChannels, loader, remoteActorSet.actors, remoteActorSet.activeObjects) bootstrap.setPipelineFactory(pipelineFactory) bootstrap.setOption("child.tcpNoDelay", true) bootstrap.setOption("child.keepAlive", true) @@ -200,7 +201,7 @@ class RemoteServer extends Logging { */ def register(actor: ActorID) = synchronized { if (_isRunning) { - log.info("Registering server side remote actor [%s] with id [%s]", actor.getClass.getName, actor.id) + log.info("Registering server side remote actor [%s] with id [%s]", actor.actorClass.getName, actor.id) RemoteServer.actorsFor(RemoteServer.Address(hostname, port)).actors.put(actor.id, actor) } } @@ -210,10 +211,22 @@ class RemoteServer extends Logging { */ def register(id: String, actor: ActorID) = synchronized { if (_isRunning) { - log.info("Registering server side remote actor [%s] with id [%s]", actor.getClass.getName, id) + log.info("Registering server side remote actor [%s] with id [%s]", actor.actorClass.getName, id) RemoteServer.actorsFor(RemoteServer.Address(hostname, port)).actors.put(id, actor) } } + + /** + * Unregister Remote Actor. + */ + def unregister(actor: ActorID) = synchronized { + if (_isRunning) { + log.info("Unregistering server side remote actor [%s] with id [%s]", actor.actorClass.getName, actor.id) + val server = RemoteServer.actorsFor(RemoteServer.Address(hostname, port)) + server.actors.put(actor.id, actor) + if (actor.actor._registeredInRemoteNodeDuringSerialization) server.actors.remove(actor.uuid) + } + } } case class Codec(encoder : ChannelHandler, decoder : ChannelHandler) diff --git a/akka-util-java/src/main/java/se/scalablesolutions/akka/remote/protobuf/RemoteProtocol.java b/akka-util-java/src/main/java/se/scalablesolutions/akka/remote/protobuf/RemoteProtocol.java index f8ee893393..724978ef12 100644 --- a/akka-util-java/src/main/java/se/scalablesolutions/akka/remote/protobuf/RemoteProtocol.java +++ b/akka-util-java/src/main/java/se/scalablesolutions/akka/remote/protobuf/RemoteProtocol.java @@ -7,6 +7,443 @@ public final class RemoteProtocol { public static void registerAllExtensions( com.google.protobuf.ExtensionRegistry registry) { } + public static final class ActorRef extends + com.google.protobuf.GeneratedMessage { + // Use ActorRef.newBuilder() to construct. + private ActorRef() {} + + private static final ActorRef defaultInstance = new ActorRef(); + public static ActorRef getDefaultInstance() { + return defaultInstance; + } + + public ActorRef getDefaultInstanceForType() { + return defaultInstance; + } + + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.internal_static_se_scalablesolutions_akka_remote_protobuf_ActorRef_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.internal_static_se_scalablesolutions_akka_remote_protobuf_ActorRef_fieldAccessorTable; + } + + // required string uuid = 1; + public static final int UUID_FIELD_NUMBER = 1; + private boolean hasUuid; + private java.lang.String uuid_ = ""; + public boolean hasUuid() { return hasUuid; } + public java.lang.String getUuid() { return uuid_; } + + // required string actorClassName = 2; + public static final int ACTORCLASSNAME_FIELD_NUMBER = 2; + private boolean hasActorClassName; + private java.lang.String actorClassName_ = ""; + public boolean hasActorClassName() { return hasActorClassName; } + public java.lang.String getActorClassName() { return actorClassName_; } + + // required string sourceHostname = 3; + public static final int SOURCEHOSTNAME_FIELD_NUMBER = 3; + private boolean hasSourceHostname; + private java.lang.String sourceHostname_ = ""; + public boolean hasSourceHostname() { return hasSourceHostname; } + public java.lang.String getSourceHostname() { return sourceHostname_; } + + // required uint32 sourcePort = 4; + public static final int SOURCEPORT_FIELD_NUMBER = 4; + private boolean hasSourcePort; + private int sourcePort_ = 0; + public boolean hasSourcePort() { return hasSourcePort; } + public int getSourcePort() { return sourcePort_; } + + // required uint64 timeout = 5; + public static final int TIMEOUT_FIELD_NUMBER = 5; + private boolean hasTimeout; + private long timeout_ = 0L; + public boolean hasTimeout() { return hasTimeout; } + public long getTimeout() { return timeout_; } + + public final boolean isInitialized() { + if (!hasUuid) return false; + if (!hasActorClassName) return false; + if (!hasSourceHostname) return false; + if (!hasSourcePort) return false; + if (!hasTimeout) return false; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + if (hasUuid()) { + output.writeString(1, getUuid()); + } + if (hasActorClassName()) { + output.writeString(2, getActorClassName()); + } + if (hasSourceHostname()) { + output.writeString(3, getSourceHostname()); + } + if (hasSourcePort()) { + output.writeUInt32(4, getSourcePort()); + } + if (hasTimeout()) { + output.writeUInt64(5, getTimeout()); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + if (hasUuid()) { + size += com.google.protobuf.CodedOutputStream + .computeStringSize(1, getUuid()); + } + if (hasActorClassName()) { + size += com.google.protobuf.CodedOutputStream + .computeStringSize(2, getActorClassName()); + } + if (hasSourceHostname()) { + size += com.google.protobuf.CodedOutputStream + .computeStringSize(3, getSourceHostname()); + } + if (hasSourcePort()) { + size += com.google.protobuf.CodedOutputStream + .computeUInt32Size(4, getSourcePort()); + } + if (hasTimeout()) { + size += com.google.protobuf.CodedOutputStream + .computeUInt64Size(5, getTimeout()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + public static se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.ActorRef parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data).buildParsed(); + } + public static se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.ActorRef parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data, extensionRegistry) + .buildParsed(); + } + public static se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.ActorRef parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data).buildParsed(); + } + public static se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.ActorRef parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data, extensionRegistry) + .buildParsed(); + } + public static se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.ActorRef parseFrom(java.io.InputStream input) + throws java.io.IOException { + return newBuilder().mergeFrom(input).buildParsed(); + } + public static se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.ActorRef parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return newBuilder().mergeFrom(input, extensionRegistry) + .buildParsed(); + } + public static se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.ActorRef parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return newBuilder().mergeDelimitedFrom(input).buildParsed(); + } + public static se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.ActorRef parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return newBuilder().mergeDelimitedFrom(input, extensionRegistry) + .buildParsed(); + } + public static se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.ActorRef parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return newBuilder().mergeFrom(input).buildParsed(); + } + public static se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.ActorRef 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(se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.ActorRef prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder { + private se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.ActorRef result; + + // Construct using se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.ActorRef.newBuilder() + private Builder() {} + + private static Builder create() { + Builder builder = new Builder(); + builder.result = new se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.ActorRef(); + return builder; + } + + protected se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.ActorRef internalGetResult() { + return result; + } + + public Builder clear() { + if (result == null) { + throw new IllegalStateException( + "Cannot call clear() after build()."); + } + result = new se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.ActorRef(); + return this; + } + + public Builder clone() { + return create().mergeFrom(result); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.ActorRef.getDescriptor(); + } + + public se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.ActorRef getDefaultInstanceForType() { + return se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.ActorRef.getDefaultInstance(); + } + + public boolean isInitialized() { + return result.isInitialized(); + } + public se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.ActorRef build() { + if (result != null && !isInitialized()) { + throw newUninitializedMessageException(result); + } + return buildPartial(); + } + + private se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.ActorRef buildParsed() + throws com.google.protobuf.InvalidProtocolBufferException { + if (!isInitialized()) { + throw newUninitializedMessageException( + result).asInvalidProtocolBufferException(); + } + return buildPartial(); + } + + public se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.ActorRef buildPartial() { + if (result == null) { + throw new IllegalStateException( + "build() has already been called on this Builder."); + } + se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.ActorRef returnMe = result; + result = null; + return returnMe; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.ActorRef) { + return mergeFrom((se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.ActorRef)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.ActorRef other) { + if (other == se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.ActorRef.getDefaultInstance()) return this; + if (other.hasUuid()) { + setUuid(other.getUuid()); + } + if (other.hasActorClassName()) { + setActorClassName(other.getActorClassName()); + } + if (other.hasSourceHostname()) { + setSourceHostname(other.getSourceHostname()); + } + if (other.hasSourcePort()) { + setSourcePort(other.getSourcePort()); + } + if (other.hasTimeout()) { + setTimeout(other.getTimeout()); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + 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()); + return this; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + this.setUnknownFields(unknownFields.build()); + return this; + } + break; + } + case 10: { + setUuid(input.readString()); + break; + } + case 18: { + setActorClassName(input.readString()); + break; + } + case 26: { + setSourceHostname(input.readString()); + break; + } + case 32: { + setSourcePort(input.readUInt32()); + break; + } + case 40: { + setTimeout(input.readUInt64()); + break; + } + } + } + } + + + // required string uuid = 1; + public boolean hasUuid() { + return result.hasUuid(); + } + public java.lang.String getUuid() { + return result.getUuid(); + } + public Builder setUuid(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + result.hasUuid = true; + result.uuid_ = value; + return this; + } + public Builder clearUuid() { + result.hasUuid = false; + result.uuid_ = getDefaultInstance().getUuid(); + return this; + } + + // required string actorClassName = 2; + public boolean hasActorClassName() { + return result.hasActorClassName(); + } + public java.lang.String getActorClassName() { + return result.getActorClassName(); + } + public Builder setActorClassName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + result.hasActorClassName = true; + result.actorClassName_ = value; + return this; + } + public Builder clearActorClassName() { + result.hasActorClassName = false; + result.actorClassName_ = getDefaultInstance().getActorClassName(); + return this; + } + + // required string sourceHostname = 3; + public boolean hasSourceHostname() { + return result.hasSourceHostname(); + } + public java.lang.String getSourceHostname() { + return result.getSourceHostname(); + } + public Builder setSourceHostname(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + result.hasSourceHostname = true; + result.sourceHostname_ = value; + return this; + } + public Builder clearSourceHostname() { + result.hasSourceHostname = false; + result.sourceHostname_ = getDefaultInstance().getSourceHostname(); + return this; + } + + // required uint32 sourcePort = 4; + public boolean hasSourcePort() { + return result.hasSourcePort(); + } + public int getSourcePort() { + return result.getSourcePort(); + } + public Builder setSourcePort(int value) { + result.hasSourcePort = true; + result.sourcePort_ = value; + return this; + } + public Builder clearSourcePort() { + result.hasSourcePort = false; + result.sourcePort_ = 0; + return this; + } + + // required uint64 timeout = 5; + public boolean hasTimeout() { + return result.hasTimeout(); + } + public long getTimeout() { + return result.getTimeout(); + } + public Builder setTimeout(long value) { + result.hasTimeout = true; + result.timeout_ = value; + return this; + } + public Builder clearTimeout() { + result.hasTimeout = false; + result.timeout_ = 0L; + return this; + } + } + + static { + se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.getDescriptor(); + } + + static { + se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.internalForceInit(); + } + } + public static final class RemoteRequest extends com.google.protobuf.GeneratedMessage { // Use RemoteRequest.newBuilder() to construct. @@ -1450,6 +1887,11 @@ public final class RemoteProtocol { } } + private static com.google.protobuf.Descriptors.Descriptor + internal_static_se_scalablesolutions_akka_remote_protobuf_ActorRef_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_se_scalablesolutions_akka_remote_protobuf_ActorRef_fieldAccessorTable; private static com.google.protobuf.Descriptors.Descriptor internal_static_se_scalablesolutions_akka_remote_protobuf_RemoteRequest_descriptor; private static @@ -1471,27 +1913,38 @@ public final class RemoteProtocol { java.lang.String[] descriptorData = { "\n>se/scalablesolutions/akka/remote/proto" + "buf/RemoteProtocol.proto\022)se.scalablesol" + - "utions.akka.remote.protobuf\"\272\002\n\rRemoteRe" + - "quest\022\n\n\002id\030\001 \002(\004\022\020\n\010protocol\030\002 \002(\r\022\017\n\007m" + - "essage\030\003 \002(\014\022\027\n\017messageManifest\030\004 \001(\014\022\016\n" + - "\006method\030\005 \001(\t\022\016\n\006target\030\006 \002(\t\022\014\n\004uuid\030\007 " + - "\002(\t\022\017\n\007timeout\030\010 \002(\004\022\026\n\016supervisorUuid\030\t" + - " \001(\t\022\017\n\007isActor\030\n \002(\010\022\020\n\010isOneWay\030\013 \002(\010\022" + - "\021\n\tisEscaped\030\014 \002(\010\022\026\n\016sourceHostname\030\r \001" + - "(\t\022\022\n\nsourcePort\030\016 \001(\r\022\024\n\014sourceTarget\030\017", - " \001(\t\022\022\n\nsourceUuid\030\020 \001(\t\"\247\001\n\013RemoteReply" + - "\022\n\n\002id\030\001 \002(\004\022\020\n\010protocol\030\002 \001(\r\022\017\n\007messag" + - "e\030\003 \001(\014\022\027\n\017messageManifest\030\004 \001(\014\022\021\n\texce" + - "ption\030\005 \001(\t\022\026\n\016supervisorUuid\030\006 \001(\t\022\017\n\007i" + - "sActor\030\007 \002(\010\022\024\n\014isSuccessful\030\010 \002(\010" + "utions.akka.remote.protobuf\"m\n\010ActorRef\022" + + "\014\n\004uuid\030\001 \002(\t\022\026\n\016actorClassName\030\002 \002(\t\022\026\n" + + "\016sourceHostname\030\003 \002(\t\022\022\n\nsourcePort\030\004 \002(" + + "\r\022\017\n\007timeout\030\005 \002(\004\"\272\002\n\rRemoteRequest\022\n\n\002" + + "id\030\001 \002(\004\022\020\n\010protocol\030\002 \002(\r\022\017\n\007message\030\003 " + + "\002(\014\022\027\n\017messageManifest\030\004 \001(\014\022\016\n\006method\030\005" + + " \001(\t\022\016\n\006target\030\006 \002(\t\022\014\n\004uuid\030\007 \002(\t\022\017\n\007ti" + + "meout\030\010 \002(\004\022\026\n\016supervisorUuid\030\t \001(\t\022\017\n\007i", + "sActor\030\n \002(\010\022\020\n\010isOneWay\030\013 \002(\010\022\021\n\tisEsca" + + "ped\030\014 \002(\010\022\026\n\016sourceHostname\030\r \001(\t\022\022\n\nsou" + + "rcePort\030\016 \001(\r\022\024\n\014sourceTarget\030\017 \001(\t\022\022\n\ns" + + "ourceUuid\030\020 \001(\t\"\247\001\n\013RemoteReply\022\n\n\002id\030\001 " + + "\002(\004\022\020\n\010protocol\030\002 \001(\r\022\017\n\007message\030\003 \001(\014\022\027" + + "\n\017messageManifest\030\004 \001(\014\022\021\n\texception\030\005 \001" + + "(\t\022\026\n\016supervisorUuid\030\006 \001(\t\022\017\n\007isActor\030\007 " + + "\002(\010\022\024\n\014isSuccessful\030\010 \002(\010" }; 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_se_scalablesolutions_akka_remote_protobuf_RemoteRequest_descriptor = + internal_static_se_scalablesolutions_akka_remote_protobuf_ActorRef_descriptor = getDescriptor().getMessageTypes().get(0); + internal_static_se_scalablesolutions_akka_remote_protobuf_ActorRef_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_se_scalablesolutions_akka_remote_protobuf_ActorRef_descriptor, + new java.lang.String[] { "Uuid", "ActorClassName", "SourceHostname", "SourcePort", "Timeout", }, + se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.ActorRef.class, + se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.ActorRef.Builder.class); + internal_static_se_scalablesolutions_akka_remote_protobuf_RemoteRequest_descriptor = + getDescriptor().getMessageTypes().get(1); internal_static_se_scalablesolutions_akka_remote_protobuf_RemoteRequest_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_se_scalablesolutions_akka_remote_protobuf_RemoteRequest_descriptor, @@ -1499,7 +1952,7 @@ public final class RemoteProtocol { se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.RemoteRequest.class, se.scalablesolutions.akka.remote.protobuf.RemoteProtocol.RemoteRequest.Builder.class); internal_static_se_scalablesolutions_akka_remote_protobuf_RemoteReply_descriptor = - getDescriptor().getMessageTypes().get(1); + getDescriptor().getMessageTypes().get(2); internal_static_se_scalablesolutions_akka_remote_protobuf_RemoteReply_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_se_scalablesolutions_akka_remote_protobuf_RemoteReply_descriptor, diff --git a/akka-util-java/src/main/java/se/scalablesolutions/akka/remote/protobuf/RemoteProtocol.proto b/akka-util-java/src/main/java/se/scalablesolutions/akka/remote/protobuf/RemoteProtocol.proto index 79885bd043..c2ccef040d 100644 --- a/akka-util-java/src/main/java/se/scalablesolutions/akka/remote/protobuf/RemoteProtocol.proto +++ b/akka-util-java/src/main/java/se/scalablesolutions/akka/remote/protobuf/RemoteProtocol.proto @@ -10,6 +10,14 @@ package se.scalablesolutions.akka.remote.protobuf; protoc se/scalablesolutions/akka/remote/protobuf/RemoteProtocol.proto --java_out . */ +message ActorRef { + required string uuid = 1; + required string actorClassName = 2; + required string sourceHostname = 3; + required uint32 sourcePort = 4; + required uint64 timeout = 5; +} + message RemoteRequest { required uint64 id = 1; required uint32 protocol = 2;