45 import java.util.concurrent.ThreadFactory; |
45 import java.util.concurrent.ThreadFactory; |
46 import java.util.concurrent.ThreadPoolExecutor; |
46 import java.util.concurrent.ThreadPoolExecutor; |
47 import java.util.concurrent.TimeUnit; |
47 import java.util.concurrent.TimeUnit; |
48 import java.util.concurrent.atomic.AtomicInteger; |
48 import java.util.concurrent.atomic.AtomicInteger; |
49 import java.util.concurrent.atomic.AtomicLong; |
49 import java.util.concurrent.atomic.AtomicLong; |
50 import java.util.logging.Level; |
50 import java.lang.System.Logger.Level; |
51 import javax.management.AttributeNotFoundException; |
51 import javax.management.AttributeNotFoundException; |
52 import javax.management.InstanceNotFoundException; |
52 import javax.management.InstanceNotFoundException; |
53 import javax.management.IntrospectionException; |
53 import javax.management.IntrospectionException; |
54 import javax.management.MBeanAttributeInfo; |
54 import javax.management.MBeanAttributeInfo; |
55 import javax.management.MBeanException; |
55 import javax.management.MBeanException; |
203 } else { |
203 } else { |
204 int maximumPoolSizeTmp = 10; |
204 int maximumPoolSizeTmp = 10; |
205 try { |
205 try { |
206 maximumPoolSizeTmp = Integer.parseInt(maximumPoolSizeStr); |
206 maximumPoolSizeTmp = Integer.parseInt(maximumPoolSizeStr); |
207 } catch (NumberFormatException e) { |
207 } catch (NumberFormatException e) { |
208 if (MONITOR_LOGGER.isLoggable(Level.FINER)) { |
208 if (MONITOR_LOGGER.isLoggable(Level.TRACE)) { |
209 MONITOR_LOGGER.logp(Level.FINER, Monitor.class.getName(), |
209 MONITOR_LOGGER.log(Level.TRACE, |
210 "<static initializer>", |
|
211 "Wrong value for " + maximumPoolSizeSysProp + |
210 "Wrong value for " + maximumPoolSizeSysProp + |
212 " system property", e); |
211 " system property", e); |
213 MONITOR_LOGGER.logp(Level.FINER, Monitor.class.getName(), |
212 MONITOR_LOGGER.log(Level.TRACE, |
214 "<static initializer>", |
|
215 maximumPoolSizeSysProp + " defaults to 10"); |
213 maximumPoolSizeSysProp + " defaults to 10"); |
216 } |
214 } |
217 maximumPoolSizeTmp = 10; |
215 maximumPoolSizeTmp = 10; |
218 } |
216 } |
219 if (maximumPoolSizeTmp < 1) { |
217 if (maximumPoolSizeTmp < 1) { |
1174 setAlreadyNotified(o, index, RUNTIME_ERROR_NOTIFIED, an); |
1164 setAlreadyNotified(o, index, RUNTIME_ERROR_NOTIFIED, an); |
1175 msg = |
1165 msg = |
1176 "The monitor must be registered in the MBean " + |
1166 "The monitor must be registered in the MBean " + |
1177 "server or an MBeanServerConnection must be " + |
1167 "server or an MBeanServerConnection must be " + |
1178 "explicitly supplied."; |
1168 "explicitly supplied."; |
1179 MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(), |
1169 MONITOR_LOGGER.log(Level.TRACE, msg); |
1180 "monitor", msg); |
1170 MONITOR_LOGGER.log(Level.TRACE, np_ex::toString); |
1181 MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(), |
|
1182 "monitor", np_ex.toString()); |
|
1183 } |
1171 } |
1184 } catch (InstanceNotFoundException inf_ex) { |
1172 } catch (InstanceNotFoundException inf_ex) { |
1185 if (isAlreadyNotified(o, OBSERVED_OBJECT_ERROR_NOTIFIED)) |
1173 if (isAlreadyNotified(o, OBSERVED_OBJECT_ERROR_NOTIFIED)) |
1186 return; |
1174 return; |
1187 else { |
1175 else { |
1189 setAlreadyNotified( |
1177 setAlreadyNotified( |
1190 o, index, OBSERVED_OBJECT_ERROR_NOTIFIED, an); |
1178 o, index, OBSERVED_OBJECT_ERROR_NOTIFIED, an); |
1191 msg = |
1179 msg = |
1192 "The observed object must be accessible in " + |
1180 "The observed object must be accessible in " + |
1193 "the MBeanServerConnection."; |
1181 "the MBeanServerConnection."; |
1194 MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(), |
1182 MONITOR_LOGGER.log(Level.TRACE, msg); |
1195 "monitor", msg); |
1183 MONITOR_LOGGER.log(Level.TRACE, inf_ex::toString); |
1196 MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(), |
|
1197 "monitor", inf_ex.toString()); |
|
1198 } |
1184 } |
1199 } catch (AttributeNotFoundException anf_ex) { |
1185 } catch (AttributeNotFoundException anf_ex) { |
1200 if (isAlreadyNotified(o, OBSERVED_ATTRIBUTE_ERROR_NOTIFIED)) |
1186 if (isAlreadyNotified(o, OBSERVED_ATTRIBUTE_ERROR_NOTIFIED)) |
1201 return; |
1187 return; |
1202 else { |
1188 else { |
1204 setAlreadyNotified( |
1190 setAlreadyNotified( |
1205 o, index, OBSERVED_ATTRIBUTE_ERROR_NOTIFIED, an); |
1191 o, index, OBSERVED_ATTRIBUTE_ERROR_NOTIFIED, an); |
1206 msg = |
1192 msg = |
1207 "The observed attribute must be accessible in " + |
1193 "The observed attribute must be accessible in " + |
1208 "the observed object."; |
1194 "the observed object."; |
1209 MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(), |
1195 MONITOR_LOGGER.log(Level.TRACE, msg); |
1210 "monitor", msg); |
1196 MONITOR_LOGGER.log(Level.TRACE, anf_ex::toString); |
1211 MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(), |
|
1212 "monitor", anf_ex.toString()); |
|
1213 } |
1197 } |
1214 } catch (MBeanException mb_ex) { |
1198 } catch (MBeanException mb_ex) { |
1215 if (isAlreadyNotified(o, RUNTIME_ERROR_NOTIFIED)) |
1199 if (isAlreadyNotified(o, RUNTIME_ERROR_NOTIFIED)) |
1216 return; |
1200 return; |
1217 else { |
1201 else { |
1218 notifType = RUNTIME_ERROR; |
1202 notifType = RUNTIME_ERROR; |
1219 setAlreadyNotified(o, index, RUNTIME_ERROR_NOTIFIED, an); |
1203 setAlreadyNotified(o, index, RUNTIME_ERROR_NOTIFIED, an); |
1220 msg = mb_ex.getMessage() == null ? "" : mb_ex.getMessage(); |
1204 msg = mb_ex.getMessage() == null ? "" : mb_ex.getMessage(); |
1221 MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(), |
1205 MONITOR_LOGGER.log(Level.TRACE, msg); |
1222 "monitor", msg); |
1206 MONITOR_LOGGER.log(Level.TRACE, mb_ex::toString); |
1223 MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(), |
|
1224 "monitor", mb_ex.toString()); |
|
1225 } |
1207 } |
1226 } catch (ReflectionException ref_ex) { |
1208 } catch (ReflectionException ref_ex) { |
1227 if (isAlreadyNotified(o, RUNTIME_ERROR_NOTIFIED)) { |
1209 if (isAlreadyNotified(o, RUNTIME_ERROR_NOTIFIED)) { |
1228 return; |
1210 return; |
1229 } else { |
1211 } else { |
1230 notifType = RUNTIME_ERROR; |
1212 notifType = RUNTIME_ERROR; |
1231 setAlreadyNotified(o, index, RUNTIME_ERROR_NOTIFIED, an); |
1213 setAlreadyNotified(o, index, RUNTIME_ERROR_NOTIFIED, an); |
1232 msg = ref_ex.getMessage() == null ? "" : ref_ex.getMessage(); |
1214 msg = ref_ex.getMessage() == null ? "" : ref_ex.getMessage(); |
1233 MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(), |
1215 MONITOR_LOGGER.log(Level.TRACE, msg); |
1234 "monitor", msg); |
1216 MONITOR_LOGGER.log(Level.TRACE, ref_ex::toString); |
1235 MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(), |
|
1236 "monitor", ref_ex.toString()); |
|
1237 } |
1217 } |
1238 } catch (IOException io_ex) { |
1218 } catch (IOException io_ex) { |
1239 if (isAlreadyNotified(o, RUNTIME_ERROR_NOTIFIED)) |
1219 if (isAlreadyNotified(o, RUNTIME_ERROR_NOTIFIED)) |
1240 return; |
1220 return; |
1241 else { |
1221 else { |
1242 notifType = RUNTIME_ERROR; |
1222 notifType = RUNTIME_ERROR; |
1243 setAlreadyNotified(o, index, RUNTIME_ERROR_NOTIFIED, an); |
1223 setAlreadyNotified(o, index, RUNTIME_ERROR_NOTIFIED, an); |
1244 msg = io_ex.getMessage() == null ? "" : io_ex.getMessage(); |
1224 msg = io_ex.getMessage() == null ? "" : io_ex.getMessage(); |
1245 MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(), |
1225 MONITOR_LOGGER.log(Level.TRACE, msg); |
1246 "monitor", msg); |
1226 MONITOR_LOGGER.log(Level.TRACE, io_ex::toString); |
1247 MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(), |
|
1248 "monitor", io_ex.toString()); |
|
1249 } |
1227 } |
1250 } catch (RuntimeException rt_ex) { |
1228 } catch (RuntimeException rt_ex) { |
1251 if (isAlreadyNotified(o, RUNTIME_ERROR_NOTIFIED)) |
1229 if (isAlreadyNotified(o, RUNTIME_ERROR_NOTIFIED)) |
1252 return; |
1230 return; |
1253 else { |
1231 else { |
1254 notifType = RUNTIME_ERROR; |
1232 notifType = RUNTIME_ERROR; |
1255 setAlreadyNotified(o, index, RUNTIME_ERROR_NOTIFIED, an); |
1233 setAlreadyNotified(o, index, RUNTIME_ERROR_NOTIFIED, an); |
1256 msg = rt_ex.getMessage() == null ? "" : rt_ex.getMessage(); |
1234 msg = rt_ex.getMessage() == null ? "" : rt_ex.getMessage(); |
1257 MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(), |
1235 MONITOR_LOGGER.log(Level.TRACE, msg); |
1258 "monitor", msg); |
1236 MONITOR_LOGGER.log(Level.TRACE, rt_ex::toString); |
1259 MONITOR_LOGGER.logp(Level.FINEST, Monitor.class.getName(), |
|
1260 "monitor", rt_ex.toString()); |
|
1261 } |
1237 } |
1262 } |
1238 } |
1263 |
1239 |
1264 synchronized (this) { |
1240 synchronized (this) { |
1265 |
1241 |
1295 setAlreadyNotified(o, index, |
1271 setAlreadyNotified(o, index, |
1296 OBSERVED_ATTRIBUTE_TYPE_ERROR_NOTIFIED, an); |
1272 OBSERVED_ATTRIBUTE_TYPE_ERROR_NOTIFIED, an); |
1297 msg = |
1273 msg = |
1298 "The observed attribute value does not " + |
1274 "The observed attribute value does not " + |
1299 "implement the Comparable interface."; |
1275 "implement the Comparable interface."; |
1300 MONITOR_LOGGER.logp(Level.FINEST, |
1276 MONITOR_LOGGER.log(Level.TRACE, msg); |
1301 Monitor.class.getName(), "monitor", msg); |
1277 MONITOR_LOGGER.log(Level.TRACE, e::toString); |
1302 MONITOR_LOGGER.logp(Level.FINEST, |
|
1303 Monitor.class.getName(), "monitor", e.toString()); |
|
1304 } |
1278 } |
1305 } catch (AttributeNotFoundException e) { |
1279 } catch (AttributeNotFoundException e) { |
1306 if (isAlreadyNotified(o, OBSERVED_ATTRIBUTE_ERROR_NOTIFIED)) |
1280 if (isAlreadyNotified(o, OBSERVED_ATTRIBUTE_ERROR_NOTIFIED)) |
1307 return; |
1281 return; |
1308 else { |
1282 else { |
1310 setAlreadyNotified( |
1284 setAlreadyNotified( |
1311 o, index, OBSERVED_ATTRIBUTE_ERROR_NOTIFIED, an); |
1285 o, index, OBSERVED_ATTRIBUTE_ERROR_NOTIFIED, an); |
1312 msg = |
1286 msg = |
1313 "The observed attribute must be accessible in " + |
1287 "The observed attribute must be accessible in " + |
1314 "the observed object."; |
1288 "the observed object."; |
1315 MONITOR_LOGGER.logp(Level.FINEST, |
1289 MONITOR_LOGGER.log(Level.TRACE, msg); |
1316 Monitor.class.getName(), "monitor", msg); |
1290 MONITOR_LOGGER.log(Level.TRACE, e::toString); |
1317 MONITOR_LOGGER.logp(Level.FINEST, |
|
1318 Monitor.class.getName(), "monitor", e.toString()); |
|
1319 } |
1291 } |
1320 } catch (RuntimeException e) { |
1292 } catch (RuntimeException e) { |
1321 if (isAlreadyNotified(o, RUNTIME_ERROR_NOTIFIED)) |
1293 if (isAlreadyNotified(o, RUNTIME_ERROR_NOTIFIED)) |
1322 return; |
1294 return; |
1323 else { |
1295 else { |
1324 notifType = RUNTIME_ERROR; |
1296 notifType = RUNTIME_ERROR; |
1325 setAlreadyNotified(o, index, |
1297 setAlreadyNotified(o, index, |
1326 RUNTIME_ERROR_NOTIFIED, an); |
1298 RUNTIME_ERROR_NOTIFIED, an); |
1327 msg = e.getMessage() == null ? "" : e.getMessage(); |
1299 msg = e.getMessage() == null ? "" : e.getMessage(); |
1328 MONITOR_LOGGER.logp(Level.FINEST, |
1300 MONITOR_LOGGER.log(Level.TRACE, msg); |
1329 Monitor.class.getName(), "monitor", msg); |
1301 MONITOR_LOGGER.log(Level.TRACE, e::toString); |
1330 MONITOR_LOGGER.logp(Level.FINEST, |
|
1331 Monitor.class.getName(), "monitor", e.toString()); |
|
1332 } |
1302 } |
1333 } |
1303 } |
1334 } |
1304 } |
1335 |
1305 |
1336 // Check that the observed attribute type is supported by this |
1306 // Check that the observed attribute type is supported by this |