- * The comparison is done based on the id if both the instances. - * - * @param other The actorId to compare with this instance. - * @return A 32-bit signed integer that indicates whether this instance - * precedes, follows, or appears in the same position in the sort order as the - * other parameter. - */ - @Override - public int compareTo(ActorId other) { - return (other == null) ? 1 - : compareContent(this, other); - } - - /** - * - * @return The hash code of this ActorId - */ - @Override - public int hashCode() { - return this.stringId.hashCode(); - } - - /** - * Compare if the content of two ids are the same. - * @param id1 One identifier. - * @param id2 Another identifier. - * @return -1, 0, or 1 depending on the compare result of the stringId member. - */ - private int compareContent(ActorId id1, ActorId id2) { - return id1.stringId.compareTo(id2.stringId); - } - - /** - * Checks if this instance is equals to the other instance. - * @return true if the 2 ActorId's are equal. - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; + + /** + * @return The String representation of this ActorId + */ + @Override + public String toString() { + return this.stringId; + } + + /** + * Compares this instance with a specified {link #ActorId} object and + * indicates whether this instance precedes, follows, or appears in the same + * position in the sort order as the specified actorId. + *
+ * The comparison is done based on the id if both the instances.
+ *
+ * @param other The actorId to compare with this instance.
+ * @return A 32-bit signed integer that indicates whether this instance
+ * precedes, follows, or appears in the same position in the sort order as the
+ * other parameter.
+ */
+ @Override
+ public int compareTo(ActorId other) {
+ return (other == null) ? 1
+ : compareContent(this, other);
+ }
+
+ /**
+ * @return The hash code of this ActorId
+ */
+ @Override
+ public int hashCode() {
+ return this.stringId.hashCode();
+ }
+
+ /**
+ * Compare if the content of two ids are the same.
+ *
+ * @param id1 One identifier.
+ * @param id2 Another identifier.
+ * @return -1, 0, or 1 depending on the compare result of the stringId member.
+ */
+ private int compareContent(ActorId id1, ActorId id2) {
+ return id1.stringId.compareTo(id2.stringId);
+ }
+
+ /**
+ * Checks if this instance is equals to the other instance.
+ *
+ * @return true if the 2 ActorId's are equal.
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj == null) {
+ return false;
+ }
+
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+
+ return hasEqualContent(this, (ActorId) obj);
}
- if (obj == null) {
- return false;
+ /**
+ * Creates a new ActorId with a random id.
+ *
+ * @return A new ActorId with a random id.
+ */
+ public static ActorId createRandom() {
+ UUID id = UUID.randomUUID();
+ return new ActorId(id.toString());
}
- if (getClass() != obj.getClass()) {
- return false;
+ /**
+ * Determines whether two specified actorIds have the same id.
+ *
+ * @param id1 The first actorId to compare, or null
+ * @param id2 The second actorId to compare, or null.
+ * @return true if the id is same for both objects; otherwise, false.
+ */
+ private static boolean equals(ActorId id1, ActorId id2) {
+ if (id1 == null && id2 == null) {
+ return true;
+ } else if (id2 == null || id1 == null) {
+ return false;
+ } else {
+ return hasEqualContent(id1, id2);
+ }
}
- return hasEqualContent(this, (ActorId) obj);
- }
-
- /**
- * Creates a new ActorId with a random id.
- *
- * @return A new ActorId with a random id.
- */
- public static ActorId createRandom() {
- UUID id = UUID.randomUUID();
- return new ActorId(id.toString());
- }
-
- /**
- * Determines whether two specified actorIds have the same id.
- *
- * @param id1 The first actorId to compare, or null
- * @param id2 The second actorId to compare, or null.
- * @return true if the id is same for both objects; otherwise, false.
- */
- private static boolean equals(ActorId id1, ActorId id2) {
- if (id1 == null && id2 == null) {
- return true;
- } else if (id2 == null || id1 == null) {
- return false;
- } else {
- return hasEqualContent(id1, id2);
+ /**
+ * Compares if two actors have the same content.
+ *
+ * @param id1 One identifier.
+ * @param id2 Another identifier.
+ * @return true if the two ActorId's are equal
+ */
+ private static boolean hasEqualContent(ActorId id1, ActorId id2) {
+ return id1.stringId.equals(id2.stringId);
}
- }
-
- /**
- * Compares if two actors have the same content.
- *
- * @param id1 One identifier.
- * @param id2 Another identifier.
- * @return true if the two ActorId's are equal
- */
- private static boolean hasEqualContent(ActorId id1, ActorId id2) {
- return id1.stringId.equals(id2.stringId);
- }
}
diff --git a/sdk/src/main/java/io/dapr/actors/ActorTrace.java b/sdk/src/main/java/io/dapr/actors/ActorTrace.java
index 487579e1af..d93f8ad463 100644
--- a/sdk/src/main/java/io/dapr/actors/ActorTrace.java
+++ b/sdk/src/main/java/io/dapr/actors/ActorTrace.java
@@ -16,71 +16,76 @@
*/
public final class ActorTrace {
- /**
- * Gets the default Logger.
- */
- private static final Logger LOGGER = Logger.getLogger(ActorTrace.class.getName());
+ /**
+ * Gets the default Logger.
+ */
+ private static final Logger LOGGER = Logger.getLogger(ActorTrace.class.getName());
- /**
- * Writes an information trace log.
- * @param type Type of log.
- * @param id Instance identifier.
- * @param msgFormat Message or message format (with type and id input as well).
- * @param params Params for the message.
- */
- public void writeInfo(String type, String id, String msgFormat, Object... params) {
- this.write(Level.INFO, type, id, msgFormat, params);
- }
-
- /**
- * Writes an warning trace log.
- * @param type Type of log.
- * @param id Instance identifier.
- * @param msgFormat Message or message format (with type and id input as well).
- * @param params Params for the message.
- */
- public void writeWarning(String type, String id, String msgFormat, Object... params) {
- this.write(Level.WARNING, type, id, msgFormat, params);
- }
+ /**
+ * Writes an information trace log.
+ *
+ * @param type Type of log.
+ * @param id Instance identifier.
+ * @param msgFormat Message or message format (with type and id input as well).
+ * @param params Params for the message.
+ */
+ public void writeInfo(String type, String id, String msgFormat, Object... params) {
+ this.write(Level.INFO, type, id, msgFormat, params);
+ }
- /**
- * Writes an error trace log.
- * @param type Type of log.
- * @param id Instance identifier.
- * @param msgFormat Message or message format (with type and id input as well).
- * @param params Params for the message.
- */
- public void writeError(String type, String id, String msgFormat, Object... params) {
- this.write(Level.SEVERE, type, id, msgFormat, params);
- }
+ /**
+ * Writes an warning trace log.
+ *
+ * @param type Type of log.
+ * @param id Instance identifier.
+ * @param msgFormat Message or message format (with type and id input as well).
+ * @param params Params for the message.
+ */
+ public void writeWarning(String type, String id, String msgFormat, Object... params) {
+ this.write(Level.WARNING, type, id, msgFormat, params);
+ }
- /**
- * Writes a trace log.
- * @param level Severity level of the log.
- * @param type Type of log.
- * @param id Instance identifier.
- * @param msgFormat Message or message format (with type and id input as well).
- * @param params Params for the message.
- */
- private void write(Level level, String type, String id, String msgFormat, Object... params) {
- String formatString = String.format("%s:%s %s", emptyIfNul(type), emptyIfNul(id), emptyIfNul(msgFormat));
- if ((params == null) || (params.length == 0)) {
- LOGGER.log(level, formatString);
- } else {
- LOGGER.log(level, String.format(formatString, params));
+ /**
+ * Writes an error trace log.
+ *
+ * @param type Type of log.
+ * @param id Instance identifier.
+ * @param msgFormat Message or message format (with type and id input as well).
+ * @param params Params for the message.
+ */
+ public void writeError(String type, String id, String msgFormat, Object... params) {
+ this.write(Level.SEVERE, type, id, msgFormat, params);
}
- }
- /**
- * Utility method that returns empty if String is null.
- * @param s String to be checked.
- * @return String (if not null) or empty (if null).
- */
- private static String emptyIfNul(String s) {
- if (s == null) {
- return "";
+ /**
+ * Writes a trace log.
+ *
+ * @param level Severity level of the log.
+ * @param type Type of log.
+ * @param id Instance identifier.
+ * @param msgFormat Message or message format (with type and id input as well).
+ * @param params Params for the message.
+ */
+ private void write(Level level, String type, String id, String msgFormat, Object... params) {
+ String formatString = String.format("%s:%s %s", emptyIfNul(type), emptyIfNul(id), emptyIfNul(msgFormat));
+ if ((params == null) || (params.length == 0)) {
+ LOGGER.log(level, formatString);
+ } else {
+ LOGGER.log(level, String.format(formatString, params));
+ }
}
- return s;
- }
+ /**
+ * Utility method that returns empty if String is null.
+ *
+ * @param s String to be checked.
+ * @return String (if not null) or empty (if null).
+ */
+ private static String emptyIfNul(String s) {
+ if (s == null) {
+ return "";
+ }
+
+ return s;
+ }
}
diff --git a/sdk/src/main/java/io/dapr/actors/Constants.java b/sdk/src/main/java/io/dapr/actors/Constants.java
deleted file mode 100644
index d0782de0ee..0000000000
--- a/sdk/src/main/java/io/dapr/actors/Constants.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) Microsoft Corporation.
- * Licensed under the MIT License.
- */
-package io.dapr.actors;
-
-/**
- * Useful constants for the Dapr's Actor SDK.
- */
-public final class Constants {
-
- /**
- * Dapr API used in this client.
- */
- public static final String API_VERSION = "v1.0";
-
- /**
- * Dapr's default hostname.
- */
- public static final String DEFAULT_HOSTNAME = "localhost";
-
- /**
- * Dapr's default port.
- */
- public static final int DEFAULT_PORT = 3500;
-
- /**
- * Environment variable used to set Dapr's port.
- */
- public static final String ENV_DAPR_HTTP_PORT = "DAPR_HTTP_PORT";
-
- /**
- * Header used for request id in Dapr.
- */
- public static final String HEADER_DAPR_REQUEST_ID = "X-DaprRequestId";
-
- /**
- * Base URL for Dapr Actor APIs.
- */
- private static String ACTORS_BASE_URL = API_VERSION + "/" + "actors";
-
- /**
- * String format for Actors state management relative url.
- */
- public static String ACTOR_STATE_KEY_RELATIVE_URL_FORMAT = ACTORS_BASE_URL + "/%s/%s/state/%s";
-
- /**
- * String format for Actors state management relative url.
- */
- public static String ACTOR_STATE_RELATIVE_URL_FORMAT = ACTORS_BASE_URL + "/%s/%s/state";
-
- /**
- * String format for Actors method invocation relative url.
- */
- public static String ACTOR_METHOD_RELATIVE_URL_FORMAT = ACTORS_BASE_URL + "/%s/%s/method/%s";
-
- /**
- * String format for Actors reminder registration relative url..
- */
- public static String ACTOR_REMINDER_RELATIVE_URL_FORMAT = ACTORS_BASE_URL + "/%s/%s/reminders/%s";
-
- /**
- * String format for Actors timer registration relative url..
- */
- public static String ACTOR_TIMER_RELATIVE_URL_FORMAT = ACTORS_BASE_URL + "/%s/%s/reminders/%s";
-
- /**
- * Invoke Publish Path
- */
- public static String PUBLISH_PATH = API_VERSION + "/publish";
-
- /**
- * Invoke Binding Path
- */
- public static String BINDING_PATH = API_VERSION + "/binding";
-
- /**
- * State Path
- */
- public static String STATE_PATH = API_VERSION + "/state";
-
-
-
-}
diff --git a/sdk/src/main/java/io/dapr/actors/client/ActorMethodEnvelope.java b/sdk/src/main/java/io/dapr/actors/client/ActorMethodEnvelope.java
index 857f8f31d4..693708a22b 100644
--- a/sdk/src/main/java/io/dapr/actors/client/ActorMethodEnvelope.java
+++ b/sdk/src/main/java/io/dapr/actors/client/ActorMethodEnvelope.java
@@ -10,24 +10,26 @@
*/
public class ActorMethodEnvelope {
- /**
- * Data serialized for input/output of Actor methods.
- */
- private byte[] data;
+ /**
+ * Data serialized for input/output of Actor methods.
+ */
+ private byte[] data;
- /**
- * Gets the data serialized for input/output of Actor methods.
- * @return Data serialized for input/output of Actor methods.
- */
- public byte[] getData() {
- return data;
- }
+ /**
+ * Gets the data serialized for input/output of Actor methods.
+ *
+ * @return Data serialized for input/output of Actor methods.
+ */
+ public byte[] getData() {
+ return data;
+ }
- /**
- * Sets the data serialized for input/output of Actor methods.
- * @param data Data serialized for input/output of Actor methods.
- */
- public void setData(byte[] data) {
- this.data = data;
- }
+ /**
+ * Sets the data serialized for input/output of Actor methods.
+ *
+ * @param data Data serialized for input/output of Actor methods.
+ */
+ public void setData(byte[] data) {
+ this.data = data;
+ }
}
diff --git a/sdk/src/main/java/io/dapr/actors/client/ActorProxy.java b/sdk/src/main/java/io/dapr/actors/client/ActorProxy.java
index 6f35b3429d..c012ff49b6 100644
--- a/sdk/src/main/java/io/dapr/actors/client/ActorProxy.java
+++ b/sdk/src/main/java/io/dapr/actors/client/ActorProxy.java
@@ -3,8 +3,6 @@
import io.dapr.actors.ActorId;
import reactor.core.publisher.Mono;
-import java.io.IOException;
-
/**
* Proxy to communicate to a given Actor instance in Dapr.
*/
@@ -28,7 +26,8 @@ public interface ActorProxy {
* Invokes an Actor method on Dapr.
*
* @param methodName Method name to invoke.
- * @param clazz The type of the return class.
+ * @param clazz The type of the return class.
+ * @param
* The base type for actors, that provides the common functionality
* for actors that derive from {@link Actor}.
* The state is preserved across actor garbage collections and fail-overs.
*/
public abstract class AbstractActor {
- /**
- * Type of tracing messages.
- */
- private static final String TRACE_TYPE = "Actor";
-
- /**
- * Context for the Actor runtime.
- */
- private final ActorRuntimeContext> actorRuntimeContext;
-
- /**
- * Actor identifier.
- */
- private final ActorId id;
-
- /**
- * Manager for the states in Actors.
- */
- private final ActorStateManager actorStateManager;
-
- /**
- * Emits trace messages for Actors.
- */
- private final ActorTrace actorTrace;
-
- /**
- * Registered timers for this Actor.
- */
- private final Map Type for the state object.
- * @return Asynchronous result.
- */
- protected Mono actorTimer = new ActorTimer(this, name, methodName, state, dueTime, period);
- String serializedTimer = null;
- try {
- serializedTimer = this.actorRuntimeContext.getActorSerializer().serialize(actorTimer);
- } catch (IOException e) {
- return Mono.error(e);
+ /**
+ * Internal method to emit a trace message.
+ *
+ * @param type Type of trace message.
+ * @param id Identifier of entity relevant for the trace message.
+ * @param message Message to be logged.
+ * @return Asynchronous void response.
+ */
+ private Mono