Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 1 | /* |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 2 | * Copyright 2014 Open Networking Laboratory |
Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 3 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 7 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
Thomas Vachuska | 781d18b | 2014-10-27 10:31:25 -0700 | [diff] [blame] | 15 | */ |
tom | f110fff | 2014-09-26 00:38:18 -0700 | [diff] [blame] | 16 | package org.onlab.onos.foo; |
| 17 | |
| 18 | import org.onlab.nio.AbstractMessage; |
| 19 | |
tom | 0e0863f | 2014-09-26 09:02:33 -0700 | [diff] [blame] | 20 | import static com.google.common.base.Preconditions.checkNotNull; |
| 21 | |
tom | f110fff | 2014-09-26 00:38:18 -0700 | [diff] [blame] | 22 | /** |
tom | 0e0863f | 2014-09-26 09:02:33 -0700 | [diff] [blame] | 23 | * Test message for measuring rate and round-trip latency. |
tom | f110fff | 2014-09-26 00:38:18 -0700 | [diff] [blame] | 24 | */ |
| 25 | public class TestMessage extends AbstractMessage { |
| 26 | |
tom | 0e0863f | 2014-09-26 09:02:33 -0700 | [diff] [blame] | 27 | private final byte[] padding; |
tom | f110fff | 2014-09-26 00:38:18 -0700 | [diff] [blame] | 28 | |
tom | 0e0863f | 2014-09-26 09:02:33 -0700 | [diff] [blame] | 29 | private final long requestorTime; |
| 30 | private final long responderTime; |
tom | f110fff | 2014-09-26 00:38:18 -0700 | [diff] [blame] | 31 | |
| 32 | /** |
| 33 | * Creates a new message with the specified data. |
| 34 | * |
Thomas Vachuska | b14c77a | 2014-11-04 18:08:01 -0800 | [diff] [blame] | 35 | * @param length message length |
tom | 0e0863f | 2014-09-26 09:02:33 -0700 | [diff] [blame] | 36 | * @param requestorTime requester time |
| 37 | * @param responderTime responder time |
| 38 | * @param padding message padding |
tom | f110fff | 2014-09-26 00:38:18 -0700 | [diff] [blame] | 39 | */ |
tom | 0e0863f | 2014-09-26 09:02:33 -0700 | [diff] [blame] | 40 | TestMessage(int length, long requestorTime, long responderTime, byte[] padding) { |
| 41 | this.length = length; |
| 42 | this.requestorTime = requestorTime; |
| 43 | this.responderTime = responderTime; |
| 44 | this.padding = checkNotNull(padding, "Padding cannot be null"); |
tom | f110fff | 2014-09-26 00:38:18 -0700 | [diff] [blame] | 45 | } |
| 46 | |
tom | 0e0863f | 2014-09-26 09:02:33 -0700 | [diff] [blame] | 47 | public long requestorTime() { |
| 48 | return requestorTime; |
| 49 | } |
| 50 | |
| 51 | public long responderTime() { |
| 52 | return responderTime; |
| 53 | } |
| 54 | |
| 55 | public byte[] padding() { |
| 56 | return padding; |
tom | f110fff | 2014-09-26 00:38:18 -0700 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | } |