Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/alibaba/nacos into master_m
Browse files Browse the repository at this point in the history
  • Loading branch information
xuechaos committed Aug 17, 2018
2 parents 1792595 + 0d0eef2 commit ebdb709
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ cd nacos/bin
#### Start Server
##### Linux/Unix/Mac

Run the following command to sart(standalone means non-cluster mode):
Run the following command to start (standalone means non-cluster mode):

`sh startup.sh -m standalone`

Expand All @@ -54,7 +54,7 @@ Run the following command to start:

Or double-click the startup.cmd to run NacosServer.

you can see detail in https://nacos.io/#/docs/quick-start.md
For more details, see https://nacos.io/#/docs/quick-start.md

Quick start for other open-source projects:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,23 @@

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
* @author harold
*/
public class BeatReactor {

private ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
Thread thread = new Thread(r);
thread.setDaemon(true);
thread.setName("com.alibaba.nacos.naming.beat.sender");
return thread;
}
private ScheduledExecutorService executorService = new ScheduledThreadPoolExecutor(1, r -> {
Thread thread = new Thread(r);
thread.setDaemon(true);
thread.setName("com.alibaba.nacos.naming.beat.sender");
return thread;
});
;

private long clientBeatInterval = 10 * 1000;

Expand All @@ -48,7 +49,7 @@ public Thread newThread(Runnable r) {

public BeatReactor(NamingProxy serverProxy) {
this.serverProxy = serverProxy;
executorService.execute(new BeatProcessor());
executorService.scheduleAtFixedRate(new BeatProcessor(), 0, clientBeatInterval, TimeUnit.MILLISECONDS);
}

public void addBeatInfo(String dom, BeatInfo beatInfo) {
Expand All @@ -63,18 +64,14 @@ class BeatProcessor implements Runnable {

@Override
public void run() {
while (true) {
try {
for (Map.Entry<String, BeatInfo> entry : dom2Beat.entrySet()) {
BeatInfo beatInfo = entry.getValue();
executorService.schedule(new BeatTask(beatInfo), 0, TimeUnit.MILLISECONDS);
LogUtils.LOG.info("BEAT", "send beat to server: ", beatInfo.toString());
}

TimeUnit.MILLISECONDS.sleep(clientBeatInterval);
} catch (Exception e) {
LogUtils.LOG.error("CLIENT-BEAT", "Exception while scheduling beat.", e);
try {
for (Map.Entry<String, BeatInfo> entry : dom2Beat.entrySet()) {
BeatInfo beatInfo = entry.getValue();
executorService.schedule(new BeatTask(beatInfo), 0, TimeUnit.MILLISECONDS);
LogUtils.LOG.info("BEAT", "send beat to server: ", beatInfo.toString());
}
} catch (Exception e) {
LogUtils.LOG.error("CLIENT-BEAT", "Exception while scheduling beat.", e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ private List<SampleResult> runCollectionJob(String url, Map<String, String> para
ipList.get(i));
}
} catch (TimeoutException e) {
f.cancel(true);
if (f != null) {
f.cancel(true);
}
LogUtil.defaultLog.warn(
"get task result with TimeoutException: {} ", e
.getMessage());
Expand Down

0 comments on commit ebdb709

Please sign in to comment.