use of com.bonree.brfs.rebalance.task.listener.ServerChangeListener in project BRFS by zhangnianli.
the class TaskDispatcher method start.
public void start() throws Exception {
LOG.info("begin leaderLath server!");
leaderLath.start();
LOG.info("changeMonitorPath:" + changesPath);
treeCache.addListener(changesPath, new ServerChangeListener(this));
LOG.info("tasksPath:" + tasksPath);
treeCache.addListener(tasksPath, new TaskStatusListener(this));
singleServer.execute(new Runnable() {
@Override
public void run() {
try {
dealChangeSDetail();
} catch (InterruptedException e) {
LOG.error("consumer queue error!!", e);
e.printStackTrace();
}
}
});
scheduleExecutor.scheduleWithFixedDelay(new Runnable() {
@Override
public void run() {
try {
if (leaderLath.hasLeadership()) {
if (isLoad.get()) {
LOG.info("auditTask timer cacheSummaryCache:" + cacheSummaryCache);
for (Entry<Integer, List<ChangeSummary>> entry : cacheSummaryCache.entrySet()) {
StorageRegion sn = snManager.findStorageRegionById(entry.getKey());
// 因为sn可能会被删除
if (sn != null) {
syncAuditTask(entry.getKey(), entry.getValue());
}
}
} else {
LOG.info("load once cache!");
loadCache();
isLoad.set(true);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}, 3000, 3000, TimeUnit.MILLISECONDS);
}
Aggregations