java.lang.Object
org.newsclub.net.unix.tipc.AFTIPCTopologyWatcher
- All Implemented Interfaces:
Closeable
,AutoCloseable
Provides access to the TIPC topology service.
- Author:
- Christian Kohlschütter
-
Constructor Summary
ConstructorDescriptionCreates anAFTIPCTopologyWatcher
whose subscription requests do not time out by default.AFTIPCTopologyWatcher
(int defaultTimeoutSeconds) Creates anAFTIPCTopologyWatcher
whose subscription requests use the given default timeout. -
Method Summary
Modifier and TypeMethodDescriptionWatches for all link state changes.Watches for all port changes.addPortSubscription
(int port) Watches for port changes of the given port ("port" meaning TIPC port, not TCP).addPortSubscription
(int lower, int upper) Watches for port changes within the given range ("port" meaning TIPC port, not TCP).addServiceSubscription
(int type) Watches for service changes of the given service type, matching any instance.addServiceSubscription
(int type, int instance) Watches for service changes of the given service type, matching only the specified instance.addServiceSubscription
(int type, int lower, int upper) Watches for service changes of the given service type and instance range.final void
Cancels a previously added service subscription.final void
close()
Closes this instance.protected final void
finalize()
Deprecated.boolean
Checks if the watcher run loop is running.protected void
onClose()
Called uponclose()
.protected void
onEvent
(AFTIPCTopologyEvent event) Called for every event encountered by the run loop.final void
runLoop()
Runs a receive loop untilstopLoop()
orclose()
is called.Sends a manually crafted subscription message to the TIPC topology server.final void
stopLoop()
Stops the run loop.
-
Constructor Details
-
AFTIPCTopologyWatcher
Creates anAFTIPCTopologyWatcher
whose subscription requests do not time out by default.- Throws:
IOException
- on error.
-
AFTIPCTopologyWatcher
Creates anAFTIPCTopologyWatcher
whose subscription requests use the given default timeout.- Parameters:
defaultTimeoutSeconds
- The timeout in seconds (orAFTIPCTopologySubscription.TIPC_WAIT_FOREVER
;- Throws:
IOException
- on error.
-
-
Method Details
-
finalize
-
addPortSubscription
Watches for all port changes.- Returns:
- The subscription object.
- Throws:
IOException
- on error.- See Also:
-
addPortSubscription
Watches for port changes of the given port ("port" meaning TIPC port, not TCP).- Parameters:
port
- The port.- Returns:
- The subscription object.
- Throws:
IOException
- on error.- See Also:
-
addPortSubscription
public final AFTIPCTopologySubscription addPortSubscription(int lower, int upper) throws IOException Watches for port changes within the given range ("port" meaning TIPC port, not TCP).- Parameters:
lower
- The lower value of the port range.upper
- The upper value of the port range.- Returns:
- The subscription object.
- Throws:
IOException
- on error.- See Also:
-
addLinkStateSubscription
Watches for all link state changes.- Returns:
- The subscription object.
- Throws:
IOException
- on error.- See Also:
-
addServiceSubscription
Watches for service changes of the given service type, matching any instance.- Parameters:
type
- The service type.- Returns:
- The subscription object.
- Throws:
IOException
- on error.- See Also:
-
addServiceSubscription
public final AFTIPCTopologySubscription addServiceSubscription(int type, int instance) throws IOException Watches for service changes of the given service type, matching only the specified instance.- Parameters:
type
- The service type.instance
- The instance to match.- Returns:
- The subscription object.
- Throws:
IOException
- on error.- See Also:
-
addServiceSubscription
public final AFTIPCTopologySubscription addServiceSubscription(int type, int lower, int upper) throws IOException Watches for service changes of the given service type and instance range.- Parameters:
type
- The service type.lower
- The lower value of the instance range.upper
- The upper value of the instance range.- Returns:
- The subscription object.
- Throws:
IOException
- on error.- See Also:
-
cancelSubscription
Cancels a previously added service subscription.- Parameters:
sub
- The subscription to cancel.- Throws:
IOException
- on error.
-
sendMessage
public final AFTIPCTopologySubscription sendMessage(AFTIPCTopologySubscription sub) throws IOException Sends a manually crafted subscription message to the TIPC topology server. You usually don't need to do this directly; use the#addPortSubscription(int, int)
/cancelSubscription(AFTIPCTopologySubscription)
methods instead.- Parameters:
sub
- The subscription message.- Returns:
- The very message.
- Throws:
IOException
- on error.
-
runLoop
Runs a receive loop untilstopLoop()
orclose()
is called. This method returns after the run loop terminates.- Throws:
IOException
- on error.
-
onEvent
Called for every event encountered by the run loop.- Parameters:
event
- The event.- Throws:
IOException
- on error. Any exception will terminate the run loop.- See Also:
-
onClose
-
isRunning
public boolean isRunning()Checks if the watcher run loop is running.- Returns:
true
if running.- See Also:
-
stopLoop
public final void stopLoop()Stops the run loop. -
close
Closes this instance.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-