Examples of TimerContext


Examples of com.nokia.dempsy.monitoring.StatsCollector.TimerContext

   }
  
   @Test
   public void testOutputCycleTiming() throws Throwable
   {
      TimerContext ctx = stats.outputInvokeStarted();
      Thread.sleep(100);
      ctx.stop();
      long val = getStatValue(stats, StatsCollectorCoda.GAGE_LAST_OUTPUT_MILLIS);
      assertTrue(val >= 100);
   }
View Full Code Here

Examples of com.yammer.metrics.core.TimerContext

                int eastings = Integer.parseInt(entry.getEastings());
                int northings = Integer.parseInt(entry.getNorthings());

                unit.cartesianLocation = new CartesianLocation(eastings, northings);

                final TimerContext latLongCtx = latLongTransform.time();
                try {
                    DirectPosition eastNorth = new GeneralDirectPosition(eastings, northings);
                    DirectPosition latLng = osgbToWgs84Transform.transform(eastNorth, eastNorth);

                    unit.location = new Location(round(latLng.getOrdinate(1), 8), round(latLng.getOrdinate(0), 8));
                } finally {
                    latLongCtx.stop();
                }
            } catch (NumberFormatException e) {
                throw new RuntimeException("NumberFormatException parsing easting/northings '" + entry.getEastings() + ", " + entry.getNorthings() + "'.");
            } catch (TransformException e) {
                throw Throwables.propagate(e);
            }

            final TimerContext saveCtx = savePostcodeUnit.time();
            try {
                unit.save();

                postcodesProcessed.inc();
            } catch (MongoException.DuplicateKey e) {
                // ignore
            } finally {
                saveCtx.stop();
            }
        }
    }
View Full Code Here

Examples of com.yammer.metrics.core.TimerContext

    static {
        System.setProperty(AsyncScalr.THREAD_COUNT_PROPERTY_NAME, "4");
    }

    public static BufferedImage rotate(BufferedImage image, Scalr.Rotation rotation) throws Exception {
        TimerContext rotateContext = rotateTimer.time();
        BufferedImage result = AsyncScalr.rotate(image, rotation).get();
        image.flush();
        rotateContext.stop();
        return result;
    }
View Full Code Here

Examples of com.yammer.metrics.core.TimerContext

        return result;
    }

    public static BufferedImage fitToWidth(BufferedImage image, int width) throws Exception {
        // TODO: Don't ever make an image bigger
        TimerContext resizeContext = resizeTimer.time();
        BufferedImage result = AsyncScalr.resize(image, Scalr.Mode.FIT_TO_WIDTH, width).get();
        image.flush();
        resizeContext.stop();
        return result;
    }
View Full Code Here

Examples of com.yammer.metrics.core.TimerContext

        resizeContext.stop();
        return result;
    }

    public static BufferedImage crop(BufferedImage image, Rectangle bounds) throws Exception {
        TimerContext cropContext = cropTimer.time();
        BufferedImage result = AsyncScalr.crop(image, bounds.x, bounds.y, bounds.width, bounds.height).get();
        image.flush();
        cropContext.stop();
        return result;
    }
View Full Code Here

