Author: mriou
Date: Wed Jul 12 09:27:48 2006
New Revision: 421304
URL: http://svn.apache.org/viewvc?rev=421304&view=rev
Log:
Hot deployment now picks up modifications done will the server was stopped.
Modified:
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/DeploymentPoller.java
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/DeploymentUnit.java
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/hooks/PXEAxisServlet.java
Modified:
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/DeploymentPoller.java
URL:
http://svn.apache.org/viewvc/incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/DeploymentPoller.java?rev=421304&r1=421303&r2=421304&view=diff
==============================================================================
---
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/DeploymentPoller.java
(original)
+++
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/DeploymentPoller.java
Wed Jul 12 09:27:48 2006
@@ -6,6 +6,11 @@
import java.io.File;
import java.io.FileFilter;
import java.io.FilenameFilter;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.FileReader;
+import java.io.FileNotFoundException;
+import java.io.BufferedReader;
import java.util.HashSet;
/**
@@ -21,7 +26,6 @@
private File _deployDir;
private PollingThread _poller;
private PXEServer _pxeServer;
- private boolean _initDone = false;
/**
* Set of [EMAIL PROTECTED] DeploymentUnit} objects regarding all deployment
units that have been inspected.
@@ -50,12 +54,14 @@
public void start() {
_poller = new PollingThread();
+ readState();
_poller.start();
__log.info("Poller started.");
}
public void stop() {
_poller.kill();
+ writeState();
_poller = null;
}
@@ -72,7 +78,7 @@
try {
DeploymentUnit du = new DeploymentUnit(file, _pxeServer);
_inspectedFiles.add(du);
- du.deploy(!_initDone);
+ du.deploy(false);
__log.info("Deployment of artifact " + file.getName() + "
successful.");
} catch (Exception e) {
__log.error("Deployment of " + file.getName() + " failed, aborting
for now.", e);
@@ -93,8 +99,6 @@
_inspectedFiles.remove(du);
}
}
-
- _initDone = true;
}
/**
@@ -145,4 +149,48 @@
}
}
+ private void readState() {
+ File duState = new File(_deployDir, ".state");
+ if (duState.exists()) {
+ try {
+ BufferedReader duStateReader = new BufferedReader(new
FileReader(duState));
+ String line;
+ while ((line = duStateReader.readLine()) != null) {
+ String filename = line.substring(0, line.indexOf("|"));
+ String timestamp = line.substring(line.indexOf("|") + 1 ,
line.length());
+ DeploymentUnit du = new DeploymentUnit(new File(_deployDir,
filename), _pxeServer);
+ du.setLastModified(Long.valueOf(timestamp));
+ _inspectedFiles.add(du);
+ du.deploy(true);
+ }
+ } catch (FileNotFoundException e) {
+ // Shouldn't happen
+ } catch (IOException e) {
+ __log.error("An error occured while reading past deployments states,
some " +
+ "processes will be redeployed.", e);
+ }
+ } else {
+ __log.info("Couldn't find any deployment history, all processes will " +
+ "be redeployed.");
+ }
+ }
+
+ private void writeState() {
+ try {
+ __log.debug("Writing current deployment state.");
+ FileWriter duStateWriter = new FileWriter(new File(_deployDir,
".state"), false);
+ for (DeploymentUnit deploymentUnit : _inspectedFiles) {
+ // Somebody using pipe in their directory names don't deserve to
deploy anything
+ duStateWriter.write(deploymentUnit.getDuDirectory().getName());
+ duStateWriter.write("|");
+ duStateWriter.write(""+deploymentUnit.getLastModified());
+ duStateWriter.write("\n");
+ }
+ duStateWriter.flush();
+ duStateWriter.close();
+ } catch (IOException e) {
+ __log.error("Couldn't write deployment state! Processes could be
redeployed (or not) " +
+ "even they don't (or do) need to.", e);
+ }
+ }
}
Modified:
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/DeploymentUnit.java
URL:
http://svn.apache.org/viewvc/incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/DeploymentUnit.java?rev=421304&r1=421303&r2=421304&view=diff
==============================================================================
---
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/DeploymentUnit.java
(original)
+++
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/DeploymentUnit.java
Wed Jul 12 09:27:48 2006
@@ -154,6 +154,18 @@
return (int) (_name.hashCode() + _lastModified);
}
+ public File getDuDirectory() {
+ return _duDirectory;
+ }
+
+ public void setLastModified(long lastModified) {
+ _lastModified = lastModified;
+ }
+
+ public long getLastModified() {
+ return _lastModified;
+ }
+
public String toString() {
return "{DeploymentUnit " + _name + "}";
}
Modified:
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/hooks/PXEAxisServlet.java
URL:
http://svn.apache.org/viewvc/incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/hooks/PXEAxisServlet.java?rev=421304&r1=421303&r2=421304&view=diff
==============================================================================
---
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/hooks/PXEAxisServlet.java
(original)
+++
incubator/ode/scratch/pxe-iapi/axis/src/main/java/com/fs/pxe/axis/hooks/PXEAxisServlet.java
Wed Jul 12 09:27:48 2006
@@ -2,6 +2,7 @@
import com.fs.pxe.axis.PXEServer;
import org.apache.axis2.transport.http.AxisServlet;
+import org.apache.axis2.AxisFault;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
@@ -24,6 +25,11 @@
super.init(config);
_pxeServer = new PXEServer();
_pxeServer.init(config, axisConfiguration);
+ }
+
+ public void stop() throws AxisFault {
+ super.stop();
+ _pxeServer.shutDown();
}
}