Commit 4940abc8 authored by Ahmed El Rheddane's avatar Ahmed El Rheddane
Browse files

- En-tetes ajoutes.

- Correction de qq bugs.
parent a80ba06b
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2013 - 2014 ScalAgent Distributed Technologies
* Copyright (C) 2013 - 2014 Université Joseph Fourier
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s): Université Joseph Fourier
* Contributor(s): ScalAgent Distributed Technologies
*/
package elasticity.eval;
class Constants {
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2013 - 2014 ScalAgent Distributed Technologies
* Copyright (C) 2013 - 2014 Université Joseph Fourier
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s): Université Joseph Fourier
* Contributor(s): ScalAgent Distributed Technologies
*/
package elasticity.eval;
import javax.jms.BytesMessage;
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2013 - 2014 ScalAgent Distributed Technologies
* Copyright (C) 2013 - 2014 Université Joseph Fourier
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s): Université Joseph Fourier
* Contributor(s): ScalAgent Distributed Technologies
*/
package elasticity.eval;
import java.util.Properties;
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2013 - 2014 ScalAgent Distributed Technologies
* Copyright (C) 2013 - 2014 Université Joseph Fourier
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s): Université Joseph Fourier
* Contributor(s): ScalAgent Distributed Technologies
*/
package elasticity.eval;
import javax.jms.Connection;
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2013 - 2014 ScalAgent Distributed Technologies
* Copyright (C) 2013 - 2014 Université Joseph Fourier
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s): Université Joseph Fourier
* Contributor(s): ScalAgent Distributed Technologies
*/
package elasticity.interfaces;
import java.util.logging.FileHandler;
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2013 - 2014 ScalAgent Distributed Technologies
* Copyright (C) 2013 - 2014 Université Joseph Fourier
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s): Université Joseph Fourier
* Contributor(s): ScalAgent Distributed Technologies
*/
package elasticity.interfaces;
import java.util.Properties;
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2013 - 2014 ScalAgent Distributed Technologies
* Copyright (C) 2013 - 2014 Université Joseph Fourier
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s): Université Joseph Fourier
* Contributor(s): ScalAgent Distributed Technologies
*/
package elasticity.loop;
import java.io.FileInputStream;
......@@ -34,8 +58,6 @@ public class ControlLoop {
e.printStackTrace(System.out);
return;
}
System.out.println("[ControlLoop]\tFetched Properties..");
......@@ -48,9 +70,6 @@ public class ControlLoop {
e.printStackTrace(System.out);
return;
}
System.out.println("[ControlLoop]\tInitialized ES, ENTER to continue...");
long start,wait;
long fix = 0;
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2013 - 2014 ScalAgent Distributed Technologies
* Copyright (C) 2013 - 2014 Université Joseph Fourier
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s): Université Joseph Fourier
* Contributor(s): ScalAgent Distributed Technologies
*/
package elasticity.old;
import org.objectweb.joram.client.jms.Queue;
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2013 - 2014 ScalAgent Distributed Technologies
* Copyright (C) 2013 - 2014 Université Joseph Fourier
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s): Université Joseph Fourier
* Contributor(s): ScalAgent Distributed Technologies
*/
package elasticity.old;
public class Constants {
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2013 - 2014 ScalAgent Distributed Technologies
* Copyright (C) 2013 - 2014 Université Joseph Fourier
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s): Université Joseph Fourier
* Contributor(s): ScalAgent Distributed Technologies
*/
package elasticity.old;
import java.util.ArrayList;
......
package elasticity.services;
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2013 - 2014 ScalAgent Distributed Technologies
* Copyright (C) 2013 - 2014 Université Joseph Fourier
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s): Université Joseph Fourier
* Contributor(s): ScalAgent Distributed Technologies
*/
package elasticity.services;
import java.io.InputStream;
import java.io.FileInputStream;
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2013 - 2014 ScalAgent Distributed Technologies
* Copyright (C) 2013 - 2014 Université Joseph Fourier
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s): Université Joseph Fourier
* Contributor(s): ScalAgent Distributed Technologies
*/
package elasticity.services;
import java.util.ArrayList;
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2013 - 2014 ScalAgent Distributed Technologies
* Copyright (C) 2013 - 2014 Université Joseph Fourier
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s): Université Joseph Fourier
* Contributor(s): ScalAgent Distributed Technologies
*/
package elasticity.services;
import java.io.File;
......@@ -20,7 +44,7 @@ import org.objectweb.joram.client.jms.tcp.TcpConnectionFactory;
import elasticity.interfaces.Service;
/**
* Joram service, manages Joram workers.
* Joram service, manages Joram workers (queues + consumers).
*
* @author Ahmed El Rheddane
*
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2001 - ScalAgent Distributed Technologies
* Copyright (C) 1996 - Dyade
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s): Frederic Maistre (INRIA)
* Contributor(s): Ahmed El Rheddane (INRIA)
*/
package elasticity.topics.client;
import javax.jms.ConnectionFactory;
......@@ -7,35 +31,39 @@ import javax.jms.MessageListener;
import org.objectweb.joram.client.jms.Topic;
import org.objectweb.joram.client.jms.tcp.TcpConnectionFactory;
/**
* Wraps the standard JMS listener to handle reconnection messages.
*
* @author Ahmed El Rheddane
*
*/
public class ListenerWrapper implements MessageListener {
/** Related Subscriber Wrapper. */
private SubscriberWrapper sw;
private SubscriberThread st;
public ListenerWrapper(SubscriberWrapper sw) {
this.sw = sw;
public ListenerWrapper(SubscriberThread st) {
this.st = st;
}
@Override
public void onMessage(Message m) {
try {
if (m.propertyExists("reconnect")) {
System.out.println("HEY HEY HEY!!");
if (st.end) {
// Ignore message (avoids doubles)
return;
} else if (m.propertyExists("reconnect")) {
String tid = m.getStringProperty("reconnect");
String server = m.getStringProperty("server");
int port = m.getIntProperty("port");
Topic topic = Topic.createTopic(tid,null);
ConnectionFactory cf = TcpConnectionFactory.create(server, port);
sw.reconnect(topic,cf);
} else if (sw.reconnecting) {
// Should make sure that each message is
// processed only once.
ConnectionFactory cf = TcpConnectionFactory.create(server, port);
System.out.println("Should reconnect to:" + cf);
st.sw.reconnect(topic,cf);
} else {
sw.listener.onMessage(m);
st.sw.listener.onMessage(m);
}
} catch(Exception e) {
e.printStackTrace();
......
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2001 - ScalAgent Distributed Technologies
* Copyright (C) 1996 - Dyade
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Initial developer(s): Frederic Maistre (INRIA)
* Contributor(s): Ahmed El Rheddane (INRIA)
*/
package elasticity.topics.client;
import javax.jms.Connection;
......@@ -6,11 +30,17 @@ import javax.jms.MessageConsumer;
import javax.jms.Session;
import javax.jms.Topic;
/**
* Defines a JMS subscriber's execution.
*
* @author Ahmed El Rheddane
*
*/
public class SubscriberThread extends Thread {
Topic topic;
ConnectionFactory cf;
SubscriberWrapper sw;
ListenerWrapper lw;
boolean end;
......@@ -18,7 +48,7 @@ public class SubscriberThread extends Thread {
this.topic = topic;
this.cf = cf;
this.sw = sw;
this.lw = new ListenerWrapper(this);
end = false;
}
......@@ -28,10 +58,10 @@ public class SubscriberThread extends Thread {
Connection cnx = cf.createConnection();
Session sess = cnx.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer c = sess.createConsumer(topic);
c.setMessageListener(new ListenerWrapper(sw));
c.setMessageListener(lw);
cnx.start();
System.out.println("Matrix Reloaded.");
System.out.println("(Re)connected to: " + cf);
sw.reconnected();
while (!end) {
......@@ -39,7 +69,7 @@ public class SubscriberThread extends Thread {
}
cnx.close();
System.out.println("This is the end, my only friend.");
System.out.println("Disconnected from: " + cf);
} catch (Exception e) {
e.printStackTrace();
}
......@@ -48,5 +78,4 @@ public class SubscriberThread extends Thread {
protected void terminate() {
end = true;
}
}
......@@ -5,7 +5,7 @@ import javax.jms.MessageListener;
import javax.jms.Topic;
/**
* Creates subscribers on specified topic.
* Wraps JMS subscriber to handle reconnection.
*
* @author Ahmed El Rheddane
*
......@@ -18,7 +18,6 @@ public class SubscriberWrapper {
* Listener specified by the user.
*/
MessageListener listener;
boolean reconnecting;
SubscriberThread t0;
SubscriberThread t1;
......@@ -27,8 +26,6 @@ public class SubscriberWrapper {
this.topic = topic;
this.cf = cf;
this.listener = listener;
this.reconnecting = false;
}
public void start() {
......@@ -44,21 +41,15 @@ public class SubscriberWrapper {
if (t1 != null) {
t1.terminate();
}
reconnecting = false;
}
void reconnect(Topic topic, ConnectionFactory cf) {
reconnecting = true;
t1 = t0;
t0 = new SubscriberThread(topic,cf,this);
t0.start();
}
void reconnected() {
reconnecting = false;
if (t1 != null) {
t1.terminate();
}
......