diff --git a/duniter4j-core-client/src/main/java/org/duniter/core/client/service/bma/BlockchainRemoteServiceImpl.java b/duniter4j-core-client/src/main/java/org/duniter/core/client/service/bma/BlockchainRemoteServiceImpl.java index 3375638ae93d223dc78d9a0823f0954ddbd815a5..3fd751cd93defc0231fa3588d7341c15ca44d93a 100644 --- a/duniter4j-core-client/src/main/java/org/duniter/core/client/service/bma/BlockchainRemoteServiceImpl.java +++ b/duniter4j-core-client/src/main/java/org/duniter/core/client/service/bma/BlockchainRemoteServiceImpl.java @@ -551,7 +551,7 @@ public class BlockchainRemoteServiceImpl extends BaseRemoteServiceImpl implement // add listener wsClientEndPoint.addMessageHandler(messageHandler); - } catch (URISyntaxException ex) { + } catch (URISyntaxException | ServiceConfigurationError ex) { throw new TechnicalException("could not create URI need for web socket on block: " + ex.getMessage()); } diff --git a/duniter4j-elasticsearch/pom.xml b/duniter4j-elasticsearch/pom.xml index d44be03569b767b168fc89b41705fff8c47622f7..4c340b7d786b4c4dafdc105088793ded90e9745f 100644 --- a/duniter4j-elasticsearch/pom.xml +++ b/duniter4j-elasticsearch/pom.xml @@ -24,16 +24,9 @@ </i18n.bundleCsvFile> <config.i18nBundleName>${i18n.bundleOutputName}</config.i18nBundleName> - <!--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> + <assembly.skip>false</assembly.skip> <cesium.download.url>https://github.com/duniter/cesium/releases/download/${cesium.version}/cesium-web-${cesium.version}.zip</cesium.download.url> </properties> @@ -70,7 +63,7 @@ <dependency> <groupId>org.elasticsearch</groupId> <artifactId>elasticsearch</artifactId> - <scope>compile</scope> + <scope>provided</scope> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> @@ -151,115 +144,138 @@ </execution> </executions> </plugin> - </plugins> - </build> - <profiles> - <profile> - <id>default-bundle</id> - <activation> - <property> - <name>performRelease</name> - <value>true</value> - </property> - </activation> - <build> - <defaultGoal>package</defaultGoal> - <plugins> - <plugin> - <artifactId>maven-dependency-plugin</artifactId> - <executions> - <execution> - <id>unpack-dependencies</id> - <goals> - <goal>unpack</goal> - </goals> - <phase>prepare-package</phase> - <configuration> - <artifactItems> - <artifactItem> - <groupId>org.elasticsearch.distribution.zip</groupId> - <artifactId>elasticsearch</artifactId> - <version>${elasticsearch.version}</version> - <type>zip</type> - </artifactItem> - </artifactItems> - <outputDirectory>${project.build.directory}/</outputDirectory> - <silent>true</silent> - </configuration> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-antrun-plugin</artifactId> - <executions> - <execution> - <id>download-attachment-mapper-plugin</id> - <phase>prepare-package</phase> - <goals> - <goal>run</goal> - </goals> - <configuration> - <target> - <!-- download file --> - <get src="https://download.elastic.co/elasticsearch/release/org/elasticsearch/plugin/mapper-attachments/${elasticsearch.version}/mapper-attachments-${elasticsearch.version}.zip" - dest="${project.build.directory}/mapper-attachments-${elasticsearch.version}.zip" - verbose="false" - usetimestamp="true"/> - <unzip src="${project.build.directory}/mapper-attachments-${elasticsearch.version}.zip" - dest="${project.build.directory}/elasticsearch-${elasticsearch.version}/plugins/mapper-attachments" - overwrite="true"> + <plugin> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <id>unpack-elasticsearch</id> + <goals> + <goal>unpack</goal> + </goals> + <phase>prepare-package</phase> + <configuration> + <artifactItems> + <artifactItem> + <groupId>org.elasticsearch.distribution.zip</groupId> + <artifactId>elasticsearch</artifactId> + <version>${elasticsearch.version}</version> + <type>zip</type> + </artifactItem> + </artifactItems> + <outputDirectory>${project.build.directory}/</outputDirectory> + <silent>true</silent> + <skip>${assembly.skip}</skip> + </configuration> + </execution> + <execution> + <id>unpack-mapper-attachments-plugin</id> + <goals> + <goal>unpack</goal> + </goals> + <phase>prepare-package</phase> + <configuration> + <artifactItems> + <artifactItem> + <groupId>org.elasticsearch.plugin</groupId> + <artifactId>mapper-attachments</artifactId> + <version>${elasticsearch.version}</version> + <type>zip</type> + </artifactItem> + </artifactItems> + <outputDirectory>${project.build.directory}/elasticsearch-${elasticsearch.version}/plugins/mapper-attachments</outputDirectory> + <silent>true</silent> + <skip>${assembly.skip}</skip> + </configuration> + </execution> + </executions> + </plugin> - </unzip> - </target> - </configuration> - </execution> - </executions> - </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-antrun-plugin</artifactId> + <dependencies> + <dependency> + <groupId>ant-contrib</groupId> + <artifactId>ant-contrib</artifactId> + <version>1.0b3</version> + <exclusions> + <exclusion> + <groupId>ant</groupId> + <artifactId>ant</artifactId> + </exclusion> + </exclusions> + </dependency> + </dependencies> + <executions> + <execution> + <id>download-cesium</id> + <phase>prepare-package</phase> + <goals> + <goal>run</goal> + </goals> + <configuration> + <target> - <plugin> - <artifactId>maven-assembly-plugin</artifactId> - <executions> - <execution> - <id>assembly-plugin</id> - <phase>package</phase> - <goals> - <goal>single</goal> - </goals> - <configuration> - <attach>true</attach> - <appendAssemblyId>false</appendAssemblyId> - <finalName>${bundlePrefix}</finalName> - <descriptors> - <descriptor> - ${basedir}/src/main/assembly/plugin.xml - </descriptor> - </descriptors> - </configuration> - </execution> - <execution> - <id>assembly-standalone</id> - <phase>package</phase> - <goals> - <goal>single</goal> - </goals> - <configuration> - <attach>true</attach> - <finalName>${bundlePrefix}</finalName> - <descriptors> - <descriptor> - ${basedir}/src/main/assembly/standalone.xml - </descriptor> - </descriptors> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> + <!-- download cesium --> + <get src="${cesium.download.url}" + dest="${project.build.directory}/cesium-web-${cesium.version}.zip" + verbose="false" + usetimestamp="true"/> + <unzip src="${project.build.directory}/cesium-web-${cesium.version}.zip" + dest="${project.build.directory}/elasticsearch-${elasticsearch.version}/plugins/${project.artifactId}/_site" + overwrite="true"> + </unzip> + </target> + <skip>${assembly.skip}</skip> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <executions> + <execution> + <id>assembly-plugin</id> + <phase>package</phase> + <goals> + <goal>single</goal> + </goals> + <configuration> + <attach>true</attach> + <appendAssemblyId>false</appendAssemblyId> + <finalName>${bundlePrefix}</finalName> + <descriptors> + <descriptor> + ${basedir}/src/main/assembly/plugin.xml + </descriptor> + </descriptors> + <skipAssembly>${assembly.skip}</skipAssembly> + </configuration> + </execution> + <execution> + <id>assembly-standalone</id> + <phase>package</phase> + <goals> + <goal>single</goal> + </goals> + <configuration> + <attach>true</attach> + <finalName>${bundlePrefix}</finalName> + <descriptors> + <descriptor> + ${basedir}/src/main/assembly/standalone.xml + </descriptor> + </descriptors> + <skipAssembly>${assembly.skip}</skipAssembly> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + <profiles> <!-- use this profile to run the main class --> <profile> <id>run</id> @@ -269,91 +285,6 @@ <build> <defaultGoal>integration-test</defaultGoal> <plugins> - <plugin> - <artifactId>maven-enforcer-plugin</artifactId> - <executions> - <execution> - <id>check-run</id> - <goals> - <goal>enforce</goal> - </goals> - <phase>initialize</phase> - <configuration> - <rules> - <requireProperty> - <property>maven.jar.main.class</property> - <message>Could not find the "maven.jar.main.class" - required property, use - -Dmaven.jar.main.class=your.main.class.fqn - </message> - </requireProperty> - </rules> - <ignoreCache>true</ignoreCache> - <failFast>true</failFast> - <fail>true</fail> - </configuration> - </execution> - </executions> - </plugin> - - <plugin> - <artifactId>maven-dependency-plugin</artifactId> - <executions> - <execution> - <id>unpack-elasticsearch</id> - <goals> - <goal>unpack</goal> - </goals> - <phase>initialize</phase> - <configuration> - <artifactItems> - <artifactItem> - <groupId>org.elasticsearch.distribution.zip</groupId> - <artifactId>elasticsearch</artifactId> - <version>${elasticsearch.version}</version> - <type>zip</type> - </artifactItem> - </artifactItems> - <outputDirectory>${project.build.directory}/</outputDirectory> - <silent>true</silent> - </configuration> - </execution> - <execution> - <id>unpack-mapper-attachments-plugin</id> - <goals> - <goal>unpack</goal> - </goals> - <phase>initialize</phase> - <configuration> - <artifactItems> - <artifactItem> - <groupId>org.elasticsearch.plugin</groupId> - <artifactId>mapper-attachments</artifactId> - <version>${elasticsearch.version}</version> - <type>zip</type> - </artifactItem> - </artifactItems> - <outputDirectory>${es.home}/plugins/mapper-attachments</outputDirectory> - <silent>true</silent> - </configuration> - </execution> - <execution> - <id>copy-dependencies</id> - <phase>initialize</phase> - <goals> - <goal>copy-dependencies</goal> - </goals> - <configuration> - <outputDirectory>${es.home}/plugins/${project.artifactId}</outputDirectory> - <excludeArtifactIds>jna,jackson-core,log4j,elasticsearch</excludeArtifactIds> - <overWriteSnapshots>true</overWriteSnapshots> - <silent>true</silent> - <includeScope>runtime</includeScope> - </configuration> - </execution> - </executions> - </plugin> - <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> @@ -372,57 +303,7 @@ </dependencies> <executions> <execution> - <id>install-elasticsearch-binaries</id> - <phase>generate-resources</phase> - <goals> - <goal>run</goal> - </goals> - <configuration> - <target> - <!-- Change execution right --> - <chmod perm="ug+x"> - <fileset dir="${es.home}"> - <include name="bin/elasticsearch"/> - <include name="bin/plugin"/> - </fileset> - </chmod> - <chmod perm="ug+rw"> - <fileset dir="${es.home}/lib"/> - </chmod> - - <!-- Override config files --> - <copy todir="${es.home}/config" - overwrite="true" - filtering="true"> - <fileset dir="${basedir}/src/main/assembly/config"> - </fileset> - </copy> - </target> - </configuration> - </execution> - <execution> - <id>download-cesium</id> - <phase>initialize</phase> - <goals> - <goal>run</goal> - </goals> - <configuration> - <target> - - <!-- download cesium --> - <get src="${cesium.download.url}" - dest="${project.build.directory}/cesium-web-${cesium.version}.zip" - verbose="false" - usetimestamp="true"/> - <unzip src="${project.build.directory}/cesium-web-${cesium.version}.zip" - dest="${duniter4j.plugin.directory}/_site" - overwrite="true"> - </unzip> - </target> - </configuration> - </execution> - <execution> - <id>install-duniter-plugin</id> + <id>install-duniter-plugin-jar</id> <phase>pre-integration-test</phase> <goals> <goal>run</goal> @@ -430,53 +311,23 @@ <configuration> <target> - <!-- Copy plugin main jar --> - <copy todir="${duniter4j.plugin.directory}"> - <fileset dir="${project.build.directory}"> - <include name="${project.artifactId}-${project.version}.${project.packaging}"/> - </fileset> - </copy> - - <!-- Copy descriptor file and security files --> - <copy todir="${duniter4j.plugin.directory}" - filtering="true"> - <fileset dir="${basedir}/src/main/filtered-resources"> - <include name="plugin-descriptor.properties"/> - <include name="plugin-security.policy"/> - </fileset> - </copy> - <!-- Copy main libs --> - <move todir="${es.home}/lib"> - <fileset dir="${duniter4j.plugin.directory}"> - <include name="tyrus-*.jar"/> - <include name="javax.websocket-api-*.jar"/> - </fileset> - </move> - - <!-- Remove redundant lib in duniter plugin --> - <ac:for param="file" xmlns:ac="antlib:net.sf.antcontrib"> - <path> - <fileset dir="${duniter4j.plugin.directory}"> - <include name="**/*.jar"/> - </fileset> - </path> - <sequential> - <local name="filename" /> - <basename property="filename" file="@{file}"/> - <ac:if> - <available file="${es.home}/lib/${filename}"/> - <then> - <!--echo message="Remove lib from plugin: ${filename}"/--> - <delete file="${duniter4j.plugin.directory}/${filename}"/> - </then> - </ac:if> - </sequential> - </ac:for> - <delete> - <fileset dir="${duniter4j.plugin.directory}"> - <include name="guava-*.jar"/> - </fileset> - </delete> + <ac:if xmlns:ac="antlib:net.sf.antcontrib"> + <istrue value="${assembly.skip}"/> + <then> + <copy todir="${run.es.home}/plugins/${project.artifactId}"> + <fileset dir="${project.build.directory}" includes="*.jar"> + </fileset> + </copy> + </then> + <else> + <!-- Unzip standalone zip--> + <unzip src="${project.build.directory}/${bundlePrefix}-standalone.zip" + dest="${project.build.directory}" + overwrite="true"> + </unzip> + <move file="${project.build.directory}/${bundlePrefix}" tofile="${run.es.home}"/> + </else> + </ac:if> </target> </configuration> @@ -487,16 +338,67 @@ <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> + <dependencies> + <dependency> + <groupId>org.elasticsearch</groupId> + <artifactId>elasticsearch</artifactId> + <version>${elasticsearch.version}</version> + </dependency> + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <version>${log4j.version}</version> + </dependency> + <dependency> + <groupId>javax.websocket</groupId> + <artifactId>javax.websocket-api</artifactId> + <version>1.1</version> + </dependency> + <dependency> + <groupId>org.glassfish.tyrus</groupId> + <artifactId>tyrus-client</artifactId> + <version>${tyrus.version}</version> + </dependency> + <dependency> + <groupId>org.glassfish.tyrus</groupId> + <artifactId>tyrus-container-grizzly-client</artifactId> + <version>${tyrus.version}</version> + </dependency> + <dependency> + <groupId>net.java.dev.jna</groupId> + <artifactId>jna</artifactId> + <version>${jna.version}</version> + </dependency> + <dependency> + <groupId>net.java.dev.jna</groupId> + <artifactId>jna-platform</artifactId> + <version>${jna.version}</version> + <exclusions> + <exclusion> + <groupId>net.java.dev.jna</groupId> + <artifactId>jna</artifactId> + </exclusion> + </exclusions> + </dependency> + </dependencies> <executions> <execution> <id>run</id> <goals> - <goal>exec</goal> + <goal>java</goal> </goals> <phase>integration-test</phase> <configuration> - <executable>${es.home}/bin/elasticsearch</executable> - <workingDirectory>${es.home}</workingDirectory> + <mainClass>org.elasticsearch.bootstrap.Elasticsearch</mainClass> + <arguments>start</arguments> + <includeProjectDependencies>false</includeProjectDependencies> + <includePluginDependencies>true</includePluginDependencies> + <systemProperties> + <systemProperty> + <key>es.path.home</key> + <value>${run.es.home}</value> + </systemProperty> + </systemProperties> </configuration> </execution> </executions> @@ -505,14 +407,7 @@ </build> <properties> - <exec.mainClass>${maven.jar.main.class}</exec.mainClass> - <exec.classpathScope>runtime</exec.classpathScope> - <duniter4j.log.file>${project.build.directory}/exec.log</duniter4j.log.file> - - <es.home>${project.build.directory}/elasticsearch-${elasticsearch.version}</es.home> - <duniter4j.basedir>${es.home}</duniter4j.basedir> - <duniter4j.plugin.directory>${es.home}/plugins/${project.artifactId}</duniter4j.plugin.directory> - <es.http.cors.allow-origin>*</es.http.cors.allow-origin> + <run.es.home>${project.build.directory}/es-run-home</run.es.home> </properties> </profile> </profiles> diff --git a/duniter4j-elasticsearch/src/main/assembly/config/elasticsearch.yml b/duniter4j-elasticsearch/src/main/assembly/config/elasticsearch.yml index e5f251769270bd1ea514ad19058dffa03117e57b..d3e9c8cc0e0ba7f687b0536afa7f2b576f6d70f1 100644 --- a/duniter4j-elasticsearch/src/main/assembly/config/elasticsearch.yml +++ b/duniter4j-elasticsearch/src/main/assembly/config/elasticsearch.yml @@ -58,7 +58,9 @@ cluster.name: duniter4j-elasticsearch # # http.port: 9200 -http.cors.enabled: false +http.cors.allow-origin: "/.*/" +http.cors.enabled: true + # # For more information, see the documentation at: # <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html> @@ -97,7 +99,6 @@ http.cors.enabled: false # # action.destructive_requires_name: true - security.manager.enabled: false diff --git a/duniter4j-elasticsearch/src/main/assembly/full/README.txt b/duniter4j-elasticsearch/src/main/assembly/full/README.txt deleted file mode 100644 index 2cb4d8c6f52b6f5314014647f35522eec151eea5..0000000000000000000000000000000000000000 --- a/duniter4j-elasticsearch/src/main/assembly/full/README.txt +++ /dev/null @@ -1,15 +0,0 @@ -Starting duniter4j-ElasticSearch --------------------------------- - -# under Linux - -./duniter4j-elasticsearch.sh - -# Sous windows - -duniter4j-elasticsearch.exe - -Help ----- - -duniter4j-elasticsearch.<sh|exe> --help diff --git a/duniter4j-elasticsearch/src/main/assembly/help.xml b/duniter4j-elasticsearch/src/main/assembly/help.xml deleted file mode 100644 index d9fbefa35e3e529105288284add5bfde598a81ca..0000000000000000000000000000000000000000 --- a/duniter4j-elasticsearch/src/main/assembly/help.xml +++ /dev/null @@ -1,52 +0,0 @@ -<!-- - #%L - Reef DB :: Quadrige2 Server Core - $Id:$ - $HeadURL:$ - %% - Copyright (C) 2014 - 2015 Ifremer - %% - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - 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 Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - #L% - --> -<assembly - xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd"> - <id>help</id> - <formats> - <format>zip</format> - </formats> - - <fileSets> - - <fileSet> - <directory>src/main/help</directory> - <outputDirectory/> - <includes> - <include>**/*</include> - </includes> - </fileSet> - - <fileSet> - <directory>src/main/assembly/min</directory> - <outputDirectory/> - <filtered>true</filtered> - <includes> - <include>version.appup</include> - </includes> - </fileSet> - - </fileSets> -</assembly> diff --git a/duniter4j-elasticsearch/src/main/assembly/i18n.xml b/duniter4j-elasticsearch/src/main/assembly/i18n.xml deleted file mode 100644 index 50fbbe7bc7211100d98c0c0b5ae3636a23ac19e0..0000000000000000000000000000000000000000 --- a/duniter4j-elasticsearch/src/main/assembly/i18n.xml +++ /dev/null @@ -1,53 +0,0 @@ -<!-- - #%L - Reef DB :: Quadrige2 Server Core - $Id:$ - $HeadURL:$ - %% - Copyright (C) 2014 - 2015 Ifremer - %% - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - 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 Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - #L% - --> -<assembly - xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd"> - <id>i18n</id> - <formats> - <format>zip</format> - </formats> - - <fileSets> - - <fileSet> - <directory>target/classes/META-INF</directory> - <outputDirectory/> - <includes> - <include>duniter4j-elasticsearch-i18n*.properties</include> - <include>duniter4j-elasticsearch-i18n*.csv</include> - </includes> - </fileSet> - - <fileSet> - <directory>src/main/assembly/min</directory> - <outputDirectory/> - <filtered>true</filtered> - <includes> - <include>version.appup</include> - </includes> - </fileSet> - - </fileSets> -</assembly> diff --git a/duniter4j-elasticsearch/src/main/assembly/min/README.txt b/duniter4j-elasticsearch/src/main/assembly/min/README.txt deleted file mode 100644 index b81a83da2cc459f0f3025e6c9d58ea2f23b451bc..0000000000000000000000000000000000000000 --- a/duniter4j-elasticsearch/src/main/assembly/min/README.txt +++ /dev/null @@ -1,12 +0,0 @@ - - README - - ${project.name} Help - - ------------------------------------ - -Start a ElastoicSearch node : - > duniter4j-elasticsearch.<bat|sh> --start - -To show help (list all options) : - > duniter4j-elasticsearch.<bat|sh> --help diff --git a/duniter4j-elasticsearch/src/main/assembly/min/version.appup b/duniter4j-elasticsearch/src/main/assembly/min/version.appup deleted file mode 100644 index f2ab45c3b0ef08a7742373cd3434573d500b3b22..0000000000000000000000000000000000000000 --- a/duniter4j-elasticsearch/src/main/assembly/min/version.appup +++ /dev/null @@ -1 +0,0 @@ -${project.version} \ No newline at end of file diff --git a/duniter4j-elasticsearch/src/main/assembly/standalone.xml b/duniter4j-elasticsearch/src/main/assembly/standalone.xml index 0f7420fd328dc08ec96baa76e5e347fcbf0f9379..7ad07ec1bd98813a96be85b91d7519e4190280e5 100644 --- a/duniter4j-elasticsearch/src/main/assembly/standalone.xml +++ b/duniter4j-elasticsearch/src/main/assembly/standalone.xml @@ -37,18 +37,20 @@ <directory>target/elasticsearch-${elasticsearch.version}</directory> <outputDirectory/> <excludes> + <exclude>bin/elasticsearch</exclude> + <exclude>bin/plugin</exclude> <exclude>config/elasticsearch.yml</exclude> <exclude>config/logging.yml</exclude> </excludes> </fileSet> - <fileSet> - <directory>target/elasticsearch-${elasticsearch.version}/config</directory> - <outputDirectory>config/old</outputDirectory> + <directory>target/elasticsearch-${elasticsearch.version}</directory> + <outputDirectory/> <includes> - <include>plugin-descriptor.properties</include> - <include>plugin-security.policy</include> + <include>bin/elasticsearch</include> + <include>bin/plugin</include> </includes> + <fileMode>0755</fileMode> </fileSet> <!-- default configuration file --> @@ -61,15 +63,6 @@ </includes> </fileSet> - <!-- mapper attachment plugin - <fileSet> - <directory>target/assembly</directory> - <outputDirectory>plugins</outputDirectory> - <includes> - <include>mapper-attachments-${elasticsearch.mapper-attachments.version}.zip</include> - </includes> - </fileSet>--> - <fileSet> <directory>target</directory> <outputDirectory>plugins/${project.artifactId}</outputDirectory> @@ -105,7 +98,25 @@ <exclude>net.java.dev.jna:jna</exclude> <exclude>com.fasterxml.jackson.core:jackson-core</exclude> <exclude>log4j:log4j</exclude> + <exclude>com.google.guava:guava</exclude> + <!-- lib to include in elasticsearch/libs/ --> + <exclude>javax.websocket:javax.websocket-api</exclude> + <exclude>org.glassfish.tyrus:tyrus-client</exclude> + <exclude>org.glassfish.tyrus:tyrus-container-grizzly-client</exclude> </excludes> + <fileMode>0555</fileMode> + </dependencySet> + + <dependencySet> + <outputDirectory>lib</outputDirectory> + <useProjectArtifact>true</useProjectArtifact> + <useTransitiveFiltering>true</useTransitiveFiltering> + <includes> + <include>javax.websocket:javax.websocket-api</include> + <include>org.glassfish.tyrus:tyrus-client</include> + <include>org.glassfish.tyrus:tyrus-container-grizzly-client</include> + </includes> + <fileMode>0555</fileMode> </dependencySet> </dependencySets> </assembly> diff --git a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/AbstractService.java b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/AbstractService.java index e167691c5b326650089ba6ea46f7a5a5c1e9b17b..3ffc3aae4aba7e3e5517839bad1df7a015c971da 100644 --- a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/AbstractService.java +++ b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/AbstractService.java @@ -65,7 +65,7 @@ import java.util.regex.Pattern; public abstract class AbstractService implements Bean { protected static final String JSON_STRING_PROPERTY_REGEX = "[,]?[\"\\s\\n\\r]*%s[\"]?[\\s\\n\\r]*:[\\s\\n\\r]*\"[^\"]+\""; - protected static final String REGEX_WORD_SEPARATOR = "[-\\t@# ]+"; + protected static final String REGEX_WORD_SEPARATOR = "[-\\t@# _]+"; protected static final String REGEX_SPACE = "[\\t\\n\\r ]+"; protected final ESLogger logger; diff --git a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/BlockchainService.java b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/BlockchainService.java index db71cb97dd6dfd042859c7d6001d11114a3f20b4..590d18a6061c8c261bdb2e63f8ed4204f6277ee2 100644 --- a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/BlockchainService.java +++ b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/BlockchainService.java @@ -86,6 +86,9 @@ public class BlockchainService extends AbstractService { private BlockchainRemoteService blockchainRemoteService; private RegistryService registryService; + private JsonAttributeParser blockNumberParser = new JsonAttributeParser("number"); + private JsonAttributeParser blockCurrencyParser = new JsonAttributeParser("currency"); + private Gson gson; @Inject @@ -105,6 +108,10 @@ public class BlockchainService extends AbstractService { public BlockchainService listenAndIndexNewBlock(Peer peer){ blockchainRemoteService.addNewBlockListener(peer, message -> { indexBlockAsJson(peer, message, true /*refresh*/, true /*wait*/); + + // Update the current block + indexCurrentBlockAsJson(message, false /*wait*/); + }); return this; } @@ -366,13 +373,13 @@ public class BlockchainService extends AbstractService { ObjectUtils.checkNotNull(json); ObjectUtils.checkArgument(json.length() > 0); - JsonAttributeParser blockNumberParser = new JsonAttributeParser("number"); - JsonAttributeParser blockCurrencyParser = new JsonAttributeParser("blockchain"); - String currencyName = blockCurrencyParser.getValueAsString(json); int number = blockNumberParser.getValueAsInt(json); logger.info(I18n.t("duniter4j.blockIndexerService.indexBlock", currencyName, peer, number)); + if (logger.isTraceEnabled()) { + logger.trace(json); + } // Preparing indexBlocksFromNode IndexRequestBuilder indexRequest = client.prepareIndex(currencyName, BLOCK_TYPE) @@ -406,23 +413,37 @@ public class BlockchainService extends AbstractService { indexCurrentBlockAsJson(currentBlock.getCurrency(), json, wait); } + /** + * + * @param currentBlockJson block as JSON + * @pram wait need to wait until block processed ? + */ + public void indexCurrentBlockAsJson(String json, boolean wait) { + ObjectUtils.checkNotNull(json); + ObjectUtils.checkArgument(json.length() > 0); + + String currencyName = blockCurrencyParser.getValueAsString(json); + + indexCurrentBlockAsJson(currencyName, json, wait); + } /** * * @param currencyName * @param currentBlockJson block as JSON * @pram wait need to wait until block processed ? */ - public void indexCurrentBlockAsJson(String currencyName, String currentBlockJson, boolean wait) { - ObjectUtils.checkNotNull(currentBlockJson); - ObjectUtils.checkArgument(currentBlockJson.length() > 0); + public void indexCurrentBlockAsJson(String currencyName, String json, boolean wait) { + ObjectUtils.checkNotNull(json); + ObjectUtils.checkArgument(json.length() > 0); + ObjectUtils.checkArgument(StringUtils.isNotBlank(currencyName)); // Preparing indexBlocksFromNode IndexRequestBuilder indexRequest = client.prepareIndex(currencyName, BLOCK_TYPE) .setId(CURRENT_BLOCK_ID) .setRefresh(true) - .setSource(currentBlockJson); + .setSource(json); - // Execute indexBlocksFromNode + // Execute in a pool if (!wait) { boolean acceptedInPool = false; while(!acceptedInPool) @@ -673,7 +694,6 @@ public class BlockchainService extends AbstractService { int batchSize = pluginSettings.getIndexBulkSize(); String currentBlockJson = null; - JsonAttributeParser blockNumberParser = new JsonAttributeParser("number"); for (int batchFirstNumber = firstNumber; batchFirstNumber < lastNumber; ) { // Check if stop (e.g. ask by user) diff --git a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/MarketService.java b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/MarketService.java index ba8653b4a5c276054f3ad9fe2952912b1baff821..67d50dd9f321fb030ced759b169d9b5fad3051ec 100644 --- a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/MarketService.java +++ b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/MarketService.java @@ -308,9 +308,16 @@ public class MarketService extends AbstractService { .field("index", "not_analyzed") .endObject() + // type (offer, need, ...) + .startObject("type") + .field("type", "string") + .field("index", "not_analyzed") + .endObject() + // location .startObject("location") .field("type", "string") + .field("analyzer", stringAnalyzer) .endObject() // geoPoint @@ -386,6 +393,7 @@ public class MarketService extends AbstractService { .endObject() .startObject("name") // author .field("type", "string") + .field("analyzer", stringAnalyzer) .endObject() .endObject() .endObject() diff --git a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/RegistryService.java b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/RegistryService.java index 0a448fb4e60e213dc3464444da666d09c73a19c9..a12c15b24e96d3093ac6b86236bbacfae2aa00a5 100644 --- a/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/RegistryService.java +++ b/duniter4j-elasticsearch/src/main/java/org/duniter/elasticsearch/service/RegistryService.java @@ -405,6 +405,7 @@ public class RegistryService extends AbstractService { // address .startObject("address") .field("type", "string") + .field("analyzer", stringAnalyzer) .endObject() // city @@ -475,16 +476,17 @@ public class RegistryService extends AbstractService { .field("type", "nested") .field("dynamic", "false") .startObject("properties") - .startObject("id") // author + .startObject("id") // id .field("type", "string") .field("index", "not_analyzed") .endObject() - .startObject("parent") // author + .startObject("parent") // parent .field("type", "string") .field("index", "not_analyzed") .endObject() - .startObject("name") // author + .startObject("name") // name .field("type", "string") + .field("analyzer", stringAnalyzer) .endObject() .endObject() .endObject() diff --git a/duniter4j-elasticsearch/src/main/resources/market-categories-bulk-insert.json b/duniter4j-elasticsearch/src/main/resources/market-categories-bulk-insert.json index 5f0e335eea072197f7972a52a7a01fed048456a1..c9527a96a6f1a8d350067029670a10b4c1f2de74 100644 --- a/duniter4j-elasticsearch/src/main/resources/market-categories-bulk-insert.json +++ b/duniter4j-elasticsearch/src/main/resources/market-categories-bulk-insert.json @@ -1,7 +1,7 @@ { "index": { "_id": "cat71"}} { "name": "Emploi" , "parent": null} { "index": { "_id": "cat33"}} -{ "name": "Offres d'emploi", "parent": "cat33" } +{ "name": "Offres d'emploi", "parent": "cat71" } { "index": { "_id": "cat1" }} { "name": "Véhicules" , "parent": null} diff --git a/duniter4j-elasticsearch/src/main/resources/registry-categories-bulk-insert.json b/duniter4j-elasticsearch/src/main/resources/registry-categories-bulk-insert.json index 10d5d9e963fa3520e09f4689c6d1e49c40772e96..3ee70de3d3aa58dfd3ff01f1a578a2f917508d66 100644 --- a/duniter4j-elasticsearch/src/main/resources/registry-categories-bulk-insert.json +++ b/duniter4j-elasticsearch/src/main/resources/registry-categories-bulk-insert.json @@ -1,7 +1,3 @@ -{"index": {"_id": "0"}} -{"name": "Autres", "parent": null} -{"index": {"_id": "particulier"}} -{"name": "Particulier", "parent": "0"} {"index": {"_id": "A"}} {"name": "Agriculture, sylviculture et pêche", "parent": null} {"index": {"_id": "01.11Z"}} diff --git a/pom.xml b/pom.xml index 6b88c74d771e04e85749c3d4b3602ea0d9f9f9c6..860efa1e625bec9d0c4c6173d051b9fcaefbc85f 100644 --- a/pom.xml +++ b/pom.xml @@ -25,6 +25,7 @@ <scrypt.version>1.4.0</scrypt.version> <elasticsearch.version>2.3.3</elasticsearch.version> <jna.version>4.1.0</jna.version> + <tyrus.version>1.12</tyrus.version> <cesium.version>0.1.26</cesium.version> @@ -350,6 +351,18 @@ <artifactId>jackson-databind</artifactId> <version>2.6.4</version> </dependency> + + <!-- WebSocket --> + <dependency> + <groupId>org.glassfish.tyrus</groupId> + <artifactId>tyrus-client</artifactId> + <version>${tyrus.version}</version> + </dependency> + <dependency> + <groupId>org.glassfish.tyrus</groupId> + <artifactId>tyrus-container-grizzly-client</artifactId> + <version>${tyrus.version}</version> + </dependency> </dependencies> </dependencyManagement>