summaryrefslogtreecommitdiff
path: root/java/perftests/src/main/java/org/apache/qpid/disttest/message/ParticipantResult.java
blob: a6d3d91baeaeb4980ce4c44daa7c04863cb72958 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.apache.qpid.disttest.message;

import static org.apache.qpid.disttest.message.ParticipantAttribute.BATCH_SIZE;
import static org.apache.qpid.disttest.message.ParticipantAttribute.CONFIGURED_CLIENT_NAME;
import static org.apache.qpid.disttest.message.ParticipantAttribute.ITERATION_NUMBER;
import static org.apache.qpid.disttest.message.ParticipantAttribute.MAXIMUM_DURATION;
import static org.apache.qpid.disttest.message.ParticipantAttribute.PAYLOAD_SIZE;
import static org.apache.qpid.disttest.message.ParticipantAttribute.NUMBER_OF_MESSAGES_PROCESSED;
import static org.apache.qpid.disttest.message.ParticipantAttribute.THROUGHPUT;
import static org.apache.qpid.disttest.message.ParticipantAttribute.PARTICIPANT_NAME;
import static org.apache.qpid.disttest.message.ParticipantAttribute.TEST_NAME;

import java.util.Comparator;
import java.util.Date;
import java.util.Map;

public class ParticipantResult extends Response
{
    private String _testName;
    private String _participantName;
    private int _iterationNumber;

    private long _startInMillis;
    private long _endInMillis;
    private int _batchSize;
    private long _maximumDuration;

    private String _configuredClientName;

    private long _numberOfMessagesProcessed;
    private long _totalPayloadProcessed;
    private int _payloadSize;
    private double _throughput;

    private int _totalNumberOfConsumers;
    private int _totalNumberOfProducers;

    // As Session.SESSION_TRANSACTED is 0, we use value -1 so we can distinguish the case where an aggregated result
    // summarizes results from participants using different session acknowledge modes.
    private int _acknowledgeMode = -1;

    public static final Comparator<? super ParticipantResult> PARTICIPANT_NAME_COMPARATOR = new Comparator<ParticipantResult>()
    {
        @Override
        public int compare(ParticipantResult participantResult1, ParticipantResult participantResult2)
        {
            return participantResult1.getParticipantName().compareTo(participantResult2.getParticipantName());
        }
    };

    public ParticipantResult()
    {
        this(CommandType.PARTICIPANT_RESULT);
    }

    public ParticipantResult(CommandType commandType)
    {
        super(commandType);
    }

    public ParticipantResult(String participantName)
    {
        this();
        setParticipantName(participantName);
    }

    @OutputAttribute(attribute=TEST_NAME)
    public String getTestName()
    {
        return _testName;
    }

    public void setTestName(String testName)
    {
        _testName = testName;
    }

    @OutputAttribute(attribute=ITERATION_NUMBER)
    public int getIterationNumber()
    {
        return _iterationNumber;
    }

    public void setIterationNumber(int iterationNumber)
    {
        _iterationNumber = iterationNumber;
    }

    public void setStartDate(Date start)
    {
        _startInMillis = start.getTime();
    }

    public void setEndDate(Date end)
    {
        _endInMillis = end.getTime();
    }

    public Date getStartDate()
    {
        return new Date(_startInMillis);
    }

    public Date getEndDate()
    {
        return new Date(_endInMillis);
    }


    public long getStartInMillis()
    {
        return _startInMillis;
    }

    public long getEndInMillis()
    {
        return _endInMillis;
    }


    @OutputAttribute(attribute=PARTICIPANT_NAME)
    public String getParticipantName()
    {
        return _participantName;
    }


    public void setParticipantName(String participantName)
    {
        _participantName = participantName;
    }

    @OutputAttribute(attribute=ParticipantAttribute.TIME_TAKEN)
    public long getTimeTaken()
    {
        return _endInMillis - _startInMillis;
    }

    @OutputAttribute(attribute=CONFIGURED_CLIENT_NAME)
    public String getConfiguredClientName()
    {
        return _configuredClientName;
    }

    public void setConfiguredClientName(String configuredClientName)
    {
        _configuredClientName = configuredClientName;
    }

    @OutputAttribute(attribute=NUMBER_OF_MESSAGES_PROCESSED)
    public long getNumberOfMessagesProcessed()
    {
        return _numberOfMessagesProcessed;
    }

    public void setNumberOfMessagesProcessed(long numberOfMessagesProcessed)
    {
        _numberOfMessagesProcessed = numberOfMessagesProcessed;
    }

    @OutputAttribute(attribute=ParticipantAttribute.TOTAL_PAYLOAD_PROCESSED)
    public long getTotalPayloadProcessed()
    {
        return _totalPayloadProcessed;
    }

    @OutputAttribute(attribute = PAYLOAD_SIZE)
    public int getPayloadSize()
    {
        return _payloadSize;
    }

    public void setPayloadSize(int payloadSize)
    {
        _payloadSize = payloadSize;
    }

    public void setTotalPayloadProcessed(long totalPayloadProcessed)
    {
        _totalPayloadProcessed = totalPayloadProcessed;
    }

    public Map<ParticipantAttribute, Object> getAttributes()
    {
        return ParticipantAttributeExtractor.getAttributes(this);
    }

    public void setBatchSize(int batchSize)
    {
        _batchSize = batchSize;
    }

    @OutputAttribute(attribute=BATCH_SIZE)
    public int getBatchSize()
    {
        return _batchSize;
    }

    public void setMaximumDuration(long maximumDuration)
    {
        _maximumDuration = maximumDuration;
    }

    @OutputAttribute(attribute=MAXIMUM_DURATION)
    public long getMaximumDuration()
    {
        return _maximumDuration;
    }

    @OutputAttribute(attribute=THROUGHPUT)
    public double getThroughput()
    {
        return _throughput;
    }

    public void setThroughput(double throughput)
    {
        _throughput = throughput;
    }

    public void setTotalNumberOfConsumers(int totalNumberOfConsumers)
    {
        _totalNumberOfConsumers = totalNumberOfConsumers;
    }

    @OutputAttribute(attribute=ParticipantAttribute.TOTAL_NUMBER_OF_CONSUMERS)
    public int getTotalNumberOfConsumers()
    {
        return _totalNumberOfConsumers;
    }

    public void setTotalNumberOfProducers(int totalNumberOfProducers)
    {
        _totalNumberOfProducers = totalNumberOfProducers;
    }

    @OutputAttribute(attribute=ParticipantAttribute.TOTAL_NUMBER_OF_PRODUCERS)
    public int getTotalNumberOfProducers()
    {
        return _totalNumberOfProducers;
    }

    @OutputAttribute(attribute=ParticipantAttribute.ACKNOWLEDGE_MODE)
    public int getAcknowledgeMode()
    {
        return _acknowledgeMode;
    }

    public void setAcknowledgeMode(int acknowledgeMode)
    {
        _acknowledgeMode = acknowledgeMode;
    }

}