Package org.apache.accumulo.cloudtrace.instrument

Examples of org.apache.accumulo.cloudtrace.instrument.Span


    TTransport clientTransport = new TSocket(new Socket("localhost", socket.getLocalPort()));
    TestService.Iface client = new TestService.Client(new TBinaryProtocol(clientTransport), new TBinaryProtocol(clientTransport));
    client = TraceWrap.client(client);
    assertFalse(client.checkTrace(null, "test"));
   
    Span start = Trace.on("start");
    assertTrue(client.checkTrace(null, "my test"));
    start.stop();
   
    assertNotNull(tracer.traces.get(start.traceId()));
    String traces[] = {"my test", "checkTrace", "client:checkTrace", "start"};
    assertTrue(tracer.traces.get(start.traceId()).size() == traces.length);
    for (int i = 0; i < traces.length; i++)
      assertEquals(traces[i], tracer.traces.get(start.traceId()).get(i).description);
   
    tserver.stop();
    t.join(100);
  }
View Full Code Here


  }
 
  static class Service implements TestService.Iface {
    @Override
    public boolean checkTrace(TInfo t, String message) throws TException {
      Span trace = Trace.start(message);
      try {
        return Trace.isTracing();
      } finally {
        trace.stop();
      }
    }
View Full Code Here

      Long x = new Long(i);
    }
    System.out.println(String.format("Trivial took %d millis", System.currentTimeMillis() - now));
    now = System.currentTimeMillis();
    for (long i = 0; i < 1000 * 1000; i++) {
      Span s = Trace.start("perf");
      s.stop();
    }
    System.out.println(String.format("Span Loop took %d millis", System.currentTimeMillis() - now));
    now = System.currentTimeMillis();
    Trace.on("test");
    for (long i = 0; i < 1000 * 1000; i++) {
      Span s = Trace.start("perf");
      s.stop();
    }
    Trace.off();
    System.out.println(String.format("Trace took %d millis", System.currentTimeMillis() - now));
  }
