Package org.apache.hadoop.hbase.regionserver.wal

Examples of org.apache.hadoop.hbase.regionserver.wal.HLog$Metric


    Path regionDir = HRegion.getRegionDir(tableDir, info.getEncodedName());
    FileSystem fs = FileSystem.get(conf);
    HBaseFileSystem.makeDirOnFileSystem(fs, regionDir);
    // Write HRI to a file in case we need to recover .META.
    writeRegioninfoOnFilesystem(info, regionDir, fs, conf);
    HLog effectiveHLog = hlog;
    if (hlog == null && !ignoreHLog) {
      effectiveHLog = new HLog(fs, new Path(regionDir, HConstants.HREGION_LOGDIR_NAME),
          new Path(regionDir, HConstants.HREGION_OLDLOGDIR_NAME), conf);
    }
    HRegion region = HRegion.newHRegion(tableDir,
        effectiveHLog, fs, conf, info, hTableDescriptor, null);
    if (initialize) {
View Full Code Here


      listPaths(fs, b.getRegionDir());
    }

    Configuration conf = a.getBaseConf();
    HTableDescriptor tabledesc = a.getTableDesc();
    HLog log = a.getLog();
    Path tableDir = a.getTableDir();
    // Presume both are of same region type -- i.e. both user or catalog
    // table regions.  This way can use comparator.
    final byte[] startKey =
      (a.comparator.matchingRows(a.getStartKey(), 0, a.getStartKey().length,
View Full Code Here

    final Path logdir = new Path(c.get("hbase.tmp.dir"),
        "hlog" + tableDir.getName()
        + EnvironmentEdgeManager.currentTimeMillis());
    final Path oldLogDir = new Path(c.get("hbase.tmp.dir"),
        HConstants.HREGION_OLDLOGDIR_NAME);
    final HLog log = new HLog(fs, logdir, oldLogDir, c);
    try {
      processTable(fs, tableDir, log, c, majorCompact);
    } finally {
       log.close();
       // TODO: is this still right?
       BlockCache bc = new CacheConfig(c).getBlockCache();
       if (bc != null) bc.shutdown();
    }
  }
View Full Code Here

  public void testPutMetrics() throws Exception {
    SubsetConfiguration configuration = createNiceMock(SubsetConfiguration.class);
    Connection connection = createNiceMock(Connection.class);
    CallableStatement cstmt = createNiceMock(CallableStatement.class);
    MetricsRecord record = createNiceMock(MetricsRecord.class);
    Metric metric = createNiceMock(Metric.class);

    // set expectations
    expect(configuration.getParent()).andReturn(null);
    expect(configuration.getPrefix()).andReturn("prefix");
    expect(configuration.getString("databaseUrl")).andReturn("url");

    expect(record.context()).andReturn("context");
    expect(record.name()).andReturn("typeName");
    expect(record.tags()).andReturn(new HashSet<MetricsTag>());
    expect(record.timestamp()).andReturn(9999L);

    expect(record.metrics()).andReturn(Collections.singleton(metric));

    expect(metric.name()).andReturn("name").anyTimes();
    expect(metric.value()).andReturn(1234);

    expect(connection.prepareCall("{call dbo.uspGetMetricRecord(?, ?, ?, ?, ?, ?, ?, ?, ?)}")).andReturn(cstmt);
    cstmt.setNString(1, "context");
    cstmt.setNString(2, "typeName");
    cstmt.setNString(eq(3), (String) anyObject());
View Full Code Here

    public void testPutMetrics() throws Exception {
        SubsetConfiguration configuration = createNiceMock(SubsetConfiguration.class);
        Connection connection = createNiceMock(Connection.class);
        CallableStatement cstmt = createNiceMock(CallableStatement.class);
        MetricsRecord record = createNiceMock(MetricsRecord.class);
        Metric metric = createNiceMock(Metric.class);

        // set expectations
        expect(configuration.getParent()).andReturn(null);
        expect(configuration.getPrefix()).andReturn("prefix");
        expect(configuration.getString("databaseUrl")).andReturn("url");

        expect(record.context()).andReturn("context");
        expect(record.name()).andReturn("typeName");
        expect(record.tags()).andReturn(new HashSet<MetricsTag>());
        expect(record.timestamp()).andReturn(9999L);

        expect(record.metrics()).andReturn(Collections.singleton(metric));

        expect(metric.name()).andReturn("name").anyTimes();
        expect(metric.value()).andReturn(1234);

        expect(connection.prepareCall("{call dbo.uspGetMetricRecord(?, ?, ?, ?, ?, ?, ?, ?, ?)}")).andReturn(cstmt);
        cstmt.setNString(1, "context");
        cstmt.setNString(2, "typeName");
        cstmt.setNString(eq(3), (String) anyObject());
View Full Code Here

  private MetricsTag makeTag(String name, String value) {
    return new MetricsTag(name, "", value);
  }

  private Metric makeMetric(String name, Number value) {
    Metric metric = mock(Metric.class);
    when(metric.name()).thenReturn(name);
    when(metric.value()).thenReturn(value);
    return metric;
  }
View Full Code Here

        // and get the updated data
        cachedMetrics = metricsCache.update(record);

        if (cachedMetrics != null && cachedMetrics.metricsEntrySet() != null) {
          for (Map.Entry<String, Metric> entry : cachedMetrics.metricsEntrySet()) {
            Metric metric = entry.getValue();
            sb.append(metric.name());
            String name = sb.toString();

            // visit the metric to identify the Ganglia type and slope
            metric.visit(gangliaMetricVisitor);
            type = gangliaMetricVisitor.getType();
            slopeFromMetric = gangliaMetricVisitor.getSlope();


            GangliaConf gConf = getGangliaConfForMetric(name);
            calculatedSlope = calculateSlope(gConf, slopeFromMetric);

            // send metric to Ganglia
            emitMetric(groupName, name, type, metric.value().toString(),
                gConf, calculatedSlope);

            // reset the length of the buffer for next iteration
            sb.setLength(sbBaseLen);
          }
        }
      } else {
        // we support sparse updates

        Collection<Metric> metrics = (Collection<Metric>) record.metrics();
        if (metrics.size() > 0) {
          // we got metrics. so send the latest
          for (Metric metric : record.metrics()) {
            sb.append(metric.name());
            String name = sb.toString();

            // visit the metric to identify the Ganglia type and slope
            metric.visit(gangliaMetricVisitor);
            type = gangliaMetricVisitor.getType();
            slopeFromMetric = gangliaMetricVisitor.getSlope();


            GangliaConf gConf = getGangliaConfForMetric(name);
            calculatedSlope = calculateSlope(gConf, slopeFromMetric);

            // send metric to Ganglia
            emitMetric(groupName, name, type, metric.value().toString(),
                gConf, calculatedSlope);

            // reset the length of the buffer for next iteration
            sb.setLength(sbBaseLen);
          }
View Full Code Here

      final Iterator<Metric> it = delegate.metrics().iterator();
      public Iterator<Metric> iterator() {
        return new TryIterator<Metric>() {
          public Metric tryNext() {
            if (it.hasNext()) do {
              Metric next = it.next();
              if (filter.accepts(next.name())) {
                return next;
              }
            } while (it.hasNext());
            return done();
          }
View Full Code Here

     * Get the metric value
     * @param key name of the metric
     * @return the metric value
     */
    public Number getMetric(String key) {
      Metric metric = metrics.get(key);
      return metric != null ? metric.value() : null;
    }
View Full Code Here

  private MetricsTag makeTag(String name, String value) {
    return new MetricsTag(name, "", value);
  }

  private Metric makeMetric(String name, Number value) {
    Metric metric = mock(Metric.class);
    when(metric.name()).thenReturn(name);
    when(metric.value()).thenReturn(value);
    return metric;
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.regionserver.wal.HLog$Metric

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.