Package com.tailf.ncs.alarmman.consumer
Class AlarmSource
Object
com.tailf.ncs.alarmman.consumer.AlarmSource
- All Implemented Interfaces:
 AutoCloseable
This class establishes a listener queue for emitted alarms. It requires the
 
AlarmSourceCentral to be started, which will submit the alarms to
 the queue- 
Constructor Summary
ConstructorsConstructorDescriptionUse the AlarmSourceCentral from the thread local NcsMain object.AlarmSource(AlarmSourceCentral sourceCentral) Use a specific AlarmSourceCentral. - 
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this alarm source by stopping the listening process.booleanChecks if this alarm source is currently listening for alarms.Retrieves an alarm, waiting if necessary until one becomes available within the specified timeout period.voidStarts listening for alarms by initializing the queue if not already active.voidStops listening for alarmsRetrieves or waiting if necessary until an Alarm becomes available. 
- 
Constructor Details
- 
AlarmSource
public AlarmSource()Use the AlarmSourceCentral from the thread local NcsMain object. - 
AlarmSource
Use a specific AlarmSourceCentral.- Parameters:
 sourceCentral- the alarm source central
 
 - 
 - 
Method Details
- 
takeAlarm
Retrieves or waiting if necessary until an Alarm becomes available.
Blocks the current thread indefinitely until the operation can succeed.
- Returns:
 - Alarm the next available alarm
 - Throws:
 InterruptedException- if interrupted while waiting
 - 
pollAlarm
Retrieves an alarm, waiting if necessary until one becomes available within the specified timeout period.- Parameters:
 time- the maximum time to waitunit- the time unit of the timeout parameter- Returns:
 - an alarm, or null if the timeout elapsed or not listening
 - Throws:
 InterruptedException- if interrupted while waiting
 - 
startListening
public void startListening()Starts listening for alarms by initializing the queue if not already active. - 
stopListening
public void stopListening()Stops listening for alarms - 
isListening
public boolean isListening()Checks if this alarm source is currently listening for alarms.- Returns:
 - true if listening, false otherwise
 
 - 
close
public void close()Closes this alarm source by stopping the listening process.- Specified by:
 closein interfaceAutoCloseable
 
 -