protected void addLink(LinkGraphic lg) { LinkDescriptor comp = (LinkDescriptor) lg.getONLComponent(); ExpCoordinator.print( new String( "LinkTool::addLink " + comp.getPoint1().getLabel() + " to " + comp.getPoint2().getLabel())); lg.getONLComponent().setLabel(new String("explink" + count)); expCoordinator.getCurrentExp().addLink(comp); ++count; }
protected boolean addLink( LinkGraphic lg, ONLComponent end_comp) // returns true if successfully added { if (lg == null) return false; LinkDescriptor comp = (LinkDescriptor) lg.getONLComponent(); ONLComponent start_comp = comp.getPoint1(); // fail link if end_comp is not a component, it's a loop, the end_comp is unlinkable or is // already linked if (end_comp == null || end_comp == start_comp || !end_comp.isLinkable() || end_comp.isLinked()) { if (end_comp == null) ExpCoordinator.print( new String("LinkTool.addLink " + comp.toString() + " fail end is null"), TEST_ADD); else { if (end_comp == start_comp) ExpCoordinator.print( new String( "LinkTool.addLink " + comp.toString() + " fail end(" + end_comp.getLabel() + ") is same as start"), TEST_ADD); if (!end_comp.isLinkable() || end_comp.isLinked()) ExpCoordinator.print( new String( "LinkTool.addLink " + comp.toString() + " fail diend(" + end_comp.getLabel() + ") unlinkable isLinkable:" + end_comp.isLinkable() + " isLinked:" + end_comp.isLinked()), TEST_ADD); } return false; } else { // 10G change for gige to gige connections remove GigE to GigE restriction // if (((start_comp instanceof GigEDescriptor.Port) || (start_comp instanceof GigEDescriptor)) // && // ((end_comp instanceof GigEDescriptor.Port) || (end_comp instanceof GigEDescriptor))) // return false; // 10G change return false if interface types not equal & not a GigE-GigE link if (!start_comp.getInterfaceType().equals(end_comp.getInterfaceType()) && !(((start_comp instanceof GigEDescriptor.Port) || (start_comp instanceof GigEDescriptor)) && ((end_comp instanceof GigEDescriptor.Port) || (end_comp instanceof GigEDescriptor)))) { ExpCoordinator.print( new String( "LinkTool.addLink " + comp.toString() + " fail diff interface start:" + start_comp.getLabel() + "(" + start_comp.getInterfaceType() + ") end:" + end_comp.getLabel() + "(" + end_comp.getInterfaceType() + ")"), TEST_ADD); return false; } // SUBNET:add call SubnetManager addLink here try { if (ExpCoordinator.isOldSubnet()) { // check for cycles if (expCoordinator.getTopology().isCycle(start_comp, end_comp)) return false; OldSubnetManager.addLink( (ONLComponent.PortBase) start_comp, (ONLComponent.PortBase) end_comp); } else SubnetManager.addLink( (ONLComponent.PortBase) start_comp, (ONLComponent.PortBase) end_comp); } catch (SubnetManager.SubnetException e) { ExpCoordinator.print( new String( "LinkTool.addLink failed (" + start_comp.getLabel() + ", " + end_comp.getLabel() + ") -- " + e.getMessage())); return false; } } comp.setPoint2(end_comp); addLink(lg); return true; }