Example usage for java.util SortedMap size

List of usage examples for java.util SortedMap size

Introduction

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

Prototype

int size();

Source Link

Document

Returns the number of key-value mappings in this map.

Usage

From source file:com.streamsets.pipeline.stage.processor.statsaggregation.TestMetricAggregationProcessor.java

@Test
public void testInit() throws StageException {

    MetricRegistry metrics = metricAggregationProcessor.getMetrics();
    SortedMap<String, Timer> timers = metrics.getTimers();

    Assert.assertEquals(5, timers.size()); // 1 each for 4 stages, 1 for pipeline

    SortedMap<String, Counter> counters = metrics.getCounters();
    Assert.assertEquals(3, counters.size()); // one for each output lane in pipeline

    SortedMap<String, Meter> meters = metrics.getMeters();
    Assert.assertEquals(24, meters.size()); // 4 each for 4 stages, 5 for pipeline, one each for 3 output lanes

    SortedMap<String, Histogram> histograms = metrics.getHistograms();
    Assert.assertEquals(20, histograms.size()); // 4 each for 4 stages, 4 for pipeline
}

From source file:com.streamsets.pipeline.stage.processor.statsaggregation.TestMetricAggregationProcessor.java

@Test
public void testMetricEvaluation() throws StageException {

    MetricsRuleDefinition metricsRuleDefinition1 = new MetricsRuleDefinition("badRecordsAlertID",
            "High incidence of Bad Records", "pipeline.batchErrorRecords.meter", MetricType.METER,
            MetricElement.METER_COUNT, "${value() > 400}", false, true, System.currentTimeMillis());

    MetricsRuleDefinition metricsRuleDefinition2 = new MetricsRuleDefinition(
            "testMetricAggregation1458001548262", "Field Hasher Drops Records",
            "stage.com_streamsets_pipeline_stage_processor_fieldhasher_FieldHasherDProcessor_1.outputRecords.meter",
            MetricType.METER, MetricElement.METER_COUNT, "${value() < 1800}", false, true,
            System.currentTimeMillis());

    Record metricRuleChangeRecord1 = AggregatorUtil.createMetricRuleChangeRecord(metricsRuleDefinition1);
    Record metricRuleChangeRecord2 = AggregatorUtil.createMetricRuleChangeRecord(metricsRuleDefinition2);
    Record metricRecord1 = createTestMetricRecord();
    Record metricRecord2 = createTestMetricRecord();
    runner.runProcess(//w w w. j  av a2 s .c  o  m
            Arrays.asList(metricRuleChangeRecord1, metricRuleChangeRecord2, metricRecord1, metricRecord2));

    // look for alert gauges
    MetricRegistry metrics = metricAggregationProcessor.getMetrics();
    SortedMap<String, Gauge> gauges = metrics.getGauges();
    Assert.assertEquals(2, gauges.size());

    Gauge gauge = gauges.get(AlertsUtil.getAlertGaugeName(metricsRuleDefinition1.getId()) + ".gauge");
    Map<String, Object> alertResponse = (Map<String, Object>) gauge.getValue();
    Assert.assertEquals(500L, alertResponse.get("currentValue"));
    Assert.assertEquals("High incidence of Bad Records",
            ((List<String>) alertResponse.get("alertTexts")).iterator().next());

    gauge = gauges.get(AlertsUtil.getAlertGaugeName(metricsRuleDefinition2.getId()) + ".gauge");
    alertResponse = (Map<String, Object>) gauge.getValue();
    Assert.assertEquals(1500L, alertResponse.get("currentValue"));
    Assert.assertEquals("Field Hasher Drops Records",
            ((List<String>) alertResponse.get("alertTexts")).iterator().next());

}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccXMsgClient.CFAccXMsgClientSecUserTable.java

public CFAccSecUserBuff[] readAllDerived(CFAccAuthorization Authorization) {
    final String S_ProcName = "readAllDerived";
    String rqst = CFAccXMsgSchemaMessageFormatter.formatRqstXmlPreamble() + "\n" + "\t"
            + CFAccXMsgSecUserMessageFormatter.formatSecUserRqstReadAll("\n\t\t\t") + "\n"
            + CFAccXMsgSchemaMessageFormatter.formatRqstXmlPostamble();
    String rspn = schema.sendReceive(Authorization, rqst);
    if ((rspn == null) || (rspn.length() <= 0)) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "rspn");
    }/*  w  w  w.  ja  v  a 2 s. c  om*/
    CFAccXMsgRspnHandler responseHandler = schema.getResponseHandler();
    responseHandler.parseStringContents(rspn);
    CFLibRuntimeException exceptionRaised = responseHandler.getExceptionRaised();
    if (exceptionRaised != null) {
        throw exceptionRaised;
    }
    Object sortedMapObj = responseHandler.getSortedMapOfObjects();
    if (sortedMapObj == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                "responseHandler.getSortedMapOfObjects");
    }
    SortedMap<CFAccSecUserPKey, ICFAccSecUserObj> sortedMap = (SortedMap<CFAccSecUserPKey, ICFAccSecUserObj>) sortedMapObj;
    int sz = sortedMap.size();
    CFAccSecUserBuff arr[] = new CFAccSecUserBuff[sz];
    Iterator<ICFAccSecUserObj> iter = sortedMap.values().iterator();
    ICFAccSecUserObj cur;
    for (int idx = 0; idx < sz; idx++) {
        cur = (ICFAccSecUserObj) iter.next();
        arr[idx] = cur.getSecUserBuff();
    }
    return (arr);
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstXMsgClient.CFAstXMsgClientSecUserTable.java

