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.HashMap;
024: import java.util.StringTokenizer;
025:
026: import org.continuent.sequoia.common.i18n.ConsoleTranslate;
027: import org.continuent.sequoia.console.text.module.VirtualDatabaseAdmin;
028:
029: /**
030: * This class defines a Replicate
031: *
032: * @author <a href="mailto:Nicolas.Modrzyk@inria.fr">Nicolas Modrzyk </a>
033: * @version 1.0
034: */
035: public class Replicate extends AbstractAdminCommand {
036:
037: /**
038: * Creates a new <code>Replicate.java</code> object
039: *
040: * @param module admin module
041: */
042: public Replicate(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: StringTokenizer st = new StringTokenizer(commandText, "; "); //$NON-NLS-1$
051: if (st.countTokens() < 3) {
052: console.printError(getUsage());
053: return;
054: }
055:
056: String backend1 = st.nextToken();
057: String backend2 = st.nextToken();
058: String url = st.nextToken();
059:
060: HashMap parameters = new HashMap();
061: parameters.put("url", url); //$NON-NLS-1$
062: StringTokenizer st2;
063: while (st.hasMoreTokens()) {
064: st2 = new StringTokenizer(st.nextToken(), "="); //$NON-NLS-1$
065: if (st2.countTokens() == 2) {
066: String param = st2.nextToken();
067: String value = st2.nextToken();
068: parameters.put(param, value);
069: console.printInfo(ConsoleTranslate.get(
070: "admin.command.replicate.param", //$NON-NLS-1$
071: new String[] { param, value }));
072: }
073: }
074:
075: console.printInfo(ConsoleTranslate.get(
076: "admin.command.replicate.echo", //$NON-NLS-1$
077: new String[] { backend1, backend2, url }));
078: jmxClient.getVirtualDatabaseProxy(dbName, user, password)
079: .replicateBackend(backend1, backend2, parameters);
080:
081: }
082:
083: /**
084: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandParameters()
085: */
086: public String getCommandParameters() {
087: return ConsoleTranslate.get("admin.command.replicate.params"); //$NON-NLS-1$
088: }
089:
090: /**
091: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandName()
092: */
093: public String getCommandName() {
094: return "clone backend config"; //$NON-NLS-1$
095: }
096:
097: /**
098: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandDescription()
099: */
100: public String getCommandDescription() {
101: return ConsoleTranslate
102: .get("admin.command.replicate.description"); //$NON-NLS-1$
103: }
104:
105: }
|