Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
otrack committed Feb 22, 2019
1 parent 5184be1 commit cc3b54d
Show file tree
Hide file tree
Showing 15 changed files with 382 additions and 267 deletions.
18 changes: 0 additions & 18 deletions client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,6 @@

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.10</version>
<configuration>
<complianceLevel>1.8</complianceLevel>
<source>1.8</source>
<target>1.8</target>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal> <!-- use this goal to weave all your main classes -->
<goal>test-compile</goal> <!-- use this goal to weave all your test classes -->
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
Expand Down
18 changes: 18 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,24 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.10</version>
<configuration>
<complianceLevel>1.8</complianceLevel>
<source>1.8</source>
<target>1.8</target>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal> <!-- use this goal to weave all your main classes -->
<goal>test-compile</goal> <!-- use this goal to weave all your test classes -->
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
5 changes: 3 additions & 2 deletions server/src/main/bin/image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ docker build \
--no-cache \
-t "${IMAGE}" -f "${DOCKERFILE}" .

# push image
docker push "${IMAGE}"
# # push image
# docker push "${IMAGE}"

2 changes: 1 addition & 1 deletion server/src/main/bin/server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ fi

mv ${CONFIG} jgroups.xml

java -cp ${CLASSPATH} ${JVM} org.infinispan.creson.Server -server ${IP}:11222 ${EXTRA}
java -cp ${CLASSPATH} ${JVM} org.infinispan.creson.Server -server ${IP}:${PORT} ${EXTRA}
1 change: 1 addition & 0 deletions server/src/main/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ ENV BUCKET=undefined
ENV BUCKET_KEY=undefined
ENV BUCKET_SECRET=undefined
ENV IP=127.0.0.1
ENV PORT=11222
ENV JAR=$NAME-${VERSION}.jar
ENV TESTJAR=$NAME-${VERSION}-tests.jar
ENV EXTRA="-rf 1"
Expand Down
83 changes: 52 additions & 31 deletions server/src/test/bin/runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,59 @@ TAG="latest"
IMAGE="${MAINTAINER}/${NAME}:${TAG}"
IMAGE_ID=$(docker images | grep ${NAME} | head -n 1 | awk '{print $3}')

# 1. Deploy
NSERVERS=3
echo ">>>>> Starting servers..."
for i in `seq 1 ${NSERVERS}`
do
docker run --rm -p $((11221+i)):11222 ${IMAGE} 2>&1 > ${TARGETDIR}/.${i}.log &
done
up=-1
while [ ${up} != ${NSERVERS} ]; do
up=$(cat ${TARGETDIR}/.*.log | grep "LAUNCHED" | wc -l)
echo -n "."
sleep 1
done
echo " up!"
INSTANCES="1"
CLIENTS="1"
CALLS="10000"

