public void addTrackedPerceiver(
     Long perceiverOid, InterpolatedWorldNode wnode, Integer reactionRadius) {
   lock.lock();
   try {
     if (perceiverDataMap.containsKey(perceiverOid)) {
       // Don't add the object more than once.
       Log.error(
           "ProximityTracker.addTrackedPerceiver: perceiverOid "
               + perceiverOid
               + " is already in the set of local objects, for ProximityTracker instance "
               + this);
       return;
     }
     PerceiverData perceiverData = new PerceiverData(perceiverOid, reactionRadius, wnode);
     perceiverDataMap.put(perceiverOid, perceiverData);
   } finally {
     lock.unlock();
   }
   if (Log.loggingDebug)
     Log.debug(
         "ProximityTracker.addTrackedPerceiver: perceiverOid="
             + perceiverOid
             + " reactionRadius="
             + reactionRadius
             + " instanceOid="
             + instanceOid);
 }
Ejemplo n.º 2
0
  /**
   * there is a socket listening on the port for this packet. process if it is a new connection rdp
   * packet
   */
  public void processNewConnection(RDPServerSocket serverSocket, RDPPacket packet) {
    if (Log.loggingNet)
      Log.net(
          "processNewConnection: RDPPACKET (localport=" + serverSocket.getPort() + "): " + packet);

    //        int localPort = serverSocket.getPort();
    InetAddress remoteAddr = packet.getInetAddress();
    int remotePort = packet.getPort();
    if (!packet.isSyn()) {
      // the client is not attemping to start a new connection
      // send a reset and forget about it
      Log.debug("socket got non-syn packet, replying with reset: packet=" + packet);
      RDPPacket rstPacket = RDPPacket.makeRstPacket();
      rstPacket.setPort(remotePort);
      rstPacket.setInetAddress(remoteAddr);
      RDPServer.sendPacket(serverSocket.getDatagramChannel(), rstPacket);
      return;
    }

    // it is a syn packet, lets make a new connection for it
    RDPConnection con = new RDPConnection();
    DatagramChannel dc = serverSocket.getDatagramChannel();
    con.initConnection(dc, packet);

    // add new connection to allConnectionMap
    registerConnection(con, dc);

    // ack it with a syn
    RDPPacket synPacket = RDPPacket.makeSynPacket(con);
    con.sendPacketImmediate(synPacket, false);
  }
Ejemplo n.º 3
0
    public void run() {
      synchronized (pluginStartGroup) {
        waitForDependencies();
      }

      if (Log.loggingDebug)
        Log.debug(
            "Dependency satisfied for type="
                + await.getPluginType()
                + " name="
                + await.getPluginName());

      MVByteBuffer buffer = new MVByteBuffer(1024);
      ResponseMessage response = new ResponseMessage(await);
      Message.toBytes(response, buffer);
      buffer.flip();

      try {
        if (!ChannelUtil.writeBuffer(buffer, agentSocket)) {
          Log.error("could not write await dependencies response");
        }
      } catch (java.io.IOException e) {
        Log.exception("could not write await dependencies response", e);
      }
    }
Ejemplo n.º 4
0
 public void run() {
   while (true) {
     LinkedList<PacketCallbackStruct> list = null;
     try {
       queuedPacketCallbacksLock.lock();
       try {
         queuedPacketCallbacksNotEmpty.await();
       } catch (Exception e) {
         Log.error(
             "RDPServer.PacketCallbackThread: queuedPacketCallbacksNotEmpty.await() caught exception "
                 + e.getMessage());
       }
       list = queuedPacketCallbacks;
       queuedPacketCallbacks = new LinkedList<PacketCallbackStruct>();
     } finally {
       queuedPacketCallbacksLock.unlock();
     }
     if (Log.loggingNet)
       Log.net("RDPServer.PacketCallbackThread: Got " + list.size() + " queued packets");
     for (PacketCallbackStruct pcs : list) {
       try {
         callbackProcessPacket(pcs.cb, pcs.con, pcs.packet);
       } catch (Exception e) {
         Log.exception("RDPServer.PacketCallbackThread: ", e);
       }
     }
   }
 }
