Search in sources :

Example 1 with LogDetail

use of org.wso2.ei.dashboard.core.rest.model.LogDetail in project product-mi-tooling by wso2.

the class LogsDelegate method getLogsList.

public LogList getLogsList(String groupId, List<String> nodeList) throws ManagementApiException {
    log.debug("Fetching logs via management api.");
    LogList logList = new LogList();
    for (String nodeId : nodeList) {
        JsonArray logsArray = getLogsArray(groupId, nodeId);
        for (JsonElement jsonElement : logsArray) {
            JsonObject logObject = jsonElement.getAsJsonObject();
            String fileName = logObject.get("FileName").getAsString();
            String fileSize = logObject.get("Size").getAsString();
            AtomicBoolean isRecordExist = new AtomicBoolean(false);
            logList.stream().filter(o -> o.getName().equals(fileName)).forEach(o -> {
                LogDetail logDetail = new LogDetail();
                logDetail.setNodeId(nodeId);
                logDetail.setLogSize(fileSize);
                o.getNodes().add(logDetail);
                isRecordExist.set(true);
            });
            if (!isRecordExist.get()) {
                LogListInner logListInner = new LogListInner();
                logListInner.setName(fileName);
                List<LogDetail> logDetailList = new ArrayList<>();
                LogDetail logDetail = new LogDetail();
                logDetail.setNodeId(nodeId);
                logDetail.setLogSize(fileSize);
                logDetailList.add(logDetail);
                logListInner.setNodes(logDetailList);
                logList.add(logListInner);
            }
        }
    }
    return logList;
}
Also used : JsonArray(com.google.gson.JsonArray) JsonObject(com.google.gson.JsonObject) ManagementApiUtils(org.wso2.ei.dashboard.core.commons.utils.ManagementApiUtils) LogDetail(org.wso2.ei.dashboard.core.rest.model.LogDetail) HttpEntity(org.apache.http.HttpEntity) HttpUtils(org.wso2.ei.dashboard.core.commons.utils.HttpUtils) ManagementApiException(org.wso2.ei.dashboard.core.exception.ManagementApiException) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) IOException(java.io.IOException) LogList(org.wso2.ei.dashboard.core.rest.model.LogList) Utils(org.wso2.ei.dashboard.micro.integrator.commons.Utils) EntityUtils(org.apache.http.util.EntityUtils) ArrayList(java.util.ArrayList) JsonElement(com.google.gson.JsonElement) DatabaseManagerFactory(org.wso2.ei.dashboard.core.db.manager.DatabaseManagerFactory) JsonArray(com.google.gson.JsonArray) List(java.util.List) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) Log(org.apache.commons.logging.Log) LogListInner(org.wso2.ei.dashboard.core.rest.model.LogListInner) LogFactory(org.apache.commons.logging.LogFactory) DatabaseManager(org.wso2.ei.dashboard.core.db.manager.DatabaseManager) LogList(org.wso2.ei.dashboard.core.rest.model.LogList) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) LogDetail(org.wso2.ei.dashboard.core.rest.model.LogDetail) LogListInner(org.wso2.ei.dashboard.core.rest.model.LogListInner) JsonElement(com.google.gson.JsonElement) ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject)

Aggregations

JsonArray (com.google.gson.JsonArray)1 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Log (org.apache.commons.logging.Log)1 LogFactory (org.apache.commons.logging.LogFactory)1 HttpEntity (org.apache.http.HttpEntity)1 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)1 EntityUtils (org.apache.http.util.EntityUtils)1 HttpUtils (org.wso2.ei.dashboard.core.commons.utils.HttpUtils)1 ManagementApiUtils (org.wso2.ei.dashboard.core.commons.utils.ManagementApiUtils)1 DatabaseManager (org.wso2.ei.dashboard.core.db.manager.DatabaseManager)1 DatabaseManagerFactory (org.wso2.ei.dashboard.core.db.manager.DatabaseManagerFactory)1 ManagementApiException (org.wso2.ei.dashboard.core.exception.ManagementApiException)1 LogDetail (org.wso2.ei.dashboard.core.rest.model.LogDetail)1 LogList (org.wso2.ei.dashboard.core.rest.model.LogList)1 LogListInner (org.wso2.ei.dashboard.core.rest.model.LogListInner)1