# 2. Run
CLASSPATH=${PROJDIR}/target/*:${PROJDIR}/target/lib/*

echo ">>>>> Counters"
java -cp ${CLASSPATH} org.infinispan.creson.benchmarks.count.Benchmark -clients 10 -counters 100 -increments 1
if [ $# -ne 1 ]; then
echo "usage: config key"
exit -1
fi

echo ">>>>> Queue"
for c in $(docker ps -q --filter="ancestor=${IMAGE_ID}");
do
docker cp ${TARGETDIR}/${NAME}-tests.jar ${c}:/tmp
done
sleep 3 # that jars are read
java -cp ${CLASSPATH} org.infinispan.creson.benchmarks.queue.Benchmark -clients 10 -operations 100

# 4. Terminate
echo ">>>>> Terminate"
for c in $(docker ps -q --filter="ancestor=${IMAGE_ID}");
do
docker kill ${c}
done
if [[ "$1" == "-create" ]]
then
NSERVERS=3
echo ">>>>> Starting servers..."
for i in `seq 1 ${NSERVERS}`
do
port=$((11221+i))
docker run --net host --rm -p ${port}:${port} --env EXTRA="-rf 2" --env CLOUD=local --env PORT=${port} ${IMAGE} 2>&1 > ${TARGETDIR}/.${i}.log &
done
up=-1
while [ ${up} != ${NSERVERS} ]; do
up=$(cat ${TARGETDIR}/.*.log | grep "LAUNCHED" | wc -l)
echo -n "."
sleep 1
done
echo " up!"
elif [[ "$1" == "-counters" ]]
then
CLASS="org.infinispan.creson.benchmarks.count.Counter"
ARGS="-ea org.infinispan.creson.benchmarks.Benchmark -class ${CLASS} -instances ${INSTANCES} -clients ${CLIENTS} -calls ${CALLS} -verbose"
echo ">>>>> Counters"
java -cp ${CLASSPATH} ${ARGS}
elif [[ "$1" == "-blobs" ]]
then
echo ">>>>> Blobs"
CLASS="org.infinispan.creson.benchmarks.intensive.Blob"
ARGS="-ea org.infinispan.creson.benchmarks.Benchmark -parameters 1000 -class ${CLASS} -instances ${INSTANCES} -clients ${CLIENTS} -calls ${CALLS} -verbose"
java -cp ${CLASSPATH} ${ARGS}
elif [[ "$1" == "-queues" ]]
then
echo ">>>>> Queue"
for c in $(docker ps -q --filter="ancestor=${IMAGE_ID}");
do
docker cp ${TARGETDIR}/${NAME}-tests.jar ${c}:/tmp
done
sleep 3 # that jars are read
java -cp ${CLASSPATH} org.infinispan.creson.benchmarks.queue.Benchmark -clients 10 -operations 100
elif [[ "$1" == "-delete" ]]
then
echo ">>>>> Terminate"
for c in $(docker ps -q --filter="ancestor=${IMAGE_ID}");
do
docker kill ${c}
done
fi
10 changes: 4 additions & 6 deletions server/src/test/bin/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ N_CLIENTS=100
N_OPS=10000
N_PAR=1

random_transfer(){
from=$((RANDOM % N_ACCOUNTS))
to=$((RANDOM % N_ACCOUNTS))
amount=$((RANDOM))
transfer ${from} ${to} ${amount}
}
if [ $# -ne 1 ]; then
echo "usage: config key"
exit -1
fi

if [[ "$1" == "-create" ]]
then
Expand Down
146 changes: 146 additions & 0 deletions server/src/test/java/org/infinispan/creson/benchmarks/Benchmark.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
package org.infinispan.creson.benchmarks;

import org.infinispan.creson.Factory;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;


/**
* @author Pierre Sutra
*/
public class Benchmark {


@Option(name = "-class", required = true, usage = "object class")
String className;

@Option(name = "-parameters", usage = "parameters of the call ")
String[] parameters;

@Option(name = "-instances", required = true, usage = "#instances")
int instances;

@Option(name = "-clients", required = true, usage = "#clients")
int clients;

@Option(name = "-calls", required = true, usage = "#calls per client")
int calls;

@Option(name = "-server", usage = "connection string to server")
String server = "127.0.0.1:11222";

@Option(name = "-verbose", usage = "real-time report of total throughput (in ops/sec)")
boolean verbosity = false;


public static void main(String args[]) throws ClassNotFoundException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
new Benchmark().doMain(args);
System.exit(0);
}

public void doMain(String[] args) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {

CmdLineParser parser = new CmdLineParser(this);
parser.setUsageWidth(80);
try {
if (args.length < 6)
throw new CmdLineException(parser, "Not enough arguments are given.");
parser.parseArgument(args);
} catch (CmdLineException e) {
System.err.println(e.getMessage());
parser.printUsage(System.err);
System.err.println();
return;
}

Factory factory = Factory.get(server);
ExecutorService service = Executors.newFixedThreadPool(clients + 1);

// create instances
List<Object> objects = new ArrayList<>();
for (int i = 0; i < instances; i++) {
Class<Object> clazz = (Class<Object>) ClassLoader.getSystemClassLoader().loadClass(className);
Object object = factory.getInstanceOf(clazz,"object"+i);
objects.add(object);
}

// create clients clients
List<Task> clients = new ArrayList<>();
for (int i = 0; i < this.clients; i++) {
Class<Task> clazz = (Class<Task>) ClassLoader.getSystemClassLoader().loadClass(className+"Task");
Task task = clazz.getConstructor(List.class, String[].class, int.class).newInstance(objects , parameters, calls);
clients.add(task);
}

// run clients then print results
try {

if (verbosity)
service.submit(new TroughtputReporter(clients));

List<Future<Double>> futures = service.invokeAll(clients);

double avgTime = 0;
for (Future<Double> future : futures) {
try {
avgTime += future.get();
} catch (InterruptedException e) {
e.printStackTrace();
}
}

avgTime = avgTime / futures.size();
System.out.println("Average time: " + avgTime + " [Throughput=" + (1 / avgTime) * clients.size() + "]");

} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}

factory.close();
}

private static class TroughtputReporter implements Callable<Void> {

private List<Task> tasks;

public TroughtputReporter(List<Task> tasks) {
this.tasks = tasks;
}

@Override
public Void call() throws Exception {
boolean isOver = false;
int throughput = 0;
while (!isOver) {
Thread.sleep(10000);
throughput = 0;
for (Task callable : tasks) {
isOver |= callable.getIsOver();
throughput += callable.getLastThroughput();
}
System.out.println(+ System.currentTimeMillis() + ":" + throughput);
}

throughput = 0;
for (Task callable : tasks) {
throughput += callable.getThroughput();
}

System.out.println("Throughput:" + System.currentTimeMillis() + ":" + throughput);

return null;
}
}

}

Loading

0 comments on commit cc3b54d

Please sign in to comment.