Exemplo n.º 1
0
 /**
  * This method sends a message.
  *
  * @param msg the message to be sent
  * @return the received (and post-processed) message from the succeeding operators
  */
 public Message sendMessage(final Message msg) {
   Message msgResult = this.forwardMessage(msg.preProcess(this));
   // postprocess anyway one message, does not matter if the resultant msg is null or not to allow
   // processing right after initialization
   if (msgResult == null) {
     return msg.postProcess(this);
   } else {
     return msgResult.postProcess(this);
   }
 }
Exemplo n.º 2
0
 public Message sendMessageDebug(Message msg, final DebugStep debugstep) {
   Message msgResult = this.forwardMessageDebug(msg.preProcessDebug(this, debugstep), debugstep);
   // postprocess anyway one message, does not matter if the resultant msg is null or not to allow
   // processing right after initialization
   if (msgResult == null) {
     return msg.postProcessDebug(this, debugstep);
   } else {
     return msgResult.postProcessDebug(this, debugstep);
   }
 }
Exemplo n.º 3
0
 protected Message forwardMessageDebug(final Message msg, final DebugStep debugstep) {
   msg.setVisited(this);
   Message result = msg;
   for (final OperatorIDTuple opid : this.succeedingOperators) {
     if (!msg.hasVisited(opid.getOperator())) {
       final Message msg2 = msg.clone();
       result = opid.getOperator().receiveDebug(msg2, this, debugstep);
     }
   }
   return result;
 }
Exemplo n.º 4
0
  public Message receiveDebug(
      final Message message, final BasicOperator from, final DebugStep debugstep) {
    Message msg = message;
    if (from != null) {
      debugstep.stepMessage(from, this, msg);
      Map<BasicOperator, Message> received = this.messages.get(msg.getId());
      if (received == null) {
        received = new HashMap<BasicOperator, Message>();
        this.messages.put(msg.getId(), received);
      }
      received.put(from, msg);

      final HashSet<BasicOperator> operatorsWithoutCycles = new HashSet<BasicOperator>();
      operatorsWithoutCycles.addAll(this.precedingOperators);
      operatorsWithoutCycles.removeAll(this.cycleOperands);

      if (!received.keySet().containsAll(operatorsWithoutCycles)) {
        return null;
      }

      if (received.keySet().containsAll(this.precedingOperators)) {
        this.messages.remove(msg.getId());
      }
      msg = msg.merge(received.values(), this);
    }
    msg = msg.preProcessDebug(this, debugstep);
    msg = forwardMessageDebug(msg, debugstep);
    if (msg == null) return null;
    else return msg.postProcessDebug(this, debugstep);
  }