org.wso2.carbon.databridge.agent.thrift
Class AsyncDataPublisher

java.lang.Object
  extended by org.wso2.carbon.databridge.agent.thrift.AsyncDataPublisher

public class AsyncDataPublisher
extends Object

AsyncDataPublisher creates the connection to with receiver asynchronously and will queue all the events


Constructor Summary
AsyncDataPublisher(DataPublisher dataPublisher)
          To create the Data Publisher and creates the connection asynchronously
AsyncDataPublisher(String receiverURL, String username, String password)
          To create the Data Publisher and creates the connection asynchronously
AsyncDataPublisher(String receiverURL, String username, String password, Agent agent)
          To create the Data Publisher and creates the connection asynchronously
AsyncDataPublisher(String authenticationURL, String receiverURL, String username, String password)
          To create the Data Publisher and creates the connection asynchronously
AsyncDataPublisher(String authenticationUrl, String receiverUrl, String userName, String password, Agent agent)
          To create the Data Publisher and creates the connection asynchronously
AsyncDataPublisher(String authenticationUrl, String receiverUrl, String userName, String password, Agent agent, ConcurrentHashMap<String,String> streamDefnCache)
          To create the Data Publisher and creates the connection asynchronously
 
Method Summary
 void addStreamDefinition(org.wso2.carbon.databridge.commons.StreamDefinition definition)
          add the stream definition which can be published by the AsyncDataPublisher
 void addStreamDefinition(String streamDefn, String streamName, String version)
          add the stream definition which can be published by the AsyncDataPublisher
 boolean canPublish()
          Evaluates the publisher is ready and established the connection to publish the events
 String findStream(String name, String version)
          Deprecated. 
 String findStreamId(String name, String version)
          Returns the streamId if the already stream name and version is defined in the receiver
 Agent getAgent()
          to get the underlining agent
 LinkedBlockingQueue<PublishData> getQueuedEventsAndReset()
          resets the publishDataQueue and returns all elements
 boolean isStreamDefinitionAdded(org.wso2.carbon.databridge.commons.StreamDefinition streamDefinition)
          Returns a boolean whether the stream definition is already added to cache in async data publisher
 boolean isStreamDefinitionAdded(String streamName, String version)
          Returns a boolean whether the stream definition is already added to cache in async data publisher
 void publish(org.wso2.carbon.databridge.commons.Event event)
          Publish the event asynchronously.
 void publish(String streamName, String streamVersion, org.wso2.carbon.databridge.commons.Event event)
          Publish the event asynchronously.
 void publish(String streamName, String streamVersion, long timeStamp, Object[] metaDataArray, Object[] correlationDataArray, Object[] payloadDataArray)
          Publish the event asynchronously.
 void publish(String streamName, String streamVersion, long timeStamp, Object[] metaDataArray, Object[] correlationDataArray, Object[] payloadDataArray, Map<String,String> arbitraryDataMap)
          Publish the event asynchronously.
 void publish(String streamName, String streamVersion, Object[] metaDataArray, Object[] correlationDataArray, Object[] payloadDataArray)
          Publish the event asynchronously.
 void publish(String streamName, String streamVersion, Object[] metaDataArray, Object[] correlationDataArray, Object[] payloadDataArray, Map<String,String> arbitraryDataMap)
          Publish the event asynchronously.
 void reconnect()
          Establish the connection of data publisher to receiver again
 void registerReceiverObserver(ReceiverStateObserver observer)
           
 void setAgent(Agent agent)
          to set the underlining agent which could be sheared by many data publishers
 void stop()
          Disconnecting from the server
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AsyncDataPublisher

public AsyncDataPublisher(String authenticationURL,
                          String receiverURL,
                          String username,
                          String password)
To create the Data Publisher and creates the connection asynchronously

Parameters:
authenticationURL - the secure authentication url, use ://:
receiverURL - the event receiver url use ://: for normal data transfer and use ://: for secure data transfer
username - user name
password - password

AsyncDataPublisher

public AsyncDataPublisher(String receiverURL,
                          String username,
                          String password)
To create the Data Publisher and creates the connection asynchronously

Parameters:
receiverURL - the event receiver url use ://: for normal data transfer and use ://: for secure data transfer
username - user name
password - password

AsyncDataPublisher

