polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From paulmer...@apache.org
Subject [01/35] zest-java git commit: ZEST-177 Upgrade to ElasticSearch 5
Date Sat, 19 Nov 2016 22:50:02 GMT
Repository: zest-java
Updated Branches:
  refs/heads/develop 2bdc64f25 -> 0cd5a1508


ZEST-177 Upgrade to ElasticSearch 5


Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/19777d0f
Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/19777d0f
Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/19777d0f

Branch: refs/heads/develop
Commit: 19777d0ff5b74a548833164ccb002a7f87419118
Parents: 2bdc64f
Author: Paul Merlin <paulmerlin@apache.org>
Authored: Fri Nov 11 16:20:05 2016 +0100
Committer: Paul Merlin <paulmerlin@apache.org>
Committed: Fri Nov 11 16:24:49 2016 +0100

----------------------------------------------------------------------
 .../elasticsearch/cluster/ESClusterSupport.java | 37 +++++-----
 .../filesystem/ESFilesystemSupport.java         | 49 ++++++------
 .../internal/AbstractElasticSearchSupport.java  | 78 ++++++++++++--------
 .../elasticsearch/DocumentationSupport.java     |  3 -
 .../ElasticSearchComplexQueryTest.java          | 18 ++---
 .../elasticsearch/ElasticSearchFinderTest.java  | 21 ++----
 .../ElasticSearchQueryMultimoduleTest.java      | 36 +++++----
 .../elasticsearch/ElasticSearchQueryTest.java   | 48 +++++++-----
 .../index/elasticsearch/ElasticSearchTest.java  | 68 ++++++++++-------
 .../index/elasticsearch/ImmenseTermTest.java    | 17 ++---
 libraries.gradle                                | 10 ++-
 11 files changed, 211 insertions(+), 174 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zest-java/blob/19777d0f/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/cluster/ESClusterSupport.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/cluster/ESClusterSupport.java
b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/cluster/ESClusterSupport.java
index a49354e..20d2182 100644
--- a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/cluster/ESClusterSupport.java
+++ b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/cluster/ESClusterSupport.java
@@ -26,19 +26,19 @@ import org.apache.zest.api.configuration.Configuration;
 import org.apache.zest.api.injection.scope.This;
 import org.apache.zest.index.elasticsearch.ElasticSearchClusterConfiguration;
 import org.apache.zest.index.elasticsearch.internal.AbstractElasticSearchSupport;
+import org.elasticsearch.transport.client.PreBuiltTransportClient;
 
 import java.net.InetSocketAddress;
 
 public class ESClusterSupport
