Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhsen Jaffer2014-05-01 14:41:24 -0400
committerFlorian Waibel2014-05-01 14:48:09 -0400
commitdacb6e3309c79565c64cc1a7cab1345cf675bd21 (patch)
tree2fdead6cc8a9052fa8a95fec0dde9d09abcb1a9d
parent4d03b4f2f77d42697e6722bcc06753ed23c25e7d (diff)
downloadorg.eclipse.virgo.kernel-dacb6e3309c79565c64cc1a7cab1345cf675bd21.tar.gz
org.eclipse.virgo.kernel-dacb6e3309c79565c64cc1a7cab1345cf675bd21.tar.xz
org.eclipse.virgo.kernel-dacb6e3309c79565c64cc1a7cab1345cf675bd21.zip
424872 Improves scalability of StandardBundleInstallArtifact
Signed-off-by: Ahsen Jaffer <ahsen.jaffer@gmail.com>
-rw-r--r--org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/bundle/StandardBundleInstallArtifact.java42
-rw-r--r--org.eclipse.virgo.kernel.deployer/src/test/java/org/eclipse/virgo/kernel/install/artifact/internal/bundle/StandardBundleInstallArtifactTests.java37
2 files changed, 71 insertions, 8 deletions
diff --git a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/bundle/StandardBundleInstallArtifact.java b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/bundle/StandardBundleInstallArtifact.java
index 8f7d4617..8058924e 100644
--- a/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/bundle/StandardBundleInstallArtifact.java
+++ b/org.eclipse.virgo.kernel.deployer/src/main/java/org/eclipse/virgo/kernel/install/artifact/internal/bundle/StandardBundleInstallArtifact.java
@@ -56,11 +56,11 @@ import org.slf4j.LoggerFactory;
/**
* {@link StandardBundleInstallArtifact} is the default implementation of {@link BundleInstallArtifact}.
* <p />
- *
+ *
* <strong>Concurrent Semantics</strong><br />
- *
+ *
* This class is thread safe.
- *
+ *
*/
final class StandardBundleInstallArtifact extends AbstractInstallArtifact implements BundleInstallArtifact {
@@ -90,10 +90,14 @@ final class StandardBundleInstallArtifact extends AbstractInstallArtifact implem
private QuasiBundle quasiBundle;
+ private Bundle cachedBundle;
+
+ private File cachedBundleFile;
+
/**
* Construct a {@link StandardBundleInstallArtifact} with the given type and {@link ArtifactStorage}, none of which
* may be <code>null</code>.
- *
+ *
* @param artifactIdentifier
* @param bundleManifest
* @param artifactStorage the bundle artifact storage
@@ -179,7 +183,13 @@ final class StandardBundleInstallArtifact extends AbstractInstallArtifact implem
*/
public Bundle getBundle() {
synchronized (this.monitor) {
- return this.quasiBundle == null ? null : this.quasiBundle.getBundle();
+ return this.quasiBundle == null ? this.cachedBundle : this.quasiBundle.getBundle();
+ }
+ }
+
+ private File getBundleFile() {
+ synchronized (this.monitor) {
+ return this.quasiBundle == null ? this.cachedBundleFile : this.quasiBundle.getBundleFile();
}
}
@@ -202,6 +212,7 @@ final class StandardBundleInstallArtifact extends AbstractInstallArtifact implem
public void endInstall() throws DeploymentException {
monitorBundle();
super.endInstall();
+ cacheAndDelete();
}
private void monitorBundle() {
@@ -214,6 +225,21 @@ final class StandardBundleInstallArtifact extends AbstractInstallArtifact implem
}
/**
+ * Cache the <code>Bundle</code> contained within the <code>quasiBundle</code> and set the <code>quasiBundle</code>
+ * instance to <code>null</code>. This is a fix for this PR: https://bugs.eclipse.org/bugs/show_bug.cgi?id=424872
+ */
+ private void cacheAndDelete() {
+ synchronized (this.monitor) {
+ if (this.quasiBundle == null) {
+ return;
+ }
+ this.cachedBundle = this.quasiBundle.getBundle();
+ this.cachedBundleFile = this.quasiBundle.getBundleFile();
+ this.quasiBundle = null;
+ }
+ }
+
+ /**
* {@inheritDoc}
*/
@Override
@@ -244,7 +270,7 @@ final class StandardBundleInstallArtifact extends AbstractInstallArtifact implem
}
super.beginInstall();
}
-
+
private boolean isFragment() {
return this.bundleManifest.getFragmentHost().getBundleSymbolicName() != null;
}
@@ -501,7 +527,7 @@ final class StandardBundleInstallArtifact extends AbstractInstallArtifact implem
}
public void deleteEntry(String targetPath) {
- deleteEntry(getQuasiBundle().getBundleFile(), targetPath);
+ deleteEntry(getBundleFile(), targetPath);
getArtifactFS().getEntry(targetPath).delete();
}
@@ -517,7 +543,7 @@ final class StandardBundleInstallArtifact extends AbstractInstallArtifact implem
}
public void updateEntry(URI inputPath, String targetPath) {
- updateEntry(getQuasiBundle().getBundleFile(), inputPath, targetPath);
+ updateEntry(getBundleFile(), inputPath, targetPath);
updateEntry(getArtifactFS().getEntry(targetPath), inputPath);
}
diff --git a/org.eclipse.virgo.kernel.deployer/src/test/java/org/eclipse/virgo/kernel/install/artifact/internal/bundle/StandardBundleInstallArtifactTests.java b/org.eclipse.virgo.kernel.deployer/src/test/java/org/eclipse/virgo/kernel/install/artifact/internal/bundle/StandardBundleInstallArtifactTests.java
index d710b54e..bd38d6fb 100644
--- a/org.eclipse.virgo.kernel.deployer/src/test/java/org/eclipse/virgo/kernel/install/artifact/internal/bundle/StandardBundleInstallArtifactTests.java
+++ b/org.eclipse.virgo.kernel.deployer/src/test/java/org/eclipse/virgo/kernel/install/artifact/internal/bundle/StandardBundleInstallArtifactTests.java
@@ -17,7 +17,9 @@ import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.isA;
import static org.easymock.EasyMock.isNull;
import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.io.File;
@@ -138,4 +140,39 @@ public class StandardBundleInstallArtifactTests {
installArtifact.getDeploymentProperties().put("foo", "bar");
assertEquals("bar", installArtifact.getDeploymentProperties().get("foo"));
}
+
+ @Test
+ public void endInstallShouldNullQuasiBundleReference() throws IOException, DeploymentException {
+
+ StandardBundleInstallArtifact uut = (StandardBundleInstallArtifact) createInstallArtifact(createArtifactStorage(), artifactStateMonitor);
+ QuasiBundle quasiBundle = createMock(QuasiBundle.class);
+ expect(quasiBundle.getBundle()).andReturn(null).anyTimes();
+ expect(quasiBundle.getBundleFile()).andReturn(null);
+
+ uut.setQuasiBundle(quasiBundle);
+
+ replay(quasiBundle);
+ uut.endInstall();
+ verify(quasiBundle);
+
+ assertNull(uut.getQuasiBundle());
+ }
+
+ @Test
+ public void endInstallShouldStoreBundleReference() throws IOException, DeploymentException {
+
+ StandardBundleInstallArtifact uut = (StandardBundleInstallArtifact) createInstallArtifact(createArtifactStorage(), artifactStateMonitor);
+ QuasiBundle quasiBundle = createMock(QuasiBundle.class);
+ StubBundle stubBundle = new StubBundle();
+ expect(quasiBundle.getBundle()).andReturn(stubBundle).anyTimes();
+ expect(quasiBundle.getBundleFile()).andReturn(null);
+
+ uut.setQuasiBundle(quasiBundle);
+
+ replay(quasiBundle);
+ uut.endInstall();
+ verify(quasiBundle);
+
+ assertEquals(stubBundle, uut.getBundle());
+ }
}

Back to the top