
com.google.code.or.io.util..ActiveBufferedInputStream.swp Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of open-replicator Show documentation
Show all versions of open-replicator Show documentation
Open Replicator is a high performance MySQL binlog parser written in Java.
b0VIM 7.4 O?W˖=O ben alpha21 ~ben/src/open-replicator/src/main/java/com/google/code/or/io/util/ActiveBufferedInputStream.java utf-8 3210 #"! U tp ? ) ? i ? ad K ? ? ? m & ? ? Z W $ ! ?
?
I
? ? ? ? ? ~ b 7 ? ? ? ? m l 6 5 1 . ?
?
G
F
B
? ? ? ? o C ? ? > = < 7 3 . ? ? ? ? ? ` ] \ ? ? ? ? ? t ] Z Y T P K 6 . ? ? ? ? } | u a N ! ? ? ? ? ? ? ? ? ] N 0 % ? ? ? ? ? | P J E A > = 8 4 / $ ? ? ? ? ? ? ? h ] Y X S K J try { // } return; if(!this.closed.compareAndSet(false, true)) { // public void close() throws IOException { @Override } return this.ringBuffer.size(); public int available() throws IOException { @Override */ * /** } } } } LOGGER.error("failed to close is", e); } catch (IOException e) { close(); try { if (!this.closed.get()) { } finally { LOGGER.error("failed to transfer data", e); } catch(Exception e) { } this.lock.unlock(); } finally { this.bufferNotEmpty.signalAll(); this.bufferNotFull.signalAll(); try { this.lock.lock(); this.exception = e; } catch(IOException e) { } } offset += w; r -= w; final int w = write(buffer, offset, r); while(r > 0) { int offset = 0; // if(r < 0) throw new EOFException(); int r = this.is.read(buffer, 0, buffer.length); // while(!this.closed.get()) { final byte[] buffer = new byte[512 * 1024]; try { public void run() { */ * /** } this.worker.start(); this.worker = this.threadFactory.newThread(this); // this.ringBuffer = new ByteRingBuffer(size); this.threadFactory = tf; this.is = is; // public ActiveBufferedInputStream(InputStream is, int size, ThreadFactory tf) { } this(is, size, new XThreadFactory("active-bis", true)); public ActiveBufferedInputStream(InputStream is, int size) { } this(is, DEFAULT_CAPACITY); public ActiveBufferedInputStream(InputStream is) { */ * /** private final Condition bufferNotEmpty = this.lock.newCondition(); private final Condition bufferNotFull = this.lock.newCondition(); private final AtomicBoolean closed = new AtomicBoolean(false); private final ReentrantLock lock = new ReentrantLock(false); private final ThreadFactory threadFactory; private final ByteRingBuffer ringBuffer; private volatile IOException exception; private final InputStream is; private final Thread worker; // private static final int DEFAULT_CAPACITY = 2 * 1024 * 1024; // private static final Logger LOGGER = LoggerFactory.getLogger(ActiveBufferedInputStream.class); // public final class ActiveBufferedInputStream extends InputStream implements Runnable { */ * @author andyqzb * @author Jingqi Xu * /** import com.google.code.or.common.util.XThreadFactory; import org.slf4j.LoggerFactory; import org.slf4j.Logger; import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.Condition; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.ThreadFactory; import java.io.InputStream; import java.io.IOException; import java.io.EOFException; package com.google.code.or.io.util; */ * limitations under the License. * See the License for the specific language governing permissions and * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * distributed under the License is distributed on an "AS IS" BASIS, * Unless required by applicable law or agreed to in writing, software * * http://www.apache.org/licenses/LICENSE-2.0 * * the License. You may obtain a copy of the License at * (the "License"); you may not use this file except in compliance with * The ASF licenses this file to You under the Apache License, Version 2.0 * this work for additional information regarding copyright ownership. * contributor license agreements. See the NOTICE file distributed with * Licensed to the Apache Software Foundation (ASF) under one or more /** ad ? ? ? ? ? ? ? } } } return w; ad ?
? ) ? ? ? ? ? w h J ? ; 8 7 , ? ? ? ? n 5 ?
?
?
?
?
k
X
D
'
? ? ? ? q 6 ? ? f ? ? ? [ H 4
?
?
?
?
l
4
? ? ? ? ? w d P 3 ) & % ? ? ? ? ? ? y t n F ! ? ? ? ? ? ? ? ? ? X T S M H B , & ? ? ? ? ? ? ? ? \ V + ? ? { > ? ? ? ? ? ? ? ? ? O I ? ? ? Y ? ? ? ? ? s v this.size += w; this.head = (this.head + w) % this.buffer.length; // } if(w1 < w) System.arraycopy(b, off + w1, this.buffer, 0, w - w1); System.arraycopy(b, off, this.buffer, this.head, w1); final int w1 = Math.min(this.buffer.length - this.head, w); } else { System.arraycopy(b, off, this.buffer, this.head, w); if(this.head < this.tail) { final int w = Math.min(this.buffer.length - this.size, len); // public int write(byte b[], int off, int len) { } return r; this.size -= r; this.tail = (this.tail + r) % this.buffer.length; // } if(r1 < r) System.arraycopy(this.buffer, 0, b, off + r1, r - r1); System.arraycopy(this.buffer, this.tail, b, off, r1); final int r1 = Math.min(this.buffer.length - this.tail, r); } else { System.arraycopy(this.buffer, this.tail, b, off, r); if(this.head > this.tail) { final int r = Math.min(this.size, len); // public int read(byte b[], int off, int len) { } return r; this.size -= 1; this.tail = (this.tail + 1) % this.buffer.length; // final int r = this.buffer[this.tail] & 0xFF; // public int read() { */ * /** } return this.size == this.buffer.length; public boolean isFull() { } return this.size == 0; public boolean isEmpty() { } return this.size; public int size() { */ * /** } this.buffer = new byte[capacity]; public ByteRingBuffer(int capacity) { */ * /** private final byte[] buffer; private int tail; // Read private int head; // Write private int size; // private final class ByteRingBuffer { */ * /** } } this.lock.unlock(); } finally { return w; this.bufferNotEmpty.signal(); final int w = this.ringBuffer.write(b, off, len); // } if(this.closed.get()) throw new EOFException(); this.bufferNotFull.awaitUninterruptibly(); while (this.ringBuffer.isFull()) { // try { this.lock.lock(); public int write(byte b[], int off, int len) throws IOException { } } this.lock.unlock(); } finally { return r; th if(this.closed.get() && this.ringBuffer.isEmpty( if(this.closed.get() && this.ringBuffer.isEmpty()) throw new EOFException(); this.bufferNotEmpty.awaitUninterruptibly(); if(this.exception != null) throw this.exception; while (this.ringBuffer.isEmpty()) { // try { this.lock.lock(); public int read(byte b[], int off, int len) throws IOException { @Override } } this.lock.unlock(); } finally { return r; this.bufferNotFull.signal(); final int r = this.ringBuffer.read(); // } if(this.closed.get() && this.ringBuffer.isEmpty()) throw new EOFException(); this.bufferNotEmpty.awaitUninterruptibly(); if(this.exception != null) throw this.exception; while (this.ringBuffer.isEmpty()) { // try { this.lock.lock(); public int read() throws IOException { @Override } } } this.lock.unlock(); } finally { this.bufferNotEmpty.signalAll(); this.bufferNotFull.signalAll(); try { this.lock.lock(); } finally { this.is.close(); ad ? ? i ? ? ? ? ? o [ > 4 1 0 ? ? ? ? ? [ ?
?
?
w
Z
P
M
L
G
C
>
? ? ? ? ? ? ? ? m H D C = 8 2 ? ? ? ? ? { z t o i S M ?
?
?
?
?
?
}
R
0
? ? ? e
? ? ? ? ? v p 0 ? ? ? C ? ? ? ? ? ? this.size += w; this.head = (this.head + w) % this.buffer.length; // } if(w1 < w) System.arraycopy(b, off + w1, this.buffer, 0, w - w1); System.arraycopy(b, off, this.buffer, this.head, w1); final int w1 = Math.min(this.buffer.length - this.head, w); } else { System.arraycopy(b, off, this.buffer, this.head, w); if(this.head < this.tail) { final int w = Math.min(this.buffer.length - this.size, len); // public int write(byte b[], int off, int len) { } return r; this.size -= r; this.tail = (this.tail + r) % this.buffer.length; // } if(r1 < r) System.arraycopy(this.buffer, 0, b, off + r1, r - r1); System.arraycopy(this.buffer, this.tail, b, off, r1); final int r1 = Math.min(this.buffer.length - this.tail, r); } else { System.arraycopy(this.buffer, this.tail, b, off, r); if(this.head > this.tail) { final int r = Math.min(this.size, len); // public int read(byte b[], int off, int len) { } return r; this.size -= 1; this.tail = (this.tail + 1) % this.buffer.length; // final int r = this.buffer[this.tail] & 0xFF; // public int read() { */ * /** } return this.size == this.buffer.length; public boolean isFull() { } return this.size == 0; public boolean isEmpty() { } return this.size; public int size() { */ * /** } this.buffer = new byte[capacity]; public ByteRingBuffer(int capacity) { */ * /** private final byte[] buffer; private int tail; // Read private int head; // Write private int size; // private final class ByteRingBuffer { */ * /** } } this.lock.unlock(); } finally { return w; this.bufferNotEmpty.signal(); final int w = this.ringBuffer.write(b, off, len); // } if(this.closed.get()) throw new EOFException(); this.bufferNotFull.awaitUninterruptibly(); while (this.ringBuffer.isFull()) { // try { this.lock.lock(); public int write(byte b[], int off, int len) throws IOException { } } this.lock.unlock(); } finally { return r; this.bufferNotFull.signal(); final int r = this.ringBuffer.read(b, off, len); // }
© 2015 - 2025 Weber Informatics LLC | Privacy Policy