Package com.yammer.metrics.core

Examples of com.yammer.metrics.core.Histogram


        String fileMatch = Parameter.value("file-match", "out-*");
        // Stats to report
        long blocks = 0;
        long fileBlocks = 0;
        long chunks = 0;
        Histogram chunkSize = Metrics.newHistogram(ReadMuxStreamDirectory.class, "chunkSize");
        Histogram blockSize = Metrics.newHistogram(ReadMuxStreamDirectory.class, "blockSize");
        Histogram chunksPerBlock = Metrics.newHistogram(ReadMuxStreamDirectory.class, "chunksPerBlock");


        // Get stats
        Iterator<Path> dataFiles = Files.newDirectoryStream(streamDirectory, "out-*").iterator();
        Path lastPath = dataFiles.next();
        long nextBlockPosition = 0;
        RandomAccessFile input = new RandomAccessFile(lastPath.toFile(), "r");
        while (true) {
            if (nextBlockPosition != 0) {
                input.seek(nextBlockPosition);
            }
            if (input.getFilePointer() >= input.length()) {
                input.close();
                if (!dataFiles.hasNext()) {
                    log.info("ran out of mux data files after : " + lastPath.toString());
                    break;
                }
                lastPath = dataFiles.next();
                input = new RandomAccessFile(lastPath.toFile(), "r");
                nextBlockPosition = 0;
            }
            // parse the next block
            int countIDs = input.readShort();
            chunks += countIDs;
            chunksPerBlock.update(countIDs);
            ArrayList<Integer> streamList = new ArrayList<>(50);
            for (int i = 0; i < countIDs; i++) {
                int streamID = input.readInt();
                streamList.add(streamID);
            }
            int bodySize = input.readInt(); // (8 * countIDs) + sum of chunk lengths
            long currentPosition = input.getFilePointer(); // currentBlockStart + 2 + (4 * countIDs) + 4
            long currentBlockStart = nextBlockPosition;
            nextBlockPosition = currentPosition + bodySize;
            long currentBlockSize = nextBlockPosition - currentBlockStart; // 2 + (4 * countIDs) + 4 + bodySize
            blockSize.update(currentBlockSize);
            if (currentBlockSize < tiny_block) {
                log.info("Tiny block debug log");
                log.info(Objects.toStringHelper("block")
                        .add("block", fileBlocks)
                        .add("chunks", countIDs)
                        .add("size", currentBlockSize)
                        .add("os-file", lastPath.getFileName().toString())
                        .add("position", currentPosition)
                        .toString());
                StringBuilder sb = new StringBuilder();
                for (Integer i : streamList) {
                    sb.append(i);
                    sb.append('\n');
                }
                log.info("Stream ids in block : ");
                log.info(sb.toString());
            }
            for (int i = 0; i < countIDs; i++) {
                int chunkBodyOffset = input.readInt(); // throw away
                int chunkLength = input.readInt();
                chunkSize.update(chunkLength);
            }
            fileBlocks += 1;
            blocks += 1;
        }

        // Report stats
        log.info("### Printing stats");
        log.info("Total blocks : " + blocks);
        log.info("Total chunks : " + chunks);
        log.info("Median Chunks per Block : " + chunksPerBlock.getSnapshot().getMedian());
        log.info("05th Percentile Chunks per Block : " + chunksPerBlock.getSnapshot().getValue(0.05));
        log.info("95th Percentile Chunks per Block : " + chunksPerBlock.getSnapshot().get95thPercentile());
        log.info("Median Block Size : " + blockSize.getSnapshot().getMedian());
        log.info("Median Chunk Size : " + chunkSize.getSnapshot().getMedian());
        log.info("05th Percentile Block Size : " + blockSize.getSnapshot().getValue(0.05));
        log.info("05th Percentile Chunk Size : " + chunkSize.getSnapshot().getValue(0.05));
        log.info("95th Percentile Block Size : " + blockSize.getSnapshot().get95thPercentile());
View Full Code Here


    opts.setValueSize(valueSize);
    RandomReadTest rrt = new RandomReadTest(null, opts, null);
    Constructor<?> ctor =
      Histogram.class.getDeclaredConstructor(com.yammer.metrics.stats.Sample.class);
    ctor.setAccessible(true);
    Histogram histogram = (Histogram)ctor.newInstance(new UniformSample(1024 * 500));
    for (int i = 0; i < 100; i++) {
      histogram.update(rrt.getValueLength(null));
    }
    double stddev = histogram.stdDev();
    assertTrue(stddev != 0 && stddev != 1.0);
    assertTrue(histogram.stdDev() != 0);
    Snapshot snapshot = histogram.getSnapshot();
    double median = snapshot.getMedian();
    assertTrue(median != 0 && median != 1 && median != valueSize);
  }
