/** Get the Transport Metric for a specific Transport Type */
  public TransportMetric getTransportMetric(String protocol, EndpointAddress endpointAddress) {
    for (Iterator i = transportMetrics.iterator(); i.hasNext(); ) {
      TransportMetric transportMetric = (TransportMetric) i.next();
      if (protocol.equals(transportMetric.getProtocol())
          && endpointAddress.equals(transportMetric.getEndpointAddress())) return transportMetric;
    }

    return null;
  }
  /** {@inheritDoc} */
  public void serializeTo(Element element) throws DocumentSerializationException {
    for (Iterator i = transportMetrics.iterator(); i.hasNext(); ) {
      TransportMetric transportMetric = (TransportMetric) i.next();

      DocumentSerializableUtilities.addDocumentSerializable(
          element, "transportMetric", transportMetric);
    }
    if (moduleClassID != null) {
      DocumentSerializableUtilities.addString(element, "moduleClassID", moduleClassID.toString());
    }
  }
Example #3
0
  /** {@inheritDoc} */
  public void serializeTo(Element element) throws DocumentSerializationException {
    DocumentSerializableUtilities.addString(element, "description", description);

    for (Iterator i = serviceMonitorFilters.values().iterator(); i.hasNext(); ) {
      ServiceMonitorFilter serviceMonitorFilter = (ServiceMonitorFilter) i.next();

      Element serviceElement = DocumentSerializableUtilities.createChildElement(element, "service");

      DocumentSerializableUtilities.addString(
          serviceElement, "moduleClassID", serviceMonitorFilter.getModuleClassID().toString());
      DocumentSerializableUtilities.addDocumentSerializable(
          serviceElement, "serviceFilter", serviceMonitorFilter);
    }
  }
  /**
   * Make a shallow copy of this metric only including the portions designated in the Filter
   *
   * <p>Note: since this is a shallow copy it is dangerous to modify the submetrics
   *
   * @param transportServiceMonitorFilter Filter designates constituant parts to be included
   * @return a copy of this metric with references to the designated parts
   */
  public TransportServiceMetric shallowCopy(
      TransportServiceMonitorFilter transportServiceMonitorFilter) {
    TransportServiceMetric serviceMetric = new TransportServiceMetric();
    serviceMetric.moduleClassID = moduleClassID;

    for (Iterator i = getTransportMetrics(); i.hasNext(); ) {
      TransportMetric transportMetric = (TransportMetric) i.next();
      String protocol = transportMetric.getProtocol();

      if (transportServiceMonitorFilter.hasTransport(protocol))
        serviceMetric.addTransportMetric(transportMetric);
    }

    return serviceMetric;
  }
  public void mergeMetrics(
      ServiceMetric serviceMetric, TransportServiceMonitorFilter transportServiceMonitorFilter) {
    TransportServiceMetric otherTransportServiceMetric = (TransportServiceMetric) serviceMetric;

    for (Iterator i = otherTransportServiceMetric.getTransportMetrics(); i.hasNext(); ) {
      TransportMetric otherTransportMetric = (TransportMetric) i.next();
      String protocol = otherTransportMetric.getProtocol();

      if ((transportServiceMonitorFilter == null)
          || transportServiceMonitorFilter.hasTransport(protocol)) {
        TransportMetric transportMetric =
            getTransportMetric(
                otherTransportMetric.getProtocol(), otherTransportMetric.getEndpointAddress());

        if (transportMetric == null) {
          transportMetric = new TransportMetric(otherTransportMetric);
          addTransportMetric(transportMetric);
        }

        transportMetric.mergeMetrics(otherTransportMetric);
      }
    }
  }