Package freenet.support

Examples of freenet.support.MemoryLimitedJobRunner


                        if(val < FECCodec.MIN_MEMORY_ALLOCATION) throw new InvalidConfigValueException(l10n("memoryLimitedJobMemoryLimitMustBeAtLeast", "min", SizeUtil.formatSize(FECCodec.MIN_MEMORY_ALLOCATION)));
                        memoryLimitedJobRunner.setCapacity(val);
                    }
       
    }, true);
    memoryLimitedJobRunner = new MemoryLimitedJobRunner(nodeConfig.getLong("memoryLimitedJobMemoryLimit"), nodeConfig.getInt("memoryLimitedJobThreadLimit"), node.executor);
    shutdownHook.addEarlyJob(new NativeThread("Shutdown FEC", NativeThread.HIGH_PRIORITY, true) {
       
        public void realRun() {
            System.out.println("Stopping FEC decode threads...");
            memoryLimitedJobRunner.shutdown();
View Full Code Here


        bigBucketFactory = new TempBucketFactory(executor, fg, 0, 0, r, false, 0, null);
        baseContext = HighLevelSimpleClientImpl.makeDefaultInsertContext(bigBucketFactory, new SimpleEventProducer());
        cryptoKey = new byte[32];
        r.nextBytes(cryptoKey);
        checker = new CRCChecksumChecker();
        memoryLimitedJobRunner = new MemoryLimitedJobRunner(9*1024*1024L, 20, executor);
        jobRunner = new DummyJobRunner(executor, null);
        URI = FreenetURI.generateRandomCHK(r);
    }
View Full Code Here

        LockableRandomAccessBuffer data = generateData(r, size, bigRAFFactory);
        HashResult[] hashes = getHashes(data);
        MyCallback cb = new MyCallback();
        MyKeysFetchingLocally keys = new MyKeysFetchingLocally();
        // Only enough for one segment at a time.
        MemoryLimitedJobRunner memoryLimitedJobRunner = new MemoryLimitedJobRunner(9*1024*1024L, 1, executor);
        SplitFileInserterStorage storage = new SplitFileInserterStorage(data, size, cb, null,
                new ClientMetadata(), false, null, smallRAFFactory, true, baseContext.clone(),
                cryptoAlgorithm, cryptoKey, null, hashes, smallBucketFactory, checker,
                r, memoryLimitedJobRunner, jobRunner, ticker, keys, false, 0, 0, 0, 0);
        executor.waitForIdle();
        // Has not encoded anything.
        for(SplitFileInserterSegmentStorage segment : storage.segments)
            assert(!segment.isFinishedEncoding());
        SplitFileInserterStorage resumed = null;
        if(storage.crossSegments != null) {
            for(int i=0;i<storage.crossSegments.length;i++) {
                memoryLimitedJobRunner = new MemoryLimitedJobRunner(9*1024*1024L, 1, executor);
                resumed = new SplitFileInserterStorage(storage.getRAF(), data, cb, r,
                        memoryLimitedJobRunner, jobRunner, ticker, keys, fg, persistentFileTracker, null);
                assertEquals(i, countEncodedCrossSegments(resumed));
                resumed.start();
                // The memoryLimitedJobRunner will only encode one segment at a time.
                // Wait for it to encode one segment.
                memoryLimitedJobRunner.shutdown();
                memoryLimitedJobRunner.waitForShutdown();
                executor.waitForIdle();
                assertEquals(i+1, countEncodedCrossSegments(resumed));
            }
        }
       
        for(int i=0;i<storage.segments.length;i++) {
            memoryLimitedJobRunner = new MemoryLimitedJobRunner(9*1024*1024L, 1, executor);
            resumed = new SplitFileInserterStorage(storage.getRAF(), data, cb, r,
                    memoryLimitedJobRunner, jobRunner, ticker, keys, fg, persistentFileTracker, null);
            assertEquals(i, countEncodedSegments(resumed));
            if(storage.crossSegments != null) {
                assertEquals(resumed.crossSegments.length, countEncodedCrossSegments(resumed));
                assertTrue(resumed.getStatus() == Status.ENCODED_CROSS_SEGMENTS);
            }
            resumed.start();
            // The memoryLimitedJobRunner will only encode one segment at a time.
            // Wait for it to encode one segment.
            memoryLimitedJobRunner.shutdown();
            memoryLimitedJobRunner.waitForShutdown();
            executor.waitForIdle();
            assertEquals(i+1, countEncodedSegments(resumed));
        }
       
        cb.waitForFinishedEncode();
View Full Code Here

        bigBucketFactory = new TempBucketFactory(executor, fg, 0, 0, r, false, 0, null);
        baseContext = HighLevelSimpleClientImpl.makeDefaultInsertContext(bigBucketFactory, new SimpleEventProducer());
        cryptoKey = new byte[32];
        r.nextBytes(cryptoKey);
        checker = new CRCChecksumChecker();
        memoryLimitedJobRunner = new MemoryLimitedJobRunner(9*1024*1024L, 20, executor);
        jobRunner = new DummyJobRunner(executor, null);
        URI = FreenetURI.generateRandomCHK(r);
    }
View Full Code Here

TOP

Related Classes of freenet.support.MemoryLimitedJobRunner

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.