blob: 80e3e9875bbae6349782c1ec32a1213bf4bb7c25 [file] [log] [blame]
Carmelo Casconee5b28722018-06-22 17:28:28 +02001/*
Carmelo Cascone4c289b72019-01-22 15:30:45 -08002 * Copyright 2019-present Open Networking Foundation
Carmelo Casconee5b28722018-06-22 17:28:28 +02003 *
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
Carmelo Cascone4c289b72019-01-22 15:30:45 -080017package org.onosproject.p4runtime.ctl.controller;
Carmelo Casconee5b28722018-06-22 17:28:28 +020018
19import org.onosproject.net.DeviceId;
20import org.onosproject.p4runtime.api.P4RuntimeEventSubject;
21
22/**
23 * Default implementation of arbitration in P4Runtime.
24 */
Carmelo Cascone4c289b72019-01-22 15:30:45 -080025public final class ArbitrationUpdateEvent implements P4RuntimeEventSubject {
Carmelo Casconee5b28722018-06-22 17:28:28 +020026
27 private DeviceId deviceId;
28 private boolean isMaster;
29
30 /**
31 * Creates arbitration with given role and master flag.
32 *
33 * @param deviceId the device
34 * @param isMaster true if arbitration response signals master status
35 */
Carmelo Cascone4c289b72019-01-22 15:30:45 -080036 public ArbitrationUpdateEvent(DeviceId deviceId, boolean isMaster) {
Carmelo Casconee5b28722018-06-22 17:28:28 +020037 this.deviceId = deviceId;
38 this.isMaster = isMaster;
39 }
40
41 /**
42 * Returns true if arbitration response signals master status, false
43 * otherwise.
44 *
45 * @return boolean flag
46 */
47 boolean isMaster() {
48 return isMaster;
49 }
50
51 @Override
52 public DeviceId deviceId() {
53 return deviceId;
54 }
55}