Skip to content

Commit

Permalink
ISPN-6907: Repl/Dist cache with Transactions doesn't respect shared s…
Browse files Browse the repository at this point in the history
…tore semantics
  • Loading branch information
ryanemerson authored and wburns committed Aug 3, 2016
1 parent b7cd714 commit d3a177b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
Expand Up @@ -422,7 +422,7 @@ public Object visitApplyDeltaCommand(InvocationContext ctx, ApplyDeltaCommand co
ice = entryFactory.create(entry); ice = entryFactory.create(entry);
} }
MarshalledEntryImpl marshalledEntry = new MarshalledEntryImpl(ice.getKey(), ice.getValue(), internalMetadata(ice), marshaller); MarshalledEntryImpl marshalledEntry = new MarshalledEntryImpl(ice.getKey(), ice.getValue(), internalMetadata(ice), marshaller);
persistenceManager.writeToAllNonTxStores(marshalledEntry, command.hasFlag(Flag.SKIP_SHARED_CACHE_STORE) ? PRIVATE : BOTH); persistenceManager.writeToAllNonTxStores(marshalledEntry, skipSharedStores(ctx, command.getKey(), command) ? PRIVATE : BOTH);
} }
return null; return null;
} }
Expand All @@ -444,7 +444,7 @@ public Object visitPutMapCommand(InvocationContext ctx, PutMapCommand command) t
public Object visitRemoveCommand(InvocationContext ctx, RemoveCommand command) throws Throwable { public Object visitRemoveCommand(InvocationContext ctx, RemoveCommand command) throws Throwable {
Object key = command.getKey(); Object key = command.getKey();
if (isProperWriter(ctx, command, key)) { if (isProperWriter(ctx, command, key)) {
persistenceManager.deleteFromAllStores(key, BOTH); persistenceManager.deleteFromAllStores(key, skipSharedStores(ctx, key, command) ? PRIVATE : BOTH);
} }
return null; return null;
} }
Expand All @@ -460,7 +460,7 @@ protected Object visitSingleStore(InvocationContext ctx, FlagAffectedCommand com
if (generateStatistics) putCount++; if (generateStatistics) putCount++;
InternalCacheValue sv = entryFactory.getValueFromCtxOrCreateNew(key, ctx); InternalCacheValue sv = entryFactory.getValueFromCtxOrCreateNew(key, ctx);
MarshalledEntryImpl me = new MarshalledEntryImpl(key, sv.getValue(), internalMetadata(sv), marshaller); MarshalledEntryImpl me = new MarshalledEntryImpl(key, sv.getValue(), internalMetadata(sv), marshaller);
persistenceManager.writeToAllNonTxStores(me, command.hasFlag(Flag.SKIP_SHARED_CACHE_STORE) ? PRIVATE : BOTH); persistenceManager.writeToAllNonTxStores(me, skipSharedStores(ctx, key, command) ? PRIVATE : BOTH);
} }
return null; return null;
} }
Expand Down
Expand Up @@ -3,6 +3,7 @@
import org.infinispan.configuration.cache.ConfigurationBuilder; import org.infinispan.configuration.cache.ConfigurationBuilder;
import org.infinispan.persistence.dummy.DummyInMemoryStore; import org.infinispan.persistence.dummy.DummyInMemoryStore;
import org.infinispan.persistence.dummy.DummyInMemoryStoreConfigurationBuilder; import org.infinispan.persistence.dummy.DummyInMemoryStoreConfigurationBuilder;
import org.infinispan.persistence.spi.CacheLoader;


/** /**
* DistSyncCacheStoreTest. * DistSyncCacheStoreTest.
Expand All @@ -26,4 +27,11 @@ protected ConfigurationBuilder buildConfiguration() {
} }
return cfg; return cfg;
} }

protected void assertNumberOfInvocations(CacheLoader cs, String method, int expected) {
int actual = ((DummyInMemoryStore) cs).stats().get(method);
assert expected == actual : "Expected " + expected + " but was " + actual;
}


} }
Expand Up @@ -104,12 +104,6 @@ public void testPutFromOwner() throws Exception {
assertOnAllCachesAndOwnership(key, value); assertOnAllCachesAndOwnership(key, value);
} }


private void assertNumberOfInvocations(CacheLoader cs, String method, int expected) {
int actual = ((DummyInMemoryStore) cs).stats().get(method);
assert expected == actual : "Expected " + expected + " but was " + actual;
}


public void testPutAll() throws Exception { public void testPutAll() throws Exception {
log.trace("Here it begins"); log.trace("Here it begins");
String k1 = "1", v1 = "one", k2 = "2", v2 = "two", k3 = "3", v3 = "three", k4 = "4", v4 = "four"; String k1 = "1", v1 = "one", k2 = "2", v2 = "two", k3 = "3", v3 = "three", k4 = "4", v4 = "four";
Expand Down
Expand Up @@ -18,12 +18,8 @@
public class DistSyncTxStoreSharedTest extends BaseDistStoreTest { public class DistSyncTxStoreSharedTest extends BaseDistStoreTest {


public DistSyncTxStoreSharedTest() { public DistSyncTxStoreSharedTest() {
sync = true;
tx = true; tx = true;
testRetVals = true;
shared = true; shared = true;
INIT_CLUSTER_SIZE = 2;
numOwners = 1;
} }


public void testPutFromNonOwner() throws Exception { public void testPutFromNonOwner() throws Exception {
Expand All @@ -33,6 +29,7 @@ public void testPutFromNonOwner() throws Exception {
assertEquals("v1", cacheX.get("key1")); assertEquals("v1", cacheX.get("key1"));
assertNotNull(storeX.load("key1")); assertNotNull(storeX.load("key1"));
assertEquals("v1", storeX.load("key1").getValue()); assertEquals("v1", storeX.load("key1").getValue());
assertNumberOfInvocations(storeX, "write", 1); // Shared store, so only one node should have written the change
} }


} }

0 comments on commit d3a177b

Please sign in to comment.