-        extends AbstractElasticSearchSupport
+    extends AbstractElasticSearchSupport
 {
-
     @This
     private Configuration<ElasticSearchClusterConfiguration> configuration;
 
     @Override
     protected void activateElasticSearch()
-            throws Exception
+        throws Exception
     {
         configuration.refresh();
         ElasticSearchClusterConfiguration config = configuration.get();
@@ -47,28 +47,31 @@ public class ESClusterSupport
         index = config.index().get() == null ? DEFAULT_INDEX_NAME : config.index().get();
         indexNonAggregatedAssociations = config.indexNonAggregatedAssociations().get();
 
-        String[] nodes = config.nodes().get() == null ? new String[]{ "localhost:9300" }
: config.nodes().get().split( "," );
+        String[] nodes = config.nodes().get() == null
+                         ? new String[] { "localhost:9300" }
+                         : config.nodes().get().split( "," );
         boolean clusterSniff = config.clusterSniff().get();
         boolean ignoreClusterName = config.ignoreClusterName().get();
         String pingTimeout = config.pingTimeout().get() == null ? "5s" : config.pingTimeout().get();
         String samplerInterval = config.samplerInterval().get() == null ? "5s" : config.samplerInterval().get();
 
-        Settings settings = Settings.settingsBuilder().
-                put( "cluster.name", clusterName ).
-                put( "client.transport.sniff", clusterSniff ).
-                put( "client.transport.ignore_cluster_name", ignoreClusterName ).
-                put( "client.transport.ping_timeout", pingTimeout ).
-                put( "client.transport.nodes_sampler_interval", samplerInterval ).
-                build();
-        TransportClient transportClient = TransportClient.builder().settings(settings).build();
-        for ( String node : nodes ) {
+        Settings settings = Settings.builder()
+                                    .put( "cluster.name", clusterName )
+                                    .put( "client.transport.sniff", clusterSniff )
+                                    .put( "client.transport.ignore_cluster_name", ignoreClusterName
)
+                                    .put( "client.transport.ping_timeout", pingTimeout )
+                                    .put( "client.transport.nodes_sampler_interval", samplerInterval
)
+                                    .build();
+        TransportClient transportClient = new PreBuiltTransportClient( settings );
+        for( String node : nodes )
+        {
             String[] split = node.split( ":" );
-            String host = split[0];
-            int port = Integer.valueOf( split[1] );
-            transportClient.addTransportAddress( new InetSocketTransportAddress( new InetSocketAddress(
host, port ) ) );
+            String host = split[ 0 ];
+            int port = Integer.valueOf( split[ 1 ] );
+            InetSocketAddress socketAddress = new InetSocketAddress( host, port );
+            transportClient.addTransportAddress( new InetSocketTransportAddress( socketAddress
) );
         }
 
         client = transportClient;
     }
-
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/19777d0f/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/filesystem/ESFilesystemSupport.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/filesystem/ESFilesystemSupport.java
b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/filesystem/ESFilesystemSupport.java
index 4e2d601..aa61dae 100644
--- a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/filesystem/ESFilesystemSupport.java
+++ b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/filesystem/ESFilesystemSupport.java
@@ -20,22 +20,21 @@
 package org.apache.zest.index.elasticsearch.filesystem;
 
 import java.io.File;
-import org.apache.zest.api.identity.Identity;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.node.Node;
-import org.elasticsearch.node.NodeBuilder;
+import java.util.stream.Stream;
 import org.apache.zest.api.configuration.Configuration;
 import org.apache.zest.api.identity.HasIdentity;
+import org.apache.zest.api.identity.Identity;
 import org.apache.zest.api.injection.scope.Service;
 import org.apache.zest.api.injection.scope.This;
 import org.apache.zest.index.elasticsearch.ElasticSearchConfiguration;
 import org.apache.zest.index.elasticsearch.internal.AbstractElasticSearchSupport;
 import org.apache.zest.library.fileconfig.FileConfiguration;
+import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.node.Node;
 
 public class ESFilesystemSupport
-        extends AbstractElasticSearchSupport
+    extends AbstractElasticSearchSupport
 {
-
     @This
     private Configuration<ElasticSearchConfiguration> configuration;
 
@@ -49,7 +48,7 @@ public class ESFilesystemSupport
 
     @Override
     protected void activateElasticSearch()
-            throws Exception
+        throws Exception
     {
         configuration.refresh();
         ElasticSearchConfiguration config = configuration.get();
@@ -59,32 +58,30 @@ public class ESFilesystemSupport
         indexNonAggregatedAssociations = config.indexNonAggregatedAssociations().get();
 
         Identity identity = hasIdentity.identity().get();
-        Settings settings = Settings.settingsBuilder().
-                put( "path.work", new File( new File( fileConfig.temporaryDirectory(), identity.toString()
), "work" ).getAbsolutePath() ).
-                put( "path.home", new File( new File( fileConfig.temporaryDirectory(), identity.toString()
), "home" ).getAbsolutePath() ).
-                put( "path.logs", new File( fileConfig.logDirectory(), identity.toString()
).getAbsolutePath() ).
-                put( "path.data", new File( fileConfig.dataDirectory(), identity.toString()
).getAbsolutePath() ).
-                put( "path.conf", new File( fileConfig.configurationDirectory(), identity.toString()
).getAbsolutePath() ).
-                put( "http.enabled", false ).
-                put( "index.cache.type", "weak" ).
-                put( "index.number_of_shards", 1 ).
-                put( "index.number_of_replicas", 0 ).
-                put( "index.refresh_interval", -1 ). // Controlled by ElasticSearchIndexer
-                build();
-        node = NodeBuilder.nodeBuilder().
-                clusterName( clusterName ).
-                settings( settings ).
-                local( true ).
-                node();
+        File homeDir = new File( new File( fileConfig.temporaryDirectory(), identity.toString()
), "home" );
+        File logsDir = new File( fileConfig.logDirectory(), identity.toString() );
+        File dataDir = new File( fileConfig.dataDirectory(), identity.toString() );
+        File confDir = new File( fileConfig.configurationDirectory(), identity.toString()
);
+        Stream.of( homeDir, logsDir, dataDir, confDir ).forEach( File::mkdirs );
+        Settings settings = Settings.builder()
+                                    .put( "cluster.name", clusterName )
+                                    .put( "path.home", homeDir.getAbsolutePath() )
+                                    .put( "path.logs", logsDir.getAbsolutePath() )
+                                    .put( "path.data", dataDir.getAbsolutePath() )
+                                    .put( "path.conf", confDir.getAbsolutePath() )
+                                    .put( "transport.type", "local" )
+                                    .put( "http.enabled", false )
+                                    .build();
+        node = new Node( settings );
+        node.start();
         client = node.client();
     }
 
     @Override
     public void passivateElasticSearch()
-            throws Exception
+        throws Exception
     {
         node.close();
         node = null;
     }
-
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/19777d0f/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/internal/AbstractElasticSearchSupport.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/internal/AbstractElasticSearchSupport.java
b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/internal/AbstractElasticSearchSupport.java
index 53cde85..569127b 100644
--- a/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/internal/AbstractElasticSearchSupport.java
+++ b/extensions/indexing-elasticsearch/src/main/java/org/apache/zest/index/elasticsearch/internal/AbstractElasticSearchSupport.java
@@ -21,59 +21,76 @@ package org.apache.zest.index.elasticsearch.internal;
 
 import org.elasticsearch.client.Client;
 import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.common.xcontent.XContentBuilder;
 import org.elasticsearch.common.xcontent.XContentFactory;
 import org.apache.zest.index.elasticsearch.ElasticSearchSupport;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public abstract class AbstractElasticSearchSupport
-        implements ElasticSearchSupport
+    implements ElasticSearchSupport
 {
-
     protected static final Logger LOGGER = LoggerFactory.getLogger( ElasticSearchSupport.class
);
-
     protected static final String DEFAULT_CLUSTER_NAME = "zest_cluster";
-
     protected static final String DEFAULT_INDEX_NAME = "zest_index";
-
     protected static final String ENTITIES_TYPE = "zest_entities";
 
     protected Client client;
-
     protected String index;
-
     protected boolean indexNonAggregatedAssociations;
 
     @Override
     public final void activateService()
-            throws Exception
+        throws Exception
     {
         activateElasticSearch();
 
         // Wait for yellow status: the primary shard is allocated but replicas may not be
yet
         client.admin().cluster().prepareHealth().setWaitForYellowStatus().execute().actionGet();
 
-        if ( !client.admin().indices().prepareExists( index ).setIndices( index ).execute().actionGet().isExists()
) {
+        if( !client.admin().indices().prepareExists( index ).setIndices( index ).execute().actionGet().isExists()
)
+        {
             // Create empty index
             LOGGER.info( "Will create '{}' index as it does not exists.", index );
-            Settings.Builder indexSettings = Settings.settingsBuilder().loadFromSource( XContentFactory.jsonBuilder().
-                    startObject().
-                    startObject( "analysis" ).
-                    startObject( "analyzer" ).
-                    //
-                    startObject( "default" ).
-                    field( "type", "keyword" ). // Globally disable analysis, content is
treated as a single keyword
-                    endObject().
-                    //
-                    endObject().
-                    endObject().
-                    endObject().
-                    string() );
-            client.admin().indices().prepareCreate( index ).
-                    setIndex( index ).
-                    setSettings( indexSettings ).
-                    execute().
-                    actionGet();
+            Settings.Builder indexSettings = Settings.builder().loadFromSource(
+                XContentFactory.jsonBuilder()
+                               .startObject()
+                                   .field( "refresh_interval", -1 )
+                                   .startObject( "mapper" )
+                                       .field( "dynamic", false )
+                                   .endObject()
+                                   .startObject( "analysis" )
+                                       .startObject( "analyzer" )
+                                           .startObject( "default" )
+                                               .field( "type", "keyword" )
+                                           .endObject()
+                                           .endObject()
+                                   .endObject()
+                               .endObject()
+                               .string() );
+            XContentBuilder mapping = XContentFactory.jsonBuilder()
+                                                     .startObject()
+                                                         .startObject( entitiesType() )
+                                                             .startArray( "dynamic_templates"
)
+                                                                 .startObject()
+                                                                     .startObject( entitiesType()
)
+                                                                         .field( "match",
"*" )
+                                                                         .field( "match_mapping_type",
"string" )
+                                                                         .startObject( "mapping"
)
+                                                                             .field( "type",
"string" )
+                                                                             .field( "index",
"not_analyzed" )
+                                                                         .endObject()
+                                                                     .endObject()
+                                                                 .endObject()
+                                                             .endArray()
+                                                         .endObject()
+                                                     .endObject();
+            client.admin().indices().prepareCreate( index )
+                  .setIndex( index )
+                  .setSettings( indexSettings )
+                  .addMapping( entitiesType(), mapping )
+                  .execute()
+                  .actionGet();
             LOGGER.info( "Index '{}' created.", index );
         }
 
@@ -87,11 +104,11 @@ public abstract class AbstractElasticSearchSupport
     }
 
     protected abstract void activateElasticSearch()
-            throws Exception;
+        throws Exception;
 
     @Override
     public final void passivateService()
-            throws Exception
+        throws Exception
     {
         client.close();
         client = null;
@@ -101,7 +118,7 @@ public abstract class AbstractElasticSearchSupport
     }
 
     protected void passivateElasticSearch()
-            throws Exception
+        throws Exception
     {
         // NOOP
     }
@@ -129,5 +146,4 @@ public abstract class AbstractElasticSearchSupport
     {
         return indexNonAggregatedAssociations;
     }
-
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/19777d0f/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/DocumentationSupport.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/DocumentationSupport.java
b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/DocumentationSupport.java
index b25b648..c76e22e 100644
--- a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/DocumentationSupport.java
+++ b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/DocumentationSupport.java
@@ -29,7 +29,6 @@ import org.apache.zest.index.elasticsearch.assembly.ESFilesystemIndexQueryAssemb
 public class DocumentationSupport
     implements Assembler
 {
-
     @Override
     public void assemble( ModuleAssembly module )
         throws AssemblyException
@@ -44,7 +43,5 @@ public class DocumentationSupport
         // START SNIPPET: cluster
         new ESClusterIndexQueryAssembler().withConfig( configModule, configVisibility ).assemble(
module );
         // END SNIPPET: cluster
-
     }
-
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/19777d0f/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchComplexQueryTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchComplexQueryTest.java
b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchComplexQueryTest.java
index 79ba3bb..d1b55e9 100644
--- a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchComplexQueryTest.java
+++ b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchComplexQueryTest.java
@@ -14,8 +14,6 @@
  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
- *
- *
  */
 package org.apache.zest.index.elasticsearch;
 
@@ -39,7 +37,6 @@ import static org.apache.zest.test.util.Assume.assumeNoIbmJdk;
 public class ElasticSearchComplexQueryTest
     extends AbstractComplexQueryTest
 {
-
     private static final File DATA_DIR = new File( "build/tmp/es-complex-query-test" );
     @Rule
     public final DelTreeAfter delTreeAfter = new DelTreeAfter( DATA_DIR );
@@ -61,17 +58,17 @@ public class ElasticSearchComplexQueryTest
         new EntityTestAssembler().assemble( config );
 
         // Index/Query
-        new ESFilesystemIndexQueryAssembler().
-            withConfig( config, Visibility.layer ).
-            assemble( module );
+        new ESFilesystemIndexQueryAssembler()
+            .withConfig( config, Visibility.layer )
+            .assemble( module );
         ElasticSearchConfiguration esConfig = config.forMixin( ElasticSearchConfiguration.class
).declareDefaults();
         esConfig.indexNonAggregatedAssociations().set( Boolean.TRUE );
 
         // FileConfig
-        FileConfigurationOverride override = new FileConfigurationOverride().
-            withData( new File( DATA_DIR, "zest-data" ) ).
-            withLog( new File( DATA_DIR, "zest-logs" ) ).
-            withTemporary( new File( DATA_DIR, "zest-temp" ) );
+        FileConfigurationOverride override = new FileConfigurationOverride()
+            .withData( new File( DATA_DIR, "zest-data" ) )
+            .withLog( new File( DATA_DIR, "zest-logs" ) )
+            .withTemporary( new File( DATA_DIR, "zest-temp" ) );
         module.services( FileConfigurationService.class ).setMetaInfo( override );
     }
 
@@ -80,5 +77,4 @@ public class ElasticSearchComplexQueryTest
     {
         // IndexExporter not supported by ElasticSearch
     }
-
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/19777d0f/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchFinderTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchFinderTest.java
b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchFinderTest.java
index 3df6e19..d990a7a 100644
--- a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchFinderTest.java
+++ b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchFinderTest.java
@@ -14,10 +14,7 @@
  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
- *
- *
  */
-
 package org.apache.zest.index.elasticsearch;
 
 import java.io.File;
@@ -59,19 +56,18 @@ public class ElasticSearchFinderTest
         new EntityTestAssembler().assemble( config );
 
         // Index/Query
-        new ESFilesystemIndexQueryAssembler().
-            withConfig( config, Visibility.layer ).
-            assemble( module );
+        new ESFilesystemIndexQueryAssembler()
+            .withConfig( config, Visibility.layer )
+            .assemble( module );
         ElasticSearchConfiguration esConfig = config.forMixin( ElasticSearchConfiguration.class
).declareDefaults();
         esConfig.indexNonAggregatedAssociations().set( Boolean.TRUE );
 
         // FileConfig
-        FileConfigurationOverride override = new FileConfigurationOverride().
-            withData( new File( DATA_DIR, "zest-data" ) ).
-            withLog( new File( DATA_DIR, "zest-logs" ) ).
-            withTemporary( new File( DATA_DIR, "zest-temp" ) );
-        module.services( FileConfigurationService.class ).
-            setMetaInfo( override );
+        FileConfigurationOverride override = new FileConfigurationOverride()
+            .withData( new File( DATA_DIR, "zest-data" ) )
+            .withLog( new File( DATA_DIR, "zest-logs" ) )
+            .withTemporary( new File( DATA_DIR, "zest-temp" ) );
+        module.services( FileConfigurationService.class ).setMetaInfo( override );
     }
 
     @Override
@@ -79,5 +75,4 @@ public class ElasticSearchFinderTest
     {
         // IndexExporter not supported by ElasticSearch
     }
-
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/19777d0f/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryMultimoduleTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryMultimoduleTest.java
b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryMultimoduleTest.java
index 4446f37..240f0ee 100644
--- a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryMultimoduleTest.java
+++ b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryMultimoduleTest.java
@@ -17,10 +17,11 @@
  *
  *
  */
-
 package org.apache.zest.index.elasticsearch;
 
 import java.io.File;
+import java.io.IOException;
+import java.io.UncheckedIOException;
 import org.apache.zest.api.common.Visibility;
 import org.apache.zest.bootstrap.AssemblyException;
 import org.apache.zest.bootstrap.LayerAssembly;
@@ -30,14 +31,9 @@ import org.apache.zest.index.elasticsearch.assembly.ESFilesystemIndexQueryAssemb
 import org.apache.zest.library.fileconfig.FileConfigurationOverride;
 import org.apache.zest.library.fileconfig.FileConfigurationService;
 import org.apache.zest.test.EntityTestAssembler;
-import org.apache.zest.test.util.DelTreeAfter;
-import org.junit.Rule;
 
 public class ElasticSearchQueryMultimoduleTest extends ElasticSearchQueryTest
 {
-    @Rule
-    public final DelTreeAfter delTreeAfter = new DelTreeAfter( DATA_DIR );
-
     @Override
     public void assemble( ModuleAssembly module )
         throws AssemblyException
@@ -56,19 +52,27 @@ public class ElasticSearchQueryMultimoduleTest extends ElasticSearchQueryTest
         new EntityTestAssembler().assemble( config );
 
         // Index/Query
-        new ESFilesystemIndexQueryAssembler().
-            withConfig( config, Visibility.application ).visibleIn( Visibility.layer ).
-            assemble( module );
+        new ESFilesystemIndexQueryAssembler()
+            .withConfig( config, Visibility.application )
+            .visibleIn( Visibility.layer )
+            .assemble( module );
         ElasticSearchConfiguration esConfig = config.forMixin( ElasticSearchConfiguration.class
).declareDefaults();
         esConfig.indexNonAggregatedAssociations().set( Boolean.TRUE );
 
         // FileConfig
-        FileConfigurationOverride override = new FileConfigurationOverride().
-            withData( new File( DATA_DIR, "zest-data" ) ).
-            withLog( new File( DATA_DIR, "zest-logs" ) ).
-            withTemporary( new File( DATA_DIR, "zest-temp" ) );
-        module.services( FileConfigurationService.class ).
-            setMetaInfo( override );
+        try
+        {
+            File dir = tmpDir.newFolder();
+            FileConfigurationOverride override = new FileConfigurationOverride()
+                .withData( new File( dir, "zest-data" ) )
+                .withLog( new File( dir, "zest-logs" ) )
+                .withTemporary( new File( dir, "zest-temp" ) );
+            module.services( FileConfigurationService.class ).
+                setMetaInfo( override );
+        }
+        catch( IOException e )
+        {
+            throw new UncheckedIOException( e );
+        }
     }
-
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/19777d0f/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryTest.java
b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryTest.java
index ae1861b..6d0db9e 100644
--- a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryTest.java
+++ b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchQueryTest.java
@@ -22,10 +22,7 @@ package org.apache.zest.index.elasticsearch;
 
 import java.io.File;
 import java.io.IOException;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
+import java.io.UncheckedIOException;
 import org.apache.zest.api.common.Visibility;
 import org.apache.zest.bootstrap.AssemblyException;
 import org.apache.zest.bootstrap.ModuleAssembly;
@@ -35,24 +32,32 @@ import org.apache.zest.library.fileconfig.FileConfigurationService;
 import org.apache.zest.spi.query.EntityFinderException;
 import org.apache.zest.test.EntityTestAssembler;
 import org.apache.zest.test.indexing.AbstractQueryTest;
-import org.apache.zest.test.util.DelTreeAfter;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
 
 import static org.apache.zest.test.util.Assume.assumeNoIbmJdk;
 
 public class ElasticSearchQueryTest
     extends AbstractQueryTest
 {
-
-    protected static final File DATA_DIR = new File( "build/tmp/es-query-test" );
-    @Rule
-    public final DelTreeAfter delTreeAfter = new DelTreeAfter( DATA_DIR );
-
     @BeforeClass
     public static void beforeClass_IBMJDK()
     {
         assumeNoIbmJdk();
     }
 
+    @BeforeClass
+    public static void beforeClass_TMP()
+    {
+        new File( "build/tmp/es-query-test" ).mkdirs();
+    }
+
+    @Rule
+    public TemporaryFolder tmpDir = new TemporaryFolder( new File( "build/tmp/es-query-test"
) );
+
     @Override
     public void assemble( ModuleAssembly module )
         throws AssemblyException
@@ -64,19 +69,24 @@ public class ElasticSearchQueryTest
         new EntityTestAssembler().assemble( config );
 
         // Index/Query
-        new ESFilesystemIndexQueryAssembler().
-            withConfig( config, Visibility.layer ).
-            assemble( module );
+        new ESFilesystemIndexQueryAssembler().withConfig( config, Visibility.layer ).assemble(
module );
         ElasticSearchConfiguration esConfig = config.forMixin( ElasticSearchConfiguration.class
).declareDefaults();
         esConfig.indexNonAggregatedAssociations().set( Boolean.TRUE );
 
         // FileConfig
-        FileConfigurationOverride override = new FileConfigurationOverride().
-            withData( new File( DATA_DIR, "zest-data" ) ).
-            withLog( new File( DATA_DIR, "zest-logs" ) ).
-            withTemporary( new File( DATA_DIR, "zest-temp" ) );
-        module.services( FileConfigurationService.class ).
-            setMetaInfo( override );
+        try
+        {
+            File dir = tmpDir.newFolder();
+            FileConfigurationOverride override = new FileConfigurationOverride()
+                .withData( new File( dir, "zest-data" ) )
+                .withLog( new File( dir, "zest-logs" ) )
+                .withTemporary( new File( dir, "zest-temp" ) );
+            module.services( FileConfigurationService.class ).setMetaInfo( override );
+        }
+        catch( IOException e )
+        {
+            throw new UncheckedIOException( e );
+        }
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/zest-java/blob/19777d0f/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchTest.java
b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchTest.java
index 15399bb..821ecf8 100644
--- a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchTest.java
+++ b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ElasticSearchTest.java
@@ -17,20 +17,18 @@
  *
  *
  */
-
 package org.apache.zest.index.elasticsearch;
 
 import java.io.File;
-import org.apache.zest.api.identity.HasIdentity;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
+import java.io.IOException;
+import java.io.UncheckedIOException;
 import org.apache.zest.api.association.Association;
 import org.apache.zest.api.association.ManyAssociation;
 import org.apache.zest.api.common.UseDefaults;
 import org.apache.zest.api.common.Visibility;
 import org.apache.zest.api.entity.Aggregated;
 import org.apache.zest.api.entity.EntityBuilder;
+import org.apache.zest.api.identity.HasIdentity;
 import org.apache.zest.api.property.Property;
 import org.apache.zest.api.query.Query;
 import org.apache.zest.api.query.QueryBuilder;
@@ -43,30 +41,37 @@ import org.apache.zest.library.fileconfig.FileConfigurationOverride;
 import org.apache.zest.library.fileconfig.FileConfigurationService;
 import org.apache.zest.test.AbstractZestTest;
 import org.apache.zest.test.EntityTestAssembler;
-import org.apache.zest.test.util.DelTreeAfter;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
 import static org.apache.zest.api.query.QueryExpressions.eq;
 import static org.apache.zest.api.query.QueryExpressions.ne;
 import static org.apache.zest.api.query.QueryExpressions.not;
 import static org.apache.zest.api.query.QueryExpressions.templateFor;
 import static org.apache.zest.test.util.Assume.assumeNoIbmJdk;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 
 public class ElasticSearchTest
     extends AbstractZestTest
 {
-
-    private static final File DATA_DIR = new File( "build/tmp/es-test" );
-    @Rule
-    public final DelTreeAfter delTreeAfter = new DelTreeAfter( DATA_DIR );
-
     @BeforeClass
     public static void beforeClass_IBMJDK()
     {
         assumeNoIbmJdk();
     }
 
+    @BeforeClass
+    public static void beforeClass_TMP()
+    {
+        new File( "build/tmp/es-query-test" ).mkdirs();
+    }
+
+    @Rule
+    public TemporaryFolder tmpDir = new TemporaryFolder( new File( "build/tmp/es-query-test"
) );
+
     public interface Post
         extends HasIdentity
     {
@@ -127,19 +132,25 @@ public class ElasticSearchTest
         new EntityTestAssembler().assemble( module );
 
         // Index/Query
-        new ESFilesystemIndexQueryAssembler().
-            withConfig( config, Visibility.layer ).
-            assemble( module );
+        new ESFilesystemIndexQueryAssembler().withConfig( config, Visibility.layer )
+                                             .assemble( module );
         ElasticSearchConfiguration esConfig = config.forMixin( ElasticSearchConfiguration.class
).declareDefaults();
         esConfig.indexNonAggregatedAssociations().set( Boolean.TRUE );
 
         // FileConfig
-        FileConfigurationOverride override = new FileConfigurationOverride().
-            withData( new File( DATA_DIR, "zest-data" ) ).
-            withLog( new File( DATA_DIR, "zest-logs" ) ).
-            withTemporary( new File( DATA_DIR, "zest-temp" ) );
-        module.services( FileConfigurationService.class ).
-            setMetaInfo( override );
+        try
+        {
+            File dir = tmpDir.newFolder();
+            FileConfigurationOverride override = new FileConfigurationOverride()
+                .withData( new File( dir, "zest-data" ) )
+                .withLog( new File( dir, "zest-logs" ) )
+                .withTemporary( new File( dir, "zest-temp" ) );
+            module.services( FileConfigurationService.class ).setMetaInfo( override );
+        }
+        catch( IOException e )
+        {
+            throw new UncheckedIOException( e );
+        }
 
         // Entities & Values
         module.entities( Post.class, Page.class, Author.class, Comment.class );
@@ -210,24 +221,28 @@ public class ElasticSearchTest
         assertEquals( title, post.title().get() );
 
         post = templateFor( Post.class );
-        queryBuilder = queryBuilderFactory.newQueryBuilder( Post.class ).where( eq( post.title(),
"Not available" ) );
+        queryBuilder = queryBuilderFactory.newQueryBuilder( Post.class )
+                                          .where( eq( post.title(), "Not available" ) );
         query = uow.newQuery( queryBuilder );
         assertEquals( 0, query.count() );
 
         post = templateFor( Post.class );
-        queryBuilder = queryBuilderFactory.newQueryBuilder( Post.class ).where( ne( post.title(),
"Not available" ) );
+        queryBuilder = queryBuilderFactory.newQueryBuilder( Post.class )
+                                          .where( ne( post.title(), "Not available" ) );
         query = uow.newQuery( queryBuilder );
         assertEquals( 1, query.count() );
 
         post = templateFor( Post.class );
-        queryBuilder = queryBuilderFactory.newQueryBuilder( Post.class ).where( not( eq(
post.title(), "Not available" ) ) );
+        queryBuilder = queryBuilderFactory.newQueryBuilder( Post.class )
+                                          .where( not( eq( post.title(), "Not available"
) ) );
         query = uow.newQuery( queryBuilder );
         post = query.find();
         assertNotNull( post );
         assertEquals( title, post.title().get() );
 
         post = templateFor( Post.class );
-        queryBuilder = queryBuilderFactory.newQueryBuilder( Post.class ).where( eq( post.author().get().nickname(),
"eskatos" ) );
+        queryBuilder = queryBuilderFactory.newQueryBuilder( Post.class )
+                                          .where( eq( post.author().get().nickname(), "eskatos"
) );
         query = uow.newQuery( queryBuilder );
         assertEquals( 1, query.count() );
         post = query.find();
@@ -236,5 +251,4 @@ public class ElasticSearchTest
 
         uow.discard();
     }
-
 }

http://git-wip-us.apache.org/repos/asf/zest-java/blob/19777d0f/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ImmenseTermTest.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ImmenseTermTest.java
b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ImmenseTermTest.java
index e76d85b..88002f3 100644
--- a/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ImmenseTermTest.java
+++ b/extensions/indexing-elasticsearch/src/test/java/org/apache/zest/index/elasticsearch/ImmenseTermTest.java
@@ -98,19 +98,18 @@ public class ImmenseTermTest
         new EntityTestAssembler().assemble( module );
 
         // Index/Query
-        new ESFilesystemIndexQueryAssembler().
-            withConfig( config, Visibility.layer ).
-            assemble( module );
+        new ESFilesystemIndexQueryAssembler()
+            .withConfig( config, Visibility.layer )
+            .assemble( module );
         ElasticSearchConfiguration esConfig = config.forMixin( ElasticSearchConfiguration.class
).declareDefaults();
         esConfig.indexNonAggregatedAssociations().set( Boolean.TRUE );
 
         // FileConfig
-        FileConfigurationOverride override = new FileConfigurationOverride().
-            withData( new File( DATA_DIR, "zest-data" ) ).
-            withLog( new File( DATA_DIR, "zest-logs" ) ).
-            withTemporary( new File( DATA_DIR, "zest-temp" ) );
-        module.services( FileConfigurationService.class ).
-            setMetaInfo( override );
+        FileConfigurationOverride override = new FileConfigurationOverride()
+            .withData( new File( DATA_DIR, "zest-data" ) )
+            .withLog( new File( DATA_DIR, "zest-logs" ) )
+            .withTemporary( new File( DATA_DIR, "zest-temp" ) );
+        module.services( FileConfigurationService.class ).setMetaInfo( override );
 
         // Entities & Values
         module.entities( TestEntity.class, TestEntity2.class );

http://git-wip-us.apache.org/repos/asf/zest-java/blob/19777d0f/libraries.gradle
----------------------------------------------------------------------
diff --git a/libraries.gradle b/libraries.gradle
index 1e6a157..7952f73 100644
--- a/libraries.gradle
+++ b/libraries.gradle
@@ -28,7 +28,7 @@ def commonsLangVersion = '3.5'
 def derbyVersion = '10.13.1.1'
 def dnsJavaVersion = '2.1.7'
 def ehcacheVersion = '3.1.3'
-def elasticsearchVersion = '2.4.0'
+def elasticsearchVersion = '5.0.0'
 def freemarkerVersion = '2.3.25-incubating'
 def geodeVersion = '1.0.0-incubating'
 def groovyVersion = '2.4.7'
@@ -178,7 +178,13 @@ rootProject.ext {
           // Library & Extension dependencies
           jackson_mapper: "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion",
           ehcache: "org.ehcache:ehcache:$ehcacheVersion",
-          elasticsearch: "org.elasticsearch:elasticsearch:$elasticsearchVersion",
+          elasticsearch: [
+              "org.elasticsearch:elasticsearch:$elasticsearchVersion",
+              "org.elasticsearch.client:transport:$elasticsearchVersion",
+              // Elasticsearch 5.0 do not work with log4j 2.7
+              "org.apache.logging.log4j:log4j-api:2.6.2",
+              "org.apache.logging.log4j:log4j-core:2.6.2"
+          ],
           geode: "org.apache.geode:geode-core:$geodeVersion",
           h2: "com.h2database:h2:$h2Version",
           hazelcast: "com.hazelcast:hazelcast:$hazelcastVersion",


Mime
View raw message