public List<Event> toEventList(Object eventBundle, StreamTypeHolder streamTypeHolder) { if (eventBundle instanceof ThriftEventBundle) { return createEventList((ThriftEventBundle) eventBundle, streamTypeHolder); } else { throw new EventConversionException("Wrong type event relieved " + eventBundle.getClass()); } }
private void startSecureEventTransmission(String hostName, int port, DataBridgeReceiverService dataBridgeReceiverService) throws DataBridgeException { try { ServerConfiguration serverConfig = ServerConfiguration.getInstance(); String keyStore = serverConfig.getFirstProperty("Security.KeyStore.Location"); if (keyStore == null) { keyStore = System.getProperty("Security.KeyStore.Location"); if (keyStore == null) { throw new DataBridgeException("Cannot start agent server, not valid Security.KeyStore.Location is null"); } } String keyStorePassword = serverConfig.getFirstProperty("Security.KeyStore.Password"); if (keyStorePassword == null) { keyStorePassword = System.getProperty("Security.KeyStore.Password"); if (keyStorePassword == null) { throw new DataBridgeException("Cannot start agent server, not valid Security.KeyStore.Password is null "); } } startSecureEventTransmission(hostName, port, keyStore, keyStorePassword, dataBridgeReceiverService); } catch (TransportException e) { throw new DataBridgeException("Cannot start agent server on port " + port, e); } catch (UnknownHostException e) { //ignore since localhost } }
+ " cannot be found in the path : " + path; log.error(errorMessage, e); throw new DataBridgeConfigurationException(errorMessage, e); } catch (XMLStreamException e) { String errorMessage = "Invalid XML for " + fileName + " located in the path : " + path; log.error(errorMessage, e); throw new DataBridgeConfigurationException(errorMessage, e); } finally { try {
public synchronized void loadEventStreams(int tenantId) { try { Collection<StreamDefinition> streams = ServiceHolder.getStreamDefinitionStoreService(). getAllStreamDefinitionsFromStore(tenantId); for (StreamDefinition streamDefinition : streams) { addedEventStream(tenantId, streamDefinition.getName(), streamDefinition.getVersion()); } } catch (StreamDefinitionStoreException e) { log.error("Error while loading the stream definitions from store for tenant " + tenantId + ". " + e.getMessage(), e); } }
public String defineStream(String sessionId, String streamDefinition) throws DifferentStreamDefinitionAlreadyDefinedException, MalformedStreamDefinitionException, SessionTimeoutException { AgentSession agentSession = authenticator.getSession(sessionId); if (agentSession.getCredentials() == null) { if (log.isDebugEnabled()) { log.debug("session " + sessionId + " expired "); } throw new SessionTimeoutException(sessionId + " expired"); } try { authenticatorHandler.initContext(agentSession); String streamId = eventDispatcher.defineStream(streamDefinition, agentSession); if (streamId != null) { for (StreamAddRemoveListener streamAddRemoveListener : streamAddRemoveListenerList) { streamAddRemoveListener.streamAdded(streamId); } } return streamId; } catch (MalformedStreamDefinitionException e) { throw new MalformedStreamDefinitionException(e.getErrorMessage(), e); } catch (DifferentStreamDefinitionAlreadyDefinedException e) { throw new DifferentStreamDefinitionAlreadyDefinedException(e.getErrorMessage(), e); } catch (StreamDefinitionStoreException e) { throw new MalformedStreamDefinitionException(e.getErrorMessage(), e); } finally { authenticatorHandler.destroyContext(agentSession); } }
public List<Event> toEventList(Object eventBundle, StreamTypeHolder streamTypeHolder) { if (eventBundle instanceof ThriftEventBundle) { return createEventList((ThriftEventBundle) eventBundle, streamTypeHolder); } else { throw new EventConversionException("Wrong type of event received " + eventBundle.getClass()); } }
private void startSecureEventTransmission(String hostName, int port, String sslProtocols, String ciphers, DataBridgeReceiverService dataBridgeReceiverService) throws DataBridgeException { try { String keyStore = dataBridgeReceiverService.getInitialConfig().getKeyStoreLocation(); if (keyStore == null) { keyStore = System.getProperty("Security.KeyStore.Location"); if (keyStore == null) { throw new DataBridgeException("Cannot start thrift agent server, not valid " + "Security.KeyStore.Location is null"); } } String keyStorePassword = dataBridgeReceiverService.getInitialConfig().getKeyStorePassword(); if (keyStorePassword == null) { keyStorePassword = System.getProperty("Security.KeyStore.Password"); if (keyStorePassword == null) { throw new DataBridgeException("Cannot start thrift agent server, not valid" + " Security.KeyStore.Password is null "); } } startSecureEventTransmission(hostName, port, sslProtocols, ciphers, keyStore, keyStorePassword, dataBridgeReceiverService); } catch (TransportException e) { throw new DataBridgeException("Cannot start agent server on port " + port, e); } catch (UnknownHostException e) { //ignore since localhost } }
public synchronized void unLoadEventStreams(int tenantId) { try { Collection<StreamDefinition> streams = ServiceHolder.getStreamDefinitionStoreService(). getAllStreamDefinitionsFromStore(tenantId); for (StreamDefinition streamDefinition : streams) { removedEventStream(tenantId, streamDefinition.getName(), streamDefinition.getVersion()); } } catch (StreamDefinitionStoreException e) { log.error("Error while loading the stream definitions from store for tenant " + tenantId + ". " + e.getMessage(), e); } } }
public String defineStream(String sessionId, String streamDefinition, String indexDefinition) throws DifferentStreamDefinitionAlreadyDefinedException, MalformedStreamDefinitionException, SessionTimeoutException { AgentSession agentSession = authenticator.getSession(sessionId); if (agentSession.getCredentials() == null) { if (log.isDebugEnabled()) { log.debug("session " + sessionId + " expired "); } throw new SessionTimeoutException(sessionId + " expired"); } try { authenticatorHandler.initContext(agentSession); String streamId = eventDispatcher.defineStream(streamDefinition, agentSession, indexDefinition); if (streamId != null) { for (StreamAddRemoveListener streamAddRemoveListener : streamAddRemoveListenerList) { streamAddRemoveListener.streamAdded(streamId); } } return streamId; } catch (MalformedStreamDefinitionException e) { throw new MalformedStreamDefinitionException(e.getErrorMessage(), e); } catch (DifferentStreamDefinitionAlreadyDefinedException e) { throw new DifferentStreamDefinitionAlreadyDefinedException(e.getErrorMessage(), e); } catch (StreamDefinitionStoreException e) { throw new MalformedStreamDefinitionException(e.getErrorMessage(), e); } finally { authenticatorHandler.destroyContext(agentSession); } }
public static List<String[]> loadStreamDefinitionXML() throws DataBridgeConfigurationException { List<String[]> streamDefinitionList = new ArrayList<String[]>(); String carbonHome = System.getProperty(ServerConstants.CARBON_CONFIG_DIR_PATH); String path = carbonHome + File.separator + DataBridgeConstants.DATA_BRIDGE_DIR + File.separator + DataBridgeConstants.STREAM_DEFINITIONS_XML; File file = new File(path); if (file.exists() && !file.isDirectory()) { OMElement config = loadXML(path, DataBridgeConstants.STREAM_DEFINITIONS_XML); if (config != null) { if (!(new QName(DataBridgeConstants.DATA_BRIDGE_NAMESPACE, DataBridgeConstants.STREAM_DEFINITIONS_ELEMENT)).equals(config.getQName())) { throw new DataBridgeConfigurationException("Wrong configuration added in " + DataBridgeConstants.STREAM_DEFINITIONS_XML); } for (Iterator streamDefinitionIterator = config.getChildElements(); streamDefinitionIterator.hasNext(); ) { OMElement streamDefinition = (OMElement) streamDefinitionIterator.next(); String domainName = streamDefinition.getAttributeValue(new QName(DataBridgeConstants.DOMAIN_NAME_ATTRIBUTE)); if (domainName == null || domainName.equals("")) { domainName = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME; } streamDefinitionList.add(new String[]{domainName, streamDefinition.getText()}); } } } return streamDefinitionList; }
public List<Event> toEventList(Object eventBundle, StreamTypeHolder streamTypeHolder) { if (eventBundle instanceof ThriftEventBundle) { return createEventList((ThriftEventBundle) eventBundle, streamTypeHolder); } else { throw new EventConversionException("Wrong type of event received " + eventBundle.getClass()); } }
throw new DataBridgeException("Cannot start thrift agent server, not valid " + "Security.KeyStore.Location is null"); keyStorePassword = System.getProperty("Security.KeyStore.Password"); if (keyStorePassword == null) { throw new DataBridgeException("Cannot start thrift agent server, not valid" + " Security.KeyStore.Password is null "); throw new DataBridgeException("Cannot start agent server on port " + port, e); } catch (UnknownHostException e) {
@Override public int getNumberOfEvents(Object eventBundle) { if (eventBundle instanceof ThriftEventBundle) { return ((ThriftEventBundle) eventBundle).getEventNum(); } else { throw new EventConversionException("Wrong type event relieved " + eventBundle.getClass()); } }
protected void startEventTransmission(String hostName, int port, DataBridgeReceiverService dataBridgeReceiverService) throws DataBridgeException { try { TServerSocket serverTransport = new TServerSocket( new InetSocketAddress(hostName, port)); ThriftEventTransmissionService.Processor<ThriftEventTransmissionServiceImpl> processor = new ThriftEventTransmissionService.Processor<ThriftEventTransmissionServiceImpl>( new ThriftEventTransmissionServiceImpl(dataBridgeReceiverService)); dataReceiverServer = new TThreadPoolServer( new TThreadPoolServer.Args(serverTransport).processor(processor)); Thread thread = new Thread(new ServerThread(dataReceiverServer)); log.info("Thrift port : " + port); thread.start(); } catch (TTransportException e) { throw new DataBridgeException("Cannot start Thrift server on port " + port + " on host " + hostName, e); } }
@Override public int getNumberOfEvents(Object eventBundle) { if (eventBundle instanceof ThriftEventBundle) { return ((ThriftEventBundle) eventBundle).getEventNum(); } else { throw new EventConversionException("Wrong type event relieved " + eventBundle.getClass()); } }
protected void startEventTransmission(String hostName, int port, DataBridgeReceiverService dataBridgeReceiverService) throws DataBridgeException { try { TServerSocket serverTransport = new TServerSocket( new InetSocketAddress(hostName, port)); ThriftEventTransmissionService.Processor<ThriftEventTransmissionServiceImpl> processor = new ThriftEventTransmissionService.Processor<ThriftEventTransmissionServiceImpl>( new ThriftEventTransmissionServiceImpl(dataBridgeReceiverService)); dataReceiverServer = new TThreadPoolServer( new TThreadPoolServer.Args(serverTransport).processor(processor)); Thread thread = new Thread(new ServerThread(dataReceiverServer)); log.info("Thrift port : " + port); thread.start(); } catch (TTransportException e) { throw new DataBridgeException("Cannot start Thrift server on port " + port + " on host " + hostName, e); } }
return eventBundleSize; } else { throw new EventConversionException("Wrong type of event received " + eventBundle.getClass());
return eventBundleSize; } else { throw new EventConversionException("Wrong type of event received " + eventBundle.getClass());
attributeTypeOrder = streamTypeHolder.getDataType(streamId); if (attributeTypeOrder == null) { throw new EventConversionException("No StreamDefinition for streamId " + streamId + " present in cache "); throw new EventConversionException("Error when converting " + streamId + " of event bundle with events " + thriftEventBundle.getEventNum(), re);
public Event getEvent(ByteBuffer byteBuffer, StreamTypeHolder streamTypeHolder) throws MalformedEventException { long timeStamp = byteBuffer.getLong(); int streamIdSize = byteBuffer.getInt(); String streamId = BinaryMessageConverterUtil.getString(byteBuffer, streamIdSize); Event event = new Event(); event.setStreamId(streamId); event.setTimeStamp(timeStamp); AttributeType[][] attributeTypeOrder = streamTypeHolder.getDataType(event.getStreamId()); if (attributeTypeOrder == null) { streamTypeHolder.reloadStreamTypeHolder(); attributeTypeOrder = streamTypeHolder.getDataType(event.getStreamId()); if (attributeTypeOrder == null) { throw new EventConversionException("No StreamDefinition for streamId " + event.getStreamId() + " present in cache "); } } event.setMetaData(this.toObjectArray(byteBuffer, attributeTypeOrder[0], BinaryDataReceiverConstants.META_DATA_FIELD)); event.setCorrelationData(this.toObjectArray(byteBuffer, attributeTypeOrder[1], BinaryDataReceiverConstants.CORRELATION_DATA_FIELD)); event.setPayloadData(this.toObjectArray(byteBuffer, attributeTypeOrder[2], BinaryDataReceiverConstants.PAYLOAD_DATA_FIELD)); event.setArbitraryDataMap(this.toStringMap(byteBuffer)); return event; }