Author: toad
Date: 2008-06-13 17:11:43 +0000 (Fri, 13 Jun 2008)
New Revision: 20315
Modified:
branches/db4o/freenet/src/freenet/client/FetchContext.java
branches/db4o/freenet/src/freenet/client/HighLevelSimpleClientImpl.java
branches/db4o/freenet/src/freenet/client/async/ClientContext.java
branches/db4o/freenet/src/freenet/client/async/SimpleManifestPutter.java
branches/db4o/freenet/src/freenet/client/async/SplitFileFetcherSubSegment.java
Log:
Move random from FetchContext to ClientContext
Modified: branches/db4o/freenet/src/freenet/client/FetchContext.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/FetchContext.java 2008-06-13
17:08:14 UTC (rev 20314)
+++ branches/db4o/freenet/src/freenet/client/FetchContext.java 2008-06-13
17:11:43 UTC (rev 20315)
@@ -10,7 +10,6 @@
import freenet.client.async.USKManager;
import freenet.client.events.ClientEventProducer;
import freenet.client.events.SimpleEventProducer;
-import freenet.crypt.RandomSource;
import freenet.node.Ticker;
import freenet.support.Executor;
import freenet.support.api.BucketFactory;
@@ -35,7 +34,6 @@
public int maxSplitfileThreads;
public int maxSplitfileBlockRetries;
public int maxNonSplitfileRetries;
- public final RandomSource random;
public boolean allowSplitfiles;
public boolean followRedirects;
public boolean localRequestOnly;
@@ -63,7 +61,7 @@
int maxSplitfileBlockRetries, int
maxNonSplitfileRetries,
boolean allowSplitfiles, boolean followRedirects,
boolean localRequestOnly,
int maxDataBlocksPerSegment, int
maxCheckBlocksPerSegment,
- RandomSource random, ArchiveManager archiveManager,
BucketFactory bucketFactory,
+ ArchiveManager archiveManager, BucketFactory
bucketFactory,
ClientEventProducer producer, boolean
cacheLocalRequests, USKManager uskManager,
HealingQueue hq, boolean ignoreTooManyPathComponents,
Ticker ticker, Executor executor,
Executor[] slowSerialExecutor) {
@@ -80,7 +78,6 @@
this.maxArchiveRestarts = maxArchiveRestarts;
this.maxArchiveLevels = maxArchiveLevels;
this.dontEnterImplicitArchives = dontEnterImplicitArchives;
- this.random = random;
this.maxSplitfileThreads = maxSplitfileThreads;
this.maxSplitfileBlockRetries = maxSplitfileBlockRetries;
this.maxNonSplitfileRetries = maxNonSplitfileRetries;
@@ -118,7 +115,6 @@
this.maxArchiveRestarts = ctx.maxArchiveRestarts;
this.maxArchiveLevels = ctx.maxArchiveLevels;
this.dontEnterImplicitArchives =
ctx.dontEnterImplicitArchives;
- this.random = ctx.random;
this.maxSplitfileThreads = ctx.maxSplitfileThreads;
this.maxSplitfileBlockRetries =
ctx.maxSplitfileBlockRetries;
this.maxNonSplitfileRetries =
ctx.maxNonSplitfileRetries;
@@ -139,7 +135,6 @@
this.maxArchiveRestarts = 0;
this.maxArchiveLevels = ctx.maxArchiveLevels;
this.dontEnterImplicitArchives = true;
- this.random = ctx.random;
this.maxSplitfileThreads = 0;
this.maxSplitfileBlockRetries =
ctx.maxSplitfileBlockRetries;
this.maxNonSplitfileRetries =
ctx.maxSplitfileBlockRetries;
@@ -160,7 +155,6 @@
this.maxArchiveRestarts = ctx.maxArchiveRestarts;
this.maxArchiveLevels = ctx.maxArchiveLevels;
this.dontEnterImplicitArchives =
ctx.dontEnterImplicitArchives;
- this.random = ctx.random;
this.maxSplitfileThreads = ctx.maxSplitfileThreads;
this.maxSplitfileBlockRetries =
ctx.maxSplitfileBlockRetries;
this.maxNonSplitfileRetries =
ctx.maxNonSplitfileRetries;
@@ -181,7 +175,6 @@
this.maxArchiveRestarts = ctx.maxArchiveRestarts;
this.maxArchiveLevels = ctx.maxArchiveLevels;
this.dontEnterImplicitArchives =
ctx.dontEnterImplicitArchives;
- this.random = ctx.random;
this.maxSplitfileThreads = ctx.maxSplitfileThreads;
this.maxSplitfileBlockRetries =
ctx.maxSplitfileBlockRetries;
this.maxNonSplitfileRetries =
ctx.maxNonSplitfileRetries;
Modified:
branches/db4o/freenet/src/freenet/client/HighLevelSimpleClientImpl.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/HighLevelSimpleClientImpl.java
2008-06-13 17:08:14 UTC (rev 20314)
+++ branches/db4o/freenet/src/freenet/client/HighLevelSimpleClientImpl.java
2008-06-13 17:11:43 UTC (rev 20315)
@@ -195,7 +195,7 @@
SPLITFILE_THREADS, SPLITFILE_BLOCK_RETRIES,
NON_SPLITFILE_RETRIES,
FETCH_SPLITFILES, FOLLOW_REDIRECTS,
LOCAL_REQUESTS_ONLY,
MAX_SPLITFILE_BLOCKS_PER_SEGMENT,
MAX_SPLITFILE_CHECK_BLOCKS_PER_SEGMENT,
- random, archiveManager, bucketFactory,
globalEventProducer,
+ archiveManager, bucketFactory,
globalEventProducer,
cacheLocalRequests, core.uskManager,
healingQueue,
false, core.getTicker(), core.getExecutor(),
slowSerialExecutor);
}
Modified: branches/db4o/freenet/src/freenet/client/async/ClientContext.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/ClientContext.java
2008-06-13 17:08:14 UTC (rev 20314)
+++ branches/db4o/freenet/src/freenet/client/async/ClientContext.java
2008-06-13 17:11:43 UTC (rev 20315)
@@ -8,6 +8,7 @@
import freenet.client.FECQueue;
import freenet.client.FetchException;
import freenet.client.InsertException;
+import freenet.crypt.RandomSource;
import freenet.node.NodeClientCore;
import freenet.support.Executor;
import freenet.support.io.NativeThread;
@@ -28,6 +29,7 @@
public final Executor mainExecutor;
public final long nodeDBHandle;
public final BackgroundBlockEncoder backgroundBlockEncoder;
+ public final RandomSource random;
public ClientContext(NodeClientCore core) {
this.fecQueue = core.fecQueue;
@@ -39,6 +41,7 @@
this.mainExecutor = core.getExecutor();
this.nodeDBHandle = core.node.nodeDBHandle;
this.backgroundBlockEncoder = core.backgroundBlockEncoder;
+ this.random = core.random;
}
public void start(final ClientPutter inserter, final boolean
earlyEncode) throws InsertException {
Modified:
branches/db4o/freenet/src/freenet/client/async/SimpleManifestPutter.java
===================================================================
--- branches/db4o/freenet/src/freenet/client/async/SimpleManifestPutter.java
2008-06-13 17:08:14 UTC (rev 20314)
+++ branches/db4o/freenet/src/freenet/client/async/SimpleManifestPutter.java
2008-06-13 17:11:43 UTC (rev 20315)
@@ -192,7 +192,7 @@
private FreenetURI targetURI;
private boolean finished;
private final InsertContext ctx;
- private final ClientCallback cb;
+ final ClientCallback cb;
private final boolean getCHKOnly;
private boolean insertedAllFiles;
private boolean insertedManifest;
Modified:
branches/db4o/freenet/src/freenet/client/async/SplitFileFetcherSubSegment.java
===================================================================
---
branches/db4o/freenet/src/freenet/client/async/SplitFileFetcherSubSegment.java
2008-06-13 17:08:14 UTC (rev 20314)
+++
branches/db4o/freenet/src/freenet/client/async/SplitFileFetcherSubSegment.java
2008-06-13 17:11:43 UTC (rev 20315)
@@ -68,7 +68,7 @@
public Object chooseKey(KeysFetchingLocally keys, ObjectContainer
container, ClientContext context) {
if(cancelled) return null;
- return removeRandomBlockNum(keys);
+ return removeRandomBlockNum(keys, context);
}
public ClientKey getKey(Object token, ObjectContainer container) {
@@ -107,7 +107,7 @@
return blockNums.toArray();
}
- private Object removeRandomBlockNum(KeysFetchingLocally keys) {
+ private Object removeRandomBlockNum(KeysFetchingLocally keys,
ClientContext context) {
logMINOR = Logger.shouldLog(Logger.MINOR, this);
synchronized(segment) {
if(blockNums.isEmpty()) {
@@ -118,7 +118,7 @@
for(int i=0;i<10;i++) {
Object ret;
int x;
- x = ctx.random.nextInt(blockNums.size());
+ x = context.random.nextInt(blockNums.size());
ret = (Integer) blockNums.remove(x);
Key key =
segment.getBlockNodeKey(((Integer)ret).intValue());
if(key == null) {