本文整理了Java中org.wso2.carbon.databridge.commons.Event
类的一些代码示例,展示了Event
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Event
类的具体详情如下:
包路径:org.wso2.carbon.databridge.commons.Event
类名称:Event
[英]WSO2 Event Implementation.
[中]WSO2事件实现。
代码示例来源:origin: org.wso2.carbon.business-process/org.wso2.carbon.bpel.bam.publisher
private Event createEvent(String streamId, BAMStreamConfiguration stream,
ExtensionContext context, Element element)
throws FaultException {
Event e = new Event();
e.setStreamId(streamId);
e.setTimeStamp(System.currentTimeMillis());
e.setCorrelationData(createCorrelationData(stream, context, element));
e.setMetaData(createMetadata(stream, context, element));
e.setPayloadData(createPayloadData(stream, context, element));
return e;
}
代码示例来源:origin: org.wso2.carbon.analytics-common/org.wso2.carbon.databridge.commons
public static int getSize(Event event) {
int size = event.getStreamId().getBytes().length;
size += 8; // for timestamp.
if (event.getPayloadData() != null) {
size += getSize(event.getPayloadData());
}
if (event.getMetaData() != null) {
size += getSize(event.getMetaData());
}
if (event.getCorrelationData() != null) {
size += getSize(event.getCorrelationData());
}
if (event.getArbitraryDataMap() != null) {
size += getSize(event.getArbitraryDataMap());
}
return size;
}
代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.analytics.datasink
private void updateEvent(Event oldEvent, Event newEvent) {
oldEvent.setArbitraryDataMap(newEvent.getArbitraryDataMap());
oldEvent.setCorrelationData(newEvent.getCorrelationData());
oldEvent.setMetaData(newEvent.getMetaData());
oldEvent.setPayloadData(newEvent.getPayloadData());
oldEvent.setStreamId(newEvent.getStreamId());
oldEvent.setTimeStamp(newEvent.getTimeStamp());
}
}
代码示例来源:origin: org.wso2.carbon.commons/org.wso2.carbon.databridge.agent.thrift
public PublishData(String streamName,
String streamVersion,
long timeStamp,
Object[] metaDataArray,
Object[] correlationDataArray,
Object[] payloadDataArray, Map<String, String> arbitraryDataMap) {
this.streamName = streamName;
this.streamVersion = streamVersion;
this.event = new Event(null, timeStamp, metaDataArray,
correlationDataArray, payloadDataArray, arbitraryDataMap);
}
代码示例来源:origin: org.apache.stratos/org.apache.stratos.cartridge.agent
public void publish(DataContext dataContext) {
Event event = new Event();
event.setTimeStamp(new Date().getTime());
event.setMetaData(dataContext.getMetaData());
event.setPayloadData(dataContext.getPayloadData());
try {
dataPublisher.publish(streamDefinition.getName(), streamDefinition.getVersion(), event);
} catch (AgentException e) {
String errorMsg = "Error in publishing event";
log.error(errorMsg, e);
// no need to throw here
}
}
代码示例来源:origin: org.wso2.carbon.analytics-common/org.wso2.carbon.databridge.commons
JSONArray eventObjects = new JSONArray(json);
for (int i = 0; i < eventObjects.length(); i++) {
Event event = new Event();
JsonElement jsonElement = jsonParser.parse(eventObjects.get(i).toString());
pos++;
event.setData(key, list.toArray());
event.setStreamId(streamId);
eventList.add(event);
代码示例来源:origin: org.wso2.das/org.wso2.das.integration.common.clients
public void publish(String streamName, String version, List<Event> events) throws DataEndpointException {
String streamId = DataBridgeCommonsUtils.generateStreamId(streamName, version);
for (Event event : events) {
event.setStreamId(streamId);
dataPublisher.publish(event);
}
}
for (String publishingDomain : publishingDomains) {
Object[] metadataArray = AuditDataPublisherUtils.getMetaDataArray(publishingDomain);
org.wso2.carbon.databridge.commons.Event event = new org.wso2.carbon.databridge.commons.Event
(AuditDataPublisherConstants.OVERALL_USER_DATA_EVENT_STREAM_NAME, System
.currentTimeMillis(), metadataArray, null, payloadData);
UserOperationDataPublisherDataHolder.getInstance().getPublisherService().publish(event);
if (log.isDebugEnabled()) {
log.debug("Sending out event : " + event.toString());
代码示例来源:origin: org.wso2.carbon.commons/org.wso2.carbon.databridge.agent.thrift
streamId = streamIdCache.get(streamIdKey);
} else {
streamId = data.getEvent().getStreamId();
data.getEvent().setStreamId(streamId);
dataPublisher.publish(data.getEvent());
} else {
data.getEvent().setStreamId(streamId);
try {
dataPublisher.publish(data.getEvent());
代码示例来源:origin: org.wso2.am/org.wso2.am.integration.common.test.utils
/**
* 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);
}
});
代码示例来源:origin: org.wso2.carbon.analytics-common/org.wso2.carbon.databridge.commons
public static List<Event> convertFromJson(String json) {
List<Event> eventList = new ArrayList<Event>();
try {
JSONArray eventObjects = new JSONArray(json);
for (int i = 0; i < eventObjects.length(); i++) {
Event event = gson.fromJson(eventObjects.get(i).toString(), Event.class);
if (event.getStreamId() == null || event.getStreamId().equals("")) {
String errorMsg = "Stream Id cannot be null or empty, for JSON : " + eventObjects.get(i).toString();
MalformedEventException malformedEventException = new MalformedEventException();
if (log.isDebugEnabled()) {
log.error(errorMsg, malformedEventException);
} else {
log.error(errorMsg);
}
throw malformedEventException;
}
eventList.add(event);
}
} catch (JSONException e) {
String errorMsg = "Error converting JSON to event, for JSON : " + json;
MalformedEventException malformedEventException = new MalformedEventException(errorMsg, e);
if (log.isDebugEnabled()) {
log.error(errorMsg, malformedEventException);
} else {
log.error(errorMsg);
}
throw malformedEventException;
}
return eventList;
}
代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.analytics.datasink
public Event newInstance() {
return new Event();
}
};
代码示例来源:origin: org.wso2.carbon.commons/org.wso2.carbon.databridge.commons
JSONArray eventObjects = new JSONArray(json);
for (int i = 0; i < eventObjects.length(); i++) {
Event event = new Event();
JsonElement jsonElement = jsonParser.parse(eventObjects.get(i).toString());
pos++;
event.setData(key, list.toArray());
event.setStreamId(streamId);
eventList.add(event);
代码示例来源:origin: org.wso2.analytics.apim/org.wso2.analytics.apim.integration.common.clients
public void publish(String streamName, String version, Event event) throws DataEndpointException {
String streamId = DataBridgeCommonsUtils.generateStreamId(streamName, version);
event.setStreamId(streamId);
dataPublisher.publish(event);
}
}
代码示例来源:origin: org.wso2.carbon.commons/org.wso2.carbon.databridge.commons
public static List<Event> convertFromJson(String json) {
List<Event> eventList = new ArrayList<Event>();
try {
JSONArray eventObjects = new JSONArray(json);
for (int i = 0; i < eventObjects.length(); i++) {
Event event = gson.fromJson(eventObjects.get(i).toString(), Event.class);
if (event.getStreamId() == null || event.getStreamId().equals("")) {
String errorMsg = "Stream Id cannot be null or empty, for JSON : " + eventObjects.get(i).toString();
MalformedEventException malformedEventException = new MalformedEventException();
if (log.isDebugEnabled()) {
log.error(errorMsg, malformedEventException);
} else {
log.error(errorMsg);
}
throw malformedEventException;
}
eventList.add(event);
}
} catch (JSONException e) {
String errorMsg = "Error converting JSON to event, for JSON : " + json;
MalformedEventException malformedEventException = new MalformedEventException(errorMsg, e);
if (log.isDebugEnabled()) {
log.error(errorMsg, malformedEventException);
} else {
log.error(errorMsg);
}
throw malformedEventException;
}
return eventList;
}
代码示例来源:origin: org.wso2.extension.siddhi.map.wso2event/siddhi-map-wso2event
org.wso2.carbon.databridge.commons.Event wso2event = new org.wso2.carbon.databridge.commons.Event();
wso2event.setTimeStamp(event.getTimestamp());
wso2event.setStreamId(this.outputStreamId);
Object[] eventData = event.getData();
if (eventData.length > 0) {
metaArray[i] = eventData[this.metaDataPositions[i]];
wso2event.setMetaData(metaArray);
correlationArray[i] = eventData[this.correlationDataPositions[i]];
wso2event.setCorrelationData(correlationArray);
payloadArray[i] = eventData[this.payloadDataPositions[i]];
wso2event.setPayloadData(payloadArray);
);
wso2event.setArbitraryDataMap(arbitraryDataMap);
代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.databridge.agent
private static int getEventSize(Event event) {
int eventSize = 4 + event.getStreamId().length() + 8;
Object[] data = event.getMetaData();
if (data != null) {
for (Object aData : data) {
eventSize += getSize(aData);
}
}
data = event.getCorrelationData();
if (data != null) {
for (Object aData : data) {
eventSize += getSize(aData);
}
}
data = event.getPayloadData();
if (data != null) {
for (Object aData : data) {
eventSize += getSize(aData);
}
}
if (event.getArbitraryDataMap() != null && event.getArbitraryDataMap().size() != 0) {
for (Map.Entry<String, String> aArbitraryData : event.getArbitraryDataMap().entrySet()) {
eventSize += 8 + aArbitraryData.getKey().length() + aArbitraryData.getValue().length();
}
}
return eventSize;
}
代码示例来源:origin: org.wso2.carbon.commons/org.wso2.carbon.databridge.agent.thrift
public PublishData(String streamName,
String streamVersion,
Object[] metaDataArray,
Object[] correlationDataArray,
Object[] payloadDataArray, Map<String, String> arbitraryDataMap) {
this.streamName = streamName;
this.streamVersion = streamVersion;
this.event = new Event(null, System.currentTimeMillis(),
metaDataArray, correlationDataArray, payloadDataArray, arbitraryDataMap);
}
代码示例来源:origin: org.wso2.analytics.apim/org.wso2.analytics.apim.integration.common.clients
public void publish(String streamName, String version, List<Event> events) throws DataEndpointException {
String streamId = DataBridgeCommonsUtils.generateStreamId(streamName, version);
for (Event event : events) {
event.setStreamId(streamId);
dataPublisher.publish(event);
}
}
代码示例来源:origin: org.wso2.carbon.analytics-common/org.wso2.carbon.databridge.receiver.binary
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;
}
内容来源于网络,如有侵权,请联系作者删除!