org.wso2.carbon.databridge.commons.exception.TransportException Java Examples
The following examples show how to use
org.wso2.carbon.databridge.commons.exception.TransportException.
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: DataEndpoint.java From product-microgateway with Apache License 2.0 | 6 votes |
public void initialize(DataEndpointConfiguration dataEndpointConfiguration) throws DataEndpointException, DataEndpointAuthenticationException, TransportException { this.transportPool = dataEndpointConfiguration.getTransportPool(); this.batchSize = dataEndpointConfiguration.getBatchSize(); this.connectionWorker = new DataEndpointConnectionWorker(); this.connectionWorker.initialize(this, dataEndpointConfiguration); this.threadPoolExecutor = new EventPublisherThreadPoolExecutor(dataEndpointConfiguration.getCorePoolSize(), dataEndpointConfiguration.getMaxPoolSize(), dataEndpointConfiguration.getKeepAliveTimeInPool(), dataEndpointConfiguration.getReceiverURL()); this.connectionService = Executors.newSingleThreadExecutor(new DataBridgeThreadFactory( "ConnectionService-" + dataEndpointConfiguration.getReceiverURL())); this.maxPoolSize = dataEndpointConfiguration.getMaxPoolSize(); this.immediateDispatchSemaphore = new Semaphore(maxPoolSize); connect(); }
Example #2
Source File: Wso2EventClient.java From product-cep with Apache License 2.0 | 6 votes |
public static void publish(String protocol, String host, String port, String username, String password, String streamId,String dataFileName, String testCaseFolderName, StreamDefinition streamDefinition, int events, int delay) throws MalformedStreamDefinitionException, StreamDefinitionException, DifferentStreamDefinitionAlreadyDefinedException, MalformedURLException, NoStreamDefinitionExistException, AuthenticationException, TransportException, SocketException, DataEndpointAgentConfigurationException, DataEndpointException, DataEndpointAuthenticationException, DataEndpointConfigurationException { String relativeFilePath = getTestDataFileLocation(testCaseFolderName, dataFileName); KeyStoreUtil.setTrustStoreParams(); //create data publisher DataPublisher dataPublisher = new DataPublisher(protocol, "tcp://" + host + ":" + port, null, username, password); //Publish event for a valid stream publishEvents(dataPublisher, streamDefinition, relativeFilePath, events, delay); dataPublisher.shutdown(); }
Example #3
Source File: DataEndpoint.java From product-microgateway with Apache License 2.0 | 5 votes |
void connect() throws TransportException, DataEndpointAuthenticationException, DataEndpointException { if (connectionWorker != null) { connectionService.submit(connectionWorker); } else { throw new DataEndpointException("Data Endpoint is not initialized"); } }
Example #4
Source File: HTTPMonitoringDataPublisher.java From msf4j with Apache License 2.0 | 5 votes |
private void init(DasConfig dasConfig) { if (logger.isInfoEnabled()) { logger.info("Initializing HTTP Monitoring Data Publisher"); } String type = dasConfig.getType(); String receiverURL = dasConfig.getReceiverURL(); String authURL = dasConfig.getAuthURL(); String username = dasConfig.getUsername(); String password = dasConfig.getPassword(); String dataAgentConfigPath = dasConfig.getDataAgentConfigPath(); if (type == null) { throw new IllegalArgumentException("Type cannot be null"); } if (receiverURL == null) { throw new IllegalArgumentException("Data Receiver URL cannot be null"); } if (username == null) { throw new IllegalArgumentException("Username cannot be null"); } if (password == null) { throw new IllegalArgumentException("Password cannot be null"); } if (dataAgentConfigPath == null) { throw new IllegalArgumentException("Data Agent Configuration Path cannot be null"); } AgentHolder.setConfigPath(dataAgentConfigPath); arbitraryAttributes = SystemVariableUtil.getArbitraryAttributes(); try { dataPublisher = new DataPublisher(type, receiverURL, authURL, username, password); } catch (DataEndpointAgentConfigurationException | DataEndpointException | DataEndpointConfigurationException | DataEndpointAuthenticationException | TransportException e) { throw new IllegalStateException("Error when initializing the Data Publisher", e); } }
Example #5
Source File: DataPublisher.java From product-microgateway with Apache License 2.0 | 4 votes |
/** * This validates the input that are passed in the DataPublisher creation, * and initiates the endpoints connection. * * @param dataEndpointAgent Agent of the DataPublisher. * @param receiverURLSet The receiving endpoint URL Set. This can be either load balancing URL set, * or Failover URL set. * @param authURLSet The authenticating URL Set for the endpoints given in receiverURLSet parameter. * This should be in the same format as receiverURL set parameter. If the authURLSet * is null, then default authURLSet will be generated from the receiverURL. * @param username Authorized username at receiver. * @param password The password of the username provided. * @throws DataEndpointConfigurationException Exception to be thrown When parsing the Data Endpoint * configurations when initializing data publisher * @throws DataEndpointException Exception to be thrown when communicating with DataEndpoint. * @throws DataEndpointAuthenticationException Exception to be thrown when connecting the Data Endpoint * @throws TransportException Transport level exception */ private void processEndpoints(DataEndpointAgent dataEndpointAgent, String receiverURLSet, String authURLSet, String username, String password) throws DataEndpointConfigurationException, DataEndpointException, DataEndpointAuthenticationException, TransportException { ArrayList<Object[]> receiverURLGroups = DataPublisherUtil.getEndpointGroups(receiverURLSet); ArrayList<Object[]> authURLGroups = DataPublisherUtil.getEndpointGroups(authURLSet); DataPublisherUtil.validateURLs(receiverURLGroups, authURLGroups); for (int i = 0; i < receiverURLGroups.size(); i++) { Object[] receiverGroup = (Object[]) receiverURLGroups.get(i); Object[] authGroup = (Object[]) authURLGroups.get(i); boolean failOver = (Boolean) receiverGroup[0]; DataEndpointGroup endpointGroup; if (failOver) { endpointGroup = new DataEndpointGroup(DataEndpointGroup.HAType.FAILOVER, dataEndpointAgent); } else { endpointGroup = new DataEndpointGroup(DataEndpointGroup.HAType.LOADBALANCE, dataEndpointAgent); } /* * Since the first element holds the failover/LB settings * we need to start iterating from 2nd element. */ for (int j = 1; j < receiverGroup.length; j++) { DataEndpointConfiguration endpointConfiguration = new DataEndpointConfiguration((String) receiverGroup[j], (String) authGroup[j], username, password, dataEndpointAgent.getTransportPool(), dataEndpointAgent.getSecuredTransportPool(), dataEndpointAgent. getAgentConfiguration().getBatchSize(), dataEndpointAgent.getAgentConfiguration().getCorePoolSize(), dataEndpointAgent.getAgentConfiguration().getMaxPoolSize(), dataEndpointAgent.getAgentConfiguration().getKeepAliveTimeInPool()); DataEndpoint dataEndpoint = dataEndpointAgent.getNewDataEndpoint(); dataEndpoint.initialize(endpointConfiguration); endpointGroup.addDataEndpoint(dataEndpoint); } endpointGroups.add(endpointGroup); } }
Example #6
Source File: DataPublisher.java From product-microgateway with Apache License 2.0 | 3 votes |
/** * Creates the DataPublisher instance for a specific user, and the it creates * connection asynchronously to receiver endpoint. * * @param receiverURLSet The receiving endpoint URL Set. This can be either load balancing URL set, * or Failover URL set. * @param authURLSet The authenticating URL Set for the endpoints given in receiverURLSet parameter. * This should be in the same format as receiverURL set parameter. If null is passed * the authURLs will be offsetted by value of 100. * @param username Authorized username at receiver. * @param password The password of the username provided. * @throws DataEndpointException Exception to be thrown when communicating with DataEndpoint. * @throws DataEndpointConfigurationException Exception to be thrown When parsing the Data Endpoint * configurations when initializing data publisher * @throws DataEndpointAuthenticationException Exception to be thrown when connecting the Data Endpoint * @throws TransportException Transport level exception */ public DataPublisher(String receiverURLSet, String authURLSet, String username, String password) throws DataEndpointException, DataEndpointConfigurationException, DataEndpointAuthenticationException, TransportException { dataEndpointAgent = AgentHolder.getInstance().getDataEndpointAgent(); if (authURLSet == null) { authURLSet = DataPublisherUtil.getDefaultAuthURLSet(receiverURLSet); } processEndpoints(dataEndpointAgent, receiverURLSet, authURLSet, username, password); dataEndpointAgent.addDataPublisher(this); }