- * 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); + /** + * The ID of the actor as a String. + */ + private final String stringId; + + /** + * An error message for an invalid constructor arg. + */ + private final String errorMsg = "actor needs to be initialized with an id!"; + + /** + * Initializes a new instance of the ActorId class with the id passed in. + * + * @param id Value for actor id + */ + public ActorId(String id) { + if (id != null) { + this.stringId = id; + } else { + throw new IllegalArgumentException(errorMsg); } - - /** - * - * @param id1 - * @param id2 - * @return true if the two ActorId's are equal - */ - static private boolean hasEqualContent(ActorId id1, ActorId id2) { - return id1.getStringId().equalsIgnoreCase(id2.getStringId()); + } + + /** + * Returns the id of the actor as {link #java.lang.String} + * + * @return ActorID as {link #java.lang.String} + */ + public String getStringId() { + return this.stringId; + } + + /** + * 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. + */ + static public 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); } - - /** - * - * @param id1 - * @param id2 - * @return -1, 0, or 1 depending on the compare result of the stringId member. - */ - private int compareContent(ActorId id1, ActorId id2) { - return id1.getStringId().compareToIgnoreCase(id2.getStringId()); + } + + /** + * 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);
+ }
+
+ /**
+ *
+ * @param id1
+ * @param id2
+ * @return true if the two ActorId's are equal
+ */
+ static private boolean hasEqualContent(ActorId id1, ActorId id2) {
+ return id1.getStringId().equalsIgnoreCase(id2.getStringId());
+ }
+
+ /**
+ *
+ * @param id1
+ * @param id2
+ * @return -1, 0, or 1 depending on the compare result of the stringId member.
+ */
+ private int compareContent(ActorId id1, ActorId id2) {
+ return id1.getStringId().compareToIgnoreCase(id2.getStringId());
+ }
+
+ /**
+ *
+ * @return The String representation of this ActorId
+ */
+ @Override
+ public String toString() {
+ return this.stringId;
+ }
+
+ /**
+ *
+ * @return The hash code of this ActorId
+ */
+ @Override
+ public int hashCode() {
+ return this.stringId.hashCode();
+ }
+
+ /**
+ *
+ * @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;
+ if (obj == null) {
+ return false;
}
- /**
- *
- * @return The hash code of this ActorId
- */
- @Override
- public int hashCode() {
- return this.stringId.hashCode();
+ if (getClass() != obj.getClass()) {
+ return false;
}
- /**
- *
- * @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);
- }
+ return hasEqualContent(this, (ActorId) obj);
+ }
}
diff --git a/sdk/src/main/java/io/dapr/actors/ActorTrace.java b/sdk/src/main/java/io/dapr/actors/ActorTrace.java
index f3c7d5fea1..b3c61bbdeb 100644
--- a/sdk/src/main/java/io/dapr/actors/ActorTrace.java
+++ b/sdk/src/main/java/io/dapr/actors/ActorTrace.java
@@ -2,22 +2,22 @@
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*/
-
package io.dapr.actors;
/**
* Stub
*/
public class ActorTrace {
- public static void WriteInfo(String text) {
- System.out.println(text);
- }
-
- public static void WriteWarning(String text) {
- System.out.println("Warning: " + text);
- }
-
- public static void WriteError(String text) {
- System.err.println(text);
- }
+
+ public static void WriteInfo(String text) {
+ System.out.println(text);
+ }
+
+ public static void WriteWarning(String text) {
+ System.out.println("Warning: " + text);
+ }
+
+ public static void WriteError(String text) {
+ System.err.println(text);
+ }
}
diff --git a/sdk/src/main/java/io/dapr/actors/Constants.java b/sdk/src/main/java/io/dapr/actors/Constants.java
index 86ea80fac8..c09014d02a 100644
--- a/sdk/src/main/java/io/dapr/actors/Constants.java
+++ b/sdk/src/main/java/io/dapr/actors/Constants.java
@@ -1,67 +1,66 @@
-/*
- * 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";
-}
+/*
+ * 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";
+}
diff --git a/sdk/src/main/java/io/dapr/actors/DaprError.java b/sdk/src/main/java/io/dapr/actors/DaprError.java
index 682b14c62a..672d4a4e29 100644
--- a/sdk/src/main/java/io/dapr/actors/DaprError.java
+++ b/sdk/src/main/java/io/dapr/actors/DaprError.java
@@ -1,59 +1,62 @@
-/*
- * Copyright (c) Microsoft Corporation.
- * Licensed under the MIT License.
- */
-
-package io.dapr.actors;
-
-/**
- * Represents an error message from Dapr.
- */
-class DaprError {
-
- /**
- * Error code.
- */
- private String errorCode;
-
- /**
- * Error Message.
- */
- private String message;
-
- /**
- * Gets the error code.
- * @return Error code.
- */
- public String getErrorCode() {
- return errorCode;
- }
-
- /**
- * Sets the error code.
- * @param errorCode Error code.
- * @return This instance.
- */
- public DaprError setErrorCode(String errorCode) {
- this.errorCode = errorCode;
- return this;
- }
-
- /**
- * Gets the error message.
- * @return Error message.
- */
- public String getMessage() {
- return message;
- }
-
- /**
- * Sets the error message.
- * @param message Error message.
- * @return This instance.
- */
- public DaprError setMessage(String message) {
- this.message = message;
- return this;
- }
-
-}
+/*
+ * Copyright (c) Microsoft Corporation.
+ * Licensed under the MIT License.
+ */
+package io.dapr.actors;
+
+/**
+ * Represents an error message from Dapr.
+ */
+class DaprError {
+
+ /**
+ * Error code.
+ */
+ private String errorCode;
+
+ /**
+ * Error Message.
+ */
+ private String message;
+
+ /**
+ * Gets the error code.
+ *
+ * @return Error code.
+ */
+ public String getErrorCode() {
+ return errorCode;
+ }
+
+ /**
+ * Sets the error code.
+ *
+ * @param errorCode Error code.
+ * @return This instance.
+ */
+ public DaprError setErrorCode(String errorCode) {
+ this.errorCode = errorCode;
+ return this;
+ }
+
+ /**
+ * Gets the error message.
+ *
+ * @return Error message.
+ */
+ public String getMessage() {
+ return message;
+ }
+
+ /**
+ * Sets the error message.
+ *
+ * @param message Error message.
+ * @return This instance.
+ */
+ public DaprError setMessage(String message) {
+ this.message = message;
+ return this;
+ }
+
+}
diff --git a/sdk/src/main/java/io/dapr/actors/DaprException.java b/sdk/src/main/java/io/dapr/actors/DaprException.java
index 50ad94a9b9..67c251f8cd 100644
--- a/sdk/src/main/java/io/dapr/actors/DaprException.java
+++ b/sdk/src/main/java/io/dapr/actors/DaprException.java
@@ -1,45 +1,47 @@
-/*
- * Copyright (c) Microsoft Corporation.
- * Licensed under the MIT License.
- */
-
-package io.dapr.actors;
-
-import java.io.IOException;
-
-/**
- * A Dapr's specific exception.
- */
-public class DaprException extends IOException {
-
- /**
- * Dapr's error code for this exception.
- */
- private String errorCode;
-
- /**
- * New exception from a server-side generated error code and message.
- * @param daprError Server-side error.
- */
- DaprException(DaprError daprError) {
- this(daprError.getErrorCode(), daprError.getMessage());
- }
-
- /**
- * New Exception from a client-side generated error code and message.
- * @param errorCode Client-side error code.
- * @param message Client-side error message.
- */
- DaprException(String errorCode, String message) {
- super(String.format("%s: %s", errorCode, message));
- this.errorCode = errorCode;
- }
-
- /**
- * Returns the exception's error code.
- * @return Error code.
- */
- public String getErrorCode() {
- return this.errorCode;
- }
-}
+/*
+ * Copyright (c) Microsoft Corporation.
+ * Licensed under the MIT License.
+ */
+package io.dapr.actors;
+
+import java.io.IOException;
+
+/**
+ * A Dapr's specific exception.
+ */
+public class DaprException extends IOException {
+
+ /**
+ * Dapr's error code for this exception.
+ */
+ private String errorCode;
+
+ /**
+ * New exception from a server-side generated error code and message.
+ *
+ * @param daprError Server-side error.
+ */
+ DaprException(DaprError daprError) {
+ this(daprError.getErrorCode(), daprError.getMessage());
+ }
+
+ /**
+ * New Exception from a client-side generated error code and message.
+ *
+ * @param errorCode Client-side error code.
+ * @param message Client-side error message.
+ */
+ DaprException(String errorCode, String message) {
+ super(String.format("%s: %s", errorCode, message));
+ this.errorCode = errorCode;
+ }
+
+ /**
+ * Returns the exception's error code.
+ *
+ * @return Error code.
+ */
+ public String getErrorCode() {
+ return this.errorCode;
+ }
+}
diff --git a/sdk/src/main/java/io/dapr/actors/client/ActorProxyAsyncClient.java b/sdk/src/main/java/io/dapr/actors/client/ActorProxyAsyncClient.java
index b4f6b0bfda..b86e3d6950 100644
--- a/sdk/src/main/java/io/dapr/actors/client/ActorProxyAsyncClient.java
+++ b/sdk/src/main/java/io/dapr/actors/client/ActorProxyAsyncClient.java
@@ -2,7 +2,6 @@
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*/
-
package io.dapr.actors.client;
import reactor.core.publisher.Mono;
@@ -12,13 +11,14 @@
*/
interface ActorProxyAsyncClient {
- /**
- * Invokes an Actor method on Dapr.
- * @param actorType Type of actor.
- * @param actorId Actor Identifier.
- * @param methodName Method name to invoke.
- * @param jsonPayload Serialized body.
- * @return Asynchronous result with the Actor's response.
- */
- Mono