import com.google.common.util.concurrent.Futures;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.genius.mdsalutil.NwConstants;
+import org.opendaylight.netvirt.elan.internal.ElanServiceProvider;
import org.opendaylight.netvirt.elan.utils.ElanConstants;
import org.opendaylight.netvirt.elan.utils.ElanUtils;
//import org.opendaylight.genius.ericsson.mdsalutil.statistics.StatValue;
import java.util.concurrent.Future;
public class ElanStatisticsImpl implements ElanStatisticsService {
- private DataBroker dataBroker;
- private IInterfaceManager interfaceManager;
- private IMdsalApiManager mdsalMgr;
+ private ElanServiceProvider elanServiceProvider;
private static final Logger logger = LoggerFactory.getLogger(ElanStatisticsImpl.class);
+ private static volatile ElanStatisticsImpl elanStatisticsImpl;
- public ElanStatisticsImpl(DataBroker dataBroker, IInterfaceManager interfaceManager,
- IMdsalApiManager mdsalMgr) {
- this.interfaceManager = interfaceManager;
- this.dataBroker = dataBroker;
- this.mdsalMgr = mdsalMgr;
+
+ private ElanStatisticsImpl(ElanServiceProvider elanServiceProvider) {
+ super();
+ this.elanServiceProvider = elanServiceProvider;
+
+
+ }
+
+ public static ElanStatisticsImpl getElanStatisticsService(ElanServiceProvider elanServiceProvider) {
+ if (elanStatisticsImpl == null)
+ synchronized (ElanStatisticsImpl.class) {
+ if (elanStatisticsImpl == null) {
+ elanStatisticsImpl = new ElanStatisticsImpl(elanServiceProvider);
+ }
+ }
+ return elanStatisticsImpl;
}
@Override
public Future<RpcResult<GetElanInterfaceStatisticsOutput>> getElanInterfaceStatistics(
- GetElanInterfaceStatisticsInput input) {
+ GetElanInterfaceStatisticsInput input) {
String interfaceName = input.getInterfaceName();
logger.debug("getElanInterfaceStatistics is called for elan interface {}", interfaceName);
RpcResultBuilder<GetElanInterfaceStatisticsOutput> rpcResultBuilder = null;
String elanInstanceName = elanInterface.getElanInstanceName();
ElanInstance elanInfo = ElanUtils.getElanInstanceByName(elanInstanceName);
long elanTag = elanInfo.getElanTag();
- InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(interfaceName);
+ InterfaceInfo interfaceInfo = elanServiceProvider.getInterfaceManager().getInterfaceInfo(interfaceName);
ServicesInfo serviceInfo = ElanUtils.getServiceInfo(elanInstanceName, elanTag, interfaceName);
//FIXME [ELANBE] Get this API Later
short tableId = 0;
logger.debug("interface {} is down and returning with no statistics", interfaceName);
rpcResultBuilder = RpcResultBuilder.success();
return Futures.immediateFuture(rpcResultBuilder.withResult(new GetElanInterfaceStatisticsOutputBuilder().setStatResult(new StatResultBuilder()
- .setStatResultCode(ResultCode.NotFound).setByteRxCount(0L).setByteTxCount(0L).setPacketRxCount(0L)
- .setPacketTxCount(0L).build()).build()).build());
+ .setStatResultCode(ResultCode.NotFound).setByteRxCount(0L).setByteTxCount(0L).setPacketRxCount(0L)
+ .setPacketTxCount(0L).build()).build()).build());
}
rpcResultBuilder = RpcResultBuilder.success();
return Futures.immediateFuture(rpcResultBuilder.withResult(queryforElanInterfaceStatistics(tableId, elanInstanceName, interfaceInfo)).build());
BigInteger dpId = interfaceInfo.getDpId();
List<MatchInfo> matches = null;
String interfaceName = interfaceInfo.getInterfaceName();
- if (tableId == IfmConstants.VLAN_INTERFACE_INGRESS_TABLE) {
+ if (tableId == NwConstants.VLAN_INTERFACE_INGRESS_TABLE) {
VlanInterfaceInfo vlanInterfaceInfo = (VlanInterfaceInfo)interfaceInfo;
matches = InterfaceServiceUtil.getMatchInfoForVlanLPort(dpId, interfaceInfo.getPortNo(),
- InterfaceServiceUtil.getVlanId(interfaceName, dataBroker), vlanInterfaceInfo.isVlanTransparent());
+ InterfaceServiceUtil.getVlanId(interfaceName, elanServiceProvider.getBroker()), vlanInterfaceInfo.isVlanTransparent());
} else {
- matches = InterfaceServiceUtil.getLPortDispatcherMatches(ElanConstants.ELAN_SERVICE_INDEX, interfaceInfo.getInterfaceTag());
+ matches = InterfaceServiceUtil.getLPortDispatcherMatches(NwConstants.ELAN_SERVICE_INDEX, interfaceInfo.getInterfaceTag());
}
long groupId = interfaceInfo.getGroupId();
Set<Object> statRequestKeys = InterfaceServiceUtil.getStatRequestKeys(dpId, tableId, matches, String.format("%s.%s", elanInstanceName, interfaceName), groupId);
- // StatisticsInfo statsInfo = new StatisticsInfo(statRequestKeys);
-// org.opendaylight.genius.ericsson.mdsalutil.statistics.StatResult statResult = mdsalMgr.queryForStatistics(interfaceName, statsInfo);
+ // StatisticsInfo statsInfo = new StatisticsInfo(statRequestKeys);
+// org.opendaylight.vpnservice.ericsson.mdsalutil.statistics.StatResult statResult = mdsalMgr.queryForStatistics(interfaceName, statsInfo);
// ResultCode resultCode = ResultCode.Success;
// if (!statResult.isComplete()) {
// resultCode = ResultCode.Incomplete;
}
private Future<RpcResult<GetElanInterfaceStatisticsOutput>> getFutureWithAppErrorMessage(
- RpcResultBuilder<GetElanInterfaceStatisticsOutput> rpcResultBuilder, String message) {
+ RpcResultBuilder<GetElanInterfaceStatisticsOutput> rpcResultBuilder, String message) {
rpcResultBuilder.withError(ErrorType.APPLICATION, message);
return Futures.immediateFuture(rpcResultBuilder.build());
}