Package com.streamreduce.util

Examples of com.streamreduce.util.Pair


        metricCriteria.put("RESOURCE_ID", "DiskReadBytes");
        metricCriteria.put("METRIC_ID", "average");

        NodebellyMessageTransformer transformer = setupTransformer();

        Pair pair = transformer.getUnitsLabel("INVENTORY_ITEM_RESOURCE_USAGE", metricCriteria, 1065.0, true);
        //System.out.println(pair.first + " " + pair.second);
        assert(((String)pair.second).startsWith(" "));
        assert(((String)pair.second).endsWith("Kb"));

        pair = transformer.getUnitsLabel("INVENTORY_ITEM_RESOURCE_USAGE", metricCriteria, 234234235.0, false);
View Full Code Here


        if (space && unit.length() > 0 && !unit.equals("%")) {
            unit = " " + unit;
        }

        return new Pair(value, unit);
    }
View Full Code Here

                        Map<String, String> metricCriteria = (Map<String, String>) item.get("metricCriteria");
                        String metricName = (String) item.get("name");
                        float origValue = ((Number) item.get("value")).floatValue();
                        float origDiff = ((Number) item.get("diff")).floatValue();

                        Pair pair = getUnitsLabel(metricName, metricCriteria, ((Number) item.get("value")).doubleValue(), true);
                        item.put("value", ((Number)pair.first).floatValue());

                        Pair pairDiff = getUnitsLabel(metricName, metricCriteria, ((Number) item.get("diff")).doubleValue(), true);
                        item.put("diff", ((Number)pairDiff.first).floatValue());

                        /*
                        * Just render an explanation subheader for the first item since it
                        * has the highest stddev and will be selected by the client
                        */
                        if (first) {
                            first = false;
                            String explanation = getMetricConfigValueNotNull(metricName, metricCriteria, "explanation");
                            double previous = origValue - origDiff;
                            if (metricName.equals("CONNECTION_RESOURCE_USAGE") && metricCriteria.containsKey("RESOURCE_ID")) { // TODO hack for IMG
                                explanation = metricCriteria.get("RESOURCE_ID") + " was previously at %.2f and is now at %.2f";
                            }
                            if (explanation.length() > 0) {
                                explanation = MessageFormat.format(explanation, String.valueOf(previous), String.valueOf(pair.first) );
                            }
                            item.put("subheader", explanation);
                        }

                        item.put("name", metricTypeNameReadable(metricName, metricCriteria));
                        item.put("metricname", metricName); // needed for debugging
                        item.put("unit", pair.second);
                    }

                    HashMap<String, Object> structure = new HashMap<>();
                    structure.put("accountId", meta.get("account"));
                    structure.put("total", meta.get("total"));
                    structure.put("diff", meta.get("diff"));
                    structure.put("type", providerId);
                    structure.put("items", items); // add the updated items
                    structure.put("granularity", meta.get("granularity"));

                    // set rich formatting properties
                    // the client will render the table in "structure" how it wants to
                    messageDetails = new NodebellySummaryMessageDetails.Builder()
                            .title(title)
                            .structure(structure)
                            .build();

                    // just print the key/value pairs for the plain text version
                    details = ((NodebellySummaryMessageDetails) messageDetails).toPlainText();
                }

                break;

            case NODEBELLY_ANOMALY:

                String connectionName = "";
                if (meta.containsKey("targetConnectionAlias")) {
                    connectionName = ((String) meta.get("targetConnectionAlias"));
                }
               
                String inventoryName = "";
                if (meta.containsKey("targetAlias")) {
                    inventoryName =  " for " + ((String) meta.get("targetAlias"));
                }
               
                providerId = (String) meta.get("targetProviderId");
                String metricName = (String) meta.get("name");
                float fValue = ((Number) meta.get("value")).floatValue();
                float fMean = ((Number) meta.get("mean")).floatValue();
                float fStddev = ((Number) meta.get("stddev")).floatValue();

                int nStdDev = Double.valueOf(Math.floor(Math.abs(fValue - fMean) / fStddev)).intValue();

                Pair pair1 = getUnitsLabel(metricName, topMetricCriteria, fValue, true);
                //Pair pair2 = getUnitsLabel(metricName, topMetricCriteria, fStddev, true);
                Pair pair3 = getUnitsLabel(metricName, topMetricCriteria, fMean, true);

                int severity = getSeverityLevel(fValue, fMean, fStddev);
                title = MessageFormat.format((String) messageProperties.get("message.nodebelly.anomalyseverity" + severity),
                        metricTypeNameReadable(metricName, topMetricCriteria),
                        connectionName);
View Full Code Here

TOP

Related Classes of com.streamreduce.util.Pair

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.