Search in sources :

Example 1 with LogMessageProcessor

use of com.emc.vipr.client.system.LogMessageProcessor in project coprhd-controller by CoprHD.

the class TaskUtils method getTaskLogs.

public static List<LogMessage> getTaskLogs(TaskResourceRep task) {
    if (task == null) {
        return null;
    }
    ViPRSystemClient systemClient = BourneUtil.getSysClient();
    List<String> nodeIds = Lists.newArrayList();
    List<NodeHealth> nodeHealthList = systemClient.health().getHealth().getNodeHealthList();
    if (nodeHealthList != null) {
        for (NodeHealth nodeHealth : nodeHealthList) {
            if (nodeHealth != null) {
                nodeIds.add(nodeHealth.getNodeId());
            }
        }
    }
    String start = null;
    if (task.getStartTime() != null) {
        start = Long.toString(task.getStartTime().getTimeInMillis());
    }
    String end = null;
    if (task.getEndTime() != null) {
        end = Long.toString(task.getEndTime().getTimeInMillis());
    }
    String regex = "(?i).*" + task.getOpId() + ".*";
    final List<LogMessage> logMessages = Lists.newArrayList();
    LogMessageProcessor processor = new LogMessageProcessor() {

        @Override
        public void processItem(LogMessage logMessage) throws Exception {
            logMessages.add(logMessage);
        }
    };
    systemClient.logs().getAsItems(processor, nodeIds, null, LOG_NAMES, LOG_SEVERITY, start, end, regex, LOGS_MAX_COUNT);
    return logMessages;
}
Also used : ViPRSystemClient(com.emc.vipr.client.ViPRSystemClient) LogMessageProcessor(com.emc.vipr.client.system.LogMessageProcessor) LogMessage(com.emc.vipr.model.sys.logging.LogMessage) NodeHealth(com.emc.vipr.model.sys.healthmonitor.NodeHealth)

Aggregations

ViPRSystemClient (com.emc.vipr.client.ViPRSystemClient)1 LogMessageProcessor (com.emc.vipr.client.system.LogMessageProcessor)1 NodeHealth (com.emc.vipr.model.sys.healthmonitor.NodeHealth)1 LogMessage (com.emc.vipr.model.sys.logging.LogMessage)1