001: /**
002: * Sequoia: Database clustering technology.
003: * Copyright (C) 2005 Emic Networks.
004: * Contact: sequoia@continuent.org
005: *
006: * Licensed under the Apache License, Version 2.0 (the "License");
007: * you may not use this file except in compliance with the License.
008: * You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing, software
013: * distributed under the License is distributed on an "AS IS" BASIS,
014: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: *
018: * Initial developer(s): Emmanuel Cecchet.
019: * Contributor(s): ______________________.
020: */package org.continuent.sequoia.console.text.commands.dbadmin;
021:
022: import java.util.List;
023:
024: import org.continuent.sequoia.common.i18n.ConsoleTranslate;
025: import org.continuent.sequoia.common.jmx.mbeans.VirtualDatabaseMBean;
026: import org.continuent.sequoia.console.text.module.VirtualDatabaseAdmin;
027:
028: /**
029: * This class defines the ForceDisable command that forces the disabling of a
030: * backend without setting a checkpoint.
031: *
032: * @author <a href="mailto:emmanuel.cecchet@emicnetworks.com">Emmanuel Cecchet
033: * </a>
034: * @version 1.0
035: */
036: public class ForceDisable extends AbstractAdminCommand {
037: /**
038: * Creates a new <code>Disable.java</code> object
039: *
040: * @param module the command is attached to
041: */
042: public ForceDisable(VirtualDatabaseAdmin module) {
043: super (module);
044: }
045:
046: /**
047: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#parse(java.lang.String)
048: */
049: public void parse(String commandText) throws Exception {
050: if (commandText.trim().length() == 0) {
051: console.printError(getUsage());
052: return;
053: }
054:
055: String[] backendNames;
056: VirtualDatabaseMBean vjdc = jmxClient.getVirtualDatabaseProxy(
057: dbName, user, password);
058:
059: if (("*").equals(commandText.trim())) //$NON-NLS-1$
060: {
061: List backendNamesList = vjdc.getAllBackendNames();
062: backendNames = (String[]) backendNamesList
063: .toArray(new String[backendNamesList.size()]);
064: } else {
065: String backendName = commandText.trim();
066: backendNames = new String[] { backendName };
067: }
068: for (int i = 0; i < backendNames.length; i++) {
069: String backendName = backendNames[i];
070: vjdc.forceDisableBackend(backendName);
071: console
072: .printInfo(ConsoleTranslate
073: .get(
074: "admin.command.force.disable.backend", backendName)); //$NON-NLS-1$
075: }
076: }
077:
078: /**
079: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandDescription()
080: */
081: public String getCommandDescription() {
082: return ConsoleTranslate
083: .get("admin.command.force.disable.description"); //$NON-NLS-1$
084: }
085:
086: /**
087: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandName()
088: */
089: public String getCommandName() {
090: return "force disable"; //$NON-NLS-1$
091: }
092:
093: /**
094: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandParameters()
095: */
096: public String getCommandParameters() {
097: return ConsoleTranslate
098: .get("admin.command.force.disable.params"); //$NON-NLS-1$
099: }
100:
101: }
|