Example usage for java.util SortedMap entrySet

List of usage examples for java.util SortedMap entrySet

Introduction

In this page you can find the example usage for java.util SortedMap entrySet.

Prototype

Set<Map.Entry<K, V>> entrySet();

Source Link

Document

Returns a Set view of the mappings contained in this map.

Usage

From source file:org.apache.cassandra.db.index.sasi.disk.TokenTreeTest.java

@Test
public void buildWithMultipleMapsAndIterate() throws Exception {
    final SortedMap<Long, LongSet> merged = new TreeMap<>();
    final TokenTreeBuilder builder = new TokenTreeBuilder(simpleTokenMap).finish();
    builder.add(collidingTokensMap);//from   w  w w  .j  ava  2 s.  c  o m

    merged.putAll(collidingTokensMap);
    for (Map.Entry<Long, LongSet> entry : simpleTokenMap.entrySet()) {
        if (merged.containsKey(entry.getKey())) {
            LongSet mergingOffsets = entry.getValue();
            LongSet existingOffsets = merged.get(entry.getKey());

            if (mergingOffsets.equals(existingOffsets))
                continue;

            Set<Long> mergeSet = new HashSet<>();
            for (LongCursor merging : mergingOffsets)
                mergeSet.add(merging.value);

            for (LongCursor existing : existingOffsets)
                mergeSet.add(existing.value);

            LongSet mergedResults = new LongOpenHashSet();
            for (Long result : mergeSet)
                mergedResults.add(result);

            merged.put(entry.getKey(), mergedResults);
        } else {
            merged.put(entry.getKey(), entry.getValue());
        }
    }

    final Iterator<Pair<Long, LongSet>> tokenIterator = builder.iterator();
    final Iterator<Map.Entry<Long, LongSet>> listIterator = merged.entrySet().iterator();
    while (tokenIterator.hasNext() && listIterator.hasNext()) {
        Pair<Long, LongSet> tokenNext = tokenIterator.next();
        Map.Entry<Long, LongSet> listNext = listIterator.next();

        Assert.assertEquals(listNext.getKey(), tokenNext.left);
        Assert.assertEquals(listNext.getValue(), tokenNext.right);
    }

    Assert.assertFalse("token iterator not finished", tokenIterator.hasNext());
    Assert.assertFalse("list iterator not finished", listIterator.hasNext());

}

From source file:org.elasticsearch.metrics.ElasticsearchReporter.java

