blob: 81a74c90ac19e12dbbd2c978ea79ad7c23460e2e [file] [log] [blame]
Jordan Haltermane3813a92017-07-29 14:10:31 -07001/*
2 * Copyright 2017-present Open Networking Laboratory
3 *
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
7 *
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.
15 */
16package org.onosproject.store.cluster.messaging.impl;
17
18import com.google.common.base.MoreObjects;
19
20import org.onlab.util.ByteArraySizeHashPrinter;
21import org.onosproject.core.HybridLogicalTime;
22import org.onosproject.store.cluster.messaging.Endpoint;
23
24/**
25 * Internal request message.
26 */
27public final class InternalRequest extends InternalMessage {
28 private final Endpoint sender;
29 private final String subject;
30
31 public InternalRequest(int preamble,
32 HybridLogicalTime time,
33 long id,
34 Endpoint sender,
35 String subject,
36 byte[] payload) {
37 super(preamble, time, id, payload);
38 this.sender = sender;
39 this.subject = subject;
40 }
41
42 @Override
43 public Type type() {
44 return Type.REQUEST;
45 }
46
47 public String subject() {
48 return subject;
49 }
50
51 public Endpoint sender() {
52 return sender;
53 }
54
55 @Override
56 public String toString() {
57 return MoreObjects.toStringHelper(this)
58 .add("time", time())
59 .add("id", id())
60 .add("subject", subject)
61 .add("sender", sender)
62 .add("payload", ByteArraySizeHashPrinter.of(payload()))
63 .toString();
64 }
65}