Package org.apache.hadoop.metrics2

Examples of org.apache.hadoop.metrics2.MetricsException


  }

  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


    currentServiceName = getFirstConfigPrefix(conf);

    databaseUrl = conf.getString(DATABASE_URL_KEY);

    if (databaseUrl == null)
      throw new MetricsException(
          "databaseUrl required in the metrics2 configuration for SqlServerSink.");

    try {
      Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
    } catch (ClassNotFoundException cnfe) {
      throw new MetricsException(
          "SqlServerSink requires the Microsoft JDBC driver for SQL Server.");
    }

    hadoopConfig = new org.apache.hadoop.conf.Configuration();
    if (hadoopConfig != null) {
View Full Code Here

      }
      else if (m instanceof MetricMutableCounter<?>) {
        ((MetricMutableCounter<?>) m).incr();
      }
      else {
        throw new MetricsException("Unsupported incr() for metric "+ name);
      }
    }
    else if (factory != null) {
      metricsMap.put(name, factory.newMetric(name));
      incr(name, null);
    }
    else {
      throw new MetricsException("Metric "+ name +" doesn't exist");
    }
  }
View Full Code Here

    if (m != null) {
      if (m instanceof MetricMutableGauge<?>) {
        ((MetricMutableGauge<?>) m).decr();
      }
      else {
        throw new MetricsException("Unsupported decr() for metric "+ name);
      }
    }
    else if (factory != null) {
      metricsMap.put(name, factory.newMetric(name));
      decr(name, null);
    }
    else {
      throw new MetricsException("Metric "+ name +" doesn't exist");
    }
  }
View Full Code Here

    if (m != null) {
      if (m instanceof MetricMutableStat) {
        ((MetricMutableStat) m).add(value);
      }
      else {
        throw new MetricsException("Unsupported add(value) for metric "+ name);
      }
    }
    else if (factory != null) {
      metricsMap.put(name, factory.newStat(name));
      add(name, value, null);
    }
    else {
      throw new MetricsException("Metric "+ name +" doesn't exist");
    }
  }
View Full Code Here

    return metricsMap.entrySet();
  }

  private void checkMetricName(String name) {
    if (metricsMap.containsKey(name)) {
      throw new MetricsException("Metric name "+ name +" already exists!");
    }
  }
View Full Code Here

    }
  }

  private void checkTagName(String name) {
    if (tagsMap.containsKey(name)) {
      throw new MetricsException("Tag "+ name +" already exists!");
    }
  }
View Full Code Here

            sb.setLength(sbBaseLen);
          }
        }
      }
    } catch (IOException io) {
      throw new MetricsException("Failed to putMetrics", io);
    }
  }
View Full Code Here

  @Override
  public synchronized void start() {
    Contracts.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) {
      LOG.warn(prefix +" metrics system not yet started!",
               new MetricsException("Illegal stop"));
      return;
    }
    for (Callback cb : callbacks) cb.preStop();
    LOG.info("Stopping "+ prefix +" metrics system...");
    stopTimer();
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.