@Override
public void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters,
        SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters,
        SortedMap<String, Timer> timers) {

    // nothing to do if we dont have any metrics to report
    if (gauges.isEmpty() && counters.isEmpty() && histograms.isEmpty() && meters.isEmpty()
            && timers.isEmpty()) {
        LOGGER.info("All metrics empty, nothing to report");
        return;//from   w  ww .j  ava2s .c o m
    }

    if (!checkedForIndexTemplate) {
        checkForIndexTemplate();
    }
    final long timestamp = clock.getTime() / 1000;

    currentIndexName = index;
    if (indexDateFormat != null) {
        currentIndexName += "-" + indexDateFormat.format(new Date(timestamp * 1000));
    }

    try {
        HttpURLConnection connection = openConnection("/_bulk", "POST");
        if (connection == null) {
            LOGGER.error("Could not connect to any configured elasticsearch instances: {}",
                    Arrays.asList(hosts));
            return;
        }

        List<JsonMetric> percolationMetrics = new ArrayList<>();
        AtomicInteger entriesWritten = new AtomicInteger(0);

        for (Map.Entry<String, Gauge> entry : gauges.entrySet()) {
            if (entry.getValue().getValue() != null) {
                JsonMetric jsonMetric = new JsonGauge(name(prefix, entry.getKey()), timestamp,
                        entry.getValue());
                connection = writeJsonMetricAndRecreateConnectionIfNeeded(jsonMetric, connection,
                        entriesWritten);
                addJsonMetricToPercolationIfMatching(jsonMetric, percolationMetrics);
            }
        }

        for (Map.Entry<String, Counter> entry : counters.entrySet()) {
            JsonCounter jsonMetric = new JsonCounter(name(prefix, entry.getKey()), timestamp, entry.getValue());
            connection = writeJsonMetricAndRecreateConnectionIfNeeded(jsonMetric, connection, entriesWritten);
            addJsonMetricToPercolationIfMatching(jsonMetric, percolationMetrics);
        }

        for (Map.Entry<String, Histogram> entry : histograms.entrySet()) {
            JsonHistogram jsonMetric = new JsonHistogram(name(prefix, entry.getKey()), timestamp,
                    entry.getValue());
            connection = writeJsonMetricAndRecreateConnectionIfNeeded(jsonMetric, connection, entriesWritten);
            addJsonMetricToPercolationIfMatching(jsonMetric, percolationMetrics);
        }

        for (Map.Entry<String, Meter> entry : meters.entrySet()) {
            JsonMeter jsonMetric = new JsonMeter(name(prefix, entry.getKey()), timestamp, entry.getValue());
            connection = writeJsonMetricAndRecreateConnectionIfNeeded(jsonMetric, connection, entriesWritten);
            addJsonMetricToPercolationIfMatching(jsonMetric, percolationMetrics);
        }

        for (Map.Entry<String, Timer> entry : timers.entrySet()) {
            JsonTimer jsonMetric = new JsonTimer(name(prefix, entry.getKey()), timestamp, entry.getValue());
            connection = writeJsonMetricAndRecreateConnectionIfNeeded(jsonMetric, connection, entriesWritten);
            addJsonMetricToPercolationIfMatching(jsonMetric, percolationMetrics);
        }

        closeConnection(connection);

        // execute the notifier impl, in case percolation found matches
        if (percolationMetrics.size() > 0 && notifier != null) {
            for (JsonMetric jsonMetric : percolationMetrics) {
                List<String> matches = getPercolationMatches(jsonMetric);
                for (String match : matches) {
                    notifier.notify(jsonMetric, match);
                }
            }
        }
        // catch the exception to make sure we do not interrupt the live application
    } catch (IOException e) {
        LOGGER.error("Couldnt report to elasticsearch server", e);
    }
}

From source file:com.neoteric.starter.metrics.report.elastic.ElasticsearchReporter.java

@Override
public void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters,
        SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters,
        SortedMap<String, Timer> timers) {

    // nothing to do if we dont have any metrics to report
    if (gauges.isEmpty() && counters.isEmpty() && histograms.isEmpty() && meters.isEmpty()
            && timers.isEmpty()) {
        LOGGER.info("All metrics empty, nothing to report");
        return;//from  w  w  w  .  j  a  v a2 s .  c  om
    }

    if (!checkedForIndexTemplate) {
        checkForIndexTemplate();
    }
    final long timestamp = clock.getTime() / 1000;

    currentIndexName = index;
    if (indexDateFormat != null) {
        currentIndexName += "-" + indexDateFormat.format(new Date(timestamp * 1000));
    }

    try {
        HttpURLConnection connection;
        try {
            connection = openConnection("/_bulk", "POST");
        } catch (ElasticsearchConnectionException e) {
            LOGGER.error("Could not connect to any configured elasticsearch instances: {}",
                    Arrays.asList(hosts), e);
            return;
        }

        List<JsonMetric> percolationMetrics = new ArrayList<>();
        AtomicInteger entriesWritten = new AtomicInteger(0);

        for (Map.Entry<String, Gauge> entry : gauges.entrySet()) {
            if (entry.getValue().getValue() != null) {
                JsonMetric jsonMetric = new JsonGauge(name(prefix, entry.getKey()), timestamp,
                        entry.getValue());
                connection = writeJsonMetricAndRecreateConnectionIfNeeded(jsonMetric, connection,
                        entriesWritten);
                addJsonMetricToPercolationIfMatching(jsonMetric, percolationMetrics);
            }
        }

        for (Map.Entry<String, Counter> entry : counters.entrySet()) {
            JsonCounter jsonMetric = new JsonCounter(name(prefix, entry.getKey()), timestamp, entry.getValue());
            connection = writeJsonMetricAndRecreateConnectionIfNeeded(jsonMetric, connection, entriesWritten);
            addJsonMetricToPercolationIfMatching(jsonMetric, percolationMetrics);
        }

        for (Map.Entry<String, Histogram> entry : histograms.entrySet()) {
            JsonHistogram jsonMetric = new JsonHistogram(name(prefix, entry.getKey()), timestamp,
                    entry.getValue());
            connection = writeJsonMetricAndRecreateConnectionIfNeeded(jsonMetric, connection, entriesWritten);
            addJsonMetricToPercolationIfMatching(jsonMetric, percolationMetrics);
        }

        for (Map.Entry<String, Meter> entry : meters.entrySet()) {
            JsonMeter jsonMetric = new JsonMeter(name(prefix, entry.getKey()), timestamp, entry.getValue());
            connection = writeJsonMetricAndRecreateConnectionIfNeeded(jsonMetric, connection, entriesWritten);
            addJsonMetricToPercolationIfMatching(jsonMetric, percolationMetrics);
        }

        for (Map.Entry<String, Timer> entry : timers.entrySet()) {
            JsonTimer jsonMetric = new JsonTimer(name(prefix, entry.getKey()), timestamp, entry.getValue());
            connection = writeJsonMetricAndRecreateConnectionIfNeeded(jsonMetric, connection, entriesWritten);
            addJsonMetricToPercolationIfMatching(jsonMetric, percolationMetrics);
        }

        closeConnection(connection);

        // execute the notifier impl, in case percolation found matches
        if (percolationMetrics.size() > 0 && notifier != null) {
            for (JsonMetric jsonMetric : percolationMetrics) {
                List<String> matches = getPercolationMatches(jsonMetric);
                for (String match : matches) {
                    notifier.notify(jsonMetric, match);
                }
            }
        }
        // catch the exception to make sure we do not interrupt the live application
    } catch (ElasticsearchConnectionException e) {
        LOGGER.error("Couldnt report to elasticsearch server", e);
    } catch (IOException e) {
        LOGGER.error("Couldnt report to elasticsearch server", e);
    }
}

