http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/CommandHandler.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/CommandHandler.java b/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/CommandHandler.java deleted file mode 100644 index 7d628ff..0000000 --- a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/CommandHandler.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.asterix.installer.command; - -import org.apache.asterix.installer.command.ICommand.CommandType; - -public class CommandHandler { - - public void processCommand(String args[]) throws Exception { - CommandType cmdType = CommandType.valueOf(args[0].toUpperCase()); - ICommand cmd = null; - switch (cmdType) { - case CREATE: - cmd = new CreateCommand(); - break; - case ALTER: - cmd = new AlterCommand(); - break; - case DELETE: - cmd = new DeleteCommand(); - break; - case DESCRIBE: - cmd = new DescribeCommand(); - break; - case BACKUP: - cmd = new BackupCommand(); - break; - case RESTORE: - cmd = new RestoreCommand(); - break; - case START: - cmd = new StartCommand(); - break; - case STOP: - cmd = new StopCommand(); - break; - case VALIDATE: - cmd = new ValidateCommand(); - break; - case CONFIGURE: - cmd = new ConfigureCommand(); - break; - case INSTALL: - cmd = new InstallCommand(); - break; - case UNINSTALL: - cmd = new UninstallCommand(); - break; - case LOG: - cmd = new LogCommand(); - break; - case SHUTDOWN: - cmd = new ShutdownCommand(); - break; - case HELP: - cmd = new HelpCommand(); - break; - case STOPNODE: - cmd = new StopNodeCommand(); - break; - case STARTNODE: - cmd = new StartNodeCommand(); - break; - case VERSION: - cmd = new VersionCommand(); - break; - default: - break; - } - cmd.execute(args); - } -}
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/ConfigureCommand.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/ConfigureCommand.java b/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/ConfigureCommand.java deleted file mode 100644 index eac7586..0000000 --- a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/ConfigureCommand.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.asterix.installer.command; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.nio.file.Files; -import java.nio.file.Paths; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; -import javax.xml.bind.PropertyException; -import javax.xml.bind.Unmarshaller; - -import org.apache.asterix.event.management.EventUtil; -import org.apache.asterix.event.schema.cluster.Cluster; -import org.apache.asterix.event.schema.cluster.Node; -import org.apache.asterix.event.schema.cluster.WorkingDir; -import org.apache.asterix.installer.driver.InstallerDriver; -import org.apache.asterix.installer.schema.conf.Configuration; - -public class ConfigureCommand extends AbstractCommand { - - private static final String WORK_DIR = "/tmp/asterix"; - - @Override - protected void execCommand() throws Exception { - configureCluster("local", "local.xml"); - configureCluster("local", "local_chained_declustering_rep.xml"); - configureCluster("local", "local_metadata_only_rep.xml"); - configureCluster("demo", "demo.xml"); - - String installerConfPath = InstallerDriver.getManagixHome() + File.separator + InstallerDriver.MANAGIX_CONF_XML; - JAXBContext ctx = JAXBContext.newInstance(Configuration.class); - Unmarshaller unmarshaller = ctx.createUnmarshaller(); - Configuration configuration = (Configuration) unmarshaller.unmarshal(new File(installerConfPath)); - - configuration.setConfigured(true); - configuration.getBackup().setBackupDir(InstallerDriver.getManagixHome() + File.separator + "backup"); - configuration.getZookeeper().setHomeDir(InstallerDriver.getManagixHome() + File.separator - + InstallerDriver.MANAGIX_INTERNAL_DIR + File.separator + "zookeeper_home"); - configuration.getZookeeper().getServers().setJavaHome(System.getProperty("java.home")); - - Marshaller marshaller = ctx.createMarshaller(); - marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); - marshaller.marshal(configuration, new FileOutputStream(installerConfPath)); - } - - private void configureCluster(String dir, String file) - throws JAXBException, PropertyException, FileNotFoundException { - String clusterDir = InstallerDriver.getManagixHome() + File.separator + "clusters" + File.separator + dir; - String localClusterPath = clusterDir + File.separator + file; - - if (!Files.exists(Paths.get(localClusterPath))) { - return; - } - Cluster cluster = EventUtil.getCluster(localClusterPath); - String workingDir = clusterDir + File.separator + "working_dir"; - cluster.setWorkingDir(new WorkingDir(workingDir, true)); - cluster.setIodevices(configureIoDevices(cluster.getIodevices(), workingDir)); - cluster.setLogDir(configureDirectory(cluster.getLogDir(), workingDir)); - cluster.setTxnLogDir(configureDirectory(cluster.getTxnLogDir(), workingDir)); - String javaHome = System.getProperty("java.home"); - if (javaHome.endsWith(File.separator + "jre")) { - javaHome = javaHome.substring(0, javaHome.indexOf(File.separator + "jre")); - } - cluster.setJavaHome(javaHome); - - for (Node node : cluster.getNode()) { - node.setIodevices(configureIoDevices(node.getIodevices(), workingDir)); - node.setLogDir(configureDirectory(node.getLogDir(), workingDir)); - node.setTxnLogDir(configureDirectory(node.getTxnLogDir(), workingDir)); - } - - JAXBContext ctx = JAXBContext.newInstance(Cluster.class); - Marshaller marshaller = ctx.createMarshaller(); - marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); - marshaller.marshal(cluster, new FileOutputStream(localClusterPath)); - } - - private String configureIoDevices(String ioDevices, String workingDir) { - if (ioDevices == null) { - return null; - } - final String separator = ","; - StringBuilder sb = new StringBuilder(); - String[] ioDevs = ioDevices.split(separator); - for (int i = 0; i < ioDevs.length; ++i) { - if (i > 0) { - sb.append(separator); - } - sb.append(configureDirectory(ioDevs[i], workingDir)); - } - return sb.toString(); - } - - private String configureDirectory(String dir, String workingDir) { - return dir == null ? null : dir.replace(WORK_DIR, workingDir); - } - - @Override - protected String getUsageDescription() { - return "\nAuto-generates the ASTERIX installer configruation settings and ASTERIX cluster " - + "\nconfiguration settings for a single node setup."; - } - - @Override - protected CommandConfig getCommandConfig() { - return new ConfigureConfig(); - } - -} - -class ConfigureConfig extends CommandConfig { - -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/CreateCommand.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/CreateCommand.java b/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/CreateCommand.java deleted file mode 100644 index 6db0648..0000000 --- a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/CreateCommand.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.asterix.installer.command; - -import java.io.File; - -import org.kohsuke.args4j.Option; -import org.apache.asterix.common.api.IClusterManagementWork.ClusterState; -import org.apache.asterix.common.configuration.AsterixConfiguration; -import org.apache.asterix.event.error.VerificationUtil; -import org.apache.asterix.event.management.AsterixEventServiceClient; -import org.apache.asterix.event.management.EventUtil; -import org.apache.asterix.event.model.AsterixInstance; -import org.apache.asterix.event.model.AsterixRuntimeState; -import org.apache.asterix.event.schema.cluster.Cluster; -import org.apache.asterix.event.schema.pattern.Patterns; -import org.apache.asterix.event.service.AsterixEventService; -import org.apache.asterix.event.service.AsterixEventServiceUtil; -import org.apache.asterix.event.service.ClusterStateWatcher; -import org.apache.asterix.event.service.ServiceProvider; -import org.apache.asterix.event.util.PatternCreator; -import org.apache.asterix.installer.driver.InstallerDriver; -import org.apache.asterix.installer.driver.InstallerUtil; - -public class CreateCommand extends AbstractCommand { - - private String asterixInstanceName; - private Cluster cluster; - private AsterixConfiguration asterixConfiguration; - - @Override - protected void execCommand() throws Exception { - InstallerDriver.initConfig(true); - ValidateCommand validateCommand = new ValidateCommand(); - boolean valid = validateCommand.validateCluster(((CreateConfig) config).clusterPath); - if (!valid) { - throw new Exception("Cannot create an Asterix instance."); - } - asterixInstanceName = ((CreateConfig) config).name; - AsterixEventServiceUtil.validateAsterixInstanceNotExists(asterixInstanceName); - CreateConfig createConfig = (CreateConfig) config; - cluster = EventUtil.getCluster(createConfig.clusterPath); - cluster.setInstanceName(asterixInstanceName); - asterixConfiguration = InstallerUtil.getAsterixConfiguration(createConfig.asterixConfPath); - AsterixInstance asterixInstance = AsterixEventServiceUtil.createAsterixInstance(asterixInstanceName, cluster, - asterixConfiguration); - AsterixEventServiceUtil.evaluateConflictWithOtherInstances(asterixInstance); - AsterixEventServiceUtil.createAsterixZip(asterixInstance); - AsterixEventServiceUtil.createClusterProperties(cluster, asterixConfiguration); - AsterixEventServiceClient eventrixClient = AsterixEventService.getAsterixEventServiceClient(cluster, true, - false); - // Store the cluster initially in Zookeeper and start watching - ServiceProvider.INSTANCE.getLookupService().writeAsterixInstance(asterixInstance); - ClusterStateWatcher stateWatcher = ServiceProvider.INSTANCE.getLookupService().startWatchingClusterState( - asterixInstanceName); - Patterns asterixBinarytrasnferPattern = PatternCreator.INSTANCE.getAsterixBinaryTransferPattern( - asterixInstanceName, cluster); - eventrixClient.submit(asterixBinarytrasnferPattern); - Patterns patterns = PatternCreator.INSTANCE.getStartAsterixPattern(asterixInstanceName, cluster, true); - eventrixClient.submit(patterns); - - // Check the cluster state - ClusterState clusterState = stateWatcher.waitForClusterStart(); - if (clusterState != ClusterState.ACTIVE) { - throw new Exception("CC failed to start"); - } - - AsterixRuntimeState runtimeState = VerificationUtil.getAsterixRuntimeState(asterixInstance); - VerificationUtil.updateInstanceWithRuntimeDescription(asterixInstance, runtimeState, true); - ServiceProvider.INSTANCE.getLookupService().updateAsterixInstance(asterixInstance); - AsterixEventServiceUtil.deleteDirectory(InstallerDriver.getManagixHome() + File.separator - + InstallerDriver.ASTERIX_DIR + File.separator + asterixInstanceName); - LOGGER.info(asterixInstance.getDescription(false)); - } - - @Override - protected CommandConfig getCommandConfig() { - return new CreateConfig(); - } - - public Cluster getCluster() { - return cluster; - } - - public String getAsterixInstanceName() { - return asterixInstanceName; - } - - @Override - protected String getUsageDescription() { - return "\nCreates an ASTERIX instance with a specified name." - + "\n\nPost creation, the instance is in ACTIVE state, indicating its " - + "\navailability for executing statements/queries." + "\n\nUsage arguments/options:" - + "\n-n Name of the ASTERIX instance." + "\n-c Path to the cluster configuration file" - + "\n[-a] Path to asterix configuration file" + "\n [..] indicates optional flag"; - } - -} - -class CreateConfig extends CommandConfig { - - @Option(name = "-n", required = true, usage = "Name of Asterix Instance") - public String name; - - @Option(name = "-c", required = true, usage = "Path to cluster configuration") - public String clusterPath; - - @Option(name = "-a", required = false, usage = "Path to asterix configuration") - public String asterixConfPath; - -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/DeleteCommand.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/DeleteCommand.java b/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/DeleteCommand.java deleted file mode 100644 index 043d48a..0000000 --- a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/DeleteCommand.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.asterix.installer.command; - -import org.apache.asterix.event.model.AsterixInstance; -import org.apache.asterix.event.model.AsterixInstance.State; -import org.apache.asterix.event.schema.pattern.Patterns; -import org.apache.asterix.event.service.AsterixEventService; -import org.apache.asterix.event.service.AsterixEventServiceUtil; -import org.apache.asterix.event.service.ServiceProvider; -import org.apache.asterix.event.util.PatternCreator; -import org.apache.asterix.installer.driver.InstallerDriver; -import org.kohsuke.args4j.Option; - -public class DeleteCommand extends AbstractCommand { - - @Override - protected void execCommand() throws Exception { - InstallerDriver.initConfig(true); - String asterixInstanceName = ((DeleteConfig) config).name; - AsterixInstance instance = AsterixEventServiceUtil.validateAsterixInstanceExists(asterixInstanceName, - State.INACTIVE); - Patterns patterns = PatternCreator.INSTANCE.createDeleteInstancePattern(instance); - AsterixEventService.getAsterixEventServiceClient(instance.getCluster()).submit(patterns); - - patterns = PatternCreator.INSTANCE.createRemoveAsterixWorkingDirPattern(instance); - AsterixEventService.getAsterixEventServiceClient(instance.getCluster()).submit(patterns); - ServiceProvider.INSTANCE.getLookupService().removeAsterixInstance(asterixInstanceName); - LOGGER.info("Deleted Asterix instance: " + asterixInstanceName); - } - - @Override - protected CommandConfig getCommandConfig() { - return new DeleteConfig(); - } - - @Override - protected String getUsageDescription() { - return "\nPermanently deletes an ASTERIX instance." + "\n" + "The instance must be in the INACTIVE state." - + "\n\nAvailable arguments/options" + "\n-n name of the ASTERIX instance."; - } - -} - -class DeleteConfig extends CommandConfig { - - @Option(name = "-n", required = true, usage = "Name of Asterix Instance") - public String name; - -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/DescribeCommand.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/DescribeCommand.java b/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/DescribeCommand.java deleted file mode 100644 index 1ffcb74..0000000 --- a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/DescribeCommand.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.asterix.installer.command; - -import java.util.List; - -import org.kohsuke.args4j.Option; - -import org.apache.asterix.event.error.VerificationUtil; -import org.apache.asterix.event.model.AsterixInstance; -import org.apache.asterix.event.model.AsterixInstance.State; -import org.apache.asterix.event.model.AsterixRuntimeState; -import org.apache.asterix.event.service.AsterixEventServiceUtil; -import org.apache.asterix.event.service.ServiceProvider; -import org.apache.asterix.installer.driver.InstallerDriver; -import org.apache.asterix.installer.error.InstallerException; - -public class DescribeCommand extends AbstractCommand { - - @Override - protected void execCommand() throws Exception { - InstallerDriver.initConfig(true); - String asterixInstanceName = ((DescribeConfig) config).name; - boolean adminView = ((DescribeConfig) config).admin; - if (asterixInstanceName != null) { - AsterixEventServiceUtil.validateAsterixInstanceExists(asterixInstanceName, State.INACTIVE, State.ACTIVE, - State.UNUSABLE); - AsterixInstance instance = ServiceProvider.INSTANCE.getLookupService().getAsterixInstance( - asterixInstanceName); - if (instance != null) { - AsterixRuntimeState state = VerificationUtil.getAsterixRuntimeState(instance); - boolean expectedRunning = instance.getState().equals(State.UNUSABLE) ? instance.getPreviousState() - .equals(State.ACTIVE) : !instance.getState().equals(State.INACTIVE); - VerificationUtil.updateInstanceWithRuntimeDescription(instance, state, expectedRunning); - ServiceProvider.INSTANCE.getLookupService().updateAsterixInstance(instance); - LOGGER.info(instance.getDescription(adminView)); - } else { - throw new InstallerException("Asterix instance by the name " + asterixInstanceName + " does not exist."); - } - } else { - List<AsterixInstance> asterixInstances = ServiceProvider.INSTANCE.getLookupService().getAsterixInstances(); - if (asterixInstances.size() > 0) { - for (AsterixInstance instance : asterixInstances) { - AsterixRuntimeState state = VerificationUtil.getAsterixRuntimeState(instance); - boolean expectedRunning = instance.getState().equals(State.UNUSABLE) ? instance.getPreviousState() - .equals(State.ACTIVE) : !instance.getState().equals(State.INACTIVE); - VerificationUtil.updateInstanceWithRuntimeDescription(instance, state, expectedRunning); - ServiceProvider.INSTANCE.getLookupService().updateAsterixInstance(instance); - LOGGER.info(instance.getDescription(adminView)); - } - } else { - LOGGER.info("No Asterix instances found!"); - } - - } - } - - @Override - protected CommandConfig getCommandConfig() { - return new DescribeConfig(); - } - - @Override - protected String getUsageDescription() { - return "\nProvides information about an ASTERIX instance." + "\n\nUsage arguments/options:-" - + "\n[-n] Name of the ASTERIX instance." + "\n[-admin] Provides a detailed description"; - } - -} - -class DescribeConfig extends CommandConfig { - - @Option(name = "-n", required = false, usage = "Name of Asterix Instance") - public String name; - - @Option(name = "-admin", required = false, usage = "Detailed description") - public boolean admin; - -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/HelpCommand.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/HelpCommand.java b/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/HelpCommand.java deleted file mode 100644 index e8a93be..0000000 --- a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/HelpCommand.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.asterix.installer.command; - -import org.kohsuke.args4j.Option; - -public class HelpCommand extends AbstractCommand { - - @Override - protected void execCommand() throws Exception { - HelpConfig helpConfig = (HelpConfig) config; - String command = helpConfig.command; - CommandType cmdType = CommandType.valueOf(command.toUpperCase()); - String helpMessage = null; - switch (cmdType) { - case CREATE: - helpMessage = new CreateCommand().getUsageDescription(); - break; - case CONFIGURE: - helpMessage = new ConfigureCommand().getUsageDescription(); - break; - case DELETE: - helpMessage = new DeleteCommand().getUsageDescription(); - break; - case DESCRIBE: - helpMessage = new DescribeCommand().getUsageDescription(); - break; - case RESTORE: - helpMessage = new RestoreCommand().getUsageDescription(); - break; - case START: - helpMessage = new StartCommand().getUsageDescription(); - break; - case SHUTDOWN: - helpMessage = new ShutdownCommand().getUsageDescription(); - break; - case BACKUP: - helpMessage = new BackupCommand().getUsageDescription(); - break; - case STOP: - helpMessage = new StopCommand().getUsageDescription(); - break; - case VALIDATE: - helpMessage = new ValidateCommand().getUsageDescription(); - break; - case INSTALL: - helpMessage = new InstallCommand().getUsageDescription(); - break; - case UNINSTALL: - helpMessage = new UninstallCommand().getUsageDescription(); - break; - case ALTER: - helpMessage = new AlterCommand().getUsageDescription(); - break; - case LOG: - helpMessage = new LogCommand().getUsageDescription(); - break; - case STOPNODE: - helpMessage = new StopNodeCommand().getUsageDescription(); - break; - case STARTNODE: - helpMessage = new StartNodeCommand().getUsageDescription(); - break; - case VERSION: - helpMessage = new VersionCommand().getUsageDescription(); - break; - default: - helpMessage = "Unknown command " + command; - } - - System.out.println(helpMessage); - } - - @Override - protected CommandConfig getCommandConfig() { - return new HelpConfig(); - } - - @Override - protected String getUsageDescription() { - return "\nAlter the instance's configuration settings." - + "\nPrior to running this command, the instance is required to be INACTIVE state." - + "\n\nAvailable arguments/options" + "\n-n name of the ASTERIX instance" - + "\n-conf path to the ASTERIX configuration file."; - } - -} - -class HelpConfig extends CommandConfig { - - @Option(name = "-cmd", required = true, usage = "Name of Asterix Instance") - public String command; - -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/ICommand.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/ICommand.java b/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/ICommand.java deleted file mode 100644 index 47e4a8d..0000000 --- a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/ICommand.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.asterix.installer.command; - -public interface ICommand { - - public enum CommandType { - CREATE, - DELETE, - START, - STOP, - BACKUP, - RESTORE, - DESCRIBE, - ALTER, - VALIDATE, - CONFIGURE, - INSTALL, - UNINSTALL, - LOG, - SHUTDOWN, - HELP, - STOPNODE, - STARTNODE, - VERSION - } - - public void execute(String args[]) throws Exception; -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/InstallCommand.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/InstallCommand.java b/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/InstallCommand.java deleted file mode 100644 index 779f76d..0000000 --- a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/InstallCommand.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.asterix.installer.command; - -import org.kohsuke.args4j.Option; - -import org.apache.asterix.event.model.AsterixInstance; -import org.apache.asterix.event.model.AsterixInstance.State; -import org.apache.asterix.event.schema.pattern.Patterns; -import org.apache.asterix.event.service.AsterixEventService; -import org.apache.asterix.event.service.AsterixEventServiceUtil; -import org.apache.asterix.event.util.PatternCreator; -import org.apache.asterix.installer.driver.InstallerDriver; - -public class InstallCommand extends AbstractCommand { - - @Override - protected void execCommand() throws Exception { - InstallerDriver.initConfig(true); - InstallConfig installConfig = ((InstallConfig) config); - String instanceName = installConfig.name; - AsterixInstance instance = AsterixEventServiceUtil.validateAsterixInstanceExists(instanceName, State.INACTIVE); - PatternCreator pc = PatternCreator.INSTANCE; - Patterns patterns = pc.getLibraryInstallPattern(instance, installConfig.dataverseName, - installConfig.libraryName, installConfig.libraryPath); - AsterixEventService.getAsterixEventServiceClient(instance.getCluster()).submit(patterns); - LOGGER.info("Installed library " + installConfig.libraryName); - } - - @Override - protected CommandConfig getCommandConfig() { - return new InstallConfig(); - } - - @Override - protected String getUsageDescription() { - return "Installs a library to an asterix instance." + "\n" + "Arguments/Options\n" - + "-n Name of Asterix Instance\n" - + "-d Name of the dataverse under which the library will be installed\n" + "-l Name of the library\n" - + "-p Path to library zip bundle"; - - } - -} - -class InstallConfig extends CommandConfig { - - @Option(name = "-n", required = true, usage = "Name of Asterix Instance") - public String name; - - @Option(name = "-d", required = true, usage = "Name of the dataverse under which the library will be installed") - public String dataverseName; - - @Option(name = "-l", required = true, usage = "Name of the library") - public String libraryName; - - @Option(name = "-p", required = true, usage = "Path to library zip bundle") - public String libraryPath; - -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/LogCommand.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/LogCommand.java b/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/LogCommand.java deleted file mode 100644 index 1e00d70..0000000 --- a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/LogCommand.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.asterix.installer.command; - -import java.io.File; -import java.io.FilenameFilter; -import java.util.Date; - -import org.apache.commons.io.FileUtils; -import org.kohsuke.args4j.Option; - -import org.apache.asterix.event.management.AsterixEventServiceClient; -import org.apache.asterix.event.model.AsterixInstance; -import org.apache.asterix.event.model.AsterixInstance.State; -import org.apache.asterix.event.schema.pattern.Patterns; -import org.apache.asterix.event.service.AsterixEventService; -import org.apache.asterix.event.service.AsterixEventServiceUtil; -import org.apache.asterix.event.util.PatternCreator; -import org.apache.asterix.installer.driver.InstallerDriver; -import org.apache.asterix.installer.error.InstallerException; - -public class LogCommand extends AbstractCommand { - - @Override - protected void execCommand() throws Exception { - InstallerDriver.initConfig(true); - String asterixInstanceName = ((LogConfig) config).name; - AsterixInstance instance = AsterixEventServiceUtil.validateAsterixInstanceExists(asterixInstanceName, - State.INACTIVE, State.UNUSABLE, State.ACTIVE); - PatternCreator pc = PatternCreator.INSTANCE; - - AsterixEventServiceClient eventrixClient = AsterixEventService.getAsterixEventServiceClient( - instance.getCluster(), true, false); - - String outputDir = ((LogConfig) config).outputDir == null ? InstallerDriver.getManagixHome() + File.separator - + "logdump" : ((LogConfig) config).outputDir; - File f = new File(outputDir); - String outputDirPath = f.getAbsolutePath(); - if (!f.exists()) { - boolean success = f.mkdirs(); - if (!success) { - throw new InstallerException("Unable to create output directory:" + outputDirPath); - } - } - Patterns transferLogPattern = pc.getGenerateLogPattern(instance.getCluster(), - outputDirPath); - eventrixClient.submit(transferLogPattern); - File outputDirFile = new File(outputDirPath); - final String destFileName = "log_" + new Date().toString().replace(' ', '_') + ".zip"; - File destFile = new File(outputDirFile, destFileName); - AsterixEventServiceUtil.zipDir(outputDirFile, destFile); - - String[] filesToDelete = outputDirFile.list(new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return !name.equals(destFileName); - } - - }); - for (String fileS : filesToDelete) { - f = new File(outputDirFile, fileS); - if (f.isDirectory()) { - FileUtils.deleteDirectory(f); - } else { - f.delete(); - } - } - LOGGER.info("Log zip archive created at " + destFile.getAbsolutePath()); - } - - @Override - protected CommandConfig getCommandConfig() { - return new LogConfig(); - } - - @Override - protected String getUsageDescription() { - return "\nCreates a tar ball containing log files corresponding to each worker node (NC) and the master (CC) for an ASTERIX instance" - + "\n\nAvailable arguments/options" - + "\n-n name of the ASTERIX instance. \n-d destination directory for producing the tar ball (defaults to) " - + InstallerDriver.getManagixHome(); - } -} - -class LogConfig extends CommandConfig { - - @Option(name = "-n", required = true, usage = "Name of Asterix Instance") - public String name; - - @Option(name = "-d", required = false, usage = "Destination directory for producing log tar ball") - public String outputDir; - -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/RestoreCommand.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/RestoreCommand.java b/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/RestoreCommand.java deleted file mode 100644 index 79a1cc7..0000000 --- a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/RestoreCommand.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.asterix.installer.command; - -import java.util.List; - -import org.kohsuke.args4j.Option; - -import org.apache.asterix.event.model.AsterixInstance; -import org.apache.asterix.event.model.AsterixInstance.State; -import org.apache.asterix.event.model.BackupInfo; -import org.apache.asterix.event.schema.pattern.Patterns; -import org.apache.asterix.event.service.AsterixEventService; -import org.apache.asterix.event.service.AsterixEventServiceUtil; -import org.apache.asterix.event.util.PatternCreator; -import org.apache.asterix.installer.driver.InstallerDriver; - -public class RestoreCommand extends AbstractCommand { - - @Override - protected void execCommand() throws Exception { - InstallerDriver.initConfig(true); - String asterixInstanceName = ((RestoreConfig) config).name; - AsterixInstance instance = AsterixEventServiceUtil.validateAsterixInstanceExists(asterixInstanceName, - State.INACTIVE); - int backupId = ((RestoreConfig) config).backupId; - List<BackupInfo> backupInfoList = instance.getBackupInfo(); - if (backupInfoList.size() <= backupId || backupId < 0) { - throw new IllegalStateException("Invalid backup id"); - } - - BackupInfo backupInfo = backupInfoList.get(backupId); - Patterns patterns = PatternCreator.INSTANCE.getRestoreAsterixPattern(instance, backupInfo); - AsterixEventService.getAsterixEventServiceClient(instance.getCluster()).submit(patterns); - LOGGER.info("Asterix instance: " + asterixInstanceName + " has been restored from backup"); - } - - @Override - protected CommandConfig getCommandConfig() { - return new RestoreConfig(); - } - - @Override - protected String getUsageDescription() { - return "\nRestores an ASTERIX instance's data from a previously taken backup snapshot." - + "\n\nAvailable arguments/options" + "\n-n name of the ASTERIX instance" - + "\n-b id of the backup snapshot "; - } - -} - -class RestoreConfig extends CommandConfig { - - @Option(name = "-n", required = true, usage = "Name of the Asterix instance") - public String name; - - @Option(name = "-b", required = true, usage = "Id corresponding to the backed up version") - public int backupId; - -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/ShutdownCommand.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/ShutdownCommand.java b/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/ShutdownCommand.java deleted file mode 100644 index d4f6bcf..0000000 --- a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/ShutdownCommand.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.asterix.installer.command; - -import org.apache.asterix.event.service.AsterixEventService; -import org.apache.asterix.event.service.ILookupService; -import org.apache.asterix.event.service.ServiceProvider; -import org.apache.asterix.installer.driver.InstallerDriver; - -public class ShutdownCommand extends AbstractCommand { - - @Override - protected void execCommand() throws Exception { - InstallerDriver.initConfig(false); - ILookupService lookupService = ServiceProvider.INSTANCE.getLookupService(); - lookupService.stopService(AsterixEventService.getConfiguration()); - } - - @Override - protected CommandConfig getCommandConfig() { - return new ShutdownConfig(); - } - - @Override - protected String getUsageDescription() { - return "\nShuts down the installer's backgrouund processes"; - } - -} - -class ShutdownConfig extends CommandConfig { - -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/StartCommand.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/StartCommand.java b/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/StartCommand.java deleted file mode 100644 index 551bc11..0000000 --- a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/StartCommand.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.asterix.installer.command; - -import java.io.File; - -import org.kohsuke.args4j.Option; -import org.apache.asterix.common.api.IClusterManagementWork.ClusterState; -import org.apache.asterix.event.error.VerificationUtil; -import org.apache.asterix.event.management.AsterixEventServiceClient; -import org.apache.asterix.event.model.AsterixInstance; -import org.apache.asterix.event.model.AsterixInstance.State; -import org.apache.asterix.event.model.AsterixRuntimeState; -import org.apache.asterix.event.schema.pattern.Patterns; -import org.apache.asterix.event.service.AsterixEventService; -import org.apache.asterix.event.service.AsterixEventServiceUtil; -import org.apache.asterix.event.service.ClusterStateWatcher; -import org.apache.asterix.event.service.ServiceProvider; -import org.apache.asterix.event.util.PatternCreator; -import org.apache.asterix.installer.driver.InstallerDriver; - -public class StartCommand extends AbstractCommand { - - @Override - protected void execCommand() throws Exception { - InstallerDriver.initConfig(true); - String asterixInstanceName = ((StartConfig) config).name; - AsterixInstance instance = AsterixEventServiceUtil.validateAsterixInstanceExists(asterixInstanceName, - State.INACTIVE); - AsterixEventServiceUtil.createAsterixZip(instance); - AsterixEventServiceClient client = AsterixEventService.getAsterixEventServiceClient(instance.getCluster()); - Patterns asterixBinaryTransferPattern = PatternCreator.INSTANCE.getAsterixBinaryTransferPattern( - asterixInstanceName, instance.getCluster()); - client.submit(asterixBinaryTransferPattern); - // Start the watcher - ClusterStateWatcher stateWatcher = ServiceProvider.INSTANCE.getLookupService().startWatchingClusterState( - asterixInstanceName); - AsterixEventServiceUtil.createClusterProperties(instance.getCluster(), instance.getAsterixConfiguration()); - Patterns patterns = PatternCreator.INSTANCE.getStartAsterixPattern(asterixInstanceName, instance.getCluster(), - false); - client.submit(patterns); - // Check the cluster state - ClusterState clusterState = stateWatcher.waitForClusterStart(); - if (clusterState != ClusterState.ACTIVE) { - throw new Exception("CC failed to start"); - } - AsterixEventServiceUtil.deleteDirectory(InstallerDriver.getManagixHome() + File.separator - + InstallerDriver.ASTERIX_DIR + File.separator + asterixInstanceName); - AsterixRuntimeState runtimeState = VerificationUtil.getAsterixRuntimeState(instance); - VerificationUtil.updateInstanceWithRuntimeDescription(instance, runtimeState, true); - LOGGER.info(instance.getDescription(false)); - ServiceProvider.INSTANCE.getLookupService().updateAsterixInstance(instance); - } - - @Override - protected CommandConfig getCommandConfig() { - return new StartConfig(); - } - - @Override - protected String getUsageDescription() { - return "\nStarts an ASTERIX instance that is in INACTIVE state." - + "\nAfter executing the start command, the ASTERIX instance transits to the ACTIVE state," - + "\nindicating that it is now available for executing statements/queries." - + "\n\nAvailable arguments/options" + "\n-n name of the ASTERIX instance. "; - } -} - -class StartConfig extends CommandConfig { - - @Option(name = "-n", required = true, usage = "Name of Asterix Instance") - public String name; - -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/StartNodeCommand.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/StartNodeCommand.java b/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/StartNodeCommand.java deleted file mode 100644 index 59825fe..0000000 --- a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/StartNodeCommand.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.asterix.installer.command; - -import java.util.ArrayList; -import java.util.List; - -import org.kohsuke.args4j.Option; - -import org.apache.asterix.event.error.VerificationUtil; -import org.apache.asterix.event.management.AsterixEventServiceClient; -import org.apache.asterix.event.model.AsterixInstance; -import org.apache.asterix.event.model.AsterixInstance.State; -import org.apache.asterix.event.model.AsterixRuntimeState; -import org.apache.asterix.event.model.ProcessInfo; -import org.apache.asterix.event.schema.cluster.Cluster; -import org.apache.asterix.event.schema.cluster.Node; -import org.apache.asterix.event.schema.pattern.Pattern; -import org.apache.asterix.event.schema.pattern.Patterns; -import org.apache.asterix.event.service.AsterixEventService; -import org.apache.asterix.event.service.AsterixEventServiceUtil; -import org.apache.asterix.event.service.ServiceProvider; -import org.apache.asterix.event.util.PatternCreator; -import org.apache.asterix.installer.driver.InstallerDriver; -import org.apache.asterix.installer.error.InstallerException; - -public class StartNodeCommand extends AbstractCommand { - - @Override - protected void execCommand() throws Exception { - InstallerDriver.initConfig(true); - String asterixInstanceName = ((StartNodeConfig) config).name; - AsterixInstance instance = AsterixEventServiceUtil.validateAsterixInstanceExists(asterixInstanceName, - State.INACTIVE, State.ACTIVE, State.UNUSABLE); - - Cluster cluster = instance.getCluster(); - List<Pattern> pl = new ArrayList<Pattern>(); - AsterixRuntimeState runtimeState = VerificationUtil.getAsterixRuntimeState(instance); - String[] nodesToBeAdded = ((StartNodeConfig) config).nodes.split(","); - List<String> aliveNodes = new ArrayList<String>(); - for (ProcessInfo p : runtimeState.getProcesses()) { - aliveNodes.add(p.getNodeId()); - } - List<Node> clusterNodes = cluster.getNode(); - for (String n : nodesToBeAdded) { - if (aliveNodes.contains(n)) { - throw new InstallerException("Node: " + n + " is already alive"); - } - for (Node node : clusterNodes) { - if (n.equals(node.getId())) { - String iodevices = node.getIodevices() == null ? cluster.getIodevices() : node.getIodevices(); - Pattern createNC = PatternCreator.INSTANCE.createNCStartPattern(cluster.getMasterNode() - .getClusterIp(), node.getId(), asterixInstanceName + "_" + node.getId(), iodevices, false); - pl.add(createNC); - break; - } - } - } - Patterns patterns = new Patterns(pl); - AsterixEventServiceClient client = AsterixEventService.getAsterixEventServiceClient(cluster); - client.submit(patterns); - runtimeState = VerificationUtil.getAsterixRuntimeState(instance); - VerificationUtil.updateInstanceWithRuntimeDescription(instance, runtimeState, true); - LOGGER.info(instance.getDescription(false)); - ServiceProvider.INSTANCE.getLookupService().updateAsterixInstance(instance); - } - - @Override - protected CommandConfig getCommandConfig() { - return new StartNodeConfig(); - } - - @Override - protected String getUsageDescription() { - return "\nStarts a set of nodes for an ASTERIX instance." + "\n\nAvailable arguments/options" - + "\n-n name of the ASTERIX instance. " + "\n-nodes" - + "Comma separated list of nodes that need to be started"; - } -} - -class StartNodeConfig extends CommandConfig { - - @Option(name = "-n", required = true, usage = "Name of Asterix Instance") - public String name; - - @Option(name = "-nodes", required = true, usage = "Comma separated list of nodes that need to be started") - public String nodes; - -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/StopCommand.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/StopCommand.java b/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/StopCommand.java deleted file mode 100644 index 0feff27..0000000 --- a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/StopCommand.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.asterix.installer.command; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import org.kohsuke.args4j.Option; - -import org.apache.asterix.event.management.AsterixEventServiceClient; -import org.apache.asterix.event.model.AsterixInstance; -import org.apache.asterix.event.model.AsterixInstance.State; -import org.apache.asterix.event.schema.cluster.Node; -import org.apache.asterix.event.schema.pattern.Pattern; -import org.apache.asterix.event.schema.pattern.Patterns; -import org.apache.asterix.event.service.AsterixEventService; -import org.apache.asterix.event.service.AsterixEventServiceUtil; -import org.apache.asterix.event.service.ServiceProvider; -import org.apache.asterix.event.util.PatternCreator; -import org.apache.asterix.installer.driver.InstallerDriver; - -public class StopCommand extends AbstractCommand { - - @Override - protected void execCommand() throws Exception { - InstallerDriver.initConfig(true); - String asterixInstanceName = ((StopConfig) config).name; - AsterixInstance asterixInstance = AsterixEventServiceUtil.validateAsterixInstanceExists(asterixInstanceName, - State.ACTIVE, State.UNUSABLE); - AsterixEventServiceClient client = AsterixEventService.getAsterixEventServiceClient(asterixInstance - .getCluster()); - - List<Pattern> ncKillPatterns = new ArrayList<Pattern>(); - for (Node node : asterixInstance.getCluster().getNode()) { - ncKillPatterns.add(PatternCreator.INSTANCE.createNCStopPattern(node.getId(), asterixInstanceName + "_" - + node.getId())); - } - - List<Pattern> ccKillPatterns = new ArrayList<Pattern>(); - ccKillPatterns.add(PatternCreator.INSTANCE.createCCStopPattern(asterixInstance.getCluster().getMasterNode() - .getId())); - - try { - client.submit(new Patterns(ncKillPatterns)); - client.submit(new Patterns(ccKillPatterns)); - } catch (Exception e) { - // processes are already dead - LOGGER.debug("Attempt to kill non-existing processess"); - } - - asterixInstance.setState(State.INACTIVE); - asterixInstance.setStateChangeTimestamp(new Date()); - ServiceProvider.INSTANCE.getLookupService().updateAsterixInstance(asterixInstance); - LOGGER.info("Stopped Asterix instance: " + asterixInstanceName); - } - - @Override - protected CommandConfig getCommandConfig() { - return new StopConfig(); - } - - public String getAsterixInstanceName() { - return ((StopConfig) config).name; - } - - @Override - protected String getUsageDescription() { - return "\nShuts an ASTERIX instance that is in ACTIVE/UNUSABLE state." - + "\nAfter executing the stop command, the ASTERIX instance transits" - + "\nto the INACTIVE state, indicating that it is no longer available" - + "\nfor executing statements/queries." + "\n\nAvailable arguments/options" - + "\n-n name of the ASTERIX instance."; - - } - -} - -class StopConfig extends CommandConfig { - - @Option(name = "-n", required = true, usage = "Name of Asterix Instance") - public String name; - -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/StopNodeCommand.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/StopNodeCommand.java b/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/StopNodeCommand.java deleted file mode 100644 index 1c22f86..0000000 --- a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/StopNodeCommand.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.asterix.installer.command; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import org.kohsuke.args4j.Option; - -import org.apache.asterix.event.error.VerificationUtil; -import org.apache.asterix.event.management.AsterixEventServiceClient; -import org.apache.asterix.event.model.AsterixInstance; -import org.apache.asterix.event.model.AsterixInstance.State; -import org.apache.asterix.event.model.AsterixRuntimeState; -import org.apache.asterix.event.model.ProcessInfo; -import org.apache.asterix.event.schema.cluster.Node; -import org.apache.asterix.event.schema.pattern.Pattern; -import org.apache.asterix.event.schema.pattern.Patterns; -import org.apache.asterix.event.service.AsterixEventService; -import org.apache.asterix.event.service.AsterixEventServiceUtil; -import org.apache.asterix.event.service.ServiceProvider; -import org.apache.asterix.event.util.PatternCreator; -import org.apache.asterix.installer.driver.InstallerDriver; -import org.apache.asterix.installer.error.InstallerException; - -public class StopNodeCommand extends AbstractCommand { - - @Override - protected void execCommand() throws Exception { - InstallerDriver.initConfig(true); - String asterixInstanceName = ((StopNodeConfig) config).name; - AsterixInstance asterixInstance = AsterixEventServiceUtil.validateAsterixInstanceExists(asterixInstanceName, - State.ACTIVE, State.UNUSABLE); - - AsterixEventServiceClient client = AsterixEventService.getAsterixEventServiceClient(asterixInstance - .getCluster()); - - String[] nodesToStop = ((StopNodeConfig) config).nodeList.split(","); - AsterixRuntimeState runtimeState = VerificationUtil.getAsterixRuntimeState(asterixInstance); - List<String> aliveNodes = new ArrayList<String>(); - for (ProcessInfo p : runtimeState.getProcesses()) { - aliveNodes.add(p.getNodeId()); - } - - List<String> validNodeIds = new ArrayList<String>(); - for (Node node : asterixInstance.getCluster().getNode()) { - validNodeIds.add(node.getId()); - } - List<Pattern> ncKillPatterns = new ArrayList<Pattern>(); - for (String nodeId : nodesToStop) { - if (!nodeId.contains(nodeId)) { - throw new InstallerException("Invalid nodeId: " + nodeId); - } - if (!aliveNodes.contains(nodeId)) { - throw new InstallerException("Node: " + nodeId + " is not alive"); - } - ncKillPatterns.add(PatternCreator.INSTANCE.createNCStopPattern(nodeId, asterixInstanceName + "_" + nodeId)); - } - - try { - client.submit(new Patterns(ncKillPatterns)); - } catch (Exception e) { - // processes are already dead - LOGGER.debug("Attempt to kill non-existing processess"); - } - - asterixInstance.setStateChangeTimestamp(new Date()); - ServiceProvider.INSTANCE.getLookupService().updateAsterixInstance(asterixInstance); - LOGGER.info("Stopped nodes " + ((StopNodeConfig) config).nodeList + " serving Asterix instance: " - + asterixInstanceName); - } - - @Override - protected CommandConfig getCommandConfig() { - return new StopNodeConfig(); - } - - @Override - protected String getUsageDescription() { - return "\nStops a specified set of ASTERIX nodes." + "\n\nAvailable arguments/options" - + "\n-n name of the ASTERIX instance. " - + "\n-nodes Comma separated list of nodes that need to be stopped. "; - - } -} - -class StopNodeConfig extends CommandConfig { - - @Option(name = "-n", required = true, usage = "Name of Asterix Instance") - public String name; - - @Option(name = "-nodes", required = true, usage = "Comma separated list of nodes that need to be stopped") - public String nodeList; - -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/UninstallCommand.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/UninstallCommand.java b/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/UninstallCommand.java deleted file mode 100644 index 8199d4b..0000000 --- a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/UninstallCommand.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.asterix.installer.command; - -import org.kohsuke.args4j.Option; - -import org.apache.asterix.event.management.AsterixEventServiceClient; -import org.apache.asterix.event.model.AsterixInstance; -import org.apache.asterix.event.model.AsterixInstance.State; -import org.apache.asterix.event.schema.pattern.Patterns; -import org.apache.asterix.event.service.AsterixEventService; -import org.apache.asterix.event.service.AsterixEventServiceUtil; -import org.apache.asterix.event.service.ILookupService; -import org.apache.asterix.event.service.ServiceProvider; -import org.apache.asterix.event.util.PatternCreator; -import org.apache.asterix.installer.driver.InstallerDriver; - -public class UninstallCommand extends AbstractCommand { - - @Override - protected void execCommand() throws Exception { - InstallerDriver.initConfig(true); - UninstallConfig uninstallConfig = ((UninstallConfig) config); - String instanceName = uninstallConfig.name; - AsterixEventServiceUtil.validateAsterixInstanceExists(instanceName, State.INACTIVE); - ILookupService lookupService = ServiceProvider.INSTANCE.getLookupService(); - AsterixInstance instance = lookupService.getAsterixInstance(instanceName); - PatternCreator pc = PatternCreator.INSTANCE; - Patterns patterns = pc.getLibraryUninstallPattern(instance, uninstallConfig.dataverseName, - uninstallConfig.libraryName); - AsterixEventServiceClient client = AsterixEventService.getAsterixEventServiceClient(instance.getCluster()); - client.submit(patterns); - LOGGER.info("Uninstalled library " + uninstallConfig.libraryName); - } - - @Override - protected CommandConfig getCommandConfig() { - return new UninstallConfig(); - } - - @Override - protected String getUsageDescription() { - return "Uninstalls a library from an asterix instance." + "\n" + "Arguments/Options\n" - + "-n Name of Asterix Instance\n" - + "-d Name of the dataverse under which the library will be installed\n" + "-l Name of the library\n" - + "-l Name of the library"; - } - -} - -class UninstallConfig extends CommandConfig { - - @Option(name = "-n", required = true, usage = "Name of Asterix Instance") - public String name; - - @Option(name = "-d", required = true, usage = "Name of the dataverse under which the library will be installed") - public String dataverseName; - - @Option(name = "-l", required = true, usage = "Name of the library") - public String libraryName; - -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/ValidateCommand.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/ValidateCommand.java b/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/ValidateCommand.java deleted file mode 100644 index 3e079bd..0000000 --- a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/ValidateCommand.java +++ /dev/null @@ -1,311 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.asterix.installer.command; - -import java.io.File; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import javax.xml.bind.JAXBContext; -import javax.xml.bind.Unmarshaller; - -import org.apache.asterix.event.management.EventUtil; -import org.apache.asterix.event.schema.cluster.Cluster; -import org.apache.asterix.event.schema.cluster.MasterNode; -import org.apache.asterix.event.schema.cluster.Node; -import org.apache.asterix.event.service.AsterixEventServiceUtil; -import org.apache.asterix.installer.driver.InstallerDriver; -import org.apache.asterix.installer.schema.conf.Configuration; -import org.apache.asterix.installer.schema.conf.Zookeeper; -import org.kohsuke.args4j.Option; - -public class ValidateCommand extends AbstractCommand { - - private static final String OK = " [" + "OK" + "]"; - private static final String ERROR = " [" + "ERROR" + "]"; - private static final String WARNING = " [" + "WARNING" + "]"; - - @Override - protected void execCommand() throws Exception { - ValidateConfig vConfig = (ValidateConfig) config; - logValidationResult("Environment", validateEnvironment()); - if (((ValidateConfig) config).cluster != null) { - logValidationResult("Cluster configuration", validateCluster(vConfig.cluster)); - } else { - logValidationResult("Managix Configuration", validateConfiguration()); - } - } - - private void logValidationResult(String prefix, boolean isValid) { - if (!isValid) { - LOGGER.fatal(prefix + ERROR); - } else { - LOGGER.info(prefix + OK); - } - } - - @Override - protected CommandConfig getCommandConfig() { - return new ValidateConfig(); - } - - @Override - protected String getUsageDescription() { - return "\nValidate the installer's configuration or a cluster configuration" + "\nUsage" - + "\nFor validating the installer configuration" + "\nuse managix validate" - + "\n\nFor validating a cluster configuration" - + "\nuse managix validate -c <path to the cluster configuration file>"; - } - - public boolean validateEnvironment() throws Exception { - boolean valid = true; - File home = new File(InstallerDriver.getManagixHome()); - if (!home.exists()) { - valid = false; - LOGGER.fatal(InstallerDriver.ENV_MANAGIX_HOME + ": " + home.getAbsolutePath() + " does not exist!" + ERROR); - } - return valid; - - } - - public boolean validateCluster(String clusterPath) throws Exception { - boolean valid = true; - Cluster cluster = null; - File f = new File(clusterPath); - List<String> ipAddresses = new ArrayList<String>(); - if (!f.exists() || !f.isFile()) { - LOGGER.error(" Invalid path " + f.getAbsolutePath() + ERROR); - valid = false; - } else { - cluster = EventUtil.getCluster(clusterPath); - valid = valid & validateClusterProperties(cluster); - - Set<String> servers = new HashSet<String>(); - Set<String> serverIds = new HashSet<String>(); - servers.add(cluster.getMasterNode().getClusterIp()); - serverIds.add(cluster.getMasterNode().getId()); - - MasterNode masterNode = cluster.getMasterNode(); - Node master = new Node(masterNode.getId(), masterNode.getClusterIp(), masterNode.getJavaHome(), - masterNode.getLogDir(), null, null, null, null, null); - ipAddresses.add(masterNode.getClusterIp()); - - valid = valid & validateNodeConfiguration(master, cluster); - - for (Node node : cluster.getNode()) { - servers.add(node.getClusterIp()); - if (serverIds.contains(node.getId())) { - valid = false; - LOGGER.error("Duplicate node id :" + node.getId() + ERROR); - } else { - valid = valid & validateNodeConfiguration(node, cluster); - if (!ipAddresses.contains(node.getClusterIp())) { - ipAddresses.add(node.getClusterIp()); - } - } - } - - valid = valid & validateReplicationProperties(cluster); - } - - if (valid) { - String username = cluster.getUsername(); - if (username == null) { - username = System.getProperty("user.name"); - } - valid = checkPasswordLessSSHLogin(username, ipAddresses); - } - return valid; - } - - private boolean checkPasswordLessSSHLogin(String username, List<String> ipAddresses) throws Exception { - String script = InstallerDriver.getManagixHome() + File.separator + InstallerDriver.MANAGIX_INTERNAL_DIR - + File.separator + "scripts" + File.separator + "validate_ssh.sh"; - List<String> args = ipAddresses; - args.add(0, username); - String output = AsterixEventServiceUtil.executeLocalScript(script, args); - ipAddresses.remove(0); - for (String line : output.split("\n")) { - ipAddresses.remove(line); - } - if (ipAddresses.size() > 0) { - LOGGER.error(" Password-less SSH (from user account: " + username + " )" - + " not configured for the following hosts"); - for (String failedIp : ipAddresses) { - System.out.println(failedIp); - } - return false; - } - return true; - } - - private boolean validateClusterProperties(Cluster cluster) { - List<String> tempDirs = new ArrayList<String>(); - if (cluster.getLogDir() != null && checkTemporaryPath(cluster.getLogDir())) { - tempDirs.add("Log directory: " + cluster.getLogDir()); - } - if (cluster.getIodevices() != null && checkTemporaryPath(cluster.getIodevices())) { - tempDirs.add("IO Device: " + cluster.getIodevices()); - } - - if (tempDirs.size() > 0) { - StringBuffer msg = new StringBuffer(); - msg.append("The following paths are subject to be cleaned up by OS"); - for (String tempDir : tempDirs) { - msg.append("\n" + tempDir + WARNING); - } - LOGGER.warn(msg); - } - - if (cluster.getStore() == null || cluster.getStore().length() == 0) { - LOGGER.fatal("store not defined at cluster" + ERROR); - return false; - } - return true; - } - - private boolean validateNodeConfiguration(Node node, Cluster cluster) { - boolean valid = true; - if (node.getJavaHome() == null || node.getJavaHome().length() == 0) { - if (cluster.getJavaHome() == null || cluster.getJavaHome().length() == 0) { - valid = false; - LOGGER.fatal("java_home not defined at cluster/node level for node: " + node.getId() + ERROR); - } - } - - if (node.getLogDir() == null || node.getLogDir().length() == 0) { - if (cluster.getLogDir() == null || cluster.getLogDir().length() == 0) { - valid = false; - LOGGER.fatal("log_dir not defined at cluster/node level for node: " + node.getId() + ERROR); - } - } - - if (node.getTxnLogDir() == null || node.getTxnLogDir().length() == 0) { - if (cluster.getTxnLogDir() == null || cluster.getTxnLogDir().length() == 0) { - valid = false; - LOGGER.fatal("txn_log_dir not defined at cluster/node level for node: " + node.getId() + ERROR); - } - } - - if (node.getIodevices() == null || node.getIodevices().length() == 0) { - if (!cluster.getMasterNode().getId().equals(node.getId()) - && (cluster.getIodevices() == null || cluster.getIodevices().length() == 0)) { - valid = false; - LOGGER.fatal("iodevice(s) not defined at cluster/node level for node: " + node.getId() + ERROR); - } - } - - return valid; - } - - private boolean checkTemporaryPath(String logdir) { - return logdir.startsWith(System.getProperty("java.io.tmpdir")); - } - - public boolean validateConfiguration() throws Exception { - String managixHome = System.getenv(InstallerDriver.ENV_MANAGIX_HOME); - File configFile = new File(managixHome + File.separator + InstallerDriver.MANAGIX_CONF_XML); - JAXBContext configCtx = JAXBContext.newInstance(Configuration.class); - Unmarshaller unmarshaller = configCtx.createUnmarshaller(); - Configuration conf = (Configuration) unmarshaller.unmarshal(configFile); - return validateZookeeperConfiguration(conf); - } - - private boolean validateZookeeperConfiguration(Configuration conf) throws Exception { - boolean valid = true; - Zookeeper zk = conf.getZookeeper(); - - if (zk.getHomeDir() == null || zk.getHomeDir().length() == 0) { - valid = false; - LOGGER.fatal("Zookeeper home dir not configured" + ERROR); - } else if (checkTemporaryPath(zk.getHomeDir())) { - LOGGER.warn("Zookeeper home dir is subject to be cleaned up by OS" + WARNING); - } - - if (zk.getServers().getServer() == null || zk.getServers().getServer().isEmpty()) { - valid = false; - LOGGER.fatal("Zookeeper servers not configured" + ERROR); - } - - if (zk.getServers().getJavaHome() == null || zk.getServers().getJavaHome().length() == 0) { - valid = false; - LOGGER.fatal("Java home not set for Zookeeper server in " + InstallerDriver.getManagixHome() - + File.separator + InstallerDriver.MANAGIX_CONF_XML); - } - - if (valid) { - valid = valid & checkPasswordLessSSHLogin(System.getProperty("user.name"), zk.getServers().getServer()); - } - - return valid; - } - - private boolean validateReplicationProperties(Cluster cluster) { - boolean valid = true; - - //if replication is disabled, no need to validate the settings - if (cluster.getHighAvailability() != null && cluster.getHighAvailability().getDataReplication() != null) { - if (cluster.getHighAvailability().getDataReplication().getReplicationPort() == null || cluster - .getHighAvailability().getDataReplication().getReplicationPort().toString().length() == 0) { - valid = false; - LOGGER.fatal("Replication data port not defined for data repliaction. " + ERROR); - } - - if (cluster.getHighAvailability().getDataReplication().getReplicationTimeOut() == null || String - .valueOf(cluster.getHighAvailability().getDataReplication().getReplicationTimeOut().intValue()) - .length() == 0) { - LOGGER.warn("Replication maximum wait time not defined. Using default value (60 seconds) " + WARNING); - } - - //validate all nodes have the same number of io devices - int numOfIODevices = 0; - Set<Integer> ioDevicesCount = new HashSet<Integer>(); - for (int i = 0; i < cluster.getNode().size(); i++) { - Node node = cluster.getNode().get(i); - - if (node.getIodevices() != null) { - numOfIODevices = node.getIodevices().length() - node.getIodevices().replace(",", "").length(); - } else { - numOfIODevices = cluster.getIodevices().length() - cluster.getIodevices().replace(",", "").length(); - } - - ioDevicesCount.add(numOfIODevices); - - if (ioDevicesCount.size() > 1) { - valid = false; - LOGGER.fatal("Replication requires all nodes to have the same number of IO devices." + ERROR); - break; - } - } - - } - - return valid; - } - -} - -class ValidateConfig extends CommandConfig { - - @Option(name = "-c", required = false, usage = "Path to the cluster configuration xml") - public String cluster; - -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/5dcf139e/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/VersionCommand.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/VersionCommand.java b/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/VersionCommand.java deleted file mode 100644 index b604dc0..0000000 --- a/asterixdb/asterix-installer/src/main/java/org/apache/asterix/installer/command/VersionCommand.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.asterix.installer.command; - -import java.io.File; - -import org.apache.asterix.event.service.AsterixEventService; -import org.apache.asterix.installer.driver.InstallerDriver; - -public class VersionCommand extends AbstractCommand { - - @Override - protected void execCommand() throws Exception { - InstallerDriver.initConfig(false); - String asterixZipName = AsterixEventService.getAsterixZip().substring( - AsterixEventService.getAsterixZip().lastIndexOf(File.separator) + 1); - String asterixVersion = asterixZipName.substring("asterix-server-".length(), - asterixZipName.indexOf("-binary-assembly")); - LOGGER.info("Asterix/Managix version " + asterixVersion); - } - - @Override - protected CommandConfig getCommandConfig() { - return new VersionConfig(); - } - - @Override - protected String getUsageDescription() { - return "Provides version of Managix/Asterix"; - } - -} - -class VersionConfig extends CommandConfig { - -}