View Full Code Here

        String fileMatch = Parameter.value("file-match", "out-*");
        // Stats to report
        long blocks = 0;
        long fileBlocks = 0;
        long chunks = 0;
        Histogram chunkSize = Metrics.newHistogram(ReadMuxStreamDirectory.class, "chunkSize");
        Histogram blockSize = Metrics.newHistogram(ReadMuxStreamDirectory.class, "blockSize");
        Histogram chunksPerBlock = Metrics.newHistogram(ReadMuxStreamDirectory.class, "chunksPerBlock");


        // Get stats
        Iterator<Path> dataFiles = Files.newDirectoryStream(streamDirectory, "out-*").iterator();
        Path lastPath = dataFiles.next();
        long nextBlockPosition = 0;
        RandomAccessFile input = new RandomAccessFile(lastPath.toFile(), "r");
        while (true) {
            if (nextBlockPosition != 0) {
                input.seek(nextBlockPosition);
            }
            if (input.getFilePointer() >= input.length()) {
                input.close();
                if (!dataFiles.hasNext()) {
                    log.info("ran out of mux data files after : " + lastPath.toString());
                    break;
                }
                lastPath = dataFiles.next();
                input = new RandomAccessFile(lastPath.toFile(), "r");
                nextBlockPosition = 0;
            }
            // parse the next block
            int countIDs = input.readShort();
            chunks += countIDs;
            chunksPerBlock.update(countIDs);
            ArrayList<Integer> streamList = new ArrayList<>(50);
            for (int i = 0; i < countIDs; i++) {
                int streamID = input.readInt();
                streamList.add(streamID);
            }
            int bodySize = input.readInt(); // (8 * countIDs) + sum of chunk lengths
            long currentPosition = input.getFilePointer(); // currentBlockStart + 2 + (4 * countIDs) + 4
            long currentBlockStart = nextBlockPosition;
            nextBlockPosition = currentPosition + bodySize;
            long currentBlockSize = nextBlockPosition - currentBlockStart; // 2 + (4 * countIDs) + 4 + bodySize
            blockSize.update(currentBlockSize);
            if (currentBlockSize < tiny_block) {
                log.info("Tiny block debug log");
                log.info(Objects.toStringHelper("block")
                        .add("block", fileBlocks)
                        .add("chunks", countIDs)
                        .add("size", currentBlockSize)
                        .add("os-file", lastPath.getFileName().toString())
                        .add("position", currentPosition)
                        .toString());
                StringBuilder sb = new StringBuilder();
                for (Integer i : streamList) {
                    sb.append(i);
                    sb.append('\n');
                }
                log.info("Stream ids in block : ");
                log.info(sb.toString());
            }
            for (int i = 0; i < countIDs; i++) {
                int chunkBodyOffset = input.readInt(); // throw away
                int chunkLength = input.readInt();
                chunkSize.update(chunkLength);
            }
            fileBlocks += 1;
            blocks += 1;
        }

        // Report stats
        log.info("### Printing stats");
        log.info("Total blocks : " + blocks);
        log.info("Total chunks : " + chunks);
        log.info("Median Chunks per Block : " + chunksPerBlock.getSnapshot().getMedian());
        log.info("05th Percentile Chunks per Block : " + chunksPerBlock.getSnapshot().getValue(0.05));
        log.info("95th Percentile Chunks per Block : " + chunksPerBlock.getSnapshot().get95thPercentile());
        log.info("Median Block Size : " + blockSize.getSnapshot().getMedian());
        log.info("Median Chunk Size : " + chunkSize.getSnapshot().getMedian());
        log.info("05th Percentile Block Size : " + blockSize.getSnapshot().getValue(0.05));
        log.info("05th Percentile Chunk Size : " + chunkSize.getSnapshot().getValue(0.05));
        log.info("95th Percentile Block Size : " + blockSize.getSnapshot().get95thPercentile());
