2 * Copyright (c) 2015 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.rpc;
10 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
11 import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
12 import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitializationPhaseHandler;
13 import org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext;
14 import org.opendaylight.openflowplugin.api.openflow.rpc.RpcManager;
15 import org.opendaylight.openflowplugin.impl.util.MdSalRegistratorUtils;
17 public class RpcManagerImpl implements RpcManager {
19 private final RpcProviderRegistry rpcProviderRegistry;
20 private DeviceInitializationPhaseHandler deviceInitPhaseHandler;
21 private final Long maxRequestsQuota;
23 public RpcManagerImpl(final RpcProviderRegistry rpcProviderRegistry,
24 final Long quotaValue) {
25 this.rpcProviderRegistry = rpcProviderRegistry;
26 maxRequestsQuota = quotaValue;
30 public void setDeviceInitializationPhaseHandler(final DeviceInitializationPhaseHandler handler) {
31 deviceInitPhaseHandler = handler;
35 public void onDeviceContextLevelUp(final DeviceContext deviceContext) {
36 final RpcContext rpcContext = new RpcContextImpl(deviceContext.getMessageSpy(), rpcProviderRegistry, deviceContext.getDeviceState().getNodeInstanceIdentifier(), maxRequestsQuota.intValue());
37 deviceContext.setDeviceDisconnectedHandler(rpcContext);
38 MdSalRegistratorUtils.registerServices(rpcContext, deviceContext);
39 // finish device initialization cycle back to DeviceManager
40 deviceInitPhaseHandler.onDeviceContextLevelUp(deviceContext);