Subversion Repositories DevTools

Rev

Rev 1365 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1365 Rev 4123
Line 180... Line 180...
180
  /**constructor, implements the sequence diagram spawn thread
180
  /**constructor, implements the sequence diagram spawn thread
181
   */
181
   */
182
  public BuildDaemon(String connectionString, String username, 
182
  public BuildDaemon(String connectionString, String username, 
183
                     String password)
183
                     String password)
184
  {
184
  {
185
    mLogger.debug("BuildDaemon");
185
    mLogger.warn("BuildDaemon");
186
    ReleaseManager releaseManager = 
186
    ReleaseManager releaseManager = 
187
      new ReleaseManager(connectionString, username + "[release_manager]", password);
187
      new ReleaseManager(connectionString, username + "[release_manager]", password);
188
    boolean run = true;
188
    boolean run = true;
189
    MutableInt rtag_id = new MutableInt();
189
    MutableInt rtag_id = new MutableInt();
190
    MutableInt rcon_id = new MutableInt();
190
    MutableInt rcon_id = new MutableInt();
Line 208... Line 208...
208
      {
208
      {
209
        mLogger.fatal("run GBE_DPKG not set");
209
        mLogger.fatal("run GBE_DPKG not set");
210
        throw new Exception("run GBE_DPKG not set");
210
        throw new Exception("run GBE_DPKG not set");
211
      }
211
      }
212
 
212
 
-
 
213
      //Set the default handler invoked when a thread abruptly terminates due to an
-
 
214
      //uncaught exception, and no other handler has been defined for that thread.
-
 
215
      Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler());
-
 
216
 
213
      //
217
      //
214
      //  Start the Nagios Interface Thread
218
      //  Start the Nagios Interface Thread
215
      //
219
      //
216
      if ( connectionString.compareTo("unit test spawn thread") != 0 )
220
      if ( connectionString.compareTo("unit test spawn thread") != 0 )
217
      {
221
      {
Line 329... Line 333...
329
   */
333
   */
330
  public boolean isActive(final int rcon_id)
334
  public boolean isActive(final int rcon_id)
331
  {
335
  {
332
    mLogger.debug("isActive " + rcon_id);
336
    mLogger.debug("isActive " + rcon_id);
333
    boolean retVal = false;
337
    boolean retVal = false;
-
 
338
    boolean found = false;
334
 
339
 
335
    for (Iterator<ThreadIdentifier> it = mThreadCollection.iterator(); it.hasNext(); )
340
    for (Iterator<ThreadIdentifier> it = mThreadCollection.iterator(); it.hasNext(); )
336
    {
341
    {
337
      ThreadIdentifier threadIdentifier = it.next();
342
      ThreadIdentifier threadIdentifier = it.next();
338
 
343
 
339
      if (threadIdentifier.get_rcon_id() == rcon_id)
344
      if (threadIdentifier.get_rcon_id() == rcon_id)
340
      {
345
      {
-
 
346
        found = true;
341
        if (threadIdentifier.get_thread().isAlive())
347
        if (threadIdentifier.get_thread().isAlive())
342
        {
348
        {
343
          retVal = true;
349
          retVal = true;
344
          break;
350
          break;
345
        }
351
        }
Line 347... Line 353...
347
        {
353
        {
348
            mLogger.warn("isActive found dead thread " + rcon_id );
354
            mLogger.warn("isActive found dead thread " + rcon_id );
349
        }
355
        }
350
      }
356
      }
351
    }
357
    }
-
 
358
 
-
 
359
    if ( !found )
-
 
360
    {
-
 
361
        mLogger.warn("isActive thread not found " + rcon_id);
-
 
362
    }
-
 
363
 
352
    mLogger.info("isActive returned " + retVal);
364
    mLogger.warn("isActive returned " + retVal);
353
    return retVal;
365
    return retVal;
354
  }
366
  }
355
 
367
 
356
    /**
368
    /**
357
     *  Nagios interface
369
     *  Nagios interface
Line 384... Line 396...
384
 
396
 
385
  /**terminates all BuildThreads
397
  /**terminates all BuildThreads
386
   */
398
   */
387
  public void cleanUp()
399
  public void cleanUp()
388
  {
400
  {
389
    mLogger.debug("cleanUp");
401
    mLogger.warn("cleanUp");
390
    if ( nagiosChecker != null )
402
    if ( nagiosChecker != null )
391
    {
403
    {
392
        nagiosChecker.terminate();
404
        nagiosChecker.terminate();
393
    }
405
    }
394
 
406
 
Line 409... Line 421...
409
      }
421
      }
410
    }
422
    }
411
  }
423
  }
412
}
424
}
413
 
425
 
-
 
426
class UncaughtExceptionHandler implements Thread.UncaughtExceptionHandler
-
 
427
{
-
 
428
    private static final Logger mLogger = Logger.getLogger(UncaughtExceptionHandler.class);
-
 
429
 
-
 
430
    //Implements Thread.UncaughtExceptionHandler.uncaughtException()
-
 
431
    public void uncaughtException(Thread th, Throwable ex)
-
 
432
    {
-
 
433
        System.out.println("You crashed thread " + th.getName());
-
 
434
        System.out.println("Exception was: " + ex.toString());
-
 
435
 
-
 
436
        mLogger.fatal("UncaughtException ThreadName: " + th.getName());
-
 
437
        mLogger.fatal("UncaughtException was: " + ex.toString());
-
 
438
    }
-
 
439
}