Ejemplo n.º 5
0
    public synchronized void pluginAvailable(String pluginType, String pluginName) {
      if (Log.loggingDebug)
        Log.debug("Plugin available type=" + pluginType + " name=" + pluginName);

      PluginSpec pluginSpec = plugins.get(pluginType);
      if (pluginSpec == null) {
        Log.error("DomainServer: unexpected plugin type=" + pluginType + " name=" + pluginName);
        return;
      }

      pluginSpec.running++;
      if (pluginSpec.running > pluginSpec.expected) {
        Log.warn(
            "DomainServer: more plugins than expected, type="
                + pluginType
                + " name="
                + pluginName
                + " expected="
                + pluginSpec.expected
                + " available="
                + pluginSpec.running);
      }

      if (pluginSpec.running >= pluginSpec.expected) {
        this.notifyAll();
      }
    }
 public void handleUpdateWorldNode(long oid, WorldManagerClient.UpdateWorldNodeMessage wnodeMsg) {
   PerceiverData perceiverData = perceiverDataMap.get(oid);
   if (perceiverData == null) {
     if (Log.loggingDebug)
       Log.debug(
           "ProximityTracker.handleMessage: ignoring updateWNMsg for oid "
               + oid
               + " because PerceptionData for oid not found");
     return;
   }
   BasicWorldNode bwnode = wnodeMsg.getWorldNode();
   if (Log.loggingDebug)
     Log.debug(
         "ProximityTracker.handleMessage: UpdateWnode for "
             + oid
             + ", loc "
             + bwnode.getLoc()
             + ", dir "
             + bwnode.getDir());
   if (perceiverData.wnode != null) {
     perceiverData.previousLoc = perceiverData.lastLoc;
     perceiverData.wnode.setDirLocOrient(bwnode);
     perceiverData.wnode.setInstanceOid(bwnode.getInstanceOid());
     perceiverData.lastLoc = perceiverData.wnode.getLoc();
   } else
     Log.error(
         "ProximityTracker.handleMessage: In UpdateWorldNodeMessage for oid "
             + oid
             + ", perceiverData.wnode is null!");
   updateEntity(perceiverData);
 }
Ejemplo n.º 7
0
 public void handleMessage(Message msg, int flags) {
   try {
     lock.lock();
     if (activated == false) return; // return true;
     if (msg.getMsgType() == Behavior.MSG_TYPE_COMMAND) {
       Behavior.CommandMessage cmdMsg = (Behavior.CommandMessage) msg;
       String command = cmdMsg.getCmd();
       // Remove the executor, because anything we do will
       // end the current execution.
       Engine.getExecutor().remove(this);
       if (Log.loggingDebug)
         Log.debug(
             "BaseBehavior.onMessage: command = "
                 + command
                 + "; oid = "
                 + obj.getOid()
                 + "; name "
                 + obj.getName());
       if (command.equals(MSG_CMD_TYPE_GOTO)) {
         GotoCommandMessage gotoMsg = (GotoCommandMessage) msg;
         Point destination = gotoMsg.getDestination();
         mode = MSG_CMD_TYPE_GOTO;
         roamingBehavior = true;
         gotoSetup(destination, gotoMsg.getSpeed());
       } else if (command.equals(MSG_CMD_TYPE_STOP)) {
         followTarget = null;
         pathState.clear();
         obj.getWorldNode().setDir(new MVVector(0, 0, 0));
         obj.updateWorldNode();
         mode = MSG_CMD_TYPE_STOP;
         // If roamingBehavior is set, that means that we
         // used formerly had a roaming behavior, so send
         // an ArrivedEventMessage so that the other
         // behavior starts up again.
         if (roamingBehavior) {
           try {
             Engine.getAgent().sendBroadcast(new ArrivedEventMessage(obj));
           } catch (Exception e) {
             Log.error(
                 "BaseBehavior.onMessage: Error sending ArrivedEventMessage, error was '"
                     + e.getMessage()
                     + "'");
             throw new RuntimeException(e);
           }
         }
       } else if (command.equals(BaseBehavior.MSG_CMD_TYPE_FOLLOW)) {
         FollowCommandMessage followMsg = (FollowCommandMessage) msg;
         mode = MSG_CMD_TYPE_FOLLOW;
         followSetup(followMsg.getTarget(), followMsg.getSpeed());
       }
     } else if (msg.getMsgType() == WorldManagerClient.MSG_TYPE_MOB_PATH_CORRECTION) {
       Engine.getExecutor().remove(this);
       interpolatePath();
       interpolatingPath = false;
     }
     // return true;
   } finally {
     lock.unlock();
   }
 }
