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
-
-
Field Summary
Fields Modifier and Type Field Description static String
FILE_SUFFIX
static Duration
REFRESH_INTERVAL_SAFETY_MARGIN
static Duration
WATCH_SERVICE_POLL_INTERVAL
-
Constructor Summary
Constructors Constructor Description LocalHostDiscovery(int networkId, boolean watchEnabled, Duration leaseTime, Path path)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
channelInactive(io.netty.channel.ChannelHandlerContext ctx)
void
userEventTriggered(io.netty.channel.ChannelHandlerContext ctx, Object evt)
void
write(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, read
-
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelRead, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
-
-
-
-
Field Detail
-
REFRESH_INTERVAL_SAFETY_MARGIN
public static final Duration REFRESH_INTERVAL_SAFETY_MARGIN
-
WATCH_SERVICE_POLL_INTERVAL
public static final Duration WATCH_SERVICE_POLL_INTERVAL
-
FILE_SUFFIX
public static final String FILE_SUFFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
write
public void write(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise) throws Exception
- Specified by:
write
in interfaceio.netty.channel.ChannelOutboundHandler
- Overrides:
write
in classio.netty.channel.ChannelDuplexHandler
- Throws:
Exception
-
channelInactive
public void channelInactive(io.netty.channel.ChannelHandlerContext ctx)
- Specified by:
channelInactive
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelInactive
in classio.netty.channel.ChannelInboundHandlerAdapter
-
userEventTriggered
public void userEventTriggered(io.netty.channel.ChannelHandlerContext ctx, Object evt)
- Specified by:
userEventTriggered
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
userEventTriggered
in classio.netty.channel.ChannelInboundHandlerAdapter
-
-