Source Code Cross Referenced for guiJCGridAdminStatus.java in  » Net » JCGrid » org » homedns » dade » jcgrid » gui » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » JCGrid » org.homedns.dade.jcgrid.gui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         Copyright (C) 2004 David Bucciarelli (davibu@interfree.it)
003:
004:         This program is free software; you can redistribute it and/or
005:         modify it under the terms of the GNU General Public License
006:         as published by the Free Software Foundation; either version 2
007:         of the License, or (at your option) any later version.
008:
009:         This program is distributed in the hope that it will be useful,
010:         but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012:         GNU General Public License for more details.
013:
014:         You should have received a copy of the GNU General Public License
015:         along with this program; if not, write to the Free Software
016:         Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
017:         */
018:
019:        package org.homedns.dade.jcgrid.gui;
020:
021:        import java.io.*;
022:        import java.text.*;
023:        import java.util.*;
024:        import java.awt.*;
025:        import javax.swing.*;
026:        import javax.swing.text.*;
027:        import javax.swing.table.*;
028:
029:        import org.apache.log4j.*;
030:
031:        import org.homedns.dade.jcgrid.*;
032:        import org.homedns.dade.jcgrid.admin.*;
033:        import org.homedns.dade.jcgrid.message.*;
034:
035:        public class guiJCGridAdminStatus extends javax.swing.JDialog {
036:            private final static String className = guiJCGridAdminStatus.class
037:                    .getName();
038:            private static Logger log = Logger.getLogger(className);
039:            private static Logger logDetail = Logger.getLogger("DETAIL."
040:                    + className);
041:
042:            private static final long serialVersionUID = 1L;
043:
044:            //------------------------- The JTable model -------------------------------
045:
046:            private class WorkerStatsModel extends AbstractTableModel {
047:                private static final long serialVersionUID = 1L;
048:
049:                private String[] columnNames = { "Node name", "Status",
050:                        "Working for", "Work started", "Units done", "Unit/sec" };
051:                private Object[][] data;
052:
053:                public WorkerStatsModel(Vector stats) {
054:                    data = new Object[stats.size()][columnNames.length];
055:
056:                    int j = 0;
057:                    for (Iterator i = stats.iterator(); i.hasNext();) {
058:                        WorkerStats ws = (WorkerStats) i.next();
059:
060:                        data[j][0] = ws.getName();
061:                        if (ws.getStatus() == WorkerStats.STATUS_BUSY) {
062:                            data[j][1] = "Busy";
063:                            data[j][2] = ws.getWorkingFor();
064:                            SimpleDateFormat sdf = new SimpleDateFormat(
065:                                    "yyyy/MM/dd HH:mm:ss");
066:                            data[j][3] = sdf.format(new Date(ws
067:                                    .getWorkingStarted()));
068:                        } else {
069:                            data[j][1] = "Free";
070:                            data[j][2] = "";
071:                            data[j][3] = "";
072:                        }
073:                        data[j][4] = Long.toString(ws.getUnitDone());
074:                        data[j][5] = Double.toString(ws.getUnitSec());
075:                        j++;
076:                    }
077:                }
078:
079:                public int getColumnCount() {
080:                    return columnNames.length;
081:                }
082:
083:                public int getRowCount() {
084:                    return data.length;
085:                }
086:
087:                public String getColumnName(int col) {
088:                    return columnNames[col];
089:                }
090:
091:                public Object getValueAt(int row, int col) {
092:                    return data[row][col];
093:                }
094:
095:                public Class getColumnClass(int c) {
096:                    if (data.length > 0)
097:                        return this .getValueAt(0, c).getClass();
098:                    else
099:                        return Object.class;
100:                }
101:            }
102:
103:            //--------------------------------------------------------------------------
104:
105:            private JTable tStats;
106:            private GridNodeAdminConfig adminConfig;
107:
108:            public guiJCGridAdminStatus(GridNodeAdminConfig cfg,
109:                    java.awt.Frame parent, boolean modal) {
110:                super (parent, modal);
111:
112:                initComponents();
113:
114:                tStats = null;
115:
116:                this .refreshInfo(cfg);
117:            }
118:
119:            public void refreshInfo(GridNodeAdminConfig cfg) {
120:                try {
121:                    adminConfig = cfg;
122:
123:                    lHostName.setText(adminConfig.getGridConfig()
124:                            .getServerAddress());
125:                    lHostPort.setText(Integer.toString(adminConfig
126:                            .getGridConfig().getServerAdminPort()));
127:                    lSessionName.setText(adminConfig.getSessionName());
128:
129:                    GridAdmin ga = new GridAdmin();
130:                    ga.setNodeConfig(adminConfig);
131:
132:                    ga.start();
133:
134:                    // Ping time
135:
136:                    long pingTime = ga.ping();
137:                    lPing.setText(pingTime + "ms");
138:
139:                    // Grid Stats
140:
141:                    GridStats gs = ga.getGridStats();
142:                    lWorkerCount.setText(Integer.toString(gs.getWorkerCount()));
143:                    lQueueSize.setText(Integer.toString(gs
144:                            .getWorkRequestsQueueSize()));
145:
146:                    // Worker stats
147:
148:                    Vector stats = ga.getWorkerStats();
149:
150:                    if (tStats != null)
151:                        sPane.remove(tStats);
152:
153:                    if (stats != null) {
154:                        WorkerStatsModel model = new WorkerStatsModel(stats);
155:                        tStats = new javax.swing.JTable();
156:                        tStats.setModel(model);
157:                        sPane.setViewportView(tStats);
158:
159:                        TableColumn column = null;
160:                        Component comp = null;
161:                        int headerWidth = 0;
162:                        int cellWidth = 0;
163:                        TableCellRenderer headerRenderer = tStats
164:                                .getTableHeader().getDefaultRenderer();
165:
166:                        for (int i = 0; i < model.getColumnCount(); i++) {
167:                            column = tStats.getColumnModel().getColumn(i);
168:
169:                            comp = headerRenderer
170:                                    .getTableCellRendererComponent(null, column
171:                                            .getHeaderValue(), false, false, 0,
172:                                            0);
173:                            headerWidth = comp.getPreferredSize().width;
174:
175:                            if (model.getRowCount() > 0) {
176:                                comp = tStats.getDefaultRenderer(
177:                                        model.getColumnClass(i))
178:                                        .getTableCellRendererComponent(tStats,
179:                                                model.getValueAt(0, i), false,
180:                                                false, 0, i);
181:                                cellWidth = comp.getPreferredSize().width;
182:                            } else
183:                                cellWidth = 0;
184:
185:                            column.setPreferredWidth(Math.max(headerWidth,
186:                                    cellWidth));
187:                        }
188:                    }
189:
190:                    ga.stop();
191:
192:                    this .repaint();
193:                } catch (Exception ex) {
194:                    log.warn("Error refreshing server information", ex);
195:
196:                    JOptionPane.showMessageDialog(this ,
197:                            "Error refreshing server information.",
198:                            "Admin error", JOptionPane.ERROR_MESSAGE);
199:                }
200:            }
201:
202:            /** This method is called from within the constructor to
203:             * initialize the form.
204:             * WARNING: Do NOT modify this code. The content of this method is
205:             * always regenerated by the Form Editor.
206:             */
207:            private void initComponents() {//GEN-BEGIN:initComponents
208:                java.awt.GridBagConstraints gridBagConstraints;
209:
210:                pServer = new javax.swing.JPanel();
211:                jLabel10 = new javax.swing.JLabel();
212:                lHostName = new javax.swing.JLabel();
213:                jLabel11 = new javax.swing.JLabel();
214:                lHostPort = new javax.swing.JLabel();
215:                jLabel13 = new javax.swing.JLabel();
216:                lSessionName = new javax.swing.JLabel();
217:                jLabel12 = new javax.swing.JLabel();
218:                lPing = new javax.swing.JLabel();
219:                jLabel14 = new javax.swing.JLabel();
220:                lWorkerCount = new javax.swing.JLabel();
221:                jLabel15 = new javax.swing.JLabel();
222:                lQueueSize = new javax.swing.JLabel();
223:                pWorkers = new javax.swing.JPanel();
224:                sPane = new javax.swing.JScrollPane();
225:                bRefresh = new javax.swing.JButton();
226:
227:                getContentPane().setLayout(new java.awt.GridBagLayout());
228:
229:                setTitle("JCGrid Server Status");
230:                setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
231:                pServer.setLayout(new java.awt.GridBagLayout());
232:
233:                pServer.setBorder(new javax.swing.border.TitledBorder(
234:                        "JCGrid Server"));
235:                jLabel10
236:                        .setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
237:                jLabel10.setText("Server host name:");
238:                gridBagConstraints = new java.awt.GridBagConstraints();
239:                gridBagConstraints.gridx = 0;
240:                gridBagConstraints.gridy = 0;
241:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
242:                gridBagConstraints.weighty = 1.0;
243:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
244:                pServer.add(jLabel10, gridBagConstraints);
245:
246:                lHostName
247:                        .setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
248:                lHostName.setText("...");
249:                lHostName.setForeground(java.awt.SystemColor.activeCaption);
250:                gridBagConstraints = new java.awt.GridBagConstraints();
251:                gridBagConstraints.gridx = 1;
252:                gridBagConstraints.gridy = 0;
253:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
254:                gridBagConstraints.weighty = 1.0;
255:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
256:                pServer.add(lHostName, gridBagConstraints);
257:
258:                jLabel11
259:                        .setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
260:                jLabel11.setText("Admin. server port:");
261:                gridBagConstraints = new java.awt.GridBagConstraints();
262:                gridBagConstraints.gridx = 0;
263:                gridBagConstraints.gridy = 1;
264:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
265:                gridBagConstraints.weighty = 1.0;
266:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
267:                pServer.add(jLabel11, gridBagConstraints);
268:
269:                lHostPort
270:                        .setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
271:                lHostPort.setText("...");
272:                lHostPort.setForeground(java.awt.SystemColor.activeCaption);
273:                gridBagConstraints = new java.awt.GridBagConstraints();
274:                gridBagConstraints.gridx = 1;
275:                gridBagConstraints.gridy = 1;
276:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
277:                gridBagConstraints.weighty = 1.0;
278:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
279:                pServer.add(lHostPort, gridBagConstraints);
280:
281:                jLabel13
282:                        .setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
283:                jLabel13.setText("Admin. session name:");
284:                gridBagConstraints = new java.awt.GridBagConstraints();
285:                gridBagConstraints.gridx = 0;
286:                gridBagConstraints.gridy = 2;
287:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
288:                gridBagConstraints.weighty = 1.0;
289:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
290:                pServer.add(jLabel13, gridBagConstraints);
291:
292:                lSessionName
293:                        .setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
294:                lSessionName.setText("...");
295:                lSessionName.setForeground(java.awt.SystemColor.activeCaption);
296:                gridBagConstraints = new java.awt.GridBagConstraints();
297:                gridBagConstraints.gridx = 1;
298:                gridBagConstraints.gridy = 2;
299:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
300:                gridBagConstraints.weighty = 1.0;
301:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
302:                pServer.add(lSessionName, gridBagConstraints);
303:
304:                jLabel12
305:                        .setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
306:                jLabel12.setText("Ping time:");
307:                gridBagConstraints = new java.awt.GridBagConstraints();
308:                gridBagConstraints.gridx = 0;
309:                gridBagConstraints.gridy = 3;
310:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
311:                gridBagConstraints.weighty = 1.0;
312:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
313:                pServer.add(jLabel12, gridBagConstraints);
314:
315:                lPing.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
316:                lPing.setText("...");
317:                lPing.setForeground(java.awt.SystemColor.activeCaption);
318:                gridBagConstraints = new java.awt.GridBagConstraints();
319:                gridBagConstraints.gridx = 1;
320:                gridBagConstraints.gridy = 3;
321:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
322:                gridBagConstraints.weighty = 1.0;
323:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
324:                pServer.add(lPing, gridBagConstraints);
325:
326:                jLabel14
327:                        .setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
328:                jLabel14.setText("Grid worker count:");
329:                gridBagConstraints = new java.awt.GridBagConstraints();
330:                gridBagConstraints.gridx = 0;
331:                gridBagConstraints.gridy = 4;
332:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
333:                gridBagConstraints.weighty = 1.0;
334:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
335:                pServer.add(jLabel14, gridBagConstraints);
336:
337:                lWorkerCount
338:                        .setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
339:                lWorkerCount.setText("...");
340:                lWorkerCount.setForeground(java.awt.SystemColor.activeCaption);
341:                gridBagConstraints = new java.awt.GridBagConstraints();
342:                gridBagConstraints.gridx = 1;
343:                gridBagConstraints.gridy = 4;
344:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
345:                gridBagConstraints.weighty = 1.0;
346:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
347:                pServer.add(lWorkerCount, gridBagConstraints);
348:
349:                jLabel15
350:                        .setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
351:                jLabel15.setText("Grid work request queue size:");
352:                gridBagConstraints = new java.awt.GridBagConstraints();
353:                gridBagConstraints.gridx = 0;
354:                gridBagConstraints.gridy = 5;
355:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
356:                gridBagConstraints.weighty = 1.0;
357:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
358:                pServer.add(jLabel15, gridBagConstraints);
359:
360:                lQueueSize
361:                        .setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
362:                lQueueSize.setText("...");
363:                lQueueSize.setForeground(java.awt.SystemColor.activeCaption);
364:                gridBagConstraints = new java.awt.GridBagConstraints();
365:                gridBagConstraints.gridx = 1;
366:                gridBagConstraints.gridy = 5;
367:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
368:                gridBagConstraints.weighty = 1.0;
369:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
370:                pServer.add(lQueueSize, gridBagConstraints);
371:
372:                gridBagConstraints = new java.awt.GridBagConstraints();
373:                gridBagConstraints.gridx = 0;
374:                gridBagConstraints.gridy = 0;
375:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
376:                gridBagConstraints.weightx = 1.0;
377:                getContentPane().add(pServer, gridBagConstraints);
378:
379:                pWorkers.setLayout(new java.awt.GridBagLayout());
380:
381:                pWorkers.setBorder(new javax.swing.border.TitledBorder(
382:                        "JCGrid Workers"));
383:                gridBagConstraints = new java.awt.GridBagConstraints();
384:                gridBagConstraints.gridx = 0;
385:                gridBagConstraints.gridy = 0;
386:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
387:                gridBagConstraints.weightx = 1.0;
388:                gridBagConstraints.weighty = 1.0;
389:                pWorkers.add(sPane, gridBagConstraints);
390:
391:                gridBagConstraints = new java.awt.GridBagConstraints();
392:                gridBagConstraints.gridx = 0;
393:                gridBagConstraints.gridy = 1;
394:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
395:                gridBagConstraints.weightx = 1.0;
396:                gridBagConstraints.weighty = 1.0;
397:                getContentPane().add(pWorkers, gridBagConstraints);
398:
399:                bRefresh.setText("Refresh");
400:                bRefresh.addActionListener(new java.awt.event.ActionListener() {
401:                    public void actionPerformed(java.awt.event.ActionEvent evt) {
402:                        bRefreshActionPerformed(evt);
403:                    }
404:                });
405:
406:                gridBagConstraints = new java.awt.GridBagConstraints();
407:                gridBagConstraints.gridx = 0;
408:                gridBagConstraints.gridy = 10;
409:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
410:                getContentPane().add(bRefresh, gridBagConstraints);
411:
412:                java.awt.Dimension screenSize = java.awt.Toolkit
413:                        .getDefaultToolkit().getScreenSize();
414:                setBounds((screenSize.width - 400) / 2,
415:                        (screenSize.height - 300) / 2, 400, 300);
416:            }//GEN-END:initComponents
417:
418:            private void bRefreshActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bRefreshActionPerformed
419:                this .refreshInfo(adminConfig);
420:            }//GEN-LAST:event_bRefreshActionPerformed
421:
422:            // Variables declaration - do not modify//GEN-BEGIN:variables
423:            private javax.swing.JButton bRefresh;
424:            private javax.swing.JLabel jLabel10;
425:            private javax.swing.JLabel jLabel11;
426:            private javax.swing.JLabel jLabel12;
427:            private javax.swing.JLabel jLabel13;
428:            private javax.swing.JLabel jLabel14;
429:            private javax.swing.JLabel jLabel15;
430:            private javax.swing.JLabel lHostName;
431:            private javax.swing.JLabel lHostPort;
432:            private javax.swing.JLabel lPing;
433:            private javax.swing.JLabel lQueueSize;
434:            private javax.swing.JLabel lSessionName;
435:            private javax.swing.JLabel lWorkerCount;
436:            private javax.swing.JPanel pServer;
437:            private javax.swing.JPanel pWorkers;
438:            private javax.swing.JScrollPane sPane;
439:            // End of variables declaration//GEN-END:variables
440:
441:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.