/** * Retrieve instance of a class via OSGI registry, if there * are many only the first is returned. * * @param clazz The target class * @param containerName The container name * @param bundle The caller */ public static Object getInstance(Class<?> clazz, String containerName, Object bundle) { // Back-end convention: Container id in lower case. Let's enforce it here return getInstance(clazz, containerName.toLowerCase(), bundle, null); }
public static String getNodeDesc(Node node, String containerName, Object bundle) { ISwitchManager switchManager = (ISwitchManager) ServiceHelper .getInstance(ISwitchManager.class, containerName, bundle); if (switchManager == null) { return null; } return getNodeDesc(node, switchManager); }
public static String getPortName(NodeConnector nodeConnector, String container, Object bundle) { ISwitchManager switchManager = (ISwitchManager) ServiceHelper .getInstance(ISwitchManager.class, container, bundle); return getPortName(nodeConnector, switchManager); }
public static String getNodeDesc(Node node, String containerName, Object bundle) { ISwitchManager switchManager = (ISwitchManager) ServiceHelper .getInstance(ISwitchManager.class, containerName, bundle); if (switchManager == null) { return null; } return getNodeDesc(node, switchManager); }
public static String getPortName(NodeConnector nodeConnector, String container, Object bundle) { ISwitchManager switchManager = (ISwitchManager) ServiceHelper .getInstance(ISwitchManager.class, container, bundle); return getPortName(nodeConnector, switchManager); }
public static String getNodeDesc(Node node, Object bundle) { ISwitchManager switchManager = (ISwitchManager) ServiceHelper .getInstance(ISwitchManager.class, GlobalConstants.DEFAULT.toString(), bundle); if (switchManager == null) { return null; } return getNodeDesc(node, switchManager); }
public static String getNodeDesc(Node node, Object bundle) { ISwitchManager switchManager = (ISwitchManager) ServiceHelper .getInstance(ISwitchManager.class, GlobalConstants.DEFAULT.toString(), bundle); if (switchManager == null) { return null; } return getNodeDesc(node, switchManager); }
private ISwitchManager getISwitchManagerService(String containerName) { ISwitchManager switchManager = (ISwitchManager) ServiceHelper.getInstance(ISwitchManager.class, containerName, this); if (switchManager == null) { throw new ServiceUnavailableException("Switch Manager " + RestMessages.SERVICEUNAVAILABLE.toString()); } return switchManager; }
/** * Return the VTN manager service associated with the default container. * * @return The VTN manager service associated with the default * container. * @throws ServiceUnavailableException * Unable to get VTN manager service. */ protected final IVTNManager getVTNManager() { String cname = GlobalConstants.DEFAULT.toString(); IVTNManager mgr = (IVTNManager)ServiceHelper. getInstance(IVTNManager.class, cname, this); if (mgr == null) { throw serviceUnavailable("VTN Manager"); } return mgr; }
/** * Return the VTN flow debugger service associated with the default * container. * * @return The VTN flow debugger service associated with the default * container. * @throws ServiceUnavailableException * Unable to get VTN manager service. */ protected final IVTNFlowDebugger getVTNFlowDebugger() { String cname = GlobalConstants.DEFAULT.toString(); IVTNFlowDebugger debugger = (IVTNFlowDebugger)ServiceHelper. getInstance(IVTNFlowDebugger.class, cname, this); if (debugger == null) { throw serviceUnavailable("VTN Flow Debugger"); } return debugger; }
private AffinityLink handleAffinityLinkAvailability(String containerName, String linkName) { IAffinityManager affinityManager = (IAffinityManager) ServiceHelper.getInstance(IAffinityManager.class, containerName, this); if (affinityManager == null) throw new ServiceUnavailableException("Affinity manager " + RestMessages.SERVICEUNAVAILABLE.toString()); AffinityLink al = affinityManager.getAffinityLink(linkName); if (al == null) throw new ResourceNotFoundException(linkName + " : AffinityLink does not exist"); return al; }
private List<StaticRoute> getStaticRoutesInternal(String containerName) { IForwardingStaticRouting staticRouting = (IForwardingStaticRouting) ServiceHelper .getInstance(IForwardingStaticRouting.class, containerName, this); if (staticRouting == null) { throw new ResourceNotFoundException(RestMessages.NOCONTAINER .toString()); } List<StaticRoute> routes = new ArrayList<StaticRoute>(); for (StaticRouteConfig conf : staticRouting.getStaticRouteConfigs() .values()) { StaticRoute route = new StaticRoute(conf.getName(), conf .getStaticRoute(), conf.getNextHop()); routes.add(route); } return routes; }
private IAnalyticsManager getAnalyticsService(String containerName) { IContainerManager containerManager = (IContainerManager) ServiceHelper.getGlobalInstance(IContainerManager.class, this); if (containerManager == null) throw new ServiceUnavailableException("Container " + RestMessages.SERVICEUNAVAILABLE.toString()); boolean found = false; List<String> containerNames = containerManager.getContainerNames(); for (String cName : containerNames) if (cName.trim().equalsIgnoreCase(containerName.trim())) found = true; if (found == false) throw new ResourceNotFoundException(containerName + " " + RestMessages.NOCONTAINER.toString()); IAnalyticsManager analyticsManager = (IAnalyticsManager) ServiceHelper.getInstance(IAnalyticsManager.class, containerName, this); if (analyticsManager == null) throw new ServiceUnavailableException("Analytics " + RestMessages.SERVICEUNAVAILABLE.toString()); return analyticsManager; }
@Descriptor("Displays all the installed flow entries in a given group") public void showInstalledGroupFlows(@Descriptor("Container in which to query FRM") String container, @Descriptor("Group name") String group, @Descriptor("True for verbose else false") Boolean verbose) { IForwardingRulesManager frm = (IForwardingRulesManager) ServiceHelper.getInstance( IForwardingRulesManager.class, container, this); if (frm == null) { System.out.println("Cannot find the FRM instance on container: " + container); return; } List<FlowEntry> groupFlows = frm.getInstalledFlowEntriesForGroup(group); System.out.println("Group " + group); for (FlowEntry flowEntry : groupFlows) { if (!verbose) { System.out.println(flowEntry.getNode() + " " + flowEntry.getFlowName()); } else { System.out.println(flowEntry.getNode() + " " + flowEntry.toString()); } } }
@Descriptor("Displays all the flow entries in a given group") public void showRequestedGroupFlows(@Descriptor("Container in which to query FRM") String container, @Descriptor("Group name") String group, @Descriptor("True for verbose else false") Boolean verbose) { IForwardingRulesManager frm = (IForwardingRulesManager) ServiceHelper.getInstance( IForwardingRulesManager.class, container, this); if (frm == null) { System.out.println("Cannot find the FRM instance on container: " + container); return; } List<FlowEntry> groupFlows = frm.getFlowEntriesForGroup(group); System.out.println("Group " + group); for (FlowEntry flowEntry : groupFlows) { if (!verbose) { System.out.println(flowEntry.getNode() + " " + flowEntry.getFlowName()); } else { System.out.println(flowEntry.getNode() + " " + flowEntry.toString()); } } }
private void handleNodeConnectorAvailability(String containerName, Node node, String nodeConnectorType, String nodeConnectorId) { NodeConnector nc = NodeConnector.fromStringNoNode(nodeConnectorType, nodeConnectorId, node); if (nc == null) { throw new ResourceNotFoundException(nc + " : " + RestMessages.NORESOURCE.toString()); } ISwitchManager sm = (ISwitchManager) ServiceHelper.getInstance(ISwitchManager.class, containerName, this); if (sm == null) { throw new ServiceUnavailableException("Switch Manager " + RestMessages.SERVICEUNAVAILABLE.toString()); } if (!sm.getNodeConnectors(node).contains(nc)) { throw new ResourceNotFoundException(nc.toString() + " : " + RestMessages.NORESOURCE.toString()); } }
private Node handleNodeAvailability(String containerName, String nodeType, String nodeId) { Node node = Node.fromString(nodeType, nodeId); if (node == null) { throw new ResourceNotFoundException(nodeId + " : " + RestMessages.NONODE.toString()); } ISwitchManager sm = (ISwitchManager) ServiceHelper.getInstance(ISwitchManager.class, containerName, this); if (sm == null) { throw new ServiceUnavailableException("Switch Manager " + RestMessages.SERVICEUNAVAILABLE.toString()); } if (!sm.getNodes().contains(node)) { throw new ResourceNotFoundException(node.toString() + " : " + RestMessages.NONODE.toString()); } return node; }
private Node handleNodeAvailability(String containerName, String nodeType, String nodeId) { Node node = Node.fromString(nodeType, nodeId); if (node == null) { throw new ResourceNotFoundException(nodeId + " : " + RestMessages.NONODE.toString()); } ISwitchManager sm = (ISwitchManager) ServiceHelper.getInstance(ISwitchManager.class, containerName, this); if (sm == null) { throw new ServiceUnavailableException("Switch Manager " + RestMessages.SERVICEUNAVAILABLE.toString()); } if (!sm.getNodes().contains(node)) { throw new ResourceNotFoundException(node.toString() + " : " + RestMessages.NONODE.toString()); } return node; }
private Node handleNodeAvailability(String containerName, String nodeType, String nodeId) { Node node = Node.fromString(nodeType, nodeId); if (node == null) { throw new ResourceNotFoundException(nodeId + " : " + RestMessages.NONODE.toString()); } ISwitchManager sm = (ISwitchManager) ServiceHelper.getInstance( ISwitchManager.class, containerName, this); if (sm == null) { throw new ServiceUnavailableException("Switch Manager " + RestMessages.SERVICEUNAVAILABLE.toString()); } if (!sm.getNodes().contains(node)) { throw new ResourceNotFoundException(node.toString() + " : " + RestMessages.NONODE.toString()); } return node; }
private EidToLocatorRecord lookupEID(String containerName, int mask, LispAddress EID) { ILispmappingNorthbound nbService = (ILispmappingNorthbound) ServiceHelper.getInstance(ILispmappingNorthbound.class, containerName, this); MapRequest mapRequest = new MapRequest(); EidRecord EIDRecord = new EidRecord((byte) mask, EID); mapRequest.addEidRecord(EIDRecord); mapRequest.setSourceEid(new LispIpv4Address("127.0.0.1")); org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.control.plane.rev150314.MapRequest mr = YangTransformerNB.transformMapRequest(mapRequest); MapReply mapReply; try { mapReply = nbService.getMappingService().handleMapRequest(mr); } catch (Exception e) { throw new InternalServerErrorException(RestMessages.INTERNALERROR.toString() + " : There was an error looking up the EID"); } if (mapReply == null) { throw new InternalServerErrorException(RestMessages.INTERNALERROR.toString() + " : There was an error looking up the EID"); } return mapReply.getEidToLocatorRecord().get(0); }