[jboss-cvs] JBossAS SVN: r75134 - in trunk: profileservice/src/main/org/jboss/profileservice/management/upload/remoting and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jun 26 16:29:54 EDT 2008
Author: scott.stark at jboss.org
Date: 2008-06-26 16:29:53 -0400 (Thu, 26 Jun 2008)
New Revision: 75134
Modified:
trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java
trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentID.java
trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java
trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/StreamingDeploymentTarget.java
trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentID.java
trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentManager.java
trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentTarget.java
trunk/system/src/main/org/jboss/profileservice/spi/DeploymentRepository.java
trunk/system/src/main/org/jboss/system/server/ServerInfo.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/profileservice/test/DeployUnitTestCase.java
Log:
JBAS-5370, cleanup inconsistent vfsPath vfs virtual file uri usage
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java 2008-06-26 18:50:32 UTC (rev 75133)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java 2008-06-26 20:29:53 UTC (rev 75134)
@@ -132,6 +132,19 @@
return new DeploymentProgressImpl(targets, deployment, CommandType.DISTRIBUTE);
}
+ /**
+ * Map from the external name passed to distribute to the uploaded
+ * deployment repository name.
+ * @param names - the list of external deployment names
+ * @return the mapped list of unique names in the deployment repository.
+ */
+ public String[] getRepositoryNames(String[] names, DeploymentPhase phase)
+ throws Exception
+ {
+ List<DeploymentTarget> targets = getDeploymentTargets();
+ String[] repositoryNames = targets.get(0).getRepositoryNames(names, phase);
+ return repositoryNames;
+ }
public boolean isRedeploySupported()
{
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentID.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentID.java 2008-06-26 18:50:32 UTC (rev 75133)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentID.java 2008-06-26 20:29:53 UTC (rev 75134)
@@ -40,7 +40,8 @@
/** An InputStream to use to copy the contents */
private transient InputStream contentIS;
- private String[] deploymentName;
+ private String[] deploymentNames;
+ private String[] repositoryNames;
private DeploymentPhase phase;
private String description;
private URL contentURL;
@@ -55,16 +56,26 @@
}
public SerializableDeploymentID(String[] names, DeploymentPhase phase, String description)
{
- this.deploymentName = names;
+ this.deploymentNames = names;
this.phase = phase;
this.description = description;
}
public String[] getNames()
{
- return deploymentName;
+ return deploymentNames;
}
+ public String[] getRepositoryNames()
+ {
+ if(repositoryNames == null)
+ repositoryNames = deploymentNames;
+ return repositoryNames;
+ }
+ public void setRepositoryNames(String[] names)
+ {
+ this.repositoryNames = names;
+ }
public DeploymentPhase getPhase()
{
return phase;
@@ -106,7 +117,10 @@
public String toString()
{
StringBuffer buffer = new StringBuffer();
- buffer.append("names=").append(Arrays.toString(deploymentName));
+ buffer.append("names=").append(Arrays.toString(getNames()));
+ // Only add the repositoryNames if it differs from deploymentNames
+ if(getRepositoryNames() != getNames())
+ buffer.append("repositoryNames=").append(Arrays.toString(getRepositoryNames()));
buffer.append("phase=").append(phase);
buffer.append("description=").append(description);
return buffer.toString();
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-06-26 18:50:32 UTC (rev 75133)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java 2008-06-26 20:29:53 UTC (rev 75134)
@@ -21,8 +21,10 @@
*/
package org.jboss.profileservice.management.upload.remoting;
+import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.Map;
import javax.management.MBeanServer;
@@ -31,6 +33,7 @@
import org.jboss.aspects.remoting.AOPRemotingInvocationHandler;
import org.jboss.deployers.client.spi.main.MainDeployer;
import org.jboss.deployers.spi.management.deploy.DeploymentID;
+import org.jboss.deployers.spi.management.deploy.DeploymentManager;
import org.jboss.deployers.vfs.spi.client.VFSDeployment;
import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
import org.jboss.logging.Logger;
@@ -88,7 +91,8 @@
this.mainDeployer = mainDeployer;
}
/**
- * Handle a deployService deploy invocation
+ * Handle a DeploymentManager distribute invocation
+ * @see DeploymentManager#distribute(String, DeploymentPhase, java.net.URL)
* @param request - the remoting invocation
*/
public Object handleStream(InputStream contentIS, InvocationRequest request)
@@ -96,14 +100,13 @@
{
SerializableDeploymentID deploymentTarget = (SerializableDeploymentID) request.getParameter();
log.debug("handleStream, deploymentTarget: "+deploymentTarget);
- //Map payload = request.getRequestPayload();
deploymentTarget.setContentIS(contentIS);
DeploymentPhase phase = deploymentTarget.getPhase();
- //ZipInputStream zis = new ZipInputStream(contentIS);
String[] names = deploymentTarget.getNames();
- deploymentRepository.addDeploymentContent(names[0], contentIS, phase);
-
- return new InvocationResponse(null);
+ String repositoryName = deploymentRepository.addDeploymentContent(names[0], contentIS, phase);
+ String[] rnames = {repositoryName};
+ deploymentTarget.setRepositoryNames(rnames);
+ return new InvocationResponse(repositoryName);
}
public void addListener(InvokerCallbackHandler arg0)
@@ -111,8 +114,9 @@
}
/**
- * Handle a deployService invocation other than deploy
+ * Handle a DeploymentManager invocation other than distribute
* @param request - the remoting invocation
+ * @return the result of the invocation
*/
public Object invoke(InvocationRequest request) throws Throwable
{
@@ -127,7 +131,13 @@
{
Map payload = request.getRequestPayload();
DeploymentID dtID = (DeploymentID) payload.get("DeploymentTargetID");
- log.debug("invoke, dtID: "+dtID+", payload: "+payload);
+ log.debug("invoke, payload: "+payload);
+ if( parameter.equals("getRepositoryNames"))
+ {
+ String[] names = (String[]) payload.get("names");
+ DeploymentPhase phase = (DeploymentPhase) payload.get("phase");
+ returnValue = getRepositoryNames(names, phase);
+ }
if( parameter.equals("start") )
{
start(dtID);
@@ -156,6 +166,12 @@
{
}
+ protected String[] getRepositoryNames(String[] names, DeploymentPhase phase)
+ throws IOException
+ {
+ return deploymentRepository.getRepositoryNames(names, phase);
+ }
+
protected void start(DeploymentID dtID)
throws Exception
{
@@ -169,10 +185,10 @@
{
VirtualFile vf = deploymentRepository.getDeploymentContent(name, dtID.getPhase());
VFSDeployment vfsd = createDeployment(vf);
- deploymentRepository.addDeployment(vf.getName(), vfsd, dtID.getPhase());
+ deploymentRepository.addDeployment(name, vfsd, dtID.getPhase());
deploymentRepository.unlockDeploymentContent(vf.getPathName(), dtID.getPhase());
mainDeployer.addDeployment(vfsd);
- log.info("Started: "+vfsd);
+ log.info("Scheduling start for: "+vfsd);
}
mainDeployer.process();
mainDeployer.checkComplete();
@@ -191,10 +207,9 @@
log.info("stop, "+Arrays.asList(names));
for(String name : names)
{
- VirtualFile vf = deploymentRepository.getDeploymentContent(name, dtID.getPhase());
- VFSDeployment vfsd = createDeployment(vf);
+ VFSDeployment vfsd = deploymentRepository.getDeployment(name, dtID.getPhase());
mainDeployer.removeDeployment(vfsd);
- log.info("Stopped: "+vfsd);
+ log.info("Scheduling stop for: "+vfsd);
}
mainDeployer.process();
mainDeployer.checkComplete();
@@ -207,8 +222,7 @@
log.info("undeploy, "+Arrays.asList(names));
for(String name : names)
{
- VirtualFile vf = deploymentRepository.getDeploymentContent(name, dtID.getPhase());
- deploymentRepository.removeDeployment(vf.getName(), dtID.getPhase());
+ deploymentRepository.removeDeployment(name, dtID.getPhase());
log.info("Undeployed: "+name);
}
}
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/StreamingDeploymentTarget.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/StreamingDeploymentTarget.java 2008-06-26 18:50:32 UTC (rev 75133)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/StreamingDeploymentTarget.java 2008-06-26 20:29:53 UTC (rev 75134)
@@ -25,20 +25,26 @@
import java.io.InputStream;
import java.io.Serializable;
import java.net.URL;
+import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import org.jboss.aop.joinpoint.InvocationResponse;
import org.jboss.deployers.spi.management.deploy.DeploymentID;
import org.jboss.deployers.spi.management.deploy.DeploymentTarget;
import org.jboss.logging.Logger;
+import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
import org.jboss.profileservice.management.upload.SerializableDeploymentID;
import org.jboss.remoting.Client;
import org.jboss.remoting.InvokerLocator;
/**
+ * An implementation of DeploymentTarget that uses remoting for streaming
+ * content in distribute, and basic rpc for the other methods.
+ *
* @author Scott.Stark at jboss.org
- * @version $Revision:$
+ * @version $Revision$
*/
public class StreamingDeploymentTarget
implements DeploymentTarget, Serializable
@@ -81,7 +87,8 @@
}
/**
- * Deploy a given module
+ * Distribute a deployment to the profile targets
+ * @param deployment - the encapsulation of the deployment to distribute
*/
public void distribute(DeploymentID deployment)
throws Exception
@@ -93,9 +100,12 @@
{
InputStream contentIS = contentURL.openStream();
sdtID.setContentIS(contentIS);
- log.info("Begin deploy: " + deployment);
- transferDeployment(client, sdtID);
- log.info("End deploy");
+ log.debug("Begin distribute: " + deployment);
+ String repositoryName = transferDeployment(client, sdtID);
+ // Update the repository names on the deployment
+ String[] rnames = {repositoryName};
+ deployment.setRepositoryNames(rnames);
+ log.debug("End distribute, repositoryName: "+repositoryName);
}
finally
{
@@ -103,6 +113,26 @@
}
}
+ public String[] getRepositoryNames(String[] names, DeploymentPhase phase)
+ throws Exception
+ {
+ Client client = getClient();
+ try
+ {
+ log.debug("Begin getRepositoryNames: " + Arrays.asList(names));
+ HashMap<Object, Object> args = new HashMap<Object, Object>();
+ args.put("names", names);
+ args.put("phase", phase);
+ String[] rnames = (String[]) invoke(client, "getRepositoryNames", args);
+ log.debug("End getRepositoryNames: " + Arrays.asList(rnames));
+ return rnames;
+ }
+ finally
+ {
+ client.disconnect();
+ }
+ }
+
public void redeploy(DeploymentID deployment)
throws Exception
{
@@ -134,7 +164,7 @@
Client client = getClient();
log.debug("Start: " + dtID);
invoke(client, "start", createArgs(dtID));
- log.info("End start: "+dtID);
+ log.debug("End start: "+dtID);
}
/**
@@ -145,9 +175,9 @@
Client client = getClient();
try
{
- log.info("Begin stop: " + dtID);
+ log.debug("Begin stop: " + dtID);
invoke(client, "stop", createArgs(dtID));
- log.info("End stop");
+ log.debug("End stop");
}
finally
{
@@ -163,15 +193,28 @@
Client client = getClient();
try
{
- log.info("Begin undeploy: " + dtID);
+ log.debug("Begin undeploy: " + dtID);
invoke(client, "undeploy", createArgs(dtID));
- log.info("End undeploy");
+ log.debug("End undeploy");
}
finally
{
client.disconnect();
}
}
+
+ public String toString()
+ {
+ StringBuilder tmp = new StringBuilder();
+ tmp.append("name=");
+ tmp.append(name);
+ tmp.append(",locator=");
+ tmp.append(locator);
+ tmp.append(",subsystem=");
+ tmp.append(subsystem);
+ return tmp.toString();
+ }
+
/**
* Get the remoting client connection
* @return
@@ -186,13 +229,24 @@
return remotingClient;
}
- private void transferDeployment(Client client, SerializableDeploymentID sdtID)
+ /**
+ * Stream a deployment to the server
+ *
+ * @param client - the remoting client
+ * @param sdtID - the deployment content encapsulation
+ * @return the profile service repository unique name
+ * @throws Exception
+ */
+ private String transferDeployment(Client client, SerializableDeploymentID sdtID)
throws Exception
{
InputStream is = sdtID.getContentIS();
try
{
- client.invoke(is, sdtID);
+ // This return value depends on the proxy type
+ InvocationResponse response = (InvocationResponse) client.invoke(is, sdtID);
+ String repositoryName = (String) response.getResponse();
+ return repositoryName;
}
catch(Error e)
{
@@ -227,7 +281,7 @@
}
catch(Throwable e)
{
- throw new RuntimeException(e);
+ throw new RuntimeException(e);
}
}
}
Property changes on: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/StreamingDeploymentTarget.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Modified: trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentID.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentID.java 2008-06-26 18:50:32 UTC (rev 75133)
+++ trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentID.java 2008-06-26 20:29:53 UTC (rev 75134)
@@ -39,6 +39,21 @@
* @return the deployment name
*/
String[] getNames();
+ /**
+ * Get the unique names of the deployments in the repository. Some DeploymentManager
+ * operations like distribute produce an alternate unique name that differs
+ * from the input name. In this case this method will provide the unique
+ * names for the input names. Otherwise this returns the same value as
+ * getNames.
+ * @return the unique names of the deployments in the repository
+ */
+ String[] getRepositoryNames();
+ /**
+ * Set the unique names of the deployments in the repository.
+ * @see #getRepositoryNames()
+ * @param names - the unique names of the deployments in the repository
+ */
+ public void setRepositoryNames(String[] names);
/**
* Get the phase the deployment is associated with
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-06-26 18:50:32 UTC (rev 75133)
+++ trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentManager.java 2008-06-26 20:29:53 UTC (rev 75134)
@@ -56,6 +56,15 @@
public DeploymentProgress distribute(String name, DeploymentPhase phase,
URL contentURL);
+ /**
+ * Map from the external name passed to distribute to the uploaded
+ * deployment repository name.
+ * @param names - the list of external deployment names
+ * @return the mapped list of unique names in the deployment repository.
+ */
+ public String[] getRepositoryNames(String[] names, DeploymentPhase phase)
+ throws Exception;
+
public boolean isRedeploySupported();
/**
*
Modified: trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentTarget.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentTarget.java 2008-06-26 18:50:32 UTC (rev 75133)
+++ trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentTarget.java 2008-06-26 20:29:53 UTC (rev 75134)
@@ -23,6 +23,8 @@
import java.net.URL;
+import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
+
/**
* A target to which a deployment is uploaded.
*
@@ -41,6 +43,8 @@
void distribute(DeploymentID deployment)
throws Exception;
+ String[] getRepositoryNames(String[] names, DeploymentPhase phase)
+ throws Exception;
void redeploy(DeploymentID deployment)
throws Exception;
void prepare(DeploymentID deployment)
@@ -58,4 +62,5 @@
* @return the description
*/
String getDescription();
+
}
Modified: trunk/system/src/main/org/jboss/profileservice/spi/DeploymentRepository.java
===================================================================
--- trunk/system/src/main/org/jboss/profileservice/spi/DeploymentRepository.java 2008-06-26 18:50:32 UTC (rev 75133)
+++ trunk/system/src/main/org/jboss/profileservice/spi/DeploymentRepository.java 2008-06-26 20:29:53 UTC (rev 75134)
@@ -24,6 +24,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
+import java.net.URISyntaxException;
import java.util.Collection;
import java.util.Set;
import java.util.zip.ZipInputStream;
@@ -62,14 +63,26 @@
* @param phase - the phase of the deployment as it relates to when the
* deployment is loaded
* @throws IOException
+ * @return the unique name of the deployment in the repository
*/
- public void addDeploymentContent(String vfsPath, InputStream contentIS, DeploymentPhase phase)
+ public String addDeploymentContent(String vfsPath, InputStream contentIS, DeploymentPhase phase)
throws IOException;
- public VirtualFile getDeploymentContent(String vfsPath, DeploymentPhase phase)
+ public String[] getRepositoryNames(String[] names, DeploymentPhase phase)
throws IOException;
/**
+ * Get the repository virtual file for the given deployment name
+ * @param name - the unique virtual file URI name as returned by addDeploymentContent
+ * @param phase - the phase of the deployment as it relates to when the
+ * deployment is loaded
+ * @return the deployment content virtual file
+ * @throws IOException
+ */
+ public VirtualFile getDeploymentContent(String name, DeploymentPhase phase)
+ throws IOException, URISyntaxException;
+
+ /**
* lock deployment content and exclude it from modified deployment checks.
* @param vfsPath
* @param phase
Modified: trunk/system/src/main/org/jboss/system/server/ServerInfo.java
===================================================================
--- trunk/system/src/main/org/jboss/system/server/ServerInfo.java 2008-06-26 18:50:32 UTC (rev 75133)
+++ trunk/system/src/main/org/jboss/system/server/ServerInfo.java 2008-06-26 20:29:53 UTC (rev 75134)
@@ -44,6 +44,8 @@
import javax.management.openmbean.CompositeData;
import org.jboss.logging.Logger;
+import org.jboss.managed.api.annotation.ManagementComponent;
+import org.jboss.managed.api.annotation.ManagementObject;
import org.jboss.util.platform.Java;
/**
@@ -59,6 +61,12 @@
* @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
* @version $Revision$
*/
+ at ManagementObject(
+ name="jboss.system:type=ServerInfo",
+ isRuntime=true,
+ description="provides a view of system information for the JBoss server in which it is deployed",
+ componentType=@ManagementComponent(type="MCBean", subtype="*")
+)
public class ServerInfo
implements ServerInfoMBean, MBeanRegistration
{
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-06-26 18:50:32 UTC (rev 75133)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/RepositoryAdminAdaptor.java 2008-06-26 20:29:53 UTC (rev 75134)
@@ -88,13 +88,20 @@
mrepo.addResource(dres);
}
- public void addDeploymentContent(String name, InputStream contentIS, DeploymentPhase phase)
+ public String addDeploymentContent(String name, InputStream contentIS, DeploymentPhase phase)
throws IOException
{
// TODO
throw new IOException("Not yet implemented");
}
+ public String[] getRepositoryNames(String[] names, DeploymentPhase phase)
+ throws IOException
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
public VirtualFile getDeploymentContent(String vfsPath, DeploymentPhase phase)
throws IOException
{
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-06-26 18:50:32 UTC (rev 75133)
+++ trunk/system/src/main/org/jboss/system/server/profileservice/repository/SerializableDeploymentRepository.java 2008-06-26 20:29:53 UTC (rev 75134)
@@ -29,6 +29,7 @@
import java.io.ObjectOutputStream;
import java.io.SyncFailedException;
import java.net.URI;
+import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -86,8 +87,8 @@
private File deployersDir;
/** The application phase deployments dir */
private File[] applicationDirs;
- /** The application phase deployments dir */
- private final Map<String, VirtualFile> deployDirs = new HashMap<String, VirtualFile>();
+ /** The application phase deployment files keyed by VirtualFile URI string */
+ private final Map<String, VirtualFile> applicationVFCache = new HashMap<String, VirtualFile>();
/** The deployment post edit root location */
private File adminEditsRoot;
/** The profile key this repository is associated with */
@@ -214,34 +215,10 @@
return names;
}
- public Set<String> getDeploymentNamesForType(String type)
- {
- HashSet<String> names = new HashSet<String>();
- for(VFSDeployment ctx : bootstrapCtxs.values())
- {
- Set<String> types = ctx.getTypes();
- if( types != null && types.contains(type) )
- names.add(ctx.getName());
- }
- for(VFSDeployment ctx : deployerCtxs.values())
- {
- Set<String> types = ctx.getTypes();
- if( types != null && types.contains(type) )
- names.add(ctx.getName());
- }
- for(VFSDeployment ctx : applicationCtxs.values())
- {
- Set<String> types = ctx.getTypes();
- if( types != null && types.contains(type) )
- names.add(ctx.getName());
- }
- return names;
- }
-
/**
*
*/
- public void addDeploymentContent(String name, InputStream contentIS, DeploymentPhase phase)
+ public String addDeploymentContent(String name, InputStream contentIS, DeploymentPhase phase)
throws IOException
{
boolean trace = log.isTraceEnabled();
@@ -249,6 +226,7 @@
if( trace )
log.trace("Aquiring content read lock");
contentLock.writeLock().lock();
+ String repositoryName = null;
try
{
// Write the content out
@@ -270,6 +248,16 @@
fos.write(tmp, 0, read);
}
fos.flush();
+ // Get the vfs uri for the content as the repository name
+ VirtualFile contentVF = VFS.getVirtualFile(contentRoot.toURI(), name);
+ try
+ {
+ repositoryName = contentVF.toURI().toString();
+ }
+ catch (URISyntaxException e)
+ {
+ log.error("Should not happen", e);
+ }
}
finally
{
@@ -281,7 +269,6 @@
{
}
}
- //contentIS.close();
// Lock the content
lockDeploymentContent(name, phase);
@@ -293,21 +280,58 @@
if(trace)
log.trace("Released content write lock");
}
+ return repositoryName;
}
- public VirtualFile getDeploymentContent(String vfsPath, DeploymentPhase phase)
- throws IOException
+ /**
+ * @throws URISyntaxException
+ *
+ */
+ public VirtualFile getDeploymentContent(String name, DeploymentPhase phase)
+ throws IOException, URISyntaxException
{
- File rootDir = getPhaseDir(phase);
- // todo - will this work if vfsPath is more than just name?
- File contentDir = new File(rootDir, vfsPath);
+ // find the cached root
+ switch( phase )
+ {
+ case BOOTSTRAP:
+ case DEPLOYER:
+ throw new IOException(phase+" content access not supported");
+ case APPLICATION:
+ case APPLICATION_TRANSIENT:
+ break;
+ }
// get cached version
- VirtualFile content = getDeployDir(contentDir);
- if(content == null)
- throw new FileNotFoundException(vfsPath+" not found under root: "+rootDir);
+ URI uri = new URI(name);
+ VirtualFile content = getCachedApplicationVF(uri);
+ if(content == null || content.exists() == false)
+ throw new FileNotFoundException("Failed to find content for: "+name);
return content;
}
+ public String[] getRepositoryNames(String[] names, DeploymentPhase phase)
+ throws IOException
+ {
+ ArrayList<String> tmp = new ArrayList<String>();
+ URI rootURI = this.getDeploymentURI(phase);
+ VirtualFile root = VFS.getRoot(rootURI);
+ for(String name : names)
+ {
+ VirtualFile content = root.getChild(name);
+ try
+ {
+ String rname = content.toURI().toString();
+ tmp.add(rname);
+ }
+ catch (URISyntaxException e)
+ {
+ log.error("Should not happen", e);
+ }
+ }
+ String[] rnames = new String[tmp.size()];
+ tmp.toArray(rnames);
+ return rnames;
+ }
+
public void lockDeploymentContent(String vfsPath, DeploymentPhase phase)
{
lockedApps.add(vfsPath);
@@ -473,7 +497,7 @@
// Now check for additions
for (File applicationDir : applicationDirs)
{
- VirtualFile deployDir = getDeployDir(applicationDir);
+ VirtualFile deployDir = getCachedApplicationVF(applicationDir);
List<VirtualFile> children = deployDir.getChildren();
for(VirtualFile vf : children)
{
@@ -483,6 +507,8 @@
VFSDeployment ctx = loadDeploymentData(vf);
ModificationInfo info = new ModificationInfo(ctx, vf.getLastModified(), ModifyStatus.ADDED);
modified.add(info);
+ if(key.startsWith("test"))
+ log.error("Should not see a test... key");
applicationCtxs.put(key, ctx);
}
}
@@ -637,7 +663,10 @@
VFS deployersVFS = VFS.getVFS(deployersDir.toURI());
loadDeployers(deployersVFS.getRoot());
for (File applicationDir : applicationDirs)
- loadApplications(getDeployDir(applicationDir));
+ {
+ VirtualFile dirVF = getCachedApplicationVF(applicationDir);
+ loadApplications(dirVF);
+ }
this.lastModified = System.currentTimeMillis();
}
@@ -649,10 +678,10 @@
* @return virtual file representing app dir
* @throws IOException for any error
*/
- protected VirtualFile getDeployDir(File applicationDir) throws IOException
+ protected VirtualFile getCachedApplicationVF(File applicationDir) throws IOException
{
URI uri = applicationDir.toURI();
- return getDeployDir(uri);
+ return getCachedApplicationVF(uri);
}
/**
@@ -662,17 +691,17 @@
* @return virtual file representing app uri
* @throws IOException for any error
*/
- protected VirtualFile getDeployDir(URI uri) throws IOException
+ protected VirtualFile getCachedApplicationVF(URI uri) throws IOException
{
String uriString = uri.toString();
VirtualFile dir;
- synchronized (deployDirs)
+ synchronized (applicationVFCache)
{
- dir = deployDirs.get(uriString);
+ dir = applicationVFCache.get(uriString);
if (dir == null)
{
dir = VFS.getRoot(uri);
- deployDirs.put(uriString, dir);
+ applicationVFCache.put(uriString, dir);
}
}
return dir;
@@ -728,6 +757,8 @@
protected void addApplication(String vfsPath, VFSDeployment ctx)
throws Exception
{
+ if(vfsPath.startsWith("test"))
+ log.error("Should not see a test... key");
this.applicationCtxs.put(vfsPath, ctx);
}
@@ -892,7 +923,9 @@
File profileRoot = new File(root, key.getName());
File confDir = new File(profileRoot, "conf");
VirtualFile confVF = VFS.getRoot(confDir.toURI());
- VirtualFile jbossServiceVF = confVF.findChild("jboss-service.xml");
+ VirtualFile jbossServiceVF = confVF.getChild("jboss-service.xml");
+ if(jbossServiceVF == null)
+ throw new FileNotFoundException("Failed to find jboss-service.xml under conf");
VFSDeployment vfCtx = loadDeploymentData(jbossServiceVF);
bootstrapCtxs.put(vfCtx.getName(), vfCtx);
}
@@ -928,7 +961,10 @@
for(VirtualFile vf : children)
{
VFSDeployment vfCtx = loadDeploymentData(vf);
- applicationCtxs.put(vfCtx.getName(), vfCtx);
+ 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/profileservice/test/DeployUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/DeployUnitTestCase.java 2008-06-26 18:50:32 UTC (rev 75133)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/DeployUnitTestCase.java 2008-06-26 20:29:53 UTC (rev 75134)
@@ -22,6 +22,7 @@
package org.jboss.test.profileservice.test;
import java.net.URL;
+import java.util.Arrays;
import java.util.Set;
import javax.naming.InitialContext;
@@ -68,7 +69,6 @@
protected void testDeployment(String name, String type, ManagedDeploymentTester tester) throws Exception
{
DeploymentManager deployMgr = getDeploymentManager();
- String[] names = {name};
URL contentURL = getDeployURL(name);
assertNotNull(contentURL);
getLog().debug(contentURL);
@@ -82,6 +82,7 @@
DeploymentProgress progress = deployMgr.distribute(name, DeploymentPhase.APPLICATION, contentURL);
progress.addProgressListener(this);
progress.run();
+ String[] uploadedNames = {};
try
{
status = progress.getDeploymentStatus();
@@ -90,8 +91,11 @@
assertFalse("DeploymentStatus.isRunning", status.isRunning());
assertFalse("DeploymentStatus.isFailed", status.isFailed());
+ // Get the unique deployment name
+ uploadedNames = progress.getDeploymentID().getRepositoryNames();
+ getLog().debug("Uploaded deployment names: "+Arrays.asList(uploadedNames));
// Now start the deployment
- progress = deployMgr.start(DeploymentPhase.APPLICATION, names);
+ progress = deployMgr.start(DeploymentPhase.APPLICATION, uploadedNames);
progress.addProgressListener(this);
progress.run();
try
@@ -102,7 +106,7 @@
assertFalse("DeploymentStatus.isFailed", status.isFailed());
// Check for a
ManagementView mgtView = getManagementView();
- ManagedDeployment deployment = mgtView.getDeployment(name, DeploymentPhase.APPLICATION);
+ ManagedDeployment deployment = mgtView.getDeployment(uploadedNames[0], DeploymentPhase.APPLICATION);
assertNotNull(deployment);
getLog().info("Found " + type + " deployment: " + deployment);
Set<String> types = deployment.getTypes();
@@ -118,7 +122,7 @@
//Thread.sleep(15 * 1000); // 15 secs >> more than it takes for reaper to run :-)
// Stop/remove the deployment
- progress = deployMgr.stop(DeploymentPhase.APPLICATION, names);
+ progress = deployMgr.stop(DeploymentPhase.APPLICATION, uploadedNames);
progress.addProgressListener(this);
progress.run();
status = progress.getDeploymentStatus();
@@ -128,7 +132,7 @@
}
finally
{
- progress = deployMgr.undeploy(DeploymentPhase.APPLICATION, names);
+ progress = deployMgr.undeploy(DeploymentPhase.APPLICATION, uploadedNames);
progress.addProgressListener(this);
progress.run();
status = progress.getDeploymentStatus();
More information about the jboss-cvs-commits
mailing list