Ejemplo n.º 8
0
  private synchronized String allocName(String type, String namePattern) {
    Map<String, Integer> patterns = nameTypes.get(type);
    if (patterns == null) {
      patterns = new HashMap<String, Integer>();
      nameTypes.put(type, patterns);
    }

    Integer id = patterns.get(namePattern);
    if (id == null) id = 0;

    id++;
    patterns.put(namePattern, id);
    String agentName = namePattern.replaceFirst("#", id.toString());
    if (agentName.equals(namePattern))
      Log.warn("AllocName: missing '#' in name pattern '" + namePattern + "'");
    else
      Log.debug(
          "AllocName: for type="
              + type
              + " assigned '"
              + agentName
              + "' from pattern '"
              + namePattern
              + "'");
    return agentName;
  }
Ejemplo n.º 9
0
 public void onTcpAccept(SocketChannel agentSocket) {
   Log.debug("Got connection: " + agentSocket);
   try {
     threadPool.execute(new AgentHandler(agentSocket));
   } catch (IOException ex) {
     Log.exception("DomainServer listener", ex);
   }
 }
Ejemplo n.º 10
0
    public int compareTo(Object arg0) {
      RDPConnectionData other = (RDPConnectionData) arg0;

      if (this.readyTime < other.readyTime) {
        if (Log.loggingNet)
          Log.net(
              "RDPServer.RDPConnectionData.compareTo: readyTime compare -1: thiscon="
                  + this.con
                  + ", othercon="
                  + other.con
                  + ", thisready="
                  + this.readyTime
                  + ", otherReady="
                  + other.readyTime);
        return -1;
      } else if (this.readyTime > other.readyTime) {
        if (Log.loggingNet)
          Log.net(
              "RDPServer.RDPConnectionData.compareTo: readyTime compare 1: thiscon="
                  + this.con
                  + ", othercon="
                  + other.con
                  + ", thisready="
                  + this.readyTime
                  + ", otherReady="
                  + other.readyTime);
        return 1;
      }

      if (this.con == other.con) {
        if (Log.loggingNet)
          Log.net(
              "RDPServer.RDPConnectionData.compareTo: conRef compare 0: thiscon="
                  + this.con
                  + ", othercon="
                  + other.con);
        return 0;
      } else if (this.con.hashCode() < other.con.hashCode()) {
        if (Log.loggingNet)
          Log.net(
              "RDPServer.RDPConnectionData.compareTo: hashCode compare -1: thiscon="
                  + this.con
                  + ", othercon="
                  + other.con);
        return -1;
      } else if (this.con.hashCode() > other.con.hashCode()) {
        if (Log.loggingNet)
          Log.net(
              "RDPServer.RDPConnectionData.compareTo: hashCode compare 1: thiscon="
                  + this.con
                  + ", othercon="
                  + other.con);
        return 1;
      } else {
        throw new RuntimeException("error");
      }
    }
