001    /*
002     * LogPanel.java
003     *
004     * Created on May 22, 2003, 12:41 PM
005     *
006     * This file is part of the STAR Scheduler.
007     * Copyright (c) 2002-2006 STAR Collaboration - Brookhaven National Laboratory
008     *
009     * STAR Scheduler is free software; you can redistribute it and/or modify
010     * it under the terms of the GNU General Public License as published by
011     * the Free Software Foundation; either version 2 of the License, or
012     * (at your option) any later version.
013     *
014     * STAR Scheduler is distributed in the hope that it will be useful,
015     * but WITHOUT ANY WARRANTY; without even the implied warranty of
016     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
017     * GNU General Public License for more details.
018     *
019     * You should have received a copy of the GNU General Public License
020     * along with STAR Scheduler; if not, write to the Free Software
021     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
022     */
023    
024    package gov.bnl.star.offline.scheduler.config;
025    
026    /**
027     *
028     * @author  Gabriele Carcassi
029     */
030    public class PassivePolicyPanel extends javax.swing.JPanel implements WizardPanel {
031        
032        /** Creates new form LogPanel */
033        public PassivePolicyPanel() {
034            initComponents();
035        }
036        
037        /** This method is called from within the constructor to
038         * initialize the form.
039         * WARNING: Do NOT modify this code. The content of this method is
040         * always regenerated by the Form Editor.
041         */
042        private void initComponents() {//GEN-BEGIN:initComponents
043            java.awt.GridBagConstraints gridBagConstraints;
044    
045            instructions = new javax.swing.JTextArea();
046            localQueueLabel = new javax.swing.JLabel();
047            localQueue = new javax.swing.JTextField();
048            rootdLabel = new javax.swing.JLabel();
049            rootd = new javax.swing.JComboBox();
050            nfsQueueLabel = new javax.swing.JLabel();
051            nfsQueue = new javax.swing.JTextField();
052            localTimeLimitLabel = new javax.swing.JLabel();
053            localTimeLimit = new javax.swing.JTextField();
054            longQueueLabel = new javax.swing.JLabel();
055            longQueue = new javax.swing.JTextField();
056    
057            setLayout(new java.awt.GridBagLayout());
058    
059            instructions.setEditable(false);
060            instructions.setLineWrap(true);
061            instructions.setText("The passive policy has many parameters that can be used to tune its decision.\nisRootdAvailable - tells the policy that rootd is available on this cluster. This allows the use of rootd to enable use of local files on different machines.\nnfs/local/longQueue - the policy will dispatch files that are more than timeLimit minutes on the long queue. Of the remaining, the ones that have even a single local file will go on the local queue.");
062            instructions.setWrapStyleWord(true);
063            instructions.setFocusable(false);
064            instructions.setOpaque(false);
065            gridBagConstraints = new java.awt.GridBagConstraints();
066            gridBagConstraints.gridwidth = 4;
067            gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
068            gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
069            gridBagConstraints.weightx = 1.0;
070            gridBagConstraints.insets = new java.awt.Insets(5, 5, 15, 5);
071            add(instructions, gridBagConstraints);
072    
073            localQueueLabel.setText("local queue");
074            gridBagConstraints = new java.awt.GridBagConstraints();
075            gridBagConstraints.gridx = 0;
076            gridBagConstraints.gridy = 2;
077            gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
078            gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 0);
079            add(localQueueLabel, gridBagConstraints);
080    
081            localQueue.addKeyListener(new java.awt.event.KeyAdapter() {
082                public void keyTyped(java.awt.event.KeyEvent evt) {
083                    textChange(evt);
084                }
085            });
086    
087            gridBagConstraints = new java.awt.GridBagConstraints();
088            gridBagConstraints.gridx = 1;
089            gridBagConstraints.gridy = 2;
090            gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
091            gridBagConstraints.weightx = 1.0;
092            gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 0);
093            add(localQueue, gridBagConstraints);
094    
095            rootdLabel.setText("isRootdAvailable*");
096            gridBagConstraints = new java.awt.GridBagConstraints();
097            gridBagConstraints.gridx = 0;
098            gridBagConstraints.gridy = 1;
099            gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
100            gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 0);
101            add(rootdLabel, gridBagConstraints);
102    
103            rootd.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "", "true", "false" }));
104            rootd.addItemListener(new java.awt.event.ItemListener() {
105                public void itemStateChanged(java.awt.event.ItemEvent evt) {
106                    comboChanged(evt);
107                }
108            });
109    
110            gridBagConstraints = new java.awt.GridBagConstraints();
111            gridBagConstraints.gridx = 1;
112            gridBagConstraints.gridy = 1;
113            gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
114            gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 0);
115            add(rootd, gridBagConstraints);
116    
117            nfsQueueLabel.setText("NFS queue");
118            gridBagConstraints = new java.awt.GridBagConstraints();
119            gridBagConstraints.gridx = 2;
120            gridBagConstraints.gridy = 2;
121            gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
122            gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 0);
123            add(nfsQueueLabel, gridBagConstraints);
124    
125            nfsQueue.addKeyListener(new java.awt.event.KeyAdapter() {
126                public void keyTyped(java.awt.event.KeyEvent evt) {
127                    textChange(evt);
128                }
129            });
130    
131            gridBagConstraints = new java.awt.GridBagConstraints();
132            gridBagConstraints.gridx = 3;
133            gridBagConstraints.gridy = 2;
134            gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
135            gridBagConstraints.weightx = 1.0;
136            gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 5);
137            add(nfsQueue, gridBagConstraints);
138    
139            localTimeLimitLabel.setText("local/NFS queue time limit");
140            gridBagConstraints = new java.awt.GridBagConstraints();
141            gridBagConstraints.gridx = 0;
142            gridBagConstraints.gridy = 3;
143            gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
144            gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 0);
145            add(localTimeLimitLabel, gridBagConstraints);
146    
147            localTimeLimit.addKeyListener(new java.awt.event.KeyAdapter() {
148                public void keyTyped(java.awt.event.KeyEvent evt) {
149                    textChange(evt);
150                }
151            });
152    
153            gridBagConstraints = new java.awt.GridBagConstraints();
154            gridBagConstraints.gridx = 1;
155            gridBagConstraints.gridy = 3;
156            gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
157            gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 0);
158            add(localTimeLimit, gridBagConstraints);
159    
160            longQueueLabel.setText("long queue");
161            gridBagConstraints = new java.awt.GridBagConstraints();
162            gridBagConstraints.gridx = 0;
163            gridBagConstraints.gridy = 4;
164            gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
165            gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 0);
166            add(longQueueLabel, gridBagConstraints);
167    
168            longQueue.addKeyListener(new java.awt.event.KeyAdapter() {
169                public void keyTyped(java.awt.event.KeyEvent evt) {
170                    textChange(evt);
171                }
172            });
173    
174            gridBagConstraints = new java.awt.GridBagConstraints();
175            gridBagConstraints.gridx = 1;
176            gridBagConstraints.gridy = 4;
177            gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
178            gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
179            gridBagConstraints.weighty = 1.0;
180            gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 0);
181            add(longQueue, gridBagConstraints);
182    
183        }//GEN-END:initComponents
184    
185        private void textChange(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_textChange
186            firePropertyChange("ready", oldReady, isReady());
187            oldReady = isReady();
188        }//GEN-LAST:event_textChange
189    
190        private void comboChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_comboChanged
191            firePropertyChange("ready", oldReady, isReady());
192            oldReady = isReady();
193        }//GEN-LAST:event_comboChanged
194    
195        private boolean oldReady;
196        public String getTitle() {
197            return "PassivePolicy";
198        }    
199        
200        public boolean isReady() {
201            if (rootd.getSelectedIndex() == 0) return false;
202            return true;
203        }    
204        
205        public void addProperties(java.util.Map schedulerProperties) {
206            schedulerProperties.put("PassivePolicy.isRootdAvailable", rootd.getSelectedItem());
207            schedulerProperties.put("PassivePolicy.nfsQueue", nfsQueue.getText());
208            schedulerProperties.put("PassivePolicy.localQueue", localQueue.getText());
209            schedulerProperties.put("PassivePolicy.localQueue.minTimeLimit", localTimeLimit.getText());
210            schedulerProperties.put("PassivePolicy.longQueue", longQueue.getText());
211        }
212        
213        // Variables declaration - do not modify//GEN-BEGIN:variables
214        private javax.swing.JTextArea instructions;
215        private javax.swing.JTextField localQueue;
216        private javax.swing.JLabel localQueueLabel;
217        private javax.swing.JTextField localTimeLimit;
218        private javax.swing.JLabel localTimeLimitLabel;
219        private javax.swing.JTextField longQueue;
220        private javax.swing.JLabel longQueueLabel;
221        private javax.swing.JTextField nfsQueue;
222        private javax.swing.JLabel nfsQueueLabel;
223        private javax.swing.JComboBox rootd;
224        private javax.swing.JLabel rootdLabel;
225        // End of variables declaration//GEN-END:variables
226        
227    }