Package org.apache.hadoop.metrics2

Examples of org.apache.hadoop.metrics2.MetricsException


        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

      try {
        IOUtils.closeStream(writer);
        writer = null;
        LOG.info("writer in GraphiteSink is closed!");
      } catch (Throwable e){
        throw new MetricsException("Error closing writer", e);
      } finally {
        if (socket != null && !socket.isClosed()) {
          socket.close();
          socket = null;
          LOG.info("socket in GraphiteSink is closed!");
View Full Code Here

  @Override
  public synchronized void start() {
    checkNotNull(prefix, "prefix");
    if (monitoring) {
      LOG.warn(prefix +" metrics system already started!",
               new MetricsException("Illegal start"));
      return;
    }
    for (Callback cb : callbacks) cb.preStart();
    configure(prefix);
    startTimer();
View Full Code Here

  @Override
  public synchronized void stop() {
    if (!monitoring && !DefaultMetricsSystem.inMiniClusterMode()) {
      LOG.warn(prefix +" metrics system not yet started!",
               new MetricsException("Illegal stop"));
      return;
    }
    if (!monitoring) {
      // in mini cluster mode
      LOG.info(prefix +" metrics system stopped (again)");
View Full Code Here

      boolean extended, boolean returnExisting) {
    if (returnExisting) {
      MutableMetric rate = metricsMap.get(name);
      if (rate != null) {
        if (rate instanceof MutableRate) return (MutableRate) rate;
        throw new MetricsException("Unexpected metrics type "+ rate.getClass()
                                   +" for "+ name);
      }
    }
    MutableRate ret = new MutableRate(name, desc, extended);
    return addNewMetricIfAbsent(name, ret, MutableRate.class);
View Full Code Here

    if (m != null) {
      if (m instanceof MutableStat) {
        ((MutableStat) m).add(value);
      }
      else {
        throw new MetricsException("Unsupported add(value) for metric "+ name);
      }
    }
    else {
      metricsMap.put(name, newRate(name)); // default is a rate metric
      add(name, value);
View Full Code Here

    MetricsTag tag = Interns.tag(info, value);

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

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

        return newGauge;
      }
    }

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

    return (MutableGaugeLong) metric;
  }
View Full Code Here

TOP

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

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.