Ejemplo n.º 11
0
 /**
  * a DatagramChannel has data ready - process all the pending packets, whether its for a
  * rdpserversocket or rdpconnection.
  */
 void processActiveChannel(DatagramChannel dc) throws ClosedChannelException {
   RDPPacket packet;
   int count = 0;
   // read in the packet
   try {
     Set<RDPConnection> needsAckConnections = new HashSet<RDPConnection>();
     while ((packet = RDPServer.receivePacket(dc)) != null) {
       if (Log.loggingNet)
         Log.net(
             "RDPServer.processActiveChannel: Starting iteration with count of "
                 + count
                 + " packets");
       // see if there is a connection already for this packet
       InetAddress remoteAddr = packet.getInetAddress();
       int remotePort = packet.getPort();
       int localPort = dc.socket().getLocalPort();
       ConnectionInfo conInfo = new ConnectionInfo(remoteAddr, remotePort, localPort);
       RDPConnection con = RDPServer.getConnection(dc, conInfo);
       if (con != null) {
         if (Log.loggingNet)
           Log.net("RDPServer.processActiveChannel: found an existing connection: " + con);
         count++;
         if (processExistingConnection(con, packet)) needsAckConnections.add(con);
         // Prevent this from blocking getActiveChannels by
         // putting an upper bound on the number of packets
         // processed
         if (count >= 20) break;
         continue;
       } else {
         Log.net("RDPServer.processActiveChannel: did not find an existing connection");
       }
       // there is no connection,
       // see if there is a socket listening for new connection
       RDPServerSocket rdpSocket = RDPServer.getRDPSocket(dc);
       if (rdpSocket != null) {
         count++;
         processNewConnection(rdpSocket, packet);
         return;
       }
       return;
     }
     // Finally, send out the acks
     for (RDPConnection con : needsAckConnections) {
       RDPPacket replyPacket = new RDPPacket(con);
       con.sendPacketImmediate(replyPacket, false);
     }
   } catch (ClosedChannelException ex) {
     Log.error("RDPServer.processActiveChannel: ClosedChannel " + dc.socket());
     throw ex;
   } finally {
     if (Log.loggingNet)
       Log.net("RDPServer.processActiveChannel: Returning after processing " + count + " packets");
   }
 }
Ejemplo n.º 12
0
  private synchronized void addNewAgent(
      int agentId,
      SocketChannel socket,
      String agentName,
      String agentIP,
      int agentPort,
      int flags) {
    if (agentIP.equals(":same")) {
      InetAddress agentAddress = socket.socket().getInetAddress();
      agentIP = agentAddress.getHostAddress();
    }

    Log.info(
        "New agent id="
            + agentId
            + " name="
            + agentName
            + " address="
            + agentIP
            + ":"
            + agentPort
            + " flags="
            + flags);
    AgentInfo agentInfo = new AgentInfo();
    agentInfo.agentId = agentId;
    agentInfo.flags = flags;
    agentInfo.socket = socket;
    agentInfo.agentName = agentName;
    agentInfo.agentIP = agentIP;
    agentInfo.agentPort = agentPort;
    agentInfo.outputBuf = new MVByteBuffer(1024);
    agentInfo.inputBuf = new MVByteBuffer(1024);
    agents.put(socket, agentInfo);

    NewAgentMessage newAgentMessage =
        new NewAgentMessage(agentId, agentName, agentIP, agentPort, flags);
    for (Map.Entry<SocketChannel, AgentInfo> entry : agents.entrySet()) {
      if (entry.getKey() == socket) continue;

      // Tell other agents about the new one
      synchronized (entry.getValue().outputBuf) {
        Message.toBytes(newAgentMessage, entry.getValue().outputBuf);
      }

      // Tell new agent about other agents
      NewAgentMessage otherAgentMessage =
          new NewAgentMessage(
              entry.getValue().agentId,
              entry.getValue().agentName,
              entry.getValue().agentIP,
              entry.getValue().agentPort,
              entry.getValue().flags);
      synchronized (agentInfo.outputBuf) {
        Message.toBytes(otherAgentMessage, agentInfo.outputBuf);
      }
    }

    messageIO.addAgent(agentInfo);
    messageIO.outputReady();
  }
 protected void performNotification(
     long perceiverOid, long perceivedOid, boolean inRadius, boolean wasInRadius) {
   if (Log.loggingDebug)
     Log.debug(
         "ProximityTracker.performNotification: perceiverOid "
             + perceiverOid
             + ", perceivedOid "
             + perceivedOid
             + ", inRadius "
             + inRadius
             + ", wasInRadius "
             + wasInRadius);
   if (notifyCallback != null) {
     notifyCallback.notifyReactionRadius(perceivedOid, perceiverOid, inRadius, wasInRadius);
     notifyCallback.notifyReactionRadius(perceiverOid, perceivedOid, inRadius, wasInRadius);
   } else {
     ObjectTracker.NotifyReactionRadiusMessage nmsg =
         new ObjectTracker.NotifyReactionRadiusMessage(
             perceivedOid, perceiverOid, inRadius, wasInRadius);
     Engine.getAgent().sendBroadcast(nmsg);
     nmsg =
         new ObjectTracker.NotifyReactionRadiusMessage(
             perceiverOid, perceivedOid, inRadius, wasInRadius);
     Engine.getAgent().sendBroadcast(nmsg);
   }
 }
