This is an automated email from the ASF dual-hosted git repository.
huxing pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git
The following commit(s) were added to refs/heads/master by this push:
new 3bf77ab Add monitor module javadoc (#3121)
3bf77ab is described below
commit 3bf77abd86e7d51c74df307c4608b0294d89ca57
Author: XiaoJie Li <[email protected]>
AuthorDate: Thu Jan 3 16:21:55 2019 +0800
Add monitor module javadoc (#3121)
---
.../monitor/support/AbstractMonitorFactory.java | 11 +++++--
.../dubbo/monitor/support/MonitorFilter.java | 38 ++++++++++++++++++++--
.../apache/dubbo/monitor/dubbo/DubboMonitor.java | 11 ++++++-
3 files changed, 54 insertions(+), 6 deletions(-)
diff --git
a/dubbo-monitor/dubbo-monitor-api/src/main/java/org/apache/dubbo/monitor/support/AbstractMonitorFactory.java
b/dubbo-monitor/dubbo-monitor-api/src/main/java/org/apache/dubbo/monitor/support/AbstractMonitorFactory.java
index c49cb1b..74a129b 100644
---
a/dubbo-monitor/dubbo-monitor-api/src/main/java/org/apache/dubbo/monitor/support/AbstractMonitorFactory.java
+++
b/dubbo-monitor/dubbo-monitor-api/src/main/java/org/apache/dubbo/monitor/support/AbstractMonitorFactory.java
@@ -44,14 +44,21 @@ import java.util.concurrent.locks.ReentrantLock;
public abstract class AbstractMonitorFactory implements MonitorFactory {
private static final Logger logger =
LoggerFactory.getLogger(AbstractMonitorFactory.class);
- // lock for getting monitor center
+ /**
+ * The lock for getting monitor center
+ */
private static final ReentrantLock LOCK = new ReentrantLock();
- // monitor centers Map<RegistryAddress, Registry>
+ /**
+ * The monitor centers Map<RegistryAddress, Registry>
+ */
private static final Map<String, Monitor> MONITORS = new
ConcurrentHashMap<String, Monitor>();
private static final Map<String, CompletableFuture<Monitor>> FUTURES = new
ConcurrentHashMap<String, CompletableFuture<Monitor>>();
+ /**
+ * The monitor create executor
+ */
private static final ExecutorService executor = new ThreadPoolExecutor(0,
10, 60L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), new
NamedThreadFactory("DubboMonitorCreator", true));
public static Collection<Monitor> getMonitors() {
diff --git
a/dubbo-monitor/dubbo-monitor-api/src/main/java/org/apache/dubbo/monitor/support/MonitorFilter.java
b/dubbo-monitor/dubbo-monitor-api/src/main/java/org/apache/dubbo/monitor/support/MonitorFilter.java
index d9d4b79..10eb31e 100644
---
a/dubbo-monitor/dubbo-monitor-api/src/main/java/org/apache/dubbo/monitor/support/MonitorFilter.java
+++
b/dubbo-monitor/dubbo-monitor-api/src/main/java/org/apache/dubbo/monitor/support/MonitorFilter.java
@@ -45,15 +45,28 @@ public class MonitorFilter implements Filter {
private static final Logger logger =
LoggerFactory.getLogger(MonitorFilter.class);
+ /**
+ * The Concurrent counter
+ */
private final ConcurrentMap<String, AtomicInteger> concurrents = new
ConcurrentHashMap<String, AtomicInteger>();
+ /**
+ * The MonitorFactory
+ */
private MonitorFactory monitorFactory;
public void setMonitorFactory(MonitorFactory monitorFactory) {
this.monitorFactory = monitorFactory;
}
- // intercepting invocation
+ /**
+ * The invocation interceptor,it will collect the invoke data about this
invocation and send it to monitor center
+ *
+ * @param invoker service
+ * @param invocation invocation.
+ * @return {@link Result} the invoke result
+ * @throws RpcException
+ */
@Override
public Result invoke(Invoker<?> invoker, Invocation invocation) throws
RpcException {
if (invoker.getUrl().hasParameter(Constants.MONITOR_KEY)) {
@@ -76,7 +89,16 @@ public class MonitorFilter implements Filter {
}
}
- // collect info
+ /**
+ * The collector logic, it will be handled by the default monitor
+ *
+ * @param invoker
+ * @param invocation
+ * @param result the invoke result
+ * @param remoteHost the remote host address
+ * @param start the timestamp the invoke begin
+ * @param error if there is an error on the invoke
+ */
private void collect(Invoker<?> invoker, Invocation invocation, Result
result, String remoteHost, long start, boolean error) {
try {
URL monitorUrl =
invoker.getUrl().getUrlParameter(Constants.MONITOR_KEY);
@@ -91,6 +113,17 @@ public class MonitorFilter implements Filter {
}
}
+ /**
+ * Create statistics url
+ *
+ * @param invoker
+ * @param invocation
+ * @param result
+ * @param remoteHost
+ * @param start
+ * @param error
+ * @return
+ */
private URL createStatisticsUrl(Invoker<?> invoker, Invocation invocation,
Result result, String remoteHost, long start, boolean error) {
// ---- service statistics ----
long elapsed = System.currentTimeMillis() - start; // invocation cost
@@ -114,7 +147,6 @@ public class MonitorFilter implements Filter {
remoteKey = MonitorService.CONSUMER;
remoteValue = remoteHost;
}
-
String input = "", output = "";
if (invocation.getAttachment(Constants.INPUT_KEY) != null) {
input = invocation.getAttachment(Constants.INPUT_KEY);
diff --git
a/dubbo-monitor/dubbo-monitor-default/src/main/java/org/apache/dubbo/monitor/dubbo/DubboMonitor.java
b/dubbo-monitor/dubbo-monitor-default/src/main/java/org/apache/dubbo/monitor/dubbo/DubboMonitor.java
index 1e441e5..04df72d 100644
---
a/dubbo-monitor/dubbo-monitor-default/src/main/java/org/apache/dubbo/monitor/dubbo/DubboMonitor.java
+++
b/dubbo-monitor/dubbo-monitor-default/src/main/java/org/apache/dubbo/monitor/dubbo/DubboMonitor.java
@@ -42,19 +42,28 @@ public class DubboMonitor implements Monitor {
private static final Logger logger =
LoggerFactory.getLogger(DubboMonitor.class);
+ /**
+ * The length of the array which is a container of the statistics
+ */
private static final int LENGTH = 10;
/**
- * The timer sends the statistics data to monitor center
+ * The timer for sending statistics
*/
private final ScheduledExecutorService scheduledExecutorService =
Executors.newScheduledThreadPool(3, new
NamedThreadFactory("DubboMonitorSendTimer", true));
+ /**
+ * The future that can cancel the <b>scheduledExecutorService</b>
+ */
private final ScheduledFuture<?> sendFuture;
private final Invoker<MonitorService> monitorInvoker;
private final MonitorService monitorService;
+ /**
+ * The time interval for timer <b>scheduledExecutorService</b> to send data
+ */
private final long monitorInterval;
private final ConcurrentMap<Statistics, AtomicReference<long[]>>
statisticsMap = new ConcurrentHashMap<Statistics, AtomicReference<long[]>>();