|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectorg.mbari.siam.core.DevicePacketAggregator
public class DevicePacketAggregator
DevicePacketAggregator implements two new method signatures of getDevicePackets() on behalf of the Node interface. These method signatures add the following capabilities to getDevicePackets
The second capability is implemented using threads. The calling method simply passes the request to a worker thread, and waits for the worker thread to signal that it's done. It uses Object.wait(timeout) to accomplish this, thus implementing the timeout function. To guard against the possibility that a "stuck" Instrument can block the entire system, we use a worker thread for each ISI ID. Thus a "stuck" Instrument can block later requests on that same Instrument, but will not block requests for a different Instrument.
This class implements ServiceListener. The reason is that we need to be notified when a user does a shutdownPort. In that case, we destroy the associated DevicePacketWorker. If the user then does a scanPort and later calls getDevicePackets() for that isiId, we'll generate a new worker with the new Device reference that resulted from the scanPort.
| Nested Class Summary | |
|---|---|
protected class |
DevicePacketAggregator.DeviceInstrumentSource
Implementation of DevicePacketSource that uses an Instrument as its packet source. |
protected class |
DevicePacketAggregator.DeviceLogSource
Implementation of DevicePacketSource that uses a FilteredDeviceLog as its packet source. |
class |
DevicePacketAggregator.DeviceLogTestSource
Implementation of DevicePacketSource used for testing with tests.Aggregator. |
protected class |
DevicePacketAggregator.DevicePacketRequest
Class representing one getDevicePackets() request and response |
static interface |
DevicePacketAggregator.DevicePacketSource
Interface class that defines a source of DevicePackets. |
protected class |
DevicePacketAggregator.DevicePacketWorker
Worker thread that actually fetches the DevicePacketSet data. |
| Field Summary | |
|---|---|
protected java.lang.String |
_directory
|
protected static org.apache.log4j.Logger |
_log4j
Log4j logger |
protected NodeService |
_node
|
protected long |
_testDelay
|
protected boolean |
_testing
|
protected java.util.Vector |
_workers
|
| Constructor Summary | |
|---|---|
DevicePacketAggregator(NodeService node)
Normal constructor when operating in SIAM |
|
DevicePacketAggregator(java.lang.String directory,
long delay)
Test constructor, used by tests.Aggregator |
|
| Method Summary | |
|---|---|
void |
exitWorkers()
Tell all DevicePacketWorkers to exit |
DevicePacketSet |
getDevicePackets(long isiId,
long startKey,
long endKey,
int numBytes,
int timeout)
Get a DevicePacketSet. |
DevicePacketSet |
getDevicePackets(long isiId,
long startKey,
long endKey,
int numBytes,
int typeMask,
int timeout)
Get a DevicePacketSet. |
protected DevicePacketAggregator.DevicePacketSource |
getDevicePacketSource(long deviceID)
Creates a DevicePacketSource for this deviceID |
protected DevicePacketAggregator.DevicePacketWorker |
getWorker(long isiId)
Find the DevicePacketWorker that is servicing this isiId. |
void |
serviceInstalled(ServiceEvent e)
serviceInstalled method for the ServiceListener interface. |
void |
serviceRemoved(ServiceEvent e)
serviceRemoved method for the ServiceListener interface. |
void |
serviceRequestComplete(ServiceEvent e)
serviceRequestComplete method for the ServiceListener interface. |
void |
serviceSampleLogged(LogSampleServiceEvent e)
serviceSampleLogged method for the ServiceListener interface. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static org.apache.log4j.Logger _log4j
protected java.util.Vector _workers
protected NodeService _node
protected boolean _testing
protected java.lang.String _directory
protected long _testDelay
| Constructor Detail |
|---|
public DevicePacketAggregator(NodeService node)
public DevicePacketAggregator(java.lang.String directory,
long delay)
| Method Detail |
|---|
public DevicePacketSet getDevicePackets(long isiId,
long startKey,
long endKey,
int numBytes,
int typeMask,
int timeout)
throws TimeoutException,
java.lang.IllegalArgumentException,
DeviceNotFound,
NoDataException
isiId - = Device idstartKey - = Earliest time (key) to requestendKey - = End time of requestnumBytes - = Requested size of DevicePacketSet, in bytestypeMask - = Mask to filter requested packets. See DevicePacket.timeout - = timeout in milliseconds
TimeoutException
java.lang.IllegalArgumentException
DeviceNotFound
NoDataException
public DevicePacketSet getDevicePackets(long isiId,
long startKey,
long endKey,
int numBytes,
int timeout)
throws TimeoutException,
java.lang.IllegalArgumentException,
DeviceNotFound,
NoDataException
isiId - = Device idstartKey - = Earliest time (key) to requestendKey - = End time of requestnumBytes - = Requested size of DevicePacketSet, in bytestimeout - = timeout in milliseconds
TimeoutException
java.lang.IllegalArgumentException
DeviceNotFound
NoDataException
protected DevicePacketAggregator.DevicePacketSource getDevicePacketSource(long deviceID)
throws DeviceNotFound,
NoDataException
DeviceNotFound
NoDataException
protected DevicePacketAggregator.DevicePacketWorker getWorker(long isiId)
throws DeviceNotFound,
NoDataException
DeviceNotFound
NoDataExceptionpublic void exitWorkers()
public void serviceInstalled(ServiceEvent e)
serviceInstalled in interface ServiceListenerpublic void serviceRemoved(ServiceEvent e)
serviceRemoved in interface ServiceListenerpublic void serviceRequestComplete(ServiceEvent e)
serviceRequestComplete in interface ServiceListenerpublic void serviceSampleLogged(LogSampleServiceEvent e)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||