1 11 12 package com.sun.jmx.snmp.daemon; 13 14 import com.sun.jmx.trace.Trace; 17 18 21 22 final class SnmpTimerServer extends Thread { 23 24 27 private SnmpInformRequest req = null ; 28 29 SnmpQManager snmpq = null ; 30 String dbgTag = "SnmpTimerServer"; 31 32 boolean isBeingDestroyed = false; 36 37 40 public SnmpTimerServer (ThreadGroup grp, SnmpQManager q) { 41 super(grp, "SnmpTimerServer") ; 42 setName(dbgTag) ; 43 snmpq = q ; 44 start() ; 45 } 46 47 public synchronized void stopTimerServer() { 48 49 if (isAlive()) { 50 interrupt(); 51 try { 52 join(); 55 } catch (InterruptedException e) { 56 } 58 } 59 } 60 61 public void run() { 62 Thread.currentThread().setPriority(Thread.NORM_PRIORITY); 63 64 if (isTraceOn()) { 65 trace("run", "Timer Thread started"); 66 } 67 68 while (true) { 69 70 try { 71 if (isTraceOn()) { 72 trace("run", "Blocking for inform requests"); 73 } 74 if (req == null) { 75 req = snmpq.getTimeoutRequests() ; 76 } 77 if (req != null && req.inProgress()) { 78 if (isTraceOn()) { 79 trace("run", "Handle timeout inform request " + req.getRequestId()); 80 } 81 req.action() ; 82 req = null ; 83 } 84 if (isBeingDestroyed == true) 85 break; 86 } catch (Exception e) { 87 if (isDebugOn()) { 88 debug("run", e.getMessage()); 89 } 90 } catch (ThreadDeath d) { 91 if (isDebugOn()) { 92 debug("run", "Timer server unexpectedly shutting down"); 93 debug("run", d); 94 } 95 throw d ; 96 } catch (OutOfMemoryError ome) { 97 if (isDebugOn()) { 98 debug("run", "Received OutOfMemory"); 99 } 100 yield(); 101 } catch (Error err) { 102 if (isDebugOn()) { 103 debug("run", "Received Internal error"); 104 debug("run", err); 105 } 106 } 107 } 108 } 109 110 111 114 boolean isTraceOn() { 115 return Trace.isSelected(Trace.LEVEL_TRACE, Trace.INFO_ADAPTOR_SNMP); 116 } 117 118 void trace(String clz, String func, String info) { 119 Trace.send(Trace.LEVEL_TRACE, Trace.INFO_ADAPTOR_SNMP, clz, func, info); 120 } 121 122 void trace(String func, String info) { 123 trace(dbgTag, func, info); 124 } 125 126 boolean isDebugOn() { 127 return Trace.isSelected(Trace.LEVEL_DEBUG, Trace.INFO_ADAPTOR_SNMP); 128 } 129 130 void debug(String clz, String func, String info) { 131 Trace.send(Trace.LEVEL_DEBUG, Trace.INFO_ADAPTOR_SNMP, clz, func, info); 132 } 133 134 void debug(String clz, String func, Throwable exception) { 135 Trace.send(Trace.LEVEL_DEBUG, Trace.INFO_ADAPTOR_SNMP, clz, func, exception); 136 } 137 138 void debug(String func, String info) { 139 debug(dbgTag, func, info); 140 } 141 142 void debug(String func, Throwable exception) { 143 debug(dbgTag, func, exception); 144 } 145 } 146 | Popular Tags |