User: schaefera
Date: 01/11/12 11:59:17
Modified: src/main/org/jboss/ha/framework/server ClusterPartition.java
FarmMemberService.java
Log:
Finished 1. Version of the JBoss Farm. Now it uses the AutoDeployer and
therefore FarmAutoDeployer became obsolete. The Farm now support also
undeployment, copies a deployed file back to /deploy/farm when on a
remote node and also removes it from there when undeployed on a remote
node.
Revision Changes Path
1.6 +3 -7
jbossmx/src/main/org/jboss/ha/framework/server/ClusterPartition.java
Index: ClusterPartition.java
===================================================================
RCS file:
/cvsroot/jboss/jbossmx/src/main/org/jboss/ha/framework/server/ClusterPartition.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ClusterPartition.java 2001/11/11 19:04:25 1.5
+++ ClusterPartition.java 2001/11/12 19:59:17 1.6
@@ -24,7 +24,7 @@
*
* @author [EMAIL PROTECTED]
* @author [EMAIL PROTECTED]
- * @version $Revision: 1.5 $
+ * @version $Revision: 1.6 $
*
* <p><b>Revisions:</b><br>
*/
@@ -108,7 +108,7 @@
return this.partition;
}
- public void initService() throws Exception
+ public void startService() throws Exception
{
log.info ("Creating JavaGroups JChannel");
this.channel = new JChannel(jgProps);
@@ -122,12 +122,8 @@
log.info("...Initing HAPartition...");
partition.init();
-
log.info("...HAPartition initialized.");
- }
-
- public void startService() throws Exception
- {
+
log.info("Starting ClusterPartition: " + partitionName);
log.info(" Connecting to channel");
1.2 +76 -2
jbossmx/src/main/org/jboss/ha/framework/server/FarmMemberService.java
Index: FarmMemberService.java
===================================================================
RCS file:
/cvsroot/jboss/jbossmx/src/main/org/jboss/ha/framework/server/FarmMemberService.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- FarmMemberService.java 2001/11/12 04:24:18 1.1
+++ FarmMemberService.java 2001/11/12 19:59:17 1.2
@@ -64,7 +64,7 @@
* </ul>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Andreas Schaefer</a>
- * @version $Revision: 1.1 $ <p>
+ * @version $Revision: 1.2 $ <p>
*
* <b>Revisions:</b> <p>
*
@@ -135,7 +135,7 @@
IOException,
DeploymentException
{
-// undeploy( new URL( pFileURL ) );
+ undeploy( new URL( pFileURL ) );
}
public boolean isDeployed( String pFileURL )
@@ -161,6 +161,11 @@
// Get the date of the file
File lFile = new File( pFile.getFile() );
Date lFileDate = new Date( lFile.lastModified() );
+ Date lOldFileDate = (Date) mDeployedServices.get( lFile.getName() );
+ if( lOldFileDate != null && !lFileDate.after( lOldFileDate ) ) {
+ log.info( "deploy(), file is locally already deployed, ignore" );
+ return;
+ }
FileContent lFileContent = getFileContent( lFile );
HAPartition lHAPartition = (HAPartition) mServer.getAttribute(
sClusterPartitionService,
@@ -181,6 +186,31 @@
}
}
+ public void undeploy( URL pFile ) {
+ try {
+ log.info( "undeploy(), file: " + pFile );
+ // Get the date of the file
+ File lFile = new File( pFile.getFile() );
+ Date lFileDate = new Date( lFile.lastModified() );
+ HAPartition lHAPartition = (HAPartition) mServer.getAttribute(
+ sClusterPartitionService,
+ "HAPartition"
+ );
+ lHAPartition.callMethodOnCluster(
+ SERVICE_NAME,
+ "doUndeployment",
+ new Object[] {
+ lFile,
+ lFileDate
+ },
+ false
+ );
+ }
+ catch( Exception e ) {
+ logException( e );
+ }
+ }
+
public void doDeployment( FileContent pFile, Date pDate ) {
try {
// First check if file not already deployed
@@ -202,6 +232,50 @@
);
log.info( "doDeployment(), add file served" );
mDeployedServices.put( lFile.getName(), pDate );
+ // Adjust the date and move the file back to /deploy/farm
+ // if not already there
+ File lFarmFile = new File( "../deploy/farm", pFile.mFile.getName() );
+ if( !lFarmFile.exists() ) {
+ lFile.setLastModified( pDate.getTime() );
+ lFile.renameTo( lFarmFile );
+ log.info( "doDeployment(), file copied back to /deploy/farm" );
+ } else {
+ lFile.delete();
+ log.info( "doDeployment(), file is already in /deploy/farm" );
+ }
+ }
+ }
+ catch( Exception e ) {
+ logException( e );
+ }
+ }
+
+ public void doUndeployment( File pFile, Date pDate ) {
+ try {
+ // First check if file is already deployed
+ log.info( "doUndeployment(), File: " + pFile + ", data: " + pDate );
+ if( mDeployedServices.containsKey( pFile.getName() ) ) {
+ // Create File locally and use it
+ File lFile = new File( "../tmp", pFile.getName() );
+ log.info( "doUndeployment(), undeploy locally: " + lFile );
+ // Deploy file on Service Deployer
+ mServer.invoke(
+ sDeployerService,
+ "undeploy",
+ new Object[] { lFile.toURL().toString() },
+ new String[] { String.class.getName() }
+ );
+ log.info( "doUndeployment(), remove file served" );
+ mDeployedServices.remove( lFile.getName() );
+ // Check if the file is still in /deploy/farm and if yes
+ // then remove it
+ File lFarmFile = new File( "../deploy/farm", pFile.getName() );
+ if( lFarmFile.exists() ) {
+ lFarmFile.delete();
+ log.info( "doDeployment(), remove file from /deploy/farm" );
+ } else {
+ log.info( "doDeployment(), file is already removed" );
+ }
}
}
catch( Exception e ) {
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development