KickJava   Java API By Example, From Geeks To Geeks.

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


1 /**
2  * Sequoia: Database clustering technology.
3  * Copyright (C) 2006 Continuent.
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): Gilles Rayrat.
19  * Contributor(s): ______________________.
20  */

21
22 package org.continuent.sequoia.console.text.commands.dbadmin;
23
24 import java.util.StringTokenizer JavaDoc;
25
26 import org.continuent.sequoia.common.i18n.ConsoleTranslate;
27 import org.continuent.sequoia.common.jmx.mbeans.AbstractSchedulerControlMBean;
28 import org.continuent.sequoia.console.text.module.VirtualDatabaseAdmin;
29
30 /**
31  * This class defines the command used to dump a given scheduler queues
32  */

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

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

49   public void parse(String JavaDoc commandText) throws Exception JavaDoc
50   {
51     StringTokenizer JavaDoc st = new StringTokenizer JavaDoc(commandText.trim());
52     if (st.countTokens() != 0)
53     {
54       console.printError(getUsage());
55       return;
56     }
57
58     AbstractSchedulerControlMBean ascMbean = jmxClient.getAbstractScheduler(
59         dbName, user, password);
60     long[] atids = ascMbean.listActiveTransactionIds();
61     StringBuffer JavaDoc disp = new StringBuffer JavaDoc();
62     disp.append(ConsoleTranslate.get("DumpSchedulerQueues.activeTransactions",
63         atids.length));
64     for (int i = 0; i < atids.length; i++)
65     {
66       disp.append(' ');
67       disp.append(atids[i]);
68     }
69     disp.append('\n');
70     long[] prids = ascMbean.listPendingReadRequestIds();
71     disp.append(ConsoleTranslate.get("DumpSchedulerQueues.pendingReads",
72         prids.length));
73     for (int i = 0; i < prids.length; i++)
74     {
75       disp.append(' ');
76       disp.append(prids[i]);
77     }
78     disp.append('\n');
79     long[] pwids = ascMbean.listPendingWriteRequestIds();
80     disp.append(ConsoleTranslate.get("DumpSchedulerQueues.pendingWrites",
81         pwids.length));
82     for (int i = 0; i < pwids.length; i++)
83     {
84       disp.append(' ');
85       disp.append(pwids[i]);
86     }
87     console.println(disp.toString());
88   }
89
90   /**
91    * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandName()
92    */

93   public String JavaDoc getCommandName()
94   {
95     return "dump scheduler queues"; //$NON-NLS-1$
96
}
97
98   /**
99    * @see org.continuent.sequoia.console.text.commands.ConsoleCommand#getCommandParameters()
100    */

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

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