public CFAstSecUserBuff[] readAllDerived(CFAstAuthorization Authorization) {
    final String S_ProcName = "readAllDerived";
    String rqst = CFAstXMsgSchemaMessageFormatter.formatRqstXmlPreamble() + "\n" + "\t"
            + CFAstXMsgSecUserMessageFormatter.formatSecUserRqstReadAll("\n\t\t\t") + "\n"
            + CFAstXMsgSchemaMessageFormatter.formatRqstXmlPostamble();
    String rspn = schema.sendReceive(Authorization, rqst);
    if ((rspn == null) || (rspn.length() <= 0)) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "rspn");
    }//w ww  . jav  a  2s  .  c o m
    CFAstXMsgRspnHandler responseHandler = schema.getResponseHandler();
    responseHandler.parseStringContents(rspn);
    CFLibRuntimeException exceptionRaised = responseHandler.getExceptionRaised();
    if (exceptionRaised != null) {
        throw exceptionRaised;
    }
    Object sortedMapObj = responseHandler.getSortedMapOfObjects();
    if (sortedMapObj == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                "responseHandler.getSortedMapOfObjects");
    }
    SortedMap<CFAstSecUserPKey, ICFAstSecUserObj> sortedMap = (SortedMap<CFAstSecUserPKey, ICFAstSecUserObj>) sortedMapObj;
    int sz = sortedMap.size();
    CFAstSecUserBuff arr[] = new CFAstSecUserBuff[sz];
    Iterator<ICFAstSecUserObj> iter = sortedMap.values().iterator();
    ICFAstSecUserObj cur;
    for (int idx = 0; idx < sz; idx++) {
        cur = (ICFAstSecUserObj) iter.next();
        arr[idx] = cur.getSecUserBuff();
    }
    return (arr);
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccXMsgClient.CFAccXMsgClientMimeTypeTable.java

public CFAccMimeTypeBuff[] readAllDerived(CFAccAuthorization Authorization) {
    final String S_ProcName = "readAllDerived";
    String rqst = CFAccXMsgSchemaMessageFormatter.formatRqstXmlPreamble() + "\n" + "\t"
            + CFAccXMsgMimeTypeMessageFormatter.formatMimeTypeRqstReadAll("\n\t\t\t") + "\n"
            + CFAccXMsgSchemaMessageFormatter.formatRqstXmlPostamble();
    String rspn = schema.sendReceive(Authorization, rqst);
    if ((rspn == null) || (rspn.length() <= 0)) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "rspn");
    }/*from  w  w  w. j a va  2s  . c o m*/
    CFAccXMsgRspnHandler responseHandler = schema.getResponseHandler();
    responseHandler.parseStringContents(rspn);
    CFLibRuntimeException exceptionRaised = responseHandler.getExceptionRaised();
    if (exceptionRaised != null) {
        throw exceptionRaised;
    }
    Object sortedMapObj = responseHandler.getSortedMapOfObjects();
    if (sortedMapObj == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                "responseHandler.getSortedMapOfObjects");
    }
    SortedMap<CFAccMimeTypePKey, ICFAccMimeTypeObj> sortedMap = (SortedMap<CFAccMimeTypePKey, ICFAccMimeTypeObj>) sortedMapObj;
    int sz = sortedMap.size();
    CFAccMimeTypeBuff arr[] = new CFAccMimeTypeBuff[sz];
    Iterator<ICFAccMimeTypeObj> iter = sortedMap.values().iterator();
    ICFAccMimeTypeObj cur;
    for (int idx = 0; idx < sz; idx++) {
        cur = (ICFAccMimeTypeObj) iter.next();
        arr[idx] = cur.getMimeTypeBuff();
    }
    return (arr);
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstXMsgClient.CFAstXMsgClientMimeTypeTable.java

