Examples of OpTimer


Examples of org.apache.accumulo.core.util.OpTimer

        public void run() {
          NativeMap nm = new NativeMap();
         
          Random r = new Random();
         
          OpTimer opTimer = new OpTimer(log, Level.INFO);
         
          opTimer.start("Creating map of size " + mapSizePerThread);
         
          for (int i = 0; i < mapSizePerThread; i++) {
            String row = String.format("r%08d", i);
            String val = row + "v";
            put(nm, row, val, i);
          }
         
          opTimer.stop("Created map of size " + nm.size() + " in %DURATION%");
         
          opTimer.start("Doing " + getsPerThread + " gets()");
         
          for (int i = 0; i < getsPerThread; i++) {
            String row = String.format("r%08d", r.nextInt(mapSizePerThread));
            String val = row + "v";
           
            Value value = nm.get(new Key(new Text(row)));
            if (value == null || !value.toString().equals(val)) {
              log.error("nm.get(" + row + ") failed");
            }
          }
         
          opTimer.stop("Finished " + getsPerThread + " gets in %DURATION%");
         
          int scanned = 0;
         
          opTimer.start("Doing " + getsPerThread + " random iterations");
         
          for (int i = 0; i < getsPerThread; i++) {
            int startRow = r.nextInt(mapSizePerThread);
            String row = String.format("r%08d", startRow);
           
            Iterator<Entry<Key,Value>> iter = nm.iterator(new Key(new Text(row)));
           
            int count = 0;
           
            while (iter.hasNext() && count < 10) {
              String row2 = String.format("r%08d", startRow + count);
              String val2 = row2 + "v";
             
              Entry<Key,Value> entry = iter.next();
              if (!entry.getValue().toString().equals(val2) || !entry.getKey().equals(new Key(new Text(row2)))) {
                log.error("nm.iter(" + row2 + ") failed row = " + row + " count = " + count + " row2 = " + row + " val2 = " + val2);
              }
             
              count++;
            }
           
            scanned += count;
          }
         
          opTimer.stop("Finished " + getsPerThread + " random iterations (scanned = " + scanned + ") in %DURATION%");
         
          nm.delete();
        }
      };
     
View Full Code Here