Ejemplo n.º 14
0
 protected boolean interpolatePath() {
   long timeNow = System.currentTimeMillis();
   PathLocAndDir locAndDir = pathState.interpolatePath(timeNow);
   long oid = obj.getOid();
   //         if (locAndDir != null) {
   //             if (Log.loggingDebug) {
   //                 Log.debug("BaseBehavior.interpolatePath: oid = " + oid + "; loc = " +
   // locAndDir.getLoc() + "; dir = " + locAndDir.getDir());
   //             }
   //         }
   //         else {
   //             if (Log.loggingDebug)
   //                 Log.debug("BaseBehavior.interpolatePath: oid = " + oid + "; locAndDir is
   // null");
   //         }
   if (locAndDir == null) {
     // We have arrived - - turn off interpolation, and cancel that path
     interpolatingPath = false;
     if (Log.loggingDebug)
       Log.debug(
           "BaseBehavior.interpolatePath: cancelling path: oid = "
               + oid
               + "; myLoc = "
               + obj.getWorldNode().getLoc());
     cancelPathInterpolator(oid);
     obj.getWorldNode().setDir(new MVVector(0, 0, 0));
   } else {
     obj.getWorldNode()
         .setPathInterpolatorValues(
             timeNow, locAndDir.getDir(), locAndDir.getLoc(), locAndDir.getOrientation());
     MobManagerPlugin.getTracker(obj.getInstanceOid()).updateEntity(obj);
   }
   return interpolatingPath;
 }
  protected boolean maybeAddPerceivedObject(PerceptionMessage.ObjectNote objectNote) {
    ObjectType objType = (ObjectType) objectNote.getObjectType();
    long perceivedOid = objectNote.getSubject();
    long perceiverOid = objectNote.getTarget();
    if (perceivedOid == perceiverOid) return true;
    boolean callbackNixedIt = false;
    if (remoteObjectFilter != null)
      callbackNixedIt = !remoteObjectFilter.objectShouldBeTracked(perceivedOid, objectNote);
    if (callbackNixedIt || !(objType.isMob())) {
      //             if (Log.loggingDebug)
      //                 Log.debug("ProximityTracker.maybeAddPerceivedObject: ignoring oid=" +
      // perceivedOid
      //                     + " objType=" + objType
      //                     + " detected by " + perceiverOid
      //                     + ", instanceOid=" + instanceOid);
      return false;
    }

    if (Log.loggingDebug)
      Log.debug(
          "ProximityTracker.maybeAddPerceivedObject: oid="
              + perceivedOid
              + " objType="
              + objType
              + " detected by "
              + perceiverOid
              + ", instanceOid="
              + instanceOid);
    lock.lock();
    try {
      PerceiverData perceiverData = perceiverDataMap.get(perceiverOid);
      if (perceiverData == null) {
        Log.error(
            "ProximityTracker.maybeAddPerceivedObject: got perception msg with perceived obj oid="
                + perceivedOid
                + " for unknown perceiver="
                + perceiverOid);
        return false;
      }
      perceiverData.perceivedOids.add(perceivedOid);
      PerceiverData perceivedData = perceiverDataMap.get(perceivedOid);
      if (perceivedData != null) testProximity(perceiverData, perceivedData, true, false);
    } finally {
      lock.unlock();
    }
    return true;
  }
Ejemplo n.º 16
0
 private static void touchFile(String fileName) {
   try {
     FileWriter writer = new FileWriter(fileName);
     writer.close();
   } catch (java.io.IOException e) {
     Log.exception("touchFile " + fileName, e);
   }
 }
Ejemplo n.º 17
0
    public boolean handleMessage() throws java.io.IOException {
      ByteBuffer buf = ByteBuffer.allocate(4);
      int nBytes = ChannelUtil.fillBuffer(buf, agentSocket);
      if (nBytes == 0) {
        Log.info("DomainServer: agent closed connection " + agentSocket);
        return false;
      }
      if (nBytes < 4) {
        Log.error("DomainServer: invalid message " + nBytes);
        return false;
      }

      int msgLen = buf.getInt();
      if (msgLen < 0) {
        return false;
      }

      MVByteBuffer buffer = new MVByteBuffer(msgLen);
      nBytes = ChannelUtil.fillBuffer(buffer.getNioBuf(), agentSocket);
      if (nBytes == 0) {
        Log.info("DomainServer: agent closed connection " + agentSocket);
        return false;
      }
      if (nBytes < msgLen) {
        Log.error(
            "DomainServer: invalid message, expecting "
                + msgLen
                + " got "
                + nBytes
                + " from "
                + agentSocket);
        return false;
      }

      Message message = (Message) MarshallingRuntime.unmarshalObject(buffer);

      if (message instanceof AgentHelloMessage) {
        // Successfully added agent, clear our socket var
        // so we don't close it.
        if (handleAgentHello((AgentHelloMessage) message)) agentSocket = null;
        return false;
      } else if (message instanceof AllocNameMessage)
        handleAllocName((AllocNameMessage) message, agentSocket);

      return true;
    }
Ejemplo n.º 18
0
    public void run() {
      try {
        while (handleMessage()) {}
      } catch (InterruptedIOException ex) {
        Log.info("DomainServer: closed connection due to timeout " + agentSocket);
      } catch (IOException ex) {
        Log.info("DomainServer: agent closed connection " + agentSocket);
      } catch (Exception ex) {
        Log.exception("DomainServer.SocketHandler: ", ex);
      }

      try {
        if (agentSocket != null) agentSocket.close();
      } catch (IOException ex) {
        /* ignore */
      }
    }
Ejemplo n.º 19
0
  /** make sure the packet as the remote address and remote port set */
  static void sendPacket(DatagramChannel dc, RDPPacket packet) {

    sendMeter.add();

    // allocate a buffer
    int bufSize = 100 + (packet.numEacks() * 4);
    if (packet.getData() != null) {
      bufSize += packet.getData().length;
      sendDataMeter.add();
    }
    MVByteBuffer buf = new MVByteBuffer(bufSize);
    packet.toByteBuffer(buf); // function flips the buffer

    int remotePort = packet.getPort();
    InetAddress remoteAddr = packet.getInetAddress();

    if ((remotePort < 0) || (remoteAddr == null)) {
      throw new MVRuntimeException("RDPServer.sendPacket: remotePort or addr is null");
    }

    try {
      int bytes = dc.send(buf.getNioBuf(), new InetSocketAddress(remoteAddr, remotePort));
      if (bytes == 0) {
        Log.error("RDPServer.sendPacket: could not send packet, size=" + bufSize);
      }

      if (Log.loggingNet)
        Log.net(
            "RDPServer.sendPacket: remoteAddr="
                + remoteAddr
                + ", remotePort="
                + remotePort
                + ", numbytes sent="
                + bytes);
    } catch (java.io.IOException e) {
      Log.exception(
          "RDPServer.sendPacket: remoteAddr="
              + remoteAddr
              + ", remotePort="
              + remotePort
              + ", got exception",
          e);
      throw new MVRuntimeException("RDPServer.sendPacket", e);
    }
  }
    public void run() {
      while (running) {
        try {
          update();
        } catch (MVRuntimeException e) {
          Log.exception("ProximityTracker.Updater.run caught MVRuntimeException", e);
        } catch (Exception e) {
          Log.exception("ProximityTracker.Updater.run caught exception", e);
        }

        try {
          Thread.sleep(1000);
        } catch (InterruptedException e) {
          Log.warn("Updater: " + e);
          e.printStackTrace();
        }
      }
    }
 public void removeTrackedPerceiver(Long perceiverOid) {
   lock.lock();
   try {
     // Iterate over perceived objects, removing our
     // perceiverOid from their oid sets.
     PerceiverData perceiverData = perceiverDataMap.get(perceiverOid);
     if (perceiverData != null) {
       if (Log.loggingDebug)
         Log.debug(
             "ProximityTracker.removeTrackedPerceiver: perceiverOid "
                 + perceiverOid
                 + ", inRangeOids count "
                 + perceiverData.inRangeOids.size());
       // Iterate over perceived objects, removing our
       // perceiverOid from their oid sets.
       for (Long perceivedOid : perceiverData.perceivedOids) {
         PerceiverData perceivedData = perceiverDataMap.get(perceivedOid);
         if (perceivedData != null) {
           perceivedData.perceivedOids.remove(perceiverOid);
           if (perceivedData.inRangeOids.contains(perceiverOid)) {
             perceivedData.inRangeOids.remove(perceiverOid);
             performNotification(perceiverOid, perceivedOid, false, true);
           }
         }
       }
       perceiverData.perceivedOids.clear();
       perceiverData.inRangeOids.clear();
       perceiverDataMap.remove(perceiverOid);
     } else
       Log.warn(
           "ProximityTracker.removeTrackedPerceiver: For oid="
               + perceiverOid
               + ", didn't find PerceiverData");
   } finally {
     lock.unlock();
   }
   if (Log.loggingDebug)
     Log.debug(
         "ProximityTracker.removeTrackedPerceiver: oid="
             + perceiverOid
             + " instanceOid="
             + instanceOid);
 }
