Mercurial > stress-tester
changeset 1247:1deac0382914
FlowMetric.errors map
author | Devel 2 |
---|---|
date | Wed, 01 Jul 2020 11:55:49 +0200 |
parents | e0a246f43a80 |
children | d8b7a6da8618 |
files | stress-tester/src/main/java/com/passus/st/client/FlowError.java stress-tester/src/main/java/com/passus/st/client/FlowMetric.java stress-tester/src/main/java/com/passus/st/client/FlowProcessor.java stress-tester/src/main/java/com/passus/st/client/FlowWorkerBase.java |
diffstat | 4 files changed, 48 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/client/FlowError.java Wed Jul 01 10:06:34 2020 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/FlowError.java Wed Jul 01 11:55:49 2020 +0200 @@ -26,19 +26,20 @@ public static final byte CODE_CONNECTION_RESET_BY_PEER = 11; public static final byte CODE_SOCKET_ERROR = 12; public static final byte CODE_IO_ERROR = 13; - public static final byte CODE_MAX_ENCODER_ERRORS_REACHED = 14; - public static final byte CODE_MAX_DECODER_ERRORS_REACHED = 15; - public static final byte CODE_MAX_SEND_ERRORS_REACHED = 16; - public static final byte CODE_IDE_TIMEOUT = 17; + public static final byte CODE_DECODER_ERROR = 14; + public static final byte CODE_MAX_ENCODER_ERRORS_REACHED = 15; + public static final byte CODE_MAX_DECODER_ERRORS_REACHED = 16; + public static final byte CODE_MAX_SEND_ERRORS_REACHED = 17; + public static final byte CODE_IDE_TIMEOUT = 18; - public static final byte BIND_ADDRESS_ALREADY_IN_USE = 18; - public static final byte BIND_CANNOT_ASSIGN_ADDRESS = 19; - public static final byte BIND_MAPPER_INVALID = 20; - public static final byte BIND_OTHER = 21; + public static final byte BIND_ADDRESS_ALREADY_IN_USE = 19; + public static final byte BIND_CANNOT_ASSIGN_ADDRESS = 20; + public static final byte BIND_MAPPER_INVALID = 21; + public static final byte BIND_OTHER = 22; - public static final byte CODE_SSL_ERROR = 22; - public static final byte CODE_SSL_UNRECOGNIZED_MESSAGE_ERROR = 23; - public static final byte CODE_SSL_HANDSHAKE_ERROR = 24; + public static final byte CODE_SSL_ERROR = 23; + public static final byte CODE_SSL_UNRECOGNIZED_MESSAGE_ERROR = 24; + public static final byte CODE_SSL_HANDSHAKE_ERROR = 25; public static final byte CODE_INTERNAL_ERROR = (byte) 255; @@ -121,6 +122,8 @@ return "Networking socket error."; case CODE_IO_ERROR: return "Networking IO error."; + case CODE_DECODER_ERROR: + return "Decoder error."; case CODE_MAX_ENCODER_ERRORS_REACHED: return "Max encoder errors reached."; case CODE_MAX_SEND_ERRORS_REACHED:
--- a/stress-tester/src/main/java/com/passus/st/client/FlowMetric.java Wed Jul 01 10:06:34 2020 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/FlowMetric.java Wed Jul 01 11:55:49 2020 +0200 @@ -5,6 +5,10 @@ import com.passus.commons.metric.Metric; import org.apache.commons.lang3.mutable.MutableInt; +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + public class FlowMetric extends GenericMetric { public static final String FLOW_METRIC = "Flow"; @@ -15,7 +19,7 @@ private final MutableInt responsesNum = new MutableInt(0); - private final MutableInt errorsNum = new MutableInt(0); + private final Map<String, MutableInt> errors = new HashMap<>(); private final LongHistogramMetric requestSizeHistogram = new LongHistogramMetricImpl(DEFAULT_HISTOGRAM_VALUES); @@ -27,7 +31,7 @@ super(FLOW_METRIC); attrs.put("requests", requestsNum); attrs.put("responses", responsesNum); - attrs.put("errors", errorsNum); + attrs.put("errors", (Serializable) errors); attrs.put("requestSendTimeDist", requestSendingTimeHistogram); attrs.put("requestSizeDist", requestSizeHistogram); attrs.put("responseSizeDist", responseSizeHistogram); @@ -42,8 +46,28 @@ responsesNum.increment(); } - public void incErrorNum() { - errorsNum.increment(); + public void error(Throwable cause) { + FlowError flowError = FlowError.interpret(cause); + error(flowError); + } + + public void error(int errorCode) { + String msg = FlowError.codeToString(errorCode); + incErrorByCategory(msg); + } + + public void error(FlowError flowError) { + incErrorByCategory(flowError.message()); + } + + private void incErrorByCategory(String category) { + MutableInt count = errors.get(category); + if (count == null) { + count = new MutableInt(1); + errors.put(category, count); + } else { + count.increment(); + } } public int getRequestsNum() { @@ -85,7 +109,7 @@ @Override public void update(Metric metric) { FlowMetric flowMetric = (FlowMetric) metric; - errorsNum.add(flowMetric.errorsNum); + Metric.updateCountMap(errors, flowMetric.errors); requestsNum.add(flowMetric.requestsNum); responsesNum.add(flowMetric.responsesNum); requestSendingTimeHistogram.update(flowMetric.requestSendingTimeHistogram); @@ -96,7 +120,7 @@ @Override public void reset() { - errorsNum.setValue(0); + errors.clear(); requestsNum.setValue(0); responsesNum.setValue(0); requestSendingTimeHistogram.reset();
--- a/stress-tester/src/main/java/com/passus/st/client/FlowProcessor.java Wed Jul 01 10:06:34 2020 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/FlowProcessor.java Wed Jul 01 11:55:49 2020 +0200 @@ -448,7 +448,7 @@ if (decoder.state() == DataDecoder.STATE_ERROR) { if (collectMetric) { synchronized (metric) { - metric.incErrorNum(); + metric.error(CODE_DECODER_ERROR); } } @@ -495,7 +495,7 @@ } catch (Exception e) { if (collectMetric) { synchronized (metric) { - metric.incErrorNum(); + metric.error(e); } }
--- a/stress-tester/src/main/java/com/passus/st/client/FlowWorkerBase.java Wed Jul 01 10:06:34 2020 +0200 +++ b/stress-tester/src/main/java/com/passus/st/client/FlowWorkerBase.java Wed Jul 01 11:55:49 2020 +0200 @@ -506,7 +506,7 @@ if (decoder.state() == DataDecoder.STATE_ERROR) { if (collectMetrics) { synchronized (metric) { - metric.incErrorNum(); + metric.error(CODE_DECODER_ERROR); } } @@ -548,7 +548,7 @@ } catch (Exception e) { if (collectMetrics) { synchronized (metric) { - metric.incErrorNum(); + metric.error(e); } }