From 24650d7c4415243b7a38174ea314811f7f6fc069 Mon Sep 17 00:00:00 2001 From: blavenie <benoit.lavenier@e-is.pro> Date: Wed, 20 Sep 2017 09:04:35 +0200 Subject: [PATCH] [fix] Prepare ES config & logging files for next release --- .../main/assembly/config/elasticsearch.yml | 80 ++++++++++--------- .../src/main/assembly/config/logging.yml | 1 + .../src/test/es-home/config/elasticsearch.yml | 50 +++++++----- .../src/test/es-home/config/logging.yml | 5 +- .../src/test/misc/test_es_query.sh | 22 +++++ .../duniter/elasticsearch/PluginSettings.java | 6 +- .../synchro/AbstractSynchroAction.java | 2 +- .../elasticsearch/synchro/SynchroService.java | 6 +- .../src/test/es-home/config/elasticsearch.yml | 4 +- .../src/test/es-home/config/elasticsearch.yml | 6 +- .../src/test/es-home/config/elasticsearch.yml | 10 +-- 11 files changed, 110 insertions(+), 82 deletions(-) diff --git a/duniter4j-es-assembly/src/main/assembly/config/elasticsearch.yml b/duniter4j-es-assembly/src/main/assembly/config/elasticsearch.yml index c3eddf43..f80034e2 100644 --- a/duniter4j-es-assembly/src/main/assembly/config/elasticsearch.yml +++ b/duniter4j-es-assembly/src/main/assembly/config/elasticsearch.yml @@ -14,7 +14,6 @@ # # Use a descriptive name for your cluster: # -# cluster.name: my-application cluster.name: duniter4j-es-g1 # # ------------------------------------ Node ------------------------------------ @@ -74,7 +73,7 @@ http.cors.enabled: true # The default list of hosts is ["127.0.0.1", "[::1]"] # # discovery.zen.ping.unicast.hosts: ["host1", "host2"] -#discovery.zen.ping.unicast.hosts: ["127.0.0.1", ""] +# discovery.zen.ping.unicast.hosts: ["127.0.0.1", ""] # # Prevent the "split brain" by configuring the majority of nodes (total number of nodes / 2 + 1): # @@ -101,17 +100,18 @@ http.cors.enabled: true # Require explicit names when deleting indices: # # rest.destructive_requires_name: true - +# +# Security to isolate plugin classpath - /!\ WARNING: should be DISABLE for Duniter4j +# security.manager.enabled: false - # # ---------------------------------- Duniter4j --------------------------------- # -# Disbale duniter4j plugin +# Enable duniter4j plugins # # duniter.enabled: false # -# Delete then create all indices at startup - DO NOT set to true in production +# Delete then create all indices at startup - /!\ WARNING: DO NOT set to true in production # # duniter.indices.reload: true # @@ -123,39 +123,47 @@ duniter.string.analyzer: french # duniter.blockchain.enable: true # -# Force blockchain reload - WARNING: all user events will be resetted to 'unread' +# Force blockchain full synchronization - /!\ WARNING: all user events will be reset to 'unread' # -#duniter.blockchain.reload: true -#duniter.blockchain.reload.from: 50999 +# duniter.blockchain.reload: true +# duniter.blockchain.reload.from: 50999 # # Duniter node address # duniter.host: g1.duniter.org duniter.port: 10901 -#duniter.useSsl: true +# duniter.useSsl: true # -# Should maintain stats on index rows count ? +# Compute statistics on indices (each hour) ? (default: true) # -#duniter.stats.enable: false - +# duniter.stats.enable: false # # ---------------------------------- Duniter4j security module ------------------- # -# Keyring for the ES node +# Keyring, use to sign emitted documents (user events, subscription, etc.). +# If not set, random keys will be generated. # -#duniter.keyring.salt: -#duniter.keyring.password: +# duniter.keyring.salt: +# duniter.keyring.password: # -# Enable security - will restrict HTTP access to only Duniter4j known indices +# Enable security - will restrict HTTP access to only Duniter4j known indices - /!\ WARNING: should be enable for production use # duniter.security.enable: true # -# ---------------------------------- Duniter4j P2P sync ------------------------- +# ---------------------------------- Duniter4j P2P module ------------------------- # -# Should synchronize data from an existing ES node ? +# Enable P2P synchronize between ES peers ? (default: true) +# +# duniter.p2p.enable: false +# +# Enable P2P websocket direct synchronisation ? (default: true) +# +# duniter.p2p.ws.enable: false +# +# Max peer time offset, in seconds (max peer's clock error) - use to request peer's data. (default: 3600 = 1hour) +# +# duniter.p2p.peerTimeOffset: 3600 # -#duniter.p2p.enable: false - # ---------------------------------- Duniter4j Mail module ----------------------- # # Enable mail module ? @@ -164,37 +172,37 @@ duniter.mail.enable: false # # Mail: SMTP server configuration (host and port) # -#duniter.mail.smtp.host: localhost -#duniter.mail.smtp.port: 25 +# duniter.mail.smtp.host: localhost +# duniter.mail.smtp.port: 25 # # Mail: SMTP server SSL security # -#duniter.mail.smtp.ssl: true -#duniter.mail.smtp.starttls: true +# duniter.mail.smtp.ssl: true +# duniter.mail.smtp.starttls: true # # Mail: SMTP server authentication # -#duniter.mail.smtp.username: -#duniter.mail.smtp.password: +# duniter.mail.smtp.username: +# duniter.mail.smtp.password: # # Mail: 'from' address # -#duniter.mail.from: no-reply@domain.com +# duniter.mail.from: no-reply@domain.com # # Mail: admin address # -#duniter.mail.admin: user@domain.com +# duniter.mail.admin: user@domain.com # # Mail: subject prefix # -#duniter.mail.subject.prefix: '[Cesium+]' +# duniter.mail.subject.prefix: '[Cesium+]' # ---------------------------------- Duniter4j Websocket server ---------------------- # -# Websocket port (usefull for listen changes) +# Websocket port (default: 9400-9410) # duniter.ws.port: 9400-9410 - +# # ---------------------------------- Duniter4j Subscription module ------------------- # # Enable subscription module (Need to enable mail features) @@ -203,12 +211,12 @@ duniter.subscription.enable: false # # Email subscription: Day of the week to trigger weekly (default: 2 = monday) # -#duniter.subscription.email.dayOfWeek: 2 +# duniter.subscription.email.dayOfWeek: 2 # # Email subscription: Hour in day to trigger daily email subscription (default: 3 AM) # -#duniter.subscription.email.hourOfDay: 3 +# duniter.subscription.email.hourOfDay: 3 # -# Email subscription: URL to a Cesium site (for link in the email content) +# Email subscription: URL to a Cesium site, for links in the email content (default: https://g1.duniter.fr) # -#duniter.subscription.email.cesium.url: 'http://domain.com/cesium' \ No newline at end of file +# duniter.subscription.email.cesium.url: 'http://domain.com/cesium' \ No newline at end of file diff --git a/duniter4j-es-assembly/src/main/assembly/config/logging.yml b/duniter4j-es-assembly/src/main/assembly/config/logging.yml index 2d99c771..37e26015 100644 --- a/duniter4j-es-assembly/src/main/assembly/config/logging.yml +++ b/duniter4j-es-assembly/src/main/assembly/config/logging.yml @@ -15,6 +15,7 @@ logger: com.amazonaws.metrics.AwsSdkMetrics: ERROR duniter: INFO + #duniter.p2p: TRACE security: INFO cluster.metadata: ERROR cluster.routing.allocation: ERROR diff --git a/duniter4j-es-assembly/src/test/es-home/config/elasticsearch.yml b/duniter4j-es-assembly/src/test/es-home/config/elasticsearch.yml index 097dfc2c..b42daea7 100644 --- a/duniter4j-es-assembly/src/test/es-home/config/elasticsearch.yml +++ b/duniter4j-es-assembly/src/test/es-home/config/elasticsearch.yml @@ -14,7 +14,6 @@ # # Use a descriptive name for your cluster: # -# cluster.name: my-application cluster.name: duniter4j-es-assembly-test # # ------------------------------------ Node ------------------------------------ @@ -101,19 +100,20 @@ http.cors.enabled: true # Require explicit names when deleting indices: # # rest.destructive_requires_name: true - +# +# Security to isolate plugin classpath - /!\ WARNING: should be DISABLE for Duniter4j +# security.manager.enabled: false - # # ---------------------------------- Duniter4j --------------------------------- # -# Disbale duniter4j plugin +# Enable duniter4j plugins # # duniter.enabled: false # -# Delete then create all indices at startup - DO NOT set to true in production +# Delete then create all indices at startup - /!\ WARNING: DO NOT set to true in production # -#duniter.indices.reload: true +# duniter.indices.reload: true # # Default string analyzer # @@ -123,30 +123,30 @@ duniter.string.analyzer: french # duniter.blockchain.enable: true # -# Force blockchain reload - WARNING: all user events will be resetted to 'unread' +# Force blockchain full synchronization - /!\ WARNING: all user events will be reset to 'unread' # -#duniter.blockchain.reload: true -#duniter.blockchain.reload.from: 50999 +# duniter.blockchain.reload: true +# duniter.blockchain.reload.from: 50999 # # Duniter node address # duniter.host: g1.duniter.org duniter.port: 10901 -#duniter.useSsl: true +# duniter.useSsl: true # -# Should maintain stats on index rows count ? +# Compute statistics on indices (each hour) ? (default: true) # -#duniter.stats.enable: false - +# duniter.stats.enable: false # # ---------------------------------- Duniter4j security module ------------------- # -# Keyring for the ES node +# Keyring, use to sign emitted documents (user events, subscription, etc.). +# If not set, random keys will be generated. # duniter.keyring.salt: 'abc' duniter.keyring.password: 'def' # -# Enable security - will restrict HTTP access to only Duniter4j known indices +# Enable security - will restrict HTTP access to only Duniter4j known indices - /!\ WARNING: should be enable for production use # duniter.security.enable: true # @@ -158,12 +158,20 @@ duniter.security.enable: true # # duniter.auth.tokenValidityDuration: 3600 # = 1hour -# ---------------------------------- Duniter4j P2P sync ------------------------- +# ---------------------------------- Duniter4j P2P module ------------------------- # -# Should synchronize data from an existing ES node ? +# Enable P2P synchronize between ES peers ? (default: true) +# +# duniter.p2p.enable: false +# +# Enable P2P websocket direct synchronisation ? (default: true) +# +# duniter.p2p.ws.enable: false +# +# Max peer time offset, in seconds (max peer's clock error) - use to request peer's data. (default: 3600 = 1hour) +# +# duniter.p2p.peerTimeOffset: 3600 # -#duniter.p2p.enable: false - # ---------------------------------- Duniter4j Mail module ----------------------- # # Enable mail module ? @@ -199,10 +207,10 @@ duniter.mail.enable: false # ---------------------------------- Duniter4j Websocket server ---------------------- # -# Websocket port (usefull for listen changes) +# Websocket port (default: 9400-9410) # duniter.ws.port: 9400-9410 - +# # ---------------------------------- Duniter4j Subscription module ------------------- # # Enable subscription module (Need to enable mail features) diff --git a/duniter4j-es-assembly/src/test/es-home/config/logging.yml b/duniter4j-es-assembly/src/test/es-home/config/logging.yml index 156875ec..9963d24c 100644 --- a/duniter4j-es-assembly/src/test/es-home/config/logging.yml +++ b/duniter4j-es-assembly/src/test/es-home/config/logging.yml @@ -14,7 +14,7 @@ logger: com.amazonaws.jmx.SdkMBeanRegistrySupport: ERROR com.amazonaws.metrics.AwsSdkMetrics: ERROR - duniter: INFO + duniter: DEBUG #duniter.core: DEBUG #duniter.security: ERROR #duniter.user.event: DEBUG @@ -22,12 +22,13 @@ logger: #duniter.network.peer: DEBUG #duniter.mail: DEBUG #duniter.subscription: DEBUG + #duniter.p2p: TRACE security: DEBUG cluster.metadata: ERROR cluster.routing.allocation: ERROR - org.duniter: INFO + org.duniter: DEBUG #org.duniter.core.util.LockManager: DEBUG #org.duniter.core.beans: DEBUG #org.duniter.core.client.service: DEBUG diff --git a/duniter4j-es-assembly/src/test/misc/test_es_query.sh b/duniter4j-es-assembly/src/test/misc/test_es_query.sh index 2151fb3c..66d191e0 100755 --- a/duniter4j-es-assembly/src/test/misc/test_es_query.sh +++ b/duniter4j-es-assembly/src/test/misc/test_es_query.sh @@ -48,3 +48,25 @@ curl -XPOST 'http://localhost:9200/g1/block/_search?pretty' -d ' } } }' + +curl -XPOST 'http://localhost:9200/g1/peer/_search?pretty' -d ' +{ + "size" : 1000, + "query" : { + "constant_score" : { + "filter" : { + "bool" : { + "must" : [ { + "bool" : { + "must" : { + "term" : { + "api" : "ES_USER_API" + } + } + } + }] + } + } + } + } +}' \ No newline at end of file diff --git a/duniter4j-es-core/src/main/java/org/duniter/elasticsearch/PluginSettings.java b/duniter4j-es-core/src/main/java/org/duniter/elasticsearch/PluginSettings.java index 813ca522..38137b45 100644 --- a/duniter4j-es-core/src/main/java/org/duniter/elasticsearch/PluginSettings.java +++ b/duniter4j-es-core/src/main/java/org/duniter/elasticsearch/PluginSettings.java @@ -219,15 +219,15 @@ public class PluginSettings extends AbstractLifecycleComponent<PluginSettings> { } public boolean enableSynchro() { - return settings.getAsBoolean("duniter.synchro.enable", true); + return settings.getAsBoolean("duniter.p2p.enable", true); } public boolean enableSynchroWebsocket() { - return settings.getAsBoolean("duniter.synchro.ws.enable", true); + return settings.getAsBoolean("duniter.p2p.ws.enable", true); } public int getSynchroTimeOffset() { - return settings.getAsInt("duniter.synchro.timeOffset", 60*60/*=1hour*/); + return settings.getAsInt("duniter.p2p.peerTimeOffset", 60*60/*=1hour*/); } diff --git a/duniter4j-es-core/src/main/java/org/duniter/elasticsearch/synchro/AbstractSynchroAction.java b/duniter4j-es-core/src/main/java/org/duniter/elasticsearch/synchro/AbstractSynchroAction.java index 7a0412fe..a0563444 100644 --- a/duniter4j-es-core/src/main/java/org/duniter/elasticsearch/synchro/AbstractSynchroAction.java +++ b/duniter4j-es-core/src/main/java/org/duniter/elasticsearch/synchro/AbstractSynchroAction.java @@ -87,7 +87,7 @@ public abstract class AbstractSynchroAction extends AbstractService implements S PluginSettings pluginSettings, CryptoService cryptoService, ThreadPool threadPool) { - super("duniter.synchro." + toIndex, client, pluginSettings, cryptoService); + super("duniter.p2p." + toIndex, client, pluginSettings, cryptoService); this.fromIndex = fromIndex; this.fromType = fromType; this.toIndex = toIndex; diff --git a/duniter4j-es-core/src/main/java/org/duniter/elasticsearch/synchro/SynchroService.java b/duniter4j-es-core/src/main/java/org/duniter/elasticsearch/synchro/SynchroService.java index 0f055206..f50e8626 100644 --- a/duniter4j-es-core/src/main/java/org/duniter/elasticsearch/synchro/SynchroService.java +++ b/duniter4j-es-core/src/main/java/org/duniter/elasticsearch/synchro/SynchroService.java @@ -81,7 +81,7 @@ public class SynchroService extends AbstractService { PeerDao peerDao, SynchroExecutionDao synchroExecutionDao, final ServiceLocator serviceLocator) { - super("duniter.synchro", client, settings, cryptoService); + super("duniter.p2p", client, settings, cryptoService); this.threadPool = threadPool; this.currencyDao = currencyDao; this.peerDao = peerDao; @@ -171,7 +171,7 @@ public class SynchroService extends AbstractService { } } - public SynchroResult synchronizePeer(final Peer peer, boolean listenChanges) { + public SynchroResult synchronizePeer(final Peer peer, boolean enableSynchroWebsocket) { long now = System.currentTimeMillis(); SynchroResult result = new SynchroResult(); @@ -201,7 +201,7 @@ public class SynchroService extends AbstractService { saveExecution(peer, result); // Start listen changes on this peer - if (listenChanges) { + if (enableSynchroWebsocket) { startListenChangesOnPeer(peer, executedActions); } diff --git a/duniter4j-es-core/src/test/es-home/config/elasticsearch.yml b/duniter4j-es-core/src/test/es-home/config/elasticsearch.yml index 0274bb7d..e79deaae 100644 --- a/duniter4j-es-core/src/test/es-home/config/elasticsearch.yml +++ b/duniter4j-es-core/src/test/es-home/config/elasticsearch.yml @@ -149,9 +149,7 @@ duniter.security.enable: false # # Should synchronizePeer data using P2P # -duniter.data.sync.enable: false -#duniter.data.sync.host: data.duniter.fr -#duniter.data.sync.port: 80 +duniter.p2p.enable: false # ---------------------------------- Duniter4j SMTP server ------------------------- # diff --git a/duniter4j-es-subscription/src/test/es-home/config/elasticsearch.yml b/duniter4j-es-subscription/src/test/es-home/config/elasticsearch.yml index bb407837..8bec1e82 100644 --- a/duniter4j-es-subscription/src/test/es-home/config/elasticsearch.yml +++ b/duniter4j-es-subscription/src/test/es-home/config/elasticsearch.yml @@ -149,10 +149,8 @@ duniter.security.enable: false # # Should synchronize data using P2P # -duniter.data.sync.enable: false -#duniter.data.sync.host: data.duniter.fr -#duniter.data.sync.port: 80 - +duniter.p2p.enable: false +# # ---------------------------------- Duniter4j SMTP server ---------------------- # # SMTP server configuration (host and port) diff --git a/duniter4j-es-user/src/test/es-home/config/elasticsearch.yml b/duniter4j-es-user/src/test/es-home/config/elasticsearch.yml index 377ed516..543cdedf 100644 --- a/duniter4j-es-user/src/test/es-home/config/elasticsearch.yml +++ b/duniter4j-es-user/src/test/es-home/config/elasticsearch.yml @@ -158,15 +158,7 @@ duniter.security.enable: true # # Should synchronize data from an existing ES node ? # -duniter.data.sync.enable: true -#duniter.data.sync.enable: true -duniter.data.sync.host: localhost -duniter.data.sync.port: 9200 - -# -# Should maintain stats on data ? -# -duniter.data.stats.enable: true +duniter.p2p.enable: false # ---------------------------------- Duniter4j Mail module ----------------------- # -- GitLab