Search in sources :

Example 1 with LogRecord

use of com.alibaba.otter.shared.common.model.config.record.LogRecord in project otter by alibaba.

the class LogRecordServiceImpl method create.

public void create(Event event) {
    LogRecord logRecord = new LogRecord();
    if (event instanceof NodeAlarmEvent) {
        NodeAlarmEvent nodeAlarmEvent = (NodeAlarmEvent) event;
        Pipeline tempPipeline = new Pipeline();
        tempPipeline.setId(nodeAlarmEvent.getPipelineId());
        logRecord.setPipeline(tempPipeline);
        logRecord.setNid(nodeAlarmEvent.getNid());
        logRecord.setTitle(nodeAlarmEvent.getTitle());
        logRecord.setMessage(nodeAlarmEvent.getMessage());
    }
    create(logRecord);
}
Also used : LogRecord(com.alibaba.otter.shared.common.model.config.record.LogRecord) NodeAlarmEvent(com.alibaba.otter.shared.communication.model.arbitrate.NodeAlarmEvent) Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)

Example 2 with LogRecord

use of com.alibaba.otter.shared.common.model.config.record.LogRecord in project otter by alibaba.

the class LogRecordServiceImpl method doToModel.

/**
     * <pre>
     * 用于DO对象转化为Model对象
     * </pre>
     * 
     * @param channelDO
     * @return Channel
     */
private LogRecord doToModel(LogRecordDO logRecordDo) {
    LogRecord logRecord = new LogRecord();
    try {
        logRecord.setId(logRecordDo.getId());
        if (logRecordDo.getPipelineId() > 0 && logRecordDo.getChannelId() > 0) {
            try {
                Channel channel = channelService.findByPipelineId(logRecordDo.getPipelineId());
                logRecord.setChannel(channel);
                for (Pipeline pipeline : channel.getPipelines()) {
                    if (pipeline.getId().equals(logRecordDo.getPipelineId())) {
                        logRecord.setPipeline(pipeline);
                    }
                }
            } catch (Exception e) {
                // 可能历史的log记录对应的channel/pipeline已经被删除了,直接忽略吧
                Channel channel = new Channel();
                channel.setId(0l);
                logRecord.setChannel(channel);
                Pipeline pipeline = new Pipeline();
                pipeline.setId(0l);
                logRecord.setPipeline(pipeline);
            }
        } else {
            Channel channel = new Channel();
            channel.setId(-1l);
            logRecord.setChannel(channel);
            Pipeline pipeline = new Pipeline();
            pipeline.setId(-1l);
            logRecord.setPipeline(pipeline);
        }
        logRecord.setTitle(logRecordDo.getTitle());
        logRecord.setNid(logRecordDo.getNid());
        logRecord.setMessage(logRecordDo.getMessage());
        logRecord.setGmtCreate(logRecordDo.getGmtCreate());
        logRecord.setGmtModified(logRecordDo.getGmtModified());
    } catch (Exception e) {
        logger.error("ERROR ## ");
        throw new ManagerException(e);
    }
    return logRecord;
}
Also used : LogRecord(com.alibaba.otter.shared.common.model.config.record.LogRecord) Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)

Example 3 with LogRecord

use of com.alibaba.otter.shared.common.model.config.record.LogRecord in project otter by alibaba.

the class AbstractRuleMonitor method logRecordAlarm.

protected void logRecordAlarm(Long pipelineId, Long nodeId, MonitorName monitorName, String message) {
    Pipeline pipeline = new Pipeline();
    pipeline.setId(pipelineId);
    LogRecord logRecord = new LogRecord();
    logRecord.setTitle(monitorName.toString());
    logRecord.setNid(nodeId);
    logRecord.setPipeline(pipeline);
    logRecord.setMessage(message);
    logRecordService.create(logRecord);
}
Also used : LogRecord(com.alibaba.otter.shared.common.model.config.record.LogRecord) Pipeline(com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)

Example 4 with LogRecord

use of com.alibaba.otter.shared.common.model.config.record.LogRecord in project otter by alibaba.

the class LogRecordTab method execute.

public void execute(@Param("pageIndex") int pageIndex, @Param("searchKey") String searchKey, @Param("pipelineId") Long pipelineId, Context context) throws Exception {
    @SuppressWarnings("unchecked") Map<String, Object> condition = new HashMap<String, Object>();
    if ("请输入关键字(目前支持log内容关键字搜索)".equals(searchKey)) {
        searchKey = "";
    }
    condition.put("pipelineId", pipelineId);
    condition.put("searchKey", searchKey);
    int count = logRecordService.getCount(condition);
    Paginator paginator = new Paginator();
    paginator.setItems(count);
    paginator.setPage(pageIndex);
    condition.put("offset", paginator.getOffset());
    condition.put("length", paginator.getLength());
    List<LogRecord> logRecords = logRecordService.listByCondition(condition);
    for (LogRecord logRecord : logRecords) {
        if (!StringUtils.isEmpty(logRecord.getMessage())) {
            logRecord.setMessage(logRecord.getMessage().replaceAll("\n\t", "<br/>"));
        }
    }
    context.put("logRecords", logRecords);
    context.put("paginator", paginator);
    context.put("searchKey", searchKey);
    context.put("pipelineId", pipelineId);
    Channel channel = channelService.findByPipelineId(pipelineId);
    context.put("channel", channel);
}
Also used : HashMap(java.util.HashMap) LogRecord(com.alibaba.otter.shared.common.model.config.record.LogRecord) Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) Paginator(com.alibaba.citrus.util.Paginator)

Example 5 with LogRecord

use of com.alibaba.otter.shared.common.model.config.record.LogRecord in project otter by alibaba.

the class LogRecordList method execute.

public void execute(@Param("pageIndex") int pageIndex, @Param("pipelineId") String pipelineId, @Param("monitorName") String monitorName, @Param("searchKey") String searchKey, Context context) throws Exception {
    @SuppressWarnings("unchecked") Map<String, Object> condition = new HashMap<String, Object>();
    if ("请输入关键字(目前支持CID,PID搜索)".equals(searchKey)) {
        searchKey = "";
    }
    condition.put("searchKey", searchKey);
    condition.put("monitorName", monitorName);
    condition.put("pipelineId", pipelineId);
    int count = logRecordService.getCount(condition);
    Paginator paginator = new Paginator();
    paginator.setItems(count);
    paginator.setPage(pageIndex);
    condition.put("offset", paginator.getOffset());
    condition.put("length", paginator.getLength());
    List<LogRecord> logRecords = logRecordService.listByCondition(condition);
    // List<LogRecord> logRecords = logRecordService.listAll();
    context.put("logRecords", logRecords);
    context.put("paginator", paginator);
    context.put("searchKey", searchKey);
    context.put("pipelineId", pipelineId);
    context.put("monitorName", monitorName);
}
Also used : HashMap(java.util.HashMap) LogRecord(com.alibaba.otter.shared.common.model.config.record.LogRecord) Paginator(com.alibaba.citrus.util.Paginator)

Aggregations

LogRecord (com.alibaba.otter.shared.common.model.config.record.LogRecord)5 Pipeline (com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)3 Paginator (com.alibaba.citrus.util.Paginator)2 Channel (com.alibaba.otter.shared.common.model.config.channel.Channel)2 HashMap (java.util.HashMap)2 ManagerException (com.alibaba.otter.manager.biz.common.exceptions.ManagerException)1 NodeAlarmEvent (com.alibaba.otter.shared.communication.model.arbitrate.NodeAlarmEvent)1