You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by az...@apache.org on 2007/07/14 17:56:34 UTC
svn commit: r556294 - in
/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering:
ClusteringUtils.java control/GetConfigurationResponseCommand.java
Author: azeez
Date: Sat Jul 14 08:56:33 2007
New Revision: 556294
URL: http://svn.apache.org/viewvc?view=rev&rev=556294
Log:
Should remove service groups which have not been loaded by a randomly selected neighbour
Modified:
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/ClusteringUtils.java
webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/control/GetConfigurationResponseCommand.java
Modified: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/ClusteringUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/ClusteringUtils.java?view=diff&rev=556294&r1=556293&r2=556294
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/ClusteringUtils.java (original)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/ClusteringUtils.java Sat Jul 14 08:56:33 2007
@@ -30,50 +30,51 @@
import java.util.Random;
/**
- *
+ * A Utility for handling some of the functions needed by the clustering implementation
*/
public class ClusteringUtils {
- private static final Log log = LogFactory.getLog(ClusteringUtils.class);
-
- public static boolean isURL(String location) {
- try {
- new URL(location);
- return true;
- } catch (MalformedURLException e) {
- return false;
- }
- }
-
+ /**
+ * Load a ServiceGroup having name <code>serviceGroupName</code>
+ *
+ * @param serviceGroupName
+ * @param configCtx
+ * @param tempDirectory
+ * @throws Exception
+ */
public static void loadServiceGroup(String serviceGroupName,
ConfigurationContext configCtx,
String tempDirectory) throws Exception {
if (!serviceGroupName.endsWith(".aar")) {
serviceGroupName += ".aar";
}
+ File serviceArchive;
+ String axis2Repo = System.getProperty(Constants.AXIS2_REPO);
+ if (isURL(axis2Repo)) {
+ DataHandler dh = new DataHandler(new URL(axis2Repo + "services/" + serviceGroupName));
+ String tempDir =
+ tempDirectory + File.separator +
+ (System.currentTimeMillis() + new Random().nextDouble());
+ new File(tempDir).mkdirs();
+ serviceArchive = new File(tempDir + File.separator + serviceGroupName);
+ FileOutputStream out = new FileOutputStream(serviceArchive);
+ dh.writeTo(out);
+ out.close();
+ } else {
+ serviceArchive = new File(axis2Repo + File.separator + "services" +
+ File.separator + serviceGroupName);
+ }
+ AxisServiceGroup asGroup =
+ DeploymentEngine.loadServiceGroup(serviceArchive, configCtx);
+ configCtx.getAxisConfiguration().addServiceGroup(asGroup);
+ }
+
+ private static boolean isURL(String location) {
try {
- File serviceArchive;
- String axis2Repo = System.getProperty(Constants.AXIS2_REPO);
- if (isURL(axis2Repo)) {
- DataHandler dh = new DataHandler(new URL(axis2Repo + "services/" + serviceGroupName));
- String tempDir =
- tempDirectory + File.separator +
- (System.currentTimeMillis() + new Random().nextDouble());
- new File(tempDir).mkdirs();
- serviceArchive = new File(tempDir + File.separator + serviceGroupName);
- FileOutputStream out = new FileOutputStream(serviceArchive);
- dh.writeTo(out);
- out.close();
- } else {
- serviceArchive = new File(axis2Repo + File.separator + "services" +
- File.separator + serviceGroupName);
- }
- AxisServiceGroup asGroup =
- DeploymentEngine.loadServiceGroup(serviceArchive, configCtx);
- configCtx.getAxisConfiguration().addServiceGroup(asGroup);
- } catch (Exception e) {
- log.error(e);
- throw e;
+ new URL(location);
+ return true;
+ } catch (MalformedURLException e) {
+ return false;
}
}
}
Modified: webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/control/GetConfigurationResponseCommand.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/control/GetConfigurationResponseCommand.java?view=diff&rev=556294&r1=556293&r2=556294
==============================================================================
--- webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/control/GetConfigurationResponseCommand.java (original)
+++ webservices/axis2/trunk/java/modules/clustering/src/org/apache/axis2/clustering/control/GetConfigurationResponseCommand.java Sat Jul 14 08:56:33 2007
@@ -20,8 +20,13 @@
import org.apache.axis2.clustering.ClusteringUtils;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.description.AxisServiceGroup;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.AxisModule;
+import org.apache.axis2.AxisFault;
import java.io.FileNotFoundException;
+import java.util.Iterator;
/**
*
@@ -30,24 +35,61 @@
private String[] serviceGroups;
- public void execute(ConfigurationContext configurationContext) throws ClusteringFault {
- AxisConfiguration axisConfig = configurationContext.getAxisConfiguration();
+ public void execute(ConfigurationContext configContext) throws ClusteringFault {
+ AxisConfiguration axisConfig = configContext.getAxisConfiguration();
// Run this code only if this node is not already initialized
- if (configurationContext.
+ if (configContext.
getPropertyNonReplicable(ClusteringConstants.CLUSTER_INITIALIZED) == null) {
if (serviceGroups != null) {
+
+ // Load all the service groups that are sent by the neighbour
for (int i = 0; i < serviceGroups.length; i++) {
String serviceGroup = serviceGroups[i];
if (axisConfig.getServiceGroup(serviceGroup) == null) {
//Load the service group
try {
ClusteringUtils.loadServiceGroup(serviceGroup,
- configurationContext,
+ configContext,
System.getProperty("axis2.work.dir")); //TODO: Introduce a constant. work dir is a temp dir.
} catch (FileNotFoundException ignored) {
} catch (Exception e) {
throw new ClusteringFault(e);
+ }
+ }
+ }
+
+ // Unload all service groups which were not sent by the neighbour,
+ // but have been currently loaded
+ for (Iterator iter = axisConfig.getServiceGroups(); iter.hasNext();) {
+ AxisServiceGroup serviceGroup = (AxisServiceGroup) iter.next();
+ boolean foundServiceGroup = false;
+ for (int i = 0; i < serviceGroups.length; i++) {
+ String serviceGroupName = serviceGroups[i];
+ if (serviceGroup.getServiceGroupName().equals(serviceGroupName)) {
+ foundServiceGroup = true;
+ break;
+ }
+ }
+ if (!foundServiceGroup) {
+ boolean mustUnloadServiceGroup = true;
+ // Verify that this service was not loaded from within a module
+ // If so, we must not unload such a service
+ for (Iterator serviceIter = serviceGroup.getServices();
+ serviceIter.hasNext();) {
+ AxisService service = (AxisService) serviceIter.next();
+ if (service.isClientSide() ||
+ service.getParameter(AxisModule.MODULE_SERVICE) != null) {
+ mustUnloadServiceGroup = false;
+ break; // Do not unload service groups containing client side services
+ }
+ }
+ if (mustUnloadServiceGroup) {
+ try {
+ axisConfig.removeServiceGroup(serviceGroup.getServiceGroupName());
+ } catch (Exception e) {
+ throw new ClusteringFault(e);
+ }
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org