Merge statsnode repository at fc0a288

This commit is contained in:
Christoph Atteneder 2018-09-14 11:53:35 +02:00
parent 3de0a8b964
commit d1be121b57
No known key found for this signature in database
GPG key ID: CD5DC1C529CDFD3B
5 changed files with 210 additions and 0 deletions

View file

@ -7,5 +7,6 @@ include 'monitor'
include 'pricenode'
include 'relay'
include 'seednode'
include 'statsnode'
rootProject.name = 'bisq'

27
statsnode/build.gradle Normal file
View file

@ -0,0 +1,27 @@
plugins {
id 'java'
id 'application'
}
group = 'network.bisq'
version = '0.8.0-SNAPSHOT'
sourceCompatibility = 1.8
mainClassName = 'bisq.statistics.StatisticsMain'
repositories {
jcenter()
maven { url "https://jitpack.io" }
maven { url 'https://raw.githubusercontent.com/JesusMcCloud/tor-binary/master/release/' }
}
dependencies {
compile project(':core')
compileOnly 'org.projectlombok:lombok:1.16.16'
annotationProcessor 'org.projectlombok:lombok:1.16.16'
}
build.dependsOn installDist
installDist.destinationDir = file('build/app')
distZip.enabled = false

View file

@ -0,0 +1,71 @@
/*
* This file is part of Bisq.
*
* Bisq is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bisq is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/
package bisq.statistics;
import bisq.core.app.misc.AppSetup;
import bisq.core.app.misc.AppSetupWithP2P;
import bisq.core.offer.OfferBookService;
import bisq.core.provider.price.PriceFeedService;
import bisq.core.trade.statistics.TradeStatisticsManager;
import bisq.network.p2p.BootstrapListener;
import bisq.network.p2p.P2PService;
import com.google.inject.Injector;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class Statistics {
@Setter
private Injector injector;
private OfferBookService offerBookService; // pin to not get GC'ed
private PriceFeedService priceFeedService;
private TradeStatisticsManager tradeStatisticsManager;
private P2PService p2pService;
private AppSetup appSetup;
public Statistics() {
}
public void startApplication() {
p2pService = injector.getInstance(P2PService.class);
offerBookService = injector.getInstance(OfferBookService.class);
priceFeedService = injector.getInstance(PriceFeedService.class);
tradeStatisticsManager = injector.getInstance(TradeStatisticsManager.class);
// We need the price feed for market based offers
priceFeedService.setCurrencyCode("USD");
p2pService.addP2PServiceListener(new BootstrapListener() {
@Override
public void onUpdatedDataReceived() {
// we need to have tor ready
log.info("onBootstrapComplete: we start requestPriceFeed");
priceFeedService.requestPriceFeed(price -> log.info("requestPriceFeed. price=" + price),
(errorMessage, throwable) -> log.warn("Exception at requestPriceFeed: " + throwable.getMessage()));
tradeStatisticsManager.onAllServicesInitialized();
}
});
appSetup = injector.getInstance(AppSetupWithP2P.class);
appSetup.start();
}
}

View file

@ -0,0 +1,93 @@
/*
* This file is part of Bisq.
*
* Bisq is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bisq is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/
package bisq.statistics;
import bisq.core.app.BisqEnvironment;
import bisq.core.app.BisqExecutable;
import bisq.core.app.misc.ExecutableForAppWithP2p;
import bisq.core.app.misc.ModuleForAppWithP2p;
import bisq.common.UserThread;
import bisq.common.app.AppModule;
import bisq.common.setup.CommonSetup;
import joptsimple.OptionSet;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class StatisticsMain extends ExecutableForAppWithP2p {
private static final String VERSION = "0.6.1";
private Statistics statistics;
public static void main(String[] args) throws Exception {
log.info("Statistics.VERSION: " + VERSION);
BisqEnvironment.setDefaultAppName("bisq_statistics");
if (BisqExecutable.setupInitialOptionParser(args))
new StatisticsMain().execute(args);
}
@Override
protected void doExecute(OptionSet options) {
super.doExecute(options);
CommonSetup.setup(this);
checkMemory(bisqEnvironment, this);
keepRunning();
}
@Override
protected void launchApplication() {
UserThread.execute(() -> {
try {
statistics = new Statistics();
UserThread.execute(this::onApplicationLaunched);
} catch (Exception e) {
e.printStackTrace();
}
});
}
@Override
protected void onApplicationLaunched() {
super.onApplicationLaunched();
}
///////////////////////////////////////////////////////////////////////////////////////////
// We continue with a series of synchronous execution tasks
///////////////////////////////////////////////////////////////////////////////////////////
@Override
protected AppModule getModule() {
return new ModuleForAppWithP2p(bisqEnvironment);
}
@Override
protected void applyInjector() {
super.applyInjector();
statistics.setInjector(injector);
}
@Override
protected void startApplication() {
statistics.startApplication();
}
}

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="CONSOLE_APPENDER" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%highlight(%d{MMM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{15}: %msg %xEx%n)</pattern>
</encoder>
</appender>
<root level="TRACE">
<appender-ref ref="CONSOLE_APPENDER"/>
</root>
<logger name="bisq.common.storage.Storage" level="WARN"/>
<logger name="bisq.common.storage.FileManager" level="WARN"/>
<logger name="com.msopentech.thali.toronionproxy.OnionProxyManagerEventHandler" level="INFO"/>
</configuration>