Software Defined Networking
1829836 Members
1998 Online
109993 Solutions
New Discussion

Re: HP VAN SDN Controller v2.4.5 - Can't use internal services

 
PaMartins
Occasional Contributor

HP VAN SDN Controller v2.4.5 - Can't use internal services

Hello,

 

 

I'm developing an aplication on Java as well for the HP VAN SDN Controller v2.4.5 and I'm interested in using it's internal services as you did. (NodeService, TopologyService, and so on). But I haven't been able to do that, the program runs normally until it reaches an instruction like Set<Node> nodes = nodeService.getNodes(IpAddress.ip(ipAddress)); and it stops running.

 

I don't know what's missing so I can use such services. I'm going to leave a sample of code that I'm working on so you can see where it stops:

 

public class trffcmngrManager implements trffcmngrService {

//@SuppressWarnings("unused")
@Reference(policy = ReferencePolicy.DYNAMIC, cardinality = ReferenceCardinality.MANDATORY_UNARY)

private volatile ControllerService controllerService; // This Service works perfectly 
private volatile TopologyService topoService; //This is the Service that I want to use and I can't

 

private static final Logger LOG = LoggerFactory.getLogger( trffcmngrService.class );

private SwitchListener switchListener;
private PacketListener packetListener; // This is the class where I want to use Topology Service

@Activate
protected void activate()
{
LOG.info( "MySdnLab: Activated" );
LOG.info( "MySdnLab: I'm Alive!!!!!" );
switchListener = new SwitchListener();
switchListener.init(controllerService);
switchListener.startup();

packetListener = new PacketListener();
packetListener.init(controllerService, topoService);
packetListener.startup();
}

 

@Deactivate
protected void deactivate()
{
LOG.info( "MySdnLab: Deactivated" );
LOG.info( "MySdnLab: Ok.. I'm dead" );
switchListener.shutdown();
packetListener.shutdown();
}

}

 

///-------------------------------//-------------------------------------------------//

 

 

public class IpPacketHandler {

 

ControllerService mControllerService;
TopologyService mTopoService;

private static final Logger LOG = LoggerFactory.getLogger(IpPacketHandler.class);
private static final ProtocolVersion PV = ProtocolVersion.V_1_3;

public IpPacketHandler(ControllerService controllerservice, TopologyService topoService) {
mControllerService = controllerservice;
mTopoService = topoService;
}

 

/*

*There is some code here that will call the next function

*/

 

private DataPathId FindDestination (MessageContext messageContext, MacAddress destAdd){
LOG.info("MySdnLab: IpPacketHandler: FindDestination Activated");
Topology topology = mTopoService.getTopology(); //This is where the program stops
LOG.info("MySdnLab: IpPacketHandler: topogia {}", topology.toString());
return null;

}

}

 

I really appreciate your help in advance.

PM 

1 REPLY 1
PaMartins
Occasional Contributor

Re: HP VAN SDN Controller v2.4.5 - Can't use internal services

Hello, 

 

So it seems I just found the problem, when we request a service to the controller it has to have a reference like this one: @Reference(policy = ReferencePolicy.DYNAMIC, cardinality = ReferenceCardinality.MANDATORY_UNARY)

 

So what I did was justo copy this intruction to all other Services and they are working perfectly:

 

//@SuppressWarnings("unused")
@Reference(policy = ReferencePolicy.DYNAMIC, cardinality = ReferenceCardinality.MANDATORY_UNARY)
private volatile ControllerService controllerService;
@Reference(policy = ReferencePolicy.DYNAMIC, cardinality = ReferenceCardinality.MANDATORY_UNARY)
private volatile TopologyService topoService;
@Reference(policy = ReferencePolicy.DYNAMIC, cardinality = ReferenceCardinality.MANDATORY_UNARY)
private volatile NodeService nodeService;

 

So I guess it's problem soved then ;)

 

I just want to ask another question, what is exacly that reference? How does it work?

Thank you!

 

Cheers

PM