public CFAstMimeTypeBuff[] readAllDerived(CFAstAuthorization Authorization) {
    final String S_ProcName = "readAllDerived";
    String rqst = CFAstXMsgSchemaMessageFormatter.formatRqstXmlPreamble() + "\n" + "\t"
            + CFAstXMsgMimeTypeMessageFormatter.formatMimeTypeRqstReadAll("\n\t\t\t") + "\n"
            + CFAstXMsgSchemaMessageFormatter.formatRqstXmlPostamble();
    String rspn = schema.sendReceive(Authorization, rqst);
    if ((rspn == null) || (rspn.length() <= 0)) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "rspn");
    }/*ww  w.j a v a  2s. com*/
    CFAstXMsgRspnHandler responseHandler = schema.getResponseHandler();
    responseHandler.parseStringContents(rspn);
    CFLibRuntimeException exceptionRaised = responseHandler.getExceptionRaised();
    if (exceptionRaised != null) {
        throw exceptionRaised;
    }
    Object sortedMapObj = responseHandler.getSortedMapOfObjects();
    if (sortedMapObj == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                "responseHandler.getSortedMapOfObjects");
    }
    SortedMap<CFAstMimeTypePKey, ICFAstMimeTypeObj> sortedMap = (SortedMap<CFAstMimeTypePKey, ICFAstMimeTypeObj>) sortedMapObj;
    int sz = sortedMap.size();
    CFAstMimeTypeBuff arr[] = new CFAstMimeTypeBuff[sz];
    Iterator<ICFAstMimeTypeObj> iter = sortedMap.values().iterator();
    ICFAstMimeTypeObj cur;
    for (int idx = 0; idx < sz; idx++) {
        cur = (ICFAstMimeTypeObj) iter.next();
        arr[idx] = cur.getMimeTypeBuff();
    }
    return (arr);
}

From source file:net.sourceforge.msscodefactory.cfgcash.v2_0.CFGCashXMsgClient.CFGCashXMsgClientMimeTypeTable.java

public CFGCashMimeTypeBuff[] readAllDerived(CFGCashAuthorization Authorization) {
    final String S_ProcName = "readAllDerived";
    String rqst = CFGCashXMsgSchemaMessageFormatter.formatRqstXmlPreamble() + "\n" + "\t"
            + CFGCashXMsgMimeTypeMessageFormatter.formatMimeTypeRqstReadAll("\n\t\t\t") + "\n"
            + CFGCashXMsgSchemaMessageFormatter.formatRqstXmlPostamble();
    String rspn = schema.sendReceive(Authorization, rqst);
    if ((rspn == null) || (rspn.length() <= 0)) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "rspn");
    }/*from   w ww. ja v  a 2s.com*/
    CFGCashXMsgRspnHandler responseHandler = schema.getResponseHandler();
    responseHandler.parseStringContents(rspn);
    CFLibRuntimeException exceptionRaised = responseHandler.getExceptionRaised();
    if (exceptionRaised != null) {
        throw exceptionRaised;
    }
    Object sortedMapObj = responseHandler.getSortedMapOfObjects();
    if (sortedMapObj == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                "responseHandler.getSortedMapOfObjects");
    }
    SortedMap<CFGCashMimeTypePKey, ICFGCashMimeTypeObj> sortedMap = (SortedMap<CFGCashMimeTypePKey, ICFGCashMimeTypeObj>) sortedMapObj;
    int sz = sortedMap.size();
    CFGCashMimeTypeBuff arr[] = new CFGCashMimeTypeBuff[sz];
    Iterator<ICFGCashMimeTypeObj> iter = sortedMap.values().iterator();
    ICFGCashMimeTypeObj cur;
    for (int idx = 0; idx < sz; idx++) {
        cur = (ICFGCashMimeTypeObj) iter.next();
        arr[idx] = cur.getMimeTypeBuff();
    }
    return (arr);
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccXMsgClient.CFAccXMsgClientVersionTable.java

