@@ -25,7 +25,7 @@ public class App
25
25
{
26
26
private static ArrayList <Instance > _instances = new ArrayList <Instance >();
27
27
private static LinkedList <Instance > _brokenInstances = new LinkedList <Instance >();
28
- private final static Logger LOGGER = Logger .getLogger (App .class .getName ());
28
+ private final static Logger LOGGER = Logger .getLogger (App .class .getName ());
29
29
private static int _loopCounter ;
30
30
31
31
@@ -54,11 +54,11 @@ public static void main( String[] args ) {
54
54
}
55
55
56
56
// Set up the logger to add file handler
57
- try {
58
- CustomLogger .setup (Level .toLevel (config .logLevel ), config .logLocation );
59
- } catch (IOException e ) {
60
- LOGGER .error ("Unable to setup file handler to file: " + config .logLocation , e );
61
- }
57
+ // try {
58
+ // CustomLogger.setup(Level.toLevel(config.logLevel), config.logLocation);
59
+ // } catch (IOException e) {
60
+ // LOGGER.error("Unable to setup file handler to file: " + config.logLocation, e);
61
+ // }
62
62
63
63
64
64
// The specified action is unknown
@@ -119,16 +119,16 @@ public void run() {
119
119
}
120
120
121
121
122
- private static void _doLoop (AppConfig config ) {
122
+ public static void _doLoop (AppConfig config ) {
123
123
// Main Loop that will periodically collect metrics from the JMX Server
124
124
while (true ) {
125
125
long start = System .currentTimeMillis ();
126
- if (_instances .size () > 0 ) {
126
+ if (false && _instances .size () > 0 ) {
127
127
doIteration (config );
128
128
} else {
129
129
LOGGER .warn ("No instance could be initiated. Retrying initialization." );
130
130
config .status .flush ();
131
- init (config , true );
131
+ init (config , false );
132
132
}
133
133
long length = System .currentTimeMillis () - start ;
134
134
LOGGER .debug ("Iteration ran in " + length + " ms" );
@@ -178,7 +178,7 @@ public static void doIteration(AppConfig config) {
178
178
179
179
instanceStatus = Status .STATUS_WARNING ;
180
180
// We don't want to log the warning at every iteration so we use this custom logger.
181
- CustomLogger .laconic (LOGGER , Level .WARN , instanceMessage , 0 );
181
+ // CustomLogger.laconic(LOGGER, Level.WARN, instanceMessage, 0);
182
182
}
183
183
reporter .sendMetrics (metrics , instance .getName ());
184
184
config .status .addInstanceStats (instance .getCheckName (), instance .getName (), metrics .size (), instanceMessage , instanceStatus );
@@ -268,7 +268,7 @@ public static void init(AppConfig config, boolean forceNewConnection) {
268
268
Map .Entry <String , YamlParser > entry = (Map .Entry <String , YamlParser >)it .next ();
269
269
String name = entry .getKey ();
270
270
YamlParser yamlConfig = entry .getValue ();
271
- it .remove ();
271
+ it .remove ();
272
272
273
273
274
274
ArrayList <LinkedHashMap <String , Object >> configInstances = ((ArrayList <LinkedHashMap <String , Object >>) yamlConfig .getYamlInstances ());
@@ -279,12 +279,14 @@ public static void init(AppConfig config, boolean forceNewConnection) {
279
279
continue ;
280
280
}
281
281
282
- for (Iterator <LinkedHashMap <String ,Object >> i = configInstances .iterator (); i .hasNext (); ) {
282
+ for (Iterator <LinkedHashMap <String ,Object >> i = configInstances .iterator (); i .hasNext (); ) {
283
283
Instance instance = null ;
284
284
//Create a new Instance object
285
285
try {
286
- instance = new Instance (i .next (), ((LinkedHashMap <String , Object >) yamlConfig .getInitConfig ()), name , config );
286
+ LinkedHashMap <String , Object > initConfig = (LinkedHashMap <String , Object >) yamlConfig .getInitConfig ();
287
+ instance = new Instance (i .next (), new LinkedHashMap <String , Object >(), name , config );
287
288
} catch (Exception e ) {
289
+ e .printStackTrace ();
288
290
String warning = "Unable to create instance. Please check your yaml file" ;
289
291
config .status .addInitFailedCheck (name , warning , Status .STATUS_ERROR );
290
292
LOGGER .error (warning );
@@ -301,7 +303,7 @@ public static void init(AppConfig config, boolean forceNewConnection) {
301
303
LOGGER .error (warning );
302
304
} catch (Exception e ) {
303
305
_brokenInstances .add (instance );
304
- String warning = "Unexpected exception while initiating instance " + instance + " : " + e .getMessage ();
306
+ String warning = "Unexpected exception while initiating instance " + instance + " : " + e .getMessage ();
305
307
config .status .addInstanceStats (name , instance .getName (), 0 , warning , Status .STATUS_ERROR );
306
308
LOGGER .error (warning , e );
307
309
}
0 commit comments