blob: 8f4dab32993715dbcbc64da434d47a85e8e26f5d [file] [log] [blame]
Madan Jampaniccdf9da2016-05-05 14:37:27 -07001/*
2 * Copyright 2016-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.service;
17
18import java.util.Collection;
19
20import org.onosproject.cluster.NodeId;
21import org.onosproject.cluster.PartitionId;
22import org.onosproject.store.service.DistributedPrimitive.Status;
23
24import com.google.common.collect.ImmutableList;
25
26import static com.google.common.base.Preconditions.checkNotNull;
27
28/**
29 * Contains information about a database partition client.
30 */
31public class PartitionClientInfo {
32 private final PartitionId partitionId;
33 private final Status status;
34 private final Collection<NodeId> servers;
35 private final long sessionId;
36
37 public PartitionClientInfo(PartitionId partitionId, Collection<NodeId> servers, long sessionId, Status status) {
38 this.partitionId = checkNotNull(partitionId);
39 this.servers = ImmutableList.copyOf(checkNotNull(servers));
40 this.sessionId = sessionId;
41 this.status = checkNotNull(status);
42 }
43
44 /**
45 * Returns the identifier for the partition.
46 *
47 * @return partition id
48 */
49 public PartitionId partitionId() {
50 return partitionId;
51 }
52
53 /**
54 * Returns the collection of servers that are members of the partition.
55 *
56 * @return active members of the partition
57 */
58 public Collection<NodeId> servers() {
59 return servers;
60 }
61
62 /**
63 * Return the sessionId for the partition client.
64 * @return session id
65 */
66 public long sessionId() {
67 return sessionId;
68 }
69
70 /**
71 * Returns the current status for the client session.
72 * @return status
73 */
74 public Status status() {
75 return status;
76 }
77}