Skip to content

Commit

Permalink
ISPN-11797 Introduce strong typed indexing configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustavo Fernandes authored and tristantarrant committed Nov 27, 2020
1 parent 24feb14 commit 2701352
Show file tree
Hide file tree
Showing 182 changed files with 2,124 additions and 583 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.infinispan.client.hotrod.admin;

import static org.infinispan.configuration.cache.IndexStorage.LOCAL_HEAP;
import static org.infinispan.server.hotrod.test.HotRodTestingUtil.hotRodCacheConfiguration;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertFalse;
Expand Down Expand Up @@ -33,7 +34,6 @@
import org.infinispan.protostream.SerializationContextInitializer;
import org.infinispan.query.dsl.embedded.testdomain.Transaction;
import org.infinispan.query.dsl.embedded.testdomain.User;
import org.infinispan.query.helper.SearchConfig;
import org.infinispan.server.core.admin.embeddedserver.EmbeddedServerAdminOperationHandler;
import org.infinispan.server.hotrod.HotRodServer;
import org.infinispan.server.hotrod.configuration.HotRodServerConfigurationBuilder;
Expand All @@ -47,8 +47,8 @@ protected void createCacheManagers() throws Throwable {
ConfigurationBuilder builder = hotRodCacheConfiguration(
getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC, false));
builder.indexing().enable()
.addIndexedEntity("sample_bank_account.Transaction")
.addProperty(SearchConfig.DIRECTORY_TYPE, SearchConfig.HEAP);
.storage(LOCAL_HEAP)
.addIndexedEntity("sample_bank_account.Transaction");
createHotRodServers(2, builder);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.infinispan.client.hotrod.event;


