/** * Set node-specific immutable settings and initialize components. This method must be called * exactly once for each instance. * * <p>Scratch space configuration is checked and initialized. * * <p>State of an instance remains not configured if exception appears. * * @param node node to configure * @param baseScratchConfiguration base scratch data space configuration, may be <code>null</code> * if node does not provide a scratch space; not existing directory pointed by this * configuration will be created * @throws IllegalStateException when trying to reconfigure already configured instance * @throws IllegalArgumentException when trying to configure node that is on different runtime/JVM * @throws ConfigurationException when configuration appears to be wrong during node scratch space * initialization (e.g. capabilities checking) * @throws FileSystemException when VFS creation or scratch initialization fails */ public synchronized void configureNode( Node node, BaseScratchSpaceConfiguration baseScratchConfiguration) throws IllegalStateException, IllegalArgumentException, FileSystemException, ConfigurationException { logger.debug("Configuring node for Data Spaces"); checkNotConfigured(); if (!NodeFactory.isNodeLocal(node)) { logger.error("Node to configure is not on the same runtime/JVM as a caller"); throw new IllegalArgumentException( "Node to configure is not on the same runtime/JVM as a caller"); } this.node = node; try { if (baseScratchConfiguration != null) { if (baseScratchConfiguration.getUrl() == null) { baseScratchConfiguration = startProActiveProviderServer(baseScratchConfiguration); } final NodeScratchSpace configuringScratchSpace = new VFSNodeScratchSpaceImpl(); configuringScratchSpace.init(node, baseScratchConfiguration); this.nodeScratchSpace = configuringScratchSpace; } configured = true; } finally { if (!configured) { tryCloseProviderServer(); // node scratch space is not configured (does not need close) for sure } } logger.debug("Node configured for Data Spaces"); }
/** * Returns the alive Nodes accessible by the RM * * @return list of ProActive Nodes */ public List<Node> listAliveNodes() throws Exception { ArrayList<Node> nodes = new ArrayList<>(); Set<String> urls = getResourceManager().listAliveNodeUrls(); for (String url : urls) { nodes.add(NodeFactory.getNode(url)); } return nodes; }
/** * Pings remote nodes and returns distances to hosts where these nodes are located. * * @param nodes to ping * @return distances map to hosts where these nodes are located */ public HashMap<InetAddress, Long> ping(NodeSet nodes) { HashMap<InetAddress, Long> results = new HashMap<>(); for (Node node : nodes) { try { InetAddress current = NodeFactory.getDefaultNode().getVMInformation().getInetAddress(); InetAddress nodeAddress = node.getVMInformation().getInetAddress(); if (current.equals(nodeAddress)) { // nodes on the same host results.put(nodeAddress, new Long(0)); } else { results.put(nodeAddress, pingNode(node)); } } catch (NodeException e) { } } return results; }
@Override protected Node createLocalNode(String nodeName) { Node localNode = null; try { localNode = NodeFactory.createLocalNode(nodeName, false, null, null); if (localNode == null) { System.out.println("The node returned by the NodeFactory is null"); System.err.println(RMNodeStarter.ExitStatus.RMNODE_NULL.description); System.exit(RMNodeStarter.ExitStatus.RMNODE_NULL.exitCode); } // this property is set to be able to which node source this node must // be added once added to the RM localNode.setProperty(VIRMNodeStarter.HOLDING_VM_KEY, this.holdingVM); } catch (Throwable t) { System.out.println("Unable to create the local node " + nodeName); t.printStackTrace(); System.exit(RMNodeStarter.ExitStatus.RMNODE_ADD_ERROR.exitCode); } return localNode; }