KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > continuent > sequoia > console > text > commands > dbadmin > Replicate


1 /**
2  * Sequoia: Database clustering technology.
3  * Copyright (C) 2002-2004 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Contact: sequoia@continuent.org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  * Initial developer(s): Nicolas Modrzyk
20  * Contributor(s): ______________________.
21  */

22
23 package org.continuent.sequoia.console.text.commands.dbadmin;
24
25 import java.util.HashMap JavaDoc;
26 import java.util.StringTokenizer JavaDoc;
27
28 import org.continuent.sequoia.common.i18n.ConsoleTranslate;
29 import org.continuent.sequoia.console.text.module.VirtualDatabaseAdmin;
30
31 /**
32  * This class defines a Replicate
33  *
34  * @author <a HREF="mailto:Nicolas.Modrzyk@inria.fr">Nicolas Modrzyk </a>
35  * @version 1.0
36  */

37 public class Replicate extends AbstractAdminCommand
38 {
39
40   /**
41    * Creates a new <code>Replicate.java</code> object
42    *
43    * @param module admin module
44    */

45   public Replicate(VirtualDatabaseAdmin module)
46   {
47     super(module);
48   }
49
50   /**
51    * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#parse(java.lang.String)
52    */

53   public void parse(String JavaDoc commandText) throws Exception JavaDoc
54   {
55     StringTokenizer JavaDoc st = new StringTokenizer JavaDoc(commandText, "; "); //$NON-NLS-1$
56
if (st.countTokens() < 3)
57     {
58       console.printError(getUsage());
59       return;
60     }
61     
62     String JavaDoc backend1 = st.nextToken();
63     String JavaDoc backend2 = st.nextToken();
64     String JavaDoc url = st.nextToken();
65
66     HashMap JavaDoc parameters = new HashMap JavaDoc();
67     parameters.put("url",url); //$NON-NLS-1$
68
StringTokenizer JavaDoc st2;
69     while (st.hasMoreTokens())
70     {
71       st2 = new StringTokenizer JavaDoc(st.nextToken(), "="); //$NON-NLS-1$
72
if (st2.countTokens() == 2)
73       {
74         String JavaDoc param = st2.nextToken();
75         String JavaDoc value = st2.nextToken();
76         parameters.put(param, value);
77         console.printInfo(ConsoleTranslate.get("admin.command.replicate.param", //$NON-NLS-1$
78
new String JavaDoc[]{param, value}));
79       }
80     }
81
82     console.printInfo(ConsoleTranslate.get("admin.command.replicate.echo", //$NON-NLS-1$
83
new String JavaDoc[]{backend1, backend2, url}));
84     jmxClient.getVirtualDatabaseProxy(dbName, user, password).replicateBackend(
85         backend1, backend2, parameters);
86
87   }
88
89   /**
90    * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandParameters()
91    */

92   public String JavaDoc getCommandParameters()
93   {
94     return ConsoleTranslate.get("admin.command.replicate.params"); //$NON-NLS-1$
95
}
96
97   /**
98    * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandName()
99    */

100   public String JavaDoc getCommandName()
101   {
102     return "clone backend config"; //$NON-NLS-1$
103
}
104
105   /**
106    * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandDescription()
107    */

108   public String JavaDoc getCommandDescription()
109   {
110     return ConsoleTranslate.get("admin.command.replicate.description"); //$NON-NLS-1$
111
}
112
113 }
Popular Tags