mirror of
https://github.com/anthonyraymond/joal.git
synced 2024-09-20 15:26:25 +08:00
Indent and unsused imports
This commit is contained in:
parent
5607766302
commit
94e7436434
|
@ -1,11 +1,6 @@
|
|||
package org.araymond.joal.core.events.announce;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.araymond.joal.core.ttorent.client.announce.AnnounceResult;
|
||||
import org.araymond.joal.core.ttorent.client.announce.Announcer;
|
||||
import org.araymond.joal.core.ttorent.client.bandwidth.TorrentWithStats;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Created by raymo on 22/05/2017.
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
package org.araymond.joal.core.events.announce;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.turn.ttorrent.common.protocol.TrackerMessage.AnnounceRequestMessage.RequestEvent;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.araymond.joal.core.ttorent.client.announce.AnnounceResult;
|
||||
import org.araymond.joal.core.ttorent.client.announce.Announcer;
|
||||
import org.araymond.joal.core.ttorent.client.bandwidth.TorrentWithStats;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Created by raymo on 22/05/2017.
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package org.araymond.joal.core.events.announce;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.araymond.joal.core.ttorent.client.announce.Announcer;
|
||||
import org.araymond.joal.core.ttorent.client.bandwidth.TorrentWithStats;
|
||||
|
||||
/**
|
||||
* Created by raymo on 22/05/2017.
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package org.araymond.joal.core.events.announce;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.araymond.joal.core.ttorent.client.announce.Announcer;
|
||||
import org.araymond.joal.core.ttorent.client.bandwidth.TorrentWithStats;
|
||||
|
||||
/**
|
||||
* Created by raymo on 22/05/2017.
|
||||
|
|
|
@ -3,7 +3,6 @@ package org.araymond.joal.core.events.announce;
|
|||
import com.google.common.base.Preconditions;
|
||||
import com.turn.ttorrent.common.protocol.TrackerMessage.AnnounceRequestMessage.RequestEvent;
|
||||
import org.araymond.joal.core.ttorent.client.announce.Announcer;
|
||||
import org.araymond.joal.core.ttorent.client.bandwidth.TorrentWithStats;
|
||||
|
||||
/**
|
||||
* Created by raymo on 22/05/2017.
|
||||
|
|
|
@ -164,7 +164,7 @@ public class Client implements AnnouncerEventListener, TorrentFileChangeAware {
|
|||
|
||||
publisher.publishEvent(new AnnouncerHasStoppedEvent(announcer));
|
||||
|
||||
if (this.currentState!= ClientState.STOPPING && this.currentState != ClientState.STOPPED) {
|
||||
if (this.currentState != ClientState.STOPPING && this.currentState != ClientState.STOPPED) {
|
||||
try {
|
||||
addSeedingTorrent();
|
||||
} catch (final NoMoreTorrentsFileAvailableException e) {
|
||||
|
|
|
@ -17,7 +17,7 @@ public interface AnnounceResponseListener extends EventListener {
|
|||
* Handle the discovery of new peers.
|
||||
*
|
||||
* @param peers The list of peers discovered (from the announce response or
|
||||
* any other means like DHT/PEX, etc.).
|
||||
* any other means like DHT/PEX, etc.).
|
||||
*/
|
||||
void handleDiscoveredPeers(final TorrentWithStats torrent, final List<Peer> peers);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.araymond.joal.core.ttorent.client.announce;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.araymond.joal.core.ttorent.client.bandwidth.TorrentWithStats;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
|
|
|
@ -20,7 +20,8 @@ import java.net.UnknownServiceException;
|
|||
import java.util.*;
|
||||
|
||||
import static com.turn.ttorrent.common.protocol.TrackerMessage.AnnounceRequestMessage;
|
||||
import static org.araymond.joal.core.ttorent.client.announce.AnnounceResult.*;
|
||||
import static org.araymond.joal.core.ttorent.client.announce.AnnounceResult.ErrorAnnounceResult;
|
||||
import static org.araymond.joal.core.ttorent.client.announce.AnnounceResult.SuccessAnnounceResult;
|
||||
|
||||
/**
|
||||
* Created by raymo on 23/01/2017.
|
||||
|
|
|
@ -78,8 +78,8 @@ public abstract class TrackerClient {
|
|||
* with the decoded payload.
|
||||
* </p>
|
||||
*
|
||||
* @param event The announce event type (can be AnnounceEvent.NONE for
|
||||
* periodic updates).
|
||||
* @param event The announce event type (can be AnnounceEvent.NONE for
|
||||
* periodic updates).
|
||||
*/
|
||||
public final void announce(final AnnounceRequestMessage.RequestEvent event) throws AnnounceException {
|
||||
logger.debug("Announcing {} to tracker with {}U/{}D/{}L bytes...",
|
||||
|
@ -125,7 +125,7 @@ public abstract class TrackerClient {
|
|||
* listeners.
|
||||
* </p>
|
||||
*
|
||||
* @param message The incoming {@link TrackerMessage}.
|
||||
* @param message The incoming {@link TrackerMessage}.
|
||||
*/
|
||||
protected void handleTrackerAnnounceResponse(final TrackerMessage message) throws AnnounceException {
|
||||
if (message instanceof ErrorMessage) {
|
||||
|
|
|
@ -129,7 +129,7 @@ public class BandwidthDispatcher implements AnnouncerEventListener, Runnable {
|
|||
lock.readLock().lock();
|
||||
|
||||
final int torrentCount = this.torrents.size();
|
||||
for (final TorrentWithStats torrent: this.torrents) {
|
||||
for (final TorrentWithStats torrent : this.torrents) {
|
||||
final long uploadRateInBytesForTorrent = torrent.getCurrentRandomSpeedInBytes() / torrentCount;
|
||||
|
||||
torrent.addUploaded(uploadRateInBytesForTorrent * updateInterval / 1000);
|
||||
|
|
|
@ -13,7 +13,7 @@ public class JacksonConfig {
|
|||
|
||||
@Bean
|
||||
public Jackson2ObjectMapperBuilder objectMapperBuilder() {
|
||||
return new Jackson2ObjectMapperBuilder()
|
||||
return new Jackson2ObjectMapperBuilder()
|
||||
.featuresToDisable(
|
||||
SerializationFeature.WRITE_DATES_AS_TIMESTAMPS
|
||||
)
|
||||
|
|
|
@ -35,6 +35,7 @@ public enum StompMessageTypes {
|
|||
static StompMessageTypes typeFor(final MessagePayload payload) {
|
||||
return typeFor(payload.getClass());
|
||||
}
|
||||
|
||||
static StompMessageTypes typeFor(final Class<? extends MessagePayload> clazz) {
|
||||
final StompMessageTypes type = classToType.get(clazz);
|
||||
if (type == null) {
|
||||
|
|
|
@ -3,8 +3,6 @@ package org.araymond.joal.web.messages.outgoing.impl.announce;
|
|||
import com.google.common.base.Preconditions;
|
||||
import org.araymond.joal.core.events.announce.AnnouncerEvent;
|
||||
import org.araymond.joal.core.ttorent.client.announce.AnnounceResult;
|
||||
import org.araymond.joal.core.ttorent.client.announce.Announcer;
|
||||
import org.araymond.joal.core.ttorent.client.bandwidth.TorrentWithStats;
|
||||
import org.araymond.joal.web.messages.outgoing.MessagePayload;
|
||||
|
||||
import java.util.Collection;
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
package org.araymond.joal.web.messages.outgoing.impl.announce;
|
||||
|
||||
import org.araymond.joal.core.events.announce.AnnouncerHasAnnouncedEvent;
|
||||
import org.araymond.joal.core.ttorent.client.announce.AnnounceResult;
|
||||
import org.araymond.joal.core.ttorent.client.bandwidth.TorrentWithStats;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Created by raymo on 25/06/2017.
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
package org.araymond.joal.web.messages.outgoing.impl.announce;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.araymond.joal.core.events.announce.AnnouncerHasFailedToAnnounceEvent;
|
||||
import org.araymond.joal.core.ttorent.client.announce.AnnounceResult;
|
||||
import org.araymond.joal.core.ttorent.client.bandwidth.TorrentWithStats;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Created by raymo on 25/06/2017.
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.araymond.joal.web.messages.outgoing.impl.announce;
|
||||
|
||||
import org.araymond.joal.core.events.announce.AnnouncerHasStartedEvent;
|
||||
import org.araymond.joal.core.ttorent.client.bandwidth.TorrentWithStats;
|
||||
|
||||
/**
|
||||
* Created by raymo on 25/06/2017.
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.araymond.joal.web.messages.outgoing.impl.announce;
|
||||
|
||||
import org.araymond.joal.core.events.announce.AnnouncerHasStoppedEvent;
|
||||
import org.araymond.joal.core.ttorent.client.bandwidth.TorrentWithStats;
|
||||
|
||||
/**
|
||||
* Created by raymo on 25/06/2017.
|
||||
|
|
|
@ -3,8 +3,6 @@ package org.araymond.joal.web.resources;
|
|||
import org.araymond.joal.web.messages.outgoing.StompMessage;
|
||||
import org.araymond.joal.web.services.JoalMessageSendingTemplate;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.messaging.handler.annotation.MessageMapping;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
|
|
@ -67,6 +67,7 @@ public class JoalMessageSendingTemplate {
|
|||
case ANNOUNCER_HAS_STOPPED: {
|
||||
final String id = ((AnnouncePayload) stompMessage.getPayload()).getId();
|
||||
replayablePayloads.removeIf(message -> {
|
||||
//noinspection SimplifiableIfStatement
|
||||
if (!AnnouncePayload.class.isAssignableFrom(message.getPayload().getClass())) {
|
||||
return false;
|
||||
}
|
||||
|
@ -77,6 +78,7 @@ public class JoalMessageSendingTemplate {
|
|||
case ANNOUNCER_WILL_ANNOUNCE: {
|
||||
final String id = ((AnnouncePayload) stompMessage.getPayload()).getId();
|
||||
replayablePayloads.removeIf(message -> {
|
||||
//noinspection SimplifiableIfStatement
|
||||
if (!AnnouncePayload.class.isAssignableFrom(message.getPayload().getClass())) {
|
||||
return false;
|
||||
}
|
||||
|
@ -89,6 +91,7 @@ public class JoalMessageSendingTemplate {
|
|||
case ANNOUNCER_HAS_ANNOUNCED: {
|
||||
final String id = ((AnnouncePayload) stompMessage.getPayload()).getId();
|
||||
replayablePayloads.removeIf(message -> {
|
||||
//noinspection SimplifiableIfStatement
|
||||
if (!AnnouncePayload.class.isAssignableFrom(message.getPayload().getClass())) {
|
||||
return false;
|
||||
}
|
||||
|
@ -101,6 +104,7 @@ public class JoalMessageSendingTemplate {
|
|||
case ANNOUNCER_HAS_FAILED_TO_ANNOUNCE: {
|
||||
final String id = ((AnnouncePayload) stompMessage.getPayload()).getId();
|
||||
replayablePayloads.removeIf(message -> {
|
||||
//noinspection SimplifiableIfStatement
|
||||
if (!AnnouncePayload.class.isAssignableFrom(message.getPayload().getClass())) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
|
||||
<Loggers>
|
||||
<Root level="INFO" additivity="false">
|
||||
<AppenderRef ref="CONSOLE" />
|
||||
<AppenderRef ref="CONSOLE"/>
|
||||
</Root>
|
||||
<Logger name="org.araymond.joal" level="DEBUG" additivity="false">
|
||||
<Appender-ref ref="CONSOLE" />
|
||||
<Appender-ref ref="CONSOLE"/>
|
||||
</Logger>
|
||||
</Loggers>
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@ public class PeerIdInfoTest {
|
|||
final PeerIdInfo peerIdInfo = new PeerIdInfo("-my.pre-", ALPHABETIC, false, false);
|
||||
|
||||
assertThat(peerIdInfo.generateNewPeerId())
|
||||
.startsWith("-my.pre-")
|
||||
.hasSize(PeerIdInfo.PEER_ID_LENGTH);
|
||||
.startsWith("-my.pre-")
|
||||
.hasSize(PeerIdInfo.PEER_ID_LENGTH);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -19,15 +19,15 @@ public class JoalConfigProviderTest {
|
|||
|
||||
private static final Path resourcePath = Paths.get("src/test/resources/configtest");
|
||||
public static final AppConfiguration defaultConfig = new AppConfiguration(
|
||||
180L,
|
||||
190L,
|
||||
2,
|
||||
"azureus-5.7.5.0.client"
|
||||
180L,
|
||||
190L,
|
||||
2,
|
||||
"azureus-5.7.5.0.client"
|
||||
);
|
||||
|
||||
@Test
|
||||
public void shouldFailIWithEmptyConfigPath() {
|
||||
assertThatThrownBy(() ->new JoalConfigProvider(new ObjectMapper(), " "))
|
||||
assertThatThrownBy(() -> new JoalConfigProvider(new ObjectMapper(), " "))
|
||||
.isInstanceOf(IllegalArgumentException.class)
|
||||
.hasMessageContaining("A config path is required.");
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public class JoalConfigProviderTest {
|
|||
@Test
|
||||
public void shouldFailIfJsonFileIsNotPresent() {
|
||||
final String fakePath = resourcePath.resolve("nop").toString();
|
||||
assertThatThrownBy(() ->new JoalConfigProvider(new ObjectMapper(), fakePath))
|
||||
assertThatThrownBy(() -> new JoalConfigProvider(new ObjectMapper(), fakePath))
|
||||
.isInstanceOf(FileNotFoundException.class)
|
||||
.hasMessageContaining("App configuration file '" + fakePath + "\\config.json' not found.");
|
||||
}
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
package org.araymond.joal.core.events.announce;
|
||||
|
||||
import org.araymond.joal.core.ttorent.client.announce.AnnounceResult;
|
||||
import org.araymond.joal.core.ttorent.client.announce.Announcer;
|
||||
import org.araymond.joal.core.ttorent.client.bandwidth.TorrentWithStats;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
|
|
@ -9,7 +9,6 @@ import org.mockito.Mockito;
|
|||
import java.util.Collections;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
/**
|
||||
* Created by raymo on 25/06/2017.
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.araymond.joal.core.events.announce;
|
||||
|
||||
import com.turn.ttorrent.common.protocol.TrackerMessage;
|
||||
import org.araymond.joal.core.ttorent.client.announce.Announcer;
|
||||
import org.araymond.joal.core.ttorent.client.bandwidth.TorrentWithStats;
|
||||
import org.araymond.joal.web.messages.outgoing.impl.announce.AnnouncePayloadTest;
|
||||
|
|
|
@ -136,7 +136,7 @@ public class HTTPTrackerClientTest {
|
|||
final BitTorrentClient bitTorrentClient = Mockito.mock(BitTorrentClient.class);
|
||||
|
||||
final ByteBuffer buffer = createValidHttpAnnounceResponseAsByteBuffer().put(0, (byte) 50);
|
||||
assertThatThrownBy(() ->new HTTPTrackerClient(torrent, peer, uri, bitTorrentClient).toTrackerMessage(buffer))
|
||||
assertThatThrownBy(() -> new HTTPTrackerClient(torrent, peer, uri, bitTorrentClient).toTrackerMessage(buffer))
|
||||
.isInstanceOf(AnnounceException.class)
|
||||
.hasMessage("Error reading tracker response!");
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ public class HTTPTrackerClientTest {
|
|||
map.put("incomplete", new BEValue(100));
|
||||
map.put("interval", new BEValue(1800));
|
||||
map.put("complete", new BEValue(2945));
|
||||
map.put("peers", new BEValue(new byte[] { 8, 8, 8, 8, 8, 0}));
|
||||
map.put("peers", new BEValue(new byte[]{8, 8, 8, 8, 8, 0}));
|
||||
|
||||
return BEncoder.bencode(map);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import com.turn.ttorrent.common.protocol.http.HTTPAnnounceResponseMessage;
|
|||
import com.turn.ttorrent.common.protocol.http.HTTPTrackerErrorMessage;
|
||||
import org.araymond.joal.core.ttorent.client.ConnectionHandler;
|
||||
import org.araymond.joal.core.ttorent.client.announce.AnnounceResponseListener;
|
||||
import org.araymond.joal.core.ttorent.client.announce.Announcer;
|
||||
import org.araymond.joal.core.ttorent.client.bandwidth.TorrentWithStats;
|
||||
import org.assertj.core.util.Lists;
|
||||
import org.junit.Test;
|
||||
|
@ -203,6 +202,7 @@ public class TrackerClientTest {
|
|||
TorrentWithStats getTorrentWithStats() {
|
||||
return this.torrent;
|
||||
}
|
||||
|
||||
Peer getPeer() {
|
||||
return this.peer;
|
||||
}
|
||||
|
|
|
@ -150,7 +150,7 @@ public class BandwidthDispatcherTest {
|
|||
bandwidthDispatcher.stop();
|
||||
|
||||
final AppConfiguration conf = configProvider.get();
|
||||
for (final TorrentWithStats t: torrents) {
|
||||
for (final TorrentWithStats t : torrents) {
|
||||
assertThat(t.getUploaded())
|
||||
.isBetween(
|
||||
conf.getMinUploadRate() * 1000 / (1000 / updateInterval) / 4,
|
||||
|
|
|
@ -5,9 +5,6 @@ import org.araymond.joal.web.messages.outgoing.impl.global.SeedSessionHasEndedPa
|
|||
import org.araymond.joal.web.messages.outgoing.impl.global.SeedSessionHasStartedPayload;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package org.araymond.joal.web.messages.outgoing.impl.announce;
|
|||
|
||||
import org.araymond.joal.core.events.announce.AnnouncerEvent;
|
||||
import org.araymond.joal.core.ttorent.client.MockedTorrent;
|
||||
import org.araymond.joal.core.ttorent.client.announce.Announcer;
|
||||
import org.araymond.joal.core.ttorent.client.bandwidth.TorrentWithStats;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
|
|
@ -8,7 +8,6 @@ import org.mockito.Mockito;
|
|||
import java.util.Collections;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
/**
|
||||
* Created by raymo on 25/06/2017.
|
||||
|
|
|
@ -8,7 +8,6 @@ import org.mockito.Mockito;
|
|||
import java.util.Collections;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
/**
|
||||
* Created by raymo on 25/06/2017.
|
||||
|
|
Loading…
Reference in a new issue