blob: 7370dc7e06e4fb14743a302622331caf57b5b4dd [file] [log] [blame]
Yi Tseng3e7f1452017-10-20 10:31:53 -07001/*
2 * Copyright 2017-present Open Networking Foundation
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
17package org.onosproject.p4runtime.ctl;
18
19import org.onosproject.net.MastershipRole;
20import org.onosproject.p4runtime.api.P4RuntimeEventSubject;
21import p4.P4RuntimeOuterClass.Uint128;
22
23/**
24 * Default implementation of arbitration in P4Runtime.
25 */
26public class DefaultArbitration implements P4RuntimeEventSubject {
27 private MastershipRole role;
28 private Uint128 electionId;
29
30 /**
31 * Creates arbitration with given role and election id.
32 *
33 * @param role the role
34 * @param electionId the election id
35 */
36 public DefaultArbitration(MastershipRole role, Uint128 electionId) {
37 this.role = role;
38 this.electionId = electionId;
39 }
40
41 /**
42 * Gets the role of this arbitration.
43 *
44 * @return the role
45 */
46 public MastershipRole role() {
47 return role;
48 }
49
50 /**
51 * Gets election id of this arbitration.
52 *
53 * @return the election id
54 */
55 public Uint128 electionId() {
56 return electionId;
57 }
58}