use of org.wso2.carbon.databridge.commons.StreamDefinition in project carbon-apimgt by wso2.
the class DASThriftTestServer method addStreamDefinition.
public void addStreamDefinition(String streamDefinitionStr) throws StreamDefinitionStoreException, MalformedStreamDefinitionException {
StreamDefinition streamDefinition = EventDefinitionConverterUtils.convertFromJson(streamDefinitionStr);
getStreamDefinitionStore().saveStreamDefinitionToStore(streamDefinition);
}
use of org.wso2.carbon.databridge.commons.StreamDefinition in project carbon-apimgt by wso2.
the class DASThriftTestServer method start.
public void start(int receiverPort) throws DataBridgeException {
DataPublisherTestUtil.setKeyStoreParams();
streamDefinitionStore = getStreamDefinitionStore();
numberOfEventsReceived = new AtomicInteger(0);
DataBridge databridge = new DataBridge(new AuthenticationHandler() {
public boolean authenticate(String userName, String password) {
// allays authenticate to true
return true;
}
public void initContext(AgentSession agentSession) {
// To change body of implemented methods use File | Settings |
// File Templates.
}
public void destroyContext(AgentSession agentSession) {
}
}, streamDefinitionStore, DataPublisherTestUtil.getDataBridgeConfigPath());
thriftDataReceiver = new ThriftDataReceiver(receiverPort, databridge);
databridge.subscribe(new AgentCallback() {
int totalSize = 0;
@Override
public void definedStream(StreamDefinition streamDefinition) {
log.info("StreamDefinition " + streamDefinition);
}
@Override
public void removeStream(StreamDefinition streamDefinition) {
log.info("StreamDefinition remove " + streamDefinition);
}
/**
* Retrving and handling all the events to DAS event receiver
* @param eventList list of event it received
* @param credentials client credentials
*/
public void receive(List<Event> eventList, Credentials credentials) {
for (Event event : eventList) {
String streamKey = event.getStreamId();
if (!dataTables.containsKey(streamKey)) {
dataTables.put(streamKey, new ArrayList<Event>());
}
dataTables.get(streamKey).add(event);
log.info("=== " + event.toString());
}
numberOfEventsReceived.addAndGet(eventList.size());
log.info("Received events : " + numberOfEventsReceived);
}
});
String address = "localhost";
log.info("DAS Test Thrift Server starting on " + address);
thriftDataReceiver.start(address);
log.info("DAS Test Thrift Server Started");
}
Aggregations