blob: c3c3835db34440566f58347c973a4fa316b95b4a [file] [log] [blame]
Jonathan Hart054da972015-02-18 17:30:28 -08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Jonathan Hart054da972015-02-18 17:30:28 -08003 *
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
Jonathan Hart054da972015-02-18 17:30:28 -080018import java.util.List;
19
Jordan Halterman980a8c12017-09-22 18:01:19 -070020import com.google.common.collect.ImmutableList;
21import org.onosproject.cluster.PartitionId;
22
Jonathan Hart054da972015-02-18 17:30:28 -080023/**
24 * Contains information about a database partition.
25 */
26public class PartitionInfo {
Jordan Halterman980a8c12017-09-22 18:01:19 -070027 private final PartitionId partitionId;
Jonathan Hart054da972015-02-18 17:30:28 -080028 private final long term;
29 private final List<String> members;
30 private final String leader;
31
32 /**
33 * Class constructor.
34 *
Jordan Halterman980a8c12017-09-22 18:01:19 -070035 * @param partitionId partition identifier
Jonathan Hart054da972015-02-18 17:30:28 -080036 * @param term term number
37 * @param members partition members
38 * @param leader leader name
39 */
Jordan Halterman980a8c12017-09-22 18:01:19 -070040 public PartitionInfo(PartitionId partitionId, long term, List<String> members, String leader) {
41 this.partitionId = partitionId;
Jonathan Hart054da972015-02-18 17:30:28 -080042 this.term = term;
43 this.members = ImmutableList.copyOf(members);
44 this.leader = leader;
45 }
46
47 /**
Jordan Halterman980a8c12017-09-22 18:01:19 -070048 * Returns the partition ID.
Jonathan Hart054da972015-02-18 17:30:28 -080049 *
Jordan Halterman980a8c12017-09-22 18:01:19 -070050 * @return partition ID
Jonathan Hart054da972015-02-18 17:30:28 -080051 */
Jordan Halterman980a8c12017-09-22 18:01:19 -070052 public PartitionId id() {
53 return partitionId;
Jonathan Hart054da972015-02-18 17:30:28 -080054 }
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}