Commit fe3229e5 authored by legoc's avatar legoc

Minor changes

parent 8803a548
<?xml version="1.0" encoding="UTF-8"?>
<config port="10000" max_applications="20" log_directory="logs" debug="OFF" polling_time="100">
<config port="10000" max_applications="200" log_directory="logs" debug="OFF" polling_time="100">
<applications>
......
......@@ -16,6 +16,7 @@
#include <cameo/cameo.h>
#include <iostream>
#include <sstream>
using namespace std;
using namespace cameo;
......@@ -32,15 +33,33 @@ int main(int argc, char *argv[]) {
requestMessage = argv[1];
}
// Get the local Cameo server.
Server& server = application::This::getServer();
string serverEndpoint;
if (argc > 2) {
serverEndpoint = argv[2];
}
int N = 1;
if (argc > 3) {
istringstream is(argv[3]);
is >> N;
}
auto_ptr<Server> server;
if (serverEndpoint == "") {
server.reset(new Server(application::This::getServer().getEndpoint()));
} else {
server.reset(new Server(serverEndpoint));
}
if (application::This::isAvailable() && server.isAvailable()) {
cout << "Connected server " << server << endl;
if (application::This::isAvailable() && server->isAvailable()) {
cout << "Connected server " << *server << endl;
}
// Connect to the server.
auto_ptr<application::Instance> responderServer = server.connect("responder-server");
auto_ptr<application::Instance> responderServer = server->connect("responder-server");
cout << "Application " << *responderServer << " has state " << application::toString(responderServer->now()) << endl;
......@@ -54,13 +73,20 @@ int main(int argc, char *argv[]) {
return -1;
}
// Send a simple message as string.
requester->send(requestMessage);
for (int i = 0; i < N; ++i) {
// Send a simple message as string.
ostringstream os;
os << requestMessage << "-" << i;
string response;
requester->receive(response);
requester->send(os.str());
string response;
requester->receive(response);
cout << "Response is " << response << endl;
}
cout << "Response is " << response << endl;
cout << "Finished the application" << endl;
}
......
......@@ -16,6 +16,7 @@
package fr.ill.ics.cameo.test;
import java.util.LinkedList;
import java.util.List;
import fr.ill.ics.cameo.Application;
......@@ -129,16 +130,18 @@ public class Test {
}
}
public static void testFastParallel(Server server) {
public static void testFastParallel(Server server, int numberOfThreads) {
server.killAllAndWaitFor("fastpar");
final Server localServer = server;
List<Thread> threads = new LinkedList<Thread>();
// start 10 threads
for (int i = 0; i < 10; ++i) {
for (int i = 0; i < numberOfThreads; ++i) {
new Thread(new Runnable()
Thread thread = new Thread(new Runnable()
{
@Override
public void run() {
......@@ -169,7 +172,17 @@ public class Test {
}
}).start();
});
thread.start();
threads.add(thread);
}
for (Thread t : threads) {
try {
t.join();
} catch (InterruptedException e) {
}
}
}
......@@ -283,7 +296,11 @@ public class Test {
} else if (testArg.equals("fastout1000")) {
testFastOut(server, 1000);
} else if (testArg.equals("fastparallel")) {
testFastParallel(server);
int numberOfThreads = 10;
if (args.length > 2) {
numberOfThreads = Integer.parseInt(args[2]);
}
testFastParallel(server, numberOfThreads);
} else if (testArg.equals("fastconnect")) {
testFastConnect(server);
} else if (testArg.equals("error")) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment