Skip to content

Commit

Permalink
[FIX] skip locking interceptor
Browse files Browse the repository at this point in the history
[FIX] align emulation and remote test
  • Loading branch information
otrack committed Jun 7, 2018
1 parent 6c067f0 commit 97d990c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 45 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package org.infinispan.creson.utils;

import org.infinispan.commands.FlagAffectedCommand;
import org.infinispan.commands.VisitableCommand;
import org.infinispan.configuration.cache.CacheMode;
import org.infinispan.configuration.cache.ConfigurationBuilder;
import org.infinispan.configuration.cache.Index;
import org.infinispan.configuration.cache.SingleFileStoreConfigurationBuilder;
import org.infinispan.context.InvocationContext;
import org.infinispan.context.impl.FlagBitSets;
import org.infinispan.creson.Factory;
import org.infinispan.creson.server.StateMachineInterceptor;
import org.infinispan.interceptors.AsyncInterceptor;
import org.infinispan.interceptors.BaseAsyncInterceptor;
import org.infinispan.interceptors.impl.CallInterceptor;
import org.infinispan.interceptors.locking.NonTransactionalLockingInterceptor;
Expand Down Expand Up @@ -42,17 +43,8 @@ public static void installCreson(
// SMR interceptor
StateMachineInterceptor stateMachineInterceptor = new StateMachineInterceptor();
builder.customInterceptors().addInterceptor().before(CallInterceptor.class).interceptor(stateMachineInterceptor);

// FIXME skip lock interceptor properly
AsyncInterceptor after = new BaseAsyncInterceptor() {
@Override
public Object visitCommand(InvocationContext ctx, VisitableCommand command) throws Throwable {
return invokeNext(ctx,command);
}
};
SkipInterceptor before = new SkipInterceptor(after);
builder.customInterceptors().addInterceptor().before(NonTransactionalLockingInterceptor.class).interceptor(before);
builder.customInterceptors().addInterceptor().after(NonTransactionalLockingInterceptor.class).interceptor(after);
builder.customInterceptors().addInterceptor().before(NonTransactionalLockingInterceptor.class).
interceptor(new ForceSkipLockInterceptor());

// clustering
builder.clustering()
Expand Down Expand Up @@ -85,17 +77,12 @@ public Object visitCommand(InvocationContext ctx, VisitableCommand command) thro

}

public static class SkipInterceptor extends BaseAsyncInterceptor{

AsyncInterceptor forward;

public SkipInterceptor(AsyncInterceptor interceptor) {
this.forward = interceptor;
}
public static class ForceSkipLockInterceptor extends BaseAsyncInterceptor{

@Override
public Object visitCommand(InvocationContext ctx, VisitableCommand command) throws Throwable {
return forward.visitCommand(ctx,command);
((FlagAffectedCommand) command).setFlagsBitSet(FlagBitSets.SKIP_LOCKING);
return invokeNext(ctx, command);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.infinispan.server.hotrod.HotRodServer;
import org.infinispan.server.hotrod.test.HotRodTestingUtil;
import org.infinispan.test.MultipleCacheManagersTest;
import org.infinispan.test.fwk.CleanupAfterTest;
import org.infinispan.test.fwk.TransportFlags;

import java.util.ArrayList;
Expand All @@ -16,6 +17,7 @@
import static org.infinispan.creson.Factory.CRESON_CACHE_NAME;
import static org.infinispan.creson.utils.ConfigurationHelper.installCreson;

@CleanupAfterTest
public class Emulation extends MultipleCacheManagersTest {

protected static final CacheMode CACHE_MODE = CacheMode.DIST_SYNC;
Expand All @@ -26,7 +28,7 @@ public class Emulation extends MultipleCacheManagersTest {
private static List<BasicCacheContainer> remoteCacheManagers = new ArrayList<>();

protected int numberOfCaches(){
return 1;
return 3;
}

private static List<HotRodServer> servers = new ArrayList<>();
Expand All @@ -37,7 +39,7 @@ private boolean addContainer() {
// embedded cache manager
TransportFlags flags = new TransportFlags();
flags.withFD(true).withMerge(true);
EmbeddedCacheManager cm = addClusterEnabledCacheManager(flags);
EmbeddedCacheManager cm = addClusterEnabledCacheManager();
installCreson(
cm,
CACHE_MODE,
Expand Down Expand Up @@ -68,10 +70,9 @@ private boolean addContainer() {
}

@Override
protected void createCacheManagers() throws Throwable {
protected void createCacheManagers() {
for (int i = 0; i< numberOfCaches(); i++) {
addContainer();
waitForClusterToForm();
System.out.println("Node " + remoteCacheManagers.get(i)+ " added.");
}
}
Expand Down
28 changes: 7 additions & 21 deletions server/src/test/java/org/infinispan/creson/test/RemoteTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
import org.infinispan.client.hotrod.RemoteCacheManager;
import org.infinispan.commons.api.BasicCacheContainer;
import org.infinispan.commons.marshall.Marshaller;
import org.infinispan.configuration.cache.CacheMode;
import org.infinispan.configuration.cache.ConfigurationBuilder;
import org.infinispan.creson.Factory;
import org.infinispan.lifecycle.ComponentStatus;
import org.infinispan.manager.EmbeddedCacheManager;
import org.infinispan.server.hotrod.HotRodServer;
import org.infinispan.server.hotrod.test.HotRodTestingUtil;
import org.infinispan.test.fwk.TransportFlags;
import org.testng.annotations.Test;

import java.util.ArrayList;
Expand All @@ -30,7 +29,6 @@ public class RemoteTest extends AbstractTest {

private static List<HotRodServer> servers = new ArrayList<>();
private static List<BasicCacheContainer> remoteCacheManagers = new ArrayList<>();
private static ConfigurationBuilder defaultBuilder;

@Override
public BasicCacheContainer container(int i) {
Expand All @@ -47,13 +45,16 @@ public boolean addContainer() {
int index = servers.size();

// embedded cache manager
EmbeddedCacheManager cm = addClusterEnabledCacheManager();
TransportFlags flags = new TransportFlags();
flags.withFD(true).withMerge(true);
EmbeddedCacheManager cm = addClusterEnabledCacheManager(flags);
installCreson(
cm,
CACHE_MODE,
REPLICATION_FACTOR, MAX_ENTRIES,
REPLICATION_FACTOR,
MAX_ENTRIES,
PASSIVATION,
PERSISTENT_STORAGE_DIR + "/" + containers().size(),
PERSISTENT_STORAGE_DIR + "/" + index,
true,
false);
waitForClusterToForm(CRESON_CACHE_NAME);
Expand Down Expand Up @@ -104,7 +105,6 @@ public boolean deleteContainer() {

@Override
protected void createCacheManagers() throws Throwable {
createDefaultBuilder();

for (int j = 0; j < NMANAGERS; j++) {
addContainer();
Expand All @@ -123,18 +123,4 @@ protected void createCacheManagers() throws Throwable {
Factory.forCache(container(0).getCache(CRESON_CACHE_NAME), true);
}

// Helpers

private void createDefaultBuilder() {
defaultBuilder = getDefaultClusteredCacheConfig(CACHE_MODE, false);
defaultBuilder
.clustering().cacheMode(CacheMode.DIST_SYNC).hash().numOwners(REPLICATION_FACTOR)
.locking().useLockStriping(false)
.compatibility().enable();
defaultBuilder.clustering().stateTransfer()
.awaitInitialTransfer(true)
.timeout(10000)
.fetchInMemoryState(true);
}

}

0 comments on commit 97d990c

Please sign in to comment.