From source file:eagle.log.entity.meta.IndexDefinition.java

private byte[] generateUniqueIndexRowkey(byte[][] indexValues, int[] partitionHashCodes,
        SortedMap<Integer, Integer> tagMap) {
    final int prefixHashCode = indexPrefix.hashCode();
    int totalLength = 4;
    totalLength += (partitionHashCodes != null) ? (4 * partitionHashCodes.length) : 0;

    totalLength += (2 * indexValues.length);
    for (int i = 0; i < indexValues.length; ++i) {
        final byte[] value = indexValues[i];
        totalLength += value.length;//  ww  w. ja v a 2  s .  com
    }
    if (tagMap != null && (!tagMap.isEmpty())) {
        totalLength += tagMap.size() * 8;
    }

    int offset = 0;
    final byte[] rowkey = new byte[totalLength];

    // 1. set prefix
    ByteUtil.intToBytes(prefixHashCode, rowkey, offset);
    offset += 4;

    // 2. set partition
    if (partitionHashCodes != null) {
        for (Integer partitionHashCode : partitionHashCodes) {
            ByteUtil.intToBytes(partitionHashCode, rowkey, offset);
            offset += 4;
        }
    }

    // 3. set index values
    for (int i = 0; i < columns.length; ++i) {
        ByteUtil.shortToBytes((short) indexValues[i].length, rowkey, offset);
        offset += 2;
        for (int j = 0; j < indexValues[i].length; ++j) {
            rowkey[offset++] = indexValues[i][j];
        }
    }

    // Check if it's non clustered index, then set the tag/value hash code
    if (tagMap != null && (!tagMap.isEmpty())) {
        // 4. set tag key/value hashes
        for (Map.Entry<Integer, Integer> entry : tagMap.entrySet()) {
            ByteUtil.intToBytes(entry.getKey(), rowkey, offset);
            offset += 4;
            ByteUtil.intToBytes(entry.getValue(), rowkey, offset);
            offset += 4;
        }
    }

    return rowkey;
}

From source file:org.apache.nifi.provenance.MiNiFiPersistentProvenanceRepository.java

