2 * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.openflowplugin.impl.mastership;
10 import javax.annotation.Nonnull;
11 import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
12 import org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeRegistration;
13 import org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeService;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
17 public class MastershipServiceDelegate implements MastershipChangeService, MastershipChangeRegistration {
19 private static final Logger LOG = LoggerFactory.getLogger(MastershipServiceDelegate.class);
21 private final MastershipChangeService service;
22 private final AutoCloseable unregisterService;
24 MastershipServiceDelegate(final MastershipChangeService service,
25 final AutoCloseable unregisterService) {
26 LOG.debug("Mastership change service registered: {}", service);
27 this.service = service;
28 this.unregisterService = unregisterService;
32 public void close() throws Exception {
33 LOG.debug("Mastership change service un-registered: {}", service);
34 this.unregisterService.close();
39 public void onBecomeOwner(@Nonnull final DeviceInfo deviceInfo) {
40 this.service.onBecomeOwner(deviceInfo);
44 public void onLoseOwnership(@Nonnull final DeviceInfo deviceInfo) {
45 this.service.onLoseOwnership(deviceInfo);
49 public String toString() {
50 return service.toString();