protected AbstractName buildControllerName(Artifact configId, NodeInfo nodeInfo) { return new AbstractName(configId, Collections.singletonMap("nodeName", nodeInfo.getName())); }
private void log(NodeInfo nodeInfo, Map<String, DownloadResults> results) { log.info("installing to node: " + nodeInfo.getName()); for (Map.Entry<String, DownloadResults> entry: results.entrySet()) { log.info("installation results for plugin list: " + entry.getKey()); DownloadResults downloadResults = entry.getValue(); log.info("installed: " + downloadResults.getInstalledConfigIDs()); if (downloadResults.isFailed()) { log.info("failure: ", downloadResults.getFailure()); } } }
public JpaNodeInfo getNodeInfo(JpaClusterInfo cluster, NodeInfo nodeInfo) { Query query = em.createNamedQuery("nodeByName"); query.setParameter("name", nodeInfo.getName()); JpaNodeInfo jpaNodeInfo; try { jpaNodeInfo = (JpaNodeInfo) query.getSingleResult(); } catch (NoResultException e) { jpaNodeInfo = new JpaNodeInfo(nodeInfo); em.persist(jpaNodeInfo); } if (jpaNodeInfo.getCluster() == null) { jpaNodeInfo.setCluster(cluster); } else if (!jpaNodeInfo.getCluster().getName().equals(cluster.getName())){ throw new IllegalStateException("cannot move node to another cluster"); } em.flush(); return jpaNodeInfo; }
public void serviceRemoved(URI service) { NodeInfo nodeInfo = toNodeInfo(service); if (nodeInfo != null) { String clusterName = toClusterName(service); nodeListener.removeNode(clusterName, nodeInfo.getName()); } }
public void stopConfiguration() throws Exception { for (NodeInfo nodeInfo : clusterInfo.getNodeInfos()) { if (!nodeInfo.getName().equals(nodeName)) { continue; } Kernel kernel = nodeInfo.newKernel(); ConfigurationManager configurationManager = newConfigurationManager(kernel); configurationManager.stopConfiguration(artifact); } }
public Map<String, DownloadResults> addNode(String clusterName, NodeInfo nodeInfo) { log.info("Node " + nodeInfo.getName() + " added to cluster " + clusterName); JpaClusterInfo cluster; JpaNodeInfo jpaNodeInfo; synchronized (this) { JpaContext clusterContext = new JpaContext(emf); cluster = clusterContext.getClusterInfo(clusterName); jpaNodeInfo = clusterContext.getNodeInfo(cluster, nodeInfo); clusterContext.close(); } Map<String, DownloadResults> installedPluginLists = new HashMap<String, DownloadResults>(); for (JpaPluginList pluginList : cluster.getPluginLists()) { DownloadResults downloadResults = installToNode(pluginList, jpaNodeInfo); installedPluginLists.put(pluginList.getName(), downloadResults); } return installedPluginLists; }
public void startConfiguration() throws Exception { for (NodeInfo nodeInfo : clusterInfo.getNodeInfos()) { if (!nodeInfo.getName().equals(nodeName)) { continue; } Kernel kernel = nodeInfo.newKernel(); ConfigurationManager configurationManager = newConfigurationManager(kernel); if (!configurationManager.isLoaded(artifact)) { configurationManager.loadConfiguration(artifact); } configurationManager.startConfiguration(artifact); } }
protected GBeanData buildControllerGBean(Artifact configId, NodeInfo nodeInfo, Artifact slaveConfigId) { AbstractName controllerName = buildControllerName(configId, nodeInfo); GBeanData gbean = new GBeanData(controllerName, BasicClusterConfigurationController.class); gbean.setAttribute(BasicClusterConfigurationController.GBEAN_ATTR_ARTIFACT, slaveConfigId); gbean.setAttribute(BasicClusterConfigurationController.GBEAN_ATTR_IGNORE_START_CONF_FAIL_UPON_START, Boolean.TRUE); gbean.setAttribute(BasicClusterConfigurationController.GBEAN_ATTR_NODE_NAME, nodeInfo.getName()); gbean.setAttribute(BasicClusterConfigurationController.GBEAN_ATTR_START_CONF_UPON_START, Boolean.TRUE); gbean.setReferencePattern(BasicClusterConfigurationController.GBEAN_REF_CLUSTER_INFO, clusterInfoName); return gbean; }
public JpaNodeInfo(NodeInfo nodeInfo) { this.name = nodeInfo.getName(); ExtendedJMXConnectorInfo connectorInfo = nodeInfo.getConnectorInfo(); userName = connectorInfo.getUsername(); password = connectorInfo.getPassword(); protocol = connectorInfo.getProtocol(); host = connectorInfo.getHost(); port = connectorInfo.getPort(); urlPath = connectorInfo.getUrlPath(); local = connectorInfo.isLocal(); }