Examples of com.yammer.metrics.core.TimerContext

            throw new WebApplicationException(501); // Not implemented
        }

        if (width != null || rotateAngle != null || crop != null) {
            BufferedImage image;
            TimerContext readContext = readTimer.time();
            try {
                image = ImageIO.read(imageStream);
            } finally {
                imageStream.close();
                readContext.stop();
            }

            if (crop != null) {
                image = com.thousandmemories.photon.core.Processor.crop(image, crop.get());
            }
View Full Code Here

Examples of com.yammer.metrics.core.TimerContext

    } catch (Exception e) {
      LOG.error("Unknown error while trying to get the correct index reader for selector [{0}].", e, selector);
      throw new BException(e.getMessage(), e);
    }
    IndexSearcherClosable searcher = null;
    TimerContext timerContext = _fetchTimer.time();
    boolean usedCache = true;
    try {
      ShardServerContext shardServerContext = ShardServerContext.getShardServerContext();
      if (shardServerContext != null) {
        searcher = shardServerContext.getIndexSearcherClosable(table, shard);
      }
      if (searcher == null) {
        searcher = index.getIndexReader();
        usedCache = false;
      }

      TableContext tableContext = getTableContext(table);
      FieldManager fieldManager = tableContext.getFieldManager();

      Query highlightQuery = getHighlightQuery(selector, table, fieldManager);

      fetchRow(searcher.getIndexReader(), table, shard, selector, fetchResult, highlightQuery, fieldManager,
          _maxHeapPerRowFetch);

      if (fetchResult.rowResult != null) {
        if (fetchResult.rowResult.row != null && fetchResult.rowResult.row.records != null) {
          _readRecordsMeter.mark(fetchResult.rowResult.row.records.size());
        }
        _readRowMeter.mark();
      } else if (fetchResult.recordResult != null) {
        _readRecordsMeter.mark();
      }
    } catch (Exception e) {
      LOG.error("Unknown error while trying to fetch row.", e);
      throw new BException(e.getMessage(), e);
    } finally {
      timerContext.stop();
      if (!usedCache && searcher != null) {
        // if the cached search was not used, close the searcher.
        // this will allow for closing of index
        try {
          searcher.close();
View Full Code Here

Examples of com.yammer.metrics.core.TimerContext

      throw e;
    } catch (Exception e) {
      LOG.error("Unknown error while trying to get the correct index reader for selector [{0}].", e, selector);
      throw new BException(e.getMessage(), e);
    }
    TimerContext timerContext = _fetchTimer.time();
    boolean usedCache = true;
    try {
      ShardServerContext shardServerContext = ShardServerContext.getShardServerContext();
      if (shardServerContext != null) {
        searcher = shardServerContext.getIndexSearcherClosable(table, shard);
      }
      if (searcher == null) {
        // Was not pulled from cache, get a fresh one from the index.
        searcher = index.getIndexSearcher();
        usedCache = false;
      }
      FieldManager fieldManager = tableContext.getFieldManager();

      Query highlightQuery = getHighlightQuery(selector, table, fieldManager);

      fetchRow(searcher.getIndexReader(), table, shard, selector, fetchResult, highlightQuery, fieldManager,
          _maxHeapPerRowFetch, tableContext, filter);
    } catch (Exception e) {
      LOG.error("Unknown error while trying to fetch row.", e);
      throw new BException(e.getMessage(), e);
    } finally {
      trace.done();
      timerContext.stop();
      if (!usedCache && searcher != null) {
        // if the cached search was not used, close the searcher.
        // this will allow for closing of index
        try {
          searcher.close();
View Full Code Here

Examples of com.yammer.metrics.core.TimerContext

        if (vertex.isHalted() && !Iterables.isEmpty(messages)) {
          vertex.wakeUp();
        }
        if (!vertex.isHalted()) {
          context.progress();
          TimerContext computeOneTimerContext = computeOneTimer.time();
          try {
            vertex.compute(messages);
          } finally {
            computeOneTimerContext.stop();
          }
          // Need to unwrap the mutated edges (possibly)
          vertex.unwrapMutableEdges();
          // Write vertex to superstep output (no-op if it is not used)
          vertexWriter.writeVertex(vertex);
View Full Code Here

Examples of com.yammer.metrics.core.TimerContext

  public void run(InputBenchmarkCmd args) throws Exception {
    HadoopNative.requireHadoopNative();

    Timer allTime = Metrics.newTimer(InputBenchmark.class, "all-time", MILLISECONDS, MILLISECONDS);
    TimerContext allTimerContext = allTime.time();

    HiveInputDescription input = new HiveInputDescription();
    input.setDbName(args.tableOpts.database);
    input.setTableName(args.tableOpts.table);
    input.setPartitionFilter(args.tableOpts.partitionFilter);

    HiveConf hiveConf = new HiveConf(InputBenchmark.class);
    ThriftHiveMetastore.Iface client = HiveMetastores.create(args.metastoreOpts.hiveHost, args.metastoreOpts.hivePort);

    System.err.println("Initialize profile with input data");
    HiveApiInputFormat.setProfileInputDesc(hiveConf, input, HiveApiInputFormat.DEFAULT_PROFILE_ID);

    HiveApiInputFormat defaultInputFormat = new HiveApiInputFormat();
    if (args.trackMetrics) {
      defaultInputFormat.setObserver(new MetricsObserver("default", args.recordPrintPeriod));
    }

    List<InputSplit> splits = defaultInputFormat.getSplits(hiveConf, client);
    System.err.println("getSplits returned " + splits.size() + " splits");

    long numRows = 0;
    for (int i = 0; i < splits.size(); ++i) {
      InputSplit split = splits.get(i);
      TaskAttemptID taskID = new TaskAttemptID();
      TaskAttemptContext taskContext = new TaskAttemptContext(hiveConf, taskID);
      if (i % args.splitPrintPeriod == 0) {
        System.err.println("Handling split " + i + " of " + splits.size());
      }
      RecordReader<WritableComparable, HiveReadableRecord> reader =
          defaultInputFormat.createRecordReader(split, taskContext);
      reader.initialize(split, taskContext);
      numRows += readFully(reader);
    }

    System.err.println("Parsed " + numRows + " rows");

    allTimerContext.stop();

    new ConsoleReporter(System.err).run();
  }
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.