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