Ejemplo n.º 22
0
  void handlePluginAvailable(PluginAvailableMessage available, SocketChannel agentSocket)
      throws java.io.IOException {
    if (available.getMsgType() != MessageTypes.MSG_TYPE_PLUGIN_AVAILABLE) {
      Log.error("DomainServer: invalid available message");
      return;
    }

    if (pluginStartGroup == null) {
      Log.error(
          "DomainServer: no start group defined for plugin type="
              + available.getPluginType()
              + " name="
              + available.getPluginName());
      // ## return error
      return;
    }

    pluginStartGroup.pluginAvailable(available.getPluginType(), available.getPluginName());
  }
Ejemplo n.º 23
0
  void handleAwaitPluginDependents(AwaitPluginDependentsMessage await, SocketChannel agentSocket)
      throws java.io.IOException {
    if (await.getMsgType() != MessageTypes.MSG_TYPE_AWAIT_PLUGIN_DEPENDENTS) {
      Log.error("DomainServer: invalid await message");
      return;
    }

    if (pluginStartGroup == null) {
      Log.error(
          "DomainServer: no start group defined for plugin type="
              + await.getPluginType()
              + " name="
              + await.getPluginName());
      // ## return error
      return;
    }

    new Thread(new PluginDependencyWatcher(await, agentSocket)).start();
  }
Ejemplo n.º 24
0
 public void RemoveVoiceGroup() {
   int error = 0;
   // Remove voice group voice server
   error = VoiceClient.removeVoiceGroup(this.GetGroupOid());
   if (error != VoiceClient.SUCCESS) {
     Log.error(
         "MarsGroup.RemoveVoiceGroup : Remove Voice Group Response - "
             + VoiceClient.errorString(error));
   }
 }
  /**
   * Track union of perceived objects and keep filter in-sync. The filter must be a {@link
   * PerceptionFilter} and the message must be a {@link PerceptionMessage}.
   *
   * @param triggeringMessage The matched message.
   * @param triggeringFilter The matched filter.
   * @param agent The local message agent.
   */
  public synchronized void trigger(
      Message triggeringMessage, IFilter triggeringFilter, MessageAgent agent) {
    PerceptionMessage message = (PerceptionMessage) triggeringMessage;

    List<ObjectNote> gainObjects = message.getGainObjects();
    List<ObjectNote> lostObjects = message.getLostObjects();

    if (gainObjects != null) {
      List<PerceptionFilter.TypedSubject> newSubjects =
          new ArrayList<PerceptionFilter.TypedSubject>(gainObjects.size());

      for (ObjectNote gain : gainObjects) {
        IntHolder refCount = objectRefs.get(gain.subjectOid);
        if (refCount == null) {
          objectRefs.put(gain.subjectOid, new IntHolder(1));
          newSubjects.add(new PerceptionFilter.TypedSubject(gain.subjectOid, gain.objectType));
        } else refCount.count++;
      }

      if (newSubjects.size() > 0) {
        if (Log.loggingDebug) Log.debug("PerceptionTrigger adding " + newSubjects.size());
        filter.addSubjects(newSubjects);
      }
    }

    if (lostObjects == null) return;

    List<Long> freeOids = new ArrayList<Long>(lostObjects.size());

    for (ObjectNote lost : lostObjects) {
      IntHolder refCount = objectRefs.get(lost.subjectOid);
      if (refCount == null) Log.error("PerceptionTrigger: duplicate lost " + lost.subjectOid);
      else if (refCount.count == 1) {
        objectRefs.remove(lost.subjectOid);
        freeOids.add(lost.subjectOid);
      } else refCount.count--;
    }

    if (freeOids.size() > 0) {
      if (Log.loggingDebug) Log.debug("PerceptionTrigger removing " + freeOids.size());
      filter.removeSubjects(freeOids);
    }
  }
