Skip to content

Commit

Permalink
OPEN - #6: Update version of Elasticsearch and make
Browse files Browse the repository at this point in the history
ElasticSearchIndexMaintainer a proper service 

- update elasticsearch to version 1.7.5. 2.3.4 is newest but because we
need to be roughly in sync with hibernate-search (both depend on lucene,
tapestry 5.4 requires hibernate 4.x) it was not possible to update to
the very latest
- fix compilation errors
- update hibernate related dependencies and fix compilation errors
- adjust version till it works at runtime passing all integration tests
  • Loading branch information
kaosko committed Jul 8, 2016
1 parent d700236 commit 169308c
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 58 deletions.
9 changes: 2 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<parent>
<groupId>org.tynamo</groupId>
<artifactId>tynamo-parent</artifactId>
<version>0.2.2</version>
<version>0.2.3</version>
</parent>

<modules>
Expand All @@ -31,7 +31,7 @@
</scm>

<properties>
<tapestry-release-version>5.4-rc-1</tapestry-release-version>
<tapestry-release-version>5.4.1</tapestry-release-version>
</properties>

<!-- note that our own versions are auto-managed by the release plugin -->
Expand Down Expand Up @@ -62,11 +62,6 @@
<artifactId>tapestry-model-test</artifactId>
<version>0.6.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.tynamo</groupId>
<artifactId>tapestry-model-web</artifactId>
<version>0.6.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.tynamo</groupId>
<artifactId>tynamo-test</artifactId>
Expand Down
1 change: 1 addition & 0 deletions tapestry-model-example/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/build/
/target/
/test-output/
41 changes: 14 additions & 27 deletions tapestry-model-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search</artifactId>
<version>4.3.0.Final</version>
<artifactId>hibernate-search-orm</artifactId>
<version>5.0.0.Final</version>
</dependency>

<dependency>
Expand All @@ -124,23 +124,15 @@
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.5.1</version>
<version>2.6.3</version>
</dependency>

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.3.0.Final</version>
<version>4.3.2.Final</version>
</dependency>

<!--
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.1.3.Final</version>
</dependency>
-->

<dependency>
<groupId>org.tynamo</groupId>
<artifactId>tynamo-test</artifactId>
Expand All @@ -150,7 +142,7 @@
<dependency>
<groupId>org.tynamo</groupId>
<artifactId>tapestry-routing</artifactId>
<version>0.1.0</version>
<version>0.1.1</version>
<exclusions>
<exclusion>
<groupId>org.apache.tapestry</groupId>
Expand All @@ -165,20 +157,15 @@
<version>1.7.2</version>
</dependency>

</dependencies>
<!-- hibernate bring a version of xml-apis too old for htmlunit -->
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>1.4.01</version>
<scope>test</scope>
</dependency>


<profiles>
<profile>
<id>repositories</id>
<repositories>
<repository>
<id>EclipseLink Repo</id>
<url>
http://download.eclipse.org/rt/eclipselink/maven.repo
</url>
</repository>
</repositories>
</profile>
</profiles>
</dependencies>

</project>
1 change: 1 addition & 0 deletions tapestry-model-hibernate/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target/
/test-output/
17 changes: 13 additions & 4 deletions tapestry-model-hibernate/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.2.2.Final</version>
<version>4.3.6.Final</version>
<optional>true</optional>
</dependency>

Expand All @@ -61,7 +61,7 @@
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.3.0.Final</version>
<version>4.3.2.Final</version>
<exclusions>
<!-- Make sure we use the version defined by tapestry-ioc. -->
<exclusion>
Expand All @@ -71,12 +71,21 @@
</exclusions>
</dependency>

<!-- We need to find a combination of hibernate versions that work together with the constraints - hibernate-search has a dependency to Lucene,
and tapestry-hibernate-core to hibernate-core. Hibernate 5.2.x requires Java 8 so we have to wait for Tapestry 5.5 to be released first -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search</artifactId>
<version>4.3.0.Final</version>
<artifactId>hibernate-search-orm</artifactId>
<version>5.0.0.Final</version>
<optional>true</optional>
</dependency>

<!-- queryparser is an optional dependency of hibernate-search, we need it for parsing string queries. Keep the version in sync of hibernate-search's lucene dependencies -->
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queryparser</artifactId>
<version>4.10.2</version>
</dependency>

<dependency>
<groupId>org.apache.tapestry</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import java.util.Set;

