Cleanup for EndPointBase

This commit is contained in:
nathan 2018-01-25 17:02:18 +01:00
parent be399c44ea
commit 799b9db1ef
4 changed files with 12 additions and 12 deletions

View File

@ -31,7 +31,7 @@ import java.util.concurrent.TimeUnit;
import org.slf4j.Logger; import org.slf4j.Logger;
import dorkbox.network.connection.EndPoint; import dorkbox.network.connection.Shutdownable;
import dorkbox.network.dns.DnsQuestion; import dorkbox.network.dns.DnsQuestion;
import dorkbox.network.dns.DnsResponse; import dorkbox.network.dns.DnsResponse;
import dorkbox.network.dns.constants.DnsRecordType; import dorkbox.network.dns.constants.DnsRecordType;
@ -71,7 +71,7 @@ import io.netty.util.internal.PlatformDependent;
*/ */
@SuppressWarnings({"unused", "WeakerAccess"}) @SuppressWarnings({"unused", "WeakerAccess"})
public public
class DnsClient extends EndPoint { class DnsClient extends Shutdownable {
/* /*
* TODO: verify ResolverConfiguration works as expected! * TODO: verify ResolverConfiguration works as expected!

View File

@ -2,8 +2,8 @@ package dorkbox.network;
import org.slf4j.Logger; import org.slf4j.Logger;
import dorkbox.network.connection.EndPoint;
import dorkbox.network.connection.EndPointBase; import dorkbox.network.connection.EndPointBase;
import dorkbox.network.connection.Shutdownable;
import dorkbox.network.dns.serverHandlers.DnsServerHandler; import dorkbox.network.dns.serverHandlers.DnsServerHandler;
import dorkbox.util.NamedThreadFactory; import dorkbox.util.NamedThreadFactory;
import dorkbox.util.OS; import dorkbox.util.OS;
@ -40,7 +40,7 @@ import io.netty.channel.socket.oio.OioServerSocketChannel;
* large due to a large number of records. * large due to a large number of records.
*/ */
public 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 * The maximum queue length for incoming connection indications (a request to connect). If a connection indication arrives when the

View File

@ -51,7 +51,7 @@ import io.netty.util.NetUtil;
* represents the base of a client/server end point * represents the base of a client/server end point
*/ */
public abstract 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! // 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. // it results in severe UDP packet loss and contention.
// //
@ -316,7 +316,7 @@ class EndPointBase extends EndPoint {
* @return a new network connection * @return a new network connection
*/ */
protected 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); return new ConnectionImpl(logger, endPoint, rmiBridge);
} }

View File

@ -23,7 +23,7 @@ import io.netty.util.internal.PlatformDependent;
* This is the highest level endpoint, for lifecycle support/management. * This is the highest level endpoint, for lifecycle support/management.
*/ */
public public
class EndPoint { class Shutdownable {
static { static {
//noinspection Duplicates //noinspection Duplicates
try { try {
@ -76,7 +76,7 @@ class EndPoint {
protected final ThreadGroup threadGroup; protected final ThreadGroup threadGroup;
protected final Class<? extends EndPoint> type; protected final Class<? extends Shutdownable> type;
protected final Object shutdownInProgress = new Object(); protected final Object shutdownInProgress = new Object();
private volatile boolean isShutdown = false; private volatile boolean isShutdown = false;
@ -93,7 +93,7 @@ class EndPoint {
private AtomicBoolean stopCalled = new AtomicBoolean(false); private AtomicBoolean stopCalled = new AtomicBoolean(false);
public public
EndPoint(final Class<? extends EndPoint> type) { Shutdownable(final Class<? extends Shutdownable> type) {
this.type = type; this.type = type;
// setup the thread group to easily ID what the following threads belong to (and their spawned threads...) // setup the thread group to easily ID what the following threads belong to (and their spawned threads...)
@ -111,8 +111,8 @@ class EndPoint {
@Override @Override
public public
void run() { void run() {
if (EndPoint.this.shouldShutdownHookRun()) { if (Shutdownable.this.shouldShutdownHookRun()) {
EndPoint.this.stop(); Shutdownable.this.stop();
} }
} }
}; };
@ -238,7 +238,7 @@ class EndPoint {
@Override @Override
public public
void run() { void run() {
EndPoint.this.stopInThread(); Shutdownable.this.stopInThread();
} }
}); });
thread.setDaemon(false); thread.setDaemon(false);