Пример #1
0
 public void messageArrived(LoginBrokerInfo info) {
   StateUpdate update = new StateUpdate();
   addDoorInfo(
       update,
       PATH_TO_DOORS.newChild(info.getIdentifier()),
       info,
       TimeUnit.MILLISECONDS.toSeconds((long) (EXPIRATION_FACTOR * info.getUpdateTime())));
   _sum.enqueueUpdate(update);
 }
Пример #2
0
  /**
   * Add additional state-update to record information about a door.
   *
   * @param update the StateUpdate we are to add metrics to.
   * @param pathToDoor a StatePath under which we are to add data.
   * @param info the information about the door.
   * @param lifetime the duration, in seconds, for this information
   */
  private void addDoorInfo(
      StateUpdate update, StatePath pathToDoor, LoginBrokerInfo info, long lifetime) {
    StatePath pathToProtocol = pathToDoor.newChild("protocol");

    conditionalAddString(update, pathToProtocol, "engine", info.getProtocolEngine(), lifetime);
    conditionalAddString(update, pathToProtocol, "family", info.getProtocolFamily(), lifetime);
    conditionalAddString(update, pathToProtocol, "version", info.getProtocolVersion(), lifetime);
    conditionalAddString(update, pathToProtocol, "root", info.getRoot(), lifetime);

    update.appendUpdate(
        pathToDoor.newChild("load"), new FloatingPointStateValue(info.getLoad(), lifetime));
    update.appendUpdate(
        pathToDoor.newChild("port"), new IntegerStateValue(info.getPort(), lifetime));
    update.appendUpdate(
        pathToDoor.newChild("cell"), new StringStateValue(info.getCellName(), lifetime));
    update.appendUpdate(
        pathToDoor.newChild("domain"), new StringStateValue(info.getDomainName(), lifetime));
    update.appendUpdate(
        pathToDoor.newChild("update-time"), new IntegerStateValue(info.getUpdateTime(), lifetime));

    info.getAddresses()
        .stream()
        .forEach(i -> addInterfaceInfo(update, pathToDoor.newChild("interfaces"), i, lifetime));

    update.appendUpdateCollection(pathToDoor.newChild("tags"), info.getTags(), lifetime);
  }