Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlyn Normington2012-02-01 11:55:42 -0500
committerGlyn Normington2012-02-01 11:55:42 -0500
commit38e83705479e7bcbaa379227f7446e33a2d37a77 (patch)
tree324d055961a3d287e7d9c1402725bb59a469e7fe
parentfcb5175eaae234059ec0a49d499159831322a010 (diff)
downloadorg.eclipse.virgo.kernel-38e83705479e7bcbaa379227f7446e33a2d37a77.tar.gz
org.eclipse.virgo.kernel-38e83705479e7bcbaa379227f7446e33a2d37a77.tar.xz
org.eclipse.virgo.kernel-38e83705479e7bcbaa379227f7446e33a2d37a77.zip
365034: add fix and further test - currently failing
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/PlanDeploymentWithDAGTests.java26
-rw-r--r--org.eclipse.virgo.kernel.deployer.test/src/test/resources/testunscopednonatomicD.plan11
-rw-r--r--org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/deployer/core/internal/ExistingNodeLocator.java34
-rw-r--r--org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/deployer/core/internal/PipelinedApplicationDeployer.java4
-rw-r--r--org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/deployer/core/internal/PlanResolver.java56
-rw-r--r--org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/StandardPlanInstallArtifact.java2
6 files changed, 95 insertions, 38 deletions
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/PlanDeploymentWithDAGTests.java b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/PlanDeploymentWithDAGTests.java
index 8d093c8d..8134556f 100644
--- a/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/PlanDeploymentWithDAGTests.java
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/java/org/eclipse/virgo/kernel/deployer/test/PlanDeploymentWithDAGTests.java
@@ -167,7 +167,7 @@ public class PlanDeploymentWithDAGTests extends AbstractDeployerIntegrationTest
@Test
public void planReferencingAnAlreadyInstalledBundleNotInRepositoryUndeployBundleFirst() throws Exception {
- File file = new File("src/test/resources/plan-deployment/simple.bundle.three.jar");
+ File file = new File("src/test/resources/plan-deployment-dag/simple.bundle.three.jar");
DeploymentIdentity deploymentId = this.deployer.deploy(file.toURI());
assertBundlesInstalled(this.context.getBundles(), BUNDLE_THREE_SYMBOLIC_NAME);
@@ -181,6 +181,30 @@ public class PlanDeploymentWithDAGTests extends AbstractDeployerIntegrationTest
this.deployer.undeploy(deploymentIdentity);
assertBundlesNotInstalled(this.context.getBundles(), BUNDLE_THREE_SYMBOLIC_NAME);
}
+
+ @Test
+ public void twoPlansReferencingAnAlreadyInstalledBundleNotInRepository() throws Exception {
+
+ File file = new File("src/test/resources/plan-deployment-dag/simple.bundle.three.jar");
+ DeploymentIdentity bundleDeploymentId = this.deployer.deploy(file.toURI());
+ assertBundlesInstalled(this.context.getBundles(), BUNDLE_THREE_SYMBOLIC_NAME);
+
+ DeploymentIdentity planCDeploymentId = this.deployer.deploy(new File("src/test/resources/testunscopednonatomicC.plan").toURI());
+ assertBundlesInstalled(this.context.getBundles(), BUNDLE_THREE_SYMBOLIC_NAME);
+
+ DeploymentIdentity planDDeploymentId = this.deployer.deploy(new File("src/test/resources/testunscopednonatomicD.plan").toURI());
+ assertBundlesInstalled(this.context.getBundles(), BUNDLE_THREE_SYMBOLIC_NAME);
+
+ this.deployer.undeploy(planCDeploymentId);
+ assertBundlesInstalled(this.context.getBundles(), BUNDLE_THREE_SYMBOLIC_NAME);
+
+ this.deployer.undeploy(bundleDeploymentId.getType(), bundleDeploymentId.getSymbolicName(), bundleDeploymentId.getVersion());
+ assertBundlesInstalled(this.context.getBundles(), BUNDLE_THREE_SYMBOLIC_NAME);
+
+ this.deployer.undeploy(planDDeploymentId);
+ assertBundlesNotInstalled(this.context.getBundles(), BUNDLE_THREE_SYMBOLIC_NAME);
+ }
+
static void assertBundlesActive(Bundle[] bundles, String... bsns) {
for (String bsn : bsns) {
diff --git a/org.eclipse.virgo.kernel.deployer.test/src/test/resources/testunscopednonatomicD.plan b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/testunscopednonatomicD.plan
new file mode 100644
index 00000000..6cf0f4e7
--- /dev/null
+++ b/org.eclipse.virgo.kernel.deployer.test/src/test/resources/testunscopednonatomicD.plan
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<plan name="testD.plan" version="1.0.0" scoped="false" atomic="false"
+ xmlns="http://www.eclipse.org/virgo/schema/plan"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://www.eclipse.org/virgo/schema/plan
+ http://www.eclipse.org/virgo/schema/plan/eclipse-virgo-plan.xsd">
+
+ <artifact type="bundle" name="simple.bundle.three" version="[1, 2)"/>
+
+</plan> \ No newline at end of file
diff --git a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/deployer/core/internal/ExistingNodeLocator.java b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/deployer/core/internal/ExistingNodeLocator.java
index 851cd945..ac7334ef 100644
--- a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/deployer/core/internal/ExistingNodeLocator.java
+++ b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/deployer/core/internal/ExistingNodeLocator.java
@@ -30,12 +30,12 @@ public final class ExistingNodeLocator implements DirectedAcyclicGraphVisitor<In
private final String name;
private final VersionRange versionRange;
-
+
/**
- * Searches the DAG from the given GC roots looking for an install artifact that matches the given graph node and returns
- * the first one it finds or <code>null</code> if none are found.
+ * Searches the DAG from the given GC roots looking for an install artifact with the given identity and returns the
+ * first one it finds or <code>null</code> if none are found.
*/
- public static GraphNode<InstallArtifact> findSharedNode(ArtifactIdentity artifactIdentity, GCRoots gcRoots) {
+ public static GraphNode<InstallArtifact> findSharedNode(GCRoots gcRoots, ArtifactIdentity artifactIdentity) {
ExistingNodeLocator visitor = new ExistingNodeLocator(artifactIdentity.getType(), artifactIdentity.getName(),
VersionRange.createExactRange(artifactIdentity.getVersion()), artifactIdentity.getScopeName());
for (InstallArtifact gcRoot : gcRoots) {
@@ -44,16 +44,28 @@ public final class ExistingNodeLocator implements DirectedAcyclicGraphVisitor<In
return visitor.getFoundNode();
}
-
/**
- * Searches the DAG from the given GC roots looking for an install artifact that matches the given graph node and returns
- * the first one it finds or <code>null</code> if none are found.
+ * Searches the DAG from the given GC roots looking for an install artifact with the given type, name, and scope
+ * name and with version in the given version range and returns the first one it finds or <code>null</code> if none
+ * are found.
+ */
+ public static GraphNode<InstallArtifact> findSharedNode(GCRoots gcRoots, String type, String name, VersionRange versionRange, String scopeName) {
+ ExistingNodeLocator visitor = new ExistingNodeLocator(type, name, versionRange, scopeName);
+ for (InstallArtifact gcRoot : gcRoots) {
+ gcRoot.getGraph().visit(visitor);
+ }
+ return visitor.getFoundNode();
+ }
+
+ /**
+ * Searches the DAG from the given GC roots looking for an install artifact that matches the given graph node and
+ * returns the first one it finds or <code>null</code> if none are found.
*/
- public static GraphNode<InstallArtifact> findSharedNode(GraphNode<InstallArtifact> installGraph, GCRoots gcRoots) {
+ public static GraphNode<InstallArtifact> findSharedNode(GCRoots gcRoots, GraphNode<InstallArtifact> installGraph) {
InstallArtifact installArtifact = installGraph.getValue();
- ArtifactIdentity artifactIdentity = new ArtifactIdentity(installArtifact.getType(), installArtifact.getName(),
- installArtifact.getVersion(), installArtifact.getScopeName());
- return findSharedNode(artifactIdentity, gcRoots);
+ ArtifactIdentity artifactIdentity = new ArtifactIdentity(installArtifact.getType(), installArtifact.getName(), installArtifact.getVersion(),
+ installArtifact.getScopeName());
+ return findSharedNode(gcRoots, artifactIdentity);
}
ExistingNodeLocator(@NonNull String type, @NonNull String name, @NonNull VersionRange versionRange, String scopeName) {
diff --git a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/deployer/core/internal/PipelinedApplicationDeployer.java b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/deployer/core/internal/PipelinedApplicationDeployer.java
index 63a41c96..2d2256a0 100644
--- a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/deployer/core/internal/PipelinedApplicationDeployer.java
+++ b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/deployer/core/internal/PipelinedApplicationDeployer.java
@@ -211,7 +211,7 @@ final class PipelinedApplicationDeployer implements ApplicationDeployer, Applica
private GraphNode<InstallArtifact> findSharedNode(ArtifactIdentity artifactIdentity) {
GCRoots gcRoots = (GCRoots) this.ram;
- return ExistingNodeLocator.findSharedNode(artifactIdentity, gcRoots);
+ return ExistingNodeLocator.findSharedNode(gcRoots, artifactIdentity);
}
private void destroyInstallGraph(GraphNode<InstallArtifact> installGraph) throws DeploymentException {
@@ -616,7 +616,7 @@ final class PipelinedApplicationDeployer implements ApplicationDeployer, Applica
this.ram.delete(deploymentIdentity);
// Avoid uninstalling an artifact which is shared by a plan.
- if (ExistingNodeLocator.findSharedNode(installArtifact.getGraph(), (GCRoots) this.ram) == null) {
+ if (ExistingNodeLocator.findSharedNode((GCRoots) this.ram, installArtifact.getGraph()) == null) {
stopArtifact(installArtifact);
uninstallArtifact(installArtifact);
return location;
diff --git a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/deployer/core/internal/PlanResolver.java b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/deployer/core/internal/PlanResolver.java
index 31ca5e7f12..c5bb829b 100644
--- a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/deployer/core/internal/PlanResolver.java
+++ b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/deployer/core/internal/PlanResolver.java
@@ -62,7 +62,7 @@ public class PlanResolver implements Transformer {
private final Repository repository;
private final ArtifactIdentityDeterminer artifactIdentityDeterminer;
-
+
private final EventLogger eventLogger;
public PlanResolver(@NonNull InstallArtifactGraphInclosure installArtifactGraphInclosure, @NonNull GCRoots gcRoots,
@@ -101,7 +101,8 @@ public class PlanResolver implements Transformer {
GraphNode<InstallArtifact> childInstallNode = obtainInstallArtifactGraph(artifactSpecification, scopeName,
planInstallArtifact.getProvisioning());
- if (childInstallNode.getParents().isEmpty()) {
+ boolean newNode = childInstallNode.getParents().isEmpty();
+ if (newNode) {
graph.addChild(childInstallNode);
// Put child into the INSTALLING state as Transformers (like this) are after the
// "begin install"
@@ -145,19 +146,33 @@ public class PlanResolver implements Transformer {
private GraphNode<InstallArtifact> obtainInstallArtifactGraph(ArtifactSpecification artifactSpecification, String scopeName,
Provisioning parentProvisioning) throws DeploymentException {
- ArtifactIdentity identity;
- File artifact;
+ GraphNode<InstallArtifact> sharedNode = null;
+ ArtifactIdentity identity = null;
+ File artifact = null;
Map<String, String> properties = determineDeploymentProperties(artifactSpecification.getProperties(), parentProvisioning);
String repositoryName = null;
URI uri = artifactSpecification.getUri();
if (uri == null) {
RepositoryAwareArtifactDescriptor repositoryAwareArtifactDescriptor = lookup(artifactSpecification);
- URI artifactUri = repositoryAwareArtifactDescriptor.getUri();
+ if (repositoryAwareArtifactDescriptor == null) {
+ String type = artifactSpecification.getType();
+ String name = artifactSpecification.getName();
+ VersionRange versionRange = artifactSpecification.getVersionRange();
+ sharedNode = findSharedNode(type, name, versionRange, null);
+ if (sharedNode == null) {
+ this.eventLogger.log(DeployerLogEvents.ARTIFACT_NOT_FOUND, type, name, versionRange, this.repository.getName());
+ throw new DeploymentException(type + " '" + name + "' in version range '" + versionRange + "' not found");
+ }
+ } else {
+ URI artifactUri = repositoryAwareArtifactDescriptor.getUri();
+
+ artifact = new File(artifactUri);
+ identity = new ArtifactIdentity(repositoryAwareArtifactDescriptor.getType(), repositoryAwareArtifactDescriptor.getName(),
+ repositoryAwareArtifactDescriptor.getVersion(), scopeName);
+ repositoryName = repositoryAwareArtifactDescriptor.getRepositoryName();
+ sharedNode = findSharedNode(identity);
+ }
- artifact = new File(artifactUri);
- identity = new ArtifactIdentity(repositoryAwareArtifactDescriptor.getType(), repositoryAwareArtifactDescriptor.getName(),
- repositoryAwareArtifactDescriptor.getVersion(), scopeName);
- repositoryName = repositoryAwareArtifactDescriptor.getRepositoryName();
} else {
try {
artifact = new File(uri);
@@ -165,8 +180,8 @@ public class PlanResolver implements Transformer {
throw new DeploymentException("Invalid artifact specification URI", e);
}
identity = determineIdentity(uri, scopeName);
+ sharedNode = findSharedNode(identity);
}
- GraphNode<InstallArtifact> sharedNode = findSharedNode(identity);
return sharedNode == null ? this.installArtifactGraphInclosure.constructGraphNode(identity, artifact, properties, repositoryName)
: sharedNode;
}
@@ -178,22 +193,13 @@ public class PlanResolver implements Transformer {
}
private RepositoryAwareArtifactDescriptor lookup(ArtifactSpecification specification) throws DeploymentException {
- if (specification.getUri() != null) {
- throw new IllegalArgumentException("Non-null artifact specification URI");
- }
String type = specification.getType();
String name = specification.getName();
VersionRange versionRange = specification.getVersionRange();
- RepositoryAwareArtifactDescriptor artifactDescriptor = this.repository.get(type, name, versionRange);
- if (artifactDescriptor == null) {
- this.eventLogger.log(DeployerLogEvents.ARTIFACT_NOT_FOUND, type, name, versionRange, this.repository.getName());
- throw new DeploymentException(type + " '" + name + "' version '" + versionRange + "' not found");
- }
-
- return artifactDescriptor;
+ return this.repository.get(type, name, versionRange);
}
-
+
private ArtifactIdentity determineIdentity(URI artifactUri, String scopeName) throws DeploymentException {
try {
File artifact = new File(artifactUri);
@@ -206,7 +212,7 @@ public class PlanResolver implements Transformer {
throw new DeploymentException(e.getMessage() + ": uri='" + artifactUri + "'", e);
}
}
-
+
private ArtifactIdentity determineIdentity(File file, String scopeName) throws DeploymentException {
ArtifactIdentity artifactIdentity = this.artifactIdentityDeterminer.determineIdentity(file, scopeName);
@@ -219,7 +225,11 @@ public class PlanResolver implements Transformer {
}
private GraphNode<InstallArtifact> findSharedNode(ArtifactIdentity artifactIdentity) {
- return ExistingNodeLocator.findSharedNode(artifactIdentity, this.gcRoots);
+ return ExistingNodeLocator.findSharedNode(this.gcRoots, artifactIdentity);
+ }
+
+ public GraphNode<InstallArtifact> findSharedNode(String type, String name, VersionRange versionRange, String scopeName) {
+ return ExistingNodeLocator.findSharedNode(this.gcRoots, type, name, versionRange, scopeName);
}
}
diff --git a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/StandardPlanInstallArtifact.java b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/StandardPlanInstallArtifact.java
index 08bf172c..19eda12e 100644
--- a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/StandardPlanInstallArtifact.java
+++ b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/StandardPlanInstallArtifact.java
@@ -167,7 +167,7 @@ public class StandardPlanInstallArtifact extends AbstractInstallArtifact impleme
for (GraphNode<InstallArtifact> child : getChildrenSnapshot()) {
getGraph().removeChild(child);
// Avoid uninstalling shared child
- if (ExistingNodeLocator.findSharedNode(child, this.gcRoots) == null) {
+ if (ExistingNodeLocator.findSharedNode(this.gcRoots, child) == null) {
try {
child.getValue().uninstall();
} catch (DeploymentException e) {

Back to the top