private List<Path> getPathsForId(final long id) {
    final SortedMap<Long, Path> map = idToPathMap.get();

    final List<Path> paths = new ArrayList<>();

    final Iterator<Map.Entry<Long, Path>> itr = map.entrySet().iterator();
    if (!itr.hasNext()) {
        return paths;
    }/* w  ww .jav  a  2s.  co  m*/

    Map.Entry<Long, Path> lastEntry = itr.next();
    while (itr.hasNext()) {
        final Map.Entry<Long, Path> entry = itr.next();
        final Long startIndex = entry.getKey();

        if (startIndex >= id) {
            paths.add(lastEntry.getValue());
            paths.add(entry.getValue());

            while (itr.hasNext()) {
                paths.add(itr.next().getValue());
            }

            return paths;
        }

        lastEntry = entry;
    }

    // we didn't find any entry whose first ID is greater than the id
    // requested. However,
    // since we don't know the max ID of the last entry in the map, it's
    // possible that the
    // ID that we want lives within that file, so we add it to the paths to
    // return
    if (lastEntry != null) {
        paths.add(lastEntry.getValue());
    }

    if (logger.isDebugEnabled()) {
        logger.debug("Looking for Event ID {}, searching in paths: {}", id, paths);
    }

    return paths;
}

From source file:com.palantir.atlasdb.transaction.impl.SnapshotTransaction.java

private List<Entry<Cell, byte[]>> getPostfilteredWithLocalWrites(final String tableName,
        final SortedMap<Cell, byte[]> postFiltered, final RangeRequest rangeRequest,
        List<RowResult<Value>> prePostFilter, final byte[] endRowExclusive) {
    Map<Cell, Value> prePostFilterCells = Cells.convertRowResultsToCells(prePostFilter);
    Collection<Entry<Cell, byte[]>> postFilteredCells = Collections2.filter(postFiltered.entrySet(), Predicates
            .compose(Predicates.in(prePostFilterCells.keySet()), MapEntries.<Cell, byte[]>getKeyFunction()));
    Collection<Entry<Cell, byte[]>> localWritesInRange = getLocalWritesForRange(tableName,
            rangeRequest.getStartInclusive(), endRowExclusive).entrySet();
    return ImmutableList.copyOf(mergeInLocalWrites(postFilteredCells.iterator(), localWritesInRange.iterator(),
            rangeRequest.isReverse()));/*from www  .  j a v a  2s .  c  o m*/
}

From source file:com.aurel.track.exchange.excel.ExcelImportBL.java

/**
 * Render grid/row errors/* w w w  . java  2s  .  c om*/
 * 
 * @param errorsMap
 * @param fieldIDToColumnIndexMap
 * @param locale
 * @param actionSupport
 * @return
 */
static List<String> renderRowErrors(SortedMap<Integer, List<ErrorData>> errorsMap,
        Map<Integer, Integer> fieldIDToColumnIndexMap, Locale locale) {
    Map<Integer, TFieldConfigBean> fieldConfigsMap = FieldRuntimeBL.getLocalizedDefaultFieldConfigsMap(locale);
    List<String> rowErrors = new LinkedList<String>();
    for (Map.Entry<Integer, List<ErrorData>> entry : errorsMap.entrySet()) {
        Integer row = entry.getKey();
        List<ErrorData> errorsOnRow = entry.getValue();
        if (errorsOnRow != null) {
            for (ErrorData errorData : errorsOnRow) {
                // the fieldID if present was set in
                // FieldManagerRT.validate()
                Integer fieldID = errorData.getFieldID();
                // field id is not needed as extra resource parameter
                errorData.setFieldID(null);
                String validationError = ErrorHandlerJSONAdapter.createFieldMessage(errorData, fieldConfigsMap,
                        locale);
                List<ErrorParameter> resourceParameters = new ArrayList<ErrorParameter>();
                // row always known
                resourceParameters.add(new ErrorParameter(row));
                ErrorData modifiedErrorData = null;
                if (fieldID != null && fieldIDToColumnIndexMap.get(fieldID) != null) {
                    // column known only if field is known and column is in
                    // the excel sheet
                    resourceParameters.add(new ErrorParameter(
                            ExcelFieldMatchBL.colNumericToLetter(fieldIDToColumnIndexMap.get(fieldID))));
                    modifiedErrorData = new ErrorData("admin.actions.importExcel.err.validationErrorGrid",
                            resourceParameters);
                } else {
                    modifiedErrorData = new ErrorData("admin.actions.importExcel.err.validationErrorRow",
                            resourceParameters);
                }
                resourceParameters.add(new ErrorParameter(validationError));
                rowErrors.add(ErrorHandlerJSONAdapter.createMessage(modifiedErrorData, locale));
            }
        }
    }
    return rowErrors;
}

