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.controller;
022:
023: import java.util.StringTokenizer;
024:
025: import org.continuent.sequoia.common.i18n.ConsoleTranslate;
026: import org.continuent.sequoia.common.util.Constants;
027: import org.continuent.sequoia.console.text.commands.ConsoleCommand;
028: import org.continuent.sequoia.console.text.module.AbstractConsoleModule;
029:
030: /**
031: * Drop a virtual database from a controller command
032: *
033: * @author <a href="mailto:Nicolas.Modrzyk@inria.fr">Nicolas Modrzyk </a>
034: * @version 1.0
035: */
036: public class ShutdownVirtualDatabase extends ConsoleCommand {
037:
038: /**
039: * Creates a new <code>Load.java</code> object
040: *
041: * @param module the command is attached to
042: */
043: public ShutdownVirtualDatabase(AbstractConsoleModule 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: checkJmxConnectionToController();
052: StringTokenizer st = new StringTokenizer(commandText.trim());
053:
054: String database = null;
055: int mode = Constants.SHUTDOWN_SAFE;
056: try {
057: database = st.nextToken();
058: String modeStr = st.nextToken();
059: mode = Integer.parseInt(modeStr);
060: } catch (Exception e) {
061: }
062:
063: if (database == null || database.length() == 0) {
064: console
065: .printError(ConsoleTranslate
066: .get("controller.command.shutdown.virtualdatabase.null")); //$NON-NLS-1$
067: console.printError(getUsage());
068: return;
069: }
070:
071: String user = console.readLine(ConsoleTranslate
072: .get("admin.login.user")); //$NON-NLS-1$
073: if (user == null)
074: return;
075:
076: String password = console.readPassword(ConsoleTranslate
077: .get("admin.login.password")); //$NON-NLS-1$
078: if (password == null)
079: return;
080:
081: console
082: .printInfo(ConsoleTranslate
083: .get(
084: "controller.command.shutdown.virtualdatabase.echo", database)); //$NON-NLS-1$
085:
086: jmxClient.getVirtualDatabaseProxy(database, user, password)
087: .shutdown(mode);
088:
089: console
090: .printInfo(ConsoleTranslate
091: .get(
092: "controller.command.shutdown.virtualdatabase.success", database)); //$NON-NLS-1$
093: }
094:
095: /**
096: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandName()
097: */
098: public String getCommandName() {
099: return "shutdown virtualdatabase"; //$NON-NLS-1$
100: }
101:
102: /**
103: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandParameters()
104: */
105: public String getCommandParameters() {
106: return ConsoleTranslate
107: .get("controller.command.shutdown.virtualdatabase.params"); //$NON-NLS-1$
108: }
109:
110: /**
111: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandDescription()
112: */
113: public String getCommandDescription() {
114: return ConsoleTranslate
115: .get("controller.command.shutdown.virtualdatabase.description"); //$NON-NLS-1$
116: }
117:
118: }
|