Skip to content

Commit

Permalink
ISPN-9201 Do not forget to apply Hot Rod flags to the cache before pe…
Browse files Browse the repository at this point in the history
…rforming ops

- Also modify the reindex test to use a proper index-assisted query
  • Loading branch information
tristantarrant authored and Gustavo Fernandes committed May 23, 2018
1 parent 658cf66 commit 8fd20db
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.Collections; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;


Expand All @@ -17,8 +17,7 @@
import org.infinispan.client.hotrod.Search; import org.infinispan.client.hotrod.Search;
import org.infinispan.client.hotrod.exceptions.HotRodClientException; import org.infinispan.client.hotrod.exceptions.HotRodClientException;
import org.infinispan.client.hotrod.marshall.ProtoStreamMarshaller; import org.infinispan.client.hotrod.marshall.ProtoStreamMarshaller;
import org.infinispan.client.hotrod.query.testdomain.protobuf.AddressPB; import org.infinispan.client.hotrod.query.testdomain.protobuf.TransactionPB;
import org.infinispan.client.hotrod.query.testdomain.protobuf.UserPB;
import org.infinispan.client.hotrod.query.testdomain.protobuf.marshallers.MarshallerRegistration; import org.infinispan.client.hotrod.query.testdomain.protobuf.marshallers.MarshallerRegistration;
import org.infinispan.client.hotrod.test.HotRodClientTestingUtil; import org.infinispan.client.hotrod.test.HotRodClientTestingUtil;
import org.infinispan.client.hotrod.test.MultiHotRodServersTest; import org.infinispan.client.hotrod.test.MultiHotRodServersTest;
Expand All @@ -31,7 +30,7 @@
import org.infinispan.configuration.global.GlobalConfigurationBuilder; import org.infinispan.configuration.global.GlobalConfigurationBuilder;
import org.infinispan.configuration.internal.PrivateGlobalConfigurationBuilder; import org.infinispan.configuration.internal.PrivateGlobalConfigurationBuilder;
import org.infinispan.manager.EmbeddedCacheManager; import org.infinispan.manager.EmbeddedCacheManager;
import org.infinispan.query.dsl.embedded.testdomain.Address; import org.infinispan.query.dsl.embedded.testdomain.Transaction;
import org.infinispan.query.dsl.embedded.testdomain.User; import org.infinispan.query.dsl.embedded.testdomain.User;
import org.infinispan.query.remote.client.ProtobufMetadataManagerConstants; import org.infinispan.query.remote.client.ProtobufMetadataManagerConstants;
import org.infinispan.server.core.admin.embeddedserver.EmbeddedServerAdminOperationHandler; import org.infinispan.server.core.admin.embeddedserver.EmbeddedServerAdminOperationHandler;
Expand Down Expand Up @@ -145,26 +144,24 @@ public void cacheReindexTest(Method m) throws IOException {


// Create the cache // Create the cache
client(0).administration().createCache(cacheName, "template"); client(0).administration().createCache(cacheName, "template");
RemoteCache<Object, Object> cache = client(0).getCache(cacheName); RemoteCache<String, Transaction> cache = client(0).getCache(cacheName);
User user1 = new UserPB(); Transaction tx = new TransactionPB();
user1.setId(1); tx.setId(1);
user1.setName("Tom"); tx.setAccountId(777);
user1.setSurname("Cat"); tx.setAmount(500);
user1.setGender(User.Gender.MALE); tx.setDate(new Date(1));
user1.setAccountIds(Collections.singleton(12)); tx.setDescription("February rent");
Address address1 = new AddressPB(); tx.setLongDescription("February rent");
address1.setStreet("Dark Alley"); tx.setNotes("card was not present");
address1.setPostCode("1234"); cache.withFlags(Flag.SKIP_INDEXING).put("tx", tx);
user1.setAddresses(Collections.singletonList(address1)); verifyQuery(cache, 0);
cache.withFlags(Flag.SKIP_INDEXING).put(0, user1);
verifyUserQuery(cache, 0);
client(0).administration().reindexCache(cacheName); client(0).administration().reindexCache(cacheName);
verifyUserQuery(cache, 1); verifyQuery(cache, 1);
client(0).administration().removeCache(cacheName); client(0).administration().removeCache(cacheName);
} }


private void verifyUserQuery(RemoteCache<Object, Object> cache, int count) { private void verifyQuery(RemoteCache<String, Transaction> cache, int count) {
List<User> users = Search.getQueryFactory(cache).create("from sample_bank_account.User where name='Tom'").list(); List<User> users = Search.getQueryFactory(cache).create("from sample_bank_account.Transaction where longDescription:'RENT'").list();
assertEquals(count, users.size()); assertEquals(count, users.size());
} }


Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -389,7 +389,6 @@ public AdvancedCache<byte[], byte[]> cache(CacheDecodeContext cdc) throws Reques
} else { } else {
cache = getCacheInstance(cdc, cacheName, cacheManager, true, true); cache = getCacheInstance(cdc, cacheName, cacheManager, true, true);
} }
return cache;
} }
cache = cdc.decoder.getOptimizedCache(cdc.header, cache, getCacheConfiguration(cacheName)); cache = cdc.decoder.getOptimizedCache(cdc.header, cache, getCacheConfiguration(cacheName));
if (cdc.subject != null) { if (cdc.subject != null) {
Expand Down

0 comments on commit 8fd20db

Please sign in to comment.