protected AbstractName buildControllerName(Artifact configId, NodeInfo nodeInfo) { return new AbstractName(configId, Collections.singletonMap("nodeName", 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 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(); }
protected void install(NodeInfo nodeInfo, ConfigurationData configurationData) throws IOException { Kernel kernel = nodeInfo.newKernel(); AbstractName clusterConfigurationStoreName = searchClusterConfigurationStore(kernel); File configurationDataFile = uploadConfiguration(kernel, nodeInfo, configurationData); boolean inVMCall = nodeInfo.getConnectorInfo().isLocal(); File oldConfigurationDir = null; if (inVMCall) { oldConfigurationDir = configurationData.getConfigurationDir(); } Object[] params = new Object[] {configurationData, configurationDataFile}; try { kernel.invoke(clusterConfigurationStoreName, "install", params, METHOD_SIGNATURE_INSTALL); } catch (Exception e) { throw (IOException) new IOException("See nested").initCause(e); } finally { if (inVMCall) { configurationData.setConfigurationDir(oldConfigurationDir); } } }
protected File uploadConfiguration(Kernel kernel, NodeInfo nodeInfo, ConfigurationData configurationData) throws IOException { File packedConfigurationDir = packager.pack(configurationData.getConfigurationDir()); if (nodeInfo.getConnectorInfo().isLocal()) { return packedConfigurationDir; } URL remoteDeployUploadURL = fileUploadClient.getRemoteDeployUploadURL(kernel); ConfigurationUploadProgress configurationUploadProgress = new ConfigurationUploadProgress(configurationData); File[] configurationDataFiles = new File[] {packedConfigurationDir}; ExtendedJMXConnectorInfo connectorInfo = nodeInfo.getConnectorInfo(); fileUploadClient.uploadFilesToServer(remoteDeployUploadURL, connectorInfo.getUsername(), connectorInfo.getPassword(), configurationDataFiles, configurationUploadProgress); if (configurationUploadProgress.failure) { if (null != configurationUploadProgress.exception) { throw (IOException) new IOException("See nested").initCause(configurationUploadProgress.exception); } throw new IOException(configurationUploadProgress.failureMessage); } return configurationDataFiles[0]; }
protected void uninstall(NodeInfo nodeInfo, Artifact configId) throws IOException { Kernel kernel = nodeInfo.newKernel(); try { ConfigurationManager configurationManager = (ConfigurationManager) kernel.getGBean(ConfigurationManager.class); configurationManager.stopConfiguration(configId); configurationManager.unloadConfiguration(configId); configurationManager.uninstallConfiguration(configId); } catch (Exception e) { throw (IOException) new IOException("See nested").initCause(e); } }
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 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); } }
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 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; }
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; }