Cleanup for EndPointBase
This commit is contained in:
parent
be399c44ea
commit
799b9db1ef
|
@ -31,7 +31,7 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import dorkbox.network.connection.EndPoint;
|
||||
import dorkbox.network.connection.Shutdownable;
|
||||
import dorkbox.network.dns.DnsQuestion;
|
||||
import dorkbox.network.dns.DnsResponse;
|
||||
import dorkbox.network.dns.constants.DnsRecordType;
|
||||
|
@ -71,7 +71,7 @@ import io.netty.util.internal.PlatformDependent;
|
|||
*/
|
||||
@SuppressWarnings({"unused", "WeakerAccess"})
|
||||
public
|
||||
class DnsClient extends EndPoint {
|
||||
class DnsClient extends Shutdownable {
|
||||
|
||||
/*
|
||||
* TODO: verify ResolverConfiguration works as expected!
|
||||
|
|
|
@ -2,8 +2,8 @@ package dorkbox.network;
|
|||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import dorkbox.network.connection.EndPoint;
|
||||
import dorkbox.network.connection.EndPointBase;
|
||||
import dorkbox.network.connection.Shutdownable;
|
||||
import dorkbox.network.dns.serverHandlers.DnsServerHandler;
|
||||
import dorkbox.util.NamedThreadFactory;
|
||||
import dorkbox.util.OS;
|
||||
|
@ -40,7 +40,7 @@ import io.netty.channel.socket.oio.OioServerSocketChannel;
|
|||
* large due to a large number of records.
|
||||
*/
|
||||
public
|
||||
class DnsServer extends EndPoint {
|
||||
class DnsServer extends Shutdownable {
|
||||
|
||||
/**
|
||||
* The maximum queue length for incoming connection indications (a request to connect). If a connection indication arrives when the
|
||||
|
|
|
@ -51,7 +51,7 @@ import io.netty.util.NetUtil;
|
|||
* represents the base of a client/server end point
|
||||
*/
|
||||
public abstract
|
||||
class EndPointBase extends EndPoint {
|
||||
class EndPointBase extends Shutdownable {
|
||||
// If TCP and UDP both fill the pipe, THERE WILL BE FRAGMENTATION and dropped UDP packets!
|
||||
// it results in severe UDP packet loss and contention.
|
||||
//
|
||||
|
@ -316,7 +316,7 @@ class EndPointBase extends EndPoint {
|
|||
* @return a new network connection
|
||||
*/
|
||||
protected
|
||||
ConnectionImpl newConnection(final Logger logger, final EndPointBase endPoint, final RmiBridge rmiBridge) {
|
||||
<E extends EndPointBase> ConnectionImpl newConnection(final Logger logger, final E endPoint, final RmiBridge rmiBridge) {
|
||||
return new ConnectionImpl(logger, endPoint, rmiBridge);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import io.netty.util.internal.PlatformDependent;
|
|||
* This is the highest level endpoint, for lifecycle support/management.
|
||||
*/
|
||||
public
|
||||
class EndPoint {
|
||||
class Shutdownable {
|
||||
static {
|
||||
//noinspection Duplicates
|
||||
try {
|
||||
|
@ -76,7 +76,7 @@ class EndPoint {
|
|||
|
||||
protected final ThreadGroup threadGroup;
|
||||
|
||||
protected final Class<? extends EndPoint> type;
|
||||
protected final Class<? extends Shutdownable> type;
|
||||
|
||||
protected final Object shutdownInProgress = new Object();
|
||||
private volatile boolean isShutdown = false;
|
||||
|
@ -93,7 +93,7 @@ class EndPoint {
|
|||
private AtomicBoolean stopCalled = new AtomicBoolean(false);
|
||||
|
||||
public
|
||||
EndPoint(final Class<? extends EndPoint> type) {
|
||||
Shutdownable(final Class<? extends Shutdownable> type) {
|
||||
this.type = type;
|
||||
|
||||
// setup the thread group to easily ID what the following threads belong to (and their spawned threads...)
|
||||
|
@ -111,8 +111,8 @@ class EndPoint {
|
|||
@Override
|
||||
public
|
||||
void run() {
|
||||
if (EndPoint.this.shouldShutdownHookRun()) {
|
||||
EndPoint.this.stop();
|
||||
if (Shutdownable.this.shouldShutdownHookRun()) {
|
||||
Shutdownable.this.stop();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -238,7 +238,7 @@ class EndPoint {
|
|||
@Override
|
||||
public
|
||||
void run() {
|
||||
EndPoint.this.stopInThread();
|
||||
Shutdownable.this.stopInThread();
|
||||
}
|
||||
});
|
||||
thread.setDaemon(false);
|
Loading…
Reference in New Issue
Block a user