01: /**
02: * Sequoia: Database clustering technology.
03: * Copyright (C) 2005 Emic Networks.
04: * Contact: sequoia@continuent.org
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
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: */package org.continuent.sequoia.console.text.commands.dbadmin;
21:
22: import org.continuent.sequoia.common.i18n.ConsoleTranslate;
23: import org.continuent.sequoia.common.jmx.management.DumpInfo;
24: import org.continuent.sequoia.common.jmx.mbeans.VirtualDatabaseMBean;
25: import org.continuent.sequoia.console.text.module.VirtualDatabaseAdmin;
26:
27: /**
28: * This class defines the command used to purge the recovery log up to a
29: * checkpoint associated with a specified dump
30: */
31: public class PurgeLogUpToDump extends AbstractAdminCommand {
32: /**
33: * Creates a new <code>PurgeLogUpToDump</code> object
34: *
35: * @param module the command is attached to
36: */
37: public PurgeLogUpToDump(VirtualDatabaseAdmin module) {
38: super (module);
39: }
40:
41: /**
42: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#parse(java.lang.String)
43: */
44: public void parse(String commandText) throws Exception {
45: String dumpName = commandText.trim();
46:
47: if ("".equals(dumpName)) //$NON-NLS-1$
48: {
49: console.printError(getUsage());
50: return;
51: }
52:
53: VirtualDatabaseMBean vdb = jmxClient.getVirtualDatabaseProxy(
54: dbName, user, password);
55: DumpInfo[] dumpInfos = vdb.getAvailableDumps();
56: DumpInfo foundDump = null;
57: for (int i = 0; i < dumpInfos.length; i++) {
58: DumpInfo dumpInfo = dumpInfos[i];
59: if (dumpInfo.getDumpName().equals(dumpName)) {
60: foundDump = dumpInfo;
61: break;
62: }
63: }
64: if (foundDump == null) {
65: console.printError(ConsoleTranslate.get(
66: "admin.command.purgeLogUpToDump.nodump", dumpName)); //$NON-NLS-1$
67: return;
68: }
69: vdb.deleteLogUpToCheckpoint(foundDump.getCheckpointName());
70: }
71:
72: /**
73: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandName()
74: */
75: public String getCommandName() {
76: return "purge log"; //$NON-NLS-1$
77: }
78:
79: /**
80: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandParameters()
81: */
82: public String getCommandParameters() {
83: return ConsoleTranslate
84: .get("admin.command.purgeLogUpToDump.params"); //$NON-NLS-1$
85: }
86:
87: /**
88: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandDescription()
89: */
90: public String getCommandDescription() {
91: return ConsoleTranslate
92: .get("admin.command.purgeLogUpToDump.description"); //$NON-NLS-1$
93: }
94:
95: }
|