Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to ES2.0.0-beta1 and Lucene 5.2.1 #1153

Open
wants to merge 6 commits into
base: titan09
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@
version used by the titan-lucene module. When updating
the ES version, also consider the version of Lucene, and
vice-versa. -->
<lucene.version>4.10.4</lucene.version>
<elasticsearch.version>1.5.1</elasticsearch.version>
<lucene.version>5.2.1</lucene.version>
<elasticsearch.version>2.0.0-beta1</elasticsearch.version>
<elasticsearch.mr.version>2.0.0</elasticsearch.mr.version>
<commons.beanutils.version>1.7.0</commons.beanutils.version>
<joda.version>1.6.2</joda.version>
<concurrentlinkedhashmap.version>1.3</concurrentlinkedhashmap.version>
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
import com.thinkaurelius.titan.diskstorage.configuration.ConfigOption;
import com.thinkaurelius.titan.diskstorage.configuration.Configuration;
import com.thinkaurelius.titan.util.system.IOUtils;

import org.apache.commons.lang.StringUtils;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.node.Node;
import org.elasticsearch.node.NodeBuilder;
Expand All @@ -18,6 +19,7 @@

import java.io.*;
import java.lang.reflect.Array;
import java.net.InetAddress;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -68,23 +70,25 @@ public enum ElasticSearchSetup {
public Connection connect(Configuration config) throws IOException {
log.debug("Configuring TransportClient");

ImmutableSettings.Builder settingsBuilder = settingsBuilder(config);
Settings.Builder settingsBuilder = settingsBuilder(config);

if (config.has(ElasticSearchIndex.CLIENT_SNIFF)) {
String k = "client.transport.sniff";
settingsBuilder.put(k, config.get(ElasticSearchIndex.CLIENT_SNIFF));
log.debug("Set {}: {}", k, config.get(ElasticSearchIndex.CLIENT_SNIFF));
}

TransportClient tc = new TransportClient(settingsBuilder.build());
makeLocalDirsIfNecessary(settingsBuilder, config);

TransportClient tc = TransportClient.builder().settings(settingsBuilder.build()).build();
int defaultPort = config.has(INDEX_PORT) ? config.get(INDEX_PORT) : ElasticSearchIndex.HOST_PORT_DEFAULT;
for (String host : config.get(INDEX_HOSTS)) {
String[] hostparts = host.split(":");
String hostname = hostparts[0];
int hostport = defaultPort;
if (hostparts.length == 2) hostport = Integer.parseInt(hostparts[1]);
log.info("Configured remote host: {} : {}", hostname, hostport);
tc.addTransportAddress(new InetSocketTransportAddress(hostname, hostport));
tc.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(hostname), hostport));
}
return new Connection(null, tc);
}
Expand All @@ -99,7 +103,7 @@ public Connection connect(Configuration config) throws IOException {

log.debug("Configuring Node Client");

ImmutableSettings.Builder settingsBuilder = settingsBuilder(config);
Settings.Builder settingsBuilder = settingsBuilder(config);

if (config.has(ElasticSearchIndex.TTL_INTERVAL)) {
String k = "indices.ttl.interval";
Expand Down Expand Up @@ -145,7 +149,7 @@ public Connection connect(Configuration config) throws IOException {
* <li>If ignore-cluster-name is set, copy that value to client.transport.ignore_cluster_name in the settings builder</li>
* <li>If client-sniff is set, copy that value to client.transport.sniff in the settings builder</li>
* <li>If ttl-interval is set, copy that volue to indices.ttl.interval in the settings builder</li>
* <li>Unconditionally set script.disable_dynamic to false (i.e. enable dynamic scripting)</li>
* <li>Unconditionally set script.inline to on (i.e. enable inline scripting)</li>
* </ol>
*
* This method then returns the builder.
Expand All @@ -154,9 +158,9 @@ public Connection connect(Configuration config) throws IOException {
* @return ES settings builder configured according to the {@code config} parameter
* @throws java.io.IOException if conf-file was set but could not be read
*/
private static ImmutableSettings.Builder settingsBuilder(Configuration config) throws IOException {
private static Settings.Builder settingsBuilder(Configuration config) throws IOException {

ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder();
Settings.Builder settings = Settings.settingsBuilder();

// Set Titan defaults
settings.put("client.transport.ignore_cluster_name", true);
Expand Down Expand Up @@ -185,20 +189,21 @@ private static ImmutableSettings.Builder settingsBuilder(Configuration config) t
}

// Force-enable dynamic scripting. This is probably only useful in Node mode.
String disableScriptsKey = "script.disable_dynamic";
String disableScriptsKey = "script.inline";
String disableScriptsVal = settings.get(disableScriptsKey);
if (null != disableScriptsVal && !"false".equals(disableScriptsVal)) {
log.warn("Titan requires Elasticsearch dynamic scripting. Setting {} to false. " +
if (null != disableScriptsVal && !"on".equals(disableScriptsVal)) {
log.warn("Titan requires Elasticsearch dynamic scripting. Setting {} to 'on'. " +
"Dynamic scripting must be allowed in the Elasticsearch cluster configuration.",
disableScriptsKey);
}
settings.put(disableScriptsKey, false);
log.debug("Set {}: {}", disableScriptsKey, false);
settings.put(disableScriptsKey, "on");
settings.put("path.home", System.getProperty("java.io.tmpdir"));
log.debug("Set {}: {}", disableScriptsKey, "on");

return settings;
}

static void applySettingsFromFile(ImmutableSettings.Builder settings,
static void applySettingsFromFile(Settings.Builder settings,
Configuration config,
ConfigOption<String> confFileOption) throws FileNotFoundException {
if (config.has(confFileOption)) {
Expand All @@ -216,7 +221,7 @@ static void applySettingsFromFile(ImmutableSettings.Builder settings,
}
}

static void applySettingsFromTitanConf(ImmutableSettings.Builder settings,
static void applySettingsFromTitanConf(Settings.Builder settings,
Configuration config,
ConfigNamespace rootNS) {
int keysLoaded = 0;
Expand Down Expand Up @@ -248,7 +253,7 @@ static void applySettingsFromTitanConf(ImmutableSettings.Builder settings,
}


private static void makeLocalDirsIfNecessary(ImmutableSettings.Builder settingsBuilder, Configuration config) {
private static void makeLocalDirsIfNecessary(Settings.Builder settingsBuilder, Configuration config) {
if (config.has(INDEX_DIRECTORY)) {
String dataDirectory = config.get(INDEX_DIRECTORY);
File f = new File(dataDirectory);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.thinkaurelius.titan.diskstorage.es;

import com.google.common.base.Joiner;

import com.thinkaurelius.titan.core.TitanFactory;
import com.thinkaurelius.titan.core.TitanGraph;
import com.thinkaurelius.titan.core.attribute.Text;
Expand All @@ -13,15 +12,15 @@
import com.thinkaurelius.titan.diskstorage.configuration.backend.CommonsConfiguration;
import com.thinkaurelius.titan.diskstorage.indexing.*;
import com.thinkaurelius.titan.diskstorage.util.StandardBaseTransactionConfig;

import com.thinkaurelius.titan.diskstorage.util.time.TimestampProviders;
import com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration;
import com.thinkaurelius.titan.graphdb.query.condition.PredicateCondition;
import com.thinkaurelius.titan.util.system.IOUtils;

import org.apache.commons.configuration.BaseConfiguration;
import org.elasticsearch.action.admin.indices.settings.get.GetSettingsRequest;
import org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.node.Node;
import org.elasticsearch.node.NodeBuilder;
import org.junit.Assert;
Expand All @@ -35,7 +34,6 @@
import static com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration.INDEX_CONF_FILE;
import static com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration.INDEX_DIRECTORY;
import static com.thinkaurelius.titan.graphdb.configuration.GraphDatabaseConfiguration.INDEX_HOSTS;

import static org.junit.Assert.*;

/**
Expand Down Expand Up @@ -259,7 +257,7 @@ public void testIndexCreationOptions() throws InterruptedException, BackendExcep



ImmutableSettings.Builder settingsBuilder = ImmutableSettings.settingsBuilder();
Settings.Builder settingsBuilder = Settings.settingsBuilder();
settingsBuilder.put("discovery.zen.ping.multicast.enabled", "false");
settingsBuilder.put("discovery.zen.ping.unicast.hosts", "localhost,127.0.0.1:9300");
settingsBuilder.put("cluster.name", "indexCreationOptions");
Expand All @@ -271,7 +269,7 @@ public void testIndexCreationOptions() throws InterruptedException, BackendExcep
assertEquals(String.valueOf(shards), response.getSetting("titan", "index.number_of_shards"));

idx.close();
n.stop();
n.close();
esr.stop();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import java.io.FileReader;
import java.io.IOException;

import org.elasticsearch.common.Preconditions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.base.Preconditions;
import com.thinkaurelius.titan.util.system.IOUtils;

public class HBaseStatus {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.thinkaurelius.titan.graphdb.query.TitanPredicate;
import com.thinkaurelius.titan.graphdb.query.condition.*;
import com.thinkaurelius.titan.util.system.IOUtils;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
Expand All @@ -39,12 +40,12 @@
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.util.Version;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.time.Instant;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
Expand All @@ -63,7 +64,7 @@ public class LuceneIndex implements IndexProvider {
private static final String GEOID = "_____geo";
private static final int MAX_STRING_FIELD_LEN = 256;

private static final Version LUCENE_VERSION = Version.LUCENE_4_10_4;
private static final Version LUCENE_VERSION = Version.LUCENE_5_2_1;
private static final IndexFeatures LUCENE_FEATURES = new IndexFeatures.Builder().supportedStringMappings(Mapping.TEXT, Mapping.STRING).supportsCardinality(Cardinality.SINGLE).supportsNanoseconds().build();

private static final int GEO_MAX_LEVELS = 11;
Expand Down Expand Up @@ -97,7 +98,7 @@ private Directory getStoreDirectory(String store) throws BackendException {
if (!path.exists() || !path.isDirectory() || !path.canWrite())
throw new PermanentBackendException("Cannot access or write to directory: " + dir);
log.debug("Opening store directory [{}]", path);
return FSDirectory.open(path);
return FSDirectory.open(path.toPath());
} catch (IOException e) {
throw new PermanentBackendException("Could not open directory: " + dir, e);
}
Expand All @@ -107,7 +108,7 @@ private IndexWriter getWriter(String store) throws BackendException {
Preconditions.checkArgument(writerLock.isHeldByCurrentThread());
IndexWriter writer = writers.get(store);
if (writer == null) {
IndexWriterConfig iwc = new IndexWriterConfig(LUCENE_VERSION, analyzer);
IndexWriterConfig iwc = new IndexWriterConfig(analyzer);
iwc.setOpenMode(IndexWriterConfig.OpenMode.CREATE_OR_APPEND);
try {
writer = new IndexWriter(getStoreDirectory(store), iwc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ private SpatialStrategy getSpatialStrategy(String key) {

@Test
public void example1() throws Exception {
Directory dir = FSDirectory.open(path);
Directory dir = FSDirectory.open(path.toPath());
Analyzer analyzer = new StandardAnalyzer();
IndexWriterConfig iwc = new IndexWriterConfig(Version.LUCENE_4_10_4, analyzer);
IndexWriterConfig iwc = new IndexWriterConfig(analyzer);

iwc.setOpenMode(IndexWriterConfig.OpenMode.CREATE_OR_APPEND);
IndexWriter writer = new IndexWriter(dir, iwc);
Expand All @@ -91,7 +91,7 @@ public void example1() throws Exception {
writer.close();

//Search
IndexReader reader = DirectoryReader.open(FSDirectory.open(path));
IndexReader reader = DirectoryReader.open(FSDirectory.open(path.toPath()));
IndexSearcher searcher = new IndexSearcher(reader);
analyzer = new StandardAnalyzer();

Expand Down