Examples of org.apache.accumulo.core.util.OpTimer

  @Override
  public String getRootTabletLocation() {
    String zRootLocPath = ZooUtil.getRoot(this) + Constants.ZROOT_TABLET_LOCATION;

    OpTimer opTimer = new OpTimer(log, Level.TRACE).start("Looking up root tablet location in zoocache.");

    byte[] loc = zooCache.get(zRootLocPath);

    opTimer.stop("Found root tablet at " + (loc == null ? null : new String(loc, Constants.UTF8)) + " in %DURATION%");

    if (loc == null) {
      return null;
    }
View Full Code Here

Examples of org.apache.accumulo.core.util.OpTimer

  @Override
  public List<String> getMasterLocations() {

    String masterLocPath = ZooUtil.getRoot(this) + Constants.ZMASTER_LOCK;

    OpTimer opTimer = new OpTimer(log, Level.TRACE).start("Looking up master location in zoocache.");

    byte[] loc = ZooLock.getLockData(zooCache, masterLocPath, null);

    opTimer.stop("Found master at " + (loc == null ? null : new String(loc, Constants.UTF8)) + " in %DURATION%");

    if (loc == null) {
      return Collections.emptyList();
    }
View Full Code Here

Examples of org.apache.accumulo.core.util.OpTimer

  @Override
  public List<String> getMasterLocations() {
    String masterLocPath = ZooUtil.getRoot(this) + Constants.ZMASTER_LOCK;

    OpTimer opTimer = new OpTimer(log, Level.TRACE).start("Looking up master location in zoocache.");
    byte[] loc = ZooUtil.getLockData(zooCache, masterLocPath);
    opTimer.stop("Found master at " + (loc == null ? null : new String(loc, Constants.UTF8)) + " in %DURATION%");

    if (loc == null) {
      return Collections.emptyList();
    }
View Full Code Here

Examples of org.apache.accumulo.core.util.OpTimer

  @Override
  public String getRootTabletLocation() {
    String zRootLocPath = ZooUtil.getRoot(this) + Constants.ZROOT_TABLET_LOCATION;

    OpTimer opTimer = new OpTimer(log, Level.TRACE).start("Looking up root tablet location in zookeeper.");
    byte[] loc = zooCache.get(zRootLocPath);
    opTimer.stop("Found root tablet at " + (loc == null ? null : new String(loc, Constants.UTF8)) + " in %DURATION%");

    if (loc == null) {
      return null;
    }
View Full Code Here

Examples of org.apache.accumulo.core.util.OpTimer

   *
   * @return List of tables in accumulo
   */
  @Override
  public SortedSet<String> list() {
    OpTimer opTimer = new OpTimer(log, Level.TRACE).start("Fetching list of tables...");
    TreeSet<String> tableNames = new TreeSet<String>(Tables.getNameToIdMap(instance).keySet());
    opTimer.stop("Fetched " + tableNames.size() + " table names in %DURATION%");
    return tableNames;
  }
View Full Code Here

Examples of org.apache.accumulo.core.util.OpTimer

  public boolean exists(String tableName) {
    ArgumentChecker.notNull(tableName);
    if (tableName.equals(Constants.METADATA_TABLE_NAME))
      return true;

    OpTimer opTimer = new OpTimer(log, Level.TRACE).start("Checking if table " + tableName + "exists...");
    boolean exists = Tables.getNameToIdMap(instance).containsKey(tableName);
    opTimer.stop("Checked existance of " + exists + " in %DURATION%");
    return exists;
  }
View Full Code Here

Examples of org.apache.accumulo.core.util.OpTimer

        }

        try {
          TabletClientService.Client client = ThriftUtil.getTServerClient(tl.tablet_location, instance.getConfiguration());
          try {
            OpTimer opTimer = null;
            if (log.isTraceEnabled())
              opTimer = new OpTimer(log, Level.TRACE).start("Splitting tablet " + tl.tablet_extent + " on " + tl.tablet_location + " at " + split);

            client.splitTablet(Tracer.traceInfo(), credentials, tl.tablet_extent.toThrift(), TextUtil.getByteBuffer(split));

            // just split it, might as well invalidate it in the cache
            tabLocator.invalidateCache(tl.tablet_extent);

            if (opTimer != null)
              opTimer.stop("Split tablet in %DURATION%");
          } finally {
            ThriftUtil.returnClient(client);
          }

        } catch (TApplicationException tae) {
View Full Code Here

Examples of org.apache.accumulo.core.util.OpTimer

 
  @Override
  public void binMutations(List<Mutation> mutations, Map<String,TabletServerMutations> binnedMutations, List<Mutation> failures, TCredentials credentials) throws AccumuloException,
      AccumuloSecurityException, TableNotFoundException {
   
    OpTimer opTimer = null;
    if (log.isTraceEnabled())
      opTimer = new OpTimer(log, Level.TRACE).start("Binning " + mutations.size() + " mutations for table " + tableId);
   
    ArrayList<Mutation> notInCache = new ArrayList<Mutation>();
    Text row = new Text();
   
    rLock.lock();
    try {
      processInvalidated(credentials);
     
      // for this to be efficient rows need to be in sorted order, but always sorting is slow... therefore only sort the
      // stuff not in the cache.... it is most efficient to pass _locateTablet rows in sorted order
     
      // For this to be efficient, need to avoid fine grained synchronization and fine grained logging.
      // Therefore methods called by this are not synchronized and should not log.
     
      for (Mutation mutation : mutations) {
        row.set(mutation.getRow());
        TabletLocation tl = locateTabletInCache(row);
        if (tl == null)
          notInCache.add(mutation);
        else
          addMutation(binnedMutations, mutation, tl);
       
      }
    } finally {
      rLock.unlock();
    }
   
    if (notInCache.size() > 0) {
      Collections.sort(notInCache, new Comparator<Mutation>() {
        public int compare(Mutation o1, Mutation o2) {
          return WritableComparator.compareBytes(o1.getRow(), 0, o1.getRow().length, o2.getRow(), 0, o2.getRow().length);
        }
      });
     
      wLock.lock();
      try {
        boolean failed = false;
        for (Mutation mutation : notInCache) {
          if (failed) {
            // when one table does not return a location, something is probably
            // screwy, go ahead and fail everything.
            failures.add(mutation);
            continue;
          }
         
          row.set(mutation.getRow());
         
          TabletLocation tl = _locateTablet(row, false, false, false, credentials);
         
          if (tl == null) {
            failures.add(mutation);
            failed = true;
          } else {
            addMutation(binnedMutations, mutation, tl);
          }
        }
      } finally {
        wLock.unlock();
      }
    }
   
    if (opTimer != null)
      opTimer.stop("Binned " + mutations.size() + " mutations for table " + tableId + " to " + binnedMutations.size() + " tservers in %DURATION%");
  }
View Full Code Here

Examples of org.apache.accumulo.core.util.OpTimer

    /*
     * For this to be efficient, need to avoid fine grained synchronization and fine grained logging. Therefore methods called by this are not synchronized and
     * should not log.
     */
   
    OpTimer opTimer = null;
    if (log.isTraceEnabled())
      opTimer = new OpTimer(log, Level.TRACE).start("Binning " + ranges.size() + " ranges for table " + tableId);
   
    List<Range> failures;
    rLock.lock();
    try {
      processInvalidated(credentials);
     
      // for this to be optimal, need to look ranges up in sorted order when
      // ranges are not present in cache... however do not want to always
      // sort ranges... therefore try binning ranges using only the cache
      // and sort whatever fails and retry
     
      failures = binRanges(ranges, binnedRanges, true, credentials);
    } finally {
      rLock.unlock();
    }
   
    if (failures.size() > 0) {
      // sort failures by range start key
      Collections.sort(failures);
     
      // try lookups again
      wLock.lock();
      try {
        failures = binRanges(failures, binnedRanges, false, credentials);
      } finally {
        wLock.unlock();
      }
    }
   
    if (opTimer != null)
      opTimer.stop("Binned " + ranges.size() + " ranges for table " + tableId + " to " + binnedRanges.size() + " tservers in %DURATION%");
   
    return failures;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.