ElasticSearchIndex implements IndexProvider { @Override public void close() throws BackendException { if (node != null && !node.isClosed()) { node.close(); } client.close(); } ElasticSearchIndex(Configuration config); @Override void register(String store, String key, KeyInformation information, BaseTransaction tx); XContentBuilder getNewDocument(final List<IndexEntry> additions, KeyInformation.StoreRetriever informations, int ttl); @Override void mutate(Map<String, Map<String, IndexMutation>> mutations, KeyInformation.IndexRetriever informations, BaseTransaction tx); void restore(Map<String,Map<String, List<IndexEntry>>> documents, KeyInformation.IndexRetriever informations, BaseTransaction tx); FilterBuilder getFilter(Condition<?> condition, KeyInformation.StoreRetriever informations); @Override List<String> query(IndexQuery query, KeyInformation.IndexRetriever informations, BaseTransaction tx); @Override Iterable<RawQuery.Result<String>> query(RawQuery query, KeyInformation.IndexRetriever informations, BaseTransaction tx); @Override boolean supports(KeyInformation information, TitanPredicate titanPredicate); @Override boolean supports(KeyInformation information); @Override String mapKey2Field(String key, KeyInformation information); @Override IndexFeatures getFeatures(); @Override BaseTransactionConfigurable beginTransaction(BaseTransactionConfig config); @Override void close(); @Override void clearStorage(); static final ImmutableList<String> DATA_SUBDIRS; static final ConfigNamespace ELASTICSEARCH_NS; static final ConfigOption<Boolean> CLIENT_ONLY; static final ConfigOption<String> CLUSTER_NAME; static final ConfigOption<Boolean> LOCAL_MODE; static final ConfigOption<Boolean> CLIENT_SNIFF; static final ConfigOption<String> INTERFACE; static final ConfigOption<Boolean> IGNORE_CLUSTER_NAME; static final ConfigOption<String> TTL_INTERVAL; static final ConfigOption<String> HEALTH_REQUEST_TIMEOUT; static final ConfigOption<Boolean> LOAD_DEFAULT_NODE_SETTINGS; static final ConfigOption<Boolean> USE_EDEPRECATED_IGNORE_UNMAPPED_OPTION; static final ConfigNamespace ES_EXTRAS_NS; static final ConfigNamespace ES_CREATE_NS; static final ConfigOption<Long> CREATE_SLEEP; static final ConfigNamespace ES_CREATE_EXTRAS_NS; static final int HOST_PORT_DEFAULT; }
@Test public void testConfiguration() throws BackendException { final String index = "es"; ModifiableConfiguration config = GraphDatabaseConfiguration.buildGraphConfiguration(); config.set(LOCAL_MODE, true, index); config.set(CLIENT_ONLY, true, index); config.set(INDEX_HOSTS, new String[] { "10.0.0.1" }, index); config.set(GraphDatabaseConfiguration.INDEX_DIRECTORY, StorageSetup.getHomeDir("es"), index); Configuration indexConfig = config.restrictTo(index); IndexProvider idx = new ElasticSearchIndex(indexConfig); idx.close(); config = GraphDatabaseConfiguration.buildGraphConfiguration(); config.set(LOCAL_MODE, false, index); config.set(CLIENT_ONLY, true, index); config.set(INDEX_HOSTS, new String[] { "10.0.0.1" }, index); config.set(GraphDatabaseConfiguration.INDEX_DIRECTORY, StorageSetup.getHomeDir("es"), index); indexConfig = config.restrictTo(index); RuntimeException expectedException = null; try { idx = new ElasticSearchIndex(indexConfig); idx.close(); } catch (RuntimeException re) { expectedException = re; } assertNotNull(expectedException); }