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 ForceEnable command that forces the enabling of a
030: * backend without checkpoint checking.
031: *
032: * @author <a href="mailto:emmanuel.cecchet@emicnetworks.com">Emmanuel Cecchet
033: * </a>
034: * @version 1.0
035: */
036: public class ForceEnable extends AbstractAdminCommand {
037:
038: /**
039: * Creates a new <code>ForceEnableEnable</code> object
040: *
041: * @param module the command is attached to
042: */
043: public ForceEnable(VirtualDatabaseAdmin module) {
044: super (module);
045: }
046:
047: /**
048: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#parse(java.lang.String)
049: */
050: public void parse(String commandText) throws Exception {
051:
052: if (commandText.trim().length() == 0) {
053: console.printError(getUsage());
054: return;
055: }
056:
057: String[] backendNames;
058: VirtualDatabaseMBean vjdc = jmxClient.getVirtualDatabaseProxy(
059: dbName, user, password);
060:
061: if (("*").equals(commandText.trim())) //$NON-NLS-1$
062: {
063: List backendNamesList = vjdc.getAllBackendNames();
064: backendNames = (String[]) backendNamesList
065: .toArray(new String[backendNamesList.size()]);
066: } else {
067: String backendName = commandText.trim();
068: backendNames = new String[] { backendName };
069: }
070: for (int i = 0; i < backendNames.length; i++) {
071: String backendName = backendNames[i];
072: console.printInfo(ConsoleTranslate.get(
073: "admin.command.force.enable.backend", backendName)); //$NON-NLS-1$
074: vjdc.forceEnableBackend(backendName);
075: }
076: }
077:
078: /**
079: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandName()
080: */
081: public String getCommandName() {
082: return "force enable"; //$NON-NLS-1$
083: }
084:
085: /**
086: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandDescription()
087: */
088: public String getCommandDescription() {
089: return ConsoleTranslate
090: .get("admin.command.force.enable.description"); //$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.enable.params"); //$NON-NLS-1$
099: }
100: }
|