public void sendMessage( CellMessage msg, boolean local, boolean remote, CellMessageAnswerable callback, long timeout) throws SerializationException { if (!msg.isStreamMode()) { msg.touch(); } msg.setTtl(timeout); EventLogger.sendBegin(this, msg, "callback"); UOID uoid = msg.getUOID(); boolean success = false; try { CellLock lock = new CellLock(msg, callback, timeout); synchronized (_waitHash) { _waitHash.put(uoid, lock); } __cellGlue.sendMessage(this, msg, local, remote); success = true; } catch (NoRouteToCellException e) { if (callback != null) { callback.exceptionArrived(msg, e); } } finally { if (!success) { synchronized (_waitHash) { _waitHash.remove(uoid); } EventLogger.sendEnd(msg); } } }
public CellMessage sendAndWait(CellMessage msg, boolean local, boolean remote, long timeout) throws SerializationException, NoRouteToCellException, InterruptedException { if (!msg.isStreamMode()) { msg.touch(); } msg.setTtl(timeout); EventLogger.sendBegin(this, msg, "blocking"); UOID uoid = msg.getUOID(); try { CellLock lock = new CellLock(); synchronized (_waitHash) { _waitHash.put(uoid, lock); } LOGGER.trace("sendAndWait : adding to hash : {}", uoid); __cellGlue.sendMessage(this, msg, local, remote); // // because of a linux native thread problem with // wait(n > 0), we have to use a interruptedFlag // and the time messurement. // synchronized (lock) { long start = System.currentTimeMillis(); while (lock.getObject() == null && timeout > 0) { lock.wait(timeout); timeout -= (System.currentTimeMillis() - start); } } CellMessage answer = (CellMessage) lock.getObject(); if (answer == null) { return null; } answer = answer.decode(); Object obj = answer.getMessageObject(); if (obj instanceof NoRouteToCellException) { throw (NoRouteToCellException) obj; } else if (obj instanceof SerializationException) { throw (SerializationException) obj; } return answer; } finally { synchronized (_waitHash) { _waitHash.remove(uoid); } EventLogger.sendEnd(msg); } }
public void sendMessage(CellMessage msg, boolean locally, boolean remotely) throws SerializationException, NoRouteToCellException { if (!msg.isStreamMode()) { msg.touch(); } EventLogger.sendBegin(this, msg, "async"); try { __cellGlue.sendMessage(this, msg, locally, remotely); } finally { EventLogger.sendEnd(msg); } }
@Override public void innerRun() { try (CDC ignored = _lock.getCdc().restore()) { CellMessageAnswerable callback = _lock.getCallback(); CellMessage answer; Object obj; try { answer = _message.decode(); obj = answer.getMessageObject(); } catch (SerializationException e) { LOGGER.warn(e.getMessage()); obj = e; answer = null; } EventLogger.sendEnd(_lock.getMessage()); if (obj instanceof Exception) { callback.exceptionArrived(_lock.getMessage(), (Exception) obj); } else { callback.answerArrived(_lock.getMessage(), answer); } LOGGER.trace("addToEventQueue : callback done for : {}", _message); } }
public <T extends Message> List<DeliveryAddress> validateMessageRecipients(MessageWrapper<T> msg) throws InvalidAddressException { LinkedList<DeliveryAddress> outList = new LinkedList<DeliveryAddress>(); // Ok Here we go Set<String> validServices = services.getServiceNames(); Set<Recipient> sendTo = msg.getMessage().getHeader().getRecipientsList(); Iterator<Recipient> itr = sendTo.iterator(); while (itr.hasNext()) { Recipient r = itr.next(); DeliveryAddress adr = r.getDeliveryAddress(); AddressType type = adr.getAddressType(); if (type == null) { InvalidAddressException exp = new InvalidAddressException("Recipient passed with unknown/type"); eventLogger.logUserExceptionEvent("validateMessageRecipients", exp); throw exp; } switch (type) { case Physical: { PhysicalAddress a = adr.getPhysicalAddress(); if (!validServices.contains(a.getServiceId())) { outList.add(adr); } break; } case Group: { // TODO: Should we do a deep validation? - For not no - We // assume Group integrity if (groupMgr.findGroup(adr.getGroupAddress().getName()) == null) { outList.add(adr); } break; } case Party: { // TODO: Should we do a deep Validation? - For not no - We // assume user integrity; if (userMgr.findUser(adr.getPartyAddress().getName()) == null) { outList.add(adr); } break; } default: { outList.add(adr); } } } // Loop Address - Switch by type return outList; }
private void preparePlayer(boolean playWhenReady) { if (player == null) { player = new DemoPlayer(getRendererBuilder()); player.addListener(this); player.setCaptionListener(this); player.setMetadataListener(this); player.seekTo(playerPosition); playerNeedsPrepare = true; mediaController.setMediaPlayer(player.getPlayerControl()); mediaController.setEnabled(true); eventLogger = new EventLogger(); eventLogger.startSession(); player.addListener(eventLogger); player.setInfoListener(eventLogger); player.setInternalErrorListener(eventLogger); debugViewHelper = new DebugTextViewHelper(player, debugTextView); debugViewHelper.start(); } if (playerNeedsPrepare) { player.prepare(); playerNeedsPrepare = false; updateButtonVisibilities(); } player.setSurface(surfaceView.getHolder().getSurface()); player.setPlayWhenReady(playWhenReady); }
public Integer createUpdate(Integer executorId, BillingProcessConfigurationDTO dto) { configuration = configurationDas.findByEntity(dto.getEntity()); if (configuration != null) { if (!configuration.getGenerateReport().equals( dto.getGenerateReport())) { eLogger.audit(executorId, null, Constants.TABLE_BILLING_PROCESS_CONFIGURATION, configuration.getId(), EventLogger.MODULE_BILLING_PROCESS, EventLogger.ROW_UPDATED, new Integer(configuration .getGenerateReport()), null, null); configuration.setGenerateReport(dto.getGenerateReport()); configuration .setReviewStatus(dto.getGenerateReport() == 1 ? Constants.REVIEW_STATUS_GENERATED : Constants.REVIEW_STATUS_APPROVED); } else { eLogger.audit(executorId, null, Constants.TABLE_BILLING_PROCESS_CONFIGURATION, configuration.getId(), EventLogger.MODULE_BILLING_PROCESS, EventLogger.ROW_UPDATED, null, null, null); } configuration.setNextRunDate(dto.getNextRunDate()); } else { configuration = configurationDas.create(dto.getEntity(), dto .getNextRunDate(), dto.getGenerateReport()); } configuration.setDaysForReport(dto.getDaysForReport()); configuration.setDaysForRetry(dto.getDaysForRetry()); configuration.setPeriodUnit(dto.getPeriodUnit()); configuration.setDueDateUnitId(dto.getDueDateUnitId()); configuration.setDueDateValue(dto.getDueDateValue()); configuration.setDfFm(dto.getDfFm()); configuration.setOnlyRecurring(dto.getOnlyRecurring()); configuration.setInvoiceDateProcess(dto.getInvoiceDateProcess()); configuration.setAutoPaymentApplication(dto.getAutoPaymentApplication()); configuration.setMaximumPeriods(dto.getMaximumPeriods()); configuration.setLastDayOfMonth(dto.getLastDayOfMonth()); configuration.setProratingType(dto.getProratingType()); return configuration.getId(); }
private void releasePlayer() { if (player != null) { debugViewHelper.stop(); debugViewHelper = null; playerPosition = player.getCurrentPosition(); player.release(); player = null; eventLogger.endSession(); eventLogger = null; } }
public void setReviewApproval(Integer executorId, boolean flag) { eLogger.audit(executorId, null, Constants.TABLE_BILLING_PROCESS_CONFIGURATION, configuration .getId(), EventLogger.MODULE_BILLING_PROCESS, EventLogger.ROW_UPDATED, configuration.getReviewStatus(), null, null); configuration.setReviewStatus(flag ? Constants.REVIEW_STATUS_APPROVED : Constants.REVIEW_STATUS_DISAPPROVED); }
@Override public void innerRun() { EventLogger.queueEnd(_event); if (_event instanceof LastMessageEvent) { LOGGER.trace("messageThread : LastMessageEvent arrived"); _cell.messageArrived((MessageEvent) _event); } else if (_event instanceof RoutedMessageEvent) { LOGGER.trace("messageThread : RoutedMessageEvent arrived"); _cell.messageArrived((RoutedMessageEvent) _event); } else if (_event instanceof MessageEvent) { MessageEvent msgEvent = (MessageEvent) _event; LOGGER.trace("messageThread : MessageEvent arrived"); CellMessage msg; try { msg = msgEvent.getMessage().decode(); } catch (SerializationException e) { CellMessage envelope = msgEvent.getMessage(); LOGGER.error( String.format( "Discarding a malformed message from %s with UOID %s and session [%s]: %s", envelope.getSourcePath(), envelope.getUOID(), envelope.getSession(), e.getMessage()), e); return; } CDC.setMessageContext(msg); try { LOGGER.trace("messageThread : delivering message: {}", msg); _cell.messageArrived(new MessageEvent(msg)); LOGGER.trace("messageThread : delivering message done: {}", msg); } catch (RuntimeException e) { if (!msg.isReply()) { try { msg.revertDirection(); msg.setMessageObject(e); sendMessage(msg); } catch (NoRouteToCellException f) { LOGGER.error("PANIC : Problem returning answer: {}", f); } } throw e; } finally { CDC.clearMessageContext(); } } }
public int updateWaitQueue() { Collection<CellLock> expired = new ArrayList<>(); long now = System.currentTimeMillis(); int size; synchronized (_waitHash) { Iterator<CellLock> i = _waitHash.values().iterator(); while (i.hasNext()) { CellLock lock = i.next(); if (lock != null && !lock.isSync() && lock.getTimeout() < now) { expired.add(lock); i.remove(); } } size = _waitHash.size(); } // // _waitHash can't be used here. Otherwise // we will end up in a deadlock (NO LOCKS WHILE CALLING CALLBACKS) // for (CellLock lock : expired) { try { CellMessage envelope = lock.getMessage(); EventLogger.sendEnd(envelope); lock.getCallback().answerTimedOut(envelope); } catch (RuntimeException e) { /* Don't let a problem in the callback prevent us from * expiring all messages. */ Thread t = Thread.currentThread(); t.getUncaughtExceptionHandler().uncaughtException(t, e); } } return size; }
public DeliverMessageTask(CellEvent event) { _event = event; EventLogger.queueBegin(_event); }
/** * @param adr * @param addressMap * @param exclude - Set of Delivery addresses already seen to avoid loops * @param msg - The Message wrapper for context dependent addressing */ public <T extends Message> void resolveAddress( DeliveryAddress adr, HashMap<String, List<PhysicalAddress>> addressMap, Set<DeliveryAddress> exclude, MessageWrapper<T> msg, Recipient r) { if (!exclude.contains(adr)) { exclude.add(adr); AddressType type = adr.getAddressType(); if (type == null) { eventLogger.logSummaryEvent( LogEntryType.User_SendMessage, EventLevel.warn, "resolveAddress", "RecipientAddress Type Unknown", "Recipient passed with unknown/type"); return; } switch (adr.getAddressType()) { case Physical: { PhysicalAddress a = adr.getPhysicalAddress(); List<PhysicalAddress> list = addressMap.get(a.getServiceId()); if (list == null) { list = new LinkedList<PhysicalAddress>(); addressMap.put(a.getServiceId(), list); } list.add(a); break; } case Group: { DeliveryGroup grp = groupMgr.findGroup(adr.getGroupAddress().getName()); if (grp != null) { // Loop the group LinkedList<DeliveryAddress> grpList = grp.getGroup(); Iterator<DeliveryAddress> itr = grpList.iterator(); while (itr.hasNext()) { resolveAddress(itr.next(), addressMap, exclude, msg, r); } } break; } case Party: { UserContactInfo userInfo = userMgr.findUser(adr.getPartyAddress().getName()); if (userInfo != null) { // TODO Extend for context and better address selection - ay need more context for the // operation. // TODO Extend for presence // Resolve the user preferred address PhysicalAddress a = userInfo.getPreferredAddress(); List<PhysicalAddress> list = addressMap.get(a.getServiceId()); if (list == null) { list = new LinkedList<PhysicalAddress>(); addressMap.put(a.getServiceId(), list); } list.add(a); } break; } } } }
public void send(final LoveLetter letter) { eventLogger.sentLoveLetter(); }
public void send(final GreetingLetter letter) { eventLogger.sentGreetingLetter(); }
private void init() { eLogger = EventLogger.getInstance(); configurationDas = new BillingProcessConfigurationDAS(); }