@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public void update(EventBean[] newEvents, EventBean[] oldEvents) { if (newEvents != null && newEvents.length > 0) { Map<String, Object> eventMap = getEventMap(newEvents[0]); if (eventMap != null) { for (Map.Entry<String, Object> e : eventMap.entrySet()) { if (e.getValue() != null) { if (e.getValue() instanceof Map) { event.putAll((Map)e.getValue()); } else { event.put(e.getKey(), e.getValue()); } } } } } } }
@Override public void remoteSessionExpired(String uid, String ak, byte[] payload, byte[] metadata) { JetstreamEvent jsEvent = new JetstreamEvent(); int type = identifierType(uid); jsEvent.setEventType(Constants.EVENT_TYPE_SESSION_EXPIRED_EVENT); jsEvent.put(Constants.EVENT_PAYLOAD_SESSION_UNIQUEID, uid); jsEvent.put(Constants.EVENT_PAYLOAD_SESSION_TYPE, Integer.valueOf(type)); jsEvent.put(AFFINITY_KEY, ak); jsEvent.put(Constants.EVENT_PAYLOAD_SESSION_PAYLOAD, payload); jsEvent.put(Constants.EVENT_PAYLOAD_SESSION_METADATA, metadata); int queueIndex = getQueueIndex(ak); try { responseQueues[queueIndex].put(jsEvent); } catch (InterruptedException e) { responseQueueFullCounter.incrementAndGet(); } }
public void forwardSessionEndEvent(String identifier, Session session, String uid) { JetstreamEvent jsEvent = createEvent(session, Constants.EVENT_TYPE_SESSION_TRANSFERED_EVENT); jsEvent.put(Constants.EVENT_PAYLOAD_SESSION_UNIQUEID, uid); jsEvent.put(Constants.EVENT_PAYLOAD_SESSION_TYPE, Integer.valueOf(session.getType())); totalOwnershipChangedSessionCounter.incrementAndGet(); jsEvent.put(AFFINITY_KEY, session.getAffinityKey()); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Transfer event: {}", jsEvent); } super.fireSendEvent(jsEvent); }
private void sessionBegin(Session session) { JetstreamEvent sessionBeginEvent = new JetstreamEvent(); sessionBeginEvent.setEventType(mainSessionProfile.getBeginMarker()); Map<String, Object> initialAttributes = session.getInitialAttributes(); if (initialAttributes != null) { sessionBeginEvent.putAll(initialAttributes); } if (mainSessionProfile.getSessionIdKey() != null) { sessionBeginEvent.put(mainSessionProfile.getSessionIdKey(), session.getSessionId()); } if (mainSessionProfile.getSessionStartTimestampKey() != null) { sessionBeginEvent.put(mainSessionProfile.getSessionStartTimestampKey(), session.getCreationTime()); } if (mainEsperSessionizer != null && mainEsperSessionizer.isEventSupported(sessionBeginEvent)) { mainEsperSessionizer.process(session, sessionBeginEvent); } eventSender.sendSessionBeginEvent(mainSessionProfile.getSessionType(), session, sessionBeginEvent); }
@Override public void sendExpirationCheckEvent(String uid, String ak) { JetstreamEvent jsEvent = new JetstreamEvent(); int type = identifierType(uid); jsEvent.setEventType(Constants.EVENT_TYPE_SESSION_EXPIRED_EVENT); jsEvent.put(Constants.EVENT_PAYLOAD_SESSION_UNIQUEID, uid); jsEvent.put(Constants.EVENT_PAYLOAD_SESSION_TYPE, Integer.valueOf(type)); jsEvent.put(AFFINITY_KEY, ak); this.loopbackEventProducer.sendExpirationCheckEvent(jsEvent); }
sessionEndEvent.put(mainSessionProfile.getSessionIdKey(), session.getSessionId()); sessionEndEvent.put(mainSessionProfile.getSessionStartTimestampKey(), session.getCreationTime()); sessionEndEvent.put(mainSessionProfile.getSessionEndTimestampKey(), session.getLastModifiedTime()); sessionEndEvent.put(mainSessionProfile.getSessionDurationKey(), session.getDuration()); sessionEndEvent.put(mainSessionProfile.getSessionEventCountKey(), session.getEventCount());
@SuppressWarnings({ "unchecked" }) @Override public void update(EventBean[] newEvents, EventBean[] oldEvents) { if (newEvents != null && newEvents.length > 0) { Map<String, Object> eventMap = getEventMap(newEvents[0]); if (eventMap != null) { JetstreamEvent event = context.getEvent(); for (Map.Entry<String, Object> e : eventMap.entrySet()) { if (e.getValue() != null) { if (e.getValue() instanceof Map) { for (Map.Entry<String, Object> nestede : ((Map<String, Object>)e.getValue()).entrySet()) { if (nestede.getValue() != null) { event.put(nestede.getKey(), normailizeValue(nestede.getValue())); } } } else if (e.getValue() != null) { event.put(e.getKey(), normailizeValue(e.getValue())); } } } } } } }
sessionEndEvent.put(profile.getSessionIdKey(), subSession.getSessionId()); sessionEndEvent.put(mainSessionProfile.getSessionStartTimestampKey(), subSession.getCreationTime()); sessionEndEvent.put(mainSessionProfile.getSessionEndTimestampKey(), subSession.getLastModifiedTime()); sessionEndEvent.put(mainSessionProfile.getSessionDurationKey(), subSession.getDuration()); sessionEndEvent.put(mainSessionProfile.getSessionEventCountKey(), subSession.getEventCount());
private JetstreamEvent createEvent(Session session, String type) { JetstreamEvent jsEvent = new JetstreamEvent(); jsEvent.setEventType(type); jsEvent.put(Constants.EVENT_PAYLOAD_SESSION_PAYLOAD, BinaryFormatSerializer.getInstance().getSessionPayload(session).array()); jsEvent.put(Constants.EVENT_PAYLOAD_SESSION_METADATA, BinaryFormatSerializer.getInstance().getSessionMetadata(session).array()); return jsEvent; }
@Override public void remoteSessionLoaded(String uid, Session session, String ak) { JetstreamEvent event = new JetstreamEvent(); event.setEventType(Constants.EVENT_TYPE_SESSION_LOAD_EVENT); int type = identifierType(uid); event.put(Constants.EVENT_PAYLOAD_SESSION_UNIQUEID, uid); event.put(Constants.EVENT_PAYLOAD_SESSION_OBJ, session); event.put(Constants.EVENT_PAYLOAD_SESSION_TYPE, Integer.valueOf(type)); if (session != null) { session.setType(type); session.setIdentifier(identifierValue(uid)); } int queueIndex = getQueueIndex(ak); try { responseQueues[queueIndex].put(event); } catch (InterruptedException e) { responseQueueFullCounter.incrementAndGet(); } }
@Override public void onStatus(Status status) { HashtagEntity[] hashtagEntities = status.getHashtagEntities(); JetstreamEvent event = new JetstreamEvent(); event.setEventType("TwitterSample"); Place place = status.getPlace(); if (place != null) { event.put("country", place.getCountry()); } event.put("ct", status.getCreatedAt().getTime()); event.put("text", status.getText()); event.put("lang", status.getLang()); event.put("user", status.getUser().getName()); if (hashtagEntities != null && hashtagEntities.length > 0) { StringBuilder s = new StringBuilder(); s.append(hashtagEntities[0].getText()); for (int i = 1; i < hashtagEntities.length; i++) { s.append(","); s.append(hashtagEntities[i].getText()); } event.put("hashtag", s.toString()); } fireSendEvent(event); }
private void processEPL(JetstreamEvent event) { Object sesionizerList = event.remove(SessionizerProcessor.SESSIONIZER_LIST); try { esperService.getEPRuntime().sendEvent(event, event.getEventType()); } finally { if (sesionizerList != null) { event.put(SessionizerProcessor.SESSIONIZER_LIST, sesionizerList); } } }
} else if (m.size() == 1) { Entry<String, SessionizationInfo> entry = m.entrySet().iterator().next(); event.put(CURRENT_SESSIOIZERINFO, entry.getValue()); processSessionizableEvent(event, sessionizerMap.get(entry.getKey()), entry.getValue()); } else { LinkedList<SessionizationInfo> slist = new LinkedList<SessionizationInfo>(m.values()); event.put(SESSIONIZER_LIST, slist); SessionizationInfo sessionizationInfo = slist.removeFirst(); event.put(CURRENT_SESSIOIZERINFO, sessionizationInfo); processSessionizableEvent(event, sessionizerMap.get(sessionizationInfo.getName()), sessionizationInfo);
private void execute(BoundStatement q, JetstreamEvent event) { try { ResultSetFuture future = cassandraSession.executeAsync(q); CallBackListener listener = new CallBackListener(future, event); future.addListener(listener, pool); pendingRequestCounter.incrementAndGet(); } catch (Throwable ex) { LOGGER.error( "Error publising metrics in MetricCassandraCollector:" + ex.getMessage()); cassandraErrorCount.increment(); if (event.get(JetstreamReservedKeys.MessageAffinityKey.toString()) == null) { event.put(JetstreamReservedKeys.MessageAffinityKey.toString(), (String) event.get(MCConstant.METRIC_NAME)); } getAdviceListener().retry(event, RetryEventCode.MSG_RETRY, ex.getMessage()); eventSentToAdviceListener.increment(); registerError(ex); } }
@Override public void run() { pendingRequestCounter.decrementAndGet(); try { future.getUninterruptibly(); } catch (DriverException e) { cassandraErrorCount.increment(); if (event != null) { if (event.get(JetstreamReservedKeys.MessageAffinityKey .toString()) == null) { event.put(JetstreamReservedKeys.MessageAffinityKey .toString(), (String) event .get(MCConstant.METRIC_NAME)); } getAdviceListener().retry(event, RetryEventCode.MSG_RETRY, e.getMessage()); eventSentToAdviceListener.increment(); } registerError(e); } } }
@Override public void sendEvent(JetstreamEvent event) throws EventException { if (isPaused() || shutdownFlag.get()) { super.incrementEventDroppedCounter(); return; } if (MCCounterHelper.isGroupByCounterEvent(event)) { if (!connected.get()) { if (config.getEnableCassandra()) { if (event.get(JetstreamReservedKeys.MessageAffinityKey .toString()) == null) { event.put(JetstreamReservedKeys.MessageAffinityKey .toString(), (String) event .get(MCConstant.METRIC_NAME)); } getAdviceListener().retry(event, RetryEventCode.MSG_RETRY, "Cassandra Down"); eventSentToAdviceListener.increment(); } else { super.incrementEventDroppedCounter(); } return; } incrementEventRecievedCounter(); m_lastEvent = event; publishAsync(event); } }
event.put(Constants.EVENT_PAYLOAD_SESSION_OBJ, transferInSession);