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 String getJmxURI() { return "service:jmx:rmi://" + getHost() + "/jndi/" + getProtocol() + "://" + getHost() + ":" + getPort() + "/" + getUrlPath(); }
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 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); } } }
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 JMXConnector connect() throws IOException { String url = getJmxURI(); log.info("Attempting to connect to " + url + " with username " + getUsername() + " and password " + getPassword()); Map<String, ?> environment = Collections.singletonMap("jmx.remote.credentials", new String[] {getUsername(), getPassword()}); return JMXConnectorFactory.connect(new JMXServiceURL(url), environment); }
public Kernel newKernel() throws IOException { if (kernel == null) { if (local) { kernel = KernelRegistry.getSingleKernel(); } else { ExtendedJMXConnectorInfo connectorInfo = getConnectorInfo(); jmxConnector = connectorInfo.connect(); return connectorInfo.newKernel(jmxConnector); } } return kernel; }
protected AbstractName buildControllerName(Artifact configId, NodeInfo nodeInfo) { return new AbstractName(configId, Collections.singletonMap("nodeName", nodeInfo.getName())); }
@Override @EncryptOnPersist public String getPassword() { return super.getPassword(); } }
public void uninstall(ClusterInfo clusterInfo, Artifact configId) { uninstall(clusterInfo, configId, clusterInfo.getNodeInfos()); }
public ExtendedJMXConnectorInfo getConnectorInfo() { return new BasicExtendedJMXConnectorInfo(userName, password, protocol, host, port, urlPath, local); }
@Override @DoNotPersist public InetSocketAddress getListenAddress() { return super.getListenAddress(); }
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); } }
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); } }
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()); } } }
protected List<GBeanData> buildControllerGBeans(Artifact configId, Artifact slaveConfigId) { List<GBeanData> gbeans = new ArrayList<GBeanData>(); for (NodeInfo nodeInfo : clusterInfo.getNodeInfos()) { GBeanData gbean = buildControllerGBean(configId, nodeInfo, slaveConfigId); gbeans.add(gbean); } return gbeans; }
public void serviceRemoved(URI service) { NodeInfo nodeInfo = toNodeInfo(service); if (nodeInfo != null) { String clusterName = toClusterName(service); nodeListener.removeNode(clusterName, nodeInfo.getName()); } }
public void install(ClusterInfo clusterInfo, ConfigurationData configurationData) throws IOException, InvalidConfigException { Collection<NodeInfo> nodeInfos = clusterInfo.getNodeInfos(); Collection<NodeInfo> installedToNodeInfos = new ArrayList<NodeInfo>(); for (NodeInfo nodeInfo : nodeInfos) { try { install(nodeInfo, configurationData); installedToNodeInfos.add(nodeInfo); } catch (Exception e) { uninstall(clusterInfo, configurationData.getId(), installedToNodeInfos); if (e instanceof IOException) { throw (IOException) e; } else if (e instanceof InvalidConfigException) { throw (InvalidConfigException) e; } throw (IOException) new IOException("See nested").initCause(e); } } }
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; }