Madan Jampani | ccdf9da | 2016-05-05 14:37:27 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Madan Jampani | ccdf9da | 2016-05-05 14:37:27 -0700 | [diff] [blame] | 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 | */ |
| 16 | package org.onosproject.store.service; |
| 17 | |
| 18 | import java.util.Collection; |
| 19 | |
| 20 | import org.onosproject.cluster.NodeId; |
| 21 | import org.onosproject.cluster.PartitionId; |
Madan Jampani | ccdf9da | 2016-05-05 14:37:27 -0700 | [diff] [blame] | 22 | |
| 23 | import com.google.common.collect.ImmutableList; |
| 24 | |
| 25 | import static com.google.common.base.Preconditions.checkNotNull; |
| 26 | |
| 27 | /** |
| 28 | * Contains information about a database partition client. |
| 29 | */ |
| 30 | public class PartitionClientInfo { |
| 31 | private final PartitionId partitionId; |
Madan Jampani | ccdf9da | 2016-05-05 14:37:27 -0700 | [diff] [blame] | 32 | private final Collection<NodeId> servers; |
Madan Jampani | ccdf9da | 2016-05-05 14:37:27 -0700 | [diff] [blame] | 33 | |
Jordan Halterman | 2bf177c | 2017-06-29 01:49:08 -0700 | [diff] [blame] | 34 | public PartitionClientInfo(PartitionId partitionId, Collection<NodeId> servers) { |
Madan Jampani | ccdf9da | 2016-05-05 14:37:27 -0700 | [diff] [blame] | 35 | this.partitionId = checkNotNull(partitionId); |
| 36 | this.servers = ImmutableList.copyOf(checkNotNull(servers)); |
Madan Jampani | ccdf9da | 2016-05-05 14:37:27 -0700 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Returns the identifier for the partition. |
| 41 | * |
| 42 | * @return partition id |
| 43 | */ |
| 44 | public PartitionId partitionId() { |
| 45 | return partitionId; |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Returns the collection of servers that are members of the partition. |
| 50 | * |
| 51 | * @return active members of the partition |
| 52 | */ |
| 53 | public Collection<NodeId> servers() { |
| 54 | return servers; |
| 55 | } |
Madan Jampani | ccdf9da | 2016-05-05 14:37:27 -0700 | [diff] [blame] | 56 | } |