[jboss-cvs] JBossAS SVN: r77864 - in trunk: profileservice/src and 14 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Sep 3 18:06:46 EDT 2008
Author: scott.stark at jboss.org
Date: 2008-09-03 18:06:46 -0400 (Wed, 03 Sep 2008)
New Revision: 77864
Added:
trunk/profileservice/src/test/
trunk/profileservice/src/test/main/
trunk/profileservice/src/test/main/org/
trunk/profileservice/src/test/main/org/jboss/
trunk/profileservice/src/test/main/org/jboss/test/
trunk/profileservice/src/test/main/org/jboss/test/ps/
trunk/profileservice/src/test/main/org/jboss/test/ps/SerializableDeploymentRepositoryUnitTest.java
trunk/profileservice/src/test/resources/
trunk/profileservice/src/test/resources/log4j.properties
trunk/system/src/main/org/jboss/profileservice/spi/DeploymentContentFlags.java
Removed:
trunk/profileservice/src/test/readme.html
trunk/profileservice/src/tests/
Modified:
trunk/cluster/src/main/org/jboss/ha/singleton/HASingletonDeploymentScanner.java
trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java
trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java
trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentManager.java
trunk/system/src/main/org/jboss/profileservice/spi/DeploymentRepository.java
trunk/system/src/main/org/jboss/system/server/profileservice/repository/RepositoryAdminAdaptor.java
trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java
trunk/testsuite/src/main/org/jboss/test/deployers/AbstractDeploymentTest.java
trunk/testsuite/src/main/org/jboss/test/profileservice/test/AbstractProfileServiceTest.java
trunk/testsuite/src/main/org/jboss/test/profileservice/test/DeployUnitTestCase.java
Log:
JBAS-5625, add more support for isolating hot deployment from the deployment manager workings
Modified: trunk/cluster/src/main/org/jboss/ha/singleton/HASingletonDeploymentScanner.java
===================================================================
--- trunk/cluster/src/main/org/jboss/ha/singleton/HASingletonDeploymentScanner.java 2008-09-03 20:16:03 UTC (rev 77863)
+++ trunk/cluster/src/main/org/jboss/ha/singleton/HASingletonDeploymentScanner.java 2008-09-03 22:06:46 UTC (rev 77864)
@@ -237,9 +237,9 @@
{
if (activeProfile != key)
{
- this.deploymentManager.loadProfile(key);
+ this.deploymentManager.loadProfile(key, false);
activeProfile = key;
- }
+ }
}
private String[] getAllUploadedNames()
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java 2008-09-03 20:16:03 UTC (rev 77863)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java 2008-09-03 22:06:46 UTC (rev 77864)
@@ -147,7 +147,7 @@
return false;
}
- public void loadProfile(ProfileKey key) throws Exception
+ public void loadProfile(ProfileKey key, boolean allowHotDeployments) throws Exception
{
activeProfile = ps.getProfile(key);
if( activeProfile == null )
@@ -157,11 +157,27 @@
String msg = formatter.format(args);
throw new NoSuchProfileException(msg);
}
+ activeProfile.enableModifiedDeploymentChecks(allowHotDeployments);
// Set the deployment repository on the handler
DeploymentRepository repository = repositoryFactory.getDeploymentRepository(key);
deployHandler.setDeploymentRepository(repository);
}
+ public void releaseProfile(ProfileKey key, boolean allowHotDeployments)
+ throws Exception
+ {
+ activeProfile = ps.getProfile(key);
+ if( activeProfile == null )
+ {
+ formatter.applyPattern(i18n.getString("DeploymentManager.NoSuchProfileException")); //$NON-NLS-1$
+ Object[] args = {key};
+ String msg = formatter.format(args);
+ throw new NoSuchProfileException(msg);
+ }
+ activeProfile.enableModifiedDeploymentChecks(allowHotDeployments);
+ deployHandler.setDeploymentRepository(null);
+ }
+
public DeploymentProgress redeploy(String name, DeploymentPhase phase, URL contentURL)
{
List<DeploymentTarget> targets = getDeploymentTargets();
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java 2008-09-03 20:16:03 UTC (rev 77863)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java 2008-09-03 22:06:46 UTC (rev 77864)
@@ -215,7 +215,7 @@
{
VirtualFile vf = deploymentRepository.getDeploymentContent(name, phase);
VFSDeployment vfsd = createDeployment(vf);
- deploymentRepository.addDeployment(name, vfsd, phase);
+ deploymentRepository.addDeployment(vf.getName(), vfsd, phase);
deploymentRepository.unlockDeploymentContent(vf.getPathName(), phase);
mainDeployer.addDeployment(vfsd);
log.info("Scheduling start for: "+vfsd);
@@ -239,7 +239,11 @@
{
for(String name : names)
{
+ // Obtain the
VFSDeployment vfsd = deploymentRepository.getDeployment(name, dtID.getPhase());
+ // Lock the content to make it unavailable to the deployment scanner
+ String path = vfsd.getRoot().getPathName();
+ deploymentRepository.lockDeploymentContent(path, dtID.getPhase());
mainDeployer.removeDeployment(vfsd);
log.info("Scheduling stop for: "+vfsd);
}
Copied: trunk/profileservice/src/test (from rev 77671, trunk/profileservice/src/tests)
Added: trunk/profileservice/src/test/main/org/jboss/test/ps/SerializableDeploymentRepositoryUnitTest.java
===================================================================
--- trunk/profileservice/src/test/main/org/jboss/test/ps/SerializableDeploymentRepositoryUnitTest.java (rev 0)
+++ trunk/profileservice/src/test/main/org/jboss/test/ps/SerializableDeploymentRepositoryUnitTest.java 2008-09-03 22:06:46 UTC (rev 77864)
@@ -0,0 +1,144 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This 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 (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.ps;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.URI;
+import java.util.Collection;
+
+import junit.framework.TestCase;
+
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
+import org.jboss.logging.Logger;
+import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
+import org.jboss.profileservice.spi.AttachmentsSerializer;
+import org.jboss.profileservice.spi.DeploymentContentFlags;
+import org.jboss.profileservice.spi.ModificationInfo;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.system.server.profileservice.repository.JavaSerializationAttachmentsSerializer;
+import org.jboss.system.server.profileservice.repository.SerializableDeploymentRepository;
+
+
+/**
+ * Tests of the SerializableDeploymentRepository implementation details.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class SerializableDeploymentRepositoryUnitTest
+ extends TestCase
+{
+ private static Logger log = Logger.getLogger(SerializableDeploymentRepositoryUnitTest.class);
+
+ public SerializableDeploymentRepositoryUnitTest(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Test the behavior of the {@link DeploymentContentFlags#LOCKED} flag
+ * @throws Exception
+ */
+ public void testDeploymentContentFlagsLocked()
+ throws Exception
+ {
+ File root = getServerRoot();
+ URI[] appURIs = {root.toURI().resolve("default/deploy")};
+ ProfileKey key = new ProfileKey("default");
+ log.info("Creating SDR with root: "+root+", appURI: "+appURIs[0]);
+ SerializableDeploymentRepository sdr = new SerializableDeploymentRepository(root, appURIs, key);
+ AttachmentsSerializer serializer = new JavaSerializationAttachmentsSerializer();
+ sdr.setSerializer(serializer);
+ sdr.load();
+
+ log.info("DeploymentNames: "+sdr.getDeploymentNames());
+ // Validate we can get the ROOT.war
+ VFSDeployment rootWar = sdr.getDeployment("ROOT.war", DeploymentPhase.APPLICATION);
+ assertNotNull("deploy/ROOT.war", rootWar);
+
+ // Modify the ROOT.war
+ URI warURI = rootWar.getRoot().toURI();
+ File warFile = new File(warURI.getPath());
+ warFile.setLastModified(System.currentTimeMillis());
+ // Check its flags
+ int flags = sdr.getDeploymentContentFlags("ROOT.war", DeploymentPhase.APPLICATION);
+ assertEquals("ROOT.war flags", 0, flags);
+
+ // Validate the ROOT.war is in the modified deployments
+ Collection<ModificationInfo> mods = sdr.getModifiedDeployments();
+ assertEquals("Collection<ModificationInfo> size is 1", 1, mods.size());
+ ModificationInfo warMods = mods.iterator().next();
+ assertEquals("ModificationInfo.status is MODIFIED", ModificationInfo.ModifyStatus.MODIFIED, warMods.getStatus());
+ assertEquals("ModificationInfo.name is ROOT.war", "ROOT.war", warMods.getDeployment().getSimpleName());
+
+ // lock the war
+ flags = sdr.setDeploymentContentFlags("ROOT.war", DeploymentPhase.APPLICATION,
+ DeploymentContentFlags.LOCKED);
+ assertEquals(flags, DeploymentContentFlags.LOCKED);
+ warFile.setLastModified(System.currentTimeMillis()+1000);
+ // It should be modified, but not show up in the mods
+ assertTrue("vfsfile ROOT.war hasBeenModified", rootWar.getRoot().hasBeenModified());
+ mods = sdr.getModifiedDeployments();
+ assertEquals("Collection<ModificationInfo> size is 0", 0, mods.size());
+
+ // Validate that the locked flag overrides the modified flag
+ assertFalse("vfsfile ROOT.war hasBeenModified", rootWar.getRoot().hasBeenModified());
+ flags = DeploymentContentFlags.LOCKED | DeploymentContentFlags.MODIFIED;
+ sdr.setDeploymentContentFlags("ROOT.war", DeploymentPhase.APPLICATION, flags);
+ mods = sdr.getModifiedDeployments();
+ assertEquals("Collection<ModificationInfo> size is 0", 0, mods.size());
+
+ // Validate that the modified flag allows it to show
+ flags = sdr.clearDeploymentContentFlags("ROOT.war", DeploymentPhase.APPLICATION,
+ DeploymentContentFlags.LOCKED);
+ assertEquals("ROOT.war has MODIFIED flag", flags, DeploymentContentFlags.MODIFIED);
+ mods = sdr.getModifiedDeployments();
+ assertEquals("Collection<ModificationInfo> size is 1", 1, mods.size());
+ warMods = mods.iterator().next();
+ assertEquals("ModificationInfo.status is MODIFIED", ModificationInfo.ModifyStatus.MODIFIED, warMods.getStatus());
+ assertEquals("ModificationInfo.name is ROOT.war", "ROOT.war", warMods.getDeployment().getSimpleName());
+ }
+
+ /**
+ * Get the file for the jboss server directory. Relies on one
+ * of the following variables to be set:
+ * JBOSS_HOME env variable
+ * jboss.home system property
+ *
+ * @return
+ * @throws IOException
+ */
+ protected File getServerRoot() throws IOException
+ {
+ String home = System.getenv("JBOSS_HOME");
+ if(home == null)
+ {
+ home = System.getProperty("jboss.home");
+ }
+ File defaultDir = new File(home, "server");
+ if(defaultDir.exists() == false)
+ throw new FileNotFoundException(defaultDir.getAbsolutePath()+", check the JBOSS_HOME env variable or jboss.home system property");
+ return defaultDir;
+ }
+}
Deleted: trunk/profileservice/src/test/readme.html
===================================================================
--- trunk/profileservice/src/tests/readme.html 2008-08-30 00:41:44 UTC (rev 77671)
+++ trunk/profileservice/src/test/readme.html 2008-09-03 22:06:46 UTC (rev 77864)
@@ -1,22 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
-<html>
- <head>
- <!-- $Id: readme.html 46331 2006-07-17 14:12:39Z starksm $ -->
- </head>
-
- <body bgcolor="white">
- <h1>System Unit Tests</h1>
- The system module unit tests rely on the following system module locations:
- <ul>
- <li>src/resources/tests/bootstrap : for the ProfileService based bootstrap
- tests to load the bootstrap-deployers.xml descriptor.</li>
- <li>src/resources/tests/conf : for the test-log4j.xml when running from the
- command line to generate a test.log file.</li>
- <li>src/resources/tests/xml : to locate unit test related descriptors.</li>
- </ul>
-
- <h2>The build-test.xml ant file</h1>
- The build-test.xml ant file is used to compile and run the tests outside of
- eclipse.
- </body>
-</html>
Added: trunk/profileservice/src/test/resources/log4j.properties
===================================================================
--- trunk/profileservice/src/test/resources/log4j.properties (rev 0)
+++ trunk/profileservice/src/test/resources/log4j.properties 2008-09-03 22:06:46 UTC (rev 77864)
@@ -0,0 +1,9 @@
+# $Id:$
+
+log4j.rootCategory=DEBUG, CONSOLE
+
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.Target=System.out
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c{1}] %m%n
+
Modified: trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentManager.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentManager.java 2008-09-03 20:16:03 UTC (rev 77863)
+++ trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentManager.java 2008-09-03 22:06:46 UTC (rev 77864)
@@ -39,9 +39,21 @@
* for future operations.
*
* @param key - the profile to load
+ * @param allowHotDeployments - Can be used to suspend hot deployment
+ * processing while working against a live server to avoid conflicts.
* @throws Exception for any error
*/
- public void loadProfile(ProfileKey key) throws Exception;
+ public void loadProfile(ProfileKey key, boolean allowHotDeployments) throws Exception;
+ /**
+ * Release a profile. This frees any resources and resets the hot deployment
+ * processing.
+ *
+ * @param key - the profile to load
+ * @param allowHotDeployments - Can be used to suspend hot deployment
+ * processing while working against a live server to avoid conflicts.
+ * @throws Exception
+ */
+ public void releaseProfile(ProfileKey key, boolean allowHotDeployments) throws Exception;
/**
* Add raw deployment content to the profile.
Added: trunk/system/src/main/org/jboss/profileservice/spi/DeploymentContentFlags.java
===================================================================
--- trunk/system/src/main/org/jboss/profileservice/spi/DeploymentContentFlags.java (rev 0)
+++ trunk/system/src/main/org/jboss/profileservice/spi/DeploymentContentFlags.java 2008-09-03 22:06:46 UTC (rev 77864)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This 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 (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.profileservice.spi;
+
+/**
+ * States for DeploymentRepository content
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface DeploymentContentFlags
+{
+ /** content that is not publicly visible in profile */
+ public static final int DISABLED=1;
+ /** content that is visible in profile */
+ public static final int ENABLED=2;
+ /** exists in profile, but is excluded from modified deployment checks. */
+ public static final int LOCKED=4;
+ /** Can be used to explicitly put a deployment into the modified list */
+ public static final int MODIFIED=8;
+}
Modified: trunk/system/src/main/org/jboss/profileservice/spi/DeploymentRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/profileservice/spi/DeploymentRepository.java 2008-09-03 20:16:03 UTC (rev 77863)
+++ trunk/system/src/main/org/jboss/profileservice/spi/DeploymentRepository.java 2008-09-03 22:06:46 UTC (rev 77864)
@@ -90,18 +90,58 @@
/**
* lock deployment content and exclude it from modified deployment checks.
- * @param vfsPath
- * @param phase
+ * @param vfsPath - the content vfs path relative to the deployment phase root
+ * @param phase - the deployment phase
+ * @return the deployment content flags, {@linkplain DeploymentContentFlags}
*/
- public void lockDeploymentContent(String vfsPath, DeploymentPhase phase);
+ public int lockDeploymentContent(String vfsPath, DeploymentPhase phase);
/**
* Unlock a previously locked deployment content.
- * @param vfsPath
- * @param phase
+ * @param vfsPath - the content vfs path relative to the deployment phase root
+ * @param phase - the deployment phase
+ * @return the deployment content flags, {@linkplain DeploymentContentFlags}
*/
- public void unlockDeploymentContent(String vfsPath, DeploymentPhase phase);
+ public int unlockDeploymentContent(String vfsPath, DeploymentPhase phase);
/**
+ * Get the status flags for the deployment path
+ * @param vfsPath - the content vfs path relative to the deployment phase root
+ * @param phase - the deployment phase
+ * @return the deployment content flags, {@linkplain DeploymentContentFlags}
+ */
+ public int getDeploymentContentFlags(String vfsPath, DeploymentPhase phase);
+ /**
+ * Set one or more flags for the deployment.
+ * @see #clearDeploymentContentFlags(String, DeploymentPhase, int)
+ *
+ * @param vfsPath - the content vfs path relative to the deployment phase root
+ * @param phase - the deployment phase
+ * @param flags - the deployment content flags, {@linkplain DeploymentContentFlags}
+ */
+ public int setDeploymentContentFlags(String vfsPath, DeploymentPhase phase,
+ int flags);
+ /**
+ * Clear one or more flags for the deployment. This ands the compliment of
+ * the flags argument into the existing content flags and returns the result.
+ *
+ * @param vfsPath - the content vfs path relative to the deployment phase root
+ * @param phase - the deployment phase
+ * @param flags - the deployment content flags, {@linkplain DeploymentContentFlags}
+ */
+ public int clearDeploymentContentFlags(String vfsPath, DeploymentPhase phase,
+ int flags);
+ /**
+ * Does a deployment content have the indicated flag.
+ *
+ * @param vfsPath - the content vfs path relative to the deployment phase root
+ * @param phase - the deployment phase
+ * @param flags - the deployment content flags, {@linkplain DeploymentContentFlags}
+ * @return true if the content flags contains the flag, false otherwise.
+ */
+ public boolean hasDeploymentContentFlags(String vfsPath, DeploymentPhase phase,
+ int flag);
+
+ /**
* Acquire the repository write lock. This generally prevents content
* uploads and {@link #getModifiedDeployments()} calls while the lock is
* held.
Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/RepositoryAdminAdaptor.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/RepositoryAdminAdaptor.java 2008-09-03 20:16:03 UTC (rev 77863)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/RepositoryAdminAdaptor.java 2008-09-03 22:06:46 UTC (rev 77864)
@@ -109,27 +109,56 @@
return null;
}
- public void lockDeploymentContent(String vfsPath, DeploymentPhase phase)
+ public int lockDeploymentContent(String vfsPath, DeploymentPhase phase)
{
// TODO Auto-generated method stub
+ return 0;
}
+ public int unlockDeploymentContent(String vfsPath, DeploymentPhase phase)
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
- public void acquireDeploymentContentLock()
+
+ public int getDeploymentContentFlags(String vfsPath, DeploymentPhase phase)
{
// TODO Auto-generated method stub
+ return 0;
}
- public void releaseDeploymentContentLock()
+ public int clearDeploymentContentFlags(String vfsPath,
+ DeploymentPhase phase, int flags)
{
// TODO Auto-generated method stub
+ return 0;
}
- public void unlockDeploymentContent(String vfsPath, DeploymentPhase phase)
+ public boolean hasDeploymentContentFlags(String vfsPath,
+ DeploymentPhase phase, int flag)
{
// TODO Auto-generated method stub
-
+ return false;
}
+ public int setDeploymentContentFlags(String vfsPath, DeploymentPhase phase,
+ int flags)
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public void acquireDeploymentContentLock()
+ {
+ // TODO Auto-generated method stub
+ }
+
+ public void releaseDeploymentContentLock()
+ {
+ // TODO Auto-generated method stub
+ }
+
+
public void addManagedObject(String vfsPath, Attachments edits) throws Exception
{
MutableRepository repo = this.getRepository(adminEditsRoot.toURI());
Modified: trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java 2008-09-03 20:16:03 UTC (rev 77863)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java 2008-09-03 22:06:46 UTC (rev 77864)
@@ -40,6 +40,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.zip.ZipInputStream;
@@ -49,6 +50,7 @@
import org.jboss.logging.Logger;
import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
import org.jboss.profileservice.spi.AttachmentsSerializer;
+import org.jboss.profileservice.spi.DeploymentContentFlags;
import org.jboss.profileservice.spi.DeploymentRepository;
import org.jboss.profileservice.spi.ModificationInfo;
import org.jboss.profileservice.spi.ModificationInfo.ModifyStatus;
@@ -101,7 +103,7 @@
private LinkedHashMap<String,VFSDeployment> applicationCtxs = new LinkedHashMap<String,VFSDeployment>();
/** The {@link VFSDeployment#getTransientManagedObjects()} serializer */
private AttachmentsSerializer serializer;
- private Set<String> lockedApps = Collections.synchronizedSet(new HashSet<String>());
+ private Map<String, Integer> contentFlags = new ConcurrentHashMap<String, Integer>();
/** The last time the profile was modified */
private long lastModified;
/** A lock for the hot deployment/{@link #getModifiedDeployments()} */
@@ -327,16 +329,57 @@
return rnames;
}
- public void lockDeploymentContent(String vfsPath, DeploymentPhase phase)
+ public int lockDeploymentContent(String vfsPath, DeploymentPhase phase)
{
- lockedApps.add(vfsPath);
+ if( log.isTraceEnabled() )
+ log.trace("lockDeploymentContent, "+vfsPath);
+ int flags = setDeploymentContentFlags(vfsPath, phase, DeploymentContentFlags.LOCKED);
+ return flags;
}
- public void unlockDeploymentContent(String vfsPath, DeploymentPhase phase)
+ public int unlockDeploymentContent(String vfsPath, DeploymentPhase phase)
{
- lockedApps.remove(vfsPath);
+ if( log.isTraceEnabled() )
+ log.trace("unlockDeploymentContent, "+vfsPath);
+ int flags = clearDeploymentContentFlags(vfsPath, phase, DeploymentContentFlags.LOCKED);
+ return flags;
}
+ public int getDeploymentContentFlags(String vfsPath, DeploymentPhase phase)
+ {
+ Integer flags = contentFlags.get(vfsPath);
+ int iflags = flags != null ? flags.intValue() : 0;
+ return iflags;
+ }
+ public synchronized int clearDeploymentContentFlags(String vfsPath,
+ DeploymentPhase phase,
+ int flags)
+ {
+ Integer dflags = contentFlags.get(vfsPath);
+ if(dflags != null)
+ {
+ dflags &= ~flags;
+ contentFlags.put(vfsPath, dflags);
+ }
+ int iflags = dflags != null ? dflags.intValue() : 0;
+ return iflags;
+ }
+ public boolean hasDeploymentContentFlags(String vfsPath, DeploymentPhase phase,
+ int flag)
+ {
+ Integer flags = contentFlags.get(vfsPath);
+ boolean hasFlag = false;
+ if(flags != null )
+ hasFlag = (flags & flag) != 0 ? true : false;
+ return hasFlag;
+ }
+ public int setDeploymentContentFlags(String vfsPath, DeploymentPhase phase,
+ int flags)
+ {
+ contentFlags.put(vfsPath, flags);
+ return flags;
+ }
+
public void acquireDeploymentContentLock()
{
contentLock.writeLock().lock();
@@ -459,8 +502,9 @@
VFSDeployment ctx = iter.next();
VirtualFile root = ctx.getRoot();
String name = root.getPathName();
- // See if this file is locked
- if(this.lockedApps.contains(name))
+ // Ignore locked or disabled applications
+ int flags = DeploymentContentFlags.LOCKED | DeploymentContentFlags.DISABLED;
+ if(this.hasDeploymentContentFlags(name, DeploymentPhase.APPLICATION, flags))
{
if(trace)
log.trace("Ignoring locked application: "+root);
@@ -477,7 +521,8 @@
log.trace(name + " was removed");
}
// Check for modification
- else if( root.hasBeenModified() )
+ else if( root.hasBeenModified() ||
+ hasDeploymentContentFlags(root.getPathName(), DeploymentPhase.APPLICATION, DeploymentContentFlags.MODIFIED) )
{
long rootLastModified = root.getLastModified();
if( trace )
@@ -954,8 +999,6 @@
{
VFSDeployment vfCtx = loadDeploymentData(vf);
String key = vfCtx.getName();
- if(key.startsWith("test"))
- log.error("Should not see a test... key");
applicationCtxs.put(key, vfCtx);
}
}
Modified: trunk/testsuite/src/main/org/jboss/test/deployers/AbstractDeploymentTest.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/deployers/AbstractDeploymentTest.java 2008-09-03 20:16:03 UTC (rev 77863)
+++ trunk/testsuite/src/main/org/jboss/test/deployers/AbstractDeploymentTest.java 2008-09-03 22:06:46 UTC (rev 77864)
@@ -111,7 +111,7 @@
InitialContext ctx = new InitialContext();
ProfileService ps = (ProfileService) ctx.lookup("ProfileService");
dm = ps.getDeploymentManager();
- dm.loadProfile(new ProfileKey("profileservice"));
+ dm.loadProfile(new ProfileKey("profileservice"), false);
return dm;
}
return dm;
Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/test/AbstractProfileServiceTest.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/AbstractProfileServiceTest.java 2008-09-03 20:16:03 UTC (rev 77863)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/AbstractProfileServiceTest.java 2008-09-03 22:06:46 UTC (rev 77864)
@@ -167,7 +167,7 @@
ProfileService ps = (ProfileService) ctx.lookup("ProfileService");
deployMgr = ps.getDeploymentManager();
ProfileKey defaultKey = new ProfileKey(profileName);
- deployMgr.loadProfile(defaultKey);
+ deployMgr.loadProfile(defaultKey, false);
// Init the VFS to setup the vfs* protocol handlers
VFS.init();
}
Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/test/DeployUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/DeployUnitTestCase.java 2008-09-03 20:16:03 UTC (rev 77863)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/DeployUnitTestCase.java 2008-09-03 22:06:46 UTC (rev 77864)
@@ -26,6 +26,10 @@
import java.util.Set;
import javax.naming.InitialContext;
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
import org.jboss.deployers.spi.management.ManagementView;
import org.jboss.deployers.spi.management.deploy.DeploymentManager;
import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
@@ -34,6 +38,10 @@
import org.jboss.deployers.spi.management.deploy.ProgressListener;
import org.jboss.managed.api.ManagedDeployment;
import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
+import org.jboss.profileservice.spi.ProfileKey;
+import org.jboss.profileservice.spi.ProfileService;
+import org.jboss.test.JBossTestSetup;
+import org.jboss.test.jpa.test.WebClassesEARJPAUnitTestCase;
import org.jboss.test.profileservice.ejb2x.BeanHome;
import org.jboss.test.profileservice.ejb2x.BeanRemote;
import org.jboss.test.profileservice.ejb3x.BeanRemote3x;
@@ -53,6 +61,26 @@
super(name);
}
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ DeploymentManager deployMgr = getDeploymentManager();
+ String profileName = getProfileName();
+ ProfileKey key = new ProfileKey(profileName);
+ deployMgr.loadProfile(key, false);
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ DeploymentManager deployMgr = getDeploymentManager();
+ String profileName = getProfileName();
+ ProfileKey key = new ProfileKey(profileName);
+ deployMgr.releaseProfile(key, true);
+ super.tearDown();
+ }
+
public void progressEvent(ProgressEvent eventInfo)
{
eventCount ++;
More information about the jboss-cvs-commits
mailing list