public V2StreamSender ( I2PSocket s, int id ) throws IOException { super ( s, id ); _data = new ArrayList<ByteArray> ( 1 ); _cache = ByteCache.getInstance ( 10, 32 * 1024 ); _out = s.getOutputStream(); _stillRunning = true; }
/** * Does not start itself. Caller must start() */ public StreamForwarder(InputStream in, OutputStream out, boolean toI2P) { this.in = in; this.out = out; _toI2P = toI2P; direction = (toI2P ? "toI2P" : "fromI2P"); _cache = ByteCache.getInstance(32, NETWORK_BUFFER_SIZE); setName("StreamForwarder " + _runnerId + '.' + direction); }
/** * Does not start itself. Caller must start() */ private StreamForwarder(InputStream in, OutputStream out, boolean toI2P) { this.in = in; this.out = out; _toI2P = toI2P; direction = (toI2P ? "toOutproxy" : "fromOutproxy"); _cache = ByteCache.getInstance(32, NETWORK_BUFFER_SIZE); setName("OutproxyForwarder " + _runnerId + '.' + __forwarderId.incrementAndGet()); }
public V1StreamSender ( I2PSocket s, int id ) throws IOException { super ( s, id ); _data = new ArrayList<ByteArray>(1); _cache = ByteCache.getInstance(4, 32*1024); _out = s.getOutputStream(); _stillRunning = true; }
public CachingByteArrayOutputStream(int cacheQuantity, int arraySize) { super(0); _cache = ByteCache.getInstance(cacheQuantity, arraySize); _buf = _cache.acquire(); super.buf = _buf.getData(); }
/** * Copy in to out. Caller MUST close the streams. * * @param in non-null * @param out non-null * @since 0.9.29 */ public static void copy(InputStream in, OutputStream out) throws IOException { final ByteCache cache = ByteCache.getInstance(8, 8*1024); final ByteArray ba = cache.acquire(); try { final byte buf[] = ba.getData(); int read; while ((read = in.read(buf)) != -1) { out.write(buf, 0, read); } } finally { cache.release(ba); } }
public MessageOutputStream(I2PAppContext ctx, SimpleTimer2 timer, DataReceiver receiver, int bufSize, int passiveFlushDelay) { super(); _dataCache = ByteCache.getInstance(128, bufSize); _originalBufferSize = bufSize; _currentBufferSize = bufSize; _context = ctx; _log = ctx.logManager().getLog(MessageOutputStream.class); _buf = _dataCache.acquire().getData(); // new byte[bufSize]; _dataReceiver = receiver; _dataLock = new Object(); _writeTimeout = -1; _passiveFlushDelay = passiveFlushDelay; _nextBufferSize = 0; //_sendPeriodBeginTime = ctx.clock().now(); //_context.statManager().createRateStat("stream.sendBps", "How fast we pump data through the stream", "Stream", new long[] { 60*1000, 5*60*1000, 60*60*1000 }); _flusher = new Flusher(timer); //if (_log.shouldLog(Log.DEBUG)) // _log.debug("MessageOutputStream created"); }
ByteCache cache = ByteCache.getInstance(8, MAX_UNCOMPRESSED); ByteArray outBuf = cache.acquire(); try {
public MessageOutputStream(I2PAppContext ctx, SimpleTimer2 timer, DataReceiver receiver, int bufSize, int passiveFlushDelay) { super(); _dataCache = ByteCache.getInstance(128, bufSize); _originalBufferSize = bufSize; _currentBufferSize = bufSize; _context = ctx; _log = ctx.logManager().getLog(MessageOutputStream.class); _buf = _dataCache.acquire().getData(); // new byte[bufSize]; _dataReceiver = receiver; _dataLock = new Object(); _writeTimeout = -1; _passiveFlushDelay = passiveFlushDelay; _nextBufferSize = 0; //_sendPeriodBeginTime = ctx.clock().now(); //_context.statManager().createRateStat("stream.sendBps", "How fast we pump data through the stream", "Stream", new long[] { 60*1000, 5*60*1000, 60*60*1000 }); _flusher = new Flusher(timer); //if (_log.shouldLog(Log.DEBUG)) // _log.debug("MessageOutputStream created"); }