Package com.brienwheeler.lib.io

Examples of com.brienwheeler.lib.io.ReconnectingSocket


    @Override
  public void onStart()
  {
    if (!hostname.isEmpty()) {
      ReconnectingSocket reconnectingSocket = new ReconnectingSocket(hostname, port, log);
      reconnectingSocket.start();
      this.reconnectingSocket.set(reconnectingSocket);
    }
  }
View Full Code Here


  }

  @Override
  public void onStop(long stopGracePeriod)
  {
    ReconnectingSocket socket = reconnectingSocket.getAndSet(null);
    if (socket != null)
      socket.stop();
  }
View Full Code Here

  }
 
  @Override
  public void process(TelemetryInfo telemetryInfo)
  {
    ReconnectingSocket socket = reconnectingSocket.get();
    if (socket == null || !socket.isConnected())
      return;

        String name = telemetryInfo.getName();
        if (globalRedact != null) {
            name = name.replace(globalRedact, "");
        }
        if (globalPrefix != null) {
            name = (globalPrefix + ".") + name;
        }

    long createdAt = telemetryInfo.getCreatedAt() / 1000; // Graphite uses UNIX epoch

    StringBuffer data = new StringBuffer(256);
    for (String attrName : telemetryInfo.getAttributeNames()) {
            // we never care about NAME or CREATED_AT
      if (attrName.equals(TelemetryInfo.ATTR_NAME) || attrName.equals(TelemetryInfo.ATTR_CREATED_AT))
        continue;

            // allow a chance to filter out based on attrName too (FilteringTelemetryInfoProcessor
            // can only filter on telemetryInfo.name)
            String statisticName = name + "." + attrName;
            if (!telemetryNameFilter.process(statisticName))
                continue;

      Object attrValue = telemetryInfo.get(attrName);
      if (attrValue instanceof Double || attrValue instanceof Float ||
          attrValue instanceof Integer || attrValue instanceof Long) {
        data.setLength(0);
        data.append(statisticName);
        data.append(" ").append(attrValue.toString());
        data.append(" ").append(createdAt).append("\n");
        String dataStr = data.toString();
        socket.write(dataStr);
        log.debug(dataStr);
      }
    }
  }
View Full Code Here

TOP

Related Classes of com.brienwheeler.lib.io.ReconnectingSocket

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.