Search in sources :

Example 1 with LogMessage

use of com.emc.vipr.model.sys.logging.LogMessage in project coprhd-controller by CoprHD.

the class TaskLogsDataTable method fetch.

public static List<Log> fetch(URI taskId) {
    if (taskId == null) {
        return Collections.EMPTY_LIST;
    }
    List<LogMessage> logMessages = TaskUtils.getTaskLogs(taskId);
    List<Log> logs = Lists.newArrayList();
    if (logMessages != null) {
        for (LogMessage logMessage : logMessages) {
            logs.add(new Log(logMessage));
        }
    }
    return logs;
}
Also used : LogMessage(com.emc.vipr.model.sys.logging.LogMessage)

Example 2 with LogMessage

use of com.emc.vipr.model.sys.logging.LogMessage in project coprhd-controller by CoprHD.

the class Logs method getAsItems.

/**
 * @deprecated Replaced by
 * @see #getAsItems(ItemProcessor, Collection, Collection, Collection, Integer, String, String, String, Integer)
 */
@Deprecated
public void getAsItems(ItemProcessor<LogMessage> processor, Collection<String> nodeIds, Collection<String> logNames, Integer severity, String start, String end, String regex, Integer maxCount) {
    ListProcessor<LogMessage> listProcessor = new ListProcessor<LogMessage>(LogMessage.class, processor);
    InputStream in = getAsStream(nodeIds, logNames, severity, start, end, regex, maxCount);
    try {
        listProcessor.process(in);
    } catch (Exception e) {
        throw new ViPRException(e);
    } finally {
        try {
            in.close();
        } catch (IOException e) {
        // Silently ignore
        }
    }
}
Also used : ListProcessor(com.emc.vipr.client.impl.jaxb.ListProcessor) LogMessage(com.emc.vipr.model.sys.logging.LogMessage) InputStream(java.io.InputStream) ViPRException(com.emc.vipr.client.exceptions.ViPRException) IOException(java.io.IOException) IOException(java.io.IOException) ViPRException(com.emc.vipr.client.exceptions.ViPRException)

Example 3 with LogMessage

use of com.emc.vipr.model.sys.logging.LogMessage 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

LogMessage (com.emc.vipr.model.sys.logging.LogMessage)3 ViPRSystemClient (com.emc.vipr.client.ViPRSystemClient)1 ViPRException (com.emc.vipr.client.exceptions.ViPRException)1 ListProcessor (com.emc.vipr.client.impl.jaxb.ListProcessor)1 LogMessageProcessor (com.emc.vipr.client.system.LogMessageProcessor)1 NodeHealth (com.emc.vipr.model.sys.healthmonitor.NodeHealth)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1