Jonathan Hart | 054da97 | 2015-02-18 17:30:28 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
Jonathan Hart | 054da97 | 2015-02-18 17:30:28 -0800 | [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 | |
Jonathan Hart | 054da97 | 2015-02-18 17:30:28 -0800 | [diff] [blame] | 18 | import java.util.List; |
| 19 | |
Jordan Halterman | 980a8c1 | 2017-09-22 18:01:19 -0700 | [diff] [blame] | 20 | import com.google.common.collect.ImmutableList; |
| 21 | import org.onosproject.cluster.PartitionId; |
| 22 | |
Jonathan Hart | 054da97 | 2015-02-18 17:30:28 -0800 | [diff] [blame] | 23 | /** |
| 24 | * Contains information about a database partition. |
| 25 | */ |
| 26 | public class PartitionInfo { |
Jordan Halterman | 980a8c1 | 2017-09-22 18:01:19 -0700 | [diff] [blame] | 27 | private final PartitionId partitionId; |
Jonathan Hart | 054da97 | 2015-02-18 17:30:28 -0800 | [diff] [blame] | 28 | private final long term; |
| 29 | private final List<String> members; |
| 30 | private final String leader; |
| 31 | |
| 32 | /** |
| 33 | * Class constructor. |
| 34 | * |
Jordan Halterman | 980a8c1 | 2017-09-22 18:01:19 -0700 | [diff] [blame] | 35 | * @param partitionId partition identifier |
Jonathan Hart | 054da97 | 2015-02-18 17:30:28 -0800 | [diff] [blame] | 36 | * @param term term number |
| 37 | * @param members partition members |
| 38 | * @param leader leader name |
| 39 | */ |
Jordan Halterman | 980a8c1 | 2017-09-22 18:01:19 -0700 | [diff] [blame] | 40 | public PartitionInfo(PartitionId partitionId, long term, List<String> members, String leader) { |
| 41 | this.partitionId = partitionId; |
Jonathan Hart | 054da97 | 2015-02-18 17:30:28 -0800 | [diff] [blame] | 42 | this.term = term; |
| 43 | this.members = ImmutableList.copyOf(members); |
| 44 | this.leader = leader; |
| 45 | } |
| 46 | |
| 47 | /** |
Jordan Halterman | 980a8c1 | 2017-09-22 18:01:19 -0700 | [diff] [blame] | 48 | * Returns the partition ID. |
Jonathan Hart | 054da97 | 2015-02-18 17:30:28 -0800 | [diff] [blame] | 49 | * |
Jordan Halterman | 980a8c1 | 2017-09-22 18:01:19 -0700 | [diff] [blame] | 50 | * @return partition ID |
Jonathan Hart | 054da97 | 2015-02-18 17:30:28 -0800 | [diff] [blame] | 51 | */ |
Jordan Halterman | 980a8c1 | 2017-09-22 18:01:19 -0700 | [diff] [blame] | 52 | public PartitionId id() { |
| 53 | return partitionId; |
Jonathan Hart | 054da97 | 2015-02-18 17:30:28 -0800 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Returns the term number. |
| 58 | * |
| 59 | * @return term number |
| 60 | */ |
| 61 | public long term() { |
| 62 | return term; |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Returns the list of partition members. |
| 67 | * |
| 68 | * @return partition members |
| 69 | */ |
| 70 | public List<String> members() { |
| 71 | return members; |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Returns the partition leader. |
| 76 | * |
| 77 | * @return partition leader |
| 78 | */ |
| 79 | public String leader() { |
| 80 | return leader; |
| 81 | } |
| 82 | } |