use of org.netxms.client.maps.NetworkMapPage in project netxms by netxms.
the class NetworkMap method createMapPage.
/**
* Create map page from map object's data
*
* @return new map page
*/
public NetworkMapPage createMapPage() {
NetworkMapPage page = new NetworkMapPage(getObjectName());
page.addAllElements(elements);
page.addAllLinks(links);
return page;
}
use of org.netxms.client.maps.NetworkMapPage in project netxms by netxms.
the class TopologyTest method testLinkLayerTopology.
public void testLinkLayerTopology() throws Exception {
final NXCSession session = connect();
NetworkMapPage page = session.queryLayer2Topology(TestConstants.NODE_ID);
for (NetworkMapElement e : page.getElements()) System.out.println(e.toString());
for (NetworkMapLink l : page.getLinks()) System.out.println(l.toString());
session.disconnect();
}
use of org.netxms.client.maps.NetworkMapPage in project netxms by netxms.
the class ClusterTab method buildClusterMap.
/**
* Build hierarchical cluster representation
*
* @return
*/
private NetworkMapPage buildClusterMap() {
NetworkMapPage page = new NetworkMapPage(pluginId + id);
long id = 1;
page.addElement(new NetworkMapObject(id++, cluster.getObjectId()));
for (AbstractObject o : cluster.getAllChilds(AbstractObject.OBJECT_NODE)) {
page.addElement(new NetworkMapObject(id, o.getObjectId()));
page.addLink(new NetworkMapLink(0, 1, id));
addOwnedResources(page, id, o.getObjectId(), cluster.getResources());
id++;
}
return page;
}
use of org.netxms.client.maps.NetworkMapPage in project netxms by netxms.
the class NXCSession method queryInternalConnectionTopology.
/**
* Query internal connection topology for node
*
* @param nodeId The node ID
* @throws IOException if socket I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
* @return The NetworkMapPage
*/
public NetworkMapPage queryInternalConnectionTopology(final long nodeId) throws IOException, NXCException {
NXCPMessage msg = newMessage(NXCPCodes.CMD_QUERY_INTERNAL_TOPOLOGY);
msg.setFieldInt32(NXCPCodes.VID_OBJECT_ID, (int) nodeId);
sendMessage(msg);
final NXCPMessage response = waitForRCC(msg.getMessageId());
int count = response.getFieldAsInt32(NXCPCodes.VID_NUM_OBJECTS);
long[] idList = response.getFieldAsUInt32Array(NXCPCodes.VID_OBJECT_LIST);
if (idList.length != count)
throw new NXCException(RCC.INTERNAL_ERROR);
NetworkMapPage page = new NetworkMapPage(msg.getMessageId() + ".InternalConnectionTopology");
for (int i = 0; i < count; i++) {
page.addElement(new NetworkMapObject(page.createElementId(), idList[i]));
}
count = response.getFieldAsInt32(NXCPCodes.VID_NUM_LINKS);
long varId = NXCPCodes.VID_OBJECT_LINKS_BASE;
for (int i = 0; i < count; i++, varId += 3) {
NetworkMapObject obj1 = page.findObjectElement(response.getFieldAsInt64(varId++));
NetworkMapObject obj2 = page.findObjectElement(response.getFieldAsInt64(varId++));
int type = response.getFieldAsInt32(varId++);
String port1 = response.getFieldAsString(varId++);
String port2 = response.getFieldAsString(varId++);
String name = response.getFieldAsString(varId++);
int flags = response.getFieldAsInt32(varId++);
if ((obj1 != null) && (obj2 != null)) {
page.addLink(new NetworkMapLink(name, type, obj1.getId(), obj2.getId(), port1, port2, flags));
}
}
return page;
}
use of org.netxms.client.maps.NetworkMapPage in project netxms by netxms.
the class NXCSession method queryLayer2Topology.
/**
* Query layer 2 topology for node
*
* @param nodeId The node ID
* @throws IOException if socket I/O error occurs
* @throws NXCException if NetXMS server returns an error or operation was timed out
* @return The NetworkMapPage
*/
public NetworkMapPage queryLayer2Topology(final long nodeId) throws IOException, NXCException {
NXCPMessage msg = newMessage(NXCPCodes.CMD_QUERY_L2_TOPOLOGY);
msg.setFieldInt32(NXCPCodes.VID_OBJECT_ID, (int) nodeId);
sendMessage(msg);
final NXCPMessage response = waitForRCC(msg.getMessageId());
int count = response.getFieldAsInt32(NXCPCodes.VID_NUM_OBJECTS);
long[] idList = response.getFieldAsUInt32Array(NXCPCodes.VID_OBJECT_LIST);
if (idList.length != count)
throw new NXCException(RCC.INTERNAL_ERROR);
NetworkMapPage page = new NetworkMapPage(msg.getMessageId() + ".L2Topology");
for (int i = 0; i < count; i++) {
page.addElement(new NetworkMapObject(page.createElementId(), idList[i]));
}
count = response.getFieldAsInt32(NXCPCodes.VID_NUM_LINKS);
long varId = NXCPCodes.VID_OBJECT_LINKS_BASE;
for (int i = 0; i < count; i++, varId += 3) {
NetworkMapObject obj1 = page.findObjectElement(response.getFieldAsInt64(varId++));
NetworkMapObject obj2 = page.findObjectElement(response.getFieldAsInt64(varId++));
int type = response.getFieldAsInt32(varId++);
String port1 = response.getFieldAsString(varId++);
String port2 = response.getFieldAsString(varId++);
String name = response.getFieldAsString(varId++);
int flags = response.getFieldAsInt32(varId++);
if ((obj1 != null) && (obj2 != null)) {
page.addLink(new NetworkMapLink(name, type, obj1.getId(), obj2.getId(), port1, port2, flags));
}
}
return page;
}
Aggregations