use of org.netxms.client.topology.NetworkPath in project netxms by netxms.
the class NXCSession method getNetworkPath.
/**
* Get IPv4 network path between two nodes. Server will return path based
* on cached routing table information. Network path object may be incomplete
* if server does not have enough information to build full path. In this case,
* no exception thrown, and completness of path can be checked by calling
* NetworkPath.isComplete().
*
* @param node1 source node
* @param node2 destination node
* @return network path object
* @throws IOException if socket or file I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
*/
public NetworkPath getNetworkPath(long node1, long node2) throws IOException, NXCException {
final NXCPMessage msg = newMessage(NXCPCodes.CMD_GET_NETWORK_PATH);
msg.setFieldInt32(NXCPCodes.VID_SOURCE_OBJECT_ID, (int) node1);
msg.setFieldInt32(NXCPCodes.VID_DESTINATION_OBJECT_ID, (int) node2);
sendMessage(msg);
final NXCPMessage response = waitForRCC(msg.getMessageId());
return new NetworkPath(response);
}
use of org.netxms.client.topology.NetworkPath in project netxms by netxms.
the class IPRouteMap method getRoute.
/**
* Get route between objects and build map page
*
* @throws Exception
*/
private void getRoute(Display display) throws Exception {
final NetworkPath path = session.getNetworkPath(rootObject.getObjectId(), targetObject.getObjectId());
// $NON-NLS-1$ //$NON-NLS-2$
final NetworkMapPage page = new NetworkMapPage(ID + "@" + rootObject.getObjectName() + "@" + targetObject.getObjectName());
long prevElementId = 0;
HopInfo prevHop = null;
for (final HopInfo h : path.getPath()) {
final long elementId = page.createElementId();
page.addElement(new NetworkMapObject(elementId, h.getNodeId()));
if (prevElementId != 0) {
NetworkMapLink link = new NetworkMapLink(prevHop.isVpn() ? NetworkMapLink.VPN : NetworkMapLink.NORMAL, prevElementId, elementId);
if (!prevHop.getName().isEmpty())
link.setName(prevHop.getName());
page.addLink(link);
}
prevElementId = elementId;
prevHop = h;
}
replaceMapPage(page, display);
}
Aggregations