public CFAccVersionBuff[] readAllDerived(CFAccAuthorization Authorization) {
    final String S_ProcName = "readAllDerived";
    String rqst = CFAccXMsgSchemaMessageFormatter.formatRqstXmlPreamble() + "\n" + "\t"
            + CFAccXMsgVersionMessageFormatter.formatVersionRqstReadAll("\n\t\t\t") + "\n"
            + CFAccXMsgSchemaMessageFormatter.formatRqstXmlPostamble();
    String rspn = schema.sendReceive(Authorization, rqst);
    if ((rspn == null) || (rspn.length() <= 0)) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "rspn");
    }// w w  w.  j a va 2  s .c  o m
    CFAccXMsgRspnHandler responseHandler = schema.getResponseHandler();
    responseHandler.parseStringContents(rspn);
    CFLibRuntimeException exceptionRaised = responseHandler.getExceptionRaised();
    if (exceptionRaised != null) {
        throw exceptionRaised;
    }
    Object sortedMapObj = responseHandler.getSortedMapOfObjects();
    if (sortedMapObj == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                "responseHandler.getSortedMapOfObjects");
    }
    SortedMap<CFAccDomainBasePKey, ICFAccDomainBaseObj> sortedMap = (SortedMap<CFAccDomainBasePKey, ICFAccDomainBaseObj>) sortedMapObj;
    int sz = sortedMap.size();
    CFAccVersionBuff arr[] = new CFAccVersionBuff[sz];
    Iterator<ICFAccDomainBaseObj> iter = sortedMap.values().iterator();
    ICFAccVersionObj cur;
    for (int idx = 0; idx < sz; idx++) {
        cur = (ICFAccVersionObj) iter.next();
        arr[idx] = cur.getVersionBuff();
    }
    return (arr);
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccXMsgClient.CFAccXMsgClientVersionTable.java

public CFAccVersionBuff[] readDerivedByTenantIdx(CFAccAuthorization Authorization, long argTenantId) {
    final String S_ProcName = "readDerivedByTenantIdx";
    String rqst = CFAccXMsgSchemaMessageFormatter.formatRqstXmlPreamble() + "\n" + "\t"
            + CFAccXMsgVersionMessageFormatter.formatVersionRqstReadByTenantIdx("\n\t\t\t", argTenantId) + "\n"
            + CFAccXMsgSchemaMessageFormatter.formatRqstXmlPostamble();
    String rspn = schema.sendReceive(Authorization, rqst);
    if ((rspn == null) || (rspn.length() <= 0)) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "rspn");
    }/*from   w  w w .j  a  v a 2s. c om*/
    CFAccXMsgRspnHandler responseHandler = schema.getResponseHandler();
    responseHandler.parseStringContents(rspn);
    CFLibRuntimeException exceptionRaised = responseHandler.getExceptionRaised();
    if (exceptionRaised != null) {
        throw exceptionRaised;
    }
    Object sortedMapObj = responseHandler.getSortedMapOfObjects();
    if (sortedMapObj == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                "responseHandler.getSortedMapOfObjects");
    }
    SortedMap<CFAccDomainBasePKey, ICFAccDomainBaseObj> sortedMap = (SortedMap<CFAccDomainBasePKey, ICFAccDomainBaseObj>) sortedMapObj;
    int sz = sortedMap.size();
    CFAccVersionBuff arr[] = new CFAccVersionBuff[sz];
    Iterator<ICFAccDomainBaseObj> iter = sortedMap.values().iterator();
    ICFAccVersionObj cur;
    for (int idx = 0; idx < sz; idx++) {
        cur = (ICFAccVersionObj) iter.next();
        arr[idx] = cur.getVersionBuff();
    }
    return (arr);
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstXMsgClient.CFAstXMsgClientVersionTable.java

public CFAstVersionBuff[] readAllDerived(CFAstAuthorization Authorization) {
    final String S_ProcName = "readAllDerived";
    String rqst = CFAstXMsgSchemaMessageFormatter.formatRqstXmlPreamble() + "\n" + "\t"
            + CFAstXMsgVersionMessageFormatter.formatVersionRqstReadAll("\n\t\t\t") + "\n"
            + CFAstXMsgSchemaMessageFormatter.formatRqstXmlPostamble();
    String rspn = schema.sendReceive(Authorization, rqst);
    if ((rspn == null) || (rspn.length() <= 0)) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "rspn");
    }//from   www .j  a va  2s.  c o m
    CFAstXMsgRspnHandler responseHandler = schema.getResponseHandler();
    responseHandler.parseStringContents(rspn);
    CFLibRuntimeException exceptionRaised = responseHandler.getExceptionRaised();
    if (exceptionRaised != null) {
        throw exceptionRaised;
    }
    Object sortedMapObj = responseHandler.getSortedMapOfObjects();
    if (sortedMapObj == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                "responseHandler.getSortedMapOfObjects");
    }
    SortedMap<CFAstDomainBasePKey, ICFAstDomainBaseObj> sortedMap = (SortedMap<CFAstDomainBasePKey, ICFAstDomainBaseObj>) sortedMapObj;
    int sz = sortedMap.size();
    CFAstVersionBuff arr[] = new CFAstVersionBuff[sz];
    Iterator<ICFAstDomainBaseObj> iter = sortedMap.values().iterator();
    ICFAstVersionObj cur;
    for (int idx = 0; idx < sz; idx++) {
        cur = (ICFAstVersionObj) iter.next();
        arr[idx] = cur.getVersionBuff();
    }
    return (arr);
}