diff --git a/src/main/java/org/araymond/joal/core/bandwith/BandwidthDispatcher.java b/src/main/java/org/araymond/joal/core/bandwith/BandwidthDispatcher.java index eed3d93..0984ba1 100644 --- a/src/main/java/org/araymond/joal/core/bandwith/BandwidthDispatcher.java +++ b/src/main/java/org/araymond/joal/core/bandwith/BandwidthDispatcher.java @@ -98,7 +98,7 @@ public class BandwidthDispatcher implements BandwidthDispatcherFacade, Runnable public void updateTorrentPeers(final InfoHash infoHash, final int seeders, final int leechers) { if (logger.isDebugEnabled()) { - logger.debug("Updating Peers stats for {}", infoHash.value()); + logger.debug("Updating Peers stats for {}", infoHash.humanReadableValue()); } this.lock.writeLock().lock(); try { @@ -111,7 +111,7 @@ public class BandwidthDispatcher implements BandwidthDispatcherFacade, Runnable public void registerTorrent(final InfoHash infoHash) { if (logger.isDebugEnabled()) { - logger.debug("{} has been added to bandwidth dispatcher.", infoHash.value()); + logger.debug("{} has been added to bandwidth dispatcher.", infoHash.humanReadableValue()); } this.lock.writeLock().lock(); try { @@ -124,7 +124,7 @@ public class BandwidthDispatcher implements BandwidthDispatcherFacade, Runnable public void unregisterTorrent(final InfoHash infoHash) { if (logger.isDebugEnabled()) { - logger.debug("{} has been removed from bandwidth dispatcher.", infoHash.value()); + logger.debug("{} has been removed from bandwidth dispatcher.", infoHash.humanReadableValue()); } this.lock.writeLock().lock(); try { diff --git a/src/main/java/org/araymond/joal/core/torrent/torrent/InfoHash.java b/src/main/java/org/araymond/joal/core/torrent/torrent/InfoHash.java index 553f1ec..97a9116 100644 --- a/src/main/java/org/araymond/joal/core/torrent/torrent/InfoHash.java +++ b/src/main/java/org/araymond/joal/core/torrent/torrent/InfoHash.java @@ -9,6 +9,10 @@ public class InfoHash { this.infoHash = new String(bytes, MockedTorrent.BYTE_ENCODING); } + public String humanReadableValue() { + return infoHash.replaceAll("\\p{C}", ""); + } + public String value() { return infoHash; } diff --git a/src/main/java/org/araymond/joal/core/ttorrent/client/announcer/request/Announcer.java b/src/main/java/org/araymond/joal/core/ttorrent/client/announcer/request/Announcer.java index 2728b3d..b88b2b5 100644 --- a/src/main/java/org/araymond/joal/core/ttorrent/client/announcer/request/Announcer.java +++ b/src/main/java/org/araymond/joal/core/ttorrent/client/announcer/request/Announcer.java @@ -27,7 +27,7 @@ public class Announcer { public SuccessAnnounceResponse announce(final RequestEvent event) throws AnnounceException, TooMuchAnnouncesFailedInARawException { if (logger.isDebugEnabled()) { - logger.debug("Attempt to announce {} for {}", event.getEventName(), this.torrent.getTorrentInfoHash().value()); + logger.debug("Attempt to announce {} for {}", event.getEventName(), this.torrent.getTorrentInfoHash().humanReadableValue()); } try { @@ -36,7 +36,7 @@ public class Announcer { this.announceDataAccessor.getHttpHeadersForTorrent() ); if (logger.isInfoEnabled()) { - logger.info("{} has announced successfully. Response: {} seeders, {} leechers, {}s interval", this.torrent.getTorrentInfoHash().value(), responseMessage.getSeeders(), responseMessage.getLeechers(), responseMessage.getInterval()); + logger.info("{} has announced successfully. Response: {} seeders, {} leechers, {}s interval", this.torrent.getTorrentInfoHash().humanReadableValue(), responseMessage.getSeeders(), responseMessage.getLeechers(), responseMessage.getInterval()); } this.consecutiveFails = 0; @@ -45,13 +45,13 @@ public class Announcer { return responseMessage; } catch (final AnnounceException e) { if (logger.isWarnEnabled()) { - logger.warn("{} has failed to announce", this.torrent.getTorrentInfoHash().value(), e); + logger.warn("{} has failed to announce", this.torrent.getTorrentInfoHash().humanReadableValue(), e); } ++this.consecutiveFails; if (this.consecutiveFails == 5) { if (logger.isInfoEnabled()) { - logger.info("{} has failed to announce 5 times in a raw", this.torrent.getTorrentInfoHash().value()); + logger.info("{} has failed to announce 5 times in a raw", this.torrent.getTorrentInfoHash().humanReadableValue()); } throw new TooMuchAnnouncesFailedInARawException(torrent); } diff --git a/src/main/java/org/araymond/joal/core/ttorrent/client/announcer/response/AnnounceEventPublisher.java b/src/main/java/org/araymond/joal/core/ttorrent/client/announcer/response/AnnounceEventPublisher.java index 29ee657..d22df55 100644 --- a/src/main/java/org/araymond/joal/core/ttorrent/client/announcer/response/AnnounceEventPublisher.java +++ b/src/main/java/org/araymond/joal/core/ttorrent/client/announcer/response/AnnounceEventPublisher.java @@ -24,7 +24,7 @@ public class AnnounceEventPublisher implements AnnounceResponseHandlerChainEleme @Override public void onAnnouncerWillAnnounce(final Announcer announcer) { if(logger.isDebugEnabled()) { - logger.debug("Publish WillAnnounceEvent event for {}.", announcer.getTorrentInfoHash().value()); + logger.debug("Publish WillAnnounceEvent event for {}.", announcer.getTorrentInfoHash().humanReadableValue()); } final InfoHash infoHash = announcer.getTorrentInfoHash(); this.eventPublisher.publishEvent(new WillAnnounceEvent(infoHash)); @@ -33,7 +33,7 @@ public class AnnounceEventPublisher implements AnnounceResponseHandlerChainEleme @Override public void onAnnounceStartSuccess(final Announcer announcer, final SuccessAnnounceResponse result) { if(logger.isDebugEnabled()) { - logger.debug("Publish SuccessfullyAnnounceEvent event for {}.", announcer.getTorrentInfoHash().value()); + logger.debug("Publish SuccessfullyAnnounceEvent event for {}.", announcer.getTorrentInfoHash().humanReadableValue()); } final InfoHash infoHash = announcer.getTorrentInfoHash(); final int interval = result.getInterval(); @@ -43,7 +43,7 @@ public class AnnounceEventPublisher implements AnnounceResponseHandlerChainEleme @Override public void onAnnounceStartFails(final Announcer announcer, final Throwable throwable) { if(logger.isDebugEnabled()) { - logger.debug("Publish FailedToAnnounceEvent event for {}.", announcer.getTorrentInfoHash().value()); + logger.debug("Publish FailedToAnnounceEvent event for {}.", announcer.getTorrentInfoHash().humanReadableValue()); } final InfoHash infoHash = announcer.getTorrentInfoHash(); final int interval = announcer.getLastKnownInterval(); @@ -53,7 +53,7 @@ public class AnnounceEventPublisher implements AnnounceResponseHandlerChainEleme @Override public void onAnnounceRegularSuccess(final Announcer announcer, final SuccessAnnounceResponse result) { if(logger.isDebugEnabled()) { - logger.debug("Publish SuccessfullyAnnounceEvent event for {}.", announcer.getTorrentInfoHash().value()); + logger.debug("Publish SuccessfullyAnnounceEvent event for {}.", announcer.getTorrentInfoHash().humanReadableValue()); } final InfoHash infoHash = announcer.getTorrentInfoHash(); final int interval = result.getInterval(); @@ -63,7 +63,7 @@ public class AnnounceEventPublisher implements AnnounceResponseHandlerChainEleme @Override public void onAnnounceRegularFails(final Announcer announcer, final Throwable throwable) { if(logger.isDebugEnabled()) { - logger.debug("Publish FailedToAnnounceEvent event for {}.", announcer.getTorrentInfoHash().value()); + logger.debug("Publish FailedToAnnounceEvent event for {}.", announcer.getTorrentInfoHash().humanReadableValue()); } final InfoHash infoHash = announcer.getTorrentInfoHash(); final int interval = announcer.getLastKnownInterval(); @@ -73,7 +73,7 @@ public class AnnounceEventPublisher implements AnnounceResponseHandlerChainEleme @Override public void onAnnounceStopSuccess(final Announcer announcer, final SuccessAnnounceResponse result) { if(logger.isDebugEnabled()) { - logger.debug("Publish SuccessfullyAnnounceEvent event for {}.", announcer.getTorrentInfoHash().value()); + logger.debug("Publish SuccessfullyAnnounceEvent event for {}.", announcer.getTorrentInfoHash().humanReadableValue()); } final InfoHash infoHash = announcer.getTorrentInfoHash(); this.eventPublisher.publishEvent(new SuccessfullyAnnounceEvent(infoHash, 0)); @@ -82,7 +82,7 @@ public class AnnounceEventPublisher implements AnnounceResponseHandlerChainEleme @Override public void onAnnounceStopFails(final Announcer announcer, final Throwable throwable) { if(logger.isDebugEnabled()) { - logger.debug("Publish FailedToAnnounceEvent event for {}.", announcer.getTorrentInfoHash().value()); + logger.debug("Publish FailedToAnnounceEvent event for {}.", announcer.getTorrentInfoHash().humanReadableValue()); } final InfoHash infoHash = announcer.getTorrentInfoHash(); this.eventPublisher.publishEvent(new FailedToAnnounceEvent(infoHash, 0)); @@ -91,7 +91,7 @@ public class AnnounceEventPublisher implements AnnounceResponseHandlerChainEleme @Override public void onTooManyAnnounceFailedInARaw(final Announcer announcer, final TooMuchAnnouncesFailedInARawException e) { if(logger.isDebugEnabled()) { - logger.debug("Publish TooManyAnnouncesFailedEvent event for {}.", announcer.getTorrentInfoHash().value()); + logger.debug("Publish TooManyAnnouncesFailedEvent event for {}.", announcer.getTorrentInfoHash().humanReadableValue()); } final InfoHash infoHash = announcer.getTorrentInfoHash(); this.eventPublisher.publishEvent(new TooManyAnnouncesFailedEvent(infoHash)); diff --git a/src/main/java/org/araymond/joal/core/ttorrent/client/announcer/response/AnnounceReEnqueuer.java b/src/main/java/org/araymond/joal/core/ttorrent/client/announcer/response/AnnounceReEnqueuer.java index 8831e4d..a339312 100644 --- a/src/main/java/org/araymond/joal/core/ttorrent/client/announcer/response/AnnounceReEnqueuer.java +++ b/src/main/java/org/araymond/joal/core/ttorrent/client/announcer/response/AnnounceReEnqueuer.java @@ -27,7 +27,7 @@ public class AnnounceReEnqueuer implements AnnounceResponseHandlerChainElement { @Override public void onAnnounceStartSuccess(final Announcer announcer, final SuccessAnnounceResponse result) { if (logger.isDebugEnabled()) { - logger.debug("Enqueue torrent {} in regular queue.", announcer.getTorrentInfoHash().value()); + logger.debug("Enqueue torrent {} in regular queue.", announcer.getTorrentInfoHash().humanReadableValue()); } this.delayQueue.addOrReplace(AnnounceRequest.createRegular(announcer), result.getInterval(), ChronoUnit.SECONDS); } @@ -35,7 +35,7 @@ public class AnnounceReEnqueuer implements AnnounceResponseHandlerChainElement { @Override public void onAnnounceStartFails(final Announcer announcer, final Throwable throwable) { if (logger.isDebugEnabled()) { - logger.debug("Enqueue torrent {} in start queue once again (because it failed).", announcer.getTorrentInfoHash().value()); + logger.debug("Enqueue torrent {} in start queue once again (because it failed).", announcer.getTorrentInfoHash().humanReadableValue()); } this.delayQueue.addOrReplace(AnnounceRequest.createStart(announcer), 5, ChronoUnit.SECONDS); } @@ -43,7 +43,7 @@ public class AnnounceReEnqueuer implements AnnounceResponseHandlerChainElement { @Override public void onAnnounceRegularSuccess(final Announcer announcer, final SuccessAnnounceResponse result) { if (logger.isDebugEnabled()) { - logger.debug("Enqueue torrent {} in regular queue.", announcer.getTorrentInfoHash().value()); + logger.debug("Enqueue torrent {} in regular queue.", announcer.getTorrentInfoHash().humanReadableValue()); } this.delayQueue.addOrReplace(AnnounceRequest.createRegular(announcer), result.getInterval(), ChronoUnit.SECONDS); } @@ -51,7 +51,7 @@ public class AnnounceReEnqueuer implements AnnounceResponseHandlerChainElement { @Override public void onAnnounceRegularFails(final Announcer announcer, final Throwable throwable) { if (logger.isDebugEnabled()) { - logger.debug("Enqueue torrent {} in regular queue once again (because it failed).", announcer.getTorrentInfoHash().value()); + logger.debug("Enqueue torrent {} in regular queue once again (because it failed).", announcer.getTorrentInfoHash().humanReadableValue()); } this.delayQueue.addOrReplace(AnnounceRequest.createRegular(announcer), announcer.getLastKnownInterval(), ChronoUnit.SECONDS); } @@ -63,7 +63,7 @@ public class AnnounceReEnqueuer implements AnnounceResponseHandlerChainElement { @Override public void onAnnounceStopFails(final Announcer announcer, final Throwable throwable) { if (logger.isDebugEnabled()) { - logger.debug("Enqueue torrent {} in stop queue once again (because it failed).", announcer.getTorrentInfoHash().value()); + logger.debug("Enqueue torrent {} in stop queue once again (because it failed).", announcer.getTorrentInfoHash().humanReadableValue()); } this.delayQueue.addOrReplace(AnnounceRequest.createStop(announcer), 0, ChronoUnit.SECONDS); } diff --git a/src/main/java/org/araymond/joal/core/ttorrent/client/announcer/response/BandwidthDispatcherNotifier.java b/src/main/java/org/araymond/joal/core/ttorrent/client/announcer/response/BandwidthDispatcherNotifier.java index d91c668..e02cc4c 100644 --- a/src/main/java/org/araymond/joal/core/ttorrent/client/announcer/response/BandwidthDispatcherNotifier.java +++ b/src/main/java/org/araymond/joal/core/ttorrent/client/announcer/response/BandwidthDispatcherNotifier.java @@ -24,7 +24,7 @@ public class BandwidthDispatcherNotifier implements AnnounceResponseHandlerChain @Override public void onAnnounceStartSuccess(final Announcer announcer, final SuccessAnnounceResponse result) { if(logger.isDebugEnabled()) { - logger.debug("Register {} in bandwidth dispatcher and update stats.", announcer.getTorrentInfoHash().value()); + logger.debug("Register {} in bandwidth dispatcher and update stats.", announcer.getTorrentInfoHash().humanReadableValue()); } final InfoHash infoHash = announcer.getTorrentInfoHash(); this.bandwidthDispatcher.registerTorrent(infoHash); @@ -38,7 +38,7 @@ public class BandwidthDispatcherNotifier implements AnnounceResponseHandlerChain @Override public void onAnnounceRegularSuccess(final Announcer announcer, final SuccessAnnounceResponse result) { if(logger.isDebugEnabled()) { - logger.debug("Update {} stats in bandwidth dispatcher.", announcer.getTorrentInfoHash().value()); + logger.debug("Update {} stats in bandwidth dispatcher.", announcer.getTorrentInfoHash().humanReadableValue()); } final InfoHash infoHash = announcer.getTorrentInfoHash(); this.bandwidthDispatcher.updateTorrentPeers(infoHash, result.getSeeders(), result.getLeechers()); @@ -51,7 +51,7 @@ public class BandwidthDispatcherNotifier implements AnnounceResponseHandlerChain @Override public void onAnnounceStopSuccess(final Announcer announcer, final SuccessAnnounceResponse result) { if(logger.isDebugEnabled()) { - logger.debug("Unregister {} from bandwidth dispatcher.", announcer.getTorrentInfoHash().value()); + logger.debug("Unregister {} from bandwidth dispatcher.", announcer.getTorrentInfoHash().humanReadableValue()); } this.bandwidthDispatcher.unregisterTorrent(announcer.getTorrentInfoHash()); } @@ -63,7 +63,7 @@ public class BandwidthDispatcherNotifier implements AnnounceResponseHandlerChain @Override public void onTooManyAnnounceFailedInARaw(final Announcer announcer, final TooMuchAnnouncesFailedInARawException e) { if(logger.isDebugEnabled()) { - logger.debug("Unregister {} from bandwidth dispatcher.", announcer.getTorrentInfoHash().value()); + logger.debug("Unregister {} from bandwidth dispatcher.", announcer.getTorrentInfoHash().humanReadableValue()); } this.bandwidthDispatcher.unregisterTorrent(announcer.getTorrentInfoHash()); }