KickJava   Java API By Example, From Geeks To Geeks.

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


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): Jeff Mesnil.
19  * Contributor(s): ______________________.
20  */

21
22 package org.continuent.sequoia.console.text.commands.dbadmin;
23
24 import org.continuent.sequoia.common.i18n.ConsoleTranslate;
25 import org.continuent.sequoia.common.jmx.management.DumpInfo;
26 import org.continuent.sequoia.common.jmx.mbeans.VirtualDatabaseMBean;
27 import org.continuent.sequoia.console.text.module.VirtualDatabaseAdmin;
28
29 /**
30  * This class defines the command used to purge the recovery log up to a
31  * checkpoint associated with a specified dump
32  */

33 public class PurgeLogUpToDump extends AbstractAdminCommand
34 {
35   /**
36    * Creates a new <code>PurgeLogUpToDump</code> object
37    *
38    * @param module the command is attached to
39    */

40   public PurgeLogUpToDump(VirtualDatabaseAdmin module)
41   {
42     super(module);
43   }
44
45   /**
46    * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#parse(java.lang.String)
47    */

48   public void parse(String JavaDoc commandText) throws Exception JavaDoc
49   {
50     String JavaDoc dumpName = commandText.trim();
51
52     if ("".equals(dumpName)) //$NON-NLS-1$
53
{
54       console.printError(getUsage());
55       return;
56     }
57
58     VirtualDatabaseMBean vdb = jmxClient.getVirtualDatabaseProxy(dbName, user,
59         password);
60     DumpInfo[] dumpInfos = vdb.getAvailableDumps();
61     DumpInfo foundDump = null;
62     for (int i = 0; i < dumpInfos.length; i++)
63     {
64       DumpInfo dumpInfo = dumpInfos[i];
65       if (dumpInfo.getDumpName().equals(dumpName))
66       {
67         foundDump = dumpInfo;
68         break;
69       }
70     }
71     if (foundDump == null)
72     {
73       console.printError(ConsoleTranslate.get(
74           "admin.command.purgeLogUpToDump.nodump", dumpName)); //$NON-NLS-1$
75
return;
76     }
77     vdb.deleteLogUpToCheckpoint(foundDump.getCheckpointName());
78   }
79
80   /**
81    * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandName()
82    */

83   public String JavaDoc getCommandName()
84   {
85     return "purge log"; //$NON-NLS-1$
86
}
87
88   /**
89    * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandParameters()
90    */

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

99   public String JavaDoc getCommandDescription()
100   {
101     return ConsoleTranslate.get("admin.command.purgeLogUpToDump.description"); //$NON-NLS-1$
102
}
103
104 }
Popular Tags