Skip to content

Commit

Permalink
Add debug to protocolfactory to see which instance of a protocol got …
Browse files Browse the repository at this point in the history
…a URL

Signed-off-by: Julien Nioche <[email protected]>
  • Loading branch information
jnioche committed Nov 29, 2023
1 parent 71cae46 commit 87145c3
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@
import java.util.HashMap;
import org.apache.commons.lang.StringUtils;
import org.apache.storm.Config;
import org.slf4j.LoggerFactory;

public class ProtocolFactory {

private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(ProtocolFactory.class);

private final HashMap<String, Protocol[]> cache = new HashMap<>();

private ProtocolFactory() {}
Expand Down Expand Up @@ -100,7 +103,9 @@ public synchronized Protocol getProtocol(URL url) {
// select client from pool
int hash = url.getHost().hashCode();
Protocol[] pool = cache.get(protocol);
return pool[(hash & Integer.MAX_VALUE) % pool.length];
int index = (hash & Integer.MAX_VALUE) % pool.length;
LOG.debug("Protocol instance {} returned for {}", index, url);
return pool[index];
}

/**
Expand Down

0 comments on commit 87145c3

Please sign in to comment.