Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
otrack committed Apr 3, 2019
1 parent 818926d commit e503845
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ public int await(){
long current = getCount();
while(current != 0) {
current=getCount();
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// ignore
}
}
return ret;
}
Expand All @@ -32,8 +27,4 @@ public int getCount(){
return counter.tally();
}

public void reset(){
counter.increment(this.parties);
}

}
6 changes: 4 additions & 2 deletions client/src/main/java/org/infinispan/creson/CyclicBarrier.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

public class CyclicBarrier {

private static final int MAGIC = 10;

private AtomicCounter counter;
private AtomicCounter generation;
private int parties;
Expand All @@ -23,14 +25,14 @@ public int await(){
}

int current = generation.tally();
int backoff = 2;
int backoff = (parties - ret)/MAGIC;
while (previous == current) {
current = generation.tally();
try {
Thread.currentThread().sleep(backoff);
} catch (InterruptedException e) {
// ignore
}
current = generation.tally();
}
return ret;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ spec:
imagePullPolicy: "Always"
resources:
requests:
cpu: 0.01
cpu: 1
env:
- name: IP
valueFrom:
Expand Down
6 changes: 3 additions & 3 deletions client/src/test/bin/k8s/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ else
usage
fi
start_access ${template}
start_monitor
# start_monitor
wait_access ${template}
# sleep 300
stop_monitor
compute_throughput
# stop_monitor
# compute_throughput
fi


4 changes: 2 additions & 2 deletions client/src/test/bin/local/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ IMAGE="${MAINTAINER}/${NAME}:${TAG}"
IMAGE_ID=$(docker images | grep ${NAME} | head -n 1 | awk '{print $3}')

INSTANCES="1"
CLIENTS="100"
CALLS="1000"
CLIENTS="200"
CALLS="200"

CLIENT="infinispan-creson-client"
VERSION=$(cat ${PROJDIR}/pom.xml | grep version | head -n 1 | tr -d '[:blank:]' | sed s,\</*version\>,,g)
Expand Down
3 changes: 3 additions & 0 deletions client/src/test/java/org/infinispan/creson/Benchmark.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ public void doMain(String[] args) throws ClassNotFoundException, NoSuchMethodExc
ExecutorService service = Executors.newFixedThreadPool(clients + 1);
List<Task> clientTasks = new ArrayList<>();

// clear previous objects
factory.clear();

// create clients
Class<Task> taskClazz = (Class<Task>) ClassLoader.getSystemClassLoader().loadClass(className+"Task");
for (int i = 0; i < this.clients; i++) {
Expand Down
6 changes: 5 additions & 1 deletion core/src/main/java/org/infinispan/creson/Factory.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ public void disposeInstanceOf(Class clazz, Object key)
}

public void close() {
cache.clear();
log.info("closed");
}

Expand All @@ -246,4 +245,9 @@ public String toString() {
return "Factory[" + cache.toString() + "]";
}

public void clear(){
log.info("cleared");
cache.clear();
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.infinispan.creson.server;

import com.fasterxml.uuid.impl.RandomBasedGenerator;
import org.infinispan.commands.write.ClearCommand;
import org.infinispan.commands.write.PutKeyValueCommand;
import org.infinispan.context.InvocationContext;
import org.infinispan.creson.Factory;
Expand All @@ -12,7 +13,7 @@
import org.infinispan.creson.utils.Context;
import org.infinispan.creson.utils.ContextManager;
import org.infinispan.creson.utils.Reflection;
import org.infinispan.interceptors.distribution.NonTxDistributionInterceptor;
import org.infinispan.interceptors.impl.ClusteringInterceptor;
import org.infinispan.util.logging.Log;
import org.infinispan.util.logging.LogFactory;

Expand All @@ -28,13 +29,19 @@
import static org.infinispan.creson.utils.Reflection.callObject;
import static org.infinispan.creson.utils.Reflection.hasReadOnlyMethods;

public class StateMachineInterceptor extends NonTxDistributionInterceptor {
public class StateMachineInterceptor extends ClusteringInterceptor {

private static final Log log = LogFactory.getLog(StateMachineInterceptor.class);

private ConcurrentMap<Reference,Map<UUID,CallResponse>> lastCall = new ConcurrentHashMap<>(); // UUID == callID
private Factory factory;

@Override
public java.lang.Object visitClearCommand(InvocationContext ctx, ClearCommand command) throws Throwable {
lastCall.clear();
return super.visitClearCommand(ctx, command);
}

@Override
public java.lang.Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable {

Expand Down Expand Up @@ -128,6 +135,7 @@ public java.lang.Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyVal
log.trace(" New [" + reference + "]");

object = Reflection.open(reference, callConstruct.getInitArgs());
lastCall.get(reference).clear();

}

Expand Down

0 comments on commit e503845

Please sign in to comment.