From dae5be0c0401009ff2c5204c05e823b4ef6ba270 Mon Sep 17 00:00:00 2001 From: blavenie <benoit.lavenier@e-is.pro> Date: Fri, 17 Jun 2016 16:05:57 +0200 Subject: [PATCH] Refactoring code, as a classical ES plugin --- .../client/config/ConfigurationOption.java | 2 +- .../duniter/core/client/dao/CurrencyDao.java | 2 +- .../core/client/service/ServiceLocator.java | 14 +- .../org/duniter/core/beans/BeanFactory.java | 45 +- duniter4j-elasticsearch/pom.xml | 22 +- .../src/main/assembly/plugin.xml | 2 + .../main/filtered-resources/duniter4j.config | 2 + .../plugin-descriptor.properties | 13 +- .../org/duniter/elasticsearch/Plugin.java | 97 +++ .../duniter/elasticsearch/PluginSettings.java | 141 ++++ .../elasticsearch/action/RestModule.java | 8 +- .../currency/RestCurrencyIndexAction.java | 2 +- .../market/RestMarketRecordIndexAction.java | 9 +- .../RestRegistryRecordIndexAction.java | 9 +- .../security/RestSecurityAuthAction.java | 2 +- .../org/duniter/elasticsearch/cli/Main.java | 236 ------- .../cli/action/IndexerCliAction.java | 56 +- .../cli/action/NodeCliAction.java | 98 --- .../elasticsearch/config/Configuration.java | 316 --------- .../config/ConfigurationAction.java | 65 -- .../config/ConfigurationOption.java | 298 --------- .../config/ConfigurationProvider.java | 61 -- .../elasticsearch/job/BlockIndexer.java | 212 ++++++ .../duniter/elasticsearch/plugin/Plugin.java | 57 -- ...dexerService.java => AbstractService.java} | 101 ++- .../service/ElasticSearchService.java | 255 -------- .../service/ExecutorService.java | 45 -- .../service/ExecutorServiceImpl.java | 278 -------- .../elasticsearch/service/ServiceLocator.java | 121 ++-- .../elasticsearch/service/ServiceModule.java | 54 ++ .../BlockBlockchainService.java} | 88 ++- ...ervice.java => CategoryMarketService.java} | 25 +- ...rService.java => RecordMarketService.java} | 56 +- ...vice.java => CategoryRegistryService.java} | 33 +- ...ervice.java => CitiesRegistryService.java} | 42 +- ...vice.java => CurrencyRegistryService.java} | 107 +-- ...ervice.java => RecordRegistryService.java} | 41 +- .../elasticsearch/service/task/Job.java | 171 ----- .../elasticsearch/service/task/JobFuture.java | 92 --- .../elasticsearch/service/task/JobVO.java | 47 -- .../services/org.duniter.core.beans.Bean | 9 - .../src/main/resources/plugin-security.policy | 5 + .../src/test/es-home/logs/elasticsearch.log | 618 ++++++++++++++++-- .../plugin-descriptor.properties | 10 +- .../plugin-security.policy | 5 + .../duniter/elasticsearch/TestResource.java | 11 +- .../RegistryRecordIndexerServiceTest.java | 6 +- .../BlockIndexerServiceTest.java | 9 +- .../services/org.duniter.core.beans.Bean | 2 +- pom.xml | 8 +- 50 files changed, 1542 insertions(+), 2466 deletions(-) create mode 100644 duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/Plugin.java create mode 100644 duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/PluginSettings.java delete mode 100644 duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/cli/Main.java delete mode 100644 duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/cli/action/NodeCliAction.java delete mode 100644 duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/config/Configuration.java delete mode 100644 duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/config/ConfigurationAction.java delete mode 100644 duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/config/ConfigurationOption.java delete mode 100644 duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/config/ConfigurationProvider.java create mode 100644 duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/job/BlockIndexer.java delete mode 100644 duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/plugin/Plugin.java rename duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/{BaseIndexerService.java => AbstractService.java} (67%) delete mode 100644 duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/ElasticSearchService.java delete mode 100644 duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/ExecutorService.java delete mode 100644 duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/ExecutorServiceImpl.java create mode 100644 duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/ServiceModule.java rename duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/{currency/BlockIndexerService.java => blockchain/BlockBlockchainService.java} (93%) rename duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/market/{MarketCategoryIndexerService.java => CategoryMarketService.java} (87%) rename duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/market/{MarketRecordIndexerService.java => RecordMarketService.java} (86%) rename duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/registry/{RegistryCategoryIndexerService.java => CategoryRegistryService.java} (85%) rename duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/registry/{RegistryCitiesIndexerService.java => CitiesRegistryService.java} (92%) rename duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/registry/{RegistryCurrencyIndexerService.java => CurrencyRegistryService.java} (86%) rename duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/registry/{RegistryRecordIndexerService.java => RecordRegistryService.java} (90%) delete mode 100644 duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/task/Job.java delete mode 100644 duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/task/JobFuture.java delete mode 100644 duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/task/JobVO.java create mode 100644 duniter4j-elasticsearch/src/main/resources/plugin-security.policy create mode 100644 duniter4j-elasticsearch/src/test/es-home/plugins/duniter4j-elasticsearch/plugin-security.policy rename duniter4j-elasticsearch/src/test/java/org/duniter/elasticsearch/service/{currency => blockchain}/BlockIndexerServiceTest.java (94%) diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/config/ConfigurationOption.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/config/ConfigurationOption.java index 41d817b1..77ae3141 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/config/ConfigurationOption.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/config/ConfigurationOption.java @@ -127,7 +127,7 @@ public enum ConfigurationOption implements ConfigOptionDef { false), NODE_CURRENCY( - "duniter4j.node.currency", + "duniter4j.node.blockchain", n("duniter4j.config.option.node.currency.description"), "meta_brouzouf", String.class, diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/dao/CurrencyDao.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/dao/CurrencyDao.java index 172255fe..249975d3 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/dao/CurrencyDao.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/dao/CurrencyDao.java @@ -57,7 +57,7 @@ public interface CurrencyDao extends Bean, EntityDao<Currency> { Long getCurrencyIdByName(String currencyName); /** - * Return a (cached) list of currency ids + * Return a (cached) list of blockchain ids * @return */ Set<Long> getCurrencyIds(); diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/service/ServiceLocator.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/service/ServiceLocator.java index c3b70e9e..668013b5 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/service/ServiceLocator.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/service/ServiceLocator.java @@ -25,10 +25,7 @@ package org.duniter.core.client.service; import org.duniter.core.beans.Bean; import org.duniter.core.beans.BeanFactory; -import org.duniter.core.client.service.bma.BlockchainRemoteService; -import org.duniter.core.client.service.bma.NetworkRemoteService; -import org.duniter.core.client.service.bma.TransactionRemoteService; -import org.duniter.core.client.service.bma.WotRemoteService; +import org.duniter.core.client.service.bma.*; import org.duniter.core.client.service.elasticsearch.CurrencyRegistryRemoteService; import org.duniter.core.client.service.local.CurrencyService; import org.duniter.core.client.service.local.PeerService; @@ -56,6 +53,10 @@ public class ServiceLocator implements Closeable { protected ServiceLocator() { } + protected ServiceLocator(BeanFactory beanFactory) { + this.beanFactory = beanFactory; + } + public void init() { initBeanFactory(); } @@ -132,7 +133,6 @@ public class ServiceLocator implements Closeable { return getBean(CurrencyRegistryRemoteService.class); } - public <S extends Bean> S getBean(Class<S> clazz) { if (beanFactory == null) { initBeanFactory(); @@ -148,4 +148,8 @@ public class ServiceLocator implements Closeable { } } + public BeanFactory getBeanFactory() { + return beanFactory; + } + } diff --git a/duniter4j-core-shared/src/main/java/org/duniter/core/beans/BeanFactory.java b/duniter4j-core-shared/src/main/java/org/duniter/core/beans/BeanFactory.java index 71f975a7..d1c767bb 100644 --- a/duniter4j-core-shared/src/main/java/org/duniter/core/beans/BeanFactory.java +++ b/duniter4j-core-shared/src/main/java/org/duniter/core/beans/BeanFactory.java @@ -42,10 +42,12 @@ public class BeanFactory implements Closeable{ private final Map<Class<?>, Object> beansCache; private final ServiceLoader<Bean> beansLoader; + private final Map<Class<? extends Bean>, Class<? extends Bean>> beansClassMap; public BeanFactory() { beansCache = new HashMap<>(); beansLoader = ServiceLoader.load(Bean.class); + beansClassMap = new HashMap<>(); } public <S extends Bean> S getBean(Class<S> clazz) { @@ -73,20 +75,45 @@ public class BeanFactory implements Closeable{ public <S extends Bean> S newBean(Class<S> clazz) { + if (log.isTraceEnabled()) { + log.trace(String.format("Asking bean on type [%s]...", clazz.getName())); + } for (Bean bean: beansLoader) { if (clazz.isInstance(bean)) { if (log.isDebugEnabled()) { - log.debug(String.format("Creating new bean of type [%s]", clazz.getName())); + log.debug(String.format(" Creating new bean of type [%s]", clazz.getName())); } return (S)bean; } } + for (Map.Entry<Class<? extends Bean>, Class<? extends Bean>> beanDef : beansClassMap.entrySet()) { + if (log.isTraceEnabled()) { + log.trace(String.format(" Check against type [%s]", beanDef.getKey().getName())); + } + if (clazz.equals(beanDef.getKey())) { + if (log.isDebugEnabled()) { + log.debug(String.format("Creating new bean of type [%s] with class [%s]", clazz.getName(), beanDef.getValue().getName())); + } + + Class<? extends Bean> beanDefClass = beanDef.getValue(); + try { + Bean bean = beanDefClass.newInstance(); + if (clazz.isInstance(bean)) { + return (S) beanDefClass.newInstance(); + } + } catch(Exception e) { + // skip + } + } + } + throw new TechnicalException(String.format("Unable to create bean with type [%s]: not configured for the service loader [%s]", clazz.getName(), Bean.class.getCanonicalName())); } + @Override public void close() throws IOException { for(Object bean: beansCache.values()) { @@ -103,4 +130,20 @@ public class BeanFactory implements Closeable{ } } } + + public <S extends Bean> BeanFactory bind(Class<S> def, Class<? extends S> beanClass) { + if (log.isTraceEnabled()) { + log.trace(String.format("Bind on type [%s] with class [%s]", def.getName(), beanClass.getName())); + } + beansClassMap.put(def, beanClass); + return this; + } + + public BeanFactory add(Class<? extends Bean> beanClass) { + if (log.isTraceEnabled()) { + log.trace(String.format("Adding bean of type [%s]", beanClass.getName())); + } + beansClassMap.put(beanClass, beanClass); + return this; + } } diff --git a/duniter4j-elasticsearch/pom.xml b/duniter4j-elasticsearch/pom.xml index dec72d6f..72eda53c 100644 --- a/duniter4j-elasticsearch/pom.xml +++ b/duniter4j-elasticsearch/pom.xml @@ -24,9 +24,13 @@ </i18n.bundleCsvFile> <config.i18nBundleName>${i18n.bundleOutputName}</config.i18nBundleName> - <maven.jar.main.class> + <!--maven.jar.main.class> org.duniter.elasticsearch.cli.Main + </maven.jar.main.class--> + <maven.jar.main.class> + org.elasticsearch.bootstrap.Elasticsearch </maven.jar.main.class> + <exec.classpathScope>provided</exec.classpathScope> <duniter4j-elasticsearch.config>${project.basedir}/src/test/resources/duniter4j-elasticsearch-test.properties</duniter4j-elasticsearch.config> </properties> @@ -68,7 +72,7 @@ <dependency> <groupId>net.java.dev.jna</groupId> <artifactId>jna</artifactId> - <!--scope>provided</scope--> + <scope>compile</scope> </dependency> <dependency> <groupId>net.java.dev.jna</groupId> @@ -195,12 +199,12 @@ <attach>true</attach> <finalName>${bundlePrefix}</finalName> <descriptors> + <!--descriptor> + ${basedir}/src/main/assembly/standalone.xml + </descriptor--> <descriptor> - src/main/assembly/standalone.xml + ${basedir}/src/main/assembly/plugin.xml </descriptor> - <descriptors> - <descriptor>${basedir}/src/main/assembly/plugin.xml</descriptor> - </descriptors> </descriptors> </configuration> </execution> @@ -261,10 +265,14 @@ <classpathScope>${exec.classpathScope}</classpathScope> <commandlineArgs>start</commandlineArgs> <systemProperties> - <property > + <property> <key>duniter4j-elasticsearch.config</key> <value>${duniter4j-elasticsearch.config}</value> </property> + <property> + <key>es.path.home</key> + <value>${basedir}/src/test/es-home</value> + </property> </systemProperties> </configuration> </execution> diff --git a/duniter4j-elasticsearch/src/main/assembly/plugin.xml b/duniter4j-elasticsearch/src/main/assembly/plugin.xml index 6e3443d8..873c5a24 100644 --- a/duniter4j-elasticsearch/src/main/assembly/plugin.xml +++ b/duniter4j-elasticsearch/src/main/assembly/plugin.xml @@ -15,6 +15,7 @@ <useTransitiveFiltering>true</useTransitiveFiltering> <excludes> <exclude>org.elasticsearch:elasticsearch</exclude> + <exclude>net.java.dev.jna:jna</exclude> </excludes> </dependencySet> </dependencySets> @@ -31,6 +32,7 @@ <outputDirectory/> <includes> <include>plugin-descriptor.properties</include> + <include>plugin-security.policy</include> </includes> </fileSet> </fileSets> diff --git a/duniter4j-elasticsearch/src/main/filtered-resources/duniter4j.config b/duniter4j-elasticsearch/src/main/filtered-resources/duniter4j.config index 03d3b6b2..053ef9a3 100644 --- a/duniter4j-elasticsearch/src/main/filtered-resources/duniter4j.config +++ b/duniter4j-elasticsearch/src/main/filtered-resources/duniter4j.config @@ -1,3 +1,5 @@ +app.name=duniter4j +duniter4j.config.path=sqqs duniter4j.version=${project.version} duniter4j.site.url=${project.url} duniter4j.inceptionYear=${project.inceptionYear} diff --git a/duniter4j-elasticsearch/src/main/filtered-resources/plugin-descriptor.properties b/duniter4j-elasticsearch/src/main/filtered-resources/plugin-descriptor.properties index c3cb24e2..f0e3dd83 100644 --- a/duniter4j-elasticsearch/src/main/filtered-resources/plugin-descriptor.properties +++ b/duniter4j-elasticsearch/src/main/filtered-resources/plugin-descriptor.properties @@ -1,11 +1,10 @@ name=duniter4j-elasticsearch -#description=${project.description} -description=duniter4j-elasticsearch +description=${project.description} version=1.0 -#version=${project.version} -site=true +version=${project.version} +site=false jvm=true -classname=org.duniter.elasticsearch.plugin.Plugin +classname=org.duniter.elasticsearch.Plugin java.version=1.7 -elasticsearch.version=2.3.1 -isolated=false \ No newline at end of file +elasticsearch.version=2.3.3 +isolated=true \ No newline at end of file diff --git a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/Plugin.java b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/Plugin.java new file mode 100644 index 00000000..2411c189 --- /dev/null +++ b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/Plugin.java @@ -0,0 +1,97 @@ +package org.duniter.elasticsearch; + +/* + * #%L + * duniter4j-elasticsearch-plugin + * %% + * Copyright (C) 2014 - 2016 EIS + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import com.google.common.collect.Lists; +import org.duniter.elasticsearch.action.RestModule; +import org.duniter.elasticsearch.job.BlockIndexer; +import org.duniter.elasticsearch.security.SecurityModule; +import org.duniter.elasticsearch.service.ServiceModule; +import org.elasticsearch.common.component.LifecycleComponent; +import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.inject.Module; +import org.elasticsearch.common.logging.ESLogger; +import org.elasticsearch.common.logging.ESLoggerFactory; + +import java.util.Collection; + +public class Plugin extends org.elasticsearch.plugins.Plugin { + + private ESLogger log = ESLoggerFactory.getLogger(Plugin.class.getName()); + + private org.elasticsearch.common.settings.Settings settings; + private boolean disable; + + @Inject public Plugin(org.elasticsearch.common.settings.Settings settings) { + this.settings = settings; + this.disable = settings.getAsBoolean("duniter.disable", false); + } + + @Override + public String name() { + return "duniter"; + } + + @Override + public String description() { + return "Duniter ElasticSearch Plugin"; + } + + @Override + public Collection<Module> nodeModules() { + Collection<Module> modules = Lists.newArrayList(); + if (disable) { + log.warn(description() + " has been disabled."); + return modules; + } + modules.add(new SecurityModule()); + modules.add(new RestModule()); + modules.add(new ServiceModule()); + return modules; + } + + @Override + public Collection<Class<? extends LifecycleComponent>> nodeServices() { + Collection<Class<? extends LifecycleComponent>> components = Lists.newArrayList(); + if (disable) { + return components; + } + components.add(BlockIndexer.class); + //components.add(PluginSettings.class); + // Market + //components.add(CategoryMarketService.class); + //components.add(RecordMarketService.class); + // Registry + //components.add(CurrencyRegistryService.class); + //components.add(CategoryRegistryService.class); + //components.add(CitiesRegistryService.class); + //components.add(RecordRegistryService.class); + // BC + //components.add(BlockBlockchainService.class); + return components; + } + + /* -- protected methods -- */ + + +} \ No newline at end of file diff --git a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/PluginSettings.java b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/PluginSettings.java new file mode 100644 index 00000000..304ee516 --- /dev/null +++ b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/PluginSettings.java @@ -0,0 +1,141 @@ +package org.duniter.elasticsearch; + +/* + * #%L + * UCoin Java Client :: Core API + * %% + * Copyright (C) 2014 - 2015 EIS + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + + +import org.apache.commons.io.FileUtils; +import org.duniter.core.client.config.Configuration; +import org.duniter.core.client.config.ConfigurationOption; +import org.elasticsearch.common.component.Lifecycle; +import org.elasticsearch.common.component.LifecycleComponent; +import org.elasticsearch.common.component.LifecycleListener; +import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.logging.ESLogger; +import org.elasticsearch.common.logging.ESLoggerFactory; +import org.nuiton.config.ApplicationConfig; +import org.nuiton.i18n.I18n; +import org.nuiton.i18n.init.DefaultI18nInitializer; +import org.nuiton.i18n.init.UserI18nInitializer; + +import java.io.File; +import java.io.IOException; +import java.util.Locale; + +/** + * Access to configuration options + * @author Benoit Lavenier <benoit.lavenier@e-is.pro> + * @since 1.0 + */ +public class PluginSettings { + /** Logger. */ + private ESLogger log = ESLoggerFactory.getLogger(PluginSettings.class.getName()); + + private org.elasticsearch.common.settings.Settings settings; + + /** + * Delegate application config. + */ + protected final ApplicationConfig applicationConfig; + + @Inject + public PluginSettings(org.elasticsearch.common.settings.Settings settings) { + this.settings = settings; + this.applicationConfig = new ApplicationConfig(); + + // Cascade the application config to the client module + org.duniter.core.client.config.Configuration clientConfig = new org.duniter.core.client.config.Configuration(applicationConfig); + org.duniter.core.client.config.Configuration.setInstance(clientConfig); + + String baseDir = settings.get("es.path.home"); + applicationConfig.setOption(ConfigurationOption.BASEDIR.getKey(), baseDir); + applicationConfig.setOption(ConfigurationOption.NODE_HOST.getKey(), getNodeBmaHost()); + applicationConfig.setOption(ConfigurationOption.NODE_PORT.getKey(), String.valueOf(getNodeBmaPort())); + applicationConfig.setOption(ConfigurationOption.NODE_PROTOCOL.getKey(), getNodeBmaPort() == 443 ? "https" : "http"); + + //initI18n(); + } + + public String getNodeBmaHost() { + return settings.get("duniter.host", "cgeek.fr"); + } + + public int getNodeBmaPort() { + return settings.getAsInt("duniter.port", 9330); + } + + public boolean isIndexBulkEnable() { + return settings.getAsBoolean("duniter.bulk.enable", true); + } + + public int getIndexBulkSize() { + return settings.getAsInt("duniter.bulk.size", 1000); + } + + public String getIndexStringAnalyzer() { + return settings.get("duniter.string.analyzer", "english"); + } + + public File getTempDirectory() { + return Configuration.instance().getTempDirectory(); + } + + public boolean isDevMode() { + return settings.getAsBoolean("duniter.dev.enable", false); + } + + /* */ + + protected void initI18n() throws IOException { + Configuration config = Configuration.instance(); + + // --------------------------------------------------------------------// + // init i18n + // --------------------------------------------------------------------// + + File i18nDirectory = new File(Configuration.instance().getDataDirectory(), "i18n"); + if (i18nDirectory.exists()) { + // clean i18n cache + FileUtils.cleanDirectory(i18nDirectory); + } + + FileUtils.forceMkdir(i18nDirectory); + + if (log.isDebugEnabled()) { + log.debug("I18N directory: " + i18nDirectory); + } + + Locale i18nLocale = config.getI18nLocale(); + + if (log.isInfoEnabled()) { + log.info(String.format("Starts i18n with locale [%s] at [%s]", + i18nLocale, i18nDirectory)); + } + I18n.init(new UserI18nInitializer( + i18nDirectory, new DefaultI18nInitializer(getI18nBundleName())), + i18nLocale); + } + + protected String getI18nBundleName() { + return "duniter4j-elasticsearch-i18n"; + } +} diff --git a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/action/RestModule.java b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/action/RestModule.java index a3ea3b97..99578540 100644 --- a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/action/RestModule.java +++ b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/action/RestModule.java @@ -33,13 +33,13 @@ import org.elasticsearch.common.inject.Module; public class RestModule extends AbstractModule implements Module { @Override protected void configure() { - bind(RestCurrencyIndexAction.class).asEagerSingleton(); + //bind(RestCurrencyIndexAction.class).asEagerSingleton(); bind(RestMarketRecordIndexAction.class).asEagerSingleton(); - bind(RestRegistryRecordIndexAction.class).asEagerSingleton(); + //bind(RestRegistryRecordIndexAction.class).asEagerSingleton(); - bind(RestSecurityGetChallengeAction.class).asEagerSingleton(); - bind(RestSecurityAuthAction.class).asEagerSingleton(); + //bind(RestSecurityGetChallengeAction.class).asEagerSingleton(); + //bind(RestSecurityAuthAction.class).asEagerSingleton(); } } \ No newline at end of file diff --git a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/action/currency/RestCurrencyIndexAction.java b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/action/currency/RestCurrencyIndexAction.java index 5721c65f..71b5f4c5 100644 --- a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/action/currency/RestCurrencyIndexAction.java +++ b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/action/currency/RestCurrencyIndexAction.java @@ -34,7 +34,7 @@ public class RestCurrencyIndexAction extends BaseRestHandler { @Inject public RestCurrencyIndexAction(Settings settings, RestController controller, Client client) { super(settings, controller, client); - controller.registerHandler(RestRequest.Method.POST, "/currency", this); + controller.registerHandler(RestRequest.Method.POST, "/blockchain", this); } @Override diff --git a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/action/market/RestMarketRecordIndexAction.java b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/action/market/RestMarketRecordIndexAction.java index ac3bc193..9aff904a 100644 --- a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/action/market/RestMarketRecordIndexAction.java +++ b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/action/market/RestMarketRecordIndexAction.java @@ -23,7 +23,7 @@ package org.duniter.elasticsearch.action.market; */ import org.duniter.core.exception.BusinessException; -import org.duniter.elasticsearch.service.ServiceLocator; +import org.duniter.elasticsearch.service.market.RecordMarketService; import org.elasticsearch.client.Client; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.logging.ESLogger; @@ -39,17 +39,20 @@ public class RestMarketRecordIndexAction extends BaseRestHandler { private static final ESLogger log = ESLoggerFactory.getLogger(RestMarketRecordIndexAction.class.getName()); + private RecordMarketService service; + @Inject - public RestMarketRecordIndexAction(Settings settings, RestController controller, Client client) { + public RestMarketRecordIndexAction(Settings settings, RestController controller, Client client, RecordMarketService service) { super(settings, controller, client); controller.registerHandler(POST, "/market/record", this); + this.service = service; } @Override protected void handleRequest(final RestRequest request, RestChannel restChannel, Client client) throws Exception { try { - String recordId = ServiceLocator.instance().getMarketRecordIndexerService().indexRecordFromJson(request.content().toUtf8()); + String recordId = service.indexRecordFromJson(request.content().toUtf8()); restChannel.sendResponse(new BytesRestResponse(OK, recordId)); } diff --git a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/action/registry/RestRegistryRecordIndexAction.java b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/action/registry/RestRegistryRecordIndexAction.java index c3c0c707..287ee35f 100644 --- a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/action/registry/RestRegistryRecordIndexAction.java +++ b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/action/registry/RestRegistryRecordIndexAction.java @@ -23,7 +23,7 @@ package org.duniter.elasticsearch.action.registry; */ import org.duniter.core.exception.BusinessException; -import org.duniter.elasticsearch.service.ServiceLocator; +import org.duniter.elasticsearch.service.registry.RecordRegistryService; import org.elasticsearch.client.Client; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.logging.ESLogger; @@ -39,17 +39,20 @@ public class RestRegistryRecordIndexAction extends BaseRestHandler { private static final ESLogger log = ESLoggerFactory.getLogger(RestRegistryRecordIndexAction.class.getName()); + private RecordRegistryService service; + @Inject - public RestRegistryRecordIndexAction(Settings settings, RestController controller, Client client) { + public RestRegistryRecordIndexAction(Settings settings, RestController controller, Client client, RecordRegistryService service) { super(settings, controller, client); controller.registerHandler(POST, "/registry/record", this); + this.service = service; } @Override protected void handleRequest(final RestRequest request, RestChannel restChannel, Client client) throws Exception { try { - String recordId = ServiceLocator.instance().getRegistryRecordIndexerService().indexRecordFromJson(request.content().toUtf8()); + String recordId = service.indexRecordFromJson(request.content().toUtf8()); restChannel.sendResponse(new BytesRestResponse(OK, recordId)); } diff --git a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/action/security/RestSecurityAuthAction.java b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/action/security/RestSecurityAuthAction.java index d6ff67cf..26c63f63 100644 --- a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/action/security/RestSecurityAuthAction.java +++ b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/action/security/RestSecurityAuthAction.java @@ -23,10 +23,10 @@ package org.duniter.elasticsearch.action.security; */ import org.duniter.core.client.model.bma.gson.GsonUtils; +import org.duniter.core.client.service.ServiceLocator; import org.duniter.core.util.StringUtils; import org.duniter.elasticsearch.security.challenge.ChallengeMessageStore; import org.duniter.elasticsearch.security.token.SecurityTokenStore; -import org.duniter.elasticsearch.service.ServiceLocator; import org.elasticsearch.client.Client; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.logging.ESLogger; diff --git a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/cli/Main.java b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/cli/Main.java deleted file mode 100644 index 02560623..00000000 --- a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/cli/Main.java +++ /dev/null @@ -1,236 +0,0 @@ -package org.duniter.elasticsearch.cli; - -/* - * #%L - * UCoin Java Client :: Core API - * %% - * Copyright (C) 2014 - 2015 EIS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - - -import com.google.common.collect.Lists; -import org.duniter.core.exception.TechnicalException; -import org.duniter.core.util.CommandLinesUtils; -import org.duniter.core.util.StringUtils; -import org.duniter.elasticsearch.config.Configuration; -import org.duniter.elasticsearch.config.ConfigurationAction; -import org.duniter.elasticsearch.service.ServiceLocator; -import org.duniter.elasticsearch.util.Desktop; -import org.duniter.elasticsearch.util.DesktopPower; -import org.apache.commons.io.FileUtils; -import org.elasticsearch.common.logging.ESLogger; -import org.elasticsearch.common.logging.ESLoggerFactory; -import org.nuiton.config.ApplicationConfig; -import org.nuiton.i18n.I18n; -import org.nuiton.i18n.init.DefaultI18nInitializer; -import org.nuiton.i18n.init.UserI18nInitializer; - -import java.io.File; -import java.io.IOException; -import java.util.Arrays; -import java.util.List; -import java.util.Locale; - -public class Main { - - private static String TITLE_SEPARATOR_LINE = "************************************************\n"; - private static String TITLE_EMPTY_LINE = "*\n"; - private static String TITLE = TITLE_SEPARATOR_LINE - + TITLE_EMPTY_LINE - + "* %s\n" // title - + TITLE_EMPTY_LINE - + "* %s\n" // sub-title - + TITLE_EMPTY_LINE + TITLE_SEPARATOR_LINE; - - private static final ESLogger log = ESLoggerFactory.getLogger(Main.class.getName()); - - public static void main(String[] args) { - Main main = new Main(); - main.run(args); - } - - public void run(String[] args) { - if (log.isInfoEnabled()) { - log.info("Starting duniter4j :: ElasticSearch Indexer with arguments " + Arrays.toString(args)); - } - - // By default, start - if (args == null || args.length == 0) { - args = new String[] { "--start" }; - } - - List<String> arguments = Lists.newArrayList(Arrays.asList(args)); - arguments.removeAll(Arrays.asList(ConfigurationAction.HELP.aliases)); - - // Could override config file name (useful for dev) - String configFile = "duniter4j-elasticsearch.config"; - if (System.getProperty(configFile) != null) { - configFile = System.getProperty(configFile); - configFile = configFile.replaceAll("\\\\", "/"); - } - - // Create configuration - Configuration config = new Configuration(configFile, args) { - protected void addAlias(ApplicationConfig applicationConfig) { - super.addAlias(applicationConfig); - // Add custom alias - }; - }; - Configuration.setInstance(config); - - // Init i18n - try { - initI18n(config); - } catch (IOException e) { - throw new TechnicalException("i18n initialization failed", e); - } - - // Add hook on system - addShutdownHook(); - - // Run all actions - try { - config.getApplicationConfig().doAllAction(); - } catch (Exception e) { - log.error(e.getMessage(), e); - } - - if (config.isDaemon()) { - while (true) { - try { - Thread.sleep(5000); - } catch(InterruptedException e) { - // Nothing - } - } - } - else { - if (arguments.size() > 0) { - - // Check if auto-quit if need - boolean quit = true; - for (String startAlias : ConfigurationAction.START.aliases) { - if (arguments.contains(startAlias)) { - quit = false; - break; - } - } - - // If scheduling is running, wait quit instruction - if (!quit) { - - while (!quit) { - String userInput = CommandLinesUtils.readInput( - String.format(TITLE, - "duniter4j :: Elasticsearch successfully started", - ">> To quit, press [Q] or [enter]"), - "Q", true); - quit = StringUtils.isNotBlank(userInput) && "Q".equalsIgnoreCase(userInput); - } - } - } - } - - // shutdown - shutdown(); - } - - /* -- protected methods -- */ - - /** - * Shutdown all services - */ - protected static void shutdown() { - if (ServiceLocator.instance() != null) { - try { - ServiceLocator.instance().close(); - } - catch(IOException e) { - // Silent is gold - } - } - - log.info("duniter4j :: ElasticSearch Indexer successfully stopped"); - } - - protected void initI18n(Configuration config) throws IOException { - - // --------------------------------------------------------------------// - // init i18n - // --------------------------------------------------------------------// - File i18nDirectory = new File(config.getDataDirectory(), "i18n"); - if (i18nDirectory.exists()) { - // clean i18n cache - FileUtils.cleanDirectory(i18nDirectory); - } - - FileUtils.forceMkdir(i18nDirectory); - - if (log.isDebugEnabled()) { - log.debug("I18N directory: " + i18nDirectory); - } - - Locale i18nLocale = config.getI18nLocale(); - - if (log.isInfoEnabled()) { - log.info(String.format("Starts i18n with locale [%s] at [%s]", - i18nLocale, i18nDirectory)); - } - I18n.init(new UserI18nInitializer( - i18nDirectory, new DefaultI18nInitializer(getI18nBundleName())), - i18nLocale); - } - - protected String getI18nBundleName() { - return "duniter4j-elasticsearch-i18n"; - } - - /** - * Add an OS shutdown hook, to close application on shutdown - */ - private void addShutdownHook() { - - // Use shutdownHook to close context on System.exit - Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { - @Override - public void run() { - shutdown(); - } - })); - - // Add DesktopPower to hook computer shutdown - DesktopPower desktopPower = Desktop.getDesktopPower(); - if (desktopPower != null) { - - desktopPower.addListener(new DesktopPower.Listener() { - @Override - public void quit() { - if (ServiceLocator.instance() != null) { - try { - ServiceLocator.instance().close(); - } - catch(IOException e) { - // Silent is gold - } - } - } - }); - } - - } -} diff --git a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/cli/action/IndexerCliAction.java b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/cli/action/IndexerCliAction.java index eebd836b..89263085 100644 --- a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/cli/action/IndexerCliAction.java +++ b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/cli/action/IndexerCliAction.java @@ -24,21 +24,6 @@ package org.duniter.elasticsearch.cli.action; * #L% */ -import org.duniter.core.client.model.bma.BlockchainParameters; -import org.duniter.core.client.model.bma.gson.GsonUtils; -import org.duniter.core.client.model.local.Peer; -import org.duniter.core.client.service.bma.BlockchainRemoteService; -import org.duniter.core.util.websocket.WebsocketClientEndpoint; -import org.duniter.elasticsearch.config.Configuration; -import org.duniter.elasticsearch.service.ServiceLocator; -import org.duniter.elasticsearch.service.currency.BlockIndexerService; -import org.duniter.elasticsearch.service.market.MarketCategoryIndexerService; -import org.duniter.elasticsearch.service.market.MarketRecordIndexerService; -import org.duniter.elasticsearch.service.registry.RegistryCategoryIndexerService; -import org.duniter.elasticsearch.service.registry.RegistryCitiesIndexerService; -import org.duniter.elasticsearch.service.registry.RegistryCurrencyIndexerService; -import org.duniter.elasticsearch.service.registry.RegistryRecordIndexerService; -import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -46,6 +31,7 @@ public class IndexerCliAction { /* Logger */ private static final Logger log = LoggerFactory.getLogger(IndexerCliAction.class); + /* public void indexBlocksFromNode() { final boolean async = ServiceLocator.instance().getElasticSearchService().isNodeInstance(); @@ -53,21 +39,21 @@ public class IndexerCliAction { Runnable runnable = new Runnable() { @Override public void run() { - Configuration config = Configuration.instance(); + PluginSettings config = PluginSettings.instance(); final Peer peer = checkConfigAndGetPeer(config); - final BlockIndexerService blockIndexerService = ServiceLocator.instance().getBlockIndexerService(); + final BlockBlockchainService blockIndexerService = ServiceLocator.instance().getBlockIndexerService(); - // Will create the currency if not exist + // Will create the blockchain if not exist blockIndexerService.indexLastBlocks(peer); if (async) { ServiceLocator.instance().getBlockchainRemoteService().addNewBlockListener(peer, new WebsocketClientEndpoint.MessageHandler() { @Override public void handleMessage(String message) { - String currencyName = GsonUtils.getValueFromJSONAsString(message, "currency"); - blockIndexerService.indexBlockAsJson(peer, message, true /*refresh*/, true /*wait*/); - blockIndexerService.indexCurrentBlockAsJson(currencyName, message, true /*wait*/); - } + String currencyName = GsonUtils.getValueFromJSONAsString(message, "blockchain"); + *///blockIndexerService.indexBlockAsJson(peer, message, true /*refresh*/, true /*wait*/); + //blockIndexerService.indexCurrentBlockAsJson(currencyName, message, true /*wait*/); + /* } }); } } @@ -92,18 +78,18 @@ public class IndexerCliAction { } public void resetAllCurrencies() { - RegistryCurrencyIndexerService currencyIndexerService = ServiceLocator.instance().getRegistryCurrencyIndexerService(); + CurrencyRegistryService currencyIndexerService = ServiceLocator.instance().getRegistryCurrencyIndexerService(); currencyIndexerService.deleteAllCurrencies(); } public void resetDataBlocks() { BlockchainRemoteService blockchainService = ServiceLocator.instance().getBlockchainRemoteService(); - BlockIndexerService indexerService = ServiceLocator.instance().getBlockIndexerService(); - Configuration config = Configuration.instance(); + BlockBlockchainService indexerService = ServiceLocator.instance().getBlockIndexerService(); + PluginSettings config = PluginSettings.instance(); Peer peer = checkConfigAndGetPeer(config); try { - // Get the currency name from node + // Get the blockchain name from node BlockchainParameters parameter = blockchainService.getParameters(peer); if (parameter == null) { log.error(String.format("Could not connect to node [%s:%s]", @@ -114,7 +100,7 @@ public class IndexerCliAction { log.info(String.format("Reset data for index [%s]", currencyName)); - // Delete then create index on currency + // Delete then create index on blockchain boolean indexExists = indexerService.existsIndex(currencyName); if (indexExists) { indexerService.deleteIndex(currencyName); @@ -129,8 +115,8 @@ public class IndexerCliAction { } public void resetMarketRecords() { - MarketRecordIndexerService recordIndexerService = ServiceLocator.instance().getMarketRecordIndexerService(); - MarketCategoryIndexerService categoryIndexerService = ServiceLocator.instance().getMarketCategoryIndexerService(); + RecordMarketService recordIndexerService = ServiceLocator.instance().getMarketRecordIndexerService(); + CategoryMarketService categoryIndexerService = ServiceLocator.instance().getMarketCategoryIndexerService(); try { // Delete then create index on records @@ -150,9 +136,9 @@ public class IndexerCliAction { } public void resetRegistry() { - RegistryRecordIndexerService recordIndexerService = ServiceLocator.instance().getRegistryRecordIndexerService(); - RegistryCategoryIndexerService categoryIndexerService = ServiceLocator.instance().getRegistryCategoryIndexerService(); - RegistryCitiesIndexerService citiesIndexerService = ServiceLocator.instance().getRegistryCitiesIndexerService(); + RecordRegistryService recordIndexerService = ServiceLocator.instance().getRegistryRecordIndexerService(); + CategoryRegistryService categoryIndexerService = ServiceLocator.instance().getRegistryCategoryIndexerService(); + CitiesRegistryService citiesIndexerService = ServiceLocator.instance().getRegistryCitiesIndexerService(); try { // Delete then create index on records @@ -179,11 +165,11 @@ public class IndexerCliAction { } catch(Exception e) { log.error("Error during reset registry records: " + e.getMessage(), e); } - } + }*/ /* -- internal methods -- */ - protected Peer checkConfigAndGetPeer(Configuration config) { + /*protected Peer checkConfigAndGetPeer(PluginSettings config) { if (StringUtils.isBlank(config.getNodeBmaHost())) { log.error("ERROR: node host is required"); System.exit(-1); @@ -197,5 +183,5 @@ public class IndexerCliAction { Peer peer = new Peer(config.getNodeBmaHost(), config.getNodeBmaPort()); return peer; - } + }*/ } diff --git a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/cli/action/NodeCliAction.java b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/cli/action/NodeCliAction.java deleted file mode 100644 index 1559d01d..00000000 --- a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/cli/action/NodeCliAction.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.duniter.elasticsearch.cli.action; - -/* - * #%L - * SIH-Adagio :: Shared - * $Id:$ - * $HeadURL:$ - * %% - * Copyright (C) 2012 - 2014 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import org.duniter.elasticsearch.config.Configuration; -import org.duniter.elasticsearch.service.ElasticSearchService; -import org.duniter.elasticsearch.service.ServiceLocator; -import org.duniter.elasticsearch.service.market.MarketCategoryIndexerService; -import org.duniter.elasticsearch.service.market.MarketRecordIndexerService; -import org.duniter.elasticsearch.service.registry.RegistryCurrencyIndexerService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class NodeCliAction { - /* Logger */ - private static final Logger log = LoggerFactory.getLogger(NodeCliAction.class); - - public void start() { - - Configuration config = Configuration.instance(); - //config.setNodeElasticSearchLocal(false); - - // Starting ES node - ElasticSearchService esService = ServiceLocator.instance().getElasticSearchService(); - esService.startNode(); - - // Wait 5s, to avoid error on existsIndex() - try { - Thread t = new Thread() { - @Override - public void run() { - super.run(); - try { - sleep(5000); - } - catch(InterruptedException e) { - // continue - } - catch(IllegalMonitorStateException e) { - e.printStackTrace(); - } - } - }; - t.start(); - t.join(); - } - catch(InterruptedException e) { - // continue - } - - - // Create indexed if need - { - // Currency index - RegistryCurrencyIndexerService currencyIndexerService = ServiceLocator.instance().getRegistryCurrencyIndexerService(); - currencyIndexerService.createIndexIfNotExists(); - - // Product index - MarketRecordIndexerService recordIndexerService = ServiceLocator.instance().getMarketRecordIndexerService(); - recordIndexerService.createIndexIfNotExists(); - - // Category index - MarketCategoryIndexerService categoryIndexerService = ServiceLocator.instance().getMarketCategoryIndexerService(); - categoryIndexerService.createIndexIfNotExists(); - } - } - - /*public void stop() { - // Starting ES node - ElasticSearchService esService = ServiceLocator.instance().getElasticSearchService(); - esService.stopNode(); - }*/ - - /* -- protected methods -- */ - -} diff --git a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/config/Configuration.java b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/config/Configuration.java deleted file mode 100644 index 18b0db44..00000000 --- a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/config/Configuration.java +++ /dev/null @@ -1,316 +0,0 @@ -package org.duniter.elasticsearch.config; - -/* - * #%L - * UCoin Java Client :: Core API - * %% - * Copyright (C) 2014 - 2015 EIS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - - -import com.google.common.base.Charsets; -import org.duniter.core.exception.TechnicalException; -import org.nuiton.config.ApplicationConfig; -import org.nuiton.config.ApplicationConfigHelper; -import org.nuiton.config.ApplicationConfigProvider; -import org.nuiton.config.ArgumentsParserException; -import org.nuiton.util.version.Version; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.util.Locale; -import java.util.Set; - -import static org.nuiton.i18n.I18n.t; - -/** - * Access to configuration options - * @author Benoit Lavenier <benoit.lavenier@e-is.pro> - * @since 1.0 - */ -public class Configuration { - /** Logger. */ - private static final Logger log = LoggerFactory.getLogger(Configuration.class); - - /** - * Delegate application config. - */ - protected final ApplicationConfig applicationConfig; - - private static Configuration instance; - - public static Configuration instance() { - return instance; - } - - public static void setInstance(Configuration instance) { - Configuration.instance = instance; - - // Cascade the application config to the client module - org.duniter.core.client.config.Configuration clientConfig = new org.duniter.core.client.config.Configuration(instance.getApplicationConfig()); - org.duniter.core.client.config.Configuration.setInstance(clientConfig); - } - - protected final String[] optionKeyToNotSave; - - protected File configFile; - - public Configuration(ApplicationConfig applicationConfig) { - super(); - this.applicationConfig = applicationConfig; - this.optionKeyToNotSave = null; - - // Override application version - initVersion(applicationConfig); - } - - public Configuration(String file, String... args) { - super(); - this.applicationConfig = new ApplicationConfig(); - this.applicationConfig.setEncoding(Charsets.UTF_8.name()); - this.applicationConfig.setConfigFileName(file); - - // get all config providers - Set<ApplicationConfigProvider> providers = - ApplicationConfigHelper.getProviders(null, - null, - null, - true); - - // load all default options - ApplicationConfigHelper.loadAllDefaultOption(applicationConfig, - providers); - - // Load actions - for (ApplicationConfigProvider provider : providers) { - applicationConfig.loadActions(provider.getActions()); - } - - // Define Alias - addAlias(applicationConfig); - - // Override application version - initVersion(applicationConfig); - - // get all transient and final option keys - Set<String> optionToSkip = - ApplicationConfigHelper.getTransientOptionKeys(providers); - - if (log.isDebugEnabled()) { - log.debug("Option that won't be saved: " + optionToSkip); - } - optionKeyToNotSave = optionToSkip.toArray(new String[optionToSkip.size()]); - - try { - applicationConfig.parse(args); - - } catch (ArgumentsParserException e) { - throw new TechnicalException(t("duniter4j.config.parse.error"), e); - } - - // TODO Review this, this is very dirty to do this... - File appBasedir = applicationConfig.getOptionAsFile( - ConfigurationOption.BASEDIR.getKey()); - - if (appBasedir == null) { - appBasedir = new File(""); - } - if (!appBasedir.isAbsolute()) { - appBasedir = new File(appBasedir.getAbsolutePath()); - } - if (appBasedir.getName().equals("..")) { - appBasedir = appBasedir.getParentFile().getParentFile(); - } - if (appBasedir.getName().equals(".")) { - appBasedir = appBasedir.getParentFile(); - } - if (log.isInfoEnabled()) { - log.info("Application basedir: " + appBasedir); - } - applicationConfig.setOption( - ConfigurationOption.BASEDIR.getKey(), - appBasedir.getAbsolutePath()); - - // Init other configuration - org.duniter.core.client.config.Configuration coreConfig = new org.duniter.core.client.config.Configuration(applicationConfig); - org.duniter.core.client.config.Configuration.setInstance(coreConfig); - } - - /** - * Override the version default option, from the MANIFEST implementation version (if any) - * @param applicationConfig - */ - protected void initVersion(ApplicationConfig applicationConfig) { - // Override application version - String implementationVersion = this.getClass().getPackage().getSpecificationVersion(); - if (implementationVersion != null) { - applicationConfig.setDefaultOption( - ConfigurationOption.VERSION.getKey(), - implementationVersion); - } - } - - /** - * Add alias to the given ApplicationConfig. <p/> - * This method could be override to add specific alias - * - * @param applicationConfig - */ - protected void addAlias(ApplicationConfig applicationConfig) { - applicationConfig.addAlias("-h", "--option", ConfigurationOption.NODE_BMA_HOST.getKey()); - applicationConfig.addAlias("--host", "--option", ConfigurationOption.NODE_BMA_HOST.getKey()); - applicationConfig.addAlias("-p", "--option", ConfigurationOption.NODE_BMA_PORT.getKey()); - applicationConfig.addAlias("--port", "--option", ConfigurationOption.NODE_BMA_PORT.getKey()); - - applicationConfig.addAlias("-esh", "--option", ConfigurationOption.HOST.getKey()); - applicationConfig.addAlias("--es-host", "--option", ConfigurationOption.HOST.getKey()); - applicationConfig.addAlias("-esp", "--option", ConfigurationOption.PORT.getKey()); - applicationConfig.addAlias("--es-port", "--option", ConfigurationOption.PORT.getKey()); - - applicationConfig.addAlias("--daemon", "--option", ConfigurationOption.DAEMON.getKey(), Boolean.TRUE.toString()); - } - - public File getConfigFile() { - if (configFile == null) { - File dir = getBasedir(); - if (dir == null || !dir.exists()) { - dir = new File(applicationConfig.getUserConfigDirectory()); - } - configFile = new File(dir, applicationConfig.getConfigFileName()); - } - return configFile; - } - - /** @return {@link ConfigurationOption#BASEDIR} value */ - public File getBasedir() { - File result = applicationConfig.getOptionAsFile(ConfigurationOption.BASEDIR.getKey()); - return result; - } - - /** @return {@link ConfigurationOption#DATA_DIRECTORY} value */ - public File getDataDirectory() { - File result = applicationConfig.getOptionAsFile(ConfigurationOption.DATA_DIRECTORY.getKey()); - return result; - } - - /** @return {@link ConfigurationOption#TEMP_DIRECTORY} value */ - public File getTempDirectory() { - File result = applicationConfig.getOptionAsFile(ConfigurationOption.TEMP_DIRECTORY.getKey()); - return result; - } - - /** @return {@link ConfigurationOption#PLUGINS_DIRECTORY} value */ - public File getPluginsDirectory() { - File result = applicationConfig.getOptionAsFile(ConfigurationOption.PLUGINS_DIRECTORY.getKey()); - return result; - } - - /** @return {@link ConfigurationOption#MODE} value */ - public boolean isFullMode() { - String launchMode = applicationConfig.getOption(ConfigurationOption.LAUNCH_MODE.getKey()); - return "full".equals(launchMode); - } - - - public ApplicationConfig getApplicationConfig() { - return applicationConfig; - } - - public Version getVersion() { - return applicationConfig.getOptionAsVersion(ConfigurationOption.VERSION.getKey()); - } - - public File getI18nDirectory() { - return applicationConfig.getOptionAsFile( - ConfigurationOption.I18N_DIRECTORY.getKey()); - } - - public Locale getI18nLocale() { - return applicationConfig.getOptionAsLocale( - ConfigurationOption.I18N_LOCALE.getKey()); - } - - public void setI18nLocale(Locale locale) { - applicationConfig.setOption(ConfigurationOption.I18N_LOCALE.getKey(), locale.toString()); - } - - public String getNodeBmaHost() { - return applicationConfig.getOption(ConfigurationOption.NODE_BMA_HOST.getKey()); - } - - public int getNodeBmaPort() { - return applicationConfig.getOptionAsInt(ConfigurationOption.NODE_BMA_PORT.getKey()); - } - - public String getHost() { - return applicationConfig.getOption(ConfigurationOption.HOST.getKey()); - } - - public String getNetworkHost() { - return applicationConfig.getOption(ConfigurationOption.NETWORK_HOST.getKey()); - } - - public int getPort() { - return applicationConfig.getOptionAsInt(ConfigurationOption.PORT.getKey()); - } - - public boolean isDaemon() { - return applicationConfig.getOptionAsBoolean(ConfigurationOption.DAEMON.getKey()); - } - - public boolean isEmbedded() { - return applicationConfig.getOptionAsBoolean(ConfigurationOption.EMBEDDED_ENABLE.getKey()); - } - - public void setEmbedded(boolean embeddedNode) { - applicationConfig.setOption(ConfigurationOption.EMBEDDED_ENABLE.getKey(), Boolean.toString(embeddedNode)); - } - - public boolean isLocal() { - return applicationConfig.getOptionAsBoolean(ConfigurationOption.LOCAL_ENABLE.getKey()); - } - - public boolean isHttpEnable() { - return applicationConfig.getOptionAsBoolean(ConfigurationOption.HTTP_ENABLE.getKey()); - } - - public String getClusterName() { - return applicationConfig.getOption(ConfigurationOption.CLUSTER_NAME.getKey()); - } - - public int getTaskExecutorQueueCapacity() { - return applicationConfig.getOptionAsInt(ConfigurationOption.TASK_EXECUTOR_QUEUE_CAPACITY.getKey()); - } - - public int getTaskExecutorTimeToIdle() { - return applicationConfig.getOptionAsInt(ConfigurationOption.TASK_EXECUTOR_TIME_TO_IDLE.getKey()); - } - - public boolean isIndexBulkEnable() { - return applicationConfig.getOptionAsBoolean(ConfigurationOption.INDEX_BULK_ENABLE.getKey()); - } - - public int getIndexBulkSize() { - return applicationConfig.getOptionAsInt(ConfigurationOption.INDEX_BULK_SIZE.getKey()); - } - - public String getIndexStringAnalyzer() { - return applicationConfig.getOption(ConfigurationOption.INDEX_STRING_ANALYZER.getKey()); - } -} diff --git a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/config/ConfigurationAction.java b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/config/ConfigurationAction.java deleted file mode 100644 index c3cc408b..00000000 --- a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/config/ConfigurationAction.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.duniter.elasticsearch.config; - -/* - * #%L - * SIH-Adagio :: Shared - * $Id:$ - * $HeadURL:$ - * %% - * Copyright (C) 2012 - 2014 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import org.duniter.elasticsearch.cli.action.HelpCliAction; -import org.duniter.elasticsearch.cli.action.IndexerCliAction; -import org.duniter.elasticsearch.cli.action.NodeCliAction; -import org.nuiton.config.ConfigActionDef; - -public enum ConfigurationAction implements ConfigActionDef { - - HELP(HelpCliAction.class.getName() + "#show", "--help"), - - START(NodeCliAction.class.getName() + "#start", "start"), - - INDEX_BLOCKS(IndexerCliAction.class.getName() + "#indexBlocksFromNode", "index"), - - RESET_ALL_DATA(IndexerCliAction.class.getName() + "#resetAllData", "reset-data"), - - RESET_BLOCKS(IndexerCliAction.class.getName() + "#resetDataBlocks", "reset-blocks"), - - RESET_MARKET(IndexerCliAction.class.getName() + "#resetMarketRecords", "reset-market"), - - RESET_REGISTRY(IndexerCliAction.class.getName() + "#resetRegistry", "reset-registry"); - - public String action; - public String[] aliases; - - private ConfigurationAction(String action, String... aliases) { - this.action = action; - this.aliases = aliases; - } - - @Override - public String getAction() { - return action; - } - - @Override - public String[] getAliases() { - return aliases; - } -} diff --git a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/config/ConfigurationOption.java b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/config/ConfigurationOption.java deleted file mode 100644 index 0e15103b..00000000 --- a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/config/ConfigurationOption.java +++ /dev/null @@ -1,298 +0,0 @@ -package org.duniter.elasticsearch.config; - -/* - * #%L - * Tutti :: Persistence - * $Id: TuttiConfigurationOption.java 1441 2013-12-09 20:13:47Z tchemit $ - * $HeadURL: http://svn.forge.codelutin.com/svn/tutti/trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiConfigurationOption.java $ - * %% - * Copyright (C) 2012 - 2013 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import org.nuiton.config.ConfigOptionDef; -import org.nuiton.util.Version; - -import java.io.File; -import java.net.URL; -import java.util.Locale; - -import static org.nuiton.i18n.I18n.n; - -/** - * All application configuration options. - * - * @author Benoit Lavenier <benoit.lavenier@e-is.pro> - * @since 1.0 - */ -public enum ConfigurationOption implements ConfigOptionDef { - - - // ------------------------------------------------------------------------// - // -- READ-ONLY OPTIONS ---------------------------------------------------// - // ------------------------------------------------------------------------// - - - BASEDIR( - "duniter4j.basedir", - n("duniter4j.config.option.basedir.description"), - "${user.home}/.config/duniter-es", - File.class), - - DATA_DIRECTORY( - "duniter4j.data.directory", - n("duniter4j.config.option.data.directory.description"), - "${duniter4j.basedir}/data", - File.class), - - TEMP_DIRECTORY( - "duniter4j.temp.directory", - n("duniter4j.config.option.temp.directory.description"), - "${duniter4j.basedir}/temp", - File.class), - - PLUGINS_DIRECTORY( - "duniter4j.plugins.directory", - n("duniter4j.config.option.plugins.directory.description"), - "${duniter4j.basedir}/plugins", - File.class), - - LAUNCH_MODE( - "duniter4j.launch.mode", - n("duniter4j.config.option.launch.mode.description"), - "dev", - String.class), - - I18N_DIRECTORY( - "duniter4j.i18n.directory", - n("duniter4j.config.option.i18n.directory.description"), - "${duniter4j.basedir}/i18n", - File.class), - - VERSION( - "duniter4j.version", - n("duniter4j.config.option.version.description"), - "1.0", - Version.class), - - // ------------------------------------------------------------------------// - // -- READ-WRITE OPTIONS ---------------------------------------------------// - // ------------------------------------------------------------------------// - - I18N_LOCALE( - "duniter4j.i18n.locale", - n("duniter4j.config.option.i18n.locale.description"), - Locale.FRANCE.getCountry(), - Locale.class, - false), - - NODE_BMA_HOST( - "duniter4j.node.host", - n("duniter4j.config.option.node.host.description"), - "metab.ucoin.io", - String.class, - false), - - NODE_BMA_PORT( - "duniter4j.node.port", - n("duniter4j.config.option.node.port.description"), - "9201", - Integer.class, - false), - - NODE_BMA_URL( - "duniter4j.node.url", - n("duniter4j.config.option.node.port.description"), - "${duniter4j.node.protocol}://${duniter4j.node.host}:${duniter4j.node.port}", - URL.class, - false), - - HOST( - "duniter4j.elasticsearch.host", - n("duniter4j.config.option.elasticsearch.host.description"), - "localhost", - String.class, - false), - - PORT( - "duniter4j.elasticsearch.port", - n("duniter4j.config.option.node.elasticsearch.port.description"), - "9300", - Integer.class, - false), - - NETWORK_HOST( - "duniter4j.elasticsearch.network.host", - n("duniter4j.config.option.elasticsearch.network.host.description"), - "_local_", - String.class, - false), - - DAEMON( - "duniter4j.elasticsearch.daemon", - n("duniter4j.config.option.node.elasticsearch.daemon.description"), - "false", - Boolean.class, - false), - - EMBEDDED_ENABLE( - "duniter4j.elasticsearch.embedded.enable", - n("duniter4j.config.option.elasticsearch.embedded.enable.description"), - "false", - Boolean.class, - false), - - LOCAL_ENABLE( - "duniter4j.elasticsearch.local", - n("duniter4j.config.option.elasticsearch.local.description"), - "false", - Boolean.class, - false), - - HTTP_ENABLE( - "duniter4j.elasticsearch.http.enable", - n("duniter4j.config.option.node.elasticsearch.http.enable.description"), - "true", - Boolean.class, - false), - - CLUSTER_NAME( - "duniter4j.elasticsearch.cluster.name", - n("duniter4j.config.option.elasticsearch.cluster.name.description"), - "duniter4j-elasticsearch", - String.class, - false), - - INDEX_BULK_ENABLE( - "duniter4j.elasticsearch.bulk.enable", - n("duniter4j.config.option.elasticsearch.bulk.enable.description"), - "true", - Boolean.class, - false), - - INDEX_BULK_SIZE( - "duniter4j.elasticsearch.bulk.size", - n("duniter4j.config.option.elasticsearch.bulk.size.description"), - "1000", - Integer.class, - false), - - INDEX_STRING_ANALYZER( - "duniter4j.elasticsearch.string.analyzer", - n("duniter4j.config.option.elasticsearch.string.analyze.description"), - "french", - String.class, - false), - - TASK_EXECUTOR_QUEUE_CAPACITY( - "duniter4j.elasticsearch.tasks.queueCapacity", - n("duniter4j.config.option.tasks.queueCapacity.description"), - "50", - Integer.class, - false), - - TASK_EXECUTOR_TIME_TO_IDLE( - "duniter4j.elasticsearch.tasks.timeToIdle", - "duniter4j.elasticsearch.tasks.timeToIdle.description", - "180", // 180s = 3min - Integer.class, - false) - ; - - /** Configuration key. */ - private final String key; - - /** I18n key of option description */ - private final String description; - - /** Type of option */ - private final Class<?> type; - - /** Default value of option. */ - private String defaultValue; - - /** Flag to not keep option value on disk */ - private boolean isTransient; - - /** Flag to not allow option value modification */ - private boolean isFinal; - - ConfigurationOption(String key, - String description, - String defaultValue, - Class<?> type, - boolean isTransient) { - this.key = key; - this.description = description; - this.defaultValue = defaultValue; - this.type = type; - this.isTransient = isTransient; - this.isFinal = isTransient; - } - - ConfigurationOption(String key, - String description, - String defaultValue, - Class<?> type) { - this(key, description, defaultValue, type, true); - } - - @Override - public String getKey() { - return key; - } - - @Override - public Class<?> getType() { - return type; - } - - @Override - public String getDescription() { - return description; - } - - @Override - public String getDefaultValue() { - return defaultValue; - } - - @Override - public boolean isTransient() { - return isTransient; - } - - @Override - public boolean isFinal() { - return isFinal; - } - - @Override - public void setDefaultValue(String defaultValue) { - this.defaultValue = defaultValue; - } - - @Override - public void setTransient(boolean newValue) { - // not used - } - - @Override - public void setFinal(boolean newValue) { - // not used - } -} diff --git a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/config/ConfigurationProvider.java b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/config/ConfigurationProvider.java deleted file mode 100644 index c82d0f1f..00000000 --- a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/config/ConfigurationProvider.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.duniter.elasticsearch.config; - -/* - * #%L - * Tutti :: Persistence - * $Id: TuttiConfigurationProvider.java 1418 2013-12-01 21:18:22Z tchemit $ - * $HeadURL: http://svn.forge.codelutin.com/svn/tutti/trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/TuttiConfigurationProvider.java $ - * %% - * Copyright (C) 2012 - 2013 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import org.nuiton.config.ApplicationConfigProvider; -import org.nuiton.config.ConfigActionDef; -import org.nuiton.config.ConfigOptionDef; - -import java.util.Locale; - -import static org.nuiton.i18n.I18n.l; - -/** - * Config provider (for site generation). - * - * @author Benoit Lavenier <benoit.lavenier@e-is.pro> - */ -public class ConfigurationProvider implements ApplicationConfigProvider { - - @Override - public String getName() { - return "duniter4j"; - } - - @Override - public String getDescription(Locale locale) { - return l(locale, "duniter4j-elasticsearch.config"); - } - - @Override - public ConfigOptionDef[] getOptions() { - return ConfigurationOption.values(); - } - - @Override - public ConfigActionDef[] getActions() { - return ConfigurationAction.values(); - } -} diff --git a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/job/BlockIndexer.java b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/job/BlockIndexer.java new file mode 100644 index 00000000..74a6b812 --- /dev/null +++ b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/job/BlockIndexer.java @@ -0,0 +1,212 @@ +package org.duniter.elasticsearch.job; + +import org.duniter.core.client.model.bma.BlockchainParameters; +import org.duniter.core.client.model.local.Peer; +import org.duniter.core.client.service.bma.BlockchainRemoteService; +import org.duniter.core.util.StringUtils; +import org.duniter.elasticsearch.PluginSettings; +import org.duniter.elasticsearch.service.ServiceLocator; +import org.duniter.elasticsearch.service.blockchain.BlockBlockchainService; +import org.duniter.elasticsearch.service.market.CategoryMarketService; +import org.duniter.elasticsearch.service.market.RecordMarketService; +import org.duniter.elasticsearch.service.registry.CategoryRegistryService; +import org.duniter.elasticsearch.service.registry.CitiesRegistryService; +import org.duniter.elasticsearch.service.registry.CurrencyRegistryService; +import org.duniter.elasticsearch.service.registry.RecordRegistryService; +import org.elasticsearch.common.component.Lifecycle; +import org.elasticsearch.common.component.LifecycleComponent; +import org.elasticsearch.common.component.LifecycleListener; +import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.logging.ESLogger; +import org.elasticsearch.common.logging.ESLoggerFactory; + +/** + * Created by eis on 17/06/16. + */ +public class BlockIndexer implements LifecycleComponent<BlockIndexer> { + private static final ESLogger log = ESLoggerFactory.getLogger(BlockIndexer.class.getName()); + + private Lifecycle.State state; + + private ServiceLocator serviceLocator; + private PluginSettings pluginSettings; + private RecordMarketService recordMarketService; + private CurrencyRegistryService currencyRegistryService; + private BlockBlockchainService blockBlockchainService; + private CategoryMarketService categoryMarketService; + private RecordRegistryService recordRegistryService; + private CategoryRegistryService categoryRegistryService; + private CitiesRegistryService citiesRegistryService; + + @Inject + public BlockIndexer(ServiceLocator serviceLocator, + PluginSettings pluginSettings, + RecordMarketService recordMarketService, + CurrencyRegistryService currencyRegistryService, + BlockBlockchainService blockBlockchainService, + CategoryMarketService categoryMarketService, + RecordRegistryService recordRegistryService, + CategoryRegistryService categoryRegistryService, + CitiesRegistryService citiesRegistryService + ) { + this.serviceLocator = serviceLocator; + this.pluginSettings = pluginSettings; + this.recordMarketService = recordMarketService; + this.currencyRegistryService = currencyRegistryService; + this.blockBlockchainService = blockBlockchainService; + this.categoryMarketService = categoryMarketService; + this.recordRegistryService = recordRegistryService; + this.categoryRegistryService = categoryRegistryService; + this.citiesRegistryService = citiesRegistryService; + this.state = Lifecycle.State.INITIALIZED; + } + + @Override + public Lifecycle.State lifecycleState() { + return state; + } + + @Override + public void addLifecycleListener(LifecycleListener var1){ + // TODO + } + + @Override + public void removeLifecycleListener(LifecycleListener var1){ + // TODO + } + + @Override + public BlockIndexer start(){ + state = Lifecycle.State.STARTED; + if (log.isDebugEnabled()) { + log.debug(String.format("Starting indexing blocks from node [%s:%s]...", + pluginSettings.getNodeBmaHost(), pluginSettings.getNodeBmaPort())); + } + + //resetAllData(); + return this; + } + + @Override + public BlockIndexer stop(){ + state = Lifecycle.State.STOPPED; + return this; + } + + @Override + public void close() { + state = Lifecycle.State.STOPPED; + } + + /* -- protected methods -- */ + + protected void setState(Lifecycle.State state) { + this.state = state; + } + + public void resetAllData() { + resetAllCurrencies(); + //resetDataBlocks(); + //resetMarketRecords(); + //resetRegistry(); + } + + public void resetAllCurrencies() { + currencyRegistryService.deleteAllCurrencies(); + } + + public void resetDataBlocks() { + BlockchainRemoteService blockchainService = serviceLocator.getBlockchainRemoteService(); + Peer peer = checkConfigAndGetPeer(pluginSettings); + + try { + // Get the blockchain name from node + BlockchainParameters parameter = blockchainService.getParameters(peer); + if (parameter == null) { + log.error(String.format("Could not connect to node [%s:%s]", + pluginSettings.getNodeBmaHost(), pluginSettings.getNodeBmaPort())); + return; + } + String currencyName = parameter.getCurrency(); + + log.info(String.format("Reset data for index [%s]", currencyName)); + + // Delete then create index on blockchain + boolean indexExists = blockBlockchainService.existsIndex(currencyName); + if (indexExists) { + blockBlockchainService.deleteIndex(currencyName); + blockBlockchainService.createIndex(currencyName); + } + + + log.info(String.format("Successfully reset data for index [%s]", currencyName)); + } catch(Exception e) { + log.error("Error during reset data: " + e.getMessage(), e); + } + } + + public void resetMarketRecords() { + try { + // Delete then create index on records + boolean indexExists = recordMarketService.existsIndex(); + if (indexExists) { + recordMarketService.deleteIndex(); + } + log.info(String.format("Successfully reset market records")); + + categoryMarketService.createIndex(); + categoryMarketService.initCategories(); + log.info(String.format("Successfully re-initialized market categories data")); + + } catch(Exception e) { + log.error("Error during reset market records: " + e.getMessage(), e); + } + } + + public void resetRegistry() { + try { + // Delete then create index on records + if (recordRegistryService.existsIndex()) { + recordRegistryService.deleteIndex(); + } + recordRegistryService.createIndex(); + log.info(String.format("Successfully reset registry records")); + + + if (categoryRegistryService.existsIndex()) { + categoryRegistryService.deleteIndex(); + } + categoryRegistryService.createIndex(); + categoryRegistryService.initCategories(); + log.info(String.format("Successfully re-initialized registry categories")); + + if (citiesRegistryService.existsIndex()) { + citiesRegistryService.deleteIndex(); + } + citiesRegistryService.initCities(); + log.info(String.format("Successfully re-initialized registry cities")); + + } catch(Exception e) { + log.error("Error during reset registry records: " + e.getMessage(), e); + } + } + + /* -- internal methods -- */ + + protected Peer checkConfigAndGetPeer(PluginSettings pluginSettings) { + if (StringUtils.isBlank(pluginSettings.getNodeBmaHost())) { + log.error("ERROR: node host is required"); + System.exit(-1); + return null; + } + if (pluginSettings.getNodeBmaPort() <= 0) { + log.error("ERROR: node port is required"); + System.exit(-1); + return null; + } + + Peer peer = new Peer(pluginSettings.getNodeBmaHost(), pluginSettings.getNodeBmaPort()); + return peer; + } +} diff --git a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/plugin/Plugin.java b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/plugin/Plugin.java deleted file mode 100644 index 81ea20a6..00000000 --- a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/plugin/Plugin.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.duniter.elasticsearch.plugin; - -/* - * #%L - * duniter4j-elasticsearch-plugin - * %% - * Copyright (C) 2014 - 2016 EIS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import com.google.common.collect.Lists; -import org.duniter.elasticsearch.action.RestModule; -import org.duniter.elasticsearch.security.SecurityModule; -import org.elasticsearch.common.inject.Module; - -import java.util.Collection; - -public class Plugin extends org.elasticsearch.plugins.Plugin { - - @Override - public String name() { - return "duniter4j-elasticsearch"; - } - - @Override - public String description() { - return "Duniter4j ElasticSearch Plugin"; - } - - @Override - public Collection<Module> nodeModules() { - Collection<Module> modules = Lists.newArrayList(); - modules.add(new SecurityModule()); - modules.add(new RestModule()); - return modules; - } - - /* -- protected methods -- */ - - protected void initInstance() { - - } -} \ No newline at end of file diff --git a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/BaseIndexerService.java b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/AbstractService.java similarity index 67% rename from duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/BaseIndexerService.java rename to duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/AbstractService.java index 12a0c323..5a88d438 100644 --- a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/BaseIndexerService.java +++ b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/AbstractService.java @@ -25,57 +25,126 @@ package org.duniter.elasticsearch.service; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Preconditions; -import org.duniter.core.beans.Bean; -import org.duniter.core.beans.InitializingBean; import org.duniter.core.exception.TechnicalException; import org.duniter.core.util.StringUtils; +import org.duniter.elasticsearch.PluginSettings; import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequestBuilder; import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequestBuilder; import org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsResponse; import org.elasticsearch.action.bulk.BulkRequest; +import org.elasticsearch.client.AdminClient; import org.elasticsearch.client.Client; import org.elasticsearch.client.Requests; +import org.elasticsearch.client.transport.TransportClient; import org.elasticsearch.common.bytes.BytesArray; +import org.elasticsearch.common.component.Lifecycle; +import org.elasticsearch.common.component.LifecycleComponent; +import org.elasticsearch.common.component.LifecycleListener; +import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.logging.ESLogger; +import org.elasticsearch.common.logging.ESLoggerFactory; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.transport.InetSocketTransportAddress; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.elasticsearch.node.NodeBuilder; import java.io.*; +import java.net.InetAddress; +import java.net.UnknownHostException; /** * Created by Benoit on 08/04/2015. */ -public abstract class BaseIndexerService implements Bean, InitializingBean, Closeable { +public abstract class AbstractService<T> implements LifecycleComponent<T>{ - private static final Logger log = LoggerFactory.getLogger(BaseIndexerService.class); - private ElasticSearchService elasticSearchService; + private static final ESLogger log = ESLoggerFactory.getLogger(AbstractService.class.getName()); - public BaseIndexerService() { + private Lifecycle.State state; + + private Client client; + private AdminClient admin; + + private PluginSettings pluginSettings; + + private ObjectMapper objectMapper; + + @Inject + public AbstractService(Client client, PluginSettings pluginSettings) { + this.client = client; + this.pluginSettings = pluginSettings; + this.objectMapper = new ObjectMapper(); + this.state = Lifecycle.State.INITIALIZED; + } + + + @Override + public Lifecycle.State lifecycleState() { + return state; + } + + @Override + public void addLifecycleListener(LifecycleListener var1){ + // TODO } @Override - public void afterPropertiesSet() throws Exception { - this.elasticSearchService = ServiceLocator.instance().getElasticSearchService(); + public void removeLifecycleListener(LifecycleListener var1){ + // TODO } @Override - public void close() throws IOException { - this.elasticSearchService = null; + public T start(){ + state = Lifecycle.State.STARTED; + return (T)this; + } + + @Override + public T stop(){ + state = Lifecycle.State.STOPPED; + return (T)this; + } + + @Override + public void close() { + state = Lifecycle.State.STOPPED; } /* -- protected methods -- */ + protected void setState(Lifecycle.State state) { + this.state = state; + } + protected Client getClient() { - return elasticSearchService.getClient(); + return client; + } + + protected PluginSettings getPluginSettings() { + return pluginSettings; } protected ObjectMapper getObjectMapper() { - return elasticSearchService.getObjectMapper(); + return objectMapper; } protected boolean existsIndex(String indexes) { - IndicesExistsRequestBuilder requestBuilder = getClient().admin().indices().prepareExists(indexes); + //if (admin == null) { + Settings.Builder settings = Settings.settingsBuilder() + .put("cluster.name", "duniter4j-elasticsearch") + .put("client.transport.sniff", true); + Client client = null; + try { + client = TransportClient.builder().settings(settings) + .build() + .addTransportAddress(new InetSocketTransportAddress( + InetAddress.getByName("localhost"), 9300)); + } catch (UnknownHostException e) { + throw new TechnicalException(e); + } + // admin = client.admin(); + //} + IndicesExistsRequestBuilder requestBuilder = client.admin().indices().prepareExists(indexes); IndicesExistsResponse response = requestBuilder.execute().actionGet(); return response.isExists(); @@ -87,7 +156,7 @@ public abstract class BaseIndexerService implements Bean, InitializingBean, Clos } log.info(String.format("Deleting index [%s]", indexName)); - DeleteIndexRequestBuilder deleteIndexRequestBuilder = getClient().admin().indices().prepareDelete(indexName); + DeleteIndexRequestBuilder deleteIndexRequestBuilder = client.admin().indices().prepareDelete(indexName); deleteIndexRequestBuilder.execute().actionGet(); } diff --git a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/ElasticSearchService.java b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/ElasticSearchService.java deleted file mode 100644 index df87b5ef..00000000 --- a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/ElasticSearchService.java +++ /dev/null @@ -1,255 +0,0 @@ -package org.duniter.elasticsearch.service; - -/* - * #%L - * UCoin Java Client :: Core API - * %% - * Copyright (C) 2014 - 2015 EIS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - - -import com.fasterxml.jackson.databind.ObjectMapper; -import org.duniter.core.beans.Bean; -import org.duniter.core.beans.InitializingBean; -import org.duniter.core.exception.TechnicalException; -import org.duniter.core.util.StringUtils; -import org.duniter.elasticsearch.config.Configuration; -import org.elasticsearch.client.Client; -import org.elasticsearch.client.transport.TransportClient; -import org.elasticsearch.common.logging.ESLoggerFactory; -import org.elasticsearch.common.logging.slf4j.Slf4jESLoggerFactory; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.transport.InetSocketTransportAddress; -import org.elasticsearch.node.Node; -import org.elasticsearch.node.NodeBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.Closeable; -import java.io.File; -import java.io.IOException; -import java.net.InetAddress; -import java.net.UnknownHostException; - -/** - * Created by Benoit on 08/04/2015. - */ -public class ElasticSearchService implements Bean,InitializingBean, Closeable { - - private static final Logger log = LoggerFactory.getLogger(ElasticSearchService.class); - private Client client; - private Node node; - private boolean localNode = false; - private ObjectMapper objectMapper; - - public ElasticSearchService() { - node = null; - } - - @Override - public void afterPropertiesSet() { - - Configuration config = Configuration.instance(); - - // Define Slf4j as ES logging framework - ESLoggerFactory.setDefaultFactory(new Slf4jESLoggerFactory()); - - // Create the object mapper - objectMapper = new ObjectMapper(); - - // Create the local node, if need (useful in dev mode) - if (config.isEmbedded()) { - startNode(); - } - - // Create the client - client = createClient(); - } - - public void startNode() { - Configuration config = Configuration.instance(); - startNode( - config.isHttpEnable(), - config.isLocal()); - } - - public boolean isNodeInstance() { - return node != null && !localNode; - } - - public void startNode(boolean enableHttp, boolean local) { - - if (node != null && !localNode) { - //already running - return; - } - - // Close client and node - try { - close(); - } - catch(IOException e) { - // continue - } - client = null; - - node = createNode(enableHttp, local); - client = createClient(); - } - - public void stopNode() { - // Close client and node - try { - close(); - } - catch(IOException e) { - // continue - } - - // Only recreate the client - client = createClient(); - } - - @Override - public void close() throws IOException { - - // Closing the client (if exists) - if (client != null) { - if (log.isDebugEnabled()) { - log.debug("Closing ElasticSearch client"); - } - client.close(); - client = null; - } - - // Closing the node (if exists) - if (node != null) { - log.info("Closing ElasticSearch node"); - - node.close(); - node = null; - } - } - - public Client getClient() { - return client; - } - - public Node getNode() { - return node; - } - - public ObjectMapper getObjectMapper() { - return objectMapper; - } - - /* -- internal methods -- */ - - protected Node createNode(boolean enableHttp, boolean local) { - - Configuration config = Configuration.instance(); - String clusterName = config.getClusterName(); - this.localNode = local; - - // Log starting - if (local) { - if (StringUtils.isNotBlank(clusterName)) { - log.warn(String.format("Starts ElasticSearch as [local] node with cluster name [%s] at [%s]. Local node are not recommended for production deployment.", clusterName, config.getDataDirectory())); - } else { - log.warn(String.format("Starts ElasticSearch as [local] node at [%s]. Local node are not recommended for production deployment.", config.getDataDirectory())); - } - } - else { - if (StringUtils.isNotBlank(clusterName)) { - log.info(String.format("Starts ElasticSearch node with cluster name [%s] at [%s].", clusterName, config.getDataDirectory())); - } else { - log.warn(String.format("Starts ElasticSearch node at [%s] without cluster name. Having no cluster name is not recommended for production deployment.", config.getDataDirectory())); - } - } - - Settings.Builder builder = Settings.settingsBuilder() - .put("http.enabled", enableHttp) - .put("path.home", config.getBasedir()) - .put("path.data", config.getDataDirectory()) - .put("path.plugins", config.getPluginsDirectory()) - .put("http.host", config.getHost()) - .put("http.cors.enabled", Boolean.TRUE.toString()); - - // Set network host - if (!local && enableHttp - && StringUtils.isNotBlank(config.getNetworkHost())) { - if (!"localhost".equalsIgnoreCase(config.getNetworkHost())) { - builder.put("network.host", config.getNetworkHost()); - } - } - - // Create a node builder - NodeBuilder nodeBuilder = NodeBuilder.nodeBuilder() - .clusterName(clusterName) - .settings(builder.build()) - .local(local); - - if (StringUtils.isNotBlank(clusterName)) { - nodeBuilder.clusterName(clusterName); - } - - // Start the node from builder - Node node = nodeBuilder.node().start(); - - return node; - } - - protected Client createClient() { - if (node != null) { - return node.client(); - } - - Configuration config = Configuration.instance(); - String host = config.getHost(); - int port = config.getPort(); - String clusterName = config.getClusterName(); - File dataDirectory = new File(config.getDataDirectory(), "client"); - - if (log.isDebugEnabled()) { - log.debug(String.format("Starts ElasticSearch client for node [%s:%s] at [%s]", host, port, dataDirectory)); - } - - - Settings.Builder settings = Settings.settingsBuilder() - .put("path.home", config.getBasedir()) - .put("path.data", dataDirectory); - - if (StringUtils.isNotBlank(clusterName)) { - settings.put("cluster.name", clusterName); - } - else { - settings.put("client.transport.ignore_cluster_name", true); - log.warn("Ignoring cluster name verification (no cluster name found in configuration). This is not recommended for production deployment."); - } - - // Create the transport Client - try { - return TransportClient.builder() - .settings(settings.build()) - .build() - .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(host), port)); - } catch (UnknownHostException e) { - throw new TechnicalException(e); - } - } -} diff --git a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/ExecutorService.java b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/ExecutorService.java deleted file mode 100644 index 266d34af..00000000 --- a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/ExecutorService.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.duniter.elasticsearch.service; - -/* - * #%L - * UCoin Java Client :: ElasticSearch Indexer - * %% - * Copyright (C) 2014 - 2016 EIS - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - - -import org.duniter.core.beans.Service; -import org.duniter.core.model.ProgressionModel; -import org.duniter.elasticsearch.service.task.Job; -import org.duniter.elasticsearch.service.task.JobVO; - -import java.util.List; -import java.util.Locale; - -public interface ExecutorService extends Service{ - - void stop(String jobId); - - Job execute(Runnable runnable, String jobId, String issuer, Locale locale, ProgressionModel progression); - - void execute(Runnable runnable); - - ProgressionModel getProgressionByJobId(String jobId); - - List<JobVO> getAllJobs(); -} diff --git a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/ExecutorServiceImpl.java b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/ExecutorServiceImpl.java deleted file mode 100644 index 7cc58b18..00000000 --- a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/ExecutorServiceImpl.java +++ /dev/null @@ -1,278 +0,0 @@ -package org.duniter.elasticsearch.service; - -/* - * #%L - * SIH-Adagio :: Synchro Server WebApp - * $Id:$ - * $HeadURL:$ - * %% - * Copyright (C) 2012 - 2014 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - - -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.util.concurrent.*; -import org.duniter.core.beans.InitializingBean; -import org.duniter.core.exception.TechnicalException; -import org.duniter.core.model.ProgressionModel; -import org.duniter.core.model.ProgressionModelImpl; -import org.duniter.elasticsearch.config.Configuration; -import org.duniter.elasticsearch.service.task.Job; -import org.duniter.elasticsearch.service.task.JobFuture; -import org.duniter.elasticsearch.service.task.JobVO; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.i18n.I18n; - -import java.io.IOException; -import java.sql.SQLException; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - -import static org.nuiton.i18n.I18n.l; - -public class ExecutorServiceImpl implements ExecutorService, InitializingBean { - - /** Logger. */ - private static final Log log = LogFactory.getLog(ExecutorServiceImpl.class); - - - private Configuration config; - private ListeningExecutorService delegate; - private final Map<String, JobFuture> jobsById; - private final LoadingCache<String, ProgressionModel> progressionByJobIdCache; - - public ExecutorServiceImpl() { - this.jobsById = Maps.newHashMap(); - this.config = Configuration.instance(); - this.progressionByJobIdCache = initJobByIdCache( - config.getTaskExecutorQueueCapacity() * 2, - config.getTaskExecutorTimeToIdle()); - delegate = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(config.getTaskExecutorQueueCapacity())); - } - - @Override - public void afterPropertiesSet() throws Exception { - - } - - @Override - public void close() throws IOException { - - log.debug("Closing executor service"); - - synchronized (jobsById) { - - for (ListenableFuture<Job> task : jobsById.values()) { - task.cancel(true); - } - jobsById.clear(); - - for (ProgressionModel progressionModel : progressionByJobIdCache.asMap().values()) { - progressionModel.cancel(); - } - progressionByJobIdCache.cleanUp(); - } - - if (!delegate.isShutdown()) { - delegate.shutdownNow(); - } - } - - @Override - public ProgressionModel getProgressionByJobId(String jobId) { - if (StringUtils.isBlank(jobId)) { - return null; - } - synchronized (jobsById) { - ListenableFuture<Job> job = jobsById.get(jobId); - if (job != null) { - try { - return job.get().getProgressionModel(); - } - catch(InterruptedException | ExecutionException e) { - // continue - } - } - } - - // Call the cache, but return null if the key is not present - return progressionByJobIdCache.getIfPresent(jobId); - } - - @Override - public void execute(Runnable runnable) { - execute(runnable, "duniter4j|job|" + System.currentTimeMillis(), null, Locale.getDefault(), new ProgressionModelImpl()); - } - - @Override - public Job execute(Runnable runnable, String jobId, String issuer, Locale locale, ProgressionModel progression) { - - // Make sure no import already launched - ProgressionModel existingProgression = getProgressionByJobId(jobId); - if (existingProgression != null && existingProgression.getStatus() == ProgressionModel.Status.RUNNING) { - throw new TechnicalException("Could not start a new synchronization: already running."); - } - - // Run the synchro thread - final Job job = new Job( - runnable, - jobId, - issuer, - locale, - progression); - - // Execute the job - shedule(jobId, - job, - l(locale, "duniter4j.task.starting"), - locale); - - return job; - } - - @Override - public void stop(String jobId) { - JobFuture job = jobsById.get(jobId); - if (job != null) { - job.cancel(false); - } - } - - @Override - public List<JobVO> getAllJobs() { - synchronized (jobsById) { - List<JobVO> result = Lists.newArrayListWithExpectedSize(jobsById.size()); - for (Map.Entry<String, JobFuture> entry : jobsById.entrySet()) { - String jobId = entry.getKey(); - Job job = entry.getValue().getJob(); - - // System job - String issuer = job.getIssuer(); - if (StringUtils.isBlank(issuer)) { - issuer = I18n.t("duniter4j.task.issuer.system"); - } - - JobVO jobVO = new JobVO( - jobId, - issuer - ); - - result.add(jobVO); - } - return result; - } - } - - public Job getJobById(String jobId) { - synchronized (jobsById) { - JobFuture jobFuture = jobsById.get(jobId); - if (jobFuture != null) { - return jobFuture.getJob(); - } - return null; - } - } - - /* -- Internal methods -- */ - - protected final LoadingCache<String, ProgressionModel> initJobByIdCache( - final int maximumSize, - final int expireDurationInSecond) { - return CacheBuilder.newBuilder() - .maximumSize(maximumSize) - .expireAfterWrite(expireDurationInSecond, TimeUnit.SECONDS) - .build( - new CacheLoader<String, ProgressionModel>() { - @Override - public ProgressionModel load(String jobId) throws SQLException { - Job job = getJobById(jobId); - if (job == null) { - throw new TechnicalException("Unknown task id"); - } - return job.getProgressionModel(); - } - }); - } - - protected void shedule(final String jobId, - final Job job, - String taskMessage, - final Locale locale) { - - // Set progression as as 'waiting execution' - final ProgressionModel progressionModel = job.getProgressionModel(); - progressionModel.setTask(taskMessage); - progressionModel.setMessage(l(locale, "duniter4j.executor.task.waitingExecution")); - progressionModel.setStatus(ProgressionModel.Status.WAITING_EXECUTION); - - - ListenableFuture<Job> future = delegate.submit(new Callable<Job>(){ - @Override - public Job call() throws Exception { - job.run(); - return job; - } - }); - - JobFuture jobFuture = new JobFuture(job, future); - Futures.addCallback(jobFuture, new FutureCallback<Job>() { - @Override - public void onSuccess(Job result) { - onJobFinish(jobId, progressionModel); - } - - @Override - public void onFailure(Throwable t) { - // TODO EIS : remove this (and log into the progress message instead ?) - log.error(t); - onJobFinish(jobId, progressionModel); - } - }); - - // start job - onJobScheduled(jobId, job, jobFuture); - } - - protected void onJobScheduled(final String jobId, final Job job, final JobFuture jobFuture) { - synchronized (jobsById) { - jobsById.put(jobId, jobFuture); - } - } - - protected void onJobFinish(final String jobId, final ProgressionModel progressionModel) { - synchronized (jobsById) { - // Before to remove from jobsById map, put the progressionModel again into the cache - // To avoid a getStatus() does not get retrieve it (mantis #23391) - progressionByJobIdCache.put(jobId, progressionModel); - - // ok, progressionModel is in the cache, so remove from map - jobsById.remove(jobId); - } - } -} diff --git a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/ServiceLocator.java b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/ServiceLocator.java index d5ecf755..cd2e54c2 100644 --- a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/ServiceLocator.java +++ b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/ServiceLocator.java @@ -23,70 +23,69 @@ package org.duniter.elasticsearch.service; */ -import org.duniter.elasticsearch.service.currency.BlockIndexerService; -import org.duniter.elasticsearch.service.market.MarketCategoryIndexerService; -import org.duniter.elasticsearch.service.market.MarketRecordIndexerService; -import org.duniter.elasticsearch.service.registry.RegistryCategoryIndexerService; -import org.duniter.elasticsearch.service.registry.RegistryCurrencyIndexerService; -import org.duniter.elasticsearch.service.registry.RegistryRecordIndexerService; -import org.duniter.elasticsearch.service.registry.RegistryCitiesIndexerService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ServiceLocator extends org.duniter.core.client.service.ServiceLocator { - - - /* Logger */ - private static final Logger log = LoggerFactory.getLogger(ServiceLocator.class); - - /** - * The shared instance of this ServiceLocator. - */ - private static ServiceLocator instance = new ServiceLocator(); - - static { - org.duniter.core.client.service.ServiceLocator.setInstance(instance); - } - - public static ServiceLocator instance() { - return instance; - } - - /* -- ElasticSearch Service-- */ - - public RegistryCurrencyIndexerService getRegistryCurrencyIndexerService() { - return getBean(RegistryCurrencyIndexerService.class); - } - - public ElasticSearchService getElasticSearchService() { - return getBean(ElasticSearchService.class); - } - - public BlockIndexerService getBlockIndexerService() { - return getBean(BlockIndexerService.class); - } - - public ExecutorService getExecutorService() { - return getBean(ExecutorService.class); - } - - public MarketRecordIndexerService getMarketRecordIndexerService() { - return getBean(MarketRecordIndexerService.class); - } - - public MarketCategoryIndexerService getMarketCategoryIndexerService() { - return getBean(MarketCategoryIndexerService.class); - } - - public RegistryRecordIndexerService getRegistryRecordIndexerService() { - return getBean(RegistryRecordIndexerService.class); +import org.duniter.core.beans.BeanFactory; +import org.duniter.core.client.dao.CurrencyDao; +import org.duniter.core.client.dao.PeerDao; +import org.duniter.core.client.dao.mem.MemoryCurrencyDaoImpl; +import org.duniter.core.client.dao.mem.MemoryPeerDaoImpl; +import org.duniter.core.client.service.DataContext; +import org.duniter.core.client.service.HttpService; +import org.duniter.core.client.service.HttpServiceImpl; +import org.duniter.core.client.service.bma.*; +import org.duniter.core.client.service.local.CurrencyService; +import org.duniter.core.client.service.local.CurrencyServiceImpl; +import org.duniter.core.client.service.local.PeerService; +import org.duniter.core.client.service.local.PeerServiceImpl; +import org.duniter.core.exception.TechnicalException; +import org.duniter.core.service.CryptoService; +import org.duniter.core.service.Ed25519CryptoServiceImpl; +import org.duniter.elasticsearch.PluginSettings; +import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.inject.Singleton; +import org.elasticsearch.common.logging.ESLogger; +import org.elasticsearch.common.logging.ESLoggerFactory; + +import java.io.IOException; + +@Singleton +public class ServiceLocator + extends org.duniter.core.client.service.ServiceLocator + { + private static final ESLogger log = ESLoggerFactory.getLogger(ServiceLocator.class.getName()); + + public ServiceLocator() { + super(createBeanFactory()); + log.info("Starting ServiceLocator (guice)"); + org.duniter.core.client.service.ServiceLocator.setInstance(this); + log.info("Starting ServiceLocator [OK]"); } - public RegistryCategoryIndexerService getRegistryCategoryIndexerService() { - return getBean(RegistryCategoryIndexerService.class); + @Override + public void close() { + try { + super.close(); + } + catch (IOException e) { + throw new TechnicalException(e); + } + org.duniter.core.client.service.ServiceLocator.setInstance(null); } - public RegistryCitiesIndexerService getRegistryCitiesIndexerService() { - return getBean(RegistryCitiesIndexerService.class); + /* -- Internal methods -- */ + + protected static BeanFactory createBeanFactory() { + BeanFactory beanFactory = new BeanFactory() + .bind(BlockchainRemoteService.class, BlockchainRemoteServiceImpl.class) + .bind(NetworkRemoteService.class, NetworkRemoteServiceImpl.class) + .bind(WotRemoteService.class, WotRemoteServiceImpl.class) + .bind(TransactionRemoteService.class, TransactionRemoteServiceImpl.class) + .bind(CryptoService.class, Ed25519CryptoServiceImpl.class) + .bind(PeerService.class, PeerServiceImpl.class) + .bind(CurrencyService.class, CurrencyServiceImpl.class) + .bind(HttpService.class, HttpServiceImpl.class) + .bind(CurrencyDao.class, MemoryCurrencyDaoImpl.class) + .bind(PeerDao.class, MemoryPeerDaoImpl.class) + .add(DataContext.class); + return beanFactory; } } diff --git a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/ServiceModule.java b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/ServiceModule.java new file mode 100644 index 00000000..6bf2993d --- /dev/null +++ b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/ServiceModule.java @@ -0,0 +1,54 @@ +package org.duniter.elasticsearch.service; + +/* + * #%L + * duniter4j-elasticsearch-plugin + * %% + * Copyright (C) 2014 - 2016 EIS + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import org.duniter.elasticsearch.PluginSettings; +import org.duniter.elasticsearch.service.blockchain.BlockBlockchainService; +import org.duniter.elasticsearch.service.market.CategoryMarketService; +import org.duniter.elasticsearch.service.market.RecordMarketService; +import org.duniter.elasticsearch.service.registry.CategoryRegistryService; +import org.duniter.elasticsearch.service.registry.CitiesRegistryService; +import org.duniter.elasticsearch.service.registry.CurrencyRegistryService; +import org.duniter.elasticsearch.service.registry.RecordRegistryService; +import org.elasticsearch.common.inject.AbstractModule; +import org.elasticsearch.common.inject.Module; + +public class ServiceModule extends AbstractModule implements Module { + + @Override protected void configure() { + bind(ServiceLocator.class).asEagerSingleton(); + bind(PluginSettings.class).asEagerSingleton(); + // Market + bind(CategoryMarketService.class).asEagerSingleton(); + bind(RecordMarketService.class).asEagerSingleton(); + + // Registry + bind(CurrencyRegistryService.class); + bind(CategoryRegistryService.class); + bind(CitiesRegistryService.class); + bind(RecordRegistryService.class); + + // BC + bind(BlockBlockchainService.class); + } +} \ No newline at end of file diff --git a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/currency/BlockIndexerService.java b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/blockchain/BlockBlockchainService.java similarity index 93% rename from duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/currency/BlockIndexerService.java rename to duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/blockchain/BlockBlockchainService.java index 1812b0be..29485f0d 100644 --- a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/currency/BlockIndexerService.java +++ b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/blockchain/BlockBlockchainService.java @@ -1,4 +1,4 @@ -package org.duniter.elasticsearch.service.currency; +package org.duniter.elasticsearch.service.blockchain; /* * #%L @@ -32,7 +32,6 @@ import org.duniter.core.client.model.bma.BlockchainParameters; import org.duniter.core.client.model.bma.EndpointProtocol; import org.duniter.core.client.model.bma.gson.GsonUtils; import org.duniter.core.client.model.bma.gson.JsonAttributeParser; -import org.duniter.core.client.model.elasticsearch.Currency; import org.duniter.core.client.model.local.Peer; import org.duniter.core.client.service.bma.BlockchainRemoteService; import org.duniter.core.client.service.bma.NetworkRemoteService; @@ -44,11 +43,10 @@ import org.duniter.core.model.ProgressionModelImpl; import org.duniter.core.util.CollectionUtils; import org.duniter.core.util.ObjectUtils; import org.duniter.core.util.StringUtils; -import org.duniter.elasticsearch.config.Configuration; -import org.duniter.elasticsearch.service.BaseIndexerService; +import org.duniter.elasticsearch.PluginSettings; +import org.duniter.elasticsearch.service.AbstractService; import org.duniter.elasticsearch.service.ServiceLocator; import org.duniter.elasticsearch.service.exception.DuplicateIndexIdException; -import org.duniter.elasticsearch.service.registry.RegistryCurrencyIndexerService; import org.elasticsearch.action.ActionFuture; import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder; import org.elasticsearch.action.bulk.BulkItemResponse; @@ -60,7 +58,9 @@ import org.elasticsearch.action.search.SearchRequestBuilder; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchType; import org.elasticsearch.client.Client; -import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.logging.ESLogger; +import org.elasticsearch.common.logging.ESLoggerFactory; import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; @@ -72,8 +72,6 @@ import org.elasticsearch.search.aggregations.metrics.max.Max; import org.elasticsearch.search.highlight.HighlightField; import org.elasticsearch.search.sort.SortOrder; import org.nuiton.i18n.I18n; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.*; @@ -81,9 +79,9 @@ import java.util.*; /** * Created by Benoit on 30/03/2015. */ -public class BlockIndexerService extends BaseIndexerService { +public class BlockBlockchainService extends AbstractService<BlockBlockchainService> { - private static final Logger log = LoggerFactory.getLogger(BlockIndexerService.class); + private static final ESLogger log = ESLoggerFactory.getLogger(BlockBlockchainService.class.getName()); public static final String INDEX_TYPE_BLOCK = "block"; @@ -91,33 +89,26 @@ public class BlockIndexerService extends BaseIndexerService { private static final int SYNC_MISSING_BLOCK_MAX_RETRY = 5; - private RegistryCurrencyIndexerService registryCurrencyIndexerService; - - private BlockchainRemoteService blockchainService; + private BlockchainRemoteService blockchainRemoteService; private Gson gson; - private Configuration config; - - public BlockIndexerService() { - gson = GsonUtils.newBuilder().create(); + @Inject + public BlockBlockchainService(Client client, PluginSettings settings){ + super(client, settings); + this.gson = GsonUtils.newBuilder().create(); } - @Override - public void afterPropertiesSet() throws Exception { - super.afterPropertiesSet(); - registryCurrencyIndexerService = ServiceLocator.instance().getRegistryCurrencyIndexerService(); - blockchainService = ServiceLocator.instance().getBlockchainRemoteService(); - config = Configuration.instance(); + @Inject + public void setBlockBlockchainService(ServiceLocator serviceLocator) { + blockchainRemoteService = ServiceLocator.instance().getBlockchainRemoteService(); } @Override - public void close() throws IOException { - super.close(); - registryCurrencyIndexerService = null; - blockchainService = null; - config = null; + public void close() { + blockchainRemoteService = null; gson = null; + super.close(); } public void indexLastBlocks(Peer peer) { @@ -125,15 +116,15 @@ public class BlockIndexerService extends BaseIndexerService { } public void indexLastBlocks(Peer peer, ProgressionModel progressionModel) { - boolean bulkIndex = config.isIndexBulkEnable(); + boolean bulkIndex = getPluginSettings().isIndexBulkEnable(); progressionModel.setStatus(ProgressionModel.Status.RUNNING); progressionModel.setTotal(100); long timeStart = System.currentTimeMillis(); try { - // Get the currency name from node - BlockchainParameters parameter = blockchainService.getParameters(peer); + // Get the blockchain name from node + BlockchainParameters parameter = blockchainRemoteService.getParameters(peer); if (parameter == null) { progressionModel.setStatus(ProgressionModel.Status.FAILED); log.error(String.format("Could not connect to node [%s]", @@ -144,27 +135,28 @@ public class BlockIndexerService extends BaseIndexerService { progressionModel.setTask(I18n.t("duniter4j.blockIndexerService.indexLastBlocks.task", currencyName, peer.getHost(), peer.getPort())); log.info(I18n.t("duniter4j.blockIndexerService.indexLastBlocks.task", - currencyName, config.getNodeBmaHost(), config.getNodeBmaPort())); + currencyName, getPluginSettings().getNodeBmaHost(), getPluginSettings().getNodeBmaPort())); - // Create index currency if need - registryCurrencyIndexerService.createIndexIfNotExists(); + // Create index blockchain if need + // FIXME: avoid circular dependency + //currencyRegistryService.createIndexIfNotExists(); - Currency currency = registryCurrencyIndexerService.getCurrencyById(currencyName); - if (currency == null) { - registryCurrencyIndexerService.indexCurrencyFromPeer(peer); - } + //Currency currency = currencyRegistryService.getCurrencyById(currencyName); + //if (currency == null) { + // currencyRegistryService.indexCurrencyFromPeer(peer); + //} // Check if index exists createIndexIfNotExists(currencyName); // Then index all blocks - BlockchainBlock currentBlock = blockchainService.getCurrentBlock(peer); + BlockchainBlock currentBlock = blockchainRemoteService.getCurrentBlock(peer); if (currentBlock != null) { int maxBlockNumber = currentBlock.getNumber(); // DEV mode - if (!config.isFullMode() && maxBlockNumber > 5000) { + if (getPluginSettings().isDevMode() && maxBlockNumber > 5000) { maxBlockNumber = 5000; } @@ -240,7 +232,7 @@ public class BlockIndexerService extends BaseIndexerService { log.info(String.format("Creating index [%s]", currencyName)); CreateIndexRequestBuilder createIndexRequestBuilder = getClient().admin().indices().prepareCreate(currencyName); - Settings indexSettings = Settings.settingsBuilder() + org.elasticsearch.common.settings.Settings indexSettings = org.elasticsearch.common.settings.Settings.settingsBuilder() .put("number_of_shards", 1) .put("number_of_replicas", 1) //.put("analyzer", createDefaultAnalyzer()) @@ -252,7 +244,7 @@ public class BlockIndexerService extends BaseIndexerService { public void createBlock(BlockchainBlock block) throws DuplicateIndexIdException { ObjectUtils.checkNotNull(block, "block could not be null") ; - ObjectUtils.checkNotNull(block.getCurrency(), "block attribute 'currency' could not be null"); + ObjectUtils.checkNotNull(block.getCurrency(), "block attribute 'blockchain' could not be null"); ObjectUtils.checkNotNull(block.getNumber(), "block attribute 'number' could not be null"); BlockchainBlock existingBlock = getBlockById(block.getCurrency(), block.getNumber()); @@ -272,7 +264,7 @@ public class BlockIndexerService extends BaseIndexerService { */ public void saveBlock(BlockchainBlock block, boolean updateWhenSameHash, boolean wait) throws DuplicateIndexIdException { ObjectUtils.checkNotNull(block, "block could not be null") ; - ObjectUtils.checkNotNull(block.getCurrency(), "block attribute 'currency' could not be null"); + ObjectUtils.checkNotNull(block.getCurrency(), "block attribute 'blockchain' could not be null"); ObjectUtils.checkNotNull(block.getNumber(), "block attribute 'number' could not be null"); ObjectUtils.checkNotNull(block.getHash(), "block attribute 'hash' could not be null"); @@ -377,7 +369,7 @@ public class BlockIndexerService extends BaseIndexerService { ObjectUtils.checkArgument(json.length() > 0); JsonAttributeParser blockNumberParser = new JsonAttributeParser("number"); - JsonAttributeParser blockCurrencyParser = new JsonAttributeParser("currency"); + JsonAttributeParser blockCurrencyParser = new JsonAttributeParser("blockchain"); String currencyName = blockCurrencyParser.getValueAsString(json); int number = blockNumberParser.getValueAsInt(json); @@ -595,7 +587,7 @@ public class BlockIndexerService extends BaseIndexerService { return CollectionUtils.extractSingleton(currencies); } catch(JsonSyntaxException e) { - throw new TechnicalException(String.format("Error while getting indexed block #%s for currency [%s]", blockId, currencyName), e); + throw new TechnicalException(String.format("Error while getting indexed block #%s for blockchain [%s]", blockId, currencyName), e); } } @@ -658,7 +650,7 @@ public class BlockIndexerService extends BaseIndexerService { } try { - String blockAsJson = blockchainService.getBlockAsJson(peer, curNumber); + String blockAsJson = blockchainRemoteService.getBlockAsJson(peer, curNumber); indexBlockAsJson(currencyName, curNumber, blockAsJson.getBytes(), false, true /*wait*/); // If last block @@ -682,7 +674,7 @@ public class BlockIndexerService extends BaseIndexerService { Client client = getClient(); boolean debug = log.isDebugEnabled(); - int batchSize = config.getIndexBulkSize(); + int batchSize = getPluginSettings().getIndexBulkSize(); String currentBlockJson = null; JsonAttributeParser blockNumberParser = new JsonAttributeParser("number"); @@ -698,7 +690,7 @@ public class BlockIndexerService extends BaseIndexerService { String[] blocksAsJson = null; try { - blocksAsJson = blockchainService.getBlocksAsJson(peer, batchSize, batchFirstNumber); + blocksAsJson = blockchainRemoteService.getBlocksAsJson(peer, batchSize, batchFirstNumber); } catch(HttpBadRequestException e) { if (log.isDebugEnabled()) { log.debug(String.format("Error while getting blocks from #%s (count=%s): %s. Skipping blocks.", batchFirstNumber, batchSize, e.getMessage())); diff --git a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/market/MarketCategoryIndexerService.java b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/market/CategoryMarketService.java similarity index 87% rename from duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/market/MarketCategoryIndexerService.java rename to duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/market/CategoryMarketService.java index 212d093b..886072af 100644 --- a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/market/MarketCategoryIndexerService.java +++ b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/market/CategoryMarketService.java @@ -25,32 +25,39 @@ package org.duniter.elasticsearch.service.market; import com.fasterxml.jackson.core.JsonProcessingException; import org.duniter.core.exception.TechnicalException; -import org.duniter.elasticsearch.service.BaseIndexerService; +import org.duniter.elasticsearch.PluginSettings; +import org.duniter.elasticsearch.service.AbstractService; import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.index.IndexResponse; +import org.elasticsearch.client.Client; +import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.logging.ESLogger; +import org.elasticsearch.common.logging.ESLoggerFactory; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import java.io.*; +import java.io.IOException; /** * Created by Benoit on 30/03/2015. */ -public class MarketCategoryIndexerService extends BaseIndexerService { +public class CategoryMarketService extends AbstractService<CategoryMarketService> { - private static final Logger log = LoggerFactory.getLogger(MarketCategoryIndexerService.class); + private static final ESLogger log = ESLoggerFactory.getLogger(CategoryMarketService.class.getName()); private static final String CATEGORIES_BULK_CLASSPATH_FILE = "market-categories-bulk-insert.json"; - public static final String INDEX_NAME = "market"; public static final String INDEX_TYPE = "category"; + @Inject + public CategoryMarketService(Client client, PluginSettings settings) { + super(client, settings); + } + /** - * Delete currency index, and all data + * Delete blockchain index, and all data * @throws JsonProcessingException */ public void deleteIndex() throws JsonProcessingException { @@ -63,7 +70,7 @@ public class MarketCategoryIndexerService extends BaseIndexerService { } /** - * Create index need for currency registry, if need + * Create index need for blockchain registry, if need */ public void createIndexIfNotExists() { try { diff --git a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/market/MarketRecordIndexerService.java b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/market/RecordMarketService.java similarity index 86% rename from duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/market/MarketRecordIndexerService.java rename to duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/market/RecordMarketService.java index 4ad5db3d..a2209c76 100644 --- a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/market/MarketRecordIndexerService.java +++ b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/market/RecordMarketService.java @@ -25,27 +25,27 @@ package org.duniter.elasticsearch.service.market; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.Sets; import com.google.gson.JsonSyntaxException; import org.duniter.core.client.model.elasticsearch.Record; import org.duniter.core.client.service.bma.WotRemoteService; import org.duniter.core.exception.TechnicalException; import org.duniter.core.service.CryptoService; -import org.duniter.core.util.StringUtils; -import org.duniter.elasticsearch.config.Configuration; -import org.duniter.elasticsearch.service.BaseIndexerService; +import org.duniter.elasticsearch.PluginSettings; +import org.duniter.elasticsearch.service.AbstractService; import org.duniter.elasticsearch.service.ServiceLocator; import org.duniter.elasticsearch.service.exception.InvalidFormatException; import org.duniter.elasticsearch.service.exception.InvalidSignatureException; import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.index.IndexResponse; -import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.client.Client; +import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.inject.Singleton; +import org.elasticsearch.common.logging.ESLogger; +import org.elasticsearch.common.logging.ESLoggerFactory; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.Set; @@ -53,9 +53,10 @@ import java.util.Set; /** * Created by Benoit on 30/03/2015. */ -public class MarketRecordIndexerService extends BaseIndexerService { +@Singleton +public class RecordMarketService extends AbstractService<RecordMarketService> { - private static final Logger log = LoggerFactory.getLogger(MarketRecordIndexerService.class); + private static final ESLogger log = ESLoggerFactory.getLogger(RecordMarketService.class.getName()); private static final String JSON_STRING_PROPERTY_REGEX = "[,]?[\"\\s\\n\\r]*%s[\"]?[\\s\\n\\r]*:[\\s\\n\\r]*\"[^\"]+\""; @@ -67,28 +68,30 @@ public class MarketRecordIndexerService extends BaseIndexerService { private CryptoService cryptoService; - private Configuration config; - - public MarketRecordIndexerService() { + private ServiceLocator serviceLocator; + @Inject + public RecordMarketService(Client client, PluginSettings config, ServiceLocator serviceLocator) { + super(client, config); + this.serviceLocator = serviceLocator; } @Override - public void afterPropertiesSet() throws Exception { - super.afterPropertiesSet(); - wotRemoteService = ServiceLocator.instance().getWotRemoteService(); - cryptoService = ServiceLocator.instance().getCryptoService(); - config = Configuration.instance(); + public RecordMarketService start() { + wotRemoteService = serviceLocator.getWotRemoteService(); + cryptoService = serviceLocator.getCryptoService(); + return super.start(); } @Override - public void close() throws IOException { - super.close(); + public void close() { wotRemoteService = null; + cryptoService = null; + super.close(); } /** - * Delete currency index, and all data + * Delete blockchain index, and all data * @throws JsonProcessingException */ public void deleteIndex() throws JsonProcessingException { @@ -101,7 +104,7 @@ public class MarketRecordIndexerService extends BaseIndexerService { } /** - * Create index need for currency registry, if need + * Create index need for blockchain registry, if need */ public void createIndexIfNotExists() { try { @@ -120,7 +123,7 @@ public class MarketRecordIndexerService extends BaseIndexerService { */ public void createIndex() throws JsonProcessingException { CreateIndexRequestBuilder createIndexRequestBuilder = getClient().admin().indices().prepareCreate(INDEX_NAME); - Settings indexSettings = Settings.settingsBuilder() + org.elasticsearch.common.settings.Settings indexSettings = org.elasticsearch.common.settings.Settings.settingsBuilder() .put("number_of_shards", 3) .put("number_of_replicas", 2) //.put("analyzer", createDefaultAnalyzer()) @@ -147,10 +150,8 @@ public class MarketRecordIndexerService extends BaseIndexerService { public XContentBuilder createIndexMapping(String indexType) { - String stringAnalyzer = config.getIndexStringAnalyzer(); - if (StringUtils.isBlank(stringAnalyzer)) { - stringAnalyzer = "english"; - } + String stringAnalyzer = getPluginSettings().getIndexStringAnalyzer(); + try { XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject(indexType) @@ -253,8 +254,7 @@ public class MarketRecordIndexerService extends BaseIndexerService { public String indexRecordFromJson(String recordJson, String indexType) { try { - ObjectMapper mapper = new ObjectMapper(); - JsonNode actualObj = mapper.readTree(recordJson); + JsonNode actualObj = getObjectMapper().readTree(recordJson); Set<String> fieldNames = Sets.newHashSet(actualObj.fieldNames()); if (!fieldNames.contains(Record.PROPERTY_ISSUER) || !fieldNames.contains(Record.PROPERTY_SIGNATURE)) { diff --git a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/registry/RegistryCategoryIndexerService.java b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/registry/CategoryRegistryService.java similarity index 85% rename from duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/registry/RegistryCategoryIndexerService.java rename to duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/registry/CategoryRegistryService.java index 278634cd..09460e67 100644 --- a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/registry/RegistryCategoryIndexerService.java +++ b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/registry/CategoryRegistryService.java @@ -26,54 +26,51 @@ package org.duniter.elasticsearch.service.registry; import com.fasterxml.jackson.core.JsonProcessingException; import org.duniter.core.exception.TechnicalException; import org.duniter.core.util.StringUtils; -import org.duniter.elasticsearch.config.Configuration; -import org.duniter.elasticsearch.service.BaseIndexerService; +import org.duniter.elasticsearch.PluginSettings; +import org.duniter.elasticsearch.service.AbstractService; import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.index.IndexResponse; -import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.client.Client; +import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.logging.ESLogger; +import org.elasticsearch.common.logging.ESLoggerFactory; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.io.IOException; /** * Created by Benoit on 30/03/2015. */ -public class RegistryCategoryIndexerService extends BaseIndexerService { +public class CategoryRegistryService extends AbstractService<CategoryRegistryService> { - private static final Logger log = LoggerFactory.getLogger(RegistryCategoryIndexerService.class); + private static final ESLogger log = ESLoggerFactory.getLogger(CategoryRegistryService.class.getName()); private static final String CATEGORIES_BULK_CLASSPATH_FILE = "registry-categories-bulk-insert.json"; public static final String INDEX_NAME = "registry"; public static final String INDEX_TYPE = "category"; - private Configuration config; - - @Override - public void afterPropertiesSet() throws Exception { - super.afterPropertiesSet(); - config = Configuration.instance(); + @Inject + public CategoryRegistryService(Client client, PluginSettings settings) { + super(client, settings); } /** - * Delete currency index, and all data + * Delete blockchain index, and all data * @throws JsonProcessingException */ public void deleteIndex() throws JsonProcessingException { deleteIndexIfExists(INDEX_NAME); } - public boolean existsIndex() { return super.existsIndex(INDEX_NAME); } /** - * Create index need for currency registry, if need + * Create index need for blockchain registry, if need */ public void createIndexIfNotExists() { try { @@ -94,7 +91,7 @@ public class RegistryCategoryIndexerService extends BaseIndexerService { log.info(String.format("Creating index [%s/%s]", INDEX_NAME, INDEX_TYPE)); CreateIndexRequestBuilder createIndexRequestBuilder = getClient().admin().indices().prepareCreate(INDEX_NAME); - Settings indexSettings = Settings.settingsBuilder() + org.elasticsearch.common.settings.Settings indexSettings = org.elasticsearch.common.settings.Settings.settingsBuilder() .put("number_of_shards", 1) .put("number_of_replicas", 1) //.put("analyzer", createDefaultAnalyzer()) @@ -140,7 +137,7 @@ public class RegistryCategoryIndexerService extends BaseIndexerService { public XContentBuilder createIndexMapping() { - String stringAnalyzer = config.getIndexStringAnalyzer(); + String stringAnalyzer = getPluginSettings().getIndexStringAnalyzer(); if (StringUtils.isBlank(stringAnalyzer)) { stringAnalyzer = "english"; } diff --git a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/registry/RegistryCitiesIndexerService.java b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/registry/CitiesRegistryService.java similarity index 92% rename from duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/registry/RegistryCitiesIndexerService.java rename to duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/registry/CitiesRegistryService.java index 7eb7759d..eac61b70 100644 --- a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/registry/RegistryCitiesIndexerService.java +++ b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/registry/CitiesRegistryService.java @@ -29,16 +29,17 @@ import com.google.gson.reflect.TypeToken; import org.duniter.core.client.model.bma.gson.GsonUtils; import org.duniter.core.exception.TechnicalException; import org.duniter.core.util.StringUtils; -import org.duniter.elasticsearch.config.Configuration; -import org.duniter.elasticsearch.service.BaseIndexerService; +import org.duniter.elasticsearch.PluginSettings; +import org.duniter.elasticsearch.service.AbstractService; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder; -import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.client.Client; +import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.logging.ESLogger; +import org.elasticsearch.common.logging.ESLoggerFactory; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.io.*; import java.util.Map; @@ -46,9 +47,9 @@ import java.util.Map; /** * Created by Benoit on 30/03/2015. */ -public class RegistryCitiesIndexerService extends BaseIndexerService { +public class CitiesRegistryService extends AbstractService<CitiesRegistryService> { - private static final Logger log = LoggerFactory.getLogger(RegistryCitiesIndexerService.class); + private static final ESLogger log = ESLoggerFactory.getLogger(CitiesRegistryService.class.getName()); private static final String CITIES_BULK_FILENAME = "registry-cities-bulk-insert.json"; @@ -61,27 +62,20 @@ public class RegistryCitiesIndexerService extends BaseIndexerService { private Gson gson; - private Configuration config; - - public RegistryCitiesIndexerService() { + @Inject + public CitiesRegistryService(Client client, PluginSettings settings) { + super(client, settings); gson = GsonUtils.newBuilder().create(); } @Override - public void afterPropertiesSet() throws Exception { - super.afterPropertiesSet(); - config = Configuration.instance(); - } - - @Override - public void close() throws IOException { - super.close(); - config = null; + public void close() { gson = null; + super.close(); } /** - * Delete currency index, and all data + * Delete blockchain index, and all data * @throws JsonProcessingException */ public void deleteIndex() throws JsonProcessingException { @@ -94,7 +88,7 @@ public class RegistryCitiesIndexerService extends BaseIndexerService { } /** - * Create index need for currency registry, if need + * Create index need for blockchain registry, if need */ public void createIndexIfNotExists() { try { @@ -115,7 +109,7 @@ public class RegistryCitiesIndexerService extends BaseIndexerService { log.info(String.format("Creating index [%s/%s]", INDEX_NAME, INDEX_TYPE)); CreateIndexRequestBuilder createIndexRequestBuilder = getClient().admin().indices().prepareCreate(INDEX_NAME); - Settings indexSettings = Settings.settingsBuilder() + org.elasticsearch.common.settings.Settings indexSettings = org.elasticsearch.common.settings.Settings.settingsBuilder() .put("number_of_shards", 1) .put("number_of_replicas", 1) //.put("analyzer", createDefaultAnalyzer()) @@ -169,7 +163,7 @@ public class RegistryCitiesIndexerService extends BaseIndexerService { public File createCitiesBulkFile() { - File result = new File(config.getTempDirectory(), CITIES_BULK_FILENAME); + File result = new File(getPluginSettings().getTempDirectory(), CITIES_BULK_FILENAME); InputStream ris = null; BufferedReader bf = null; @@ -269,7 +263,7 @@ public class RegistryCitiesIndexerService extends BaseIndexerService { public File createCitiesBulkFile2() { - File result = new File(config.getTempDirectory(), CITIES_BULK_FILENAME); + File result = new File(getPluginSettings().getTempDirectory(), CITIES_BULK_FILENAME); File inputFile = new File(CITIES_SOURCE_FILE2); InputStream ris = null; diff --git a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/registry/RegistryCurrencyIndexerService.java b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/registry/CurrencyRegistryService.java similarity index 86% rename from duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/registry/RegistryCurrencyIndexerService.java rename to duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/registry/CurrencyRegistryService.java index 087e6a5f..acbc7454 100644 --- a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/registry/RegistryCurrencyIndexerService.java +++ b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/registry/CurrencyRegistryService.java @@ -27,24 +27,24 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.google.common.base.Preconditions; import com.google.common.collect.Lists; import com.google.gson.Gson; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.ArrayUtils; import org.duniter.core.client.model.bma.BlockchainBlock; import org.duniter.core.client.model.bma.BlockchainParameters; import org.duniter.core.client.model.bma.gson.GsonUtils; import org.duniter.core.client.model.elasticsearch.Currency; import org.duniter.core.client.model.local.Peer; +import org.duniter.core.client.service.ServiceLocator; import org.duniter.core.client.service.bma.BlockchainRemoteService; import org.duniter.core.exception.TechnicalException; import org.duniter.core.service.CryptoService; import org.duniter.core.util.ObjectUtils; +import org.duniter.elasticsearch.PluginSettings; import org.duniter.elasticsearch.model.SearchResult; -import org.duniter.elasticsearch.service.BaseIndexerService; -import org.duniter.elasticsearch.service.ServiceLocator; -import org.duniter.elasticsearch.service.currency.BlockIndexerService; +import org.duniter.elasticsearch.service.AbstractService; import org.duniter.elasticsearch.service.exception.AccessDeniedException; import org.duniter.elasticsearch.service.exception.DuplicateIndexIdException; import org.duniter.elasticsearch.service.exception.InvalidSignatureException; -import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.lang3.ArrayUtils; import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.search.SearchPhaseExecutionException; @@ -53,6 +53,10 @@ import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchType; import org.elasticsearch.action.suggest.SuggestRequestBuilder; import org.elasticsearch.action.suggest.SuggestResponse; +import org.elasticsearch.client.Client; +import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.logging.ESLogger; +import org.elasticsearch.common.logging.ESLoggerFactory; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; @@ -63,8 +67,6 @@ import org.elasticsearch.search.highlight.HighlightField; import org.elasticsearch.search.sort.SortOrder; import org.elasticsearch.search.suggest.Suggest; import org.elasticsearch.search.suggest.completion.CompletionSuggestionBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.Iterator; @@ -75,44 +77,41 @@ import java.util.Objects; /** * Created by Benoit on 30/03/2015. */ -public class RegistryCurrencyIndexerService extends BaseIndexerService { +public class CurrencyRegistryService extends AbstractService<CurrencyRegistryService> { - private static final Logger log = LoggerFactory.getLogger(RegistryCurrencyIndexerService.class); + private static final ESLogger log = ESLoggerFactory.getLogger(CurrencyRegistryService.class.getName()); public static final String INDEX_NAME = "registry"; - public static final String INDEX_TYPE = "currency"; + public static final String INDEX_TYPE = "blockchain"; public static final String REGEX_WORD_SEPARATOR = "[-\\t@# ]+"; public static final String REGEX_SPACE = "[\\t\\n\\r ]+"; private CryptoService cryptoService; - private BlockIndexerService blockIndexerService; private Gson gson; - public RegistryCurrencyIndexerService() { - super(); + @Inject + public CurrencyRegistryService(Client client, PluginSettings settings) { + super(client, settings); this.gson = GsonUtils.newBuilder().create(); } @Override - public void afterPropertiesSet() throws Exception { - super.afterPropertiesSet(); - + public CurrencyRegistryService start() { this.cryptoService = ServiceLocator.instance().getCryptoService(); - this.blockIndexerService = ServiceLocator.instance().getBlockIndexerService(); + return super.start(); } @Override - public void close() throws IOException { - super.close(); + public void close() { this.cryptoService = null; - this.blockIndexerService = null; this.gson = null; + super.close(); } /** - * Delete currency index, and all data + * Delete blockchain index, and all data * @throws JsonProcessingException */ public void deleteIndex() throws JsonProcessingException { @@ -120,7 +119,7 @@ public class RegistryCurrencyIndexerService extends BaseIndexerService { } /** - * Create index need for currency registry, if need + * Create index need for blockchain registry, if need */ public void createIndexIfNotExists() { try { @@ -134,7 +133,7 @@ public class RegistryCurrencyIndexerService extends BaseIndexerService { } /** - * Create index need for currency registry + * Create index need for blockchain registry * @throws JsonProcessingException */ public void createIndex() throws JsonProcessingException { @@ -152,10 +151,10 @@ public class RegistryCurrencyIndexerService extends BaseIndexerService { } /** - * Retrieve the currency data, from peer + * Retrieve the blockchain data, from peer * * @param peer - * @return the created currency + * @return the created blockchain */ public Currency indexCurrencyFromPeer(Peer peer) { BlockchainRemoteService blockchainRemoteService = ServiceLocator.instance().getBlockchainRemoteService(); @@ -175,15 +174,17 @@ public class RegistryCurrencyIndexerService extends BaseIndexerService { indexCurrency(result); // Index the first block - blockIndexerService.createIndexIfNotExists(parameters.getCurrency()); - blockIndexerService.indexBlock(firstBlock, false); - blockIndexerService.indexCurrentBlock(firstBlock, true); + // FIXME : attention au dependence circulaire : cela devrait plutot etre fait à l'exetrieure e registry + // par exemple dans l'action REST + //blockBlockchainService.createIndexIfNotExists(parameters.getCurrency()); + //blockBlockchainService.indexBlock(firstBlock, false); + //blockBlockchainService.indexCurrentBlock(firstBlock, true); return result; } /** - * Index a currency + * Index a blockchain * @param currency */ public void indexCurrency(Currency currency) { @@ -247,7 +248,7 @@ public class RegistryCurrencyIndexerService extends BaseIndexerService { } /** - * Find currency that match the givent string query (Full text search) + * Find blockchain that match the givent string query (Full text search) * @param query * @return */ @@ -292,7 +293,7 @@ public class RegistryCurrencyIndexerService extends BaseIndexerService { return; } - log.info(String.format("Deleting all currency indexes")); + log.info(String.format("Deleting all blockchain indexes")); // Prepare request SearchRequestBuilder request = getClient() @@ -305,17 +306,17 @@ public class RegistryCurrencyIndexerService extends BaseIndexerService { // Delete every currencies List<Currency> currencies = toCurrencies(response); for (Currency currency: currencies){ - log.info(String.format("Deleting currency [%s]...", currency.getCurrencyName())); + log.info(String.format("Deleting blockchain [%s]...", currency.getCurrencyName())); deleteIndexIfExists(currency.getCurrencyName()); } deleteIndexIfExists(INDEX_NAME); - log.info("All currency successfully deleted"); + log.info("All blockchain successfully deleted"); } /** - * find currency that match string query (full text search), and return a generic VO for search result. + * find blockchain that match string query (full text search), and return a generic VO for search result. * @param query * @return a list of generic search result */ @@ -356,7 +357,7 @@ public class RegistryCurrencyIndexerService extends BaseIndexerService { } /** - * Retrieve a currency from its name + * Retrieve a blockchain from its name * @param currencyId * @return */ @@ -395,15 +396,15 @@ public class RegistryCurrencyIndexerService extends BaseIndexerService { } /** - * Save a currency (update or create) into the currency index. + * Save a blockchain (update or create) into the blockchain index. * @param currency * @param senderPubkey * @throws DuplicateIndexIdException - * @throws AccessDeniedException if exists and user if not the original currency sender + * @throws AccessDeniedException if exists and user if not the original blockchain sender */ public void saveCurrency(Currency currency, String senderPubkey) throws DuplicateIndexIdException { - ObjectUtils.checkNotNull(currency, "currency could not be null") ; - ObjectUtils.checkNotNull(currency.getCurrencyName(), "currency attribute 'currencyName' could not be null"); + ObjectUtils.checkNotNull(currency, "blockchain could not be null") ; + ObjectUtils.checkNotNull(currency.getCurrencyName(), "blockchain attribute 'currencyName' could not be null"); Currency existingCurrency = getCurrencyById(currency.getCurrencyName()); @@ -419,7 +420,7 @@ public class RegistryCurrencyIndexerService extends BaseIndexerService { // Exists, so check the owner signature else { if (!Objects.equals(currency.getSenderPubkey(), senderPubkey)) { - throw new AccessDeniedException("Could not change currency, because it has been registered by another public key."); + throw new AccessDeniedException("Could not change blockchain, because it has been registered by another public key."); } // Make sure the sender is not changed @@ -431,7 +432,7 @@ public class RegistryCurrencyIndexerService extends BaseIndexerService { } /** - * Get the full list of currencies names, from currency index + * Get the full list of currencies names, from blockchain index * @return */ public List<String> getAllCurrencyNames() { @@ -452,9 +453,9 @@ public class RegistryCurrencyIndexerService extends BaseIndexerService { } /** - * Registrer a new currency. + * Registrer a new blockchain. * @param pubkey the sender pubkey - * @param jsonCurrency the currency, as JSON + * @param jsonCurrency the blockchain, as JSON * @param signature the signature of sender. * @throws InvalidSignatureException if signature not correspond to sender pubkey */ @@ -465,7 +466,7 @@ public class RegistryCurrencyIndexerService extends BaseIndexerService { if (!cryptoService.verify(jsonCurrency, signature, pubkey)) { String currencyName = GsonUtils.getValueFromJSONAsString(jsonCurrency, "currencyName"); - log.warn(String.format("Currency not added, because bad signature. currency [%s]", currencyName)); + log.warn(String.format("Currency not added, because bad signature. blockchain [%s]", currencyName)); throw new InvalidSignatureException("Bad signature"); } @@ -475,8 +476,8 @@ public class RegistryCurrencyIndexerService extends BaseIndexerService { Preconditions.checkNotNull(currency); Preconditions.checkNotNull(currency.getCurrencyName()); } catch(Throwable t) { - log.error("Error while reading currency JSON: " + jsonCurrency); - throw new TechnicalException("Error while reading currency JSON: " + jsonCurrency, t); + log.error("Error while reading blockchain JSON: " + jsonCurrency); + throw new TechnicalException("Error while reading blockchain JSON: " + jsonCurrency, t); } saveCurrency(currency, pubkey); @@ -489,7 +490,7 @@ public class RegistryCurrencyIndexerService extends BaseIndexerService { XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject(INDEX_TYPE) .startObject("properties") - // currency name + // blockchain name .startObject("currencyName") .field("type", "string") .endObject() @@ -518,19 +519,21 @@ public class RegistryCurrencyIndexerService extends BaseIndexerService { } protected void createCurrency(Currency currency) throws DuplicateIndexIdException, JsonProcessingException { - ObjectUtils.checkNotNull(currency, "currency could not be null") ; - ObjectUtils.checkNotNull(currency.getCurrencyName(), "currency attribute 'currencyName' could not be null"); + ObjectUtils.checkNotNull(currency, "blockchain could not be null") ; + ObjectUtils.checkNotNull(currency.getCurrencyName(), "blockchain attribute 'currencyName' could not be null"); Currency existingCurrency = getCurrencyById(currency.getCurrencyName()); if (existingCurrency != null) { throw new DuplicateIndexIdException(String.format("Currency with name [%s] already exists.", currency.getCurrencyName())); } - // register to currency + // register to blockchain indexCurrency(currency); // Create sub indexes - ServiceLocator.instance().getBlockIndexerService().createIndex(currency.getCurrencyName()); + // FIXME : circular reference + // may be use an EVentBus (guava) + //blockBlockchainService.createIndex(currency.getCurrencyName()); } protected List<Currency> toCurrencies(SearchResponse response) { @@ -566,7 +569,7 @@ public class RegistryCurrencyIndexerService extends BaseIndexerService { return result; } catch(IOException e) { - throw new TechnicalException("Error while reading currency search result: " + e.getMessage(), e); + throw new TechnicalException("Error while reading blockchain search result: " + e.getMessage(), e); } } diff --git a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/registry/RegistryRecordIndexerService.java b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/registry/RecordRegistryService.java similarity index 90% rename from duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/registry/RegistryRecordIndexerService.java rename to duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/registry/RecordRegistryService.java index 8daf712d..7164f14e 100644 --- a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/registry/RegistryRecordIndexerService.java +++ b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/registry/RecordRegistryService.java @@ -31,23 +31,24 @@ import com.google.gson.Gson; import com.google.gson.JsonSyntaxException; import org.duniter.core.client.model.bma.gson.GsonUtils; import org.duniter.core.client.model.elasticsearch.Record; +import org.duniter.core.client.service.ServiceLocator; import org.duniter.core.client.service.bma.WotRemoteService; import org.duniter.core.exception.TechnicalException; import org.duniter.core.service.CryptoService; import org.duniter.core.util.StringUtils; -import org.duniter.elasticsearch.config.Configuration; -import org.duniter.elasticsearch.service.BaseIndexerService; -import org.duniter.elasticsearch.service.ServiceLocator; +import org.duniter.elasticsearch.PluginSettings; +import org.duniter.elasticsearch.service.AbstractService; import org.duniter.elasticsearch.service.exception.InvalidFormatException; import org.duniter.elasticsearch.service.exception.InvalidSignatureException; import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.index.IndexResponse; -import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.client.Client; +import org.elasticsearch.common.inject.Inject; +import org.elasticsearch.common.logging.ESLogger; +import org.elasticsearch.common.logging.ESLoggerFactory; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; @@ -56,9 +57,9 @@ import java.util.Set; /** * Created by Benoit on 30/03/2015. */ -public class RegistryRecordIndexerService extends BaseIndexerService { +public class RecordRegistryService extends AbstractService<RecordRegistryService> { - private static final Logger log = LoggerFactory.getLogger(RegistryRecordIndexerService.class); + private static final ESLogger log = ESLoggerFactory.getLogger(RecordRegistryService.class.getName()); private static final String JSON_STRING_PROPERTY_REGEX = "[,]?[\"\\s\\n\\r]*%s[\"]?[\\s\\n\\r]*:[\\s\\n\\r]*\"[^\"]+\""; @@ -67,34 +68,32 @@ public class RegistryRecordIndexerService extends BaseIndexerService { private Gson gson; - private Configuration config; - private WotRemoteService wotRemoteService; private CryptoService cryptoService; - public RegistryRecordIndexerService() { + @Inject + public RecordRegistryService(Client client, PluginSettings settings) { + super(client, settings); gson = GsonUtils.newBuilder().create(); } @Override - public void afterPropertiesSet() throws Exception { - super.afterPropertiesSet(); + public RecordRegistryService start() { wotRemoteService = ServiceLocator.instance().getWotRemoteService(); cryptoService = ServiceLocator.instance().getCryptoService(); - config = Configuration.instance(); + return super.start(); } @Override - public void close() throws IOException { - super.close(); + public void close(){ wotRemoteService = null; - config = null; gson = null; + super.close(); } /** - * Delete currency index, and all data + * Delete blockchain index, and all data * @throws JsonProcessingException */ public void deleteIndex() throws JsonProcessingException { @@ -107,7 +106,7 @@ public class RegistryRecordIndexerService extends BaseIndexerService { } /** - * Create index need for currency registry, if need + * Create index need for blockchain registry, if need */ public void createIndexIfNotExists() { try { @@ -128,7 +127,7 @@ public class RegistryRecordIndexerService extends BaseIndexerService { log.info(String.format("Creating index [%s/%s]", INDEX_NAME, INDEX_TYPE)); CreateIndexRequestBuilder createIndexRequestBuilder = getClient().admin().indices().prepareCreate(INDEX_NAME); - Settings indexSettings = Settings.settingsBuilder() + org.elasticsearch.common.settings.Settings indexSettings = org.elasticsearch.common.settings.Settings.settingsBuilder() .put("number_of_shards", 1) .put("number_of_replicas", 1) //.put("analyzer", createDefaultAnalyzer()) @@ -204,7 +203,7 @@ public class RegistryRecordIndexerService extends BaseIndexerService { public XContentBuilder createIndexMapping() { - String stringAnalyzer = config.getIndexStringAnalyzer(); + String stringAnalyzer = getPluginSettings().getIndexStringAnalyzer(); if (StringUtils.isBlank(stringAnalyzer)) { stringAnalyzer = "english"; } diff --git a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/task/Job.java b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/task/Job.java deleted file mode 100644 index dccfc4a5..00000000 --- a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/task/Job.java +++ /dev/null @@ -1,171 +0,0 @@ -package org.duniter.elasticsearch.service.task; - -/* - * #%L - * SIH-Adagio :: UI for Core Allegro - * $Id:$ - * $HeadURL:$ - * %% - * Copyright (C) 2012 - 2014 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -import org.duniter.core.exception.TechnicalException; -import org.duniter.core.model.ProgressionModel; -import org.duniter.core.util.ObjectUtils; -import org.duniter.elasticsearch.config.Configuration; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.util.Locale; - -import static org.nuiton.i18n.I18n.t; - -/** - * Encapsulate a RunnableWithProgress into a Job, with meta data - * - * - */ -public class Job implements java.lang.Runnable { - - private static final Logger log = LoggerFactory.getLogger(Job.class); - - - protected final ProgressionModel progressionModel; - protected final Configuration config; - protected final String jobId; - protected final String issuer; - protected final Locale locale; - protected boolean interrupted; - protected final Runnable delegate; - - public Job(Runnable delegate, String jobId, String issuer, Locale locale, ProgressionModel progressionModel) { - ObjectUtils.checkNotNull(delegate); - ObjectUtils.checkNotNull(jobId); - ObjectUtils.checkNotNull(locale); - ObjectUtils.checkNotNull(progressionModel); - - this.delegate = delegate; - this.jobId = jobId; - this.issuer = issuer; - this.locale = locale; - this.progressionModel = progressionModel; - this.config = Configuration.instance(); - } - - public ProgressionModel getProgressionModel() { - return this.progressionModel; - } - - public String getIssuer() { - return issuer; - } - - public Locale getLocale() { - return locale; - } - - public void stop() { - this.interrupted = true; - } - - @Override - public void run() { - delegate.run(); - } - - /** - * Remap progression model to a new progression model, to be able to encapsulate many tasks - * - * @param progressionModel - * @param progressionModelOffset - * @param progressionCount - */ - protected void addProgressionListeners(final ProgressionModel progressionModel, - final int progressionModelOffset, - final int progressionCount) { - // Listen 'current' attribute changes - progressionModel.addPropertyChangeListener(ProgressionModel.PROPERTY_CURRENT, - new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - Integer current = (Integer) evt.getNewValue(); - - onProgressionCurrentChanged(current, progressionModel.getTotal(), progressionModelOffset, progressionCount); - } - }); - - // Listen message changes - progressionModel.addPropertyChangeListener(ProgressionModel.PROPERTY_MESSAGE, - new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - String message = (String) evt.getNewValue(); - onProgressionMessageChanged(message); - } - }); - } - - protected void onProgressionCurrentChanged(Integer current, Integer total, int progressionOffset, int progressionCount) { - if (current == null || total == null) { - progressionModel.setCurrent(progressionOffset); - return; - } - int progression = progressionOffset - + Math.round(progressionCount * current / total); - if (progression >= progressionOffset + progressionCount) { - progression = progressionOffset + progressionCount - 2; // max - 2, to avoid ProgressionPanel to run - // onComplet() - } - progressionModel.setCurrent(progression); - - checkJobInterruption(); - } - - protected void onProgressionMessageChanged(String message) { - progressionModel.setMessage(message); - } - - protected void onError(String errorMessage) { - progressionModel.setCurrent(0); - progressionModel.setTask(""); - progressionModel.setMessage(errorMessage); - progressionModel.setStatus(ProgressionModel.Status.FAILED); - } - - protected void onSuccess() { - progressionModel.setCurrent(100); - progressionModel.setTask(""); - progressionModel.setMessage(t("duniter4j.job.success")); - progressionModel.setStatus(ProgressionModel.Status.SUCCESS); - } - - /** - * Will stop the synchronization if job cancellation has been asked - */ - protected void checkJobInterruption() { - if (this.interrupted) { - if (log.isInfoEnabled()) { - log.info(t("duniter4j.job.stopping")); - } - throw new TechnicalException(t("duniter4j.job.stopped"), new InterruptedException()); - } - } - -} diff --git a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/task/JobFuture.java b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/task/JobFuture.java deleted file mode 100644 index 92a202f5..00000000 --- a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/task/JobFuture.java +++ /dev/null @@ -1,92 +0,0 @@ -package org.duniter.elasticsearch.service.task; - -/* - * #%L - * SIH-Adagio :: Synchro Server WebApp - * $Id:$ - * $HeadURL:$ - * %% - * Copyright (C) 2012 - 2014 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - - -import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; - -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Executor; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - -/** - * - * @author Ludovic Pecquot <ludovic.pecquot@e-is.pro> - */ -public class JobFuture implements ListenableFuture<Job> { - - private final Job job; - private final ListenableFuture<Job> delegate; - - public JobFuture(Job job, ListenableFuture<Job> delegate) { - this.job = job; - this.delegate = delegate; - } - - public Job getJob() { - return job; - } - - public void addCallback(FutureCallback<? super Job> callback) { - Futures.addCallback(delegate,callback); - } - - @Override - public void addListener(Runnable runnable, Executor executor) { - delegate.addListener(runnable, executor); - } - - @Override - public boolean cancel(boolean mayInterruptIfRunning) { - this.job.stop(); - return delegate.cancel(mayInterruptIfRunning); - } - - @Override - public boolean isCancelled() { - return delegate.isCancelled(); - } - - @Override - public boolean isDone() { - return delegate.isDone(); - } - - @Override - public Job get() throws InterruptedException, ExecutionException { - return delegate.get(); - } - - @Override - public Job get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { - return delegate.get(timeout, unit); - } - - - -} diff --git a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/task/JobVO.java b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/task/JobVO.java deleted file mode 100644 index 5e58be60..00000000 --- a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/task/JobVO.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.duniter.elasticsearch.service.task; - -/* - * #%L - * SIH-Adagio :: Synchro Server WebApp - * $Id:$ - * $HeadURL:$ - * %% - * Copyright (C) 2012 - 2014 Ifremer - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - - -import java.io.Serializable; - -public class JobVO implements Serializable { - - private static final long serialVersionUID = 1L; - - private final String id; - - private final String issuer; - - public JobVO(String id, String issuer) { - this.id = id; - this.issuer = issuer; - } - - public String getId() { - return id; - } - -} diff --git a/duniter4j-elasticsearch/src/main/resources/META-INF/services/org.duniter.core.beans.Bean b/duniter4j-elasticsearch/src/main/resources/META-INF/services/org.duniter.core.beans.Bean index 4f29772a..061f29c0 100644 --- a/duniter4j-elasticsearch/src/main/resources/META-INF/services/org.duniter.core.beans.Bean +++ b/duniter4j-elasticsearch/src/main/resources/META-INF/services/org.duniter.core.beans.Bean @@ -10,13 +10,4 @@ org.duniter.core.client.service.local.PeerServiceImpl org.duniter.core.client.service.local.CurrencyServiceImpl org.duniter.core.client.dao.mem.MemoryCurrencyDaoImpl org.duniter.core.client.dao.mem.MemoryPeerDaoImpl -org.duniter.elasticsearch.service.ElasticSearchService -org.duniter.elasticsearch.service.currency.BlockIndexerService -org.duniter.elasticsearch.service.ExecutorServiceImpl -org.duniter.elasticsearch.service.market.MarketRecordIndexerService -org.duniter.elasticsearch.service.market.MarketCategoryIndexerService -org.duniter.elasticsearch.service.registry.RegistryCurrencyIndexerService -org.duniter.elasticsearch.service.registry.RegistryRecordIndexerService -org.duniter.elasticsearch.service.registry.RegistryCategoryIndexerService -org.duniter.elasticsearch.service.registry.RegistryCitiesIndexerService diff --git a/duniter4j-elasticsearch/src/main/resources/plugin-security.policy b/duniter4j-elasticsearch/src/main/resources/plugin-security.policy new file mode 100644 index 00000000..08f3659d --- /dev/null +++ b/duniter4j-elasticsearch/src/main/resources/plugin-security.policy @@ -0,0 +1,5 @@ +grant codeBase "file:${es.path.home}/plugins/duniter4j-elasticsearch/"{ + permission java.io.FilePermission "/etc/ld.so.conf", "read"; + permission java.io.FilePermission "/etc/ld.so.conf.d/*.conf", "read"; + permission java.io.FilePermission "/usr/local/lib/*", "read"; +}; \ No newline at end of file diff --git a/duniter4j-elasticsearch/src/test/es-home/logs/elasticsearch.log b/duniter4j-elasticsearch/src/test/es-home/logs/elasticsearch.log index 41bdfb5d..cad8e5cc 100644 --- a/duniter4j-elasticsearch/src/test/es-home/logs/elasticsearch.log +++ b/duniter4j-elasticsearch/src/test/es-home/logs/elasticsearch.log @@ -1,68 +1,550 @@ -[2016-02-02 19:00:21,260][INFO ][node ] [Lucas Brand] version[2.2.0], pid[4389], build[8ff36d1/2016-01-27T13:32:39Z] -[2016-02-02 19:00:21,261][INFO ][node ] [Lucas Brand] initializing ... -[2016-02-02 19:00:21,353][INFO ][plugins ] [Lucas Brand] modules [], plugins [], sites [] -[2016-02-02 19:00:21,389][INFO ][env ] [Lucas Brand] using [1] data paths, mounts [[/home (/dev/sdb5)]], net usable_space [202.6gb], net total_space [436.4gb], spins? [possibly], types [ext4] -[2016-02-02 19:00:21,389][INFO ][env ] [Lucas Brand] heap size [3.4gb], compressed ordinary object pointers [true] -[2016-02-02 19:00:23,318][INFO ][node ] [Lucas Brand] initialized -[2016-02-02 19:00:23,318][INFO ][node ] [Lucas Brand] starting ... -[2016-02-02 19:00:23,381][INFO ][transport ] [Lucas Brand] publish_address {127.0.0.1:9300}, bound_addresses {127.0.0.1:9300}, {[::1]:9300} -[2016-02-02 19:00:23,390][INFO ][discovery ] [Lucas Brand] elasticsearch/0vD7T8u-Rmajbu8MH0yb_w -[2016-02-02 19:00:26,433][INFO ][cluster.service ] [Lucas Brand] new_master {Lucas Brand}{0vD7T8u-Rmajbu8MH0yb_w}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-join(elected_as_master, [0] joins received) -[2016-02-02 19:00:26,443][INFO ][http ] [Lucas Brand] publish_address {127.0.0.1:9292}, bound_addresses {127.0.0.1:9292}, {[::1]:9292} -[2016-02-02 19:00:26,443][INFO ][node ] [Lucas Brand] started -[2016-02-02 19:00:26,535][INFO ][gateway ] [Lucas Brand] recovered [0] indices into cluster_state -[2016-02-02 19:01:28,760][INFO ][node ] [Lucas Brand] stopping ... -[2016-02-02 19:01:28,770][INFO ][node ] [Lucas Brand] stopped -[2016-02-02 19:01:28,770][INFO ][node ] [Lucas Brand] closing ... -[2016-02-02 19:01:28,773][INFO ][node ] [Lucas Brand] closed -[2016-02-02 19:01:32,954][INFO ][node ] [Hephaestus] version[2.2.0], pid[4590], build[8ff36d1/2016-01-27T13:32:39Z] -[2016-02-02 19:01:32,955][INFO ][node ] [Hephaestus] initializing ... -[2016-02-02 19:01:33,045][INFO ][plugins ] [Hephaestus] modules [], plugins [], sites [] -[2016-02-02 19:01:33,075][INFO ][env ] [Hephaestus] using [1] data paths, mounts [[/home (/dev/sdb5)]], net usable_space [202.6gb], net total_space [436.4gb], spins? [possibly], types [ext4] -[2016-02-02 19:01:33,075][INFO ][env ] [Hephaestus] heap size [3.4gb], compressed ordinary object pointers [true] -[2016-02-02 19:01:34,914][INFO ][node ] [Hephaestus] initialized -[2016-02-02 19:01:34,914][INFO ][node ] [Hephaestus] starting ... -[2016-02-02 19:01:34,973][INFO ][transport ] [Hephaestus] publish_address {127.0.0.1:9300}, bound_addresses {127.0.0.1:9300}, {[::1]:9300} -[2016-02-02 19:01:34,981][INFO ][discovery ] [Hephaestus] elasticsearch/KPUfVSTIRRicjnPSp6TjLQ -[2016-02-02 19:01:38,024][INFO ][cluster.service ] [Hephaestus] new_master {Hephaestus}{KPUfVSTIRRicjnPSp6TjLQ}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-join(elected_as_master, [0] joins received) -[2016-02-02 19:01:38,037][INFO ][http ] [Hephaestus] publish_address {127.0.0.1:9292}, bound_addresses {127.0.0.1:9292}, {[::1]:9292} -[2016-02-02 19:01:38,038][INFO ][node ] [Hephaestus] started -[2016-02-02 19:01:38,105][INFO ][gateway ] [Hephaestus] recovered [0] indices into cluster_state -[2016-02-02 19:02:06,623][INFO ][node ] [Hephaestus] stopping ... -[2016-02-02 19:02:06,633][INFO ][node ] [Hephaestus] stopped -[2016-02-02 19:02:06,633][INFO ][node ] [Hephaestus] closing ... -[2016-02-02 19:02:06,637][INFO ][node ] [Hephaestus] closed -[2016-02-02 19:02:24,839][INFO ][node ] [Sergeant Fury] version[2.2.0], pid[4758], build[8ff36d1/2016-01-27T13:32:39Z] -[2016-02-02 19:02:24,840][INFO ][node ] [Sergeant Fury] initializing ... -[2016-02-02 19:02:24,922][INFO ][plugins ] [Sergeant Fury] modules [], plugins [], sites [] -[2016-02-02 19:02:24,946][INFO ][env ] [Sergeant Fury] using [1] data paths, mounts [[/home (/dev/sdb5)]], net usable_space [202.6gb], net total_space [436.4gb], spins? [possibly], types [ext4] -[2016-02-02 19:02:24,946][INFO ][env ] [Sergeant Fury] heap size [3.4gb], compressed ordinary object pointers [true] -[2016-02-02 19:02:26,789][INFO ][node ] [Sergeant Fury] initialized -[2016-02-02 19:02:26,789][INFO ][node ] [Sergeant Fury] starting ... -[2016-02-02 19:02:26,851][INFO ][transport ] [Sergeant Fury] publish_address {127.0.0.1:9300}, bound_addresses {127.0.0.1:9300}, {[::1]:9300} -[2016-02-02 19:02:26,860][INFO ][discovery ] [Sergeant Fury] elasticsearch/dG65jlrZSDCOeJg0Q074Cw -[2016-02-02 19:02:29,905][INFO ][cluster.service ] [Sergeant Fury] new_master {Sergeant Fury}{dG65jlrZSDCOeJg0Q074Cw}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-join(elected_as_master, [0] joins received) -[2016-02-02 19:02:29,914][INFO ][http ] [Sergeant Fury] publish_address {127.0.0.1:9292}, bound_addresses {127.0.0.1:9292}, {[::1]:9292} -[2016-02-02 19:02:29,915][INFO ][node ] [Sergeant Fury] started -[2016-02-02 19:02:29,985][INFO ][gateway ] [Sergeant Fury] recovered [0] indices into cluster_state -[2016-02-02 19:02:43,546][INFO ][node ] [Sergeant Fury] stopping ... -[2016-02-02 19:02:43,555][INFO ][node ] [Sergeant Fury] stopped -[2016-02-02 19:02:43,555][INFO ][node ] [Sergeant Fury] closing ... -[2016-02-02 19:02:43,559][INFO ][node ] [Sergeant Fury] closed -[2016-02-02 19:02:49,922][INFO ][node ] [Lady Mandarin] version[2.2.0], pid[4918], build[8ff36d1/2016-01-27T13:32:39Z] -[2016-02-02 19:02:49,923][INFO ][node ] [Lady Mandarin] initializing ... -[2016-02-02 19:02:50,007][INFO ][plugins ] [Lady Mandarin] modules [], plugins [], sites [] -[2016-02-02 19:02:50,045][INFO ][env ] [Lady Mandarin] using [1] data paths, mounts [[/home (/dev/sdb5)]], net usable_space [202.6gb], net total_space [436.4gb], spins? [possibly], types [ext4] -[2016-02-02 19:02:50,045][INFO ][env ] [Lady Mandarin] heap size [3.4gb], compressed ordinary object pointers [true] -[2016-02-02 19:02:51,888][INFO ][node ] [Lady Mandarin] initialized -[2016-02-02 19:02:51,888][INFO ][node ] [Lady Mandarin] starting ... -[2016-02-02 19:02:51,950][INFO ][transport ] [Lady Mandarin] publish_address {127.0.0.1:9300}, bound_addresses {127.0.0.1:9300}, {[::1]:9300} -[2016-02-02 19:02:51,960][INFO ][discovery ] [Lady Mandarin] elasticsearch/hCDo3Pj5SnKGJzrKTawrSw -[2016-02-02 19:02:55,005][INFO ][cluster.service ] [Lady Mandarin] new_master {Lady Mandarin}{hCDo3Pj5SnKGJzrKTawrSw}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-join(elected_as_master, [0] joins received) -[2016-02-02 19:02:55,015][INFO ][http ] [Lady Mandarin] publish_address {127.0.0.1:9292}, bound_addresses {127.0.0.1:9292}, {[::1]:9292} -[2016-02-02 19:02:55,015][INFO ][node ] [Lady Mandarin] started -[2016-02-02 19:02:55,084][INFO ][gateway ] [Lady Mandarin] recovered [0] indices into cluster_state -[2016-02-02 19:25:37,053][INFO ][node ] [Lady Mandarin] stopping ... -[2016-02-02 19:25:37,064][INFO ][node ] [Lady Mandarin] stopped -[2016-02-02 19:25:37,065][INFO ][node ] [Lady Mandarin] closing ... -[2016-02-02 19:25:37,068][INFO ][node ] [Lady Mandarin] closed +[2016-06-17 00:07:43,497][INFO ][node ] [Arishem the Judge] version[2.3.3], pid[12289], build[218bdf1/2016-05-17T15:40:04Z] +[2016-06-17 00:07:43,499][INFO ][node ] [Arishem the Judge] initializing ... +[2016-06-17 00:07:44,952][INFO ][plugins ] [Arishem the Judge] modules [], plugins [duniter], sites [] +[2016-06-17 00:07:45,147][INFO ][env ] [Arishem the Judge] using [1] data paths, mounts [[/ (/dev/sda1)]], net usable_space [255.7gb], net total_space [289.4gb], spins? [possibly], types [ext4] +[2016-06-17 00:07:45,147][INFO ][env ] [Arishem the Judge] heap size [859mb], compressed ordinary object pointers [true] +[2016-06-17 00:07:50,432][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.ColorConverter@56382bc9 +[2016-06-17 00:07:50,472][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.KeyStrokeConverter@6a916402 +[2016-06-17 00:07:50,473][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.LocaleConverter@3811510 +[2016-06-17 00:07:50,473][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.URIConverter@7f2d31af +[2016-06-17 00:07:50,474][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.URLConverter@346f41a9 +[2016-06-17 00:07:50,476][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.util.converter.VersionConverter@2e26173 +[2016-06-17 00:07:50,477][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.util.version.VersionConverter@1e95b653 +[2016-06-17 00:07:50,488][INFO ][org.duniter.elasticsearch.service.ServiceLocator] Starting ServiceLocator (guice) +[2016-06-17 00:07:50,865][INFO ][node ] [Arishem the Judge] initialized +[2016-06-17 00:07:50,865][INFO ][node ] [Arishem the Judge] starting ... +[2016-06-17 00:07:50,866][INFO ][org.duniter.elasticsearch.service.ServiceLocator] Starting ServiceLocator (guice) +[2016-06-17 00:07:50,866][INFO ][org.duniter.elasticsearch.service.ServiceLocator] Starting ServiceLocator (guice) +[2016-06-17 00:07:50,954][ERROR][bootstrap ] [Arishem the Judge] Exception +java.util.ServiceConfigurationError: org.duniter.core.beans.Bean: Provider org.duniter.core.service.Ed25519CryptoServiceImpl could not be instantiated + at java.util.ServiceLoader.fail(ServiceLoader.java:232) + at java.util.ServiceLoader.access$100(ServiceLoader.java:185) + at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:384) + at java.util.ServiceLoader$LazyIterator.access$700(ServiceLoader.java:323) + at java.util.ServiceLoader$LazyIterator$2.run(ServiceLoader.java:407) + at java.security.AccessController.doPrivileged(Native Method) + at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:409) + at java.util.ServiceLoader$1.next(ServiceLoader.java:480) + at org.duniter.core.beans.BeanFactory.newBean(BeanFactory.java:79) + at org.duniter.core.beans.BeanFactory.getBean(BeanFactory.java:57) + at org.duniter.core.client.service.ServiceLocator.getBean(ServiceLocator.java:140) + at org.duniter.core.client.service.ServiceLocator.getHttpService(ServiceLocator.java:111) + at org.duniter.core.client.service.bma.BaseRemoteServiceImpl.afterPropertiesSet(BaseRemoteServiceImpl.java:45) + at org.duniter.core.client.service.bma.WotRemoteServiceImpl.afterPropertiesSet(WotRemoteServiceImpl.java:80) + at org.duniter.core.beans.BeanFactory.getBean(BeanFactory.java:66) + at org.duniter.core.client.service.ServiceLocator.getBean(ServiceLocator.java:140) + at org.duniter.core.client.service.ServiceLocator.getWotRemoteService(ServiceLocator.java:129) + at org.duniter.elasticsearch.service.market.RecordMarketService.start(RecordMarketService.java:79) + at org.duniter.elasticsearch.service.market.RecordMarketService.start(RecordMarketService.java:55) + at org.elasticsearch.node.Node.start(Node.java:255) + at org.elasticsearch.bootstrap.Bootstrap.start(Bootstrap.java:206) + at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:272) + at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:498) + at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) +Caused by: java.lang.ExceptionInInitializerError + at jnr.ffi.LibraryLoader.getSearchPaths(LibraryLoader.java:318) + at jnr.ffi.LibraryLoader.load(LibraryLoader.java:290) + at jnr.ffi.LibraryLoader.load(LibraryLoader.java:269) + at org.abstractj.kalium.NaCl$SingletonHolder.<clinit>(NaCl.java:41) + at org.abstractj.kalium.NaCl.sodium(NaCl.java:28) + at org.duniter.core.service.Ed25519CryptoServiceImpl.<init>(Ed25519CryptoServiceImpl.java:66) + at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) + at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) + at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) + at java.lang.reflect.Constructor.newInstance(Constructor.java:423) + at java.lang.Class.newInstance(Class.java:442) + at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:380) + ... 25 more +Caused by: java.security.AccessControlException: access denied ("java.io.FilePermission" "/etc/ld.so.conf" "read") + at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472) + at java.security.AccessController.checkPermission(AccessController.java:884) + at java.lang.SecurityManager.checkPermission(SecurityManager.java:549) + at java.lang.SecurityManager.checkRead(SecurityManager.java:888) + at java.io.File.exists(File.java:814) + at jnr.ffi.LibraryLoader$StaticDataHolder.<clinit>(LibraryLoader.java:386) + ... 37 more +[2016-06-17 00:07:50,960][INFO ][node ] [Arishem the Judge] stopping ... +[2016-06-17 00:07:50,966][INFO ][org.duniter.elasticsearch.service.ServiceLocator] Starting ServiceLocator (guice) +[2016-06-17 00:07:50,967][INFO ][org.duniter.elasticsearch.service.ServiceLocator] Starting ServiceLocator (guice) +[2016-06-17 00:07:50,967][INFO ][node ] [Arishem the Judge] stopped +[2016-06-17 00:07:50,967][INFO ][node ] [Arishem the Judge] closing ... +[2016-06-17 00:07:50,972][INFO ][org.duniter.elasticsearch.service.ServiceLocator] Starting ServiceLocator (guice) +[2016-06-17 00:07:50,972][INFO ][org.duniter.core.client.service.ServiceLocator] Closing ServiceLocator... +[2016-06-17 00:07:50,973][INFO ][org.duniter.elasticsearch.service.ServiceLocator] Starting ServiceLocator (guice) +[2016-06-17 00:07:50,975][INFO ][node ] [Arishem the Judge] closed +[2016-06-17 14:20:33,701][INFO ][node ] [Gargouille] version[2.3.3], pid[16348], build[218bdf1/2016-05-17T15:40:04Z] +[2016-06-17 14:20:33,801][INFO ][node ] [Gargouille] initializing ... +[2016-06-17 14:20:35,763][INFO ][plugins ] [Gargouille] modules [], plugins [duniter], sites [] +[2016-06-17 14:20:35,848][INFO ][env ] [Gargouille] using [1] data paths, mounts [[/ (/dev/sda1)]], net usable_space [255.7gb], net total_space [289.4gb], spins? [possibly], types [ext4] +[2016-06-17 14:20:35,848][INFO ][env ] [Gargouille] heap size [859mb], compressed ordinary object pointers [true] +[2016-06-17 14:20:41,808][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.ColorConverter@5731d3a +[2016-06-17 14:20:41,889][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.KeyStrokeConverter@3664f108 +[2016-06-17 14:20:41,891][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.LocaleConverter@3458eca5 +[2016-06-17 14:20:41,906][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.URIConverter@47768e74 +[2016-06-17 14:20:41,907][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.URLConverter@5fef2aac +[2016-06-17 14:20:41,909][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.util.converter.VersionConverter@5d342959 +[2016-06-17 14:20:41,910][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.util.version.VersionConverter@2721044 +[2016-06-17 14:20:41,968][INFO ][org.duniter.elasticsearch.service.ServiceLocator] Starting ServiceLocator (guice) +[2016-06-17 14:20:41,968][INFO ][org.duniter.elasticsearch.service.ServiceLocator] Starting ServiceLocator [OK] +[2016-06-17 14:20:43,057][ERROR][bootstrap ] Exception +org.elasticsearch.common.inject.ProvisionException: Guice provision errors: + +1) Error injecting method, java.util.ServiceConfigurationError: org.duniter.core.beans.Bean: Provider org.duniter.core.service.Ed25519CryptoServiceImpl could not be instantiated + at org.duniter.elasticsearch.service.blockchain.BlockBlockchainService.setBlockBlockchainService(Unknown Source) + while locating org.duniter.elasticsearch.service.blockchain.BlockBlockchainService + +1 error + at org.elasticsearch.common.inject.InjectorImpl$4.get(InjectorImpl.java:832) + at org.elasticsearch.common.inject.InheritingState.makeAllBindingsToEagerSingletons(InheritingState.java:157) + at org.elasticsearch.common.inject.InjectorImpl.readOnlyAllSingletons(InjectorImpl.java:908) + at org.elasticsearch.common.inject.ModulesBuilder.createInjector(ModulesBuilder.java:50) + at org.elasticsearch.node.Node.<init>(Node.java:213) + at org.elasticsearch.node.Node.<init>(Node.java:140) + at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:143) + at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:178) + at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:270) + at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:498) + at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) +Caused by: java.util.ServiceConfigurationError: org.duniter.core.beans.Bean: Provider org.duniter.core.service.Ed25519CryptoServiceImpl could not be instantiated + at java.util.ServiceLoader.fail(ServiceLoader.java:232) + at java.util.ServiceLoader.access$100(ServiceLoader.java:185) + at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:384) + at java.util.ServiceLoader$LazyIterator.access$700(ServiceLoader.java:323) + at java.util.ServiceLoader$LazyIterator$2.run(ServiceLoader.java:407) + at java.security.AccessController.doPrivileged(Native Method) + at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:409) + at java.util.ServiceLoader$1.next(ServiceLoader.java:480) + at org.duniter.core.beans.BeanFactory.newBean(BeanFactory.java:82) + at org.duniter.core.beans.BeanFactory.getBean(BeanFactory.java:57) + at org.duniter.core.client.service.ServiceLocator.getBean(ServiceLocator.java:140) + at org.duniter.core.client.service.ServiceLocator.getHttpService(ServiceLocator.java:111) + at org.duniter.core.client.service.bma.BaseRemoteServiceImpl.afterPropertiesSet(BaseRemoteServiceImpl.java:45) + at org.duniter.core.client.service.bma.BlockchainRemoteServiceImpl.afterPropertiesSet(BlockchainRemoteServiceImpl.java:102) + at org.duniter.core.beans.BeanFactory.getBean(BeanFactory.java:66) + at org.duniter.core.client.service.ServiceLocator.getBean(ServiceLocator.java:140) + at org.duniter.core.client.service.ServiceLocator.getBlockchainRemoteService(ServiceLocator.java:99) + at org.duniter.elasticsearch.service.blockchain.BlockBlockchainService.setBlockBlockchainService(BlockBlockchainService.java:104) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:498) + at org.elasticsearch.common.inject.SingleMethodInjector$1.invoke(SingleMethodInjector.java:56) + at org.elasticsearch.common.inject.SingleMethodInjector.inject(SingleMethodInjector.java:77) + at org.elasticsearch.common.inject.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:96) + at org.elasticsearch.common.inject.ConstructorInjector.construct(ConstructorInjector.java:95) + at org.elasticsearch.common.inject.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:104) + at org.elasticsearch.common.inject.InjectorImpl$4$1.call(InjectorImpl.java:823) + at org.elasticsearch.common.inject.InjectorImpl.callInContext(InjectorImpl.java:879) + at org.elasticsearch.common.inject.InjectorImpl$4.get(InjectorImpl.java:818) + ... 14 more +Caused by: java.lang.ExceptionInInitializerError + at jnr.ffi.LibraryLoader.getSearchPaths(LibraryLoader.java:318) + at jnr.ffi.LibraryLoader.load(LibraryLoader.java:290) + at jnr.ffi.LibraryLoader.load(LibraryLoader.java:269) + at org.abstractj.kalium.NaCl$SingletonHolder.<clinit>(NaCl.java:41) + at org.abstractj.kalium.NaCl.sodium(NaCl.java:28) + at org.duniter.core.service.Ed25519CryptoServiceImpl.<init>(Ed25519CryptoServiceImpl.java:66) + at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) + at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) + at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) + at java.lang.reflect.Constructor.newInstance(Constructor.java:423) + at java.lang.Class.newInstance(Class.java:442) + at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:380) + ... 41 more +Caused by: java.security.AccessControlException: access denied ("java.io.FilePermission" "/etc/ld.so.conf" "read") + at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472) + at java.security.AccessController.checkPermission(AccessController.java:884) + at java.lang.SecurityManager.checkPermission(SecurityManager.java:549) + at java.lang.SecurityManager.checkRead(SecurityManager.java:888) + at java.io.File.exists(File.java:814) + at jnr.ffi.LibraryLoader$StaticDataHolder.<clinit>(LibraryLoader.java:386) + ... 53 more +[2016-06-17 14:21:25,027][INFO ][node ] [Nicholas Maunder] version[2.3.3], pid[16433], build[218bdf1/2016-05-17T15:40:04Z] +[2016-06-17 14:21:25,028][INFO ][node ] [Nicholas Maunder] initializing ... +[2016-06-17 14:21:25,630][INFO ][plugins ] [Nicholas Maunder] modules [], plugins [duniter], sites [] +[2016-06-17 14:21:25,665][INFO ][env ] [Nicholas Maunder] using [1] data paths, mounts [[/ (/dev/sda1)]], net usable_space [255.7gb], net total_space [289.4gb], spins? [possibly], types [ext4] +[2016-06-17 14:21:25,666][INFO ][env ] [Nicholas Maunder] heap size [859mb], compressed ordinary object pointers [true] +[2016-06-17 14:21:29,212][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.ColorConverter@439f2d87 +[2016-06-17 14:21:29,261][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.KeyStrokeConverter@7574d4ad +[2016-06-17 14:21:29,262][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.LocaleConverter@27bc1d44 +[2016-06-17 14:21:29,263][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.URIConverter@1d2d8846 +[2016-06-17 14:21:29,264][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.URLConverter@2dcd0e41 +[2016-06-17 14:21:29,266][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.util.converter.VersionConverter@74431b9c +[2016-06-17 14:21:29,268][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.util.version.VersionConverter@4e3283f6 +[2016-06-17 14:21:29,288][INFO ][org.duniter.elasticsearch.service.ServiceLocator] Starting ServiceLocator (guice) +[2016-06-17 14:21:29,288][INFO ][org.duniter.elasticsearch.service.ServiceLocator] Starting ServiceLocator [OK] +[2016-06-17 14:21:29,955][ERROR][bootstrap ] Exception +org.elasticsearch.common.inject.ProvisionException: Guice provision errors: + +1) Error injecting method, java.util.ServiceConfigurationError: org.duniter.core.beans.Bean: Provider org.duniter.core.service.Ed25519CryptoServiceImpl could not be instantiated + at org.duniter.elasticsearch.service.blockchain.BlockBlockchainService.setBlockBlockchainService(Unknown Source) + while locating org.duniter.elasticsearch.service.blockchain.BlockBlockchainService + +1 error + at org.elasticsearch.common.inject.InjectorImpl$4.get(InjectorImpl.java:832) + at org.elasticsearch.common.inject.InheritingState.makeAllBindingsToEagerSingletons(InheritingState.java:157) + at org.elasticsearch.common.inject.InjectorImpl.readOnlyAllSingletons(InjectorImpl.java:908) + at org.elasticsearch.common.inject.ModulesBuilder.createInjector(ModulesBuilder.java:50) + at org.elasticsearch.node.Node.<init>(Node.java:213) + at org.elasticsearch.node.Node.<init>(Node.java:140) + at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:143) + at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:178) + at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:270) + at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35) +Caused by: java.util.ServiceConfigurationError: org.duniter.core.beans.Bean: Provider org.duniter.core.service.Ed25519CryptoServiceImpl could not be instantiated + at java.util.ServiceLoader.fail(ServiceLoader.java:232) + at java.util.ServiceLoader.access$100(ServiceLoader.java:185) + at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:384) + at java.util.ServiceLoader$LazyIterator.access$700(ServiceLoader.java:323) + at java.util.ServiceLoader$LazyIterator$2.run(ServiceLoader.java:407) + at java.security.AccessController.doPrivileged(Native Method) + at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:409) + at java.util.ServiceLoader$1.next(ServiceLoader.java:480) + at org.duniter.core.beans.BeanFactory.newBean(BeanFactory.java:82) + at org.duniter.core.beans.BeanFactory.getBean(BeanFactory.java:57) + at org.duniter.core.client.service.ServiceLocator.getBean(ServiceLocator.java:140) + at org.duniter.core.client.service.ServiceLocator.getHttpService(ServiceLocator.java:111) + at org.duniter.core.client.service.bma.BaseRemoteServiceImpl.afterPropertiesSet(BaseRemoteServiceImpl.java:45) + at org.duniter.core.client.service.bma.BlockchainRemoteServiceImpl.afterPropertiesSet(BlockchainRemoteServiceImpl.java:102) + at org.duniter.core.beans.BeanFactory.getBean(BeanFactory.java:66) + at org.duniter.core.client.service.ServiceLocator.getBean(ServiceLocator.java:140) + at org.duniter.core.client.service.ServiceLocator.getBlockchainRemoteService(ServiceLocator.java:99) + at org.duniter.elasticsearch.service.blockchain.BlockBlockchainService.setBlockBlockchainService(BlockBlockchainService.java:104) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:498) + at org.elasticsearch.common.inject.SingleMethodInjector$1.invoke(SingleMethodInjector.java:56) + at org.elasticsearch.common.inject.SingleMethodInjector.inject(SingleMethodInjector.java:77) + at org.elasticsearch.common.inject.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:96) + at org.elasticsearch.common.inject.ConstructorInjector.construct(ConstructorInjector.java:95) + at org.elasticsearch.common.inject.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:104) + at org.elasticsearch.common.inject.InjectorImpl$4$1.call(InjectorImpl.java:823) + at org.elasticsearch.common.inject.InjectorImpl.callInContext(InjectorImpl.java:879) + at org.elasticsearch.common.inject.InjectorImpl$4.get(InjectorImpl.java:818) + ... 9 more +Caused by: java.lang.ExceptionInInitializerError + at jnr.ffi.LibraryLoader.getSearchPaths(LibraryLoader.java:318) + at jnr.ffi.LibraryLoader.load(LibraryLoader.java:290) + at jnr.ffi.LibraryLoader.load(LibraryLoader.java:269) + at org.abstractj.kalium.NaCl$SingletonHolder.<clinit>(NaCl.java:41) + at org.abstractj.kalium.NaCl.sodium(NaCl.java:28) + at org.duniter.core.service.Ed25519CryptoServiceImpl.<init>(Ed25519CryptoServiceImpl.java:66) + at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) + at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) + at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) + at java.lang.reflect.Constructor.newInstance(Constructor.java:423) + at java.lang.Class.newInstance(Class.java:442) + at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:380) + ... 36 more +Caused by: java.security.AccessControlException: access denied ("java.io.FilePermission" "/etc/ld.so.conf" "read") + at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472) + at java.security.AccessController.checkPermission(AccessController.java:884) + at java.lang.SecurityManager.checkPermission(SecurityManager.java:549) + at java.lang.SecurityManager.checkRead(SecurityManager.java:888) + at java.io.File.exists(File.java:814) + at jnr.ffi.LibraryLoader$StaticDataHolder.<clinit>(LibraryLoader.java:386) + ... 48 more +[2016-06-17 14:22:20,332][INFO ][node ] [Zombie] version[2.3.3], pid[16488], build[218bdf1/2016-05-17T15:40:04Z] +[2016-06-17 14:22:20,332][INFO ][node ] [Zombie] initializing ... +[2016-06-17 14:22:21,068][INFO ][plugins ] [Zombie] modules [], plugins [duniter], sites [] +[2016-06-17 14:22:21,101][INFO ][env ] [Zombie] using [1] data paths, mounts [[/ (/dev/sda1)]], net usable_space [255.7gb], net total_space [289.4gb], spins? [possibly], types [ext4] +[2016-06-17 14:22:21,101][INFO ][env ] [Zombie] heap size [859mb], compressed ordinary object pointers [true] +[2016-06-17 14:22:23,859][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.ColorConverter@5731d3a +[2016-06-17 14:22:23,917][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.KeyStrokeConverter@3664f108 +[2016-06-17 14:22:23,918][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.LocaleConverter@3458eca5 +[2016-06-17 14:22:23,919][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.URIConverter@47768e74 +[2016-06-17 14:22:23,920][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.URLConverter@5fef2aac +[2016-06-17 14:22:23,922][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.util.converter.VersionConverter@5d342959 +[2016-06-17 14:22:23,923][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.util.version.VersionConverter@2721044 +[2016-06-17 14:22:23,938][INFO ][org.duniter.elasticsearch.service.ServiceLocator] Starting ServiceLocator (guice) +[2016-06-17 14:22:23,939][INFO ][org.duniter.elasticsearch.service.ServiceLocator] Starting ServiceLocator [OK] +[2016-06-17 14:22:24,287][ERROR][bootstrap ] Exception +org.elasticsearch.common.inject.ProvisionException: Guice provision errors: + +1) Error injecting method, java.util.ServiceConfigurationError: org.duniter.core.beans.Bean: Provider org.duniter.core.service.Ed25519CryptoServiceImpl could not be instantiated + at org.duniter.elasticsearch.service.blockchain.BlockBlockchainService.setBlockBlockchainService(Unknown Source) + while locating org.duniter.elasticsearch.service.blockchain.BlockBlockchainService + +1 error + at org.elasticsearch.common.inject.InjectorImpl$4.get(InjectorImpl.java:832) + at org.elasticsearch.common.inject.InheritingState.makeAllBindingsToEagerSingletons(InheritingState.java:157) + at org.elasticsearch.common.inject.InjectorImpl.readOnlyAllSingletons(InjectorImpl.java:908) + at org.elasticsearch.common.inject.ModulesBuilder.createInjector(ModulesBuilder.java:50) + at org.elasticsearch.node.Node.<init>(Node.java:213) + at org.elasticsearch.node.Node.<init>(Node.java:140) + at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:143) + at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:178) + at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:270) + at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:498) + at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) +Caused by: java.util.ServiceConfigurationError: org.duniter.core.beans.Bean: Provider org.duniter.core.service.Ed25519CryptoServiceImpl could not be instantiated + at java.util.ServiceLoader.fail(ServiceLoader.java:232) + at java.util.ServiceLoader.access$100(ServiceLoader.java:185) + at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:384) + at java.util.ServiceLoader$LazyIterator.access$700(ServiceLoader.java:323) + at java.util.ServiceLoader$LazyIterator$2.run(ServiceLoader.java:407) + at java.security.AccessController.doPrivileged(Native Method) + at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:409) + at java.util.ServiceLoader$1.next(ServiceLoader.java:480) + at org.duniter.core.beans.BeanFactory.newBean(BeanFactory.java:82) + at org.duniter.core.beans.BeanFactory.getBean(BeanFactory.java:57) + at org.duniter.core.client.service.ServiceLocator.getBean(ServiceLocator.java:140) + at org.duniter.core.client.service.ServiceLocator.getHttpService(ServiceLocator.java:111) + at org.duniter.core.client.service.bma.BaseRemoteServiceImpl.afterPropertiesSet(BaseRemoteServiceImpl.java:45) + at org.duniter.core.client.service.bma.BlockchainRemoteServiceImpl.afterPropertiesSet(BlockchainRemoteServiceImpl.java:102) + at org.duniter.core.beans.BeanFactory.getBean(BeanFactory.java:66) + at org.duniter.core.client.service.ServiceLocator.getBean(ServiceLocator.java:140) + at org.duniter.core.client.service.ServiceLocator.getBlockchainRemoteService(ServiceLocator.java:99) + at org.duniter.elasticsearch.service.blockchain.BlockBlockchainService.setBlockBlockchainService(BlockBlockchainService.java:104) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:498) + at org.elasticsearch.common.inject.SingleMethodInjector$1.invoke(SingleMethodInjector.java:56) + at org.elasticsearch.common.inject.SingleMethodInjector.inject(SingleMethodInjector.java:77) + at org.elasticsearch.common.inject.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:96) + at org.elasticsearch.common.inject.ConstructorInjector.construct(ConstructorInjector.java:95) + at org.elasticsearch.common.inject.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:104) + at org.elasticsearch.common.inject.InjectorImpl$4$1.call(InjectorImpl.java:823) + at org.elasticsearch.common.inject.InjectorImpl.callInContext(InjectorImpl.java:879) + at org.elasticsearch.common.inject.InjectorImpl$4.get(InjectorImpl.java:818) + ... 14 more +Caused by: java.lang.ExceptionInInitializerError + at jnr.ffi.LibraryLoader.getSearchPaths(LibraryLoader.java:318) + at jnr.ffi.LibraryLoader.load(LibraryLoader.java:290) + at jnr.ffi.LibraryLoader.load(LibraryLoader.java:269) + at org.abstractj.kalium.NaCl$SingletonHolder.<clinit>(NaCl.java:41) + at org.abstractj.kalium.NaCl.sodium(NaCl.java:28) + at org.duniter.core.service.Ed25519CryptoServiceImpl.<init>(Ed25519CryptoServiceImpl.java:66) + at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) + at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) + at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) + at java.lang.reflect.Constructor.newInstance(Constructor.java:423) + at java.lang.Class.newInstance(Class.java:442) + at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:380) + ... 41 more +Caused by: java.security.AccessControlException: access denied ("java.io.FilePermission" "/etc/ld.so.conf" "read") + at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472) + at java.security.AccessController.checkPermission(AccessController.java:884) + at java.lang.SecurityManager.checkPermission(SecurityManager.java:549) + at java.lang.SecurityManager.checkRead(SecurityManager.java:888) + at java.io.File.exists(File.java:814) + at jnr.ffi.LibraryLoader$StaticDataHolder.<clinit>(LibraryLoader.java:386) + ... 53 more +[2016-06-17 14:25:25,194][INFO ][node ] [Shriek] version[2.3.3], pid[16615], build[218bdf1/2016-05-17T15:40:04Z] +[2016-06-17 14:25:25,194][INFO ][node ] [Shriek] initializing ... +[2016-06-17 14:25:25,914][INFO ][plugins ] [Shriek] modules [], plugins [duniter], sites [] +[2016-06-17 14:25:25,944][INFO ][env ] [Shriek] using [1] data paths, mounts [[/ (/dev/sda1)]], net usable_space [255.7gb], net total_space [289.4gb], spins? [possibly], types [ext4] +[2016-06-17 14:25:25,944][INFO ][env ] [Shriek] heap size [859mb], compressed ordinary object pointers [true] +[2016-06-17 14:25:28,268][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.ColorConverter@1de13f34 +[2016-06-17 14:25:28,326][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.KeyStrokeConverter@6ce26986 +[2016-06-17 14:25:28,328][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.LocaleConverter@34009349 +[2016-06-17 14:25:28,330][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.URIConverter@7f2b584b +[2016-06-17 14:25:28,332][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.URLConverter@342beaf6 +[2016-06-17 14:25:28,338][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.util.converter.VersionConverter@2abc55c4 +[2016-06-17 14:25:28,340][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.util.version.VersionConverter@25ce435 +[2016-06-17 14:25:28,367][INFO ][org.duniter.elasticsearch.service.ServiceLocator] Starting ServiceLocator (guice) +[2016-06-17 14:25:28,367][INFO ][org.duniter.elasticsearch.service.ServiceLocator] Starting ServiceLocator [OK] +[2016-06-17 14:25:30,498][INFO ][node ] [Shriek] initialized +[2016-06-17 14:25:30,498][INFO ][node ] [Shriek] starting ... +[2016-06-17 14:25:30,507][DEBUG][org.duniter.elasticsearch.job.BlockIndexer] Starting indexing blocks from node [cgeek.fr:9330]... +[2016-06-17 14:25:30,530][ERROR][bootstrap ] [Shriek] Exception +java.lang.NullPointerException + at org.elasticsearch.action.support.master.TransportMasterNodeAction$AsyncSingleAction.<init>(TransportMasterNodeAction.java:129) + at org.elasticsearch.action.support.master.TransportMasterNodeAction.doExecute(TransportMasterNodeAction.java:107) + at org.elasticsearch.action.support.master.TransportMasterNodeAction.doExecute(TransportMasterNodeAction.java:51) + at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:137) + at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:85) + at org.elasticsearch.client.node.NodeClient.doExecute(NodeClient.java:58) + at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:359) + at org.elasticsearch.client.support.AbstractClient$IndicesAdmin.execute(AbstractClient.java:1226) + at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:86) + at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:56) + at org.duniter.elasticsearch.service.AbstractService.existsIndex(AbstractService.java:124) + at org.duniter.elasticsearch.service.registry.CurrencyRegistryService.deleteAllCurrencies(CurrencyRegistryService.java:292) + at org.duniter.elasticsearch.job.BlockIndexer.resetAllCurrencies(BlockIndexer.java:116) + at org.duniter.elasticsearch.job.BlockIndexer.resetAllData(BlockIndexer.java:109) + at org.duniter.elasticsearch.job.BlockIndexer.start(BlockIndexer.java:87) + at org.duniter.elasticsearch.job.BlockIndexer.start(BlockIndexer.java:26) + at org.elasticsearch.node.Node.start(Node.java:255) + at org.elasticsearch.bootstrap.Bootstrap.start(Bootstrap.java:206) + at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:272) + at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35) +[2016-06-17 14:25:30,534][INFO ][node ] [Shriek] stopping ... +[2016-06-17 14:25:30,535][INFO ][node ] [Shriek] stopped +[2016-06-17 14:25:30,535][INFO ][node ] [Shriek] closing ... +[2016-06-17 14:25:30,543][INFO ][node ] [Shriek] closed +[2016-06-17 14:26:19,318][INFO ][node ] [Hank Pym] version[2.3.3], pid[16728], build[218bdf1/2016-05-17T15:40:04Z] +[2016-06-17 14:26:19,319][INFO ][node ] [Hank Pym] initializing ... +[2016-06-17 14:26:19,884][INFO ][plugins ] [Hank Pym] modules [], plugins [duniter], sites [] +[2016-06-17 14:26:19,913][INFO ][env ] [Hank Pym] using [1] data paths, mounts [[/ (/dev/sda1)]], net usable_space [255.7gb], net total_space [289.4gb], spins? [possibly], types [ext4] +[2016-06-17 14:26:19,913][INFO ][env ] [Hank Pym] heap size [859mb], compressed ordinary object pointers [true] +[2016-06-17 14:26:22,620][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.ColorConverter@47187f50 +[2016-06-17 14:26:22,656][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.KeyStrokeConverter@7f2b584b +[2016-06-17 14:26:22,657][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.LocaleConverter@222acad +[2016-06-17 14:26:22,659][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.URIConverter@3ca3648 +[2016-06-17 14:26:22,659][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.URLConverter@2abc55c4 +[2016-06-17 14:26:22,662][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.util.converter.VersionConverter@19ad75e5 +[2016-06-17 14:26:22,663][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.util.version.VersionConverter@42cf6349 +[2016-06-17 14:26:22,682][INFO ][org.duniter.elasticsearch.service.ServiceLocator] Starting ServiceLocator (guice) +[2016-06-17 14:26:22,683][INFO ][org.duniter.elasticsearch.service.ServiceLocator] Starting ServiceLocator [OK] +[2016-06-17 14:26:23,933][INFO ][node ] [Hank Pym] initialized +[2016-06-17 14:26:23,933][INFO ][node ] [Hank Pym] starting ... +[2016-06-17 14:26:23,942][DEBUG][org.duniter.elasticsearch.job.BlockIndexer] Starting indexing blocks from node [cgeek.fr:9330]... +[2016-06-17 14:26:23,956][ERROR][bootstrap ] [Hank Pym] Exception +java.lang.NullPointerException + at org.elasticsearch.action.support.master.TransportMasterNodeAction$AsyncSingleAction.<init>(TransportMasterNodeAction.java:129) + at org.elasticsearch.action.support.master.TransportMasterNodeAction.doExecute(TransportMasterNodeAction.java:107) + at org.elasticsearch.action.support.master.TransportMasterNodeAction.doExecute(TransportMasterNodeAction.java:51) + at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:137) + at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:85) + at org.elasticsearch.client.node.NodeClient.doExecute(NodeClient.java:58) + at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:359) + at org.elasticsearch.client.support.AbstractClient$IndicesAdmin.execute(AbstractClient.java:1226) + at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:86) + at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:56) + at org.duniter.elasticsearch.service.AbstractService.existsIndex(AbstractService.java:124) + at org.duniter.elasticsearch.service.registry.CurrencyRegistryService.deleteAllCurrencies(CurrencyRegistryService.java:292) + at org.duniter.elasticsearch.job.BlockIndexer.resetAllCurrencies(BlockIndexer.java:116) + at org.duniter.elasticsearch.job.BlockIndexer.resetAllData(BlockIndexer.java:109) + at org.duniter.elasticsearch.job.BlockIndexer.start(BlockIndexer.java:87) + at org.duniter.elasticsearch.job.BlockIndexer.start(BlockIndexer.java:26) + at org.elasticsearch.node.Node.start(Node.java:255) + at org.elasticsearch.bootstrap.Bootstrap.start(Bootstrap.java:206) + at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:272) + at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35) +[2016-06-17 14:26:23,967][INFO ][node ] [Hank Pym] stopping ... +[2016-06-17 14:26:23,968][INFO ][node ] [Hank Pym] stopped +[2016-06-17 14:26:23,969][INFO ][node ] [Hank Pym] closing ... +[2016-06-17 14:26:23,988][INFO ][node ] [Hank Pym] closed +[2016-06-17 14:26:43,568][INFO ][node ] [Deadly Ernest] version[2.3.3], pid[16784], build[218bdf1/2016-05-17T15:40:04Z] +[2016-06-17 14:26:43,569][INFO ][node ] [Deadly Ernest] initializing ... +[2016-06-17 14:26:44,144][INFO ][plugins ] [Deadly Ernest] modules [], plugins [duniter], sites [] +[2016-06-17 14:26:44,170][INFO ][env ] [Deadly Ernest] using [1] data paths, mounts [[/ (/dev/sda1)]], net usable_space [255.7gb], net total_space [289.4gb], spins? [possibly], types [ext4] +[2016-06-17 14:26:44,170][INFO ][env ] [Deadly Ernest] heap size [859mb], compressed ordinary object pointers [true] +[2016-06-17 14:26:46,735][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.ColorConverter@1de13f34 +[2016-06-17 14:26:46,770][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.KeyStrokeConverter@6ce26986 +[2016-06-17 14:26:46,772][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.LocaleConverter@34009349 +[2016-06-17 14:26:46,773][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.URIConverter@7f2b584b +[2016-06-17 14:26:46,773][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.URLConverter@342beaf6 +[2016-06-17 14:26:46,776][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.util.converter.VersionConverter@2abc55c4 +[2016-06-17 14:26:46,777][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.util.version.VersionConverter@25ce435 +[2016-06-17 14:26:46,794][INFO ][org.duniter.elasticsearch.service.ServiceLocator] Starting ServiceLocator (guice) +[2016-06-17 14:26:46,794][INFO ][org.duniter.elasticsearch.service.ServiceLocator] Starting ServiceLocator [OK] +[2016-06-17 14:26:47,742][INFO ][node ] [Deadly Ernest] initialized +[2016-06-17 14:26:47,743][INFO ][node ] [Deadly Ernest] starting ... +[2016-06-17 14:28:14,538][DEBUG][org.duniter.elasticsearch.job.BlockIndexer] Starting indexing blocks from node [cgeek.fr:9330]... +[2016-06-17 14:28:44,333][ERROR][bootstrap ] [Deadly Ernest] Exception +java.lang.NullPointerException + at org.elasticsearch.action.support.master.TransportMasterNodeAction$AsyncSingleAction.<init>(TransportMasterNodeAction.java:129) + at org.elasticsearch.action.support.master.TransportMasterNodeAction.doExecute(TransportMasterNodeAction.java:107) + at org.elasticsearch.action.support.master.TransportMasterNodeAction.doExecute(TransportMasterNodeAction.java:51) + at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:137) + at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:85) + at org.elasticsearch.client.node.NodeClient.doExecute(NodeClient.java:58) + at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:359) + at org.elasticsearch.client.support.AbstractClient$IndicesAdmin.execute(AbstractClient.java:1226) + at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:86) + at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:56) + at org.duniter.elasticsearch.service.AbstractService.existsIndex(AbstractService.java:124) + at org.duniter.elasticsearch.service.registry.CurrencyRegistryService.deleteAllCurrencies(CurrencyRegistryService.java:292) + at org.duniter.elasticsearch.job.BlockIndexer.resetAllCurrencies(BlockIndexer.java:116) + at org.duniter.elasticsearch.job.BlockIndexer.resetAllData(BlockIndexer.java:109) + at org.duniter.elasticsearch.job.BlockIndexer.start(BlockIndexer.java:87) + at org.duniter.elasticsearch.job.BlockIndexer.start(BlockIndexer.java:26) + at org.elasticsearch.node.Node.start(Node.java:255) + at org.elasticsearch.bootstrap.Bootstrap.start(Bootstrap.java:206) + at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:272) + at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35) +[2016-06-17 14:28:44,342][INFO ][node ] [Deadly Ernest] stopping ... +[2016-06-17 14:28:44,344][INFO ][node ] [Deadly Ernest] stopped +[2016-06-17 14:28:44,344][INFO ][node ] [Deadly Ernest] closing ... +[2016-06-17 14:28:44,357][INFO ][node ] [Deadly Ernest] closed +[2016-06-17 14:33:22,926][INFO ][node ] [Benny Beckley] version[2.3.3], pid[17051], build[218bdf1/2016-05-17T15:40:04Z] +[2016-06-17 14:33:22,926][INFO ][node ] [Benny Beckley] initializing ... +[2016-06-17 14:33:23,639][INFO ][plugins ] [Benny Beckley] modules [], plugins [duniter], sites [] +[2016-06-17 14:33:23,673][INFO ][env ] [Benny Beckley] using [1] data paths, mounts [[/ (/dev/sda1)]], net usable_space [255.7gb], net total_space [289.4gb], spins? [possibly], types [ext4] +[2016-06-17 14:33:23,673][INFO ][env ] [Benny Beckley] heap size [859mb], compressed ordinary object pointers [true] +[2016-06-17 14:33:26,023][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.ColorConverter@36baa049 +[2016-06-17 14:33:26,069][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.KeyStrokeConverter@724aefc3 +[2016-06-17 14:33:26,070][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.LocaleConverter@7650ded6 +[2016-06-17 14:33:26,071][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.URIConverter@1a47a1e8 +[2016-06-17 14:33:26,072][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.URLConverter@24eeac69 +[2016-06-17 14:33:26,074][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.util.converter.VersionConverter@1084f78c +[2016-06-17 14:33:26,076][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.util.version.VersionConverter@6d8796c1 +[2016-06-17 14:33:26,094][INFO ][org.duniter.elasticsearch.service.ServiceLocator] Starting ServiceLocator (guice) +[2016-06-17 14:33:26,094][INFO ][org.duniter.elasticsearch.service.ServiceLocator] Starting ServiceLocator [OK] +[2016-06-17 14:33:27,148][INFO ][node ] [Benny Beckley] initialized +[2016-06-17 14:33:27,153][INFO ][node ] [Benny Beckley] starting ... +[2016-06-17 14:33:27,157][DEBUG][org.duniter.elasticsearch.job.BlockIndexer] Starting indexing blocks from node [cgeek.fr:9330]... +[2016-06-17 14:33:27,478][INFO ][transport ] [Benny Beckley] publish_address {127.0.0.1:9300}, bound_addresses {[::1]:9300}, {127.0.0.1:9300} +[2016-06-17 14:33:27,488][INFO ][discovery ] [Benny Beckley] elasticsearch/ERtxwf1iRrGMEdv5AlmsTw +[2016-06-17 14:33:30,605][INFO ][cluster.service ] [Benny Beckley] new_master {Benny Beckley}{ERtxwf1iRrGMEdv5AlmsTw}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-join(elected_as_master, [0] joins received) +[2016-06-17 14:33:30,692][INFO ][http ] [Benny Beckley] publish_address {127.0.0.1:9200}, bound_addresses {[::1]:9200}, {127.0.0.1:9200} +[2016-06-17 14:33:30,692][INFO ][node ] [Benny Beckley] started +[2016-06-17 14:33:30,976][INFO ][gateway ] [Benny Beckley] recovered [0] indices into cluster_state +[2016-06-17 14:38:28,883][INFO ][node ] [Benny Beckley] stopping ... +[2016-06-17 14:38:28,944][INFO ][node ] [Benny Beckley] stopped +[2016-06-17 14:38:28,944][INFO ][node ] [Benny Beckley] closing ... +[2016-06-17 14:38:28,951][INFO ][node ] [Benny Beckley] closed +[2016-06-17 14:38:45,136][INFO ][node ] [Abyss] version[2.3.3], pid[17629], build[218bdf1/2016-05-17T15:40:04Z] +[2016-06-17 14:38:45,137][INFO ][node ] [Abyss] initializing ... +[2016-06-17 14:38:46,656][INFO ][plugins ] [Abyss] modules [], plugins [duniter], sites [] +[2016-06-17 14:38:46,971][INFO ][env ] [Abyss] using [1] data paths, mounts [[/ (/dev/sda1)]], net usable_space [255.7gb], net total_space [289.4gb], spins? [possibly], types [ext4] +[2016-06-17 14:38:46,971][INFO ][env ] [Abyss] heap size [859mb], compressed ordinary object pointers [true] +[2016-06-17 14:38:52,477][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.ColorConverter@36baa049 +[2016-06-17 14:38:52,542][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.KeyStrokeConverter@724aefc3 +[2016-06-17 14:38:52,543][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.LocaleConverter@7650ded6 +[2016-06-17 14:38:52,544][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.URIConverter@1a47a1e8 +[2016-06-17 14:38:52,544][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.converter.URLConverter@24eeac69 +[2016-06-17 14:38:52,547][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.util.converter.VersionConverter@1084f78c +[2016-06-17 14:38:52,549][INFO ][org.nuiton.converter.ConverterUtil] register converter org.nuiton.util.version.VersionConverter@6d8796c1 +[2016-06-17 14:38:52,617][INFO ][org.duniter.elasticsearch.service.ServiceLocator] Starting ServiceLocator (guice) +[2016-06-17 14:38:52,617][INFO ][org.duniter.elasticsearch.service.ServiceLocator] Starting ServiceLocator [OK] +[2016-06-17 14:38:55,540][INFO ][node ] [Abyss] initialized +[2016-06-17 14:38:55,540][INFO ][node ] [Abyss] starting ... +[2016-06-17 14:38:55,543][DEBUG][org.duniter.elasticsearch.job.BlockIndexer] Starting indexing blocks from node [cgeek.fr:9330]... +[2016-06-17 14:38:55,556][ERROR][bootstrap ] [Abyss] Exception +java.lang.NullPointerException + at org.elasticsearch.action.support.master.TransportMasterNodeAction$AsyncSingleAction.<init>(TransportMasterNodeAction.java:129) + at org.elasticsearch.action.support.master.TransportMasterNodeAction.doExecute(TransportMasterNodeAction.java:107) + at org.elasticsearch.action.support.master.TransportMasterNodeAction.doExecute(TransportMasterNodeAction.java:51) + at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:137) + at org.elasticsearch.action.support.TransportAction.execute(TransportAction.java:85) + at org.elasticsearch.client.node.NodeClient.doExecute(NodeClient.java:58) + at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:359) + at org.elasticsearch.client.support.AbstractClient$IndicesAdmin.execute(AbstractClient.java:1226) + at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:86) + at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:56) + at org.duniter.elasticsearch.service.AbstractService.existsIndex(AbstractService.java:124) + at org.duniter.elasticsearch.service.registry.CurrencyRegistryService.deleteAllCurrencies(CurrencyRegistryService.java:292) + at org.duniter.elasticsearch.job.BlockIndexer.resetAllCurrencies(BlockIndexer.java:116) + at org.duniter.elasticsearch.job.BlockIndexer.resetAllData(BlockIndexer.java:109) + at org.duniter.elasticsearch.job.BlockIndexer.start(BlockIndexer.java:87) + at org.duniter.elasticsearch.job.BlockIndexer.start(BlockIndexer.java:26) + at org.elasticsearch.node.Node.start(Node.java:255) + at org.elasticsearch.bootstrap.Bootstrap.start(Bootstrap.java:206) + at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:272) + at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:498) + at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) +[2016-06-17 14:38:55,572][INFO ][node ] [Abyss] stopping ... +[2016-06-17 14:38:55,582][INFO ][node ] [Abyss] stopped +[2016-06-17 14:38:55,582][INFO ][node ] [Abyss] closing ... +[2016-06-17 14:38:55,597][INFO ][node ] [Abyss] closed diff --git a/duniter4j-elasticsearch/src/test/es-home/plugins/duniter4j-elasticsearch/plugin-descriptor.properties b/duniter4j-elasticsearch/src/test/es-home/plugins/duniter4j-elasticsearch/plugin-descriptor.properties index 86bdb461..d32dc21d 100644 --- a/duniter4j-elasticsearch/src/test/es-home/plugins/duniter4j-elasticsearch/plugin-descriptor.properties +++ b/duniter4j-elasticsearch/src/test/es-home/plugins/duniter4j-elasticsearch/plugin-descriptor.properties @@ -1,9 +1,9 @@ -name=duniter4j-elasticsearch -description=duniter4j :: ElasticSearch Plugin +name=duniter +description=Duniter :: ElasticSearch Plugin version=0.1-SNAPSHOT site=false jvm=true -classname=org.duniter.elasticsearch.plugin.Plugin +classname=org.duniter.elasticsearch.Plugin java.version=1.7 -elasticsearch.version=2.3.1 -isolated=false \ No newline at end of file +elasticsearch.version=2.3.3 +isolated=true \ No newline at end of file diff --git a/duniter4j-elasticsearch/src/test/es-home/plugins/duniter4j-elasticsearch/plugin-security.policy b/duniter4j-elasticsearch/src/test/es-home/plugins/duniter4j-elasticsearch/plugin-security.policy new file mode 100644 index 00000000..784f4a00 --- /dev/null +++ b/duniter4j-elasticsearch/src/test/es-home/plugins/duniter4j-elasticsearch/plugin-security.policy @@ -0,0 +1,5 @@ +grant codeBase "file:${es.path.home}/plugins/duniter4j-elasticsearch/"{ + permission java.io.FilePermission "/etc/ld.so.conf", "read"; + permission java.io.FilePermission "/etc/ld.so.conf.d/*.conf", "read"; + permission java.io.FilePermission "/usr/local/lib/*", "read"; +}; diff --git a/duniter4j-elasticsearch/src/test/java/org/duniter/elasticsearch/TestResource.java b/duniter4j-elasticsearch/src/test/java/org/duniter/elasticsearch/TestResource.java index bd9114cb..2b27a3e5 100644 --- a/duniter4j-elasticsearch/src/test/java/org/duniter/elasticsearch/TestResource.java +++ b/duniter4j-elasticsearch/src/test/java/org/duniter/elasticsearch/TestResource.java @@ -24,9 +24,8 @@ package org.duniter.elasticsearch; import com.google.common.collect.Lists; +import org.duniter.core.client.config.ConfigurationOption; import org.duniter.core.client.service.ServiceLocator; -import org.duniter.elasticsearch.config.Configuration; -import org.duniter.elasticsearch.config.ConfigurationOption; import org.apache.commons.io.FileUtils; import org.junit.runner.Description; import org.nuiton.i18n.I18n; @@ -99,12 +98,12 @@ public class TestResource extends org.duniter.core.test.TestResource { */ protected void initConfiguration(String configFilename) { String[] configArgs = getConfigArgs(); - Configuration config = new Configuration(configFilename, configArgs); - Configuration.setInstance(config); + //PluginSettings config = new PluginSettings(configFilename, configArgs); + //PluginSettings.setInstance(config); } protected void initI18n() throws IOException { - Configuration config = Configuration.instance(); + /*PluginSettings config ;//= PluginSettings.instance(); // --------------------------------------------------------------------// // init i18n @@ -129,7 +128,7 @@ public class TestResource extends org.duniter.core.test.TestResource { } I18n.init(new UserI18nInitializer( i18nDirectory, new DefaultI18nInitializer(getI18nBundleName())), - i18nLocale); + i18nLocale);*/ } protected String[] getConfigArgs() { diff --git a/duniter4j-elasticsearch/src/test/java/org/duniter/elasticsearch/service/RegistryRecordIndexerServiceTest.java b/duniter4j-elasticsearch/src/test/java/org/duniter/elasticsearch/service/RegistryRecordIndexerServiceTest.java index 223141eb..17e4ff0b 100644 --- a/duniter4j-elasticsearch/src/test/java/org/duniter/elasticsearch/service/RegistryRecordIndexerServiceTest.java +++ b/duniter4j-elasticsearch/src/test/java/org/duniter/elasticsearch/service/RegistryRecordIndexerServiceTest.java @@ -23,7 +23,7 @@ package org.duniter.elasticsearch.service; */ import org.duniter.elasticsearch.TestResource; -import org.duniter.elasticsearch.service.registry.RegistryRecordIndexerService; +import org.duniter.elasticsearch.service.registry.RecordRegistryService; import org.junit.Before; import org.junit.ClassRule; import org.junit.Test; @@ -41,11 +41,11 @@ public class RegistryRecordIndexerServiceTest { @ClassRule public static final TestResource resource = TestResource.create(); - private RegistryRecordIndexerService service; + private RecordRegistryService service; @Before public void setUp() throws Exception { - service = ServiceLocator.instance().getRegistryRecordIndexerService(); + //service = ServiceLocator.instance().getRegistryRecordIndexerService(); } @Test diff --git a/duniter4j-elasticsearch/src/test/java/org/duniter/elasticsearch/service/currency/BlockIndexerServiceTest.java b/duniter4j-elasticsearch/src/test/java/org/duniter/elasticsearch/service/blockchain/BlockIndexerServiceTest.java similarity index 94% rename from duniter4j-elasticsearch/src/test/java/org/duniter/elasticsearch/service/currency/BlockIndexerServiceTest.java rename to duniter4j-elasticsearch/src/test/java/org/duniter/elasticsearch/service/blockchain/BlockIndexerServiceTest.java index 247a7502..b9a03c41 100644 --- a/duniter4j-elasticsearch/src/test/java/org/duniter/elasticsearch/service/currency/BlockIndexerServiceTest.java +++ b/duniter4j-elasticsearch/src/test/java/org/duniter/elasticsearch/service/blockchain/BlockIndexerServiceTest.java @@ -1,4 +1,4 @@ -package org.duniter.elasticsearch.service.currency; +package org.duniter.elasticsearch.service.blockchain; /* * #%L @@ -28,7 +28,6 @@ import org.duniter.core.client.model.bma.BlockchainBlock; import org.duniter.core.client.model.local.Peer; import org.duniter.core.client.service.bma.BlockchainRemoteService; import org.duniter.elasticsearch.TestResource; -import org.duniter.elasticsearch.service.ServiceLocator; import org.junit.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,15 +41,15 @@ public class BlockIndexerServiceTest { @ClassRule public static final TestResource resource = TestResource.create(); - private BlockIndexerService service; + private BlockBlockchainService service; private BlockchainRemoteService blockchainRemoteService; private Configuration config; private Peer peer; @Before public void setUp() throws Exception { - service = ServiceLocator.instance().getBlockIndexerService(); - blockchainRemoteService = ServiceLocator.instance().getBlockchainRemoteService(); + //service = ServiceLocator.instance().getBlockIndexerService(); + //blockchainRemoteService = ServiceLocator.instance().getBlockchainRemoteService(); config = Configuration.instance(); peer = createTestPeer(); diff --git a/duniter4j-elasticsearch/src/test/resources/META-INF/services/org.duniter.core.beans.Bean b/duniter4j-elasticsearch/src/test/resources/META-INF/services/org.duniter.core.beans.Bean index e9859d08..72141109 100644 --- a/duniter4j-elasticsearch/src/test/resources/META-INF/services/org.duniter.core.beans.Bean +++ b/duniter4j-elasticsearch/src/test/resources/META-INF/services/org.duniter.core.beans.Bean @@ -10,4 +10,4 @@ org.duniter.core.client.service.local.CurrencyServiceImpl org.duniter.core.client.dao.mem.MemoryCurrencyDaoImpl org.duniter.core.client.dao.mem.MemoryPeerDaoImpl org.duniter.elasticsearch.service.ElasticSearchService -org.duniter.elasticsearch.service.registry.RegistryCurrencyIndexerService \ No newline at end of file +org.duniter.elasticsearch.service.registry.CurrencyRegistryService \ No newline at end of file diff --git a/pom.xml b/pom.xml index 4b70fadd..c5ca982a 100644 --- a/pom.xml +++ b/pom.xml @@ -20,10 +20,9 @@ <xerces.version>2.9.0</xerces.version> <xml-apis.version>2.0.2</xml-apis.version> <gson.version>2.2.2</gson.version> - <kalium.version>0.4.0</kalium.version> + <kalium.version>0.5.0</kalium.version> <scrypt.version>1.4.0</scrypt.version> - <!--<elasticsearch.version>2.2.0</elasticsearch.version>--> - <elasticsearch.version>2.3.1</elasticsearch.version> + <elasticsearch.version>2.3.3</elasticsearch.version> <jna.version>4.1.0</jna.version> <nuitonConfigVersion>3.0-rc-2</nuitonConfigVersion> @@ -376,7 +375,8 @@ <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> - <version>1.3</version> + <version>1.5.0</version> + </plugin> <plugin> -- GitLab