Commit 1cc37eff authored by Nicolas Tachker's avatar Nicolas Tachker

JORAM-28: suppress the deprecated HA mode.

parent 6e38e9b4
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2009 - 2010 ScalAgent Distributed Technologies
* Copyright (C) 2009 - 2012 ScalAgent Distributed Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -36,8 +36,6 @@ public class Activator implements BundleActivator {
public static final String AGENT_SERVER_ID_PROPERTY = "fr.dyade.aaa.agent.AgentServer.id";
public static final String AGENT_SERVER_CLUSTERID_PROPERTY = "fr.dyade.aaa.agent.AgentServer.clusterid";
public static final String AGENT_SERVER_STORAGE_PROPERTY = "fr.dyade.aaa.agent.AgentServer.storage";
public static BundleContext context;
......@@ -47,10 +45,8 @@ public class Activator implements BundleActivator {
short sid = getShortProperty(AGENT_SERVER_ID_PROPERTY, (short) 0);
String path = getProperty(AGENT_SERVER_STORAGE_PROPERTY, "s" + sid);
short cid = getShortProperty(AGENT_SERVER_CLUSTERID_PROPERTY, AgentServer.NULL_ID);
try {
AgentServer.init(sid, path, null, cid);
AgentServer.init(sid, path, null);
} catch (Exception exc) {
System.out.println(AgentServer.getName() + "initialization failed: " + AgentServer.ERRORSTRING);
System.out.println(exc.toString());
......
......@@ -46,10 +46,6 @@
<artifactId>a3-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>jgroups</groupId>
<artifactId>jgroups-all</artifactId>
</dependency>
<!-- Used for MySqlDBRepository. -->
<dependency>
......
/*
* Copyright (C) 2004 - France Telecom R&D
* Copyright (C) 2004 - 2007 ScalAgent Distributed Technologies
*
* 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): ScalAgent Distributed Technologies
* Contributor(s):
*/
package fr.dyade.aaa.agent;
import java.io.Serializable;
/**
* Message used by the master component to send the server state.
*/
public class HAStateReply implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
/** Engine state */
long now;
int stamp;
byte[] agents = null;
byte[] messages = null;
/** Network state */
private byte[] clock = null;
public HAStateReply() {
}
public void setNetworkStamp(byte[] clock) {
this.clock = clock;
}
public byte[] getNetworkStamp() {
return clock;
}
public String toString() {
StringBuffer buf = new StringBuffer();
buf.append("(HAStateReply(").append(super.toString());
buf.append("now=").append(now);
buf.append(",stamp=").append(stamp);
buf.append("],clock=").append(clock);
buf.append("))");
return buf.toString();
}
}
/*
* Copyright (C) 2004 - France Telecom R&D
* Copyright (C) 2004 - 2007 ScalAgent Distributed Technologies
*
* 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): ScalAgent Distributed Technologies
* Contributor(s):
*/
package fr.dyade.aaa.agent;
import java.io.Serializable;
import org.jgroups.Address;
/**
* Message used by a slave component to request the server state.
*/
public class HAStateRequest implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* The requestor address. This address is actually unused as the
* reply is broadcasted to all components (to keep order with other
* messages).
*/
private Address addr = null;
public HAStateRequest(Address addr) {
this.addr = addr;
}
public Address getAddress() {
return addr;
}
public String toString() {
StringBuffer buf = new StringBuffer();
buf.append("(HAStateRequest(").append(super.toString());
buf.append(",addr=").append(addr).append("))");
return buf.toString();
}
}
/*
* Copyright (C) 2004 - France Telecom R&D
* Copyright (C) 2004 - 2007 ScalAgent Distributed Technologies
*
* 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): ScalAgent Distributed Technologies
* Contributor(s):
*/
package fr.dyade.aaa.agent;
/**
* Message used by the master component to braodcast the ack of a sending
* message (so each slave can remove the message from sending queue).
*/
public class JGroupsAckMsg implements java.io.Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
String name = null;
int stamp;
boolean isPersistent;
public JGroupsAckMsg(Message message) {
this.name = message.toStringId();
this.stamp = message.getStamp();
this.isPersistent = message.isPersistent();
}
/**
* Deletes the current object in persistent storage.
*/
void delete() {
if (isPersistent) {
AgentServer.getTransaction().delete(name);
}
}
int getStamp() {
return stamp;
}
public String toString() {
StringBuffer strBuf = new StringBuffer();
strBuf.append("(").append(super.toString());
strBuf.append(",name=").append(name);
strBuf.append(",stamp=").append(stamp);
strBuf.append(")");
return strBuf.toString();
}
}
......@@ -48,28 +48,6 @@ public class SimpleNetwork extends StreamNetwork {
/** FIFO list of all messages to be sent by the watch-dog thread. */
MessageSoftList sendList;
private JGroups jgroups = null;
public void setJGroups(JGroups jgroups) {
this.jgroups = jgroups;
}
void ackMsg(JGroupsAckMsg ack) {
try {
AgentServer.getTransaction().begin();
// Deletes the processed notification
qout.remove(ack.getStamp());
ack.delete();
AgentServer.getTransaction().commit(true);
if (this.logmon.isLoggable(BasicLevel.DEBUG))
this.logmon.log(BasicLevel.DEBUG,
this.getName() + ", ackMsg(...) done.");
} catch (Exception exc) {
this.logmon.log(BasicLevel.FATAL,
this.getName() + ", ackMsg unrecoverable exception", exc);
}
}
/**
* Creates a new network component.
*/
......
......@@ -75,10 +75,6 @@ public class WakeUpTask extends TimerTask {
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, "Schedule wake up task, period=" + period);
// Don't schedule on HA slaves.
if (AgentServer.isHAServer() && !AgentServer.isMasterHAServer())
return;
if (period > 0) {
try {
Timer timer = AgentServer.getTimer();
......
......@@ -43,8 +43,6 @@ public class A3CML {
static final String ELT_PROPERTY = "property";
/** Syntaxic name for nat element */
static final String ELT_NAT = "nat";
/** Syntaxic name for cluster element */
static final String ELT_CLUSTER = "cluster";
/** Syntaxic name for id attribute */
static final String ATT_ID = "id";
/** Syntaxic name for name attribute */
......@@ -126,45 +124,6 @@ public class A3CML {
out.write("\n");
}
// write all know cluster.
for (Enumeration e = config.clusters.elements();
e.hasMoreElements();) {
Object obj = e.nextElement();
if (obj instanceof A3CMLCluster) {
A3CMLCluster cluster = (A3CMLCluster) obj;
out.write(TAB + "<" + ELT_CLUSTER + " " + ATT_ID + "=\"");
out.write(Short.toString(cluster.sid));
out.write("\" " + ATT_NAME + "=\"");
out.write(cluster.name);
out.write("\">\n");
// write all cluster property
for (Enumeration e2 = cluster.properties.elements();
e2.hasMoreElements();) {
A3CMLProperty p = (A3CMLProperty) e2.nextElement();
out.write(TAB +
"<" + ELT_PROPERTY + " " +
ATT_NAME + "=\"");
out.write(p.name);
out.write("\" " +
ATT_VALUE + "=\"");
out.write(p.value);
out.write("\"/>\n");
}
out.write("\n");
for (Enumeration e2 = cluster.servers.elements();
e2.hasMoreElements();) {
Object o = e2.nextElement();
if (o instanceof A3CMLServer)
writeToXMLServer(o,out);
}
out.write(TAB + "</" + ELT_CLUSTER + ">\n");
}
out.write("\n");
}
out.write("</" + ELT_CONFIG + ">\n");
out.flush();
}
......
/*
* Copyright (C) 2001 - 2012 ScalAgent Distributed Technologies
*
* 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): Nicolas Tachker (Scalagent)
* Contributor(s):
*/
package fr.dyade.aaa.agent.conf;
import java.io.Serializable;
import java.util.Enumeration;
import java.util.Hashtable;
public class A3CMLCluster implements Serializable {
/** define serialVersionUID for interoperability */
private static final long serialVersionUID = 1L;
public short sid = -1;
public String name = null;
public String jvmArgs = null;
public Hashtable<Short, A3CMLServer> servers = null;
public Hashtable<String, A3CMLProperty> properties = null;
public A3CMLCluster(short sid,
String name) throws Exception {
this.sid = sid;
this.name = name;
this.properties = new Hashtable<String, A3CMLProperty>();
this.servers = new Hashtable<Short, A3CMLServer>();
}
/**
* Adds a server.
*
* @param server The description of added server.
* @exception DuplicateServerException
* If the server already exist.
*/
public final void addServer(A3CMLServer server) throws DuplicateServerException {
Short id = new Short(server.sid);
if (servers.containsKey(id))
throw new DuplicateServerException("Duplicate server id. #" + server.sid);
server.name = "cluster_" + sid + "_" + server.sid;
server.sid = sid;
servers.put(id, server);
}
/**
* Removes a server.
*
* @param sid The unique server identifier.
* @return The server description if exists.
* @exception UnknownServerException
* If the server does not exist.
*/
public final A3CMLServer removeServer(short sid) throws UnknownServerException {
A3CMLServer server = null;
Short id = new Short(sid);
if (servers.containsKey(id))
server = (A3CMLServer) servers.remove(id);
else
throw new UnknownServerException("Unknown server id. #" + sid);
return server;
}
/**
* Remove a server.
*
* @param name The server name.
* @return The server description if exists.
* @exception UnknownServerException
* If the server does not exist.
*/
public final A3CMLServer removeServer(String name) throws UnknownServerException {
return removeServer(getServerIdByName(name));
}
/**
* Returns true if the configuration contains a server with specified id.
*
* @param sid server id
* @return true if contain sid; false otherwise.
*/
public final boolean containsServer(short sid) {
return servers.containsKey(new Short(sid));
}
/**
* Gets a server identifier from its name.
*
* @param name The server name.
* @return The server identifier.
* @exception UnknownServerException
* If the server does not exist.
*/
public short getServerIdByName(String name) throws UnknownServerException {
for (Enumeration<A3CMLServer> s = servers.elements(); s.hasMoreElements(); ) {
A3CMLServer server = s.nextElement();
if (server.name.equals(name)) return server.sid;
}
throw new UnknownServerException("Unknown server " + name);
}
/**
* Returns true if the configuration contains a server with specified name.
*
* @param name server name
* @return true if contain name; false otherwise.
*/
public final boolean containsServer(String name) {
try {
getServerIdByName(name);
} catch (UnknownServerException exc) {
return false;
}
return true;
}
/**
* Returns the description of a server.
*
* @param name The server identifier.
* @return The server description if exist.
* @exception UnknownServerException
* If the server does not exist.
*/
public final A3CMLServer getServer(short sid) throws UnknownServerException {
A3CMLServer server = (A3CMLServer) servers.get(new Short(sid));
if (server == null)
throw new UnknownServerException("Unknown server id. #" + sid);
return server;
}
/**
* Returns the description of a server.
*
* @param name The server name.
* @return The server description if exist.
* @exception UnknownServerException
* If the server does not exist.
*/
public final A3CMLServer getServer(String name) throws UnknownServerException {
for (Enumeration<A3CMLServer> s = servers.elements(); s.hasMoreElements(); ) {
A3CMLServer server = s.nextElement();
if (server.name.equals(name)) return server;
}
throw new UnknownServerException("Unknown server id for server " + name);
}
/**
* add property
*
* @param prop A3CMLProperty
* @return the previous value of the specified prop.name in
* this hashtable, or null if it did not have one.
* @exception Exception
*/
public final A3CMLProperty addProperty(A3CMLProperty prop) throws Exception {
return (A3CMLProperty) properties.put(prop.name, prop);
}
/**
* remove property
*
* @param name property name
* @return the value to which the name had been mapped in
* this hashtable, or null if the name did not have a mapping.
*/
public final A3CMLProperty removeProperty(String name) {
return (A3CMLProperty) properties.remove(name);
}
/**
* contains property
*
* @param name property name
* @return true if contain name; false otherwise.
*/
public final boolean containsProperty(String name) {
return properties.containsKey(name);
}
/**
* Returns the specified property.
*/
public final A3CMLProperty getProperty(String name) {
return (A3CMLProperty) properties.get(name);
}
/**
* Get the JVM argument for a particular agent server identified by its id.
*
* @param id agent server identifier.
* @return the arguments as declared in configuration file
* @exception UnknownServerException
* The specified server does not exist.
*/
public final String getJvmArgs(short sid) throws UnknownServerException {
A3CMLServer server = getServer(sid);
return server.getJvmArgs();
}
/**
* Get the JVM argument for a particular agent server identified by its name.
*
* @param name agent server name.
* @return the arguments as declared in configuration file
* @exception UnknownServerException
* The specified server does not exist.
*/
public final String getJvmArgs(String name) throws UnknownServerException {
A3CMLServer server = getServer(name);
return server.getJvmArgs();
}
public String toString() {
StringBuffer strBuf = new StringBuffer();
strBuf.append("(").append(super.toString());
strBuf.append(",sid=").append(sid);
strBuf.append(",name=").append(name);
strBuf.append(",jvmArgs=").append(jvmArgs);
strBuf.append(",properties=").append(properties);
strBuf.append(",servers=").append(servers);
strBuf.append(")");
return strBuf.toString();
}
public boolean equals(Object obj) {
if (obj == null) return false;
if (obj instanceof A3CMLCluster) {
A3CMLCluster cluster = (A3CMLCluster) obj;
if (sid == cluster.sid &&
name.equals(cluster.name) &&
servers.equals(cluster.servers) &&
properties.equals(cluster.properties))
return true;
}
return false;
}
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((properties == null) ? 0 : properties.hashCode());
result = prime * result + ((servers == null) ? 0 : servers.hashCode());
result = prime * result + sid;
return result;
}
}
......@@ -42,14 +42,11 @@ public class A3CMLConfig implements Serializable {
public Hashtable<Short, A3CMLServer> servers = null;
/** Hashtable of all global properties */
public Hashtable<String, A3CMLProperty> properties = null;
/** Hashtable of all clusters */
public Hashtable<Short, A3CMLCluster> clusters = null;
public A3CMLConfig() {
domains = new Hashtable<String, A3CMLDomain>();
servers = new Hashtable<Short, A3CMLServer>();
properties = new Hashtable<String, A3CMLProperty>();
clusters = new Hashtable<Short, A3CMLCluster>();
}
/**
......@@ -107,123 +104,6 @@ public class A3CMLConfig implements Serializable {
return domain;
}
/**
* Adds a cluster.
*
* @param cluster The description of added cluster.
* @exception DuplicateClusterException
* If the cluster already exist.
*/
public final void addCluster(A3CMLCluster cluster) throws DuplicateClusterException {
Short id = new Short(cluster.sid);
if (clusters.containsKey(id))
throw new DuplicateClusterException("Duplicate cluster " + cluster.sid);
clusters.put(id, cluster);
}
/**
* Returns the description of a cluster.
*
* @param sid The cluster identifier.
* @return The cluster description if exist.
* @exception UnknownClusterException
* If the cluster does not exist.
*/
public final A3CMLCluster getCluster(short sid) throws UnknownClusterException {
A3CMLCluster cluster = (A3CMLCluster) clusters.get(new Short(sid));
if (cluster == null)
throw new UnknownClusterException("Unknown cluster id. #" + sid);
return cluster;
}
/**
* Returns the description of a cluster.
*
* @param name The cluster name.
* @return The cluster description if exist.
* @exception UnknownClusterException
* If the cluster does not exist.
*/
public final A3CMLCluster getCluster(String name) throws UnknownClusterException {
for (Enumeration<A3CMLCluster> c = clusters.elements(); c.hasMoreElements(); ) {
A3CMLCluster cluster = c.nextElement();
if (cluster.name.equals(name)) return cluster;
}
throw new UnknownClusterException("Unknown cluster id for cluster " + name);
}
/**
* Gets a cluster identifier from its name.
*
* @param name The cluster name.
* @return The cluster identifier.
* @exception UnknownClusterException
* If the cluster does not exist.
*/