Package org.drasyl.handler.remote
Class LocalHostDiscovery
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelDuplexHandler
org.drasyl.handler.remote.LocalHostDiscovery
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler,io.netty.channel.ChannelOutboundHandler
public class LocalHostDiscovery
extends io.netty.channel.ChannelDuplexHandler
Uses the file system to discover other drasyl nodes running on the local computer.
To do this, all nodes regularly write their UdpServer address(es) to the file system. At
the same time the file system is monitored to detect other nodes. If the file system does not
support monitoring (WatchService), a fallback to polling is used.
Inspired by: Jadex
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionLocalHostDiscovery(int networkId, boolean watchEnabled, InetAddress bindHost, Duration leaseTime, Path path) -
Method Summary
Modifier and TypeMethodDescriptionvoidchannelInactive(io.netty.channel.ChannelHandlerContext ctx) voiduserEventTriggered(io.netty.channel.ChannelHandlerContext ctx, Object evt) voidwrite(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise) Methods inherited from class io.netty.channel.ChannelDuplexHandler
bind, close, connect, deregister, disconnect, flush, readMethods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelRead, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaughtMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.netty.channel.ChannelHandler
handlerAdded, handlerRemoved
-
Field Details
-
REFRESH_INTERVAL_SAFETY_MARGIN
-
WATCH_SERVICE_POLL_INTERVAL
-
FILE_SUFFIX
- See Also:
-
-
Constructor Details
-
LocalHostDiscovery
public LocalHostDiscovery(int networkId, boolean watchEnabled, InetAddress bindHost, Duration leaseTime, Path path)
-
-
Method Details
-
write
public void write(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise) throws Exception - Specified by:
writein interfaceio.netty.channel.ChannelOutboundHandler- Overrides:
writein classio.netty.channel.ChannelDuplexHandler- Throws:
Exception
-
channelInactive
public void channelInactive(io.netty.channel.ChannelHandlerContext ctx) - Specified by:
channelInactivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelInactivein classio.netty.channel.ChannelInboundHandlerAdapter
-
userEventTriggered
- Specified by:
userEventTriggeredin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
userEventTriggeredin classio.netty.channel.ChannelInboundHandlerAdapter
-