Package org.apache.hadoop.metrics2

Examples of org.apache.hadoop.metrics2.AbstractMetric


    MetricsTag tag = new MetricsTag(name, description, value);

    if (!override) {
      MetricsTag existing = tagsMap.putIfAbsent(name, tag);
      if (existing != null) {
        throw new MetricsException("Tag " + name + " already exists!");
      }
      return this;
    }

    tagsMap.put(name, tag);
View Full Code Here


        return newGauge;
      }
    }

    if (!(metric instanceof MetricMutableGaugeLong)) {
      throw new MetricsException(
          "Metric already exists in registry for metric name: " + name
              + " and not of type MetricMutableGaugeLong");
    }

    return (MetricMutableGaugeLong) metric;
View Full Code Here

        return newCounter;
      }
    }

    if (!(counter instanceof MetricMutableCounterLong)) {
      throw new MetricsException(
          "Metric already exists in registry for metric name: " + name
              + "and not of type MetricMutableCounterLong");
    }

    return (MetricMutableCounterLong) counter;
View Full Code Here

        return newHisto;
      }
    }

    if (!(histo instanceof MetricMutableHistogram)) {
      throw new MetricsException(
          "Metric already exists in registry for metric name: " + name
              + "and not of type MetricMutableHistogram");
    }

    return (MetricMutableHistogram) histo;
View Full Code Here

        return newHisto;
      }
    }

    if (!(histo instanceof MetricMutableQuantiles)) {
      throw new MetricsException(
          "Metric already exists in registry for metric name: " + name
              + "and not of type MetricMutableQuantiles");
    }

    return (MetricMutableQuantiles) histo;
View Full Code Here

  }

  private <T> T returnExistingWithCast(MetricMutable metric,
      Class<T> metricClass, String name) {
    if (!metricClass.isAssignableFrom(metric.getClass())) {
      throw new MetricsException(
          "Metric already exists in registry for metric name: " + name
              + " and not of type " + metricClass);
    }

    return (T) metric;
View Full Code Here

      writer = filename == null
          ? new PrintWriter(System.out)
          : new PrintWriter(new FileWriter(new File(filename), true));
    }
    catch (Exception e) {
      throw new MetricsException("Error creating "+ filename, e);
    }
  }
View Full Code Here

        try {
            // Open an connection to Graphite server.
            socket = new Socket(serverHost, serverPort);
            writer = new OutputStreamWriter(socket.getOutputStream());
        } catch (Exception e) {
            throw new MetricsException("Error creating connection, "
                    + serverHost + ":" + serverPort, e);
        }
    }
View Full Code Here

        try {
            if(writer != null){
              writer.write(lines.toString());
            } else {
              throw new MetricsException("Writer in GraphiteSink is null!");
            }
        } catch (Exception e) {
            throw new MetricsException("Error sending metrics", e);
        }
    }
View Full Code Here

    @Override
    public void flush() {
        try {
            writer.flush();
        } catch (Exception e) {
            throw new MetricsException("Error flushing metrics", e);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.metrics2.AbstractMetric

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.