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