Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove logger.fine statements #2793

Merged
merged 3 commits into from
Jan 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public class CompositeRouteFinder {
public CompositeRouteFinder(final GameMap map, final Map<Predicate<Territory>, Integer> matches) {
this.map = map;
this.matches = matches;
logger.finer("Initializing CompositeRouteFinderClass...");
}

Route findRoute(final Territory start, final Territory end) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
import java.lang.reflect.Proxy;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.logging.Level;
import java.util.logging.Logger;

import games.strategy.engine.GameOverException;
import games.strategy.engine.framework.headlessGameServer.HeadlessGameServer;
import games.strategy.engine.message.MessengerException;
import games.strategy.triplea.util.WrappedInvocationHandler;

Expand Down Expand Up @@ -57,38 +55,13 @@ public void setGameOver() {
* </p>
*/
public boolean blockDelegateExecution(final int timeToWaitMs) throws InterruptedException {
final boolean lockAcquired = readWriteLock.writeLock().tryLock(timeToWaitMs, TimeUnit.MILLISECONDS);
if (!lockAcquired) {
if (logger.isLoggable(Level.FINE)) {
logger.fine("Could not block delegate execution. Read Lock count: " + readWriteLock.getReadLockCount()
+ " Write Hold count: " + readWriteLock.getWriteHoldCount() + " Queue Length: "
+ readWriteLock.getQueueLength() + " Current Thread Has Lock: "
+ readWriteLock.isWriteLockedByCurrentThread() + " Has Queued Threads: "
+ readWriteLock.hasQueuedThreads() + " Is Write Locked: " + readWriteLock.isWriteLocked()
+ " toString: " + readWriteLock.toString());
} else {
HeadlessGameServer.log("Could not block delegate execution. Read Lock count: "
+ readWriteLock.getReadLockCount() + " Write Hold count: " + readWriteLock.getWriteHoldCount()
+ " Queue Length: " + readWriteLock.getQueueLength() + " Current Thread Has Lock: "
+ readWriteLock.isWriteLockedByCurrentThread() + " Has Queued Threads: "
+ readWriteLock.hasQueuedThreads() + " Is Write Locked: " + readWriteLock.isWriteLocked()
+ " toString: " + readWriteLock.toString());
}
} else {
if (logger.isLoggable(Level.FINE)) {
logger.fine(Thread.currentThread().getName() + " block delegate execution.");
}
}
return lockAcquired;
return readWriteLock.writeLock().tryLock(timeToWaitMs, TimeUnit.MILLISECONDS);
}

/**
* Allow delegate execution to resume.
*/
public void resumeDelegateExecution() {
if (logger.isLoggable(Level.FINE)) {
logger.fine(Thread.currentThread().getName() + " resumes delegate execution.");
}
readWriteLock.writeLock().unlock();
}

Expand Down Expand Up @@ -169,17 +142,11 @@ public Object invoke(final Object proxy, final Method method, final Object[] arg
}

public void leaveDelegateExecution() {
if (logger.isLoggable(Level.FINE)) {
logger.fine(Thread.currentThread().getName() + " leaves delegate execution.");
}
readWriteLock.readLock().unlock();
currentThreadHasReadLock.set(null);
}

public void enterDelegateExecution() {
if (logger.isLoggable(Level.FINE)) {
logger.fine(Thread.currentThread().getName() + " enters delegate execution.");
}
if (currentThreadHasReadLock()) {
throw new IllegalStateException("Already locked?");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ protected void launchInNewThread(final Component parent) {
}
try {
if (exceptionLoadingGame == null) {
logger.fine("Game starting");
game.startGame();
logger.fine("Game over");
}
} finally {
// todo(kg), this does not occur on the swing thread, and this notifies setupPanel observers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ protected void launchInNewThread(final Component parent) {
}
remoteMessenger.registerRemote(serverReady, ClientModel.CLIENT_READY_CHANNEL);
gameData.doPreGameStartDataModifications(playerListing);
logger.fine("Starting server");
abortLaunch = testShouldWeAbort();
final byte[] gameDataAsBytes = gameData.toBytes();
final Set<IGamePlayer> localPlayerSet =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ private static void assertCorrectHost(final GameDescription description, final I
public void updateGame(final GUID gameId, final GameDescription description) {
final INode from = MessageContext.getSender();
assertCorrectHost(description, from);
if (logger.isLoggable(Level.FINE)) {
logger.fine("Game updated:" + description);
}
synchronized (mutex) {
final GameDescription oldDescription = allGames.get(gameId);
// out of order updates
Expand Down Expand Up @@ -121,13 +118,10 @@ public String testGame(final GUID gameId) {
assertCorrectHost(description, from);
final int port = description.getPort();
final String host = description.getHostedBy().getAddress().getHostAddress();
logger.fine("Testing game connection on host:" + host + " port:" + port);
try (Socket s = new Socket()) {
s.connect(new InetSocketAddress(host, port), 10 * 1000);
logger.fine("Connection test passed for host:" + host + " port:" + port);
return null;
} catch (final IOException e) {
logger.fine("Connection test failed for host:" + host + " port:" + port + " reason:" + e.getMessage());
return "host:" + host + " " + " port:" + port;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ private static void removeBannedMac(final String mac) {
if (rs.next()) {
final Timestamp banTill = rs.getTimestamp(2);
if (banTill != null && banTill.toInstant().isBefore(now())) {
logger.fine("Ban expired for:" + mac);
removeBannedMac(mac);
return Tuple.of(false, banTill);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public class BannedUsernameController extends TimedController implements BannedU
@Override
public void addBannedUsername(final String username, final Instant banTill) {
if (banTill == null || banTill.isAfter(now())) {
logger.fine("Banning username:" + username);

try (Connection con = Database.getPostgresConnection();
PreparedStatement ps = con.prepareStatement("insert into banned_usernames (username, ban_till) values (?, ?)"
Expand All @@ -37,7 +36,6 @@ public void addBannedUsername(final String username, final Instant banTill) {
}

private static void removeBannedUsername(final String username) {
logger.fine("Removing banned username:" + username);

try (Connection con = Database.getPostgresConnection();
PreparedStatement ps = con.prepareStatement("delete from banned_usernames where username = ?")) {
Expand All @@ -64,7 +62,6 @@ public Tuple<Boolean, Timestamp> isUsernameBanned(final String username) {
if (rs.next()) {
final Timestamp banTill = rs.getTimestamp(2);
if (banTill != null && banTill.toInstant().isBefore(now())) {
logger.fine("Ban expired for:" + username);
removeBannedUsername(username);
return Tuple.of(false, banTill);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public class MutedMacController extends TimedController {
*/
public void addMutedMac(final String mac, final Instant muteTill) {
if (muteTill == null || muteTill.isAfter(now())) {
logger.fine("Muting mac:" + mac);

try (Connection con = Database.getPostgresConnection();
PreparedStatement ps = con.prepareStatement("insert into muted_macs (mac, mute_till) values (?, ?)"
Expand All @@ -42,7 +41,6 @@ public void addMutedMac(final String mac, final Instant muteTill) {
}

private static void removeMutedMac(final String mac) {
logger.fine("Removing muted mac:" + mac);

try (Connection con = Database.getPostgresConnection();
PreparedStatement ps = con.prepareStatement("delete from muted_macs where mac=?")) {
Expand Down Expand Up @@ -81,7 +79,6 @@ public Optional<Instant> getMacUnmuteTime(final String mac) {
}
final Instant expiration = muteTill.toInstant();
if (expiration.isBefore(now())) {
logger.fine("Mute expired for:" + mac);
// If the mute has expired, allow the mac
removeMutedMac(mac);
// Signal as not-muted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public class MutedUsernameController extends TimedController {
*/
public void addMutedUsername(final String username, final Instant muteTill) {
if (muteTill == null || muteTill.isAfter(now())) {
logger.fine("Muting username:" + username);

try (Connection con = Database.getPostgresConnection();
PreparedStatement ps = con.prepareStatement("insert into muted_usernames (username, mute_till) values (?, ?)"
Expand All @@ -42,7 +41,6 @@ public void addMutedUsername(final String username, final Instant muteTill) {
}

private static void removeMutedUsername(final String username) {
logger.fine("Removing muted username:" + username);

try (Connection con = Database.getPostgresConnection();
PreparedStatement ps = con.prepareStatement("delete from muted_usernames where username = ?")) {
Expand Down Expand Up @@ -82,7 +80,6 @@ public Optional<Instant> getUsernameUnmuteTime(final String username) {
final Instant expiration = muteTill.toInstant();
if (expiration.isBefore(now())) {
// If the mute has expired, allow the username
logger.fine("Mute expired for:" + username);
removeMutedUsername(username);
// Signal as not-muted
return Optional.empty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ public RemoteMethodCall(final String remoteName, final String methodName, final
this.args = args;
this.argTypes = classesToString(argTypes, args);
methodNumber = RemoteInterfaceHelper.getNumber(methodName, argTypes, remoteInterface);
if (logger.isLoggable(Level.FINE)) {
logger.fine("Remote Method Call:" + debugMethodText());
}
}

private String debugMethodText() {
Expand Down Expand Up @@ -185,8 +182,5 @@ public void resolve(final Class<?> remoteType) {
final Tuple<String, Class<?>[]> values = RemoteInterfaceHelper.getMethodInfo(methodNumber, remoteType);
methodName = values.getFirst();
argTypes = classesToString(values.getSecond(), args);
if (logger.isLoggable(Level.FINE)) {
logger.fine("Remote Method for class:" + remoteType.getSimpleName() + " Resolved To:" + debugMethodText());
}
}
}
9 changes: 0 additions & 9 deletions src/main/java/games/strategy/net/ServerMessenger.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,10 @@ public void send(final Serializable msg, final INode to) {
if (shutdown) {
return;
}
if (logger.isLoggable(Level.FINEST)) {
logger.log(Level.FINEST, "Sending" + msg + " to:" + to);
}
final MessageHeader header = new MessageHeader(to, node, msg);
final SocketChannel socketChannel = nodeToChannel.get(to);
// the socket was removed
if (socketChannel == null) {
if (logger.isLoggable(Level.FINER)) {
logger.log(Level.FINER, "no channel for node:" + to + " dropping message:" + msg);
}
// the socket has not been added yet
return;
}
Expand Down Expand Up @@ -685,9 +679,6 @@ public void socketError(final SocketChannel channel, final Exception error) {
public void socketUnqaurantined(final SocketChannel channel, final QuarantineConversation conversation) {
final ServerQuarantineConversation con = (ServerQuarantineConversation) conversation;
final INode remote = new Node(con.getRemoteName(), (InetSocketAddress) channel.socket().getRemoteSocketAddress());
if (logger.isLoggable(Level.FINER)) {
logger.log(Level.FINER, "Unquarntined node:" + remote);
}
nodeToChannel.put(remote, channel);
channelToNode.put(channel, remote);
notifyConnectionsChanged(true, remote);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ public Action message(final Object o) {
case READ_CHALLENGE:
// read name, send challenge
final Map<String, String> challenge = (Map<String, String>) o;
if (logger.isLoggable(Level.FINER)) {
logger.log(Level.FINER, "read challenge:" + challenge);
}
if (challenge != null) {
challengeProperties = challenge;
showLatch.countDown();
Expand All @@ -117,24 +114,15 @@ public Action message(final Object o) {
if (isClosed) {
return Action.NONE;
}
if (logger.isLoggable(Level.FINER)) {
logger.log(Level.FINER, "writing response" + challengeResponse);
}
send((Serializable) challengeResponse);
} else {
showLatch.countDown();
if (logger.isLoggable(Level.FINER)) {
logger.log(Level.FINER, "sending null response");
}
send(null);
}
step = Step.READ_ERROR;
return Action.NONE;
case READ_ERROR:
if (o != null) {
if (logger.isLoggable(Level.FINER)) {
logger.log(Level.FINER, "error:" + o);
}
errorMessage = (String) o;
// acknowledge the error
send(null);
Expand All @@ -144,9 +132,6 @@ public Action message(final Object o) {
return Action.NONE;
case READ_NAMES:
final String[] strings = ((String[]) o);
if (logger.isLoggable(Level.FINER)) {
logger.log(Level.FINER, "new local name:" + strings[0]);
}
localName = strings[0];
serverName = strings[1];
step = Step.READ_ADDRESS;
Expand All @@ -157,12 +142,6 @@ public Action message(final Object o) {
// this is the address the server thinks he is
networkVisibleAddress = address[0];
serverLocalAddress = address[1];
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "Server local address:" + serverLocalAddress);
logger.log(Level.FINE, "channel remote address:" + channel.socket().getRemoteSocketAddress());
logger.log(Level.FINE, "network visible address:" + networkVisibleAddress);
logger.log(Level.FINE, "channel local adresss:" + channel.socket().getLocalSocketAddress());
}
return Action.UNQUARANTINE;
default:
throw new IllegalStateException("Invalid state");
Expand Down
15 changes: 0 additions & 15 deletions src/main/java/games/strategy/net/nio/Decoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ private void loop() {
if (data == null || !running) {
continue;
}
if (logger.isLoggable(Level.FINEST)) {
logger.finest("Decoding packet:" + data);
}
try {
final MessageHeader header = IoUtils.readFromMemory(data.getData(), is -> {
try {
Expand All @@ -78,9 +75,6 @@ private void loop() {
throw new IOException(e);
}
});
if (logger.isLoggable(Level.FINEST)) {
logger.log(Level.FINEST, "header decoded:" + header);
}
// make sure we are still open
final Socket s = data.getChannel().socket();
if (!running || s == null || s.isInputShutdown()) {
Expand All @@ -96,9 +90,6 @@ private void loop() {
if (header.getFrom() == null) {
throw new IllegalArgumentException("Null from:" + header);
}
if (logger.isLoggable(Level.FINER)) {
logger.log(Level.FINER, "decoded msg:" + header.getMessage() + " size:" + data.size());
}
nioSocket.messageReceived(header, data.getChannel());
}
} catch (final Exception ioe) {
Expand All @@ -120,16 +111,10 @@ private void sendQuarantine(final SocketChannel channel, final QuarantineConvers
final MessageHeader header) {
final Action a = conversation.message(header.getMessage());
if (a == Action.TERMINATE) {
if (logger.isLoggable(Level.FINER)) {
logger.log(Level.FINER, "Terminating quarantined connection to:" + channel.socket().getRemoteSocketAddress());
}
conversation.close();
// we need to indicate the channel was closed
errorReporter.error(channel, new CouldNotLogInException());
} else if (a == Action.UNQUARANTINE) {
if (logger.isLoggable(Level.FINER)) {
logger.log(Level.FINER, "Accepting quarantined connection to:" + channel.socket().getRemoteSocketAddress());
}
nioSocket.unquarantine(channel, conversation);
quarantine.remove(channel);
}
Expand Down
6 changes: 0 additions & 6 deletions src/main/java/games/strategy/net/nio/Encoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ class Encoder {
}

void write(final SocketChannel to, final MessageHeader header) {
if (logger.isLoggable(Level.FINEST)) {
logger.log(Level.FINEST, "Encoding msg:" + header + " to:" + to);
}
if (header.getFrom() == null) {
throw new IllegalArgumentException("No from node");
}
Expand All @@ -40,9 +37,6 @@ void write(final SocketChannel to, final MessageHeader header) {
try {
final byte[] bytes = IoUtils.writeToMemory(os -> write(header, objectStreamFactory.create(os), to));
final SocketWriteData data = new SocketWriteData(bytes, bytes.length);
if (logger.isLoggable(Level.FINER)) {
logger.log(Level.FINER, "encoded msg:" + header.getMessage() + " size:" + data.size());
}
writer.enque(data, to);
} catch (final IOException e) {
// we arent doing any io, just writing in memory
Expand Down
Loading