Skip to content

Commit 8dfe779

Browse files
committed
mass reformat of the code. checked in project specific eclipse settings.
1 parent 0f1d731 commit 8dfe779

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2489
-2143
lines changed

.settings/org.eclipse.jdt.core.prefs

+282
Large diffs are not rendered by default.

.settings/org.eclipse.jdt.ui.prefs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#Tue Jan 24 16:58:35 PST 2012
2+
eclipse.preferences.version=1
3+
formatter_profile=_Jmxtrans
4+
formatter_settings_version=12

src/com/googlecode/jmxtrans/JmxTransformer.java

+53-52
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@
4444
import com.googlecode.jmxtrans.util.WatchedCallback;
4545

4646
/**
47-
* Main() class that takes an argument which is the directory
48-
* to look in for files which contain json data that defines
49-
* queries to run against JMX servers.
50-
*
47+
* Main() class that takes an argument which is the directory to look in for
48+
* files which contain json data that defines queries to run against JMX
49+
* servers.
50+
*
5151
* @author jon
5252
*/
5353
public class JmxTransformer extends SignalInterceptor implements WatchedCallback {
@@ -68,16 +68,15 @@ public class JmxTransformer extends SignalInterceptor implements WatchedCallback
6868

6969
private List<Server> masterServersList = new ArrayList<Server>();
7070

71-
7271
/** */
7372
public static void main(String[] args) throws Exception {
7473
JmxTransformer transformer = new JmxTransformer();
7574

7675
// Register signal handlers
77-
transformer.registerQuietly("HUP");
78-
transformer.registerQuietly("INT");
79-
transformer.registerQuietly("ABRT");
80-
transformer.registerQuietly("KILL");
76+
transformer.registerQuietly("HUP");
77+
transformer.registerQuietly("INT");
78+
transformer.registerQuietly("ABRT");
79+
transformer.registerQuietly("KILL");
8180
transformer.registerQuietly("TERM");
8281

8382
// Start the process
@@ -93,9 +92,9 @@ private void doMain(String[] args) throws Exception {
9392
}
9493

9594
try {
96-
this.startupScheduler();
95+
this.startupScheduler();
9796

98-
this.startupWatchdir();
97+
this.startupWatchdir();
9998

10099
this.setupObjectPooling();
101100

@@ -115,51 +114,52 @@ private void doMain(String[] args) throws Exception {
115114
* Startup the watchdir service.
116115
*/
117116
private void startupWatchdir() throws Exception {
118-
File dirToWatch = null;
119-
if (this.getJsonDirOrFile().isFile()) {
120-
dirToWatch = new File(FilenameUtils.getFullPath(this.getJsonDirOrFile().getAbsolutePath()));
121-
} else {
122-
dirToWatch = this.getJsonDirOrFile();
123-
}
124-
125-
// start the watcher
126-
this.watcher = new WatchDir(dirToWatch, this);
127-
this.watcher.start();
117+
File dirToWatch = null;
118+
if (this.getJsonDirOrFile().isFile()) {
119+
dirToWatch = new File(FilenameUtils.getFullPath(this.getJsonDirOrFile().getAbsolutePath()));
120+
} else {
121+
dirToWatch = this.getJsonDirOrFile();
122+
}
123+
124+
// start the watcher
125+
this.watcher = new WatchDir(dirToWatch, this);
126+
this.watcher.start();
128127
}
129128

130129
/**
131130
* start the server scheduler which loops over all the Server jobs
132131
*/
133132
private void startupScheduler() throws Exception {
134-
StdSchedulerFactory serverSchedFact = new StdSchedulerFactory();
135-
InputStream stream = null;
136-
if (QUARTZ_SERVER_PROPERTIES == null) {
137-
QUARTZ_SERVER_PROPERTIES = "/quartz.server.properties";
138-
stream = JmxTransformer.class.getResourceAsStream(QUARTZ_SERVER_PROPERTIES);
139-
} else {
140-
stream = new FileInputStream(QUARTZ_SERVER_PROPERTIES);
141-
}
142-
serverSchedFact.initialize(stream);
143-
this.serverScheduler = serverSchedFact.getScheduler();
144-
this.serverScheduler.start();
133+
StdSchedulerFactory serverSchedFact = new StdSchedulerFactory();
134+
InputStream stream = null;
135+
if (QUARTZ_SERVER_PROPERTIES == null) {
136+
QUARTZ_SERVER_PROPERTIES = "/quartz.server.properties";
137+
stream = JmxTransformer.class.getResourceAsStream(QUARTZ_SERVER_PROPERTIES);
138+
} else {
139+
stream = new FileInputStream(QUARTZ_SERVER_PROPERTIES);
140+
}
141+
serverSchedFact.initialize(stream);
142+
this.serverScheduler = serverSchedFact.getScheduler();
143+
this.serverScheduler.start();
145144
}
146145

147146
/**
148147
* Handy method which runs the JmxProcess
149148
*/
150149
public void executeStandalone(JmxProcess process) throws Exception {
151-
this.masterServersList = process.getServers();
150+
this.masterServersList = process.getServers();
152151

153-
this.startupScheduler();
154-
this.setupObjectPooling();
152+
this.startupScheduler();
153+
this.setupObjectPooling();
155154

156-
this.processServersIntoJobs(this.serverScheduler);
155+
this.processServersIntoJobs(this.serverScheduler);
157156

158-
// Sleep for 10 seconds to wait for jobs to complete.
159-
// There should be a better way, but it seems that way isn't working right now.
160-
Thread.sleep(10 * 1000);
157+
// Sleep for 10 seconds to wait for jobs to complete.
158+
// There should be a better way, but it seems that way isn't working
159+
// right now.
160+
Thread.sleep(10 * 1000);
161161

162-
this.handle("TERM");
162+
this.handle("TERM");
163163
}
164164

165165
/**
@@ -232,7 +232,7 @@ private void processFilesIntoServers(List<File> jsonFiles) throws LifecycleExcep
232232

233233
/**
234234
* Processes all the Servers into Job's
235-
*
235+
*
236236
* Needs to be called after processFiles()
237237
*/
238238
private void processServersIntoJobs(Scheduler scheduler) throws LifecycleException {
@@ -249,7 +249,8 @@ private void processServersIntoJobs(Scheduler scheduler) throws LifecycleExcepti
249249
}
250250
}
251251

252-
// Now validate the setup of each of the OutputWriter's per query.
252+
// Now validate the setup of each of the OutputWriter's per
253+
// query.
253254
this.validateSetup(server.getQueries());
254255

255256
// Now schedule the jobs for execution.
@@ -281,9 +282,9 @@ private void scheduleJob(Scheduler scheduler, Server server) throws ParseExcepti
281282

282283
if ((server.getCronExpression() != null) && CronExpression.isValidExpression(server.getCronExpression())) {
283284
trigger = new CronTrigger();
284-
((CronTrigger)trigger).setCronExpression(server.getCronExpression());
285-
((CronTrigger)trigger).setName(server.getHost() + ":" + server.getPort() + "-" + Long.valueOf(System.currentTimeMillis()).toString());
286-
((CronTrigger)trigger).setStartTime(new Date());
285+
((CronTrigger) trigger).setCronExpression(server.getCronExpression());
286+
((CronTrigger) trigger).setName(server.getHost() + ":" + server.getPort() + "-" + Long.valueOf(System.currentTimeMillis()).toString());
287+
((CronTrigger) trigger).setStartTime(new Date());
287288
} else {
288289
Trigger minuteTrigger = TriggerUtils.makeSecondlyTrigger(SECONDS_BETWEEN_SERVER_JOB_RUNS);
289290
minuteTrigger.setName(server.getHost() + ":" + server.getPort() + "-" + Long.valueOf(System.currentTimeMillis()).toString());
@@ -320,8 +321,8 @@ private void deleteAllJobs(Scheduler scheduler) throws Exception {
320321
}
321322

322323
/**
323-
* If this is true, then this class will execute the main()
324-
* loop and then wait 60 seconds until running again.
324+
* If this is true, then this class will execute the main() loop and then
325+
* wait 60 seconds until running again.
325326
*/
326327
public void setRunEndlessly(boolean runEndlessly) {
327328
this.runEndlessly = runEndlessly;
@@ -399,9 +400,9 @@ public File getJsonDirOrFile() {
399400
}
400401

401402
/**
402-
* If getJsonFile() is a file, then that is all we load. Otherwise,
403-
* look in the jsonDir for files.
404-
*
403+
* If getJsonFile() is a file, then that is all we load. Otherwise, look in
404+
* the jsonDir for files.
405+
*
405406
* Files must end with .json as the suffix.
406407
*/
407408
private List<File> getJsonFiles() {
@@ -448,9 +449,9 @@ protected boolean handle(String signame) {
448449
for (Entry<String, KeyedObjectPool> entry : this.getObjectPoolMap().entrySet()) {
449450
try {
450451
entry.getValue().close();
451-
log.debug("Closed object pool factory: " + entry.getKey());
452+
log.debug("Closed object pool factory: " + entry.getKey());
452453
} catch (Exception ex) {
453-
log.error("Error closing object pool factory: " + entry.getKey());
454+
log.error("Error closing object pool factory: " + entry.getKey());
454455
}
455456
}
456457

src/com/googlecode/jmxtrans/OutputWriter.java

+43-37
Original file line numberDiff line numberDiff line change
@@ -12,45 +12,51 @@
1212
import com.googlecode.jmxtrans.util.ValidationException;
1313

1414
/**
15-
* Interface which defines a writer for taking jmx data and
16-
* writing it out in whatever format you want.
17-
*
18-
* Note that this class uses a feature of Jackson to serialize
19-
* anything that implements this as a "@class". That way, when
20-
* Jackson deserializes implementations of this interface, it is
21-
* done with new objects that implement this interface.
22-
*
15+
* Interface which defines a writer for taking jmx data and writing it out in
16+
* whatever format you want.
17+
*
18+
* Note that this class uses a feature of Jackson to serialize anything that
19+
* implements this as a "@class". That way, when Jackson deserializes
20+
* implementations of this interface, it is done with new objects that implement
21+
* this interface.
22+
*
2323
* @author jon
2424
*/
25-
@JsonSerialize(include=Inclusion.NON_NULL)
26-
@JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY, property="@class")
25+
@JsonSerialize(include = Inclusion.NON_NULL)
26+
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "@class")
2727
public interface OutputWriter {
2828

29-
public void start() throws LifecycleException;
30-
public void stop() throws LifecycleException;
31-
32-
public void doWrite(Query query) throws Exception;
33-
34-
/**
35-
* Settings allow you to configure your Writers with whatever they might need.
36-
*/
37-
public Map<String, Object> getSettings();
38-
39-
/**
40-
* Settings allow you to configure your Writers with whatever they might need.
41-
*/
42-
public void setSettings(Map<String, Object> settings);
43-
44-
/**
45-
* This is run when the object is instantiated. You want to get the settings and validate them.
46-
*/
47-
public void validateSetup(Query query) throws ValidationException;
48-
49-
/**
50-
* Some writers, like GraphiteWriter will use this for object pooling. Things like
51-
* Socket connections to remote servers that we are writing to are ripe for pooling.
52-
*
53-
* This is super extensible as a map because we could have multiple object pools.
54-
*/
55-
public void setObjectPoolMap(Map<String, KeyedObjectPool> poolMap);
29+
public void start() throws LifecycleException;
30+
31+
public void stop() throws LifecycleException;
32+
33+
public void doWrite(Query query) throws Exception;
34+
35+
/**
36+
* Settings allow you to configure your Writers with whatever they might
37+
* need.
38+
*/
39+
public Map<String, Object> getSettings();
40+
41+
/**
42+
* Settings allow you to configure your Writers with whatever they might
43+
* need.
44+
*/
45+
public void setSettings(Map<String, Object> settings);
46+
47+
/**
48+
* This is run when the object is instantiated. You want to get the settings
49+
* and validate them.
50+
*/
51+
public void validateSetup(Query query) throws ValidationException;
52+
53+
/**
54+
* Some writers, like GraphiteWriter will use this for object pooling.
55+
* Things like Socket connections to remote servers that we are writing to
56+
* are ripe for pooling.
57+
*
58+
* This is super extensible as a map because we could have multiple object
59+
* pools.
60+
*/
61+
public void setObjectPoolMap(Map<String, KeyedObjectPool> poolMap);
5662
}

src/com/googlecode/jmxtrans/example/ActiveMQ.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010

1111
/**
1212
* This example shows how to query an ActiveMQ server for some information.
13-
*
13+
*
1414
* The point of this example is to show that * works as part of the objectName.
1515
* It also shows that you don't have to set an attribute to get for a query.
1616
* jmxtrans will get all attributes on an object if you don't specify any.
17-
*
17+
*
1818
* @author jon
1919
*/
2020
public class ActiveMQ {
@@ -28,7 +28,7 @@ public static void main(String[] args) throws Exception {
2828
server.setAlias("w2_activemq_1105");
2929
GraphiteWriter gw = new GraphiteWriter();
3030
gw.addSetting(BaseOutputWriter.HOST, GW_HOST);
31-
// gw.addSetting(GraphiteWriter.HOST, "localhost");
31+
// gw.addSetting(GraphiteWriter.HOST, "localhost");
3232
gw.addSetting(BaseOutputWriter.PORT, 2003);
3333

3434
// use this to add data to GW path
@@ -143,13 +143,13 @@ public static void main(String[] args) throws Exception {
143143

144144
JmxProcess process = new JmxProcess(server);
145145
JmxUtils.prettyPrintJson(process);
146-
JmxTransformer transformer = new JmxTransformer();
147-
transformer.executeStandalone(process);
146+
JmxTransformer transformer = new JmxTransformer();
147+
transformer.executeStandalone(process);
148148

149-
// for (int i = 0; i < 160; i++) {
150-
// JmxUtils.processServer(server);
151-
// Thread.sleep(1000);
152-
// }
149+
// for (int i = 0; i < 160; i++) {
150+
// JmxUtils.processServer(server);
151+
// Thread.sleep(1000);
152+
// }
153153

154154
}
155155
}

src/com/googlecode/jmxtrans/example/ActiveMQ2.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010

1111
/**
1212
* This example shows how to query an ActiveMQ server for some information.
13-
*
13+
*
1414
* The point of this example is to show that * works as part of the objectName.
1515
* It also shows that you don't have to set an attribute to get for a query.
1616
* jmxtrans will get all attributes on an object if you don't specify any.
17-
*
17+
*
1818
* @author jon
1919
*/
2020
public class ActiveMQ2 {
@@ -68,12 +68,12 @@ public static void main(String[] args) throws Exception {
6868
JmxUtils.prettyPrintJson(process);
6969

7070
JmxTransformer transformer = new JmxTransformer();
71-
transformer.executeStandalone(process);
71+
transformer.executeStandalone(process);
7272

73-
// for (int i = 0; i < 160; i++) {
74-
// JmxUtils.processServer(server);
75-
// Thread.sleep(1000);
76-
// }
73+
// for (int i = 0; i < 160; i++) {
74+
// JmxUtils.processServer(server);
75+
// Thread.sleep(1000);
76+
// }
7777

7878
}
7979
}

0 commit comments

Comments
 (0)