01: /**
02: * Sequoia: Database clustering technology.
03: * Copyright (C) 2006 Continuent.
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): Gilles Rayrat.
19: * Contributor(s): ______________________.
20: */package org.continuent.sequoia.console.text.commands.dbadmin;
21:
22: import java.util.StringTokenizer;
23:
24: import org.continuent.sequoia.common.i18n.ConsoleTranslate;
25: import org.continuent.sequoia.common.jmx.mbeans.AbstractSchedulerControlMBean;
26: import org.continuent.sequoia.console.text.module.VirtualDatabaseAdmin;
27:
28: /**
29: * This class defines the command used to dump a given scheduler queues
30: */
31: public class DumpRequest extends AbstractAdminCommand {
32:
33: /**
34: * Creates a new <code>DumpRequest</code> object
35: *
36: * @param module the commands is attached to
37: */
38: public DumpRequest(VirtualDatabaseAdmin module) {
39: super (module);
40: }
41:
42: /**
43: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#parse(java.lang.String)
44: */
45: public void parse(String commandText) throws Exception {
46: // args: <vdb name> <request id>
47:
48: StringTokenizer st = new StringTokenizer(commandText.trim());
49: String rIdStr;
50: long requestId = 0;
51: if (st.countTokens() != 1) {
52: console.printError(getUsage());
53: return;
54: }
55:
56: rIdStr = st.nextToken();
57: try {
58: requestId = Long.valueOf(rIdStr).longValue();
59: } catch (NumberFormatException e) {
60: console.printError(ConsoleTranslate.get(
61: "DumpRequest.badId", rIdStr));
62: }
63: AbstractSchedulerControlMBean ascMbean = jmxClient
64: .getAbstractScheduler(dbName, user, password);
65:
66: console.println(ascMbean.dumpRequest(requestId));
67: }
68:
69: /**
70: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandName()
71: */
72: public String getCommandName() {
73: return "dump request"; //$NON-NLS-1$
74: }
75:
76: /**
77: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandParameters()
78: */
79: public String getCommandParameters() {
80: return ConsoleTranslate.get("DumpRequest.params"); //$NON-NLS-1$
81: }
82:
83: /**
84: * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandDescription()
85: */
86: public String getCommandDescription() {
87: return ConsoleTranslate.get("DumpRequest.description"); //$NON-NLS-1$
88: }
89: }
|