Methods Summary |
---|
public void | addWork(com.sun.corba.se.spi.orbutil.threadpool.Work work)
synchronized (this) {
workItemsAdded++;
work.setEnqueueTime(System.currentTimeMillis());
theWorkQueue.addLast(work);
((ThreadPoolImpl)workerThreadPool).notifyForAvailableWork(this);
}
|
public synchronized long | averageTimeInQueue()
return (totalTimeInQueue/workItemsDequeued);
|
com.sun.corba.se.spi.monitoring.MonitoredObject | getMonitoredObject()
return workqueueMonitoredObject;
|
public java.lang.String | getName()
return name;
|
public com.sun.corba.se.spi.orbutil.threadpool.ThreadPool | getThreadPool()
return workerThreadPool;
|
private void | initializeMonitoring()
workqueueMonitoredObject = MonitoringFactories.
getMonitoredObjectFactory().
createMonitoredObject(name,
MonitoringConstants.WORKQUEUE_MONITORING_DESCRIPTION);
LongMonitoredAttributeBase b1 = new
LongMonitoredAttributeBase(MonitoringConstants.WORKQUEUE_TOTAL_WORK_ITEMS_ADDED,
MonitoringConstants.WORKQUEUE_TOTAL_WORK_ITEMS_ADDED_DESCRIPTION) {
public Object getValue() {
return new Long(WorkQueueImpl.this.totalWorkItemsAdded());
}
};
workqueueMonitoredObject.addAttribute(b1);
LongMonitoredAttributeBase b2 = new
LongMonitoredAttributeBase(MonitoringConstants.WORKQUEUE_WORK_ITEMS_IN_QUEUE,
MonitoringConstants.WORKQUEUE_WORK_ITEMS_IN_QUEUE_DESCRIPTION) {
public Object getValue() {
return new Long(WorkQueueImpl.this.workItemsInQueue());
}
};
workqueueMonitoredObject.addAttribute(b2);
LongMonitoredAttributeBase b3 = new
LongMonitoredAttributeBase(MonitoringConstants.WORKQUEUE_AVERAGE_TIME_IN_QUEUE,
MonitoringConstants.WORKQUEUE_AVERAGE_TIME_IN_QUEUE_DESCRIPTION) {
public Object getValue() {
return new Long(WorkQueueImpl.this.averageTimeInQueue());
}
};
workqueueMonitoredObject.addAttribute(b3);
|
com.sun.corba.se.spi.orbutil.threadpool.Work | requestWork(long waitTime)
Work workItem;
synchronized (this) {
if (theWorkQueue.size() != 0) {
workItem = (Work)theWorkQueue.removeFirst();
totalTimeInQueue += System.currentTimeMillis() - workItem.getEnqueueTime();
workItemsDequeued++;
return workItem;
}
try {
long remainingWaitTime = waitTime;
long finishTime = System.currentTimeMillis() + waitTime;
do {
this.wait(remainingWaitTime);
if (theWorkQueue.size() != 0) {
workItem = (Work)theWorkQueue.removeFirst();
totalTimeInQueue += System.currentTimeMillis() - workItem.getEnqueueTime();
workItemsDequeued++;
return workItem;
}
remainingWaitTime = finishTime - System.currentTimeMillis();
} while (remainingWaitTime > 0);
throw new TimeoutException();
} catch (InterruptedException ie) {
throw ie;
}
}
|
public void | setThreadPool(com.sun.corba.se.spi.orbutil.threadpool.ThreadPool workerThreadPool)
this.workerThreadPool = workerThreadPool;
|
public long | totalWorkItemsAdded()Returns the total number of Work items added to the Queue.
This method is unsynchronized and only gives a snapshot of the
state when it is called
return workItemsAdded;
|
public int | workItemsInQueue()Returns the total number of Work items in the Queue to be processed
This method is unsynchronized and only gives a snapshot of the
state when it is called
return theWorkQueue.size();
|