Java Code Examples for org.wso2.carbon.databridge.agent.DataPublisher#shutdownWithAgent()
The following examples show how to use
org.wso2.carbon.databridge.agent.DataPublisher#shutdownWithAgent() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Client.java From product-cep with Apache License 2.0 | 5 votes |
public static void main(String[] args) { log.info(Arrays.deepToString(args)); try { log.info("Starting WSO2 Performance Test Client"); AgentHolder.setConfigPath(DataPublisherUtil.getDataAgentConfigPath()); DataPublisherUtil.setTrustStoreParams(); String protocol = args[0]; String host = args[1]; String port = args[2]; String username = args[3]; String password = args[4]; String eventCount = args[5]; String elapsedCount = args[6]; String warmUpCount = args[7]; String calcType = args[8]; //create data publisher DataPublisher dataPublisher = new DataPublisher(protocol, "tcp://" + host + ":" + port, null, username, password); //Publish event for a valid stream if ("latency".equalsIgnoreCase(calcType)) { publishEventsForLatency(dataPublisher, Long.parseLong(eventCount), Long.parseLong(elapsedCount), Long.parseLong(warmUpCount)); } else { publishEvents(dataPublisher, Long.parseLong(eventCount), Long.parseLong(elapsedCount), Long.parseLong(warmUpCount)); } dataPublisher.shutdownWithAgent(); } catch (Throwable e) { log.error(e); } }
Example 2
Source File: HttpdLogAgent.java From product-cep with Apache License 2.0 | 4 votes |
public static void main(String[] args) throws SocketException, MalformedURLException, AuthenticationException, TransportException, StreamDefinitionException, MalformedStreamDefinitionException, DifferentStreamDefinitionAlreadyDefinedException, FileNotFoundException, UnknownHostException, DataEndpointAuthenticationException, DataEndpointAgentConfigurationException, DataEndpointException, DataEndpointConfigurationException { System.out.println("Starting HttpLog Agent"); DataPublisherUtil.setTrustStoreParams(); AgentHolder.setConfigPath(DataPublisherUtil.getAgentConfigPath()); String host = args[0]; String port = args[1]; String username = args[2]; String password = args[3]; //create data publisher DataPublisher dataPublisher = new DataPublisher("tcp://" + host + ":" + port, username, password); String streamId = DataBridgeCommonsUtils.generateStreamId(HTTPD_LOG_STREAM,VERSION); // try { // streamId = dataPublisher.findStream(HTTPD_LOG_STREAM, VERSION); // System.out.println("Stream already defined"); // // } catch (NoStreamDefinitionExistException e) { // //Define event stream // streamId = dataPublisher.defineStream("{" + // " 'name':'" + HTTPD_LOG_STREAM + "'," + // " 'version':'" + VERSION + "'," + // " 'nickName': 'Httpd_Log_Stream'," + // " 'description': 'Sample of Httpd logs'," + // " 'metaData':[" + // " {'name':'clientType','type':'STRING'}" + // " ]," + // " 'payloadData':[" + // " {'name':'log','type':'STRING'}" + // " ]" + // "}"); // // } if (null != streamId && !streamId.isEmpty()) { publishLogEvents(dataPublisher, streamId); } try { Thread.sleep(2000); } catch (InterruptedException e) { } dataPublisher.shutdownWithAgent(); }
Example 3
Source File: Client.java From product-cep with Apache License 2.0 | 4 votes |
public static void main(String[] args) { System.out.println(Arrays.deepToString(args)); try { System.out.println("Starting WSO2 Event Client"); AgentHolder.setConfigPath(DataPublisherUtil.getDataAgentConfigPath()); DataPublisherUtil.setTrustStoreParams(); String protocol = args[0]; String host = args[1]; String port = args[2]; String username = args[3]; String password = args[4]; String streamId = args[5]; String sampleNumber = args[6]; String filePath = args[7]; int events = Integer.parseInt(args[8]); int delay = Integer.parseInt(args[9]); Map<String, StreamDefinition> streamDefinitions = DataPublisherUtil.loadStreamDefinitions(sampleNumber); if (streamId == null || streamId.length() == 0) { throw new Exception("streamId not provided"); } StreamDefinition streamDefinition = streamDefinitions.get(streamId); if (streamDefinition == null) { throw new Exception("StreamDefinition not available for stream " + streamId); } else { log.info("StreamDefinition used :" + streamDefinition); } filePath = DataPublisherUtil.getEventFilePath(sampleNumber, streamId, filePath); //create data publisher DataPublisher dataPublisher = new DataPublisher(protocol, "tcp://" + host + ":" + port, null, username, password); //Publish event for a valid stream publishEvents(dataPublisher, streamDefinition, filePath, events, delay); dataPublisher.shutdownWithAgent(); } catch (Throwable e) { log.error(e); } }