2 * Copyright (c) 2016 Cisco Systems, Inc. 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.lifecycle;
10 import com.google.common.util.concurrent.ListenableFuture;
11 import java.util.concurrent.ExecutionException;
12 import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
13 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
14 import org.opendaylight.openflowplugin.api.openflow.lifecycle.LifecycleService;
15 import org.opendaylight.openflowplugin.api.openflow.role.RoleContext;
16 import org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext;
17 import org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
21 class LifecycleServiceImpl implements LifecycleService {
23 private static final Logger LOG = LoggerFactory.getLogger(LifecycleServiceImpl.class);
25 private final DeviceContext deviceContext;
26 private final RpcContext rpcContext;
27 private final RoleContext roleContext;
28 private final StatisticsContext statContext;
30 public LifecycleServiceImpl(
31 final DeviceContext deviceContext,
32 final RpcContext rpcContext,
33 final RoleContext roleContext,
34 final StatisticsContext statContext) {
35 this.deviceContext = deviceContext;
36 this.rpcContext = rpcContext;
37 this.roleContext = roleContext;
38 this.statContext = statContext;
42 public void instantiateServiceInstance() {
43 LOG.info("Starting device context cluster services for node {}", this.deviceContext.getServiceIdentifier());
45 this.deviceContext.startupClusterServices();
46 } catch (ExecutionException | InterruptedException e) {
47 LOG.warn("Cluster service {} was unable to start.", this.getIdentifier());
49 LOG.info("Starting statistics context cluster services for node {}", this.deviceContext.getServiceIdentifier());
53 public ListenableFuture<Void> closeServiceInstance() {
54 return deviceContext.stopClusterServices();
58 public ServiceGroupIdentifier getIdentifier() {
59 return deviceContext.getServiceIdentifier();