KickJava   Java API By Example, From Geeks To Geeks.

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


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

21
22 package org.continuent.sequoia.console.text.commands.dbadmin;
23
24 import java.util.List JavaDoc;
25
26 import org.continuent.sequoia.common.i18n.ConsoleTranslate;
27 import org.continuent.sequoia.common.jmx.mbeans.VirtualDatabaseMBean;
28 import org.continuent.sequoia.console.text.module.VirtualDatabaseAdmin;
29
30 /**
31  * This class defines the ForceDisable command that forces the disabling of a
32  * backend without setting a checkpoint.
33  *
34  * @author <a HREF="mailto:emmanuel.cecchet@emicnetworks.com">Emmanuel Cecchet
35  * </a>
36  * @version 1.0
37  */

38 public class ForceDisable extends AbstractAdminCommand
39 {
40   /**
41    * Creates a new <code>Disable.java</code> object
42    *
43    * @param module the command is attached to
44    */

45   public ForceDisable(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     if (commandText.trim().length() == 0)
56     {
57       console.printError(getUsage());
58       return;
59     }
60
61     String JavaDoc[] backendNames;
62     VirtualDatabaseMBean vjdc = jmxClient.getVirtualDatabaseProxy(dbName, user,
63         password);
64     
65     if (("*").equals(commandText.trim())) //$NON-NLS-1$
66
{
67       List JavaDoc backendNamesList = vjdc.getAllBackendNames();
68       backendNames = (String JavaDoc[]) backendNamesList
69           .toArray(new String JavaDoc[backendNamesList.size()]);
70     }
71     else
72     {
73       String JavaDoc backendName = commandText.trim();
74       backendNames = new String JavaDoc[]{backendName};
75     }
76     for (int i = 0; i < backendNames.length; i++)
77     {
78       String JavaDoc backendName = backendNames[i];
79       vjdc.forceDisableBackend(backendName);
80       console.printInfo(ConsoleTranslate.get(
81           "admin.command.force.disable.backend", backendName)); //$NON-NLS-1$
82
}
83   }
84
85   /**
86    * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandDescription()
87    */

88   public String JavaDoc getCommandDescription()
89   {
90     return ConsoleTranslate.get("admin.command.force.disable.description"); //$NON-NLS-1$
91
}
92
93   /**
94    * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandName()
95    */

96   public String JavaDoc getCommandName()
97   {
98     return "force disable"; //$NON-NLS-1$
99
}
100
101   /**
102    * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandParameters()
103    */

104   public String JavaDoc getCommandParameters()
105   {
106     return ConsoleTranslate.get("admin.command.force.disable.params"); //$NON-NLS-1$
107
}
108
109 }
110
Popular Tags