import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.queryParser.MultiFieldQueryParser;
import org.apache.lucene.queryParser.ParseException;
import org.apache.lucene.queryparser.classic.MultiFieldQueryParser;
import org.apache.lucene.queryparser.classic.ParseException;
import org.apache.lucene.util.Version;
import org.apache.tapestry5.grid.GridDataSource;
import org.apache.tapestry5.hibernate.HibernateGridDataSource;
Expand Down Expand Up @@ -49,8 +49,8 @@ public GridDataSource createGridDataSource(Class entityType,
// don't bother with a text query if there are no @Fields
if (fieldNames.size() <= 0) return createGridDataSource(entityType);

MultiFieldQueryParser parser = new MultiFieldQueryParser(Version.LUCENE_35, fieldNames.toArray(new String[fieldNames.size()]),
new StandardAnalyzer(Version.LUCENE_35));
MultiFieldQueryParser parser = new MultiFieldQueryParser(fieldNames.toArray(new String[fieldNames.size()]),
new StandardAnalyzer(Version.LUCENE_4_10_2));
// parser.setDefaultOperator(QueryParser.AND_OPERATOR); // overrides the default OR_OPERATOR, so that all words in the search are
// required
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public class DescriptorServiceAndEmbeddalesTest

private static Registry registry;

@SuppressWarnings("unchecked")
@BeforeSuite
public final void setup_registry()
{
Expand Down
14 changes: 11 additions & 3 deletions tapestry-model-jpa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.5.1</version>
<!-- must be in provided scope until we migrate to JPA 2.1/eclipselink 2.5.0 with injectable em listeners -->
<version>2.6.3</version>
<!-- must be in provided scope until we migrate to T5.5 with injectable JPA em listeners -->
<scope>provided</scope>
</dependency>

Expand All @@ -70,8 +70,16 @@
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>0.20.0.RC1</version>
<version>1.7.5</version>
</dependency>
<!-- elasticsearch 2.3.4 brings in version 5.5.0 of lucene-queryparser but downgrade because we need to be somewhat in sync with hibernate-search and
we cannot upgrade hibernate because tapestry-hibernate is still using a 4.x version. Give up and find a version of elasticsearch that works with hibernate 4.x
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queryparser</artifactId>
<version>4.10.2</version>
</dependency>
-->

<dependency>
<groupId>org.slf4j</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package org.tynamo.model.elasticsearch.mapping;

import java.io.IOException;
import java.lang.annotation.Annotation;
import java.math.BigDecimal;
import java.util.Date;

import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.Validate;
Expand All @@ -12,11 +17,6 @@
import org.tynamo.model.elasticsearch.annotations.ElasticSearchField.Store;
import org.tynamo.model.elasticsearch.descriptor.ElasticSearchFieldDescriptor;

import java.io.IOException;
import java.lang.annotation.Annotation;
import java.math.BigDecimal;
import java.util.Date;


public abstract class MappingUtil {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package org.tynamo.model.jpa.components;

import java.util.HashSet;
import java.util.Set;

import org.apache.tapestry5.grid.GridDataSource;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.ioc.services.TypeCoercer;
Expand All @@ -16,9 +19,6 @@
import org.tynamo.model.elasticsearch.descriptor.ElasticSearchFieldDescriptor;
import org.tynamo.services.DescriptorService;

import java.util.HashSet;
import java.util.Set;

public class ElasticModelSearch extends GenericModelSearch {

@Inject
Expand Down Expand Up @@ -46,7 +46,8 @@ protected GridDataSource createGridDataSource() {
// FIXME consider whether we should .setTypes("entityType")
SearchResponse searchResponse = client.prepareSearch(elasticDescriptor.getIndexName())
.setTypes(elasticDescriptor.getTypeName())
.setQuery(QueryBuilders.boolQuery().must(QueryBuilders.queryString(getSearchTerms()))).execute().actionGet();
.setQuery(QueryBuilders.boolQuery().must(QueryBuilders.queryStringQuery(getSearchTerms()))).execute()
.actionGet();

if (searchResponse.getHits().getTotalHits() <= 0) return new EmptyGridDataSource(getBeanType());

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package org.tynamo.model.jpa.services;

import java.net.InetAddress;
import java.net.UnknownHostException;

import org.apache.tapestry5.ioc.MappedConfiguration;
import org.apache.tapestry5.ioc.ServiceBinder;
import org.apache.tapestry5.ioc.annotations.Autobuild;
import org.apache.tapestry5.ioc.annotations.Startup;
import org.apache.tapestry5.ioc.annotations.Symbol;
import org.apache.tapestry5.ioc.services.RegistryShutdownHub;
import org.elasticsearch.common.network.NetworkUtils;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.node.Node;
import org.elasticsearch.node.NodeBuilder;
Expand All @@ -33,13 +35,14 @@ public static void contributeFactoryDefaults(MappedConfiguration<String, Object>

public Node buildNode(@Symbol(TynamoJpaSymbols.ELASTICSEARCH_HOME) String pathHome,
@Symbol(TynamoJpaSymbols.ELASTICSEARCH_HTTP_ENABLED) boolean httpEnabled,
RegistryShutdownHub registryShutdownHub) {
RegistryShutdownHub registryShutdownHub) throws UnknownHostException {
// Settings.Builder settings = Settings.settingsBuilder();
ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder();
if (!pathHome.isEmpty()) settings.put("path.home", pathHome);
settings.put("http.enabled", httpEnabled);
settings.put("number_of_shards", 1);
settings.put("number_of_replicas", 0);
settings.put("cluster.name", "tynamo-model-search-" + NetworkUtils.getLocalAddress().getHostName()).build();
settings.put("cluster.name", "tynamo-model-search-" + InetAddress.getLocalHost().getHostName()).build();
final Node node = NodeBuilder.nodeBuilder().local(true).data(true).settings(settings).build();
node.start();

Expand Down

0 comments on commit 169308c

Please sign in to comment.