Ejemplo n.º 26
0
  protected void SetupVoiceGroup() {
    int error = 0;

    // Create a new voice chat group specific to this group that is non-positional
    error = VoiceClient.addVoiceGroup(this.GetGroupOid(), false, 4);
    if (error != VoiceClient.SUCCESS) {
      Log.error(
          "MarsGroup.SetupGroupVoice : Create Voice Group Response - "
              + VoiceClient.errorString(error));
    }
  }
Ejemplo n.º 27
0
 public void gotoSetup(Point dest, int speed) {
   // calculate the vector to the destination
   destLoc = dest;
   mobSpeed = speed;
   Point myLoc = obj.getWorldNode().getLoc();
   long oid = obj.getOid();
   if (Log.loggingDebug)
     Log.debug("BaseBehavior.gotoSetup: oid = " + oid + "; myLoc = " + myLoc + "; dest = " + dest);
   scheduleMe(
       setupPathInterpolator(oid, myLoc, dest, false, obj.getWorldNode().getFollowsTerrain()));
 }
Ejemplo n.º 28
0
  private static void saveProcessID(String svrName, String runDir) {
    Log.info("Server Name is " + svrName + " Run Dir is " + runDir);
    RuntimeMXBean rt = ManagementFactory.getRuntimeMXBean();
    String pid = rt.getName();
    if (Log.loggingDebug) {
      Log.info("PROCESS ID IS " + pid);
      Log.info("server name is " + svrName);
    }

    try {
      if (runDir != null) {
        File outFile = new File(runDir + "\\" + svrName + ".bat");
        PrintWriter out = new PrintWriter(new FileWriter(outFile));
        out.println("set pid=" + pid.substring(0, pid.indexOf("@")));
        out.close();
      }
    } catch (IOException e) {
      Log.exception("saveProcessID caught exception", e);
    }
  }
Ejemplo n.º 29
0
 public static void startRDPServer() {
   if (rdpServerStarted) return;
   rdpServerStarted = true;
   rdpServerThread = new Thread(rdpServer, "RDPServer");
   retryThread = new Thread(new RetryThread(), "RDPRetry");
   packetCallbackThread = new Thread(new PacketCallbackThread(), "RDPCallback");
   if (Log.loggingNet) Log.net("static - starting rdpserver thread");
   try {
     selector = Selector.open();
   } catch (Exception e) {
     Log.exception("RDPServer caught exception opening selector", e);
     System.exit(1);
   }
   rdpServerThread.setPriority(rdpServerThread.getPriority() + 2);
   if (Log.loggingDebug)
     Log.debug(
         "RDPServer: starting rdpServerThread with priority " + rdpServerThread.getPriority());
   rdpServerThread.start();
   retryThread.start();
   packetCallbackThread.start();
 }
Ejemplo n.º 30
0
 public boolean equals(Object obj) {
   int rv = this.compareTo(obj);
   if (Log.loggingNet)
     Log.net(
         "RDPServer.RDPConnectionData.equals: thisObj="
             + this.toString()
             + ", other="
             + obj.toString()
             + ", result="
             + rv);
   return (rv == 0);
 }