From source file:eu.eubrazilcc.lvl.core.conf.ConfigurationManager.java

private Configuration configuration() {
    if (dont_use == null) {
        synchronized (Configuration.class) {
            if (dont_use == null && urls != null) {
                try {
                    XMLConfiguration main = null;
                    // sorting secondary configurations ensures that combination always result the same
                    final SortedMap<String, XMLConfiguration> secondary = newTreeMap();
                    // extract main configuration
                    for (final URL url : urls) {
                        final String filename = getName(url.getPath());
                        if (MAIN_CONFIG.equalsIgnoreCase(filename)) {
                            main = new XMLConfiguration(url);
                            LOGGER.info("Loading main configuration from: " + url.toString());
                        } else if (!IGNORE_LIST.contains(getName(url.getPath()))) {
                            secondary.put(filename, new XMLConfiguration(url));
                            LOGGER.info("Loading secondary configuration from: " + url.toString());
                        } else {
                            LOGGER.info("Ignoring: " + url.toString());
                        }//from  w ww.j  av a  2  s .c  om
                    }
                    if (main != null) {
                        final CombinedConfiguration configuration = new CombinedConfiguration(
                                new OverrideCombiner());
                        configuration.addConfiguration(main, MAIN_CONFIG);
                        for (final Map.Entry<String, XMLConfiguration> entry : secondary.entrySet()) {
                            configuration.addConfiguration(entry.getValue(), entry.getKey());
                        }
                        if (LOGGER.isDebugEnabled()) {
                            String names = "";
                            for (final String name : configuration.getConfigurationNameList()) {
                                names += name + " ";
                            }
                            LOGGER.trace("Loading configuration from: " + names);
                        }
                        final List<String> foundNameList = newArrayList();
                        // get main property will fail if the requested property is missing
                        configuration.setThrowExceptionOnMissing(true);
                        final File rootDir = getFile("lvl-root", configuration, foundNameList, true, null);
                        final File localCacheDir = getFile("storage.local-cache", configuration, foundNameList,
                                true, null);
                        final File htdocsDir = getFile("storage.htdocs", configuration, foundNameList, false,
                                null);
                        final String dbName = getString("database.name", configuration, foundNameList, "lvldb");
                        final String dbUsername = getString("database.credentials.username", configuration,
                                foundNameList, null);
                        final String dbPassword = getString("database.credentials.password", configuration,
                                foundNameList, null);
                        final ImmutableList<String> dbHosts = getStringList("database.hosts.host",
                                Pattern.compile("^[\\w]+:[\\d]+$"), configuration, foundNameList,
                                newArrayList("localhost:27017"));
                        final boolean brokerEmbedded = getBoolean("broker.embedded", configuration,
                                foundNameList, true);
                        final ImmutableList<String> messageBrokers = getStringList("messaging.hosts.host",
                                Pattern.compile("^[\\w]+:[\\d]+$"), configuration, foundNameList,
                                newArrayList("localhost:61616"));
                        final String smtpHost = getString("smtp.host", configuration, foundNameList,
                                "localhost");
                        final int smtpPort = getInteger("smtp.port", configuration, foundNameList, 25);
                        final String smtpSupportEmail = getString("smtp.support-email", configuration,
                                foundNameList, "support@example.com");
                        final String smtpNoreplyEmail = getString("smtp.noreply-email", configuration,
                                foundNameList, "noreply@example.com");
                        final String portalEndpoint = getString("portal.endpoint", configuration, foundNameList,
                                null);
                        final String wfHostname = getString("workflow.endpoint.hostname", configuration,
                                foundNameList, "localhost");
                        final boolean wfSecure = getBoolean("workflow.endpoint.secure", configuration,
                                foundNameList, false);
                        final int wfPort = getInteger("workflow.endpoint.port", configuration, foundNameList,
                                wfSecure ? 443 : 80);
                        final String wfUsername = getString("workflow.credentials.username", configuration,
                                foundNameList, null);
                        final String wfPasswd = getString("workflow.credentials.password", configuration,
                                foundNameList, null);
                        // get secondary property will return null if the requested property is missing
                        configuration.setThrowExceptionOnMissing(false);
                        final String linkedInAPIKey = getString("authz-server.linkedin.api-key", configuration,
                                foundNameList, null);
                        final String linkedInSecretKey = getString("authz-server.linkedin.secret-key",
                                configuration, foundNameList, null);
                        final String googleAPIKey = getString("rest-service.google.api-key", configuration,
                                foundNameList, null);
                        // get other (free-format) properties
                        final Iterator<String> keyIterator = configuration.getKeys();
                        final Map<String, String> othersMap = new Hashtable<String, String>();
                        while (keyIterator.hasNext()) {
                            final String key = keyIterator.next();
                            if (key != null && !foundNameList.contains(key)) {
                                final String value = configuration.getString(key);
                                if (value != null) {
                                    othersMap.put(key, value);
                                }
                            }
                        }
                        dont_use = new Configuration(rootDir, localCacheDir, htdocsDir, dbName, dbUsername,
                                dbPassword, dbHosts, brokerEmbedded, messageBrokers, smtpHost, smtpPort,
                                smtpSupportEmail, smtpNoreplyEmail, portalEndpoint, wfHostname, wfSecure,
                                wfPort, wfUsername, wfPasswd, linkedInAPIKey, linkedInSecretKey, googleAPIKey,
                                othersMap);
                        LOGGER.info(dont_use.toString());
                    } else {
                        throw new IllegalStateException("Main configuration not found");
                    }
                } catch (IllegalStateException e1) {
                    throw e1;
                } catch (ConfigurationException e2) {
                    throw new IllegalStateException(e2);
                } catch (Exception e) {
                    LOGGER.error("Failed to load configuration", e);
                }
            }
        }
    }
    return dont_use;
}

