use of jetbrains.buildServer.torrent.TorrentConfigurator in project teamcity-torrent-plugin by JetBrains.
the class TorrentSettingsAdminPage method fillModel.
@Override
public void fillModel(@NotNull Map<String, Object> model, @NotNull HttpServletRequest request) {
super.fillModel(model, request);
model.put("torrentConfigurator", myTorrentConfigurator);
model.put("announcedTorrentsNum", myTorrentTrackerManager.getAnnouncedTorrentsNum());
model.put("connectedClientsNum", myTorrentTrackerManager.getConnectedClientsNum());
model.put("seededTorrentsNum", myTorrentSeeder.getNumberOfSeededTorrents());
model.put("activePeersCount", myTorrentSeeder.getPeers().size());
final double speedBytesPerSecond = myTorrentSeeder.getPeers().stream().mapToDouble(it -> it.getULRate().get()).sum();
final DecimalFormat decimalFormat = new DecimalFormat("#.###");
model.put("totalSpeedMegabytesPerSecond", decimalFormat.format(speedBytesPerSecond / (1024 * 1024)));
}
use of jetbrains.buildServer.torrent.TorrentConfigurator in project teamcity-torrent-plugin by JetBrains.
the class TrackerControllerTest method createController.
@Override
@SuppressWarnings("unchecked")
protected TrackerController createController() throws IOException {
Mockery m = new Mockery();
final XmlRpcHandlerManager rpcHandlerManager = m.mock(XmlRpcHandlerManager.class);
final AddressChecker addressChecker = m.mock(AddressChecker.class);
AuthorizationInterceptor interceptor = m.mock(AuthorizationInterceptor.class);
m.checking(new Expectations() {
{
allowing(rpcHandlerManager).addHandler(with(any(String.class)), with(any(Object.class)));
allowing(interceptor).addPathNotRequiringAuth(with(any(String.class)));
allowing(addressChecker).isBadAddress(with(any(String.class)));
will(returnValue(false));
}
});
final TorrentConfigurator configurator = new TorrentConfigurator(new ServerPaths(createTempDir().getAbsolutePath()), myFixture.getSingletonService(RootUrlHolder.class), rpcHandlerManager);
myTorrentTrackerManager = new TorrentTrackerManager(configurator, myFixture.getSingletonService(ExecutorServices.class), myFixture.getSingletonService(EventDispatcher.class), addressChecker);
myTorrentTrackerManager.startTracker();
return new TrackerController(myWebManager, myTorrentTrackerManager, interceptor);
}
Aggregations