001: /**
002: * Sequoia: Database clustering technology.
003: * Copyright (C) 2002-2004 French National Institute For Research In Computer
004: * Science And Control (INRIA).
005: * Contact: sequoia@continuent.org
006: *
007: * Licensed under the Apache License, Version 2.0 (the "License");
008: * you may not use this file except in compliance with the License.
009: * You may obtain a copy of the License at
010: *
011: * http://www.apache.org/licenses/LICENSE-2.0
012: *
013: * Unless required by applicable law or agreed to in writing, software
014: * distributed under the License is distributed on an "AS IS" BASIS,
015: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016: * See the License for the specific language governing permissions and
017: * limitations under the License.
018: *
019: * Initial developer(s): Nicolas Modrzyk
020: * Contributor(s): ______________________.
021: */package org.continuent.sequoia.console.text.commands.dbadmin;
022:
023: import java.util.Iterator;
024: import java.util.List;
025: import java.util.StringTokenizer;
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 a Disable
033: *
034: * @author <a href="mailto:Nicolas.Modrzyk@inria.fr">Nicolas Modrzyk </a>
035: * @version 1.0
036: */
037: public class Disable extends AbstractAdminCommand {
038: /**
039: * Creates a new <code>Disable.java</code> object
040: *
041: * @param module the command is attached to
042: */
043: public Disable(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: String backendName = null;
052:
053: StringTokenizer st = new StringTokenizer(commandText);
054: if (st.countTokens() != 1) {
055: console.printError(getUsage());
056: return;
057: }
058: try {
059: backendName = st.nextToken();
060: } catch (Exception e) {
061: console.printError(getUsage());
062: return;
063: }
064:
065: VirtualDatabaseMBean vjdc = jmxClient.getVirtualDatabaseProxy(
066: dbName, user, password);
067: if ("*".equals(backendName)) //$NON-NLS-1$
068: {
069: console
070: .printInfo(ConsoleTranslate
071: .get("admin.command.disable.backend.all.with.checkpoint")); //$NON-NLS-1$
072: List backendNames = vjdc.getAllBackendNames();
073: for (Iterator iter = backendNames.iterator(); iter
074: .hasNext();) {
075: String backend = (String) iter.next();
076: vjdc.disableBackendWithCheckpoint(backend);
077: }
078: } else {
079: vjdc.disableBackendWithCheckpoint(backendName);
080: console
081: .printInfo(ConsoleTranslate
082: .get(
083: "admin.command.disable.backend.with.checkpoint", backendName)); //$NON-NLS-1$
084: }
085: }
086:
087: /**
088: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandParameters()
089: */
090: public String getCommandParameters() {
091: return ConsoleTranslate
092: .get("admin.command.disable.backend.params"); //$NON-NLS-1$
093: }
094:
095: /**
096: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandName()
097: */
098: public String getCommandName() {
099: return "disable"; //$NON-NLS-1$
100: }
101:
102: /**
103: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandDescription()
104: */
105: public String getCommandDescription() {
106: return ConsoleTranslate
107: .get("admin.command.disable.backend.description"); //$NON-NLS-1$
108: }
109:
110: }
|