use of com.iplanet.am.util.ThreadPoolException in project OpenAM by OpenRock.
the class FileHandler method nonBlockingFlush.
/**
* Flush any buffered messages.
*/
protected void nonBlockingFlush() {
LinkedList writeBuffer = null;
synchronized (this) {
if (recordBuffer.size() <= 0) {
if (Debug.messageEnabled()) {
Debug.message(fileName + ":FileHandler.flush: no records in buffer to write");
}
return;
}
writeBuffer = recordBuffer;
recordBuffer = new LinkedList();
}
LogTask task = new LogTask(writeBuffer);
try {
// Get an instance as required otherwise it can cause issues on container restart.
LoggingThread.getInstance().run(task);
} catch (ThreadPoolException ex) {
// use current thread to flush the data if ThreadPool is shutdown
synchronized (this) {
task.run();
}
}
}
use of com.iplanet.am.util.ThreadPoolException in project OpenAM by OpenRock.
the class Session method run.
public void run() {
if (sessionPollerPool.isPollingEnabled()) {
try {
if (!getIsPolling()) {
long expectedTime;
if (willExpire(maxIdleTime)) {
expectedTime = (latestRefreshTime + (maxIdleTime * 60)) * 1000;
if (sessionPollerPool.getCacheBasedPolling()) {
expectedTime = Math.min(expectedTime, (latestRefreshTime + (maxCachingTime * 60)) * 1000);
}
} else {
expectedTime = (latestRefreshTime + (SessionMeta.getAppSSOTokenRefreshTime() * 60)) * 1000;
}
if (expectedTime > scheduledExecutionTime()) {
// Get an instance as required otherwise it causes issues on container restart.
SystemTimerPool.getTimerPool().schedule(this, new Date(expectedTime));
return;
}
if (sender == null) {
sender = new SessionPollerSender(this);
}
RestrictedTokenContext.doUsing(getContext(), new RestrictedTokenAction() {
public Object run() throws Exception {
try {
setIsPolling(true);
sessionPollerPool.getThreadPool().run(sender);
} catch (ThreadPoolException e) {
setIsPolling(false);
sessionDebug.error("Send Polling Error: ", e);
}
return null;
}
});
}
} catch (SessionException se) {
sessionCache.removeSID(sessionID);
sessionDebug.message("session is not in timeout state so clean it", se);
} catch (Exception ex) {
sessionDebug.error("Exception encountered while polling", ex);
}
} else {
String sessionRemovalDebugMessage;
if (purgeAt > 0) {
// destroyed session scheduled for purge
if (purgeAt > scheduledExecutionTime()) {
SystemTimerPool.getTimerPool().schedule(this, new Date(purgeAt));
return;
}
sessionRemovalDebugMessage = "Session Removed, Reduced Crosstalk Purge Time complete";
} else {
// schedule at the max session time
long expectedTime = -1;
if (willExpire(maxSessionTime)) {
expectedTime = (latestRefreshTime + (maxSessionTime * 60)) * 1000;
}
if (expectedTime > scheduledExecutionTime()) {
SystemTimerPool.getTimerPool().schedule(this, new Date(expectedTime));
return;
}
sessionRemovalDebugMessage = "Session Destroyed, Caching time exceeded the Max Session Time";
}
try {
sessionCache.removeSID(sessionID);
if (sessionDebug.messageEnabled()) {
sessionDebug.message(sessionRemovalDebugMessage);
}
} catch (Exception ex) {
sessionDebug.error("Exception occured while cleaning up Session Cache", ex);
}
}
}
use of com.iplanet.am.util.ThreadPoolException in project OpenAM by OpenRock.
the class RemoteHandler method nonBlockingFlush.
/**
* Copy the existing request set map and pass it on to ThreadPool as part
* of a FlushTask. Initiatize a new map as the new request set map for
* future remote logging calls.
*/
public synchronized void nonBlockingFlush() {
if (recCount <= 0) {
if (Debug.messageEnabled()) {
Debug.message("RemoteHandler.nonBlockingFlush(): no records " + "in buffer to send");
}
return;
}
FlushTask task = new FlushTask(reqSetMap);
try {
// Get an instance as required otherwise it can cause issues on container restart.
LoggingThread.getInstance().run(task);
} catch (ThreadPoolException ex) {
//execute it.
if (Debug.messageEnabled()) {
Debug.message("RemoteHandler.nonBlockingFlush(): ThreadPoolException" + ". Performing blocking flush.");
}
task.run();
}
this.recCount = 0;
reqSetMap = new HashMap();
}
Aggregations