Tone down logging for surprisingly large reduction in CPU usage - Closes #401

This commit is contained in:
md_5 2013-06-03 19:48:21 +10:00
parent ac5e8dbaff
commit fd411edddb
2 changed files with 18 additions and 3 deletions

View File

@ -10,6 +10,7 @@ import java.security.GeneralSecurityException;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level;
import javax.crypto.Cipher; import javax.crypto.Cipher;
import javax.crypto.SecretKey; import javax.crypto.SecretKey;
import lombok.Getter; import lombok.Getter;
@ -128,6 +129,9 @@ public class InitialHandler extends PacketHandler implements PendingConnection
public void handle(Packet2Handshake handshake) throws Exception public void handle(Packet2Handshake handshake) throws Exception
{ {
Preconditions.checkState( thisState == State.HANDSHAKE, "Not expecting HANDSHAKE" ); Preconditions.checkState( thisState == State.HANDSHAKE, "Not expecting HANDSHAKE" );
this.handshake = handshake;
bungee.getLogger().log( Level.INFO, "{0} has connected", this );
if ( handshake.getUsername().length() > 16 ) if ( handshake.getUsername().length() > 16 )
{ {
disconnect( "Cannot have username longer than 16 characters" ); disconnect( "Cannot have username longer than 16 characters" );
@ -148,7 +152,6 @@ public class InitialHandler extends PacketHandler implements PendingConnection
return; return;
} }
this.handshake = handshake;
unsafe().sendPacket( PacketConstants.I_AM_BUNGEE ); unsafe().sendPacket( PacketConstants.I_AM_BUNGEE );
unsafe().sendPacket( PacketConstants.FORGE_MOD_REQUEST ); unsafe().sendPacket( PacketConstants.FORGE_MOD_REQUEST );
unsafe().sendPacket( request = EncryptionUtil.encryptRequest() ); unsafe().sendPacket( request = EncryptionUtil.encryptRequest() );

View File

@ -6,8 +6,12 @@ import io.netty.channel.ChannelInboundMessageHandlerAdapter;
import io.netty.handler.timeout.ReadTimeoutException; import io.netty.handler.timeout.ReadTimeoutException;
import java.io.IOException; import java.io.IOException;
import java.util.logging.Level; import java.util.logging.Level;
import net.md_5.bungee.ServerConnector;
import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.connection.CancelSendSignal; import net.md_5.bungee.connection.CancelSendSignal;
import net.md_5.bungee.connection.DownstreamBridge;
import net.md_5.bungee.connection.InitialHandler;
import net.md_5.bungee.connection.UpstreamBridge;
/** /**
* This class is a primitive wrapper for {@link PacketHandler} instances tied to * This class is a primitive wrapper for {@link PacketHandler} instances tied to
@ -33,17 +37,25 @@ public class HandlerBoss extends ChannelInboundMessageHandlerAdapter<Object>
{ {
channel = new ChannelWrapper( ctx.channel() ); channel = new ChannelWrapper( ctx.channel() );
handler.connected( channel ); handler.connected( channel );
if ( !( handler instanceof InitialHandler ) )
{
ProxyServer.getInstance().getLogger().log( Level.INFO, "{0} has connected", handler ); ProxyServer.getInstance().getLogger().log( Level.INFO, "{0} has connected", handler );
} }
} }
}
@Override @Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception public void channelInactive(ChannelHandlerContext ctx) throws Exception
{ {
if ( handler != null ) if ( handler != null )
{ {
ProxyServer.getInstance().getLogger().log( Level.INFO, "{0} has disconnected", handler );
handler.disconnected( channel ); handler.disconnected( channel );
if ( !( handler instanceof InitialHandler ) )
{
ProxyServer.getInstance().getLogger().log( Level.INFO, "{0} has disconnected", handler );
}
} }
} }