From b95b568a776285945f13cb1abbfa710c94aada7d Mon Sep 17 00:00:00 2001
From: pengys5 <8082209@qq.com>
Date: Mon, 10 Apr 2017 23:28:40 +0800
Subject: [PATCH] actor comments
---
.../actor/AbstractClusterWorker.java | 27 ++++++++++
.../actor/AbstractClusterWorkerProvider.java | 21 +++++++-
.../actor/AbstractLocalAsyncWorker.java | 52 +++++++++++++++++--
.../actor/selector/AbstractHashMessage.java | 5 +-
.../actor/selector/HashCodeSelector.java | 1 +
.../actor/selector/RollingSelector.java | 1 +
.../actor/selector/WorkerSelector.java | 1 +
7 files changed, 101 insertions(+), 7 deletions(-)
diff --git a/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/actor/AbstractClusterWorker.java b/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/actor/AbstractClusterWorker.java
index 207075aba..249a152d0 100644
--- a/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/actor/AbstractClusterWorker.java
+++ b/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/actor/AbstractClusterWorker.java
@@ -11,18 +11,45 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
+ * The AbstractClusterWorker should be implemented by any class whose instances
+ * are intended to provide receive remote message that message will transfer across different jvm
+ * which running in same server or another address server.
+ *
+ * Usually the implemented class used to receive persistence data or aggregation the metric.
+ *
* @author pengys5
+ * @since feature3.0
*/
public abstract class AbstractClusterWorker extends AbstractWorker {
+ /**
+ * Constructs a AbstractClusterWorker with the worker role and context.
+ *
+ * @param role The responsibility of worker in cluster, more than one workers can have
+ * same responsibility which use to provide load balancing ability.
+ * @param clusterContext See {@link ClusterWorkerContext}
+ * @param selfContext See {@link LocalWorkerContext}
+ */
protected AbstractClusterWorker(Role role, ClusterWorkerContext clusterContext, LocalWorkerContext selfContext) {
super(role, clusterContext, selfContext);
}
+ /**
+ * Receive message
+ *
+ * @param message The persistence data or metric data.
+ * @throws Exception The Exception happen in {@link #onWork(Object)}
+ */
final public void allocateJob(Object message) throws Exception {
onWork(message);
}
+ /**
+ * The data process logic in this method.
+ *
+ * @param message Cast the message object to a expect subclass.
+ * @throws Exception Don't handle the exception, throw it.
+ */
protected abstract void onWork(Object message) throws Exception;
static class WorkerWithAkka extends UntypedActor {
diff --git a/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/actor/AbstractClusterWorkerProvider.java b/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/actor/AbstractClusterWorkerProvider.java
index 421d44112..1820e5e6d 100644
--- a/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/actor/AbstractClusterWorkerProvider.java
+++ b/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/actor/AbstractClusterWorkerProvider.java
@@ -4,17 +4,36 @@ import akka.actor.ActorRef;
import akka.actor.Props;
/**
+ * The AbstractClusterWorkerProvider should be implemented by any class whose instances
+ * are intended to provide create the class instance whose implemented {@link AbstractClusterWorker}.
+ *
+ *
* @author pengys5
+ * @since feature3.0
*/
public abstract class AbstractClusterWorkerProvider
* Usually the implemented class used to persistence data to database
- * or aggregation the metric,
+ * or aggregation the metric.
*
* @author pengys5
+ * @since feature3.0
*/
public abstract class AbstractHashMessage {
private int hashCode;
@@ -16,7 +17,7 @@ public abstract class AbstractHashMessage {
this.hashCode = key.hashCode();
}
- protected int getHashCode() {
+ int getHashCode() {
return hashCode;
}
}
diff --git a/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/actor/selector/HashCodeSelector.java b/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/actor/selector/HashCodeSelector.java
index aef766ab1..6e8b52c8a 100644
--- a/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/actor/selector/HashCodeSelector.java
+++ b/skywalking-collector/skywalking-collector-cluster/src/main/java/com/a/eye/skywalking/collector/actor/selector/HashCodeSelector.java
@@ -11,6 +11,7 @@ import java.util.List;
* message to same {@link WorkerRef}. Usually, use to database operate which avoid dirty data.
*
* @author pengys5
+ * @since feature3.0
*/
public class HashCodeSelector implements WorkerSelectorAbstractLocalAsyncWorker should be implemented by any class whose instances
+ * are intended to provide receive asynchronous message in same jvm.
+ *
* @author pengys5
+ * @since feature3.0
*/
public abstract class AbstractLocalAsyncWorker extends AbstractLocalWorker {
+ /**
+ * Constructs a AbstractLocalAsyncWorker with the worker role and context.
+ *
+ * @param role The responsibility of worker in cluster, more than one workers can have
+ * same responsibility which use to provide load balancing ability.
+ * @param clusterContext See {@link ClusterWorkerContext}
+ * @param selfContext See {@link LocalWorkerContext}
+ */
public AbstractLocalAsyncWorker(Role role, ClusterWorkerContext clusterContext, LocalWorkerContext selfContext) {
super(role, clusterContext, selfContext);
}
+ /**
+ * The asynchronous worker always use to persistence data into db, this is the end of the streaming,
+ * so usually no need to create the next worker instance at the time of this worker instance create.
+ *
+ * @throws ProviderNotFoundException When worker provider not found, it will be throw this exception.
+ */
@Override
public void preStart() throws ProviderNotFoundException {
}
- final public void allocateJob(Object request) throws Exception {
- onWork(request);
+ /**
+ * Receive message
+ *
+ * @param message The persistence data or metric data.
+ * @throws Exception The Exception happen in {@link #onWork(Object)}
+ */
+ final public void allocateJob(Object message) throws Exception {
+ onWork(message);
}
- protected abstract void onWork(Object request) throws Exception;
+ /**
+ * The data process logic in this method.
+ *
+ * @param message Cast the message object to a expect subclass.
+ * @throws Exception Don't handle the exception, throw it.
+ */
+ protected abstract void onWork(Object message) throws Exception;
static class WorkerWithDisruptor implements EventHandlerWorkerRef is designed to provide a routing ability in the collector cluster
*
* @author pengys5
+ * @since feature3.0
*/
public interface WorkerSelector