use of com.alibaba.otter.shared.common.model.config.pipeline.Pipeline in project otter by alibaba.
the class PipelineMonitor method explore.
@Override
public void explore(List<AlarmRule> rules) {
Long pipelineId = rules.get(0).getPipelineId();
Pipeline pipeline = pipelineService.findById(pipelineId);
// 如果处于stop状态,则忽略报警
ChannelStatus status = arbitrateManageService.channelEvent().status(pipeline.getChannelId());
if (status == null || status.isStop()) {
return;
}
List<AlarmRule> delayTimeRules = new LinkedList<AlarmRule>();
List<AlarmRule> exceptonRules = new LinkedList<AlarmRule>();
List<AlarmRule> pipelineTimeoutRules = new LinkedList<AlarmRule>();
List<AlarmRule> processTimeoutRules = new LinkedList<AlarmRule>();
List<AlarmRule> positionTimeoutRules = new LinkedList<AlarmRule>();
Date now = new Date();
for (AlarmRule rule : rules) {
switch(rule.getMonitorName()) {
case DELAYTIME:
if (checkEnable(rule, now)) {
delayTimeRules.add(rule);
}
break;
case EXCEPTION:
if (checkEnable(rule, now)) {
exceptonRules.add(rule);
}
break;
case PIPELINETIMEOUT:
if (checkEnable(rule, now)) {
pipelineTimeoutRules.add(rule);
}
break;
case PROCESSTIMEOUT:
if (checkEnable(rule, now)) {
processTimeoutRules.add(rule);
}
break;
case POSITIONTIMEOUT:
if (checkEnable(rule, now)) {
positionTimeoutRules.add(rule);
}
break;
default:
break;
}
}
if (!delayTimeRules.isEmpty()) {
delayStatRuleMonitor.explore(delayTimeRules);
}
if (!pipelineTimeoutRules.isEmpty()) {
pipelineTimeoutRuleMonitor.explore(pipelineTimeoutRules);
}
if (!processTimeoutRules.isEmpty()) {
processTimeoutRuleMonitor.explore(processTimeoutRules);
}
if (!positionTimeoutRules.isEmpty()) {
positionTimeoutRuleMonitor.explore(positionTimeoutRules);
}
}
use of com.alibaba.otter.shared.common.model.config.pipeline.Pipeline in project otter by alibaba.
the class PositionTimeoutRuleMonitor method explore.
@Override
public void explore(List<AlarmRule> rules) {
if (CollectionUtils.isEmpty(rules)) {
return;
}
Long pipelineId = rules.get(0).getPipelineId();
Pipeline pipeline = pipelineService.findById(pipelineId);
PositionEventData data = arbitrateViewService.getCanalCursor(pipeline.getParameters().getDestinationName(), pipeline.getParameters().getMainstemClientId());
long latestSyncTime = 0L;
if (data != null && data.getModifiedTime() != null) {
Date modifiedDate = data.getModifiedTime();
latestSyncTime = modifiedDate.getTime();
} else {
return;
}
long now = System.currentTimeMillis();
long elapsed = now - latestSyncTime;
boolean flag = false;
for (AlarmRule rule : rules) {
flag |= checkTimeout(rule, elapsed);
}
if (flag) {
logRecordAlarm(pipelineId, MonitorName.POSITIONTIMEOUT, String.format(TIME_OUT_MESSAGE, pipelineId, (elapsed / 1000)));
}
}
use of com.alibaba.otter.shared.common.model.config.pipeline.Pipeline in project otter by alibaba.
the class DbLoadAction method buildContext.
private DbLoadContext buildContext(Identity identity) {
DbLoadContext context = new DbLoadContext();
context.setIdentity(identity);
Channel channel = configClientService.findChannel(identity.getChannelId());
Pipeline pipeline = configClientService.findPipeline(identity.getPipelineId());
context.setChannel(channel);
context.setPipeline(pipeline);
return context;
}
use of com.alibaba.otter.shared.common.model.config.pipeline.Pipeline in project otter by alibaba.
the class DbLoadAction method adjustPoolSize.
// 调整一下线程池
private void adjustPoolSize(DbLoadContext context) {
Pipeline pipeline = context.getPipeline();
int newPoolSize = pipeline.getParameters().getLoadPoolSize();
if (newPoolSize != poolSize) {
poolSize = newPoolSize;
if (executor instanceof ThreadPoolExecutor) {
ThreadPoolExecutor pool = (ThreadPoolExecutor) executor;
pool.setCorePoolSize(newPoolSize);
pool.setMaximumPoolSize(newPoolSize);
}
}
}
use of com.alibaba.otter.shared.common.model.config.pipeline.Pipeline in project otter by alibaba.
the class DbLoadAction method adjustConfig.
private void adjustConfig(DbLoadContext context) {
Pipeline pipeline = context.getPipeline();
this.useBatch = pipeline.getParameters().isUseBatch();
}
Aggregations