Search in sources :

Example 1 with NetworkMapPage

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;
}
Also used : NetworkMapPage(org.netxms.client.maps.NetworkMapPage)

Example 2 with NetworkMapPage

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();
}
Also used : NetworkMapPage(org.netxms.client.maps.NetworkMapPage) NetworkMapElement(org.netxms.client.maps.elements.NetworkMapElement) NetworkMapLink(org.netxms.client.maps.NetworkMapLink)

Example 3 with NetworkMapPage

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;
}
Also used : NetworkMapPage(org.netxms.client.maps.NetworkMapPage) AbstractObject(org.netxms.client.objects.AbstractObject) NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject) NetworkMapLink(org.netxms.client.maps.NetworkMapLink)

Example 4 with NetworkMapPage

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;
}
Also used : NetworkMapPage(org.netxms.client.maps.NetworkMapPage) NXCPMessage(org.netxms.base.NXCPMessage) NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject) ConnectionPoint(org.netxms.client.topology.ConnectionPoint) AccessPoint(org.netxms.client.objects.AccessPoint) NetworkMapLink(org.netxms.client.maps.NetworkMapLink)

Example 5 with NetworkMapPage

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;
}
Also used : NetworkMapPage(org.netxms.client.maps.NetworkMapPage) NXCPMessage(org.netxms.base.NXCPMessage) NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject) ConnectionPoint(org.netxms.client.topology.ConnectionPoint) AccessPoint(org.netxms.client.objects.AccessPoint) NetworkMapLink(org.netxms.client.maps.NetworkMapLink)

Aggregations

NetworkMapPage (org.netxms.client.maps.NetworkMapPage)11 NetworkMapObject (org.netxms.client.maps.elements.NetworkMapObject)8 NetworkMapLink (org.netxms.client.maps.NetworkMapLink)6 AbstractObject (org.netxms.client.objects.AbstractObject)3 NXCPMessage (org.netxms.base.NXCPMessage)2 NetworkMapElement (org.netxms.client.maps.elements.NetworkMapElement)2 AccessPoint (org.netxms.client.objects.AccessPoint)2 ConnectionPoint (org.netxms.client.topology.ConnectionPoint)2 AbstractNode (org.netxms.client.objects.AbstractNode)1 Cluster (org.netxms.client.objects.Cluster)1 VPNConnector (org.netxms.client.objects.VPNConnector)1 HopInfo (org.netxms.client.topology.HopInfo)1 NetworkPath (org.netxms.client.topology.NetworkPath)1