View Full Code Here

  }
 
  private void compactLocalityGroup(String lgName, Set<ByteSequence> columnFamilies, boolean inclusive, FileSKVWriter mfw, CompactionStats majCStats)
      throws IOException, CompactionCanceledException {
    ArrayList<FileSKVIterator> readers = new ArrayList<FileSKVIterator>(filesToCompact.size());
    Span span = Trace.start("compact");
    try {
      long entriesCompacted = 0;
      List<SortedKeyValueIterator<Key,Value>> iters = openMapDataFiles(lgName, readers);
     
      if (imm != null) {
        iters.add(imm.compactionIterator());
      }
     
      CountingIterator citr = new CountingIterator(new MultiIterator(iters, extent.toDataRange()));
      DeletingIterator delIter = new DeletingIterator(citr, propogateDeletes);
      ColumnFamilySkippingIterator cfsi = new ColumnFamilySkippingIterator(delIter);
     

      // if(env.getIteratorScope() )
     
      TabletIteratorEnvironment iterEnv;
      if (env.getIteratorScope() == IteratorScope.majc)
        iterEnv = new TabletIteratorEnvironment(IteratorScope.majc, !propogateDeletes, acuTableConf);
      else if (env.getIteratorScope() == IteratorScope.minc)
        iterEnv = new TabletIteratorEnvironment(IteratorScope.minc, acuTableConf);
      else
        throw new IllegalArgumentException();
     
      SortedKeyValueIterator<Key,Value> itr = iterEnv.getTopLevelIterator(IteratorUtil.loadIterators(env.getIteratorScope(), cfsi, extent, acuTableConf,
          iterEnv));
     
      itr.seek(extent.toDataRange(), columnFamilies, inclusive);
     
      if (!inclusive) {
        mfw.startDefaultLocalityGroup();
      } else {
        mfw.startNewLocalityGroup(lgName, columnFamilies);
      }
     
      Span write = Trace.start("write");
      try {
        while (itr.hasTop() && env.isCompactionEnabled()) {
          mfw.append(itr.getTopKey(), itr.getTopValue());
          itr.next();
          entriesCompacted++;
        }
       
        if (itr.hasTop() && !env.isCompactionEnabled()) {
          // cancel major compaction operation
          try {
            try {
              mfw.close();
            } catch (IOException e) {
              log.error(e, e);
            }
            fs.delete(new Path(outputFile), true);
          } catch (Exception e) {
            log.warn("Failed to delete Canceled compaction output file " + outputFile, e);
          }
          throw new CompactionCanceledException();
        }
       
      } finally {
        CompactionStats lgMajcStats = new CompactionStats(citr.getCount(), entriesCompacted);
        majCStats.add(lgMajcStats);
        write.stop();
      }
     
    } finally {
      // close sequence files opened
      for (FileSKVIterator reader : readers) {
View Full Code Here

     
      private void writeSortedEntries(Path dest, int part, final List<Pair<LogFileKey,LogFileValue>> kv) throws IOException {
        String path = dest + String.format("/part-r-%05d", part);
        log.debug("Writing partial log file to DSF " + path);
        log.debug("Sorting");
        Span span = Trace.start("Logger sort");
        span.data("logfile", dest.getName());
        Collections.sort(kv, new Comparator<Pair<LogFileKey,LogFileValue>>() {
          @Override
          public int compare(Pair<LogFileKey,LogFileValue> o1, Pair<LogFileKey,LogFileValue> o2) {
            return o1.getFirst().compareTo(o2.getFirst());
          }
        });
        span.stop();
        span = Trace.start("Logger write");
        span.data("logfile", dest.getName());
        MapFile.Writer writer = new MapFile.Writer(fs.getConf(), fs, path, LogFileKey.class, LogFileValue.class);
        short replication = (short) acuConf.getCount(Property.LOGGER_RECOVERY_FILE_REPLICATION);
        fs.setReplication(new Path(path + "/" + MapFile.DATA_FILE_NAME), replication);
        fs.setReplication(new Path(path + "/" + MapFile.INDEX_FILE_NAME), replication);
        try {
          for (Pair<LogFileKey,LogFileValue> entry : kv)
            writer.append(entry.getFirst(), entry.getSecond());
        } finally {
          writer.close();
          span.stop();
        }
      }
     
      private void copyLog(final String localLog, final String fullyQualifiedFileName) throws IOException {
        Path dest = new Path(fullyQualifiedFileName + ".copy");
View Full Code Here


public class TraceFSDataInputStream extends FSDataInputStream {
  @Override
  public synchronized void seek(long desired) throws IOException {
    Span span = Trace.start("FSDataInputStream.seek");
    try {
      impl.seek(desired);
    } finally {
      span.stop();
    }
  }
View Full Code Here

    }
  }
 
  @Override
  public int read(long position, byte[] buffer, int offset, int length) throws IOException {
    Span span = Trace.start("FSDataInputStream.read");
    if (Trace.isTracing())
      span.data("length", Integer.toString(length));
    try {
      return impl.read(position, buffer, offset, length);
    } finally {
      span.stop();
    }
  }
View Full Code Here

    }
  }
 
  @Override
  public void readFully(long position, byte[] buffer, int offset, int length) throws IOException {
    Span span = Trace.start("FSDataInputStream.readFully");
    if (Trace.isTracing())
      span.data("length", Integer.toString(length));
    try {
      impl.readFully(position, buffer, offset, length);
    } finally {
      span.stop();
    }
  }
View Full Code Here

    }
  }
 
  @Override
  public void readFully(long position, byte[] buffer) throws IOException {
    Span span = Trace.start("FSDataInputStream.readFully");
    if (Trace.isTracing())
      span.data("length", Integer.toString(buffer.length));
    try {
      impl.readFully(position, buffer);
    } finally {
      span.stop();
    }
  }
View Full Code Here

    }
  }
 
  @Override
  public boolean seekToNewSource(long targetPos) throws IOException {
    Span span = Trace.start("FSDataInputStream.seekToNewSource");
    try {
      return impl.seekToNewSource(targetPos);
    } finally {
      span.stop();
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.accumulo.cloudtrace.instrument.Span

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.