public AsyncDataPublisher(String receiverURL,
                          String username,
                          String password,
                          Agent agent)
To create the Data Publisher and creates the connection asynchronously

Parameters:
receiverURL - the event receiver url use ://: for normal data transfer and use ://: for secure data transfer
username - user name
password - password
agent - the underlining agent

AsyncDataPublisher

public AsyncDataPublisher(String authenticationUrl,
                          String receiverUrl,
                          String userName,
                          String password,
                          Agent agent)
To create the Data Publisher and creates the connection asynchronously

Parameters:
authenticationUrl - the secure authentication url, use ://:
receiverUrl - the event receiver url use ://: for normal data transfer and use ://: for secure data transfer
userName - user name
password - password
agent - the underlining agent

AsyncDataPublisher

public AsyncDataPublisher(String authenticationUrl,
                          String receiverUrl,
                          String userName,
                          String password,
                          Agent agent,
                          ConcurrentHashMap<String,String> streamDefnCache)
To create the Data Publisher and creates the connection asynchronously

Parameters:
authenticationUrl - the secure authentication url, use ://:
receiverUrl - the event receiver url use ://: for normal data transfer and use ://: for secure data transfer
userName - user name
password - password
agent - the underlining agent
streamDefnCache - the common Stream Definition cache used by AsyncDataPublishers

AsyncDataPublisher

public AsyncDataPublisher(DataPublisher dataPublisher)
To create the Data Publisher and creates the connection asynchronously

Parameters:
dataPublisher - DataPublisher used by the Asynchronous client to publish the events
Method Detail

reconnect

public void reconnect()
Establish the connection of data publisher to receiver again


canPublish

public boolean canPublish()
Evaluates the publisher is ready and established the connection to publish the events

Returns:
boolean value about the status of the data publisher's publishing capability

setAgent

public void setAgent(Agent agent)
              throws AgentException,
                     org.wso2.carbon.databridge.commons.exception.AuthenticationException,
                     org.wso2.carbon.databridge.commons.exception.TransportException
to set the underlining agent which could be sheared by many data publishers

Parameters:
agent - the underlining agent
Throws:
AgentException
org.wso2.carbon.databridge.commons.exception.AuthenticationException
org.wso2.carbon.databridge.commons.exception.TransportException

getAgent

public Agent getAgent()
to get the underlining agent

Returns:
agent

registerReceiverObserver

public void registerReceiverObserver(ReceiverStateObserver observer)

publish

public void publish(String streamName,
                    String streamVersion,
                    long timeStamp,
                    Object[] metaDataArray,
                    Object[] correlationDataArray,
                    Object[] payloadDataArray)
             throws AgentException
Publish the event asynchronously.

If the data publisher hasn't been initialized properly, the events will be pushed in the queue If the stream id is not in the cache the event will be pushed in the queue else the stream id from the cache will be used to publish the event

Parameters:
streamName - Name of the stream which the events is for
streamVersion - Version of the stream which the events is for
timeStamp - Timestamp of the event
metaDataArray - metadata array of the event
correlationDataArray - correlation array of the event
payloadDataArray - payload array of the event
Throws:
AgentException

publish

public void publish(String streamName,
                    String streamVersion,
                    long timeStamp,
                    Object[] metaDataArray,
                    Object[] correlationDataArray,
                    Object[] payloadDataArray,
                    Map<String,String> arbitraryDataMap)
             throws AgentException
Publish the event asynchronously.

If the data publisher hasn't been initialized properly, the events will be pushed in the queue If the stream id is not in the cache the event will be pushed in the queue else the stream id from the cache will be used to publish the event

Parameters:
streamName - Name of the stream which the events is for
streamVersion - Version of the stream which the events is for
timeStamp - Timestamp of the event
metaDataArray - metadata array of the event
correlationDataArray - correlation array of the event
payloadDataArray - payload array of the event
arbitraryDataMap - arbitrary mata (as meta.),correlation (as correlation.) & payload (as ) data as key-value pairs
Throws:
AgentException

publish

public void publish(String streamName,
                    String streamVersion,
                    Object[] metaDataArray,
                    Object[] correlationDataArray,
                    Object[] payloadDataArray)
             throws AgentException
Publish the event asynchronously.

