void connect() throws TransportException, DataEndpointAuthenticationException, DataEndpointException { if (connectionWorker != null) { connectionService.submit(connectionWorker); } else { throw new DataEndpointException("Data Endpoint is not initialized"); } }
log.error(e.getMessage()); } catch (DataEndpointException e) { log.error(e.getMessage()); } catch (DataEndpointConfigurationException e) { log.error(e.getMessage());
} catch (DataEndpointException e) { log.error("Error in initializing binary data-publisher to send requests to global throttling engine " + e.getMessage(), e); } catch (DataEndpointConfigurationException e) { log.error("Error in initializing binary data-publisher to send requests to global throttling engine " +
void connect() throws TransportException, DataEndpointAuthenticationException, DataEndpointException { if (connectionWorker != null) { connectionService.submit(connectionWorker); } else { throw new DataEndpointException("Data Endpoint is not initialized"); } }
/** * Initialize the data endpoint connection worker. * A connection worker can be instantiated only ONE time. * * @param dataEndpoint DataEndpoint instance to handle the connection. * @param dataEndpointConfiguration DataEndpointConfiguration to handle the connection. * @throws DataEndpointException */ public void initialize(DataEndpoint dataEndpoint, DataEndpointConfiguration dataEndpointConfiguration) throws DataEndpointException { if (this.dataEndpointConfiguration == null) { this.dataEndpointConfiguration = dataEndpointConfiguration; } else { throw new DataEndpointException("Already data endpoint configuration is set: " + this.dataEndpointConfiguration.toString() + " for the endpoint " + dataEndpointConfiguration.toString()); } if (this.dataEndpoint == null) { this.dataEndpoint = dataEndpoint; } else { throw new DataEndpointException("Already data endpoint is configured for the connection worker"); } }
/** * Initialize the data endpoint connection worker. * A connection worker can be instantiated only ONE time. * * @param dataEndpoint DataEndpoint instance to handle the connection. * @param dataEndpointConfiguration DataEndpointConfiguration to handle the connection. * @throws DataEndpointException */ public void initialize(DataEndpoint dataEndpoint, DataEndpointConfiguration dataEndpointConfiguration) throws DataEndpointException { if (this.dataEndpointConfiguration == null) { this.dataEndpointConfiguration = dataEndpointConfiguration; } else { throw new DataEndpointException("Already data endpoint configuration is set: " + this.dataEndpointConfiguration.toString() + " for the endpoint " + dataEndpointConfiguration.toString()); } if (this.dataEndpoint == null) { this.dataEndpoint = dataEndpoint; } else { throw new DataEndpointException("Already data endpoint is configured for the connection worker"); } }
public DataEndpoint getNewDataEndpoint() throws DataEndpointException { try { return (DataEndpoint) (DataEndpointAgent.class.getClassLoader(). loadClass(this.getAgentConfiguration().getDataEndpointClass()).newInstance()); } catch (InstantiationException | IllegalAccessException e) { throw new DataEndpointException("Error while instantiating the endpoint class for endpoint name " + this.getAgentConfiguration().getName() + ". " + e.getMessage(), e); } catch (ClassNotFoundException e) { throw new DataEndpointException("Class defined: " + this.getAgentConfiguration().getDataEndpointClass() + " cannot be found for endpoint name " + this.getAgentConfiguration().getName() + ". " + e.getMessage(), e); } }
synchronized void syncConnect(String oldSessionId) throws DataEndpointException { if (oldSessionId == null || oldSessionId.equalsIgnoreCase(getDataEndpointConfiguration().getSessionId())) { if (connectionWorker != null) { connectionWorker.run(); } else { throw new DataEndpointException("Data Endpoint is not initialized"); } } }
synchronized void syncConnect(String oldSessionId) throws DataEndpointException { if (oldSessionId == null || oldSessionId.equalsIgnoreCase(getDataEndpointConfiguration().getSessionId())) { if (connectionWorker != null) { connectionWorker.run(); } else { throw new DataEndpointException("Data Endpoint is not initialized"); } } }
public DataEndpoint getNewDataEndpoint() throws DataEndpointException { try { return (DataEndpoint) (DataEndpointAgent.class.getClassLoader(). loadClass(this.getAgentConfiguration().getDataEndpointClass()).newInstance()); } catch (InstantiationException | IllegalAccessException e) { throw new DataEndpointException("Error while instantiating the endpoint class for endpoint name " + this.getAgentConfiguration().getName() + ". " + e.getMessage(), e); } catch (ClassNotFoundException e) { throw new DataEndpointException("Class defined: " + this.getAgentConfiguration().getDataEndpointClass() + " cannot be found for endpoint name " + this.getAgentConfiguration().getName() + ". " + e.getMessage(), e); } }
@Override public Object createClient(String protocol, String hostName, int port) throws DataEndpointException, DataEndpointAgentConfigurationException { if (protocol.equalsIgnoreCase(DataEndpointConfiguration.Protocol.TCP.toString())) { int timeout = AgentHolder.getInstance().getDataEndpointAgent(DataEndpointConstants.BINARY_DATA_AGENT_TYPE) .getAgentConfiguration().getSocketTimeoutMS(); try { Socket socket = new Socket(hostName, port); socket.setSoTimeout(timeout); return socket; } catch (IOException e) { throw new DataEndpointException("Error while opening socket to " + hostName + ":" + port + ". " + e.getMessage(), e); } } else { throw new DataEndpointException("Unsupported protocol: " + protocol + ". Currently only " + DataEndpointConfiguration.Protocol.TCP.toString() + " supported."); } }
@Override public Object createClient(String protocol, String hostName, int port) throws DataEndpointException, DataEndpointAgentConfigurationException { if (protocol.equalsIgnoreCase(DataEndpointConfiguration.Protocol.TCP.toString())) { int timeout = AgentHolder.getInstance().getDataEndpointAgent(DataEndpointConstants.BINARY_DATA_AGENT_TYPE) .getAgentConfiguration().getSocketTimeoutMS(); try { Socket socket = new Socket(hostName, port); socket.setSoTimeout(timeout); return socket; } catch (IOException e) { throw new DataEndpointException("Error while opening socket to " + hostName + ":" + port + ". " + e.getMessage(), e); } } else { throw new DataEndpointException("Unsupported protocol: " + protocol + ". Currently only " + DataEndpointConfiguration.Protocol.TCP.toString() + " supported."); } }
public synchronized void shutDown() throws DataEndpointException { for (DataPublisher dataPublisher : dataPublishers) { dataPublisher.shutdown(); } try { transportPool.close(); securedTransportPool.close(); } catch (Exception e) { throw new DataEndpointException("Error while closing the transport pool", e); } } }
public synchronized void shutDown() throws DataEndpointException { for (DataPublisher dataPublisher : dataPublishers) { dataPublisher.shutdown(); } try { transportPool.close(); securedTransportPool.close(); } catch (Exception e) { throw new DataEndpointException("Error while closing the transport pool", e); } } }
@Override public Object createClient(String protocol, String hostName, int port) throws DataEndpointException, DataEndpointAgentConfigurationException { if (protocol.equalsIgnoreCase(DataEndpointConfiguration.Protocol.TCP.toString())) { int socketTimeout = AgentHolder.getInstance().getDataEndpointAgent(DataEndpointConstants.THRIFT_DATA_AGENT_TYPE). getAgentConfiguration().getSocketTimeoutMS(); TTransport receiverTransport = new TSocket(hostName, port, socketTimeout); TProtocol tProtocol = new TBinaryProtocol(receiverTransport); ThriftEventTransmissionService.Client client = new ThriftEventTransmissionService.Client(tProtocol); try { receiverTransport.open(); } catch (TTransportException e) { throw new DataEndpointException("Error while making the connection." + e.getMessage(), e); } return client; } throw new DataEndpointException("Unsupported protocol :" + protocol + " used to authenticate the client, only " + DataEndpointConfiguration.Protocol.TCP.toString() + " is supported"); }
@Override public Object createClient(String protocol, String hostName, int port) throws DataEndpointException, DataEndpointAgentConfigurationException { if (protocol.equalsIgnoreCase(DataEndpointConfiguration.Protocol.TCP.toString())) { int socketTimeout = AgentHolder.getInstance(). getDataEndpointAgent(DataEndpointConstants.THRIFT_DATA_AGENT_TYPE). getAgentConfiguration().getSocketTimeoutMS(); TTransport receiverTransport = new TSocket(hostName, port, socketTimeout); TProtocol tProtocol = new TBinaryProtocol(receiverTransport); ThriftEventTransmissionService.Client client = new ThriftEventTransmissionService.Client(tProtocol); try { receiverTransport.open(); } catch (TTransportException e) { throw new DataEndpointException("Error while making the connection." + e.getMessage(), e); } return client; } throw new DataEndpointException("Unsupported protocol :" + protocol + " used to authenticate the client, only " + DataEndpointConfiguration.Protocol.TCP.toString() + " is supported"); }
@Override protected void send(Object client, List<Event> events) throws DataEndpointException, SessionTimeoutException, UndefinedEventTypeException { Socket socket = (Socket) client; String sessionId = getDataEndpointConfiguration().getSessionId(); try { sendBinaryPublishMessage(socket, events, sessionId); processResponse(socket); } catch (Exception e) { if (e instanceof DataEndpointException) { throw (DataEndpointException) e; } else if (e instanceof UndefinedEventTypeException) { throw new UndefinedEventTypeException("Undefined Event Type Exception ", e); } else if (e instanceof SessionTimeoutException) { throw new SessionTimeoutException("Binary Session Expired Exception ", e); } else { throw new DataEndpointException("Error while trying to publish events to data receiver :" + socket.getRemoteSocketAddress().toString(), e); } } }
@Override protected void send(Object client, List<Event> events) throws DataEndpointException, SessionTimeoutException, UndefinedEventTypeException { Socket socket = (Socket) client; String sessionId = getDataEndpointConfiguration().getSessionId(); try { sendBinaryPublishMessage(socket, events, sessionId); processResponse(socket); } catch (Exception e) { if (e instanceof DataEndpointException) { throw (DataEndpointException) e; } else if (e instanceof UndefinedEventTypeException) { throw new UndefinedEventTypeException("Undefined Event Type Exception ", e); } else if (e instanceof SessionTimeoutException) { throw new SessionTimeoutException("Binary Session Expired Exception ", e); } else { throw new DataEndpointException("Error while trying to publish events to data receiver :" + socket.getRemoteSocketAddress().toString(), e); } } }
throw new DataEndpointException("Error while opening socket to " + hostName + ":" + port + ". " + e.getMessage(), e); throw new DataEndpointException("Unsupported protocol: " + protocol + ". Currently only " + DataEndpointConfiguration.Protocol.SSL.toString() + " supported.");
private Object getClient() throws DataEndpointException { try { return transportPool.borrowObject(getDataEndpointConfiguration().getPublisherKey()); } catch (Exception e) { throw new DataEndpointException("Cannot borrow client for " + getDataEndpointConfiguration().getPublisherKey(), e); } }