import static org.infinispan.configuration.cache.IndexStorage.LOCAL_HEAP;
import static org.infinispan.server.hotrod.test.HotRodTestingUtil.hotRodCacheConfiguration;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNotNull;
Expand Down Expand Up @@ -82,8 +83,8 @@ protected ConfigurationBuilder getConfigurationBuilder() {
cfgBuilder.encoding().key().mediaType(MediaType.APPLICATION_OBJECT_TYPE);
cfgBuilder.encoding().value().mediaType(MediaType.APPLICATION_OBJECT_TYPE);
cfgBuilder.indexing().enable()
.addIndexedEntities(UserHS.class)
.addProperty("directory.type", "local-heap");
.storage(LOCAL_HEAP)
.addIndexedEntities(UserHS.class);
return cfgBuilder;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.infinispan.client.hotrod.event;


import static org.infinispan.configuration.cache.IndexStorage.LOCAL_HEAP;
import static org.infinispan.server.hotrod.test.HotRodTestingUtil.hotRodCacheConfiguration;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNotNull;
Expand Down Expand Up @@ -38,8 +39,8 @@ public class ClientListenerWithIndexingAndProtobufTest extends MultiHotRodServer
protected void createCacheManagers() throws Throwable {
ConfigurationBuilder cfgBuilder = hotRodCacheConfiguration(getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC, false));
cfgBuilder.indexing().enable()
.addIndexedEntity("sample_bank_account.User")
.addProperty("directory.type", "local-heap");
.storage(LOCAL_HEAP)
.addIndexedEntity("sample_bank_account.User");

createHotRodServers(NUM_NODES, cfgBuilder);
waitForClusterToForm();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.infinispan.client.hotrod.event;

import static org.infinispan.configuration.cache.IndexStorage.LOCAL_HEAP;
import static org.infinispan.server.hotrod.test.HotRodTestingUtil.hotRodCacheConfiguration;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNotNull;
Expand Down Expand Up @@ -81,8 +82,8 @@ protected ConfigurationBuilder getConfigurationBuilder() {
cfgBuilder.encoding().key().mediaType(MediaType.APPLICATION_OBJECT_TYPE);
cfgBuilder.encoding().value().mediaType(MediaType.APPLICATION_OBJECT_TYPE);
cfgBuilder.indexing().enable()
.addIndexedEntities(UserHS.class)
.addProperty("directory.type", "local-heap");
.storage(LOCAL_HEAP)
.addIndexedEntities(UserHS.class);
cfgBuilder.expiration().disableReaper();
return cfgBuilder;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.infinispan.client.hotrod.event;


import static org.infinispan.configuration.cache.IndexStorage.LOCAL_HEAP;
import static org.infinispan.server.hotrod.test.HotRodTestingUtil.hotRodCacheConfiguration;
import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.AssertJUnit.assertNull;
Expand Down Expand Up @@ -74,8 +75,8 @@ protected void createCacheManagers() throws Throwable {
protected ConfigurationBuilder getConfigurationBuilder() {
ConfigurationBuilder cfgBuilder = hotRodCacheConfiguration(getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC, false));
cfgBuilder.indexing().enable()
.addIndexedEntity("sample_bank_account.User")
.addProperty("directory.type", "local-heap");
.storage(LOCAL_HEAP)
.addIndexedEntity("sample_bank_account.User");
cfgBuilder.expiration().disableReaper();
return cfgBuilder;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.infinispan.client.hotrod.event;


import static org.infinispan.configuration.cache.IndexStorage.LOCAL_HEAP;
import static org.infinispan.server.hotrod.test.HotRodTestingUtil.hotRodCacheConfiguration;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNotNull;
Expand Down Expand Up @@ -78,8 +79,8 @@ protected SerializationContextInitializer contextInitializer() {
protected ConfigurationBuilder getConfigurationBuilder() {
ConfigurationBuilder cfgBuilder = hotRodCacheConfiguration(getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC, false));
cfgBuilder.indexing().enable()
.addIndexedEntity("sample_bank_account.User")
.addProperty("directory.type", "local-heap");
.storage(LOCAL_HEAP)
.addIndexedEntity("sample_bank_account.User");
cfgBuilder.expiration().disableReaper();
return cfgBuilder;
}
Expand Down Expand Up @@ -133,7 +134,7 @@ public void testContinuousQuery() {
QueryFactory qf = Search.getQueryFactory(remoteCache);

Query<User> query = qf.<User>create("FROM sample_bank_account.User WHERE age <= :ageParam")
.setParameter("ageParam", 32);
.setParameter("ageParam", 32);

final BlockingQueue<KeyValuePair<String, User>> joined = new LinkedBlockingQueue<>();
final BlockingQueue<KeyValuePair<String, User>> updated = new LinkedBlockingQueue<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.infinispan.client.hotrod.event;


import static org.infinispan.configuration.cache.IndexStorage.LOCAL_HEAP;
import static org.infinispan.server.hotrod.test.HotRodTestingUtil.hotRodCacheConfiguration;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNotNull;
Expand Down Expand Up @@ -79,8 +80,8 @@ protected SerializationContextInitializer contextInitializer() {
protected ConfigurationBuilder getConfigurationBuilder() {
ConfigurationBuilder cfgBuilder = hotRodCacheConfiguration(getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC, false));
cfgBuilder.indexing().enable()
.addIndexedEntity("sample_bank_account.User")
.addProperty("directory.type", "local-heap");
.storage(LOCAL_HEAP)
.addIndexedEntity("sample_bank_account.User");
return cfgBuilder;
}

Expand Down Expand Up @@ -132,7 +133,7 @@ public void testEventFilter() {
QueryFactory qf = Search.getQueryFactory(remoteCache);

Query<Object[]> query = qf.<Object[]>create("SELECT age FROM sample_bank_account.User WHERE age <= :ageParam")
.setParameter("ageParam", 32);
.setParameter("ageParam", 32);

ClientEntryListener listener = new ClientEntryListener(serCtx);
ClientEvents.addClientQueryListener(remoteCache, listener, query);
Expand Down Expand Up @@ -197,7 +198,7 @@ public void testEventFilterChangingParameter() {
QueryFactory qf = Search.getQueryFactory(remoteCache);

Query<Object[]> query = qf.<Object[]>create("SELECT age FROM sample_bank_account.User WHERE age <= :ageParam")
.setParameter("ageParam", 32);
.setParameter("ageParam", 32);

ClientEntryListener listener = new ClientEntryListener(serCtx);
ClientEvents.addClientQueryListener(remoteCache, listener, query);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.infinispan.client.hotrod.impl.iteration;

import static org.infinispan.configuration.cache.IndexStorage.LOCAL_HEAP;
import static org.infinispan.server.hotrod.test.HotRodTestingUtil.hotRodCacheConfiguration;
import static org.testng.Assert.assertEquals;

Expand Down Expand Up @@ -34,8 +35,8 @@ public class ProtobufRemoteIteratorIndexingTest extends MultiHotRodServersTest i
protected void createCacheManagers() throws Throwable {
ConfigurationBuilder cfg = getDefaultClusteredCacheConfig(CacheMode.REPL_SYNC, false);
cfg.indexing().enable()
.addIndexedEntity("sample_bank_account.Account")
.addProperty("directory.type", "local-heap");
.storage(LOCAL_HEAP)
.addIndexedEntity("sample_bank_account.Account");
createHotRodServers(NUM_NODES, hotRodCacheConfiguration(cfg));
waitForClusterToForm();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static org.infinispan.client.hotrod.test.HotRodClientTestingUtil.killRemoteCacheManager;
import static org.infinispan.client.hotrod.test.HotRodClientTestingUtil.killServers;
import static org.infinispan.configuration.cache.IndexStorage.LOCAL_HEAP;
import static org.infinispan.server.hotrod.test.HotRodTestingUtil.hotRodCacheConfiguration;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNotNull;
Expand Down Expand Up @@ -92,8 +93,8 @@ protected org.infinispan.configuration.cache.ConfigurationBuilder createConfigBu
builder.encoding().key().mediaType(MediaType.APPLICATION_OBJECT_TYPE);
builder.encoding().value().mediaType(MediaType.APPLICATION_OBJECT_TYPE);
builder.indexing().enable()
.addIndexedEntities(UserHS.class, AccountHS.class, TransactionHS.class)
.addProperty("directory.type", "local-heap");
.storage(LOCAL_HEAP)
.addIndexedEntities(UserHS.class, AccountHS.class, TransactionHS.class);
return builder;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.infinispan.client.hotrod.query;


import static org.infinispan.configuration.cache.IndexStorage.LOCAL_HEAP;
import static org.testng.AssertJUnit.assertEquals;

import org.infinispan.Cache;
Expand Down Expand Up @@ -35,8 +36,8 @@ public class BuiltInAnalyzersTest extends SingleHotRodServerTest {
protected EmbeddedCacheManager createCacheManager() throws Exception {
org.infinispan.configuration.cache.ConfigurationBuilder builder = new org.infinispan.configuration.cache.ConfigurationBuilder();
builder.indexing().enable()
.addIndexedEntity("TestEntity")
.addProperty("directory.type", "local-heap");
.storage(LOCAL_HEAP)
.addIndexedEntity("TestEntity");

EmbeddedCacheManager manager = TestCacheManagerFactory.createServerModeCacheManager();
Cache<String, String> metadataCache = manager.getCache(ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.infinispan.commons.test.CommonsTestingUtil;
import org.infinispan.commons.util.Util;
import org.infinispan.configuration.cache.ConfigurationBuilder;
import org.infinispan.configuration.cache.IndexStorage;
import org.testng.annotations.Test;

/**
Expand All @@ -23,9 +24,7 @@ public class HotRodQueryFileSystemTest extends HotRodQueryIspnDirectoryTest {
@Override
protected ConfigurationBuilder getConfigurationBuilder() {
ConfigurationBuilder builder = super.getConfigurationBuilder();
builder.indexing()
.addProperty("directory.type", "local-filesystem")
.addProperty("directory.root", indexDirectory);
builder.indexing().storage(IndexStorage.FILESYSTEM).path(indexDirectory);
return builder;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static org.infinispan.client.hotrod.test.HotRodClientTestingUtil.killRemoteCacheManager;
import static org.infinispan.client.hotrod.test.HotRodClientTestingUtil.killServers;
import static org.infinispan.configuration.cache.IndexStorage.LOCAL_HEAP;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.AssertJUnit.assertTrue;
Expand Down Expand Up @@ -84,8 +85,8 @@ protected void configure(GlobalConfigurationBuilder builder) {
protected ConfigurationBuilder getConfigurationBuilder() {
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.indexing().enable()
.addIndexedEntity("sample_bank_account.User")
.addProperty("directory.type", "local-heap");
.storage(LOCAL_HEAP)
.addIndexedEntity("sample_bank_account.User");
return builder;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,11 @@ public void shouldPreventNonIndexedEntities() {
" <cache-container>" +
" <local-cache name=\"" + CACHE_NAME + "\">\n" +
" <encoding media-type=\"application/x-protostream\"/>\n" +
" <indexing>\n" +
" <indexing storage=\"local-heap\">\n" +
" <indexed-entities>\n" +
" <indexed-entity>Entity</indexed-entity>\n" +
" <indexed-entity>EvilTwin</indexed-entity>\n" +
" </indexed-entities>\n" +
" <property name=\"directory.type\">local-heap</property>\n" +
" </indexing>" +
" </local-cache>" +
" </cache-container>" +
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.infinispan.client.hotrod.query;

import static org.infinispan.configuration.cache.IndexStorage.LOCAL_HEAP;
import static org.infinispan.server.hotrod.test.HotRodTestingUtil.hotRodCacheConfiguration;

import org.infinispan.configuration.cache.CacheMode;
Expand All @@ -24,8 +25,8 @@ protected void createCacheManagers() throws Throwable {

ConfigurationBuilder builder = hotRodCacheConfiguration(getDefaultClusteredCacheConfig(CacheMode.REPL_SYNC, false));
builder.indexing().enable()
.addIndexedEntity("sample_bank_account.User")
.addProperty("directory.type", "local-heap");
.storage(LOCAL_HEAP)
.addIndexedEntity("sample_bank_account.User");

for (EmbeddedCacheManager cm : cacheManagers) {
cm.defineConfiguration(TEST_CACHE, builder.build());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.infinispan.client.hotrod.query;

import static org.infinispan.configuration.cache.IndexStorage.LOCAL_HEAP;
import static org.infinispan.server.hotrod.test.HotRodTestingUtil.hotRodCacheConfiguration;

import org.infinispan.configuration.cache.CacheMode;
Expand All @@ -22,8 +23,8 @@ protected void createCacheManagers() throws Throwable {

ConfigurationBuilder builder = hotRodCacheConfiguration(getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC, false));
builder.indexing().enable()
.addIndexedEntity("sample_bank_account.User")
.addProperty("directory.type", "local-heap");
.storage(LOCAL_HEAP)
.addIndexedEntity("sample_bank_account.User");

for (EmbeddedCacheManager cm : cacheManagers) {
cm.defineConfiguration(TEST_CACHE, builder.build());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.infinispan.client.hotrod.query;

import static org.infinispan.configuration.cache.IndexStorage.LOCAL_HEAP;
import static org.infinispan.server.hotrod.test.HotRodTestingUtil.hotRodCacheConfiguration;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNotNull;
Expand Down Expand Up @@ -51,8 +52,8 @@ protected void modifyGlobalConfiguration(GlobalConfigurationBuilder builder) {
protected void createCacheManagers() throws Throwable {
ConfigurationBuilder builder = hotRodCacheConfiguration(getDefaultClusteredCacheConfig(CacheMode.REPL_SYNC, useTransactions()));
builder.indexing().enable()
.addIndexedEntity("sample_bank_account.User")
.addProperty("directory.type", "local-heap");
.storage(LOCAL_HEAP)
.addIndexedEntity("sample_bank_account.User");

createHotRodServers(3, builder);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.infinispan.client.hotrod.query;

import static org.infinispan.configuration.cache.IndexStorage.LOCAL_HEAP;
import static org.infinispan.server.hotrod.test.HotRodTestingUtil.hotRodCacheConfiguration;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertFalse;
Expand All @@ -20,7 +21,6 @@
import org.infinispan.protostream.annotations.ProtoDoc;
import org.infinispan.protostream.annotations.ProtoField;
import org.infinispan.protostream.annotations.ProtoSchemaBuilder;
import org.infinispan.query.helper.SearchConfig;
import org.infinispan.query.remote.client.ProtobufMetadataManagerConstants;
import org.testng.annotations.Test;

Expand Down Expand Up @@ -90,13 +90,10 @@ public Configuration getLuceneCacheConfig(String storeName) {
public Configuration buildIndexedConfig(String storeName) {
ConfigurationBuilder builder = hotRodCacheConfiguration(getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC, false));
builder.indexing().enable()
.addIndexedEntity("News")
.addProperty(SearchConfig.DIRECTORY_TYPE, SearchConfig.HEAP)
.addProperty(SearchConfig.IO_STRATEGY, SearchConfig.NEAR_REAL_TIME)
.addProperty(SearchConfig.COMMIT_INTERVAL, "500")
.addProperty(SearchConfig.IO_MERGE_FACTOR, "30")
.addProperty(SearchConfig.IO_MERGE_MAX_SIZE, "1024")
.addProperty(SearchConfig.IO_WRITER_RAM_BUFFER_SIZE, "256");
.storage(LOCAL_HEAP)
.writer().commitInterval(500).ramBufferSize(256)
.merge().factor(30).maxSize(1024)
.addIndexedEntity("News");

builder.memory().storageType(storageType);
if (evictionSize > 0) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.infinispan.client.hotrod.query;

import static org.infinispan.configuration.cache.IndexStorage.LOCAL_HEAP;
import static org.infinispan.server.hotrod.test.HotRodTestingUtil.hotRodCacheConfiguration;
import static org.testng.Assert.assertEquals;

Expand Down Expand Up @@ -41,9 +42,9 @@ public class MultipleIndexedCacheTest extends MultiHotRodServersTest {
public Configuration buildIndexedConfig() {
ConfigurationBuilder builder = hotRodCacheConfiguration(getDefaultClusteredCacheConfig(CacheMode.DIST_SYNC, false));
builder.indexing().enable()
.addIndexedEntity("sample_bank_account.User")
.addIndexedEntity("sample_bank_account.Account")
.addProperty("directory.type", "local-heap");
.storage(LOCAL_HEAP)
.addIndexedEntity("sample_bank_account.User")
.addIndexedEntity("sample_bank_account.Account");
return builder.build();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.infinispan.client.hotrod.query;

import static org.infinispan.configuration.cache.IndexStorage.LOCAL_HEAP;
import static org.infinispan.server.hotrod.test.HotRodTestingUtil.hotRodCacheConfiguration;
import static org.infinispan.test.fwk.TestCacheManagerFactory.createServerModeCacheManager;
import static org.testng.Assert.assertEquals;
Expand Down Expand Up @@ -63,8 +64,8 @@ public ConfigurationBuilder buildIndexedConfig() {
ConfigurationBuilder builder = hotRodCacheConfiguration(new ConfigurationBuilder());
builder.memory().storageType(storageType)
.indexing().enable()
.addIndexedEntity("sample_bank_account.User")
.addProperty("directory.type", "local-heap");
.storage(LOCAL_HEAP)
.addIndexedEntity("sample_bank_account.User");
return builder;
}

Expand Down
Loading

0 comments on commit 2701352

Please sign in to comment.