package controller;

import com.sun.tools.attach.AttachNotSupportedException;
import communicator.DASPublisher;
import jvmmonitor.UsageMonitor;
import jvmmonitor.exceptions.MonitoringNotStartedException;
import jvmmonitor.model.UsageMonitorLog;
import org.wso2.carbon.databridge.agent.exception.DataEndpointAgentConfigurationException;
import org.wso2.carbon.databridge.agent.exception.DataEndpointAuthenticationException;
import org.wso2.carbon.databridge.agent.exception.DataEndpointConfigurationException;
import org.wso2.carbon.databridge.agent.exception.DataEndpointException;
import org.wso2.carbon.databridge.commons.exception.TransportException;

import javax.management.MalformedObjectNameException;
import java.io.IOException;

/*
*  Copyright (c) ${date}, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
*  WSO2 Inc. licenses this file to you under the Apache License,
*  Version 2.0 (the "License"); you may not use this file except
*  in compliance with the License.
*  You may obtain a copy of the License at
*
*    http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied.  See the License for the
* specific language governing permissions and limitations
* under the License.
*/

public class Controller {

    private static final String pid="33";

    public void sendUsageData() throws IOException,
            AttachNotSupportedException,
            MalformedObjectNameException,
            InterruptedException,
            MonitoringNotStartedException,
            DataEndpointAuthenticationException,
            DataEndpointAgentConfigurationException,
            TransportException,
            DataEndpointException,
            DataEndpointConfigurationException {

        while(true){

                UsageMonitor usageObj = new UsageMonitor(pid);
                usageObj.stratMonitoring();
                UsageMonitorLog usageLogObj = usageObj.getUsageLog();

                DASPublisher dasPublisherObj = new DASPublisher();

                dasPublisherObj.publishMemoryData(usageLogObj.getDate(), usageLogObj.getMemoryUsageLog());
                dasPublisherObj.publishCPUData(usageLogObj.getDate(), usageLogObj.getCpuLoadLog());
                dasPublisherObj.publishGCData(usageLogObj.getGarbageCollectionLog());

            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }


    }

}

@@ -189,32 +189,78 @@
 artedException;%0A
+import jvmmonitor.model.GarbageCollectionLog;%0A
 import jvmmonito
@@ -775,16 +775,45 @@
 ception;
+%0Aimport java.util.LinkedList;
 %0A%0A/*%0A*  
@@ -1539,12 +1539,17 @@
  pid
-=%2233
+ = %2211395
 %22;%0A%0A
@@ -1996,21 +1996,19 @@
 hile
+ 
 (true)
+ 
 %7B%0A%0A
-    
     
@@ -2074,20 +2074,16 @@
         
-   
- 
 usageObj
@@ -2098,28 +2098,24 @@
 nitoring();%0A
-    
             
@@ -2165,28 +2165,24 @@
 sageLog();%0A%0A
-    
             
@@ -2237,36 +2237,32 @@
 );%0A%0A            
-    
 dasPublisherObj.
@@ -2340,36 +2340,32 @@
 ));%0A            
-    
 dasPublisherObj.
@@ -2436,36 +2436,32 @@
 ));%0A            
- 
-   
 dasPublisherObj.
@@ -2470,24 +2470,59 @@
 blishGCData(
+( LinkedList%3CGarbageCollectionLog%3E)
 usageLogObj.
@@ -2546,16 +2546,17 @@
 ionLog()
+ 
 );%0A%0A    
@@ -2723,10 +2723,501 @@
 %0A    %7D%0A%0A
+    public static void main(String%5B%5D args) throws IOException,%0A            AttachNotSupportedException,%0A            MalformedObjectNameException,%0A            InterruptedException,%0A            MonitoringNotStartedException,%0A            DataEndpointAuthenticationException,%0A            DataEndpointAgentConfigurationException,%0A            TransportException,%0A            DataEndpointException,%0A            DataEndpointConfigurationException%7B%0A%0A        new Controller().sendUsageData();%0A%0A    %7D%0A%0A
 %7D%0A

Change method argument