use of org.netxms.client.maps.elements.NetworkMapObject 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;
}
use of org.netxms.client.maps.elements.NetworkMapObject in project netxms by netxms.
the class IPNeighbors method buildMapPage.
/**
* Build map page
*/
protected void buildMapPage() {
// $NON-NLS-1$
mapPage = new NetworkMapPage(ID + "." + this.toString());
long rootElementId = mapPage.createElementId();
mapPage.addElement(new NetworkMapObject(rootElementId, rootObject.getObjectId()));
addSubnets(rootObject, rootElementId);
for (long objectId : rootObject.getChildIdList()) {
AbstractObject object = session.findObjectById(objectId);
if ((object != null) && (object instanceof VPNConnector)) {
AbstractObject peer = session.findObjectById(((VPNConnector) object).getPeerGatewayId());
if (peer != null) {
long elementId = mapPage.createElementId();
mapPage.addElement(new NetworkMapObject(elementId, peer.getObjectId()));
NetworkMapLink link = new NetworkMapLink(NetworkMapLink.VPN, rootElementId, elementId);
link.setName(object.getObjectName());
mapPage.addLink(link);
addSubnets(peer, elementId);
}
}
}
addDciToRequestList();
}
use of org.netxms.client.maps.elements.NetworkMapObject 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);
}
use of org.netxms.client.maps.elements.NetworkMapObject in project netxms by netxms.
the class ServiceDependency method buildMapPage.
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.networkmaps.views.NetworkMap#buildMapPage()
*/
@Override
protected void buildMapPage() {
mapPage = new NetworkMapPage(ID + rootObject.getObjectId());
long elementId = mapPage.createElementId();
mapPage.addElement(new NetworkMapObject(elementId, rootObject.getObjectId()));
addParentServices(rootObject, elementId);
addDciToRequestList();
}
use of org.netxms.client.maps.elements.NetworkMapObject in project netxms by netxms.
the class MapContentProvider method inputChanged.
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
synchronized (cachedDciValues) {
cachedDciValues.clear();
}
if (newInput instanceof NetworkMapPage) {
page = (NetworkMapPage) newInput;
synchronized (cachedDciValues) {
for (NetworkMapElement e : page.getElements()) {
if (e instanceof NetworkMapObject) {
long id = ((NetworkMapObject) e).getObjectId();
AbstractObject object = session.findObjectById(id);
if ((object != null) && (object instanceof AbstractNode)) {
cachedDciValues.put(id, null);
}
}
}
}
} else {
page = null;
}
}
Aggregations