Search in sources :

Example 1 with MetricsInfo

use of jp.ossc.nimbus.service.aop.interceptor.MetricsInfo in project nimbus by nimbus-org.

the class SQLMetricsCollectorService method register.

private void register(String sql, long performance, boolean isException, boolean isError) {
    MetricsInfo metricsInfo = (MetricsInfo) metricsInfos.get(sql);
    if (metricsInfo == null) {
        if (maxMetricsSize > 0 && metricsInfos.size() > maxMetricsSize) {
            return;
        }
        metricsInfo = new MetricsInfo(sql, isCalculateOnlyNormal);
        MetricsInfo old = (MetricsInfo) metricsInfos.putIfAbsent(sql, metricsInfo);
        if (old != null) {
            metricsInfo = old;
        }
    }
    metricsInfo.calculate(performance, isException, isError);
}
Also used : MetricsInfo(jp.ossc.nimbus.service.aop.interceptor.MetricsInfo)

Example 2 with MetricsInfo

use of jp.ossc.nimbus.service.aop.interceptor.MetricsInfo in project nimbus by nimbus-org.

the class WsServiceMetricsHandlerService method handleMessage.

public boolean handleMessage(SOAPMessageContext context) {
    Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
    if (outboundProperty.booleanValue()) {
        performance.start();
    } else {
        performance.end();
        StringBuilder keyBuf = new StringBuilder();
        keyBuf.append(context.get(MessageContext.WSDL_SERVICE)).append('#').append(context.get(MessageContext.WSDL_PORT)).append('#').append(context.get(MessageContext.WSDL_OPERATION));
        String key = keyBuf.toString();
        MetricsInfo metricsInfo = (MetricsInfo) metricsInfos.get(key);
        if (metricsInfo == null) {
            metricsInfo = new MetricsInfo(key, isCalculateOnlyNormal);
            MetricsInfo old = (MetricsInfo) metricsInfos.putIfAbsent(key, metricsInfo);
            if (old != null) {
                metricsInfo = old;
            }
        }
        metricsInfo.calculate(performance.performance(), false, false);
    }
    return true;
}
Also used : MetricsInfo(jp.ossc.nimbus.service.aop.interceptor.MetricsInfo)

Example 3 with MetricsInfo

use of jp.ossc.nimbus.service.aop.interceptor.MetricsInfo in project nimbus by nimbus-org.

the class WsServiceMetricsHandlerService method displayMetricsInfo.

// WsServiceMetricsHandlerServiceMBeanのJavaDoc
public String displayMetricsInfo() {
    final MetricsInfo[] infos = (MetricsInfo[]) metricsInfos.values().toArray(new MetricsInfo[metricsInfos.size()]);
    Arrays.sort(infos, COMP);
    final SimpleDateFormat format = new SimpleDateFormat(dateFormat);
    final StringBuilder buf = new StringBuilder();
    buf.append("\"No.\"");
    if (isOutputCount) {
        buf.append(",\"Count\"");
    }
    if (isOutputExceptionCount) {
        buf.append(",\"ExceptionCount\"");
    }
    if (isOutputErrorCount) {
        buf.append(",\"ErrorCount\"");
    }
    if (isOutputLastTime) {
        buf.append(",\"LastTime\"");
    }
    if (isOutputLastExceptionTime) {
        buf.append(",\"LastExceptionTime\"");
    }
    if (isOutputLastErrorTime) {
        buf.append(",\"LastErrorTime\"");
    }
    if (isOutputBestPerformance) {
        buf.append(",\"Best performance[ms]\"");
    }
    if (isOutputBestPerformanceTime) {
        buf.append(",\"Best performance time\"");
    }
    if (isOutputWorstPerformance) {
        buf.append(",\"Worst performance[ms]\"");
    }
    if (isOutputWorstPerformanceTime) {
        buf.append(",\"Worst performance time\"");
    }
    if (isOutputAveragePerformance) {
        buf.append(",\"Average performance[ms]\"");
    }
    buf.append(",\"Key\"");
    buf.append(LINE_SEP);
    for (int i = 0; i < infos.length; i++) {
        buf.append('"').append(i + 1).append('"');
        if (isOutputCount) {
            buf.append(',').append('"').append(infos[i].getCount()).append('"');
        }
        if (isOutputExceptionCount) {
            buf.append(',').append('"').append(infos[i].getExceptionCount()).append('"');
        }
        if (isOutputErrorCount) {
            buf.append(',').append('"').append(infos[i].getErrorCount()).append('"');
        }
        if (isOutputLastTime) {
            if (infos[i].getLastTime() == 0) {
                buf.append(",\"\"");
            } else {
                buf.append(',').append('"').append(format.format(new Date(infos[i].getLastTime()))).append('"');
            }
        }
        if (isOutputLastExceptionTime) {
            if (infos[i].getLastExceptionTime() == 0) {
                buf.append(",\"\"");
            } else {
                buf.append(',').append('"').append(format.format(new Date(infos[i].getLastExceptionTime()))).append('"');
            }
        }
        if (isOutputLastErrorTime) {
            if (infos[i].getLastErrorTime() == 0) {
                buf.append(",\"\"");
            } else {
                buf.append('"').append(',').append(format.format(new Date(infos[i].getLastErrorTime()))).append('"');
            }
        }
        if (isOutputBestPerformance) {
            buf.append(',').append('"').append(infos[i].getBestPerformance()).append('"');
        }
        if (isOutputBestPerformanceTime) {
            if (infos[i].getBestPerformanceTime() == 0) {
                buf.append(",\"\"");
            } else {
                buf.append(',').append('"').append(format.format(new Date(infos[i].getBestPerformanceTime()))).append('"');
            }
        }
        if (isOutputWorstPerformance) {
            buf.append(',').append('"').append(infos[i].getWorstPerformance()).append('"');
        }
        if (isOutputWorstPerformanceTime) {
            if (infos[i].getWorstPerformanceTime() == 0) {
                buf.append(",\"\"");
            } else {
                buf.append(',').append('"').append(format.format(new Date(infos[i].getWorstPerformanceTime()))).append('"');
            }
        }
        if (isOutputAveragePerformance) {
            buf.append(',').append('"').append(infos[i].getAveragePerformance()).append('"');
        }
        buf.append(',').append('"').append(infos[i].getKey()).append('"');
        buf.append(LINE_SEP);
    }
    if (isOutputTimestamp) {
        buf.append(format.format(new Date())).append(LINE_SEP);
    }
    return buf.toString();
}
Also used : MetricsInfo(jp.ossc.nimbus.service.aop.interceptor.MetricsInfo) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 4 with MetricsInfo

