/hg/icedtea-web: Minor change to Resource Status names.
jkang at icedtea.classpath.org
jkang at icedtea.classpath.org
Wed Aug 20 14:41:56 UTC 2014
changeset 0191d719163b in /hg/icedtea-web
details: http://icedtea.classpath.org/hg/icedtea-web?cmd=changeset;node=0191d719163b
author: Jie Kang <jkang at redhat.com>
date: Wed Aug 20 10:37:44 2014 -0400
Minor change to Resource Status names.
2014-08-20 Jie Kang <jkang at redhat.com>
Renamed Resource Status Enum fields to better describe their meaning.
CONNECT is now PRECONNECT, DOWNLOAD is now PREDOWNLOAD and STARTED is
now PROCESSING.
* netx/net/sourceforge/jnlp/cache/Resource.java: rename enum usages
* netx/net/sourceforge/jnlp/cache/ResourceTracker.java: same
* tests/netx/unit/net/sourceforge/jnlp/cache/ResourceTest.java: same
* tests/netx/unit/net/sourceforge/jnlp/cache/ResourceTrackerTest.java: same
diffstat:
ChangeLog | 10 ++
netx/net/sourceforge/jnlp/cache/Resource.java | 8 +-
netx/net/sourceforge/jnlp/cache/ResourceTracker.java | 49 +++++----
tests/netx/unit/net/sourceforge/jnlp/cache/ResourceTest.java | 34 +++---
tests/netx/unit/net/sourceforge/jnlp/cache/ResourceTrackerTest.java | 3 -
5 files changed, 58 insertions(+), 46 deletions(-)
diffs (289 lines):
diff -r b4363c984e1b -r 0191d719163b ChangeLog
--- a/ChangeLog Wed Aug 06 14:35:44 2014 +0200
+++ b/ChangeLog Wed Aug 20 10:37:44 2014 -0400
@@ -1,3 +1,13 @@
+2014-08-20 Jie Kang <jkang at redhat.com>
+
+ Renamed Resource Status Enum fields to better describe their meaning.
+ CONNECT is now PRECONNECT, DOWNLOAD is now PREDOWNLOAD and STARTED is
+ now PROCESSING.
+ * netx/net/sourceforge/jnlp/cache/Resource.java: rename enum usages
+ * netx/net/sourceforge/jnlp/cache/ResourceTracker.java: same
+ * tests/netx/unit/net/sourceforge/jnlp/cache/ResourceTest.java: same
+ * tests/netx/unit/net/sourceforge/jnlp/cache/ResourceTrackerTest.java: same
+
2014-08-05 Jiri Vanek <jvanek at redhat.com>
Massively improved offline abilities. Added Xoffline switch to force work without inet connection.
diff -r b4363c984e1b -r 0191d719163b netx/net/sourceforge/jnlp/cache/Resource.java
--- a/netx/net/sourceforge/jnlp/cache/Resource.java Wed Aug 06 14:35:44 2014 +0200
+++ b/netx/net/sourceforge/jnlp/cache/Resource.java Wed Aug 20 10:37:44 2014 -0400
@@ -54,14 +54,14 @@
// only once, regardless of UpdatePolicy. verify and fix.
public enum Status {
- CONNECT,
+ PRECONNECT,
CONNECTING,
CONNECTED,
- DOWNLOAD,
+ PREDOWNLOAD,
DOWNLOADING,
DOWNLOADED,
ERROR,
- STARTED // enqueued or being worked on
+ PROCESSING // in queue or being worked on
}
/** list of weak references of resources currently in use */
@@ -157,7 +157,7 @@
/**
* Set the url to use for downloading the resource
- * @param location
+ * @param downloadLocation
*/
public void setDownloadLocation(URL downloadLocation) {
this.downloadLocation = downloadLocation;
diff -r b4363c984e1b -r 0191d719163b netx/net/sourceforge/jnlp/cache/ResourceTracker.java
--- a/netx/net/sourceforge/jnlp/cache/ResourceTracker.java Wed Aug 06 14:35:44 2014 +0200
+++ b/netx/net/sourceforge/jnlp/cache/ResourceTracker.java Wed Aug 20 10:37:44 2014 -0400
@@ -16,7 +16,14 @@
package net.sourceforge.jnlp.cache;
-import static net.sourceforge.jnlp.cache.Resource.Status.*;
+import static net.sourceforge.jnlp.cache.Resource.Status.PRECONNECT;
+import static net.sourceforge.jnlp.cache.Resource.Status.CONNECTED;
+import static net.sourceforge.jnlp.cache.Resource.Status.CONNECTING;
+import static net.sourceforge.jnlp.cache.Resource.Status.PREDOWNLOAD;
+import static net.sourceforge.jnlp.cache.Resource.Status.DOWNLOADED;
+import static net.sourceforge.jnlp.cache.Resource.Status.DOWNLOADING;
+import static net.sourceforge.jnlp.cache.Resource.Status.ERROR;
+import static net.sourceforge.jnlp.cache.Resource.Status.PROCESSING;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
@@ -27,11 +34,9 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
-import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
-import java.net.UnknownHostException;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
@@ -255,7 +260,7 @@
// they will just 'pass through' the tracker as if they were
// never added (for example, not affecting the total download size).
synchronized (resource) {
- resource.changeStatus(EnumSet.noneOf(Resource.Status.class), EnumSet.of(DOWNLOADED, CONNECTED, STARTED));
+ resource.changeStatus(EnumSet.noneOf(Resource.Status.class), EnumSet.of(DOWNLOADED, CONNECTED, PROCESSING));
}
fireDownloadEvent(resource);
return true;
@@ -271,7 +276,7 @@
resource.setLocalFile(CacheUtil.getCacheFile(resource.getLocation(), resource.getDownloadVersion()));
resource.setSize(resource.getLocalFile().length());
resource.setTransferred(resource.getLocalFile().length());
- resource.changeStatus(EnumSet.noneOf(Resource.Status.class), EnumSet.of(DOWNLOADED, CONNECTED, STARTED));
+ resource.changeStatus(EnumSet.noneOf(Resource.Status.class), EnumSet.of(DOWNLOADED, CONNECTED, PROCESSING));
}
fireDownloadEvent(resource);
return true;
@@ -506,14 +511,14 @@
if (resource.isSet(ERROR))
return true;
- enqueue = !resource.isSet(STARTED);
+ enqueue = !resource.isSet(PROCESSING);
if (!(resource.isSet(CONNECTED) || resource.isSet(CONNECTING)))
- resource.changeStatus(EnumSet.noneOf(Resource.Status.class), EnumSet.of(CONNECT, STARTED));
+ resource.changeStatus(EnumSet.noneOf(Resource.Status.class), EnumSet.of(PRECONNECT, PROCESSING));
if (!(resource.isSet(DOWNLOADED) || resource.isSet(DOWNLOADING)))
- resource.changeStatus(EnumSet.noneOf(Resource.Status.class), EnumSet.of(DOWNLOAD, STARTED));
+ resource.changeStatus(EnumSet.noneOf(Resource.Status.class), EnumSet.of(PREDOWNLOAD, PROCESSING));
- if (!(resource.isSet(DOWNLOAD) || resource.isSet(CONNECT)))
+ if (!(resource.isSet(PREDOWNLOAD) || resource.isSet(PRECONNECT)))
enqueue = false;
}
@@ -586,7 +591,7 @@
*/
private void queueResource(Resource resource) {
synchronized (lock) {
- if (!(resource.isSet(CONNECT) || resource.isSet(DOWNLOAD)))
+ if (!(resource.isSet(PRECONNECT) || resource.isSet(PREDOWNLOAD)))
throw new IllegalResourceDescriptorException("Invalid resource state (resource: " + resource + ")");
queue.add(resource);
@@ -612,7 +617,7 @@
synchronized (resource) {
// return to queue if we just initalized but it still needs
// to download (not cached locally / out of date)
- if (resource.isSet(DOWNLOAD)) // would be DOWNLOADING if connected before this method
+ if (resource.isSet(PREDOWNLOAD)) // would be DOWNLOADING if connected before this method
queueResource(resource);
if (resource.isSet(DOWNLOADING))
@@ -828,11 +833,11 @@
resource.setLocalFile(localFile);
// resource.connection = connection;
resource.setSize(size);
- resource.changeStatus(EnumSet.of(CONNECT, CONNECTING), EnumSet.of(CONNECTED));
+ resource.changeStatus(EnumSet.of(PRECONNECT, CONNECTING), EnumSet.of(CONNECTED));
// check if up-to-date; if so set as downloaded
if (current)
- resource.changeStatus(EnumSet.of(DOWNLOAD, DOWNLOADING), EnumSet.of(DOWNLOADED));
+ resource.changeStatus(EnumSet.of(PREDOWNLOAD, DOWNLOADING), EnumSet.of(DOWNLOADED));
}
// update cache entry
@@ -1010,7 +1015,7 @@
* resource tracker with prefetch enabled.
* <p>
* The resource state is advanced before it is returned
- * (CONNECT->CONNECTING).
+ * (PRECONNECT->CONNECTING).
* </p>
* <p>
* Calls to this method should be synchronized on lock.
@@ -1022,9 +1027,9 @@
Resource result;
// pick from queue
- result = selectByStatus(queue, CONNECT, ERROR); // connect but not error
+ result = selectByStatus(queue, PRECONNECT, ERROR); // connect but not error
if (result == null)
- result = selectByStatus(queue, EnumSet.of(DOWNLOAD), EnumSet.of(ERROR, CONNECT, CONNECTING));
+ result = selectByStatus(queue, EnumSet.of(PREDOWNLOAD), EnumSet.of(ERROR, PRECONNECT, CONNECTING));
// remove from queue if found
if (result != null)
@@ -1038,14 +1043,14 @@
return null;
synchronized (result) {
- if (result.isSet(CONNECT)) {
- result.changeStatus(EnumSet.of(CONNECT), EnumSet.of(CONNECTING));
- } else if (result.isSet(DOWNLOAD)) {
+ if (result.isSet(PRECONNECT)) {
+ result.changeStatus(EnumSet.of(PRECONNECT), EnumSet.of(CONNECTING));
+ } else if (result.isSet(PREDOWNLOAD)) {
// only download if *not* connecting, when done connecting
// select next will pick up the download part. This makes
// all requested connects happen before any downloads, so
// the size is known as early as possible.
- result.changeStatus(EnumSet.of(DOWNLOAD), EnumSet.of(DOWNLOADING));
+ result.changeStatus(EnumSet.of(PREDOWNLOAD), EnumSet.of(DOWNLOADING));
}
}
@@ -1079,7 +1084,7 @@
});
if (result == null && alternate == null)
- alternate = selectByStatus(tracker.resources, EnumSet.of(CONNECTED), EnumSet.of(ERROR, DOWNLOADED, DOWNLOADING, DOWNLOAD));
+ alternate = selectByStatus(tracker.resources, EnumSet.of(CONNECTED), EnumSet.of(ERROR, DOWNLOADED, DOWNLOADING, PREDOWNLOAD));
}
}
}
@@ -1098,7 +1103,7 @@
// prevents startResource from putting it on queue since
// we're going to return it.
- result.changeStatus(EnumSet.noneOf(Resource.Status.class), EnumSet.of(STARTED));
+ result.changeStatus(EnumSet.noneOf(Resource.Status.class), EnumSet.of(PROCESSING));
tracker.startResource(result);
}
diff -r b4363c984e1b -r 0191d719163b tests/netx/unit/net/sourceforge/jnlp/cache/ResourceTest.java
--- a/tests/netx/unit/net/sourceforge/jnlp/cache/ResourceTest.java Wed Aug 06 14:35:44 2014 +0200
+++ b/tests/netx/unit/net/sourceforge/jnlp/cache/ResourceTest.java Wed Aug 20 10:37:44 2014 -0400
@@ -37,10 +37,10 @@
package net.sourceforge.jnlp.cache;
-import static net.sourceforge.jnlp.cache.Resource.Status.CONNECT;
+import static net.sourceforge.jnlp.cache.Resource.Status.PRECONNECT;
import static net.sourceforge.jnlp.cache.Resource.Status.CONNECTED;
import static net.sourceforge.jnlp.cache.Resource.Status.CONNECTING;
-import static net.sourceforge.jnlp.cache.Resource.Status.DOWNLOAD;
+import static net.sourceforge.jnlp.cache.Resource.Status.PREDOWNLOAD;
import static net.sourceforge.jnlp.cache.Resource.Status.DOWNLOADED;
import static net.sourceforge.jnlp.cache.Resource.Status.DOWNLOADING;
import static org.junit.Assert.assertEquals;
@@ -143,38 +143,38 @@
@Test
public void testSetFlag() throws Exception {
Resource res = createResource("SetFlag");
- setStatus(res, EnumSet.of(CONNECT));
+ setStatus(res, EnumSet.of(PRECONNECT));
assertFalse("Resource should have been initialized", isUninitialized(res));
- assertTrue("Resource should have had CONNECT set", hasFlag(res, CONNECT));
- assertTrue("Resource should have only had CONNECT set", hasOnly(res, EnumSet.of(CONNECT)));
+ assertTrue("Resource should have had PRECONNECT set", hasFlag(res, PRECONNECT));
+ assertTrue("Resource should have only had PRECONNECT set", hasOnly(res, EnumSet.of(PRECONNECT)));
}
@Test
public void testSetMultipleFlags() throws Exception {
Resource res = createResource("SetFlags");
- setStatus(res, EnumSet.of(CONNECT, DOWNLOAD));
+ setStatus(res, EnumSet.of(PRECONNECT, PREDOWNLOAD));
assertFalse("Resource should have been initialized", isUninitialized(res));
- assertTrue("Resource should have had CONNECT set", hasFlag(res, CONNECT));
- assertTrue("Resource should have had DOWNLOAD set", hasFlag(res, DOWNLOAD));
- assertTrue("Resource should have only had CONNECT and DOWNLOAD set", hasOnly(res, EnumSet.of(CONNECT, DOWNLOAD)));
+ assertTrue("Resource should have had PRECONNECT set", hasFlag(res, PRECONNECT));
+ assertTrue("Resource should have had PREDOWNLOAD set", hasFlag(res, PREDOWNLOAD));
+ assertTrue("Resource should have only had PRECONNECT and PREDOWNLOAD set", hasOnly(res, EnumSet.of(PRECONNECT, PREDOWNLOAD)));
}
@Test
public void testChangeStatus() throws Exception {
Resource res = createResource("ChangeStatus");
- setStatus(res, EnumSet.of(CONNECT));
- assertTrue("Resource should have had CONNECT set", hasFlag(res, CONNECT));
- assertTrue("Resource should have only had CONNECT set", hasOnly(res, EnumSet.of(CONNECT)));
+ setStatus(res, EnumSet.of(PRECONNECT));
+ assertTrue("Resource should have had PRECONNECT set", hasFlag(res, PRECONNECT));
+ assertTrue("Resource should have only had PRECONNECT set", hasOnly(res, EnumSet.of(PRECONNECT)));
- Collection<Resource.Status> downloadFlags = EnumSet.of(DOWNLOAD, DOWNLOADING, DOWNLOADED);
- Collection<Resource.Status> connectFlags = EnumSet.of(CONNECT, CONNECTING, CONNECTED);
+ Collection<Resource.Status> downloadFlags = EnumSet.of(PREDOWNLOAD, DOWNLOADING, DOWNLOADED);
+ Collection<Resource.Status> connectFlags = EnumSet.of(PRECONNECT, CONNECTING, CONNECTED);
changeStatus(res, connectFlags, downloadFlags);
- assertTrue("Resource should have had DOWNLOAD set", hasFlag(res, DOWNLOAD));
+ assertTrue("Resource should have had PREDOWNLOAD set", hasFlag(res, PREDOWNLOAD));
assertTrue("Resource should have had DOWNLOADING set", hasFlag(res, DOWNLOADING));
assertTrue("Resource should have had DOWNLOADED set", hasFlag(res, DOWNLOADED));
- assertTrue("Resource should have only had DOWNLOAD{,ING,ED} flags set", hasOnly(res, downloadFlags));
- assertFalse("Resource should not have had CONNECT set", hasFlag(res, CONNECT));
+ assertTrue("Resource should have only had PREDOWNLOAD{,ING,ED} flags set", hasOnly(res, downloadFlags));
+ assertFalse("Resource should not have had PRECONNECT set", hasFlag(res, PRECONNECT));
}
private static Resource createResource(String testName) throws MalformedURLException {
diff -r b4363c984e1b -r 0191d719163b tests/netx/unit/net/sourceforge/jnlp/cache/ResourceTrackerTest.java
--- a/tests/netx/unit/net/sourceforge/jnlp/cache/ResourceTrackerTest.java Wed Aug 06 14:35:44 2014 +0200
+++ b/tests/netx/unit/net/sourceforge/jnlp/cache/ResourceTrackerTest.java Wed Aug 20 10:37:44 2014 -0400
@@ -36,10 +36,7 @@
*/
package net.sourceforge.jnlp.cache;
-import static net.sourceforge.jnlp.cache.Resource.Status.CONNECT;
import static net.sourceforge.jnlp.cache.Resource.Status.CONNECTED;
-import static net.sourceforge.jnlp.cache.Resource.Status.CONNECTING;
-import static net.sourceforge.jnlp.cache.Resource.Status.DOWNLOADED;
import static net.sourceforge.jnlp.cache.Resource.Status.DOWNLOADING;
import static net.sourceforge.jnlp.cache.Resource.Status.ERROR;
More information about the distro-pkg-dev
mailing list