From source file:org.apache.sling.commons.metrics.internal.MetricWebConsolePlugin.java

private void addTimerDetails(PrintWriter pw, SortedMap<String, Timer> timers) {
    if (timers.isEmpty()) {
        return;// w w w  .j  a  va2  s . c o  m
    }

    pw.println("<br>");
    pw.println("<div class='table'>");
    pw.println("<div class='ui-widget-header ui-corner-top buttonGroup'>Timers</div>");
    pw.println("<table class='nicetable' id='data-timers'>");
    pw.println("<thead>");
    pw.println("<tr>");
    pw.println("<th class='header'>Name</th>");
    pw.println("<th class='header'>Count</th>");
    pw.println("<th class='header'>Mean Rate</th>");
    pw.println("<th class='header'>1 min rate</th>");
    pw.println("<th class='header'>5 mins rate</th>");
    pw.println("<th class='header'>15 mins rate</th>");
    pw.println("<th class='header'>50%</th>");
    pw.println("<th class='header'>Min</th>");
    pw.println("<th class='header'>Max</th>");
    pw.println("<th class='header'>Mean</th>");
    pw.println("<th class='header'>StdDev</th>");
    pw.println("<th class='header'>75%</th>");
    pw.println("<th class='header'>95%</th>");
    pw.println("<th class='header'>98%</th>");
    pw.println("<th class='header'>99%</th>");
    pw.println("<th class='header'>999%</th>");
    pw.println("<th>Rate Unit</th>");
    pw.println("<th>Duration Unit</th>");
    pw.println("</tr>");
    pw.println("</thead>");
    pw.println("<tbody>");

    String rowClass = "odd";
    for (Map.Entry<String, Timer> e : timers.entrySet()) {
        Timer t = e.getValue();
        Snapshot s = t.getSnapshot();
        String name = e.getKey();

        double rateFactor = timeUnit.rateFor(name).toSeconds(1);
        String rateUnit = "events/" + calculateRateUnit(timeUnit.rateFor(name));

        double durationFactor = 1.0 / timeUnit.durationFor(name).toNanos(1);
        String durationUnit = timeUnit.durationFor(name).toString().toLowerCase(Locale.US);

        pw.printf("<tr class='%s ui-state-default'>%n", rowClass);

        pw.printf("<td>%s</td>", name);
        pw.printf("<td>%d</td>", t.getCount());
        pw.printf("<td>%f</td>", t.getMeanRate() * rateFactor);
        pw.printf("<td>%f</td>", t.getOneMinuteRate() * rateFactor);
        pw.printf("<td>%f</td>", t.getFiveMinuteRate() * rateFactor);
        pw.printf("<td>%f</td>", t.getFifteenMinuteRate() * rateFactor);

        pw.printf("<td>%f</td>", s.getMedian() * durationFactor);
        pw.printf("<td>%f</td>", s.getMin() * durationFactor);
        pw.printf("<td>%f</td>", s.getMax() * durationFactor);
        pw.printf("<td>%f</td>", s.getMean() * durationFactor);
        pw.printf("<td>%f</td>", s.getStdDev() * durationFactor);

        pw.printf("<td>%f</td>", s.get75thPercentile() * durationFactor);
        pw.printf("<td>%f</td>", s.get95thPercentile() * durationFactor);
        pw.printf("<td>%f</td>", s.get98thPercentile() * durationFactor);
        pw.printf("<td>%f</td>", s.get99thPercentile() * durationFactor);
        pw.printf("<td>%f</td>", s.get999thPercentile() * durationFactor);

        pw.printf("<td>%s</td>", rateUnit);
        pw.printf("<td>%s</td>", durationUnit);

        pw.println("</tr>");
        rowClass = "odd".equals(rowClass) ? "even" : "odd";
    }

    pw.println("</tbody>");
    pw.println("</table>");
    pw.println("</div>");
}

