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