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;
}
Aggregations