If the data publisher hasn't been initialized properly, the events will be pushed in the queue If the stream generatorsid is not in the cache the event will be pushed in the queue else the stream id from the cache will be used to publish the event

Parameters:
streamName - Name of the stream which the events is for
streamVersion - Version of the stream which the events is for
metaDataArray - metadata array of the event
correlationDataArray - correlation array of the event
payloadDataArray - payload array of the event
Throws:
AgentException

publish

public void publish(String streamName,
                    String streamVersion,
                    Object[] metaDataArray,
                    Object[] correlationDataArray,
                    Object[] payloadDataArray,
                    Map<String,String> arbitraryDataMap)
             throws AgentException
Publish the event asynchronously.

If the data publisher hasn't been initialized properly, the events will be pushed in the queue If the stream generatorsid is not in the cache the event will be pushed in the queue else the stream id from the cache will be used to publish the event

Parameters:
streamName - Name of the stream which the events is for
streamVersion - Version of the stream which the events is for
metaDataArray - metadata array of the event
correlationDataArray - correlation array of the event
payloadDataArray - payload array of the event
Throws:
AgentException

publish

public void publish(String streamName,
                    String streamVersion,
                    org.wso2.carbon.databridge.commons.Event event)
             throws AgentException
Publish the event asynchronously.

If the data publisher hasn't been initialized properly, the events will be pushed in the queue If the stream id is not in the cache the event will be pushed in the queue else the stream id from the cache will be used to publish the event

Parameters:
streamName - Name of the stream which the events is for
streamVersion - Version of the stream which the events is for
event - Event which should be published
Throws:
AgentException

publish

public void publish(org.wso2.carbon.databridge.commons.Event event)
             throws AgentException
Publish the event asynchronously.

If the data publisher hasn't been initialized properly, the events will be pushed in the queue If the stream id is not in the cache the event will be pushed in the queue else the stream id from the cache will be used to publish the event

Parameters:
event - Event which should be published
Throws:
AgentException

getQueuedEventsAndReset

public LinkedBlockingQueue<PublishData> getQueuedEventsAndReset()
resets the publishDataQueue and returns all elements

Returns:
all elements of queue

addStreamDefinition

public void addStreamDefinition(String streamDefn,
                                String streamName,
                                String version)
add the stream definition which can be published by the AsyncDataPublisher

Parameters:
streamDefn - json string format of the stream definition
streamName - Name of stream which should be added
version - Version of stream which should be added

addStreamDefinition

public void addStreamDefinition(org.wso2.carbon.databridge.commons.StreamDefinition definition)
add the stream definition which can be published by the AsyncDataPublisher

Parameters:
definition - Stream definition object which should be added

isStreamDefinitionAdded

public boolean isStreamDefinitionAdded(String streamName,
                                       String version)
Returns a boolean whether the stream definition is already added to cache in async data publisher

Parameters:
streamName - Name of the stream needed to check
version - version of the stream needed to check
Returns:
whether the stream definition is exists or not

isStreamDefinitionAdded

public boolean isStreamDefinitionAdded(org.wso2.carbon.databridge.commons.StreamDefinition streamDefinition)
Returns a boolean whether the stream definition is already added to cache in async data publisher

Parameters:
streamDefinition - Object of the stream definition needed to check in the cache
Returns:
whether the stream definition is exists or not

findStream

@Deprecated
public String findStream(String name,
                                    String version)
                  throws AgentException,
                         org.wso2.carbon.databridge.commons.exception.StreamDefinitionException,
                         org.wso2.carbon.databridge.commons.exception.NoStreamDefinitionExistException
Deprecated. 

Returns the streamId if the already stream name and version is defined in the receiver

Parameters:
name - Name of the event stream
version - Version of the stream
Returns:
Throws:
AgentException
org.wso2.carbon.databridge.commons.exception.StreamDefinitionException
org.wso2.carbon.databridge.commons.exception.NoStreamDefinitionExistException

findStreamId

public String findStreamId(String name,
                           String version)
                    throws AgentException
Returns the streamId if the already stream name and version is defined in the receiver

Parameters:
name - Name of the event stream
version - Version of the stream
Returns:
Throws:
AgentException

stop

public void stop()
Disconnecting from the server



Copyright © 2015 WSO2. All rights reserved.