use of jp.ossc.nimbus.service.aop.interceptor.MetricsInfo in project nimbus by nimbus-org.

the class WsServiceMetricsHandlerService method consume.

/**
 * 出力先が設定されていれば、。<p>
 *
 * @param dequeued null
 * @param ctrl DaemonControlオブジェクト
 */
public void consume(Object dequeued, DaemonControl ctrl) {
    Date timestamp = new Date();
    if (keyAndCategoryMap != null && keyAndCategoryMap.size() != 0) {
        final Iterator keys = keyAndCategoryMap.keySet().iterator();
        while (keys.hasNext()) {
            final String key = (String) keys.next();
            final Category category = (Category) keyAndCategoryMap.get(key);
            final MetricsInfo info = (MetricsInfo) metricsInfos.get(key);
            if (info != null && category != null) {
                try {
                    category.write(createRecord(timestamp, info));
                } catch (MessageWriteException e) {
                // TODO ログ出力
                }
            }
        }
    }
    if (metricsCategory != null) {
        final MetricsInfo[] infos = (MetricsInfo[]) metricsInfos.values().toArray(new MetricsInfo[metricsInfos.size()]);
        Arrays.sort(infos, COMP);
        for (int i = 0; i < infos.length; i++) {
            try {
                metricsCategory.write(createRecord(timestamp, i + 1, infos[i]));
            } catch (MessageWriteException e) {
            // TODO ログ出力
            }
        }
    }
    if (isResetByOutput) {
        final MetricsInfo[] infos = (MetricsInfo[]) metricsInfos.values().toArray(new MetricsInfo[metricsInfos.size()]);
        for (int i = 0; i < infos.length; i++) {
            infos[i].reset();
        }
    }
}
Also used : MetricsInfo(jp.ossc.nimbus.service.aop.interceptor.MetricsInfo) Category(jp.ossc.nimbus.service.writer.Category) Iterator(java.util.Iterator) MessageWriteException(jp.ossc.nimbus.service.writer.MessageWriteException) Date(java.util.Date)

Example 5 with MetricsInfo

use of jp.ossc.nimbus.service.aop.interceptor.MetricsInfo in project nimbus by nimbus-org.

the class WsServiceMetricsHandlerService method handleFault.

public boolean handleFault(SOAPMessageContext context) {
    performance.end();
    StringBuilder keyBuf = new StringBuilder();
    keyBuf.append(context.get(MessageContext.WSDL_SERVICE)).append('#').append(context.get(MessageContext.WSDL_PORT)).append('#').append(context.get(MessageContext.WSDL_OPERATION));
    String key = keyBuf.toString();
    MetricsInfo metricsInfo = (MetricsInfo) metricsInfos.get(key);
    if (metricsInfo == null) {
        metricsInfo = new MetricsInfo(key, isCalculateOnlyNormal);
        MetricsInfo old = (MetricsInfo) metricsInfos.putIfAbsent(key, metricsInfo);
        if (old != null) {
            metricsInfo = old;
        }
    }
    metricsInfo.calculate(performance.performance(), true, false);
    return true;
}
Also used : MetricsInfo(jp.ossc.nimbus.service.aop.interceptor.MetricsInfo)

Aggregations

MetricsInfo (jp.ossc.nimbus.service.aop.interceptor.MetricsInfo)7 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 Iterator (java.util.Iterator)1 Category (jp.ossc.nimbus.service.writer.Category)1 MessageWriteException (jp.ossc.nimbus.service.writer.MessageWriteException)1