Search in sources :

Example 1 with Pipeline

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);
    }
}
Also used : AlarmRule(com.alibaba.otter.shared.common.model.config.alarm.AlarmRule) ChannelStatus(com.alibaba.otter.shared.common.model.config.channel.ChannelStatus) LinkedList(java.util.LinkedList) Date(java.util.Date) Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)

Example 2 with Pipeline

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)));
    }
}
Also used : PositionEventData(com.alibaba.otter.shared.arbitrate.model.PositionEventData) AlarmRule(com.alibaba.otter.shared.common.model.config.alarm.AlarmRule) Date(java.util.Date) Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)

Example 3 with Pipeline

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;
}
Also used : DbLoadContext(com.alibaba.otter.node.etl.load.loader.db.context.DbLoadContext) Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)

Example 4 with Pipeline

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);
        }
    }
}
Also used : ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)

Example 5 with Pipeline

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();
}
Also used : Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)

Aggregations

Pipeline (com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)105 Channel (com.alibaba.otter.shared.common.model.config.channel.Channel)38 ArrayList (java.util.ArrayList)37 Node (com.alibaba.otter.shared.common.model.config.node.Node)22 Test (org.testng.annotations.Test)20 DataMediaPair (com.alibaba.otter.shared.common.model.config.data.DataMediaPair)19 EventData (com.alibaba.otter.shared.etl.model.EventData)19 Mock (mockit.Mock)19 ManagerException (com.alibaba.otter.manager.biz.common.exceptions.ManagerException)17 RepeatConfigureException (com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)17 Identity (com.alibaba.otter.shared.etl.model.Identity)12 RowBatch (com.alibaba.otter.shared.etl.model.RowBatch)12 BaseDbTest (com.alibaba.otter.node.etl.BaseDbTest)10 ChannelArbitrateEvent (com.alibaba.otter.shared.arbitrate.impl.manage.ChannelArbitrateEvent)10 PipelineArbitrateEvent (com.alibaba.otter.shared.arbitrate.impl.manage.PipelineArbitrateEvent)9 PipelineParameter (com.alibaba.otter.shared.common.model.config.pipeline.PipelineParameter)9 FileBatch (com.alibaba.otter.shared.etl.model.FileBatch)9 FileData (com.alibaba.otter.shared.etl.model.FileData)9 HashMap (java.util.HashMap)9 BeforeClass (org.testng.annotations.BeforeClass)9