From source file:io.wcm.handler.url.suffix.SuffixBuilder.java

/**
 * Build complete suffix./*from   ww w . j a v a2 s .co m*/
 * @return the suffix
 */
public String build() {
    SortedMap<String, Object> sortedParameterMap = new TreeMap<>(parameterMap);

    // gather resource paths in a treeset (having them in a defined order helps with caching)
    SortedSet<String> resourcePathsSet = new TreeSet<>();

    // iterate over all parts that should be kept from the current request
    for (String nextPart : initialSuffixParts) {
        // if this is a key-value-part:
        if (nextPart.indexOf(KEY_VALUE_DELIMITER) > 0) {
            String key = decodeKey(nextPart);
            // decode and keep the part if it is not overridden in the given parameter-map
            if (!sortedParameterMap.containsKey(key)) {
                String value = decodeValue(nextPart);
                sortedParameterMap.put(key, value);
            }
        } else {
            // decode and keep the resource paths (unless they are specified again in resourcePaths)
            String path = decodeResourcePathPart(nextPart);
            if (!resourcePaths.contains(path)) {
                resourcePathsSet.add(path);
            }
        }
    }

    // copy the resources specified as parameters to the sorted set of paths
    if (resourcePaths != null) {
        resourcePathsSet.addAll(ImmutableList.copyOf(resourcePaths));
    }

    // gather all suffix parts in this list
    List<String> suffixParts = new ArrayList<>();

    // now encode all resource paths
    for (String path : resourcePathsSet) {
        suffixParts.add(encodeResourcePathPart(path));
    }

    // now encode all entries from the parameter map
    for (Entry<String, Object> entry : sortedParameterMap.entrySet()) {
        Object value = entry.getValue();
        if (value == null) {
            // don't add suffix part if value is null
            continue;
        }
        String encodedKey = encodeKeyValuePart(entry.getKey());
        String encodedValue = encodeKeyValuePart(value.toString());
        suffixParts.add(encodedKey + KEY_VALUE_DELIMITER + encodedValue);
    }

    // finally join these parts to a single string
    return StringUtils.join(suffixParts, SUFFIX_PART_DELIMITER);
}