View Full Code Here

  @Override
  public void doRequest(ServerData<I, V, E> serverData) {
    ConcurrentHashMap<I, VertexMutations<I, V, E>> vertexMutations =
      serverData.getVertexMutations();
    Histogram verticesInMutationHist = GiraphMetrics.get().perSuperstep()
        .getUniformHistogram(MetricNames.VERTICES_IN_MUTATION_REQUEST);
    verticesInMutationHist.update(vertexMutations.size());
    for (Entry<I, VertexMutations<I, V, E>> entry :
        vertexIdMutations.entrySet()) {
      VertexMutations<I, V, E> mutations =
          vertexMutations.get(entry.getKey());
      if (mutations == null) {
View Full Code Here

        String fileMatch = Parameter.value("file-match", "out-*");
        // Stats to report
        long blocks = 0;
        long fileBlocks = 0;
        long chunks = 0;
        Histogram chunkSize = Metrics.newHistogram(ReadMuxStreamDirectory.class, "chunkSize");
        Histogram blockSize = Metrics.newHistogram(ReadMuxStreamDirectory.class, "blockSize");
        Histogram chunksPerBlock = Metrics.newHistogram(ReadMuxStreamDirectory.class, "chunksPerBlock");


        // Get stats
        Iterator<Path> dataFiles = Files.newDirectoryStream(streamDirectory, "out-*").iterator();
        Path lastPath = dataFiles.next();
        long nextBlockPosition = 0;
        RandomAccessFile input = new RandomAccessFile(lastPath.toFile(), "r");
        while (true) {
            if (nextBlockPosition != 0) {
                input.seek(nextBlockPosition);
            }
            if (input.getFilePointer() >= input.length()) {
                input.close();
                if (!dataFiles.hasNext()) {
                    log.info("ran out of mux data files after : " + lastPath.toString());
                    break;
                }
                lastPath = dataFiles.next();
                input = new RandomAccessFile(lastPath.toFile(), "r");
                nextBlockPosition = 0;
            }
            // parse the next block
            int countIDs = input.readShort();
            chunks += countIDs;
            chunksPerBlock.update(countIDs);
            ArrayList<Integer> streamList = new ArrayList<>(50);
            for (int i = 0; i < countIDs; i++) {
                int streamID = input.readInt();
                streamList.add(streamID);
            }
            int bodySize = input.readInt(); // (8 * countIDs) + sum of chunk lengths
            long currentPosition = input.getFilePointer(); // currentBlockStart + 2 + (4 * countIDs) + 4
            long currentBlockStart = nextBlockPosition;
            nextBlockPosition = currentPosition + bodySize;
            long currentBlockSize = nextBlockPosition - currentBlockStart; // 2 + (4 * countIDs) + 4 + bodySize
            blockSize.update(currentBlockSize);
            if (currentBlockSize < tiny_block) {
                log.info("Tiny block debug log");
                log.info(Objects.toStringHelper("block")
                        .add("block", fileBlocks)
                        .add("chunks", countIDs)
                        .add("size", currentBlockSize)
                        .add("os-file", lastPath.getFileName().toString())
                        .add("position", currentPosition)
                        .toString());
                StringBuilder sb = new StringBuilder();
                for (Integer i : streamList) {
                    sb.append(i);
                    sb.append('\n');
                }
                log.info("Stream ids in block : ");
                log.info(sb.toString());
            }
            for (int i = 0; i < countIDs; i++) {
                int chunkBodyOffset = input.readInt(); // throw away
                int chunkLength = input.readInt();
                chunkSize.update(chunkLength);
            }
            fileBlocks += 1;
            blocks += 1;
        }

        // Report stats
        log.info("### Printing stats");
        log.info("Total blocks : " + blocks);
        log.info("Total chunks : " + chunks);
        log.info("Median Chunks per Block : " + chunksPerBlock.getSnapshot().getMedian());
        log.info("05th Percentile Chunks per Block : " + chunksPerBlock.getSnapshot().getValue(0.05));
        log.info("95th Percentile Chunks per Block : " + chunksPerBlock.getSnapshot().get95thPercentile());
        log.info("Median Block Size : " + blockSize.getSnapshot().getMedian());
        log.info("Median Chunk Size : " + chunkSize.getSnapshot().getMedian());
        log.info("05th Percentile Block Size : " + blockSize.getSnapshot().getValue(0.05));
        log.info("05th Percentile Chunk Size : " + chunkSize.getSnapshot().getValue(0.05));
        log.info("95th Percentile Block Size : " + blockSize.getSnapshot().get95thPercentile());
View Full Code Here

        int tiny_block = Parameter.intValue("tiny-size", 15000);
        String fileMatch = Parameter.value("file-match", "out-*");
        // Stats to report
        long blocks = 0;
        long chunks = 0;
        Histogram chunkSize = Metrics.newHistogram(ReadMuxStreamDirectory.class, "chunkSize");
        Histogram blockSize = Metrics.newHistogram(ReadMuxStreamDirectory.class, "blockSize");
        Histogram chunksPerBlock = Metrics.newHistogram(ReadMuxStreamDirectory.class, "chunksPerBlock");


        // Get stats
        int currentFile = 1;
        Iterator<Path> dataFiles = Files.newDirectoryStream(streamDirectory, fileMatch).iterator();
        Path lastPath = dataFiles.next();
        long nextBlockPosition = 0;
        RandomAccessFile input = new RandomAccessFile(lastPath.toFile(), "r");
        while (true) {
            if (nextBlockPosition != 0) {
                input.seek(nextBlockPosition);
            }
            if (input.getFilePointer() >= input.length()) {
                input.close();
                if (!dataFiles.hasNext()) {
                    log.info("ran out of mux data files after : " + lastPath.toString());
                    break;
                }
                lastPath = dataFiles.next();
                input = new RandomAccessFile(lastPath.toFile(), "r");
                nextBlockPosition = 0;
            }
            // parse the next block
            long currentBlock = blocks++;
            int countIDs = input.readShort();
            chunks += countIDs;
            chunksPerBlock.update(countIDs);
            ArrayList<Integer> streamList = new ArrayList<>(50);
            for (int i = 0; i < countIDs; i++) {
                int streamID = input.readInt();
                streamList.add(streamID);
            }
            int bodySize = input.readInt();
            long currentPosition = input.getFilePointer();
            long currentBlockStart = nextBlockPosition;
            nextBlockPosition = currentPosition + bodySize;
            long currentBlockSize = nextBlockPosition - currentBlockStart;
            blockSize.update(currentBlockSize);
            if (currentBlockSize < tiny_block) {
                log.info("Tiny block debug log");
                log.info(Objects.toStringHelper("block")
                        .add("block", currentBlock)
                        .add("chunks", countIDs)
                        .add("size", currentBlockSize)
                        .add("os-file", lastPath.getFileName().toString())
                        .add("position", currentPosition)
                        .toString());
                StringBuilder sb = new StringBuilder();
                for (Integer i : streamList) {
                    sb.append(i);
                    sb.append('\n');
                }
                log.info("Stream ids in block : ");
                log.info(sb.toString());
            }
            for (int i = 0; i < countIDs; i++) {
                int chunkBodyOffset = input.readInt(); // throw away
                int chunkLength = input.readInt();
                chunkSize.update(chunkLength);
            }
        }

        // Report stats
        log.info("### Printing stats");
        log.info("Total blocks : " + blocks);
        log.info("Total chunks : " + chunks);
        log.info("Median Chunks per Block : " + chunksPerBlock.getSnapshot().getMedian());
        log.info("05th Percentile Chunks per Block : " + chunksPerBlock.getSnapshot().getValue(0.05));
        log.info("95th Percentile Chunks per Block : " + chunksPerBlock.getSnapshot().get95thPercentile());
        log.info("Median Block Size : " + blockSize.getSnapshot().getMedian());
        log.info("Median Chunk Size : " + chunkSize.getSnapshot().getMedian());
        log.info("05th Percentile Block Size : " + blockSize.getSnapshot().getValue(0.05));
        log.info("05th Percentile Chunk Size : " + chunkSize.getSnapshot().getValue(0.05));
        log.info("95th Percentile Block Size : " + blockSize.getSnapshot().get95thPercentile());
View Full Code Here

    }

    @Test
    public void testUpdateMetric_Histogram_Biased() {
        jsonMetric.setType("biased");
        Histogram metric = (Histogram) metricCatcher.createMetric(jsonMetric);

        metricCatcher.updateMetric(metric, 1);
        assertEquals(1, metric.count());
    }
View Full Code Here

    }

    @Test
    public void testUpdateMetric_Histogram_MultipleUpdates() {
        jsonMetric.setType("biased");
        Histogram metric = (Histogram) metricCatcher.createMetric(jsonMetric);

        int count = 7;
        for (int x = 0; x < 7; x++) {
            metricCatcher.updateMetric(metric, 1);
        }

        assertEquals(count, metric.count());
    }
View Full Code Here

TOP

Related Classes of com.yammer.metrics.core.Histogram

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.