summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Bull2011-12-05 18:11:46 (EST)
committerIan Bull2011-12-05 18:11:46 (EST)
commit3ab674b9e4971c53b190f7d77f17c75ee13df4a0 (patch)
treeedcb669d66d66879828409112c758555cc20f1b5
parent82aeb8dee11f4114494fe3dd0ca1097312d2dfd5 (diff)
downloadrt.equinox.p2-3ab674b9e4971c53b190f7d77f17c75ee13df4a0.zip
rt.equinox.p2-3ab674b9e4971c53b190f7d77f17c75ee13df4a0.tar.gz
rt.equinox.p2-3ab674b9e4971c53b190f7d77f17c75ee13df4a0.tar.bz2
Revert "Fix 351944 to avoid unnecessary loading artifact repository when doing query, getting artifact descriptors via artifact key."v20111205-2311
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java16
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/AllTests.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/Bug351944.java103
-rwxr-xr-xbundles/org.eclipse.equinox.p2.tests/testData/bug351944/artifacts.jarbin127964 -> 0 bytes
4 files changed, 4 insertions, 116 deletions
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java
index 7997041..b365b03 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java
@@ -84,11 +84,6 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
* Does this instance of the repository currently hold a lock
*/
private boolean holdsLock = false;
- /**
- * Does this instance of the repository can be locked.
- * It will be initialized when initializing the location for repository
- */
- private Boolean canLock = null;
private long cacheTimestamp = 0l;
@@ -332,8 +327,7 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
boolean lockAcquired = false;
try {
- canLock = new Boolean(canLock());
- if (canLock.booleanValue()) {
+ if (canLock()) {
lockAcquired = lockAndLoad(true, new NullProgressMonitor());
if (!lockAcquired)
throw new IllegalStateException("Cannot acquire the lock for " + location); //$NON-NLS-1$
@@ -979,8 +973,6 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
desc.setRepository(this);
if (updateTimestamp)
updateTimestamp();
- if (canLock == null)
- canLock = new Boolean(canLock());
}
private String getBlobStoreName(String defaultValue) {
@@ -1433,11 +1425,11 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
}
/**
- * Returns true if this instance of SimpleArtifactRepository holds the lock or
- * this repository can't be locked at all due to permission, false otherwise.
+ * Returns true if this instance of SimpleArtifactRepository holds the lock,
+ * false otherwise.
*/
private boolean holdsLock() {
- return (canLock != null && !canLock.booleanValue()) || holdsLock;
+ return holdsLock;
}
/**URIUtil.toURI(location.toURI()
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/AllTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/AllTests.java
index 47f8205..74095af 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/AllTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/AllTests.java
@@ -27,7 +27,6 @@ public class AllTests extends TestCase {
suite.addTestSuite(BatchExecuteArtifactRepositoryTest.class);
suite.addTestSuite(Bug252308.class);
suite.addTestSuite(Bug265577.class);
- suite.addTestSuite(Bug351944.class);
suite.addTestSuite(CompositeArtifactRepositoryTest.class);
suite.addTestSuite(CorruptedJar.class);
suite.addTestSuite(FoldersRepositoryTest.class);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/Bug351944.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/Bug351944.java
deleted file mode 100644
index 16f7dc0..0000000
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/artifact/repository/Bug351944.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Wind River and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.p2.tests.artifact.repository;
-
-import java.io.File;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.*;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.equinox.p2.core.ProvisionException;
-import org.eclipse.equinox.p2.metadata.IArtifactKey;
-import org.eclipse.equinox.p2.query.IQueryResult;
-import org.eclipse.equinox.p2.repository.artifact.*;
-import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
-
-public class Bug351944 extends AbstractProvisioningTest {
-
- File artifactRepoFile = null;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- File testData = getTestData("artifact repository", "testData/bug351944");
- artifactRepoFile = getTempFolder();
- copy("Copy to temporary folder", testData, artifactRepoFile);
- changeWritePermission(artifactRepoFile, false);
- }
-
- private void changeWritePermission(File target, boolean canWrite) {
- if (target.exists()) {
- target.setWritable(canWrite, false);
- if (target.isDirectory()) {
- for (File child : target.listFiles())
- changeWritePermission(child, canWrite);
- }
- }
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- changeWritePermission(artifactRepoFile, true);
- delete(artifactRepoFile);
- }
-
- public void testSimpleRepositoryPerformanceOnLoadReadonlyLocalRepository() throws ProvisionException, URISyntaxException {
- final URI testRepo = artifactRepoFile.toURI();
- IArtifactRepositoryManager artifactRepositoryManager = getArtifactRepositoryManager();
- IArtifactRepository repo = artifactRepositoryManager.loadRepository(testRepo, new NullProgressMonitor());
- IQueryResult<IArtifactKey> allArtifactKeys = repo.query(ArtifactKeyQuery.ALL_KEYS, new NullProgressMonitor());
- Set<IArtifactKey> keySet = allArtifactKeys.toUnmodifiableSet();
-
- Collection<IArtifactRequest> requests = new ArrayList<IArtifactRequest>();
- for (IArtifactKey key : keySet)
- requests.add(artifactRepositoryManager.createMirrorRequest(key, repo, null, null));
-
- long start = System.currentTimeMillis();
- IArtifactRequest[] toBeRequests = getRequestsForRepository(repo, requests.toArray(new IArtifactRequest[requests.size()]));
- long end = System.currentTimeMillis();
- long queryArtifactOneByOne = end - start;
-
- start = System.currentTimeMillis();
- IArtifactRequest[] toBeRequests2 = getRequestsForRepository2(repo, requests.toArray(new IArtifactRequest[requests.size()]));
- end = System.currentTimeMillis();
- long queryAllArtifacts = end - start;
-
- assertEquals("Test case has problem, not find same requests.", toBeRequests.length, toBeRequests2.length);
- assertEquals("Querying artifact key from simple repository has performance issue.", queryAllArtifacts, queryArtifactOneByOne, 10);
- }
-
- /**
- * copy from {@link org.eclipse.equinox.internal.p2.engine.DownloadManager}
- * @param repository
- * @param requestsToProcess
- * @return
- */
- private IArtifactRequest[] getRequestsForRepository(IArtifactRepository repository, IArtifactRequest[] requestsToProcess) {
- ArrayList<IArtifactRequest> applicable = new ArrayList<IArtifactRequest>();
- for (IArtifactRequest request : requestsToProcess) {
- if (repository.contains(request.getArtifactKey()))
- applicable.add(request);
- }
- return applicable.toArray(new IArtifactRequest[applicable.size()]);
- }
-
- private IArtifactRequest[] getRequestsForRepository2(IArtifactRepository repository, IArtifactRequest[] requestsToProcess) {
- Set<IArtifactKey> keys = repository.query(ArtifactKeyQuery.ALL_KEYS, new NullProgressMonitor()).toSet();
- ArrayList<IArtifactRequest> applicable = new ArrayList<IArtifactRequest>();
- for (IArtifactRequest request : requestsToProcess) {
- if (keys.contains(request.getArtifactKey()))
- applicable.add(request);
- }
- return applicable.toArray(new IArtifactRequest[applicable.size()]);
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.tests/testData/bug351944/artifacts.jar b/bundles/org.eclipse.equinox.p2.tests/testData/bug351944/artifacts.jar
deleted file mode 100755
index be67007..0000000
--- a/bundles/org.eclipse.equinox.p2.tests/testData/bug351944/artifacts.jar
+++ /dev/null
Binary files differ