
Btw, I did get the permission to publish this photo. :P
Lets take a look at this album!! I think this is a tea time in WSO2.
Talking about this photo, 4 of them are really good at playing TT :P. And below is a training time!!
package org.wso2.carbon.usage.agent.util; import java.net.MalformedURLException; import java.net.SocketException; import java.net.UnknownHostException; import javax.security.sasl.AuthenticationException; import org.wso2.carbon.eventbridge.agent.thrift.Agent; import org.wso2.carbon.eventbridge.agent.thrift.DataPublisher; import org.wso2.carbon.eventbridge.agent.thrift.conf.AgentConfiguration; import org.wso2.carbon.eventbridge.agent.thrift.exception.AgentException; import org.wso2.carbon.eventbridge.commons.Event; import org.wso2.carbon.eventbridge.commons.exception.DifferentStreamDefinitionAlreadyDefinedException; import org.wso2.carbon.eventbridge.commons.exception.MalformedStreamDefinitionException; import org.wso2.carbon.eventbridge.commons.exception.NoStreamDefinitionExistException; import org.wso2.carbon.eventbridge.commons.exception.StreamDefinitionException; import org.wso2.carbon.eventbridge.commons.exception.TransportException; public class PublishUtil2 { public static final String STREAM_NAME1 = "org.wso2.db6.kpiii"; public static final String VERSION1 = "1.0.6"; private static String streamId1; private static DataPublisher dataPublisher = null; public static void publish(long exceededBytes, long databasesize, String tenentdomain) throws AgentException, MalformedStreamDefinitionException, StreamDefinitionException, DifferentStreamDefinitionAlreadyDefinedException, MalformedURLException, AuthenticationException, NoStreamDefinitionExistException, org.wso2.carbon.eventbridge.commons.exception.AuthenticationException, TransportException, SocketException, UnknownHostException{ System.out.println("Starting BAM KPI Agent"); AgentConfiguration agentConfiguration = new AgentConfiguration(); String currentDir = System.getProperty("user.dir"); System.setProperty("javax.net.ssl.trustStore", currentDir + "/repository/resources/security/client-truststore.jks"); System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon"); Agent agent = new Agent(agentConfiguration); dataPublisher = null; try { dataPublisher = new DataPublisher("tcp://10.100.3.80:7613", "admin", "admin", agent); } catch (Throwable e){ e.printStackTrace(); } streamId1 = null; try { streamId1 = dataPublisher.findEventStream(STREAM_NAME1, VERSION1); System.out.println("Stream already defined"); } catch (NoStreamDefinitionExistException e) { streamId1 = dataPublisher.defineEventStream("{" + " 'name':'" + STREAM_NAME1 + "'," + " 'version':'" + VERSION1 + "'," + " 'nickName': 'DSSUsage'," + " 'description': 'Exceeded DB Use'," + " 'metaData':[" + " {'name':'clientType','type':'STRING'}" + " ]," + " 'payloadData':[" + " {'name':'exceededBytes','type':'LONG'}," + " {'name':'databasesize','type':'LONG'}," + " {'name':'tenentdomain','type':'STRING'}" + " ]" + "}"); } //Publish event for a valid stream if (!streamId1.isEmpty()) { System.out.println("Stream ID: " + streamId1); publishEvents(tenentdomain, exceededBytes, databasesize); // for (int i = 0; i < 1; i++) { // publishEvents("malinga"); // System.out.println("Events published : " + (i + 1) * 2); // } // try { // Thread.sleep(3000); // } catch (InterruptedException e) { // } dataPublisher.stop(); } } public static void publishEvents(String name, long exceededBytes, long databasesize) throws AgentException { System.out.println(name); publishEvents(dataPublisher, streamId1, name, exceededBytes, databasesize); } public static void publishEvents(DataPublisher dataPublisher, String streamId, String name, long exceededBytes, long databasesize) throws AgentException { Event eventOne = new Event(streamId, System.currentTimeMillis(), new Object[]{"external"}, null, new Object[]{exceededBytes, databasesize, 3600.0, name}); dataPublisher.publish(eventOne); } }