[grizzly-sendfile~main:280] grizzly-sendfile-server - fixing issues with duplicates and bogus files i
- From: igor_minar@kenai.com
- To: commits@grizzly-sendfile.kenai.com
- Subject: [grizzly-sendfile~main:280] grizzly-sendfile-server - fixing issues with duplicates and bogus files i
- Date: Thu, 14 Jan 2010 04:56:18 +0000
Project: grizzly-sendfile
Repository: main
Revision: 280
Author: igor_minar
Date: 2010-01-14 04:55:40 UTC
Link:
Log Message:
------------
disable maxConcurDownloads setting for single burst algorithms
grizzly-sendfile-server - rename
grizzly-sendfile-server-...-jar-with-dependencies.jar to ...-full.jar
grizzly-sendfile-server - fixing issues with duplicates and bogus files in
the 'full' assembly
Revisions:
----------
278
279
280
Modified Paths:
---------------
grizzly-sendfile-server/src/main/java/com/igorminar/grizzlysendfile/server/GrizzlySendfileServer.java
sendfile-core/src/main/java/com/igorminar/grizzlysendfile/SendfileConfig.java
sendfile-core/src/main/java/com/igorminar/grizzlysendfile/SendfileSelectorThread.java
sendfile-core/src/main/java/com/igorminar/grizzlysendfile/algorithm/SendfileAlgorithm.java
sendfile-core/src/main/java/com/igorminar/grizzlysendfile/algorithm/SimpleBlockingAlgorithm.java
sendfile-core/src/test/java/com/igorminar/grizzlysendfile/SendfileConfigTest.java
grizzly-sendfile-server/pom.xml
grizzly-sendfile-server/src/main/assembly/jar-assembly.xml
Added Paths:
------------
grizzly-sendfile-server/src/main/assembly/jar-assembly.xml
Diffs:
------
diff -r fbc868e1b037 -r 52827fddb773
grizzly-sendfile-server/src/main/java/com/igorminar/grizzlysendfile/server/GrizzlySendfileServer.java
---
a/grizzly-sendfile-server/src/main/java/com/igorminar/grizzlysendfile/server/GrizzlySendfileServer.java
Wed Jan 13 00:32:58 2010 -0800
+++
b/grizzly-sendfile-server/src/main/java/com/igorminar/grizzlysendfile/server/GrizzlySendfileServer.java
Wed Jan 13 14:33:40 2010 -0800
@@ -228,7 +228,7 @@
" -p --port: port to listen on\n" +
" -m --mode: grizzly-sendfile mode. Can be auto-sendfile
(default), servlet, grizzly or grizzly-async\n" +
" -t --thread-count: number of worker threads. default=" +
SendfileConfig.THREAD_COUNT_DEFAULT + "\n" +
- " -c --concur-download-max: max number of concurrently
processed downloads. default=" + SendfileConfig.MAX_CONCUR_DOWNLOADS_KEY +
"\n" +
+ " -c --concur-download-max: max number of concurrently
processed downloads (multi-burst algorithms only). default=" +
SendfileConfig.MAX_CONCUR_DOWNLOADS_DEFAULT + "\n" +
" -b --buffer-size: size of the buffer in bytes. default="
+ SendfileConfig.BUFFER_SIZE_DEFAULT + " (or 16000 for grizzly mode)\n" +
" -d --direct-buffers: allow use of direct buffers.
default=" + SendfileConfig.DIRECT_BUFFERS_ALLOWED_DEFAULT + "\n" +
" -s --ssl: turn on ssl support. Can be off (default) or
on\n" +
diff -r fbc868e1b037 -r 52827fddb773
sendfile-core/src/main/java/com/igorminar/grizzlysendfile/SendfileConfig.java
---
a/sendfile-core/src/main/java/com/igorminar/grizzlysendfile/SendfileConfig.java
Wed Jan 13 00:32:58 2010 -0800
+++
b/sendfile-core/src/main/java/com/igorminar/grizzlysendfile/SendfileConfig.java
Wed Jan 13 14:33:40 2010 -0800
@@ -81,6 +81,7 @@
public static final int BUFFER_SIZE_DEFAULT = 0; //system specific
//TODO change default to -1
public static final boolean DIRECT_BUFFERS_ALLOWED_DEFAULT = false;
public static final int MAX_CONCUR_DOWNLOADS_DEFAULT = 1000;
+ public static final int MAX_CONCUR_DOWNLOADS_DISABLED = -1;
public static final int IDLE_CONNECTION_TIMEOUT_DEFAULT = 30000;
public static final int UNLIMITED_IDLE_CONNECTION_TIMEOUT = -1;
@@ -132,9 +133,15 @@
this.directBuffersAllowed = directBuffersAllowed;
- if (maxConcurDownloads < threadCount)
- throw new IllegalArgumentException("Max concurent downloads
can't be lower than thread count");
- this.maxConcurDownloads = maxConcurDownloads;
+ if (algorithm.isMultiBurst()) {
+ if (maxConcurDownloads < threadCount) {
+ throw new IllegalArgumentException("Max concurent downloads
can't be lower than thread count");
+ }
+ this.maxConcurDownloads = maxConcurDownloads;
+ } else {
+ this.maxConcurDownloads = MAX_CONCUR_DOWNLOADS_DISABLED;
+ }
+
if (idleConnectionTimeout < 1 && idleConnectionTimeout != -1)
throw new IllegalArgumentException("Idle connection timeout must
be grater than 0 or -1");
@@ -390,12 +397,16 @@
threadCount = originalConfig.getThreadCount();
bufferSize = originalConfig.getBufferSize();
directBuffersAllowed = originalConfig.areDirectBuffersAllowed();
- maxConcurDownloads = originalConfig.getMaxConcurDownloads();
idleConnectionTimeout =
originalConfig.getIdleConnectionTimeout();
autoSendfileUriPrefix =
originalConfig.getAutoSendfileUriPrefix();
autoSendfileFileDir = originalConfig.getAutoSendfileFileDir();
plugins.addAll(originalConfig.getPlugins());
allowedPaths.putAll(originalConfig.getAllowedPaths());
+
+ if (algorithm.isMultiBurst())
+ maxConcurDownloads = originalConfig.getMaxConcurDownloads();
+ else
+ maxConcurDownloads = MAX_CONCUR_DOWNLOADS_DEFAULT;
}
diff -r fbc868e1b037 -r 52827fddb773
sendfile-core/src/main/java/com/igorminar/grizzlysendfile/SendfileSelectorThread.java
---
a/sendfile-core/src/main/java/com/igorminar/grizzlysendfile/SendfileSelectorThread.java
Wed Jan 13 00:32:58 2010 -0800
+++
b/sendfile-core/src/main/java/com/igorminar/grizzlysendfile/SendfileSelectorThread.java
Wed Jan 13 14:33:40 2010 -0800
@@ -347,7 +347,8 @@
it = pendingRegistrationQueue.iterator();
while (it.hasNext() &&
- monitoring.getSendfileStats().getDownloadsInProgress() <
maxConcurDownloads) {
+ (maxConcurDownloads ==
SendfileConfig.MAX_CONCUR_DOWNLOADS_DISABLED ||
+ monitoring.getSendfileStats().getDownloadsInProgress() <
maxConcurDownloads)) {
SendfileTask task = it.next();
it.remove();
diff -r fbc868e1b037 -r 52827fddb773
sendfile-core/src/main/java/com/igorminar/grizzlysendfile/algorithm/SendfileAlgorithm.java
---
a/sendfile-core/src/main/java/com/igorminar/grizzlysendfile/algorithm/SendfileAlgorithm.java
Wed Jan 13 00:32:58 2010 -0800
+++
b/sendfile-core/src/main/java/com/igorminar/grizzlysendfile/algorithm/SendfileAlgorithm.java
Wed Jan 13 14:33:40 2010 -0800
@@ -39,6 +39,7 @@
protected SendfileSelectorThread selectorThread;
protected boolean blocking = false;
+ protected boolean multiBurst = true;
@@ -65,6 +66,11 @@
public boolean isBlocking() {
return blocking;
}
+
+
+ public boolean isMultiBurst() {
+ return multiBurst;
+ }
/**
diff -r fbc868e1b037 -r 52827fddb773
sendfile-core/src/main/java/com/igorminar/grizzlysendfile/algorithm/SimpleBlockingAlgorithm.java
---
a/sendfile-core/src/main/java/com/igorminar/grizzlysendfile/algorithm/SimpleBlockingAlgorithm.java
Wed Jan 13 00:32:58 2010 -0800
+++
b/sendfile-core/src/main/java/com/igorminar/grizzlysendfile/algorithm/SimpleBlockingAlgorithm.java
Wed Jan 13 14:33:40 2010 -0800
@@ -40,6 +40,7 @@
public SimpleBlockingAlgorithm() {
blocking = true;
+ multiBurst = false;
}
diff -r fbc868e1b037 -r 52827fddb773
sendfile-core/src/test/java/com/igorminar/grizzlysendfile/SendfileConfigTest.java
---
a/sendfile-core/src/test/java/com/igorminar/grizzlysendfile/SendfileConfigTest.java
Wed Jan 13 00:32:58 2010 -0800
+++
b/sendfile-core/src/test/java/com/igorminar/grizzlysendfile/SendfileConfigTest.java
Wed Jan 13 14:33:40 2010 -0800
@@ -21,6 +21,7 @@
package com.igorminar.grizzlysendfile;
import com.igorminar.grizzlysendfile.algorithm.EqualBlockingAlgorithm;
+import com.igorminar.grizzlysendfile.algorithm.EqualNonBlockingAlgorithm;
import com.igorminar.grizzlysendfile.algorithm.SimpleBlockingAlgorithm;
import com.igorminar.grizzlysendfile.plugin.DownloadResultSender;
import java.net.URI;
@@ -93,11 +94,12 @@
@Test
public void testCustomConfig() {
SendfileConfig config = new SendfileConfig.Builder("/foo/*")
- .algorithm(new
SimpleBlockingAlgorithm())
+ .algorithm(new
EqualNonBlockingAlgorithm())
.bufferSize(1000)
.directBuffersAllowed(true)
.idleConnectionTimeout(2000)
.threadCount(30)
+ .maxConcurDownloads(111)
.plugin(new
DownloadResultSender(URI.create("http://localhost:8081/results")))
.addAllowedPath("/bar/*")
.autoSendfileFileDir("/bar/")
@@ -106,10 +108,12 @@
assertThat("config is not null",
config, notNullValue());
- assertThat("algorithm is SimpleBlockingAlgorithm",
- config.getAlgorithm(), is(SimpleBlockingAlgorithm.class));
+ assertThat("algorithm is EqualNonBlockingAlgorithm",
+ config.getAlgorithm(), is(EqualNonBlockingAlgorithm.class));
assertThat("threadCount is 30",
config.getThreadCount(), is(30));
+ assertThat("maxConcurDownloads is 111",
+ config.getMaxConcurDownloads(), is(111));
assertThat("bufferSize is 1000",
config.getBufferSize(), is(1000));
assertThat("directBuffersAllowed is true",
@@ -137,11 +141,12 @@
@Test
public void testCustomConfigViaProperties() {
- System.setProperty(SendfileConfig.ALGORITHM_KEY,
SimpleBlockingAlgorithm.class.getName());
+ System.setProperty(SendfileConfig.ALGORITHM_KEY,
EqualNonBlockingAlgorithm.class.getName());
System.setProperty(SendfileConfig.BUFFER_SIZE_KEY, "1000");
System.setProperty(SendfileConfig.DIRECT_BUFFERS_ALLOWED_KEY,
"true");
System.setProperty(SendfileConfig.IDLE_CONNECTION_TIMEOUT_KEY,
"2000");
System.setProperty(SendfileConfig.THREAD_COUNT_KEY, "30");
+ System.setProperty(SendfileConfig.MAX_CONCUR_DOWNLOADS_KEY, "111");
System.setProperty(SendfileConfig.PLUGINS_KEY,
DownloadResultSender.class.getName());
System.setProperty(DownloadResultSender.LOCATION_KEY,
"http://localhost:8081/results");
System.setProperty(SendfileConfig.ALLOWED_PATHS_KEY,
"/foo/*,/bar/*");
@@ -152,10 +157,12 @@
assertThat("config is not null",
config, notNullValue());
- assertThat("algorithm is SimpleBlockingAlgorithm",
- config.getAlgorithm(), is(SimpleBlockingAlgorithm.class));
+ assertThat("algorithm is EqualNonBlockingAlgorithm",
+ config.getAlgorithm(), is(EqualNonBlockingAlgorithm.class));
assertThat("threadCount is 30",
config.getThreadCount(), is(30));
+ assertThat("maxConcurDownloads is 111",
+ config.getMaxConcurDownloads(), is(111));
assertThat("bufferSize is 1000",
config.getBufferSize(), is(1000));
assertThat("directBuffersAllowed is true",
@@ -182,6 +189,18 @@
@Test
+ public void testBlockingAlgorithDisablesMaxConcurDownloads() {
+ SendfileConfig config = new SendfileConfig.Builder("/foo/*")
+ .algorithm(new
SimpleBlockingAlgorithm())
+ .maxConcurDownloads(111)
+ .build();
+
+ assertThat("maxConcurDownloads is -1 (because of single burst
algorithm)",
+ config.getMaxConcurDownloads(), is(-1));
+ }
+
+
+ @Test
public void testAllowedPathRegex() {
SendfileConfig config = new SendfileConfig.Builder("/foo/*").build();
Pattern regex = config.getAllowedPaths().values().iterator().next();
diff -r 52827fddb773 -r b6c7acde1d63 grizzly-sendfile-server/pom.xml
--- a/grizzly-sendfile-server/pom.xml Wed Jan 13 14:33:40 2010 -0800
+++ b/grizzly-sendfile-server/pom.xml Wed Jan 13 15:01:02 2010 -0800
@@ -39,9 +39,9 @@
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
- <descriptorRefs>
- <descriptorRef>jar-with-dependencies</descriptorRef>
- </descriptorRefs>
+ <descriptors>
+ <descriptor>src/main/assembly/jar-assembly.xml</descriptor>
+ </descriptors>
<archive>
<manifest>
<mainClass>com.igorminar.grizzlysendfile.server.GrizzlySendfileServer</mainClass>
@@ -50,10 +50,10 @@
</configuration>
<executions>
<execution>
- <id>make-assembly</id> <!-- this is used for inheritance merges
-->
- <phase>package</phase> <!-- append to the packaging phase. -->
+ <id>jar-with-dependencies</id>
+ <phase>prepare-package</phase>
<goals>
- <goal>single</goal> <!-- goals == mojos -->
+ <goal>single</goal>
</goals>
</execution>
</executions>
diff -r 52827fddb773 -r b6c7acde1d63
grizzly-sendfile-server/src/main/assembly/jar-assembly.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/grizzly-sendfile-server/src/main/assembly/jar-assembly.xml Wed
Jan 13 15:01:02 2010 -0800
@@ -0,0 +1,18 @@
+<assembly>
+ <id>full</id>
+ <formats>
+ <format>jar</format>
+ </formats>
+ <includeBaseDirectory>false</includeBaseDirectory>
+ <dependencySets>
+ <dependencySet>
+ <unpack>true</unpack>
+ <scope>runtime</scope>
+ </dependencySet>
+ </dependencySets>
+ <fileSets>
+ <fileSet>
+ <directory>${project.build.outputDirectory}</directory>
+ </fileSet>
+ </fileSets>
+</assembly>
diff -r b6c7acde1d63 -r a68e8b200193 grizzly-sendfile-server/pom.xml
--- a/grizzly-sendfile-server/pom.xml Wed Jan 13 15:01:02 2010 -0800
+++ b/grizzly-sendfile-server/pom.xml Wed Jan 13 20:55:40 2010 -0800
@@ -38,6 +38,7 @@
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
+ <version>2.2-beta-5</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly/jar-assembly.xml</descriptor>
diff -r b6c7acde1d63 -r a68e8b200193
grizzly-sendfile-server/src/main/assembly/jar-assembly.xml
--- a/grizzly-sendfile-server/src/main/assembly/jar-assembly.xml Wed
Jan 13 15:01:02 2010 -0800
+++ b/grizzly-sendfile-server/src/main/assembly/jar-assembly.xml Wed
Jan 13 20:55:40 2010 -0800
@@ -1,3 +1,4 @@
+<?xml version="1.0"?>
<assembly>
<id>full</id>
<formats>
@@ -6,13 +7,16 @@
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
+ <outputDirectory></outputDirectory>
+ <outputFileNameMapping></outputFileNameMapping>
<unpack>true</unpack>
<scope>runtime</scope>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
- <directory>${project.build.outputDirectory}</directory>
+ <directory>target/classes</directory>
+ <outputDirectory></outputDirectory>
</fileSet>
</fileSets>
-</assembly>
+</assembly>
\ No newline at end of file
|
[grizzly-sendfile~main:280] grizzly-sendfile-server - fixing issues with duplicates and bogus files i |
igor_minar | 01/14/2010 |





