Example #1
0
 @Override
 public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
   final Channel channel = ctx.getChannel();
   Message m = (Message) e.getMessage();
   Tuple t = cb.receive(m);
   if (m.type() == Type.DEREG) {
     channel.close();
   }
   if (t != null) {
     if (m.type() == Type.REG) {
       PhysicalLocation pl = new PhysicalLocation(m.source().logId(), (Integer) t.get(0));
       plMap.put(pl, channel);
       ctx.setAttachment(pl);
     }
     Message rsp = new Message(m.type(), m.getAck(), m.destination(), m.source(), t);
     channel.write(rsp);
   }
 }
  private void handleTaintMessage(Message m) throws ExecException {
    if (m.body().get(0).equals("cross")) { // cross-task (accumulates)
      String sourceAlias = m.source().logId();
      Map<Tuple, Set<String>> oneCTTT = crossTaskTaintTags.get(sourceAlias);

      Tuple keys = (Tuple) m.body().get(1);
      if (!oneCTTT.containsKey(keys)) {
        oneCTTT.put(keys, new HashSet<String>());
      }
      Set<String> tags = oneCTTT.get(keys);
      for (int i = 2; i < m.body().size(); i++) {
        tags.add((String) m.body().get(i));
      }
    } else { // within-task (replaces)
      currentWithinTaskTaintTag = new HashSet<String>();
      for (int i = 1; i < m.body().size(); i++) {
        currentWithinTaskTaintTag.add((String) m.body().get(i));
      }
    }
  }