KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > slamd > example > NullJobClass


1 /*
2  * Sun Public License
3  *
4  * The contents of this file are subject to the Sun Public License Version
5  * 1.0 (the "License"). You may not use this file except in compliance with
6  * the License. A copy of the License is available at http://www.sun.com/
7  *
8  * The Original Code is the SLAMD Distributed Load Generation Engine.
9  * The Initial Developer of the Original Code is Neil A. Wilson.
10  * Portions created by Neil A. Wilson are Copyright (C) 2004.
11  * Some preexisting portions Copyright (C) 2002-2004 Sun Microsystems, Inc.
12  * All Rights Reserved.
13  *
14  * Contributor(s): Neil A. Wilson
15  */

16 package com.sun.slamd.example;
17
18
19
20 import com.sun.slamd.client.*;
21 import com.sun.slamd.job.*;
22 import com.sun.slamd.parameter.*;
23 import com.sun.slamd.stat.*;
24
25
26
27 /**
28  * This class defines a SLAMD job that does nothing. It simply provides the
29  * capability to insert a delay between jobs.
30  *
31  *
32  * @author Neil A. Wilson
33  */

34 public class NullJobClass
35        extends JobClass
36 {
37   /**
38    * The default constructor used to create a new instance of the job class.
39    * The only thing it should do is to invoke the superclass constructor. All
40    * other initialization should be performed in the <CODE>initialize</CODE>
41    * method.
42    */

43   public NullJobClass()
44   {
45     super();
46   }
47
48
49
50   /**
51    * Retrieves the name of the job performed by this job thread.
52    *
53    * @return The name of the job performed by this job thread.
54    */

55   public String JavaDoc getJobName()
56   {
57     return "Null Job";
58   }
59
60
61
62   /**
63    * Retrieves a description of the job performed by this job thread.
64    *
65    * @return A description of the job performed by this job thread.
66    */

67   public String JavaDoc getJobDescription()
68   {
69     return "This job can be used to insert a delay between other jobs.";
70   }
71
72
73
74   /**
75    * Retrieves the name of the category in which this job class exists. This is
76    * used to help arrange the job classes in the administrative interface.
77    *
78    * @return The name of the category in which this job class exists.
79    */

80   public String JavaDoc getJobCategoryName()
81   {
82     return "Utility";
83   }
84
85
86
87   /**
88    * Retrieve a parameter list that can be used to determine all of the
89    * customizeable options that are available for this job.
90    *
91    * @return A parameter list that can be used to determine all of the
92    * customizeable options that are available for this job.
93    */

94   public ParameterList getParameterStubs()
95   {
96     return new ParameterList();
97   }
98
99
100
101   /**
102    * Retrieves the set of stat trackers that will be maintained by this job
103    * class. The stat trackers returned by this method do not have to actually
104    * contain any statistics -- the display name and stat tracker class should
105    * be the only information that callers of this method should rely upon. Note
106    * that this list can be different from the list of statistics actually
107    * collected by the job in some cases (e.g., if the job may not return all the
108    * stat trackers it advertises in all cases, or if the job may return stat
109    * trackers that it did not advertise), but it is a possibility that only the
110    * stat trackers returned by this method will be accessible for some features
111    * in the SLAMD server.
112    *
113    * @param clientID The client ID that should be used for the
114    * returned stat trackers.
115    * @param threadID The thread ID that should be used for the
116    * returned stat trackers.
117    * @param collectionInterval The collection interval that should be used for
118    * the returned stat trackers.
119    *
120    * @return The set of stat trackers that will be maintained by this job
121    * class.
122    */

123   public StatTracker[] getStatTrackerStubs(String JavaDoc clientID, String JavaDoc threadID,
124                                            int collectionInterval)
125   {
126     return new StatTracker[0];
127   }
128
129
130
131   /**
132    * Retrieves the stat trackers that are maintained for this job thread.
133    *
134    * @return The stat trackers that are maintained for this job thread.
135    */

136   public StatTracker[] getStatTrackers()
137   {
138     return new StatTracker[0];
139   }
140
141
142
143   /**
144    * Initializes this job thread to be used to actually run the job on the
145    * client. The provided parameter list should be processed to customize the
146    * behavior of this job thread, and any other initialization that needs to be
147    * done in order for the job to run should be performed here as well.
148    *
149    * @param clientID The client ID for this job thread.
150    * @param threadID The thread ID for this job thread.
151    * @param collectionInterval The length of time in seconds to use as the
152    * statistics collection interval.
153    * @param parameters The set of parameters provided to this job that
154    * can be used to customize its behavior.
155    *
156    * @throws UnableToRunException If a problem occurs that prevents the thread
157    * from being able to run properly.
158    */

159   public void initializeThread(String JavaDoc clientID, String JavaDoc threadID,
160                                int collectionInterval, ParameterList parameters)
161          throws UnableToRunException
162   {
163     // No implementation necessary
164
}
165
166
167
168   /**
169    * Perform the work of this job thread by executing the specified command.
170    */

171   public void runJob()
172   {
173     // Loop until it is determined that the job should stop.
174
while (! shouldStop())
175     {
176       try
177       {
178         Thread.sleep(100);
179       } catch (InterruptedException JavaDoc ie) {}
180     }
181   }
182 }
183
184
Popular Tags