finished core
This commit is contained in:
@ -51,6 +51,7 @@ public class BufferedStatLog implements StatLog {
|
||||
writer.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addData(String scope, String stat, long value, long duration) {
|
||||
if (DISABLE_LOGGING) return;
|
||||
if (!shouldLog(stat)) return;
|
||||
@ -122,6 +123,7 @@ public class BufferedStatLog implements StatLog {
|
||||
|
||||
private class StatLogWriter implements Runnable {
|
||||
private SimpleDateFormat _fmt = new SimpleDateFormat("yyyyMMdd HH:mm:ss.SSS");
|
||||
@Override
|
||||
public void run() {
|
||||
int writeStart = -1;
|
||||
int writeEnd = -1;
|
||||
|
@ -436,6 +436,7 @@ public class Rate {
|
||||
coalesce();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if ((obj == null) || (obj.getClass() != Rate.class)) return false;
|
||||
if (obj == this) return true;
|
||||
@ -451,6 +452,7 @@ public class Rate {
|
||||
&& _lifetimeTotalEventTime == r.getLifetimeTotalEventTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer(2048);
|
||||
buf.append("\n\t total value: ").append(getLastTotalValue());
|
||||
|
@ -84,12 +84,14 @@ public class RateStat {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return _statName.hashCode();
|
||||
}
|
||||
|
||||
private final static String NL = System.getProperty("line.separator");
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer(4096);
|
||||
buf.append(getGroupName()).append('.').append(getName()).append(": ").append(getDescription()).append('\n');
|
||||
@ -104,6 +106,7 @@ public class RateStat {
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if ((obj == null) || (obj.getClass() != RateStat.class)) return false;
|
||||
RateStat rs = (RateStat) obj;
|
||||
|
@ -328,6 +328,7 @@ public class NtpMessage {
|
||||
/**
|
||||
* Returns a string representation of a NtpMessage
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
String precisionStr = new DecimalFormat("0.#E0").format(Math.pow(2, precision));
|
||||
|
||||
|
@ -110,6 +110,7 @@ public class Timestamper implements Runnable {
|
||||
} catch (InterruptedException ie) {}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try { Thread.sleep(1000); } catch (InterruptedException ie) {}
|
||||
_log = _context.logManager().getLog(Timestamper.class);
|
||||
|
@ -113,6 +113,7 @@ public class BufferedRandomSource extends RandomSource {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized final void nextBytes(byte buf[]) {
|
||||
int outOffset = 0;
|
||||
while (outOffset < buf.length) {
|
||||
@ -128,6 +129,7 @@ public class BufferedRandomSource extends RandomSource {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int nextInt(int n) {
|
||||
if (n <= 0) return 0;
|
||||
int val = ((int)nextBits(countBits(n))) % n;
|
||||
@ -136,13 +138,15 @@ public class BufferedRandomSource extends RandomSource {
|
||||
else
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final int nextInt() { return nextInt(Integer.MAX_VALUE); }
|
||||
|
||||
/**
|
||||
* Like the modified nextInt, nextLong(n) returns a random number from 0 through n,
|
||||
* including 0, excluding n.
|
||||
*/
|
||||
@Override
|
||||
public final long nextLong(long n) {
|
||||
if (n <= 0) return 0;
|
||||
long val = nextBits(countBits(n)) % n;
|
||||
@ -152,6 +156,7 @@ public class BufferedRandomSource extends RandomSource {
|
||||
return val;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final long nextLong() { return nextLong(Long.MAX_VALUE); }
|
||||
|
||||
static final int countBits(long val) {
|
||||
@ -172,22 +177,26 @@ public class BufferedRandomSource extends RandomSource {
|
||||
* override as synchronized, for those JVMs that don't always pull via
|
||||
* nextBytes (cough ibm)
|
||||
*/
|
||||
@Override
|
||||
public final boolean nextBoolean() {
|
||||
return nextBits(1) != 0;
|
||||
}
|
||||
|
||||
private static final double DOUBLE_DENOMENATOR = (double)(1L << 53);
|
||||
/** defined per javadoc ( ((nextBits(26)<<27) + nextBits(27)) / (1 << 53)) */
|
||||
@Override
|
||||
public final double nextDouble() {
|
||||
long top = (((long)nextBits(26) << 27) + nextBits(27));
|
||||
return top / DOUBLE_DENOMENATOR;
|
||||
}
|
||||
private static final float FLOAT_DENOMENATOR = (float)(1 << 24);
|
||||
/** defined per javadoc (nextBits(24) / ((float)(1 << 24)) ) */
|
||||
@Override
|
||||
public float nextFloat() {
|
||||
long top = nextBits(24);
|
||||
return top / FLOAT_DENOMENATOR;
|
||||
}
|
||||
@Override
|
||||
public double nextGaussian() {
|
||||
// bah, unbuffered
|
||||
return super.nextGaussian();
|
||||
|
@ -108,6 +108,7 @@ public final class ByteCache {
|
||||
}
|
||||
|
||||
private class Cleanup implements SimpleTimer.TimedEvent {
|
||||
@Override
|
||||
public void timeReached() {
|
||||
if (System.currentTimeMillis() - _lastOverflow > EXPIRE_PERIOD) {
|
||||
// we haven't exceeded the cache size in a few minutes, so lets
|
||||
|
@ -109,7 +109,8 @@ public class Clock implements Timestamper.UpdateListener {
|
||||
}
|
||||
|
||||
public boolean getUpdatedSuccessfully() { return _alreadyChanged; }
|
||||
|
||||
|
||||
@Override
|
||||
public void setNow(long realTime) {
|
||||
long diff = realTime - System.currentTimeMillis();
|
||||
setOffset(diff);
|
||||
|
@ -206,6 +206,7 @@ public class DecayingBloomFilter {
|
||||
}
|
||||
|
||||
private class DecayEvent implements SimpleTimer.TimedEvent {
|
||||
@Override
|
||||
public void timeReached() {
|
||||
if (_keepDecaying) {
|
||||
decay();
|
||||
|
@ -262,6 +262,7 @@ public class EepGet {
|
||||
_startedOn = _lastComplete;
|
||||
_firstTime = true;
|
||||
}
|
||||
@Override
|
||||
public void bytesTransferred(long alreadyTransferred, int currentWrite, long bytesTransferred, long bytesRemaining, String url) {
|
||||
if (_firstTime) {
|
||||
if (alreadyTransferred > 0) {
|
||||
@ -318,6 +319,7 @@ public class EepGet {
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile, boolean notModified) {
|
||||
long transferred;
|
||||
if (_firstTime)
|
||||
@ -356,6 +358,7 @@ public class EepGet {
|
||||
System.out.println(buf.toString());
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void attemptFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt, int numRetries, Exception cause) {
|
||||
System.out.println();
|
||||
System.out.println("** " + new Date());
|
||||
@ -366,6 +369,7 @@ public class EepGet {
|
||||
_previousWritten += _written;
|
||||
_written = 0;
|
||||
}
|
||||
@Override
|
||||
public void transferFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt) {
|
||||
System.out.println("== " + new Date());
|
||||
System.out.println("== Transfer of " + url + " failed after " + currentAttempt + " attempts");
|
||||
@ -382,7 +386,9 @@ public class EepGet {
|
||||
buf.append("KBps");
|
||||
System.out.println(buf.toString());
|
||||
}
|
||||
@Override
|
||||
public void attempting(String url) {}
|
||||
@Override
|
||||
public void headerReceived(String url, int currentAttempt, String key, String val) {}
|
||||
}
|
||||
|
||||
@ -418,6 +424,7 @@ public class EepGet {
|
||||
timeout = new SocketTimeout(_fetchHeaderTimeout);
|
||||
final SocketTimeout stimeout = timeout; // ugly
|
||||
timeout.setTimeoutCommand(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("timeout reached on " + _url + ": " + stimeout);
|
||||
|
@ -29,7 +29,12 @@ public class EepGetScheduler implements EepGet.StatusListener {
|
||||
}
|
||||
|
||||
public void fetch() {
|
||||
I2PThread t = new I2PThread(new Runnable() { public void run() { fetchNext(); } }, "EepGetScheduler");
|
||||
I2PThread t = new I2PThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
fetchNext();
|
||||
}
|
||||
}, "EepGetScheduler");
|
||||
t.setDaemon(true);
|
||||
t.start();
|
||||
}
|
||||
@ -62,24 +67,30 @@ public class EepGetScheduler implements EepGet.StatusListener {
|
||||
get.fetch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attemptFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt, int numRetries, Exception cause) {
|
||||
_listener.attemptFailed(url, bytesTransferred, bytesRemaining, currentAttempt, numRetries, cause);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bytesTransferred(long alreadyTransferred, int currentWrite, long bytesTransferred, long bytesRemaining, String url) {
|
||||
_listener.bytesTransferred(alreadyTransferred, currentWrite, bytesTransferred, bytesRemaining, url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transferComplete(long alreadyTransferred, long bytesTransferred, long bytesRemaining, String url, String outputFile, boolean notModified) {
|
||||
_listener.transferComplete(alreadyTransferred, bytesTransferred, bytesRemaining, url, outputFile, notModified);
|
||||
fetchNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transferFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt) {
|
||||
_listener.transferFailed(url, bytesTransferred, bytesRemaining, currentAttempt);
|
||||
fetchNext();
|
||||
}
|
||||
@Override
|
||||
public void attempting(String url) { _listener.attempting(url); }
|
||||
|
||||
@Override
|
||||
public void headerReceived(String url, int attemptNum, String key, String val) {}
|
||||
}
|
||||
|
@ -73,6 +73,7 @@ public class EepPost {
|
||||
_fields = fields;
|
||||
_onCompletion = onCompletion;
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
if (_log.shouldLog(Log.DEBUG)) _log.debug("Running the post task");
|
||||
Socket s = null;
|
||||
|
@ -37,11 +37,13 @@ public class EventDispatcherImpl implements EventDispatcher {
|
||||
private boolean _ignore = false;
|
||||
private HashMap _events = new HashMap(4);
|
||||
private ArrayList _attached = new ArrayList();
|
||||
|
||||
|
||||
@Override
|
||||
public EventDispatcher getEventDispatcher() {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void attachEventDispatcher(EventDispatcher ev) {
|
||||
if (ev == null) return;
|
||||
synchronized (_attached) {
|
||||
@ -49,7 +51,8 @@ public class EventDispatcherImpl implements EventDispatcher {
|
||||
_attached.add(ev);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void detachEventDispatcher(EventDispatcher ev) {
|
||||
if (ev == null) return;
|
||||
synchronized (_attached) {
|
||||
@ -62,7 +65,8 @@ public class EventDispatcherImpl implements EventDispatcher {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void notifyEvent(String eventName, Object args) {
|
||||
if (_ignore) return;
|
||||
if (args == null) {
|
||||
@ -84,7 +88,8 @@ public class EventDispatcherImpl implements EventDispatcher {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object getEventValue(String name) {
|
||||
if (_ignore) return null;
|
||||
Object val;
|
||||
@ -106,7 +111,8 @@ public class EventDispatcherImpl implements EventDispatcher {
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void ignoreEvents() {
|
||||
_ignore = true;
|
||||
synchronized (_events) {
|
||||
@ -114,11 +120,13 @@ public class EventDispatcherImpl implements EventDispatcher {
|
||||
}
|
||||
_events = null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void unIgnoreEvents() {
|
||||
_ignore = false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object waitEventValue(String name) {
|
||||
if (_ignore) return null;
|
||||
Object val;
|
||||
|
@ -16,6 +16,7 @@ class Executor implements Runnable {
|
||||
runn = x;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while(runn.getAnswer()) {
|
||||
SimpleTimer.TimedEvent evt = null;
|
||||
|
@ -44,6 +44,7 @@ public class FortunaRandomSource extends RandomSource implements EntropyHarveste
|
||||
_haveNextGaussian = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void setSeed(byte buf[]) {
|
||||
_fortuna.addRandomBytes(buf);
|
||||
}
|
||||
@ -56,6 +57,7 @@ public class FortunaRandomSource extends RandomSource implements EntropyHarveste
|
||||
* thats what it has been used for.
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public int nextInt(int n) {
|
||||
if (n == 0) return 0;
|
||||
int rv = signedNextInt(n);
|
||||
@ -64,7 +66,8 @@ public class FortunaRandomSource extends RandomSource implements EntropyHarveste
|
||||
rv %= n;
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int nextInt() { return signedNextInt(Integer.MAX_VALUE); }
|
||||
|
||||
/**
|
||||
@ -107,6 +110,7 @@ public class FortunaRandomSource extends RandomSource implements EntropyHarveste
|
||||
* Like the modified nextInt, nextLong(n) returns a random number from 0 through n,
|
||||
* including 0, excluding n.
|
||||
*/
|
||||
@Override
|
||||
public long nextLong(long n) {
|
||||
if (n == 0) return 0;
|
||||
long rv = signedNextLong(n);
|
||||
@ -116,6 +120,7 @@ public class FortunaRandomSource extends RandomSource implements EntropyHarveste
|
||||
return rv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long nextLong() { return signedNextLong(Long.MAX_VALUE); }
|
||||
|
||||
/**
|
||||
@ -125,12 +130,14 @@ public class FortunaRandomSource extends RandomSource implements EntropyHarveste
|
||||
return ((long)nextBits(32) << 32) + nextBits(32);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean nextBoolean() {
|
||||
// wasteful, might be worth caching the boolean byte later
|
||||
byte val = _fortuna.nextByte();
|
||||
return ((val & 0x01) == 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void nextBytes(byte buf[]) {
|
||||
_fortuna.nextBytes(buf);
|
||||
}
|
||||
@ -138,18 +145,21 @@ public class FortunaRandomSource extends RandomSource implements EntropyHarveste
|
||||
/**
|
||||
* Implementation from sun's java.util.Random javadocs
|
||||
*/
|
||||
@Override
|
||||
public double nextDouble() {
|
||||
return (((long)nextBits(26) << 27) + nextBits(27)) / (double)(1L << 53);
|
||||
}
|
||||
/**
|
||||
* Implementation from sun's java.util.Random javadocs
|
||||
*/
|
||||
@Override
|
||||
public float nextFloat() {
|
||||
return nextBits(24) / ((float)(1 << 24));
|
||||
}
|
||||
/**
|
||||
* Implementation from sun's java.util.Random javadocs
|
||||
*/
|
||||
@Override
|
||||
public synchronized double nextGaussian() {
|
||||
if (_haveNextGaussian) {
|
||||
_haveNextGaussian = false;
|
||||
@ -185,14 +195,17 @@ public class FortunaRandomSource extends RandomSource implements EntropyHarveste
|
||||
return (int)rv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntropyHarvester harvester() { return this; }
|
||||
|
||||
/** reseed the fortuna */
|
||||
@Override
|
||||
public synchronized void feedEntropy(String source, long data, int bitoffset, int bits) {
|
||||
_fortuna.addRandomByte((byte)(data & 0xFF));
|
||||
}
|
||||
|
||||
/** reseed the fortuna */
|
||||
/** reseed the fortuna */
|
||||
@Override
|
||||
public synchronized void feedEntropy(String source, byte[] data, int offset, int len) {
|
||||
_fortuna.addRandomBytes(data, offset, len);
|
||||
}
|
||||
|
@ -62,7 +62,8 @@ public class I2PThread extends Thread {
|
||||
if (_log.shouldLog(level))
|
||||
_log.log(level, msg, t);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
_name = Thread.currentThread().getName();
|
||||
log(Log.DEBUG, "New thread started: " + _name, _createdBy);
|
||||
@ -81,6 +82,7 @@ public class I2PThread extends Thread {
|
||||
log(Log.DEBUG, "Thread finished gracefully: " + _name);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
log(Log.DEBUG, "Thread finalized: " + _name);
|
||||
super.finalize();
|
||||
@ -109,6 +111,7 @@ public class I2PThread extends Thread {
|
||||
|
||||
public static void main(String args[]) {
|
||||
I2PThread t = new I2PThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
throw new NullPointerException("blah");
|
||||
}
|
||||
|
@ -183,9 +183,11 @@ public class Log {
|
||||
_scopeClass = cls;
|
||||
_scopeCache = getScope(name, cls);
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return _scopeCache.hashCode();
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) throw new NullPointerException("Null object scope?");
|
||||
if (obj instanceof LogScope) {
|
||||
|
@ -655,6 +655,7 @@ public class LogManager {
|
||||
public ShutdownHook() {
|
||||
_id = ++__id;
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
setName("Log " + _id + " shutdown ");
|
||||
shutdown();
|
||||
|
@ -43,7 +43,8 @@ class LogWriter implements Runnable {
|
||||
public void stopWriting() {
|
||||
_write = false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
_write = true;
|
||||
try {
|
||||
|
@ -38,6 +38,7 @@ public class LookaheadInputStream extends FilterInputStream {
|
||||
boolean f = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
if (_eofReached)
|
||||
return -1; //throw new IOException("Already past the EOF");
|
||||
@ -52,9 +53,11 @@ public class LookaheadInputStream extends FilterInputStream {
|
||||
if (rv < 0) rv += 256;
|
||||
return rv;
|
||||
}
|
||||
@Override
|
||||
public int read(byte buf[]) throws IOException {
|
||||
return read(buf, 0, buf.length);
|
||||
}
|
||||
@Override
|
||||
public int read(byte buf[], int off, int len) throws IOException {
|
||||
if (_eofReached)
|
||||
return -1;
|
||||
|
@ -221,18 +221,21 @@ public class NativeBigInteger extends BigInteger {
|
||||
this(integer.toByteArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigInteger modPow(BigInteger exponent, BigInteger m) {
|
||||
if (_nativeOk)
|
||||
return new NativeBigInteger(nativeModPow(toByteArray(), exponent.toByteArray(), m.toByteArray()));
|
||||
else
|
||||
return super.modPow(exponent, m);
|
||||
}
|
||||
@Override
|
||||
public byte[] toByteArray(){
|
||||
if(cachedBa == null) //Since we are immutable it is safe to never update the cached ba after it has initially been generated
|
||||
cachedBa = super.toByteArray();
|
||||
return cachedBa;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double doubleValue() {
|
||||
if (_nativeOk)
|
||||
return nativeDoubleValue(toByteArray());
|
||||
|
@ -48,22 +48,26 @@ public class OrderedProperties extends Properties {
|
||||
_data = new HashMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object value) {
|
||||
return containsValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsKey(Object key) {
|
||||
synchronized (_lock) {
|
||||
return _data.containsKey(key);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsValue(Object value) {
|
||||
synchronized (_lock) {
|
||||
return _data.containsValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if ((obj != null) && (obj instanceof OrderedProperties)) {
|
||||
synchronized (_lock) {
|
||||
@ -74,20 +78,24 @@ public class OrderedProperties extends Properties {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
synchronized (_lock) {
|
||||
return _data.hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return size() == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProperty(String key) {
|
||||
return getProperty((Object) key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get(Object key) {
|
||||
return getProperty(key);
|
||||
}
|
||||
@ -102,6 +110,7 @@ public class OrderedProperties extends Properties {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object setProperty(String key, String val) {
|
||||
if ((key == null) || (val == null)) throw new IllegalArgumentException("Null values are not supported");
|
||||
synchronized (_lock) {
|
||||
@ -111,6 +120,7 @@ public class OrderedProperties extends Properties {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object put(Object key, Object val) {
|
||||
if ((key == null) || (val == null)) throw new NullPointerException("Null values or keys are not allowed");
|
||||
if (!(key instanceof String) || !(val instanceof String))
|
||||
@ -118,6 +128,7 @@ public class OrderedProperties extends Properties {
|
||||
return setProperty((String) key, (String) val);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putAll(Map data) {
|
||||
if (data == null) return;
|
||||
for (Iterator iter = data.entrySet().iterator(); iter.hasNext();) {
|
||||
@ -128,6 +139,7 @@ public class OrderedProperties extends Properties {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
synchronized (_lock) {
|
||||
OrderedProperties rv = new OrderedProperties();
|
||||
@ -136,6 +148,7 @@ public class OrderedProperties extends Properties {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
synchronized (_lock) {
|
||||
_order.clear();
|
||||
@ -143,12 +156,14 @@ public class OrderedProperties extends Properties {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
synchronized (_lock) {
|
||||
return _order.size();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object remove(Object key) {
|
||||
synchronized (_lock) {
|
||||
_order.remove(key);
|
||||
@ -157,18 +172,21 @@ public class OrderedProperties extends Properties {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set keySet() {
|
||||
synchronized (_lock) {
|
||||
return Collections.unmodifiableSortedSet((TreeSet) _order.clone());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set entrySet() {
|
||||
synchronized (_lock) {
|
||||
return Collections.unmodifiableSet(buildEntrySet((TreeSet) _order.clone()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection values() {
|
||||
synchronized (_lock) {
|
||||
Collection values = new ArrayList(_data.size());
|
||||
@ -179,28 +197,35 @@ public class OrderedProperties extends Properties {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration elements() {
|
||||
return Collections.enumeration(values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration keys() {
|
||||
return Collections.enumeration(keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration propertyNames() {
|
||||
return Collections.enumeration(keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void list(PrintStream out) { // nop
|
||||
}
|
||||
|
||||
@Override
|
||||
public void list(PrintWriter out) { // nop
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(InputStream in) { // nop
|
||||
}
|
||||
|
||||
//public void save(OutputStream out, String header) {}
|
||||
@Override
|
||||
public void store(OutputStream out, String header) { // nop
|
||||
}
|
||||
|
||||
@ -223,20 +248,24 @@ public class OrderedProperties extends Properties {
|
||||
_value = val;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getKey() {
|
||||
return _key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
return _value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object setValue(Object value) {
|
||||
Object old = _value;
|
||||
_value = value;
|
||||
return old;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Object o) {
|
||||
if (o == null) return -1;
|
||||
if (o instanceof StringMapEntry) return ((String) getKey()).compareTo((String)((StringMapEntry) o).getKey());
|
||||
@ -244,6 +273,7 @@ public class OrderedProperties extends Properties {
|
||||
return -2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == null) return false;
|
||||
if (!(o instanceof StringMapEntry)) return false;
|
||||
@ -329,6 +359,7 @@ public class OrderedProperties extends Properties {
|
||||
_props = props;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
int numRuns = 1000;
|
||||
_log.debug("Begin thrashing " + numRuns + " times");
|
||||
|
@ -89,6 +89,7 @@ public class PooledRandomSource extends RandomSource {
|
||||
* thats what it has been used for.
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public int nextInt(int n) {
|
||||
RandomSource prng = pickPRNG();
|
||||
synchronized (prng) {
|
||||
@ -100,6 +101,7 @@ public class PooledRandomSource extends RandomSource {
|
||||
* Like the modified nextInt, nextLong(n) returns a random number from 0 through n,
|
||||
* including 0, excluding n.
|
||||
*/
|
||||
@Override
|
||||
public long nextLong(long n) {
|
||||
RandomSource prng = pickPRNG();
|
||||
synchronized (prng) {
|
||||
@ -111,6 +113,7 @@ public class PooledRandomSource extends RandomSource {
|
||||
* override as synchronized, for those JVMs that don't always pull via
|
||||
* nextBytes (cough ibm)
|
||||
*/
|
||||
@Override
|
||||
public boolean nextBoolean() {
|
||||
RandomSource prng = pickPRNG();
|
||||
synchronized (prng) {
|
||||
@ -121,6 +124,7 @@ public class PooledRandomSource extends RandomSource {
|
||||
* override as synchronized, for those JVMs that don't always pull via
|
||||
* nextBytes (cough ibm)
|
||||
*/
|
||||
@Override
|
||||
public void nextBytes(byte buf[]) {
|
||||
RandomSource prng = pickPRNG();
|
||||
synchronized (prng) {
|
||||
@ -131,6 +135,7 @@ public class PooledRandomSource extends RandomSource {
|
||||
* override as synchronized, for those JVMs that don't always pull via
|
||||
* nextBytes (cough ibm)
|
||||
*/
|
||||
@Override
|
||||
public double nextDouble() {
|
||||
RandomSource prng = pickPRNG();
|
||||
synchronized (prng) {
|
||||
@ -141,6 +146,7 @@ public class PooledRandomSource extends RandomSource {
|
||||
* override as synchronized, for those JVMs that don't always pull via
|
||||
* nextBytes (cough ibm)
|
||||
*/
|
||||
@Override
|
||||
public float nextFloat() {
|
||||
RandomSource prng = pickPRNG();
|
||||
synchronized (prng) {
|
||||
@ -151,6 +157,7 @@ public class PooledRandomSource extends RandomSource {
|
||||
* override as synchronized, for those JVMs that don't always pull via
|
||||
* nextBytes (cough ibm)
|
||||
*/
|
||||
@Override
|
||||
public double nextGaussian() {
|
||||
RandomSource prng = pickPRNG();
|
||||
synchronized (prng) {
|
||||
@ -161,6 +168,7 @@ public class PooledRandomSource extends RandomSource {
|
||||
* override as synchronized, for those JVMs that don't always pull via
|
||||
* nextBytes (cough ibm)
|
||||
*/
|
||||
@Override
|
||||
public int nextInt() {
|
||||
RandomSource prng = pickPRNG();
|
||||
synchronized (prng) {
|
||||
@ -171,6 +179,7 @@ public class PooledRandomSource extends RandomSource {
|
||||
* override as synchronized, for those JVMs that don't always pull via
|
||||
* nextBytes (cough ibm)
|
||||
*/
|
||||
@Override
|
||||
public long nextLong() {
|
||||
RandomSource prng = pickPRNG();
|
||||
synchronized (prng) {
|
||||
@ -178,6 +187,7 @@ public class PooledRandomSource extends RandomSource {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntropyHarvester harvester() {
|
||||
RandomSource prng = pickPRNG();
|
||||
return prng.harvester();
|
||||
|
@ -49,6 +49,7 @@ public class RandomSource extends SecureRandom implements EntropyHarvester {
|
||||
* thats what it has been used for.
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public int nextInt(int n) {
|
||||
if (n == 0) return 0;
|
||||
int val = super.nextInt(n);
|
||||
@ -72,45 +73,54 @@ public class RandomSource extends SecureRandom implements EntropyHarvester {
|
||||
* override as synchronized, for those JVMs that don't always pull via
|
||||
* nextBytes (cough ibm)
|
||||
*/
|
||||
@Override
|
||||
public boolean nextBoolean() { return super.nextBoolean(); }
|
||||
/**
|
||||
* override as synchronized, for those JVMs that don't always pull via
|
||||
* nextBytes (cough ibm)
|
||||
*/
|
||||
@Override
|
||||
public void nextBytes(byte buf[]) { super.nextBytes(buf); }
|
||||
/**
|
||||
* override as synchronized, for those JVMs that don't always pull via
|
||||
* nextBytes (cough ibm)
|
||||
*/
|
||||
@Override
|
||||
public double nextDouble() { return super.nextDouble(); }
|
||||
/**
|
||||
* override as synchronized, for those JVMs that don't always pull via
|
||||
* nextBytes (cough ibm)
|
||||
*/
|
||||
@Override
|
||||
public float nextFloat() { return super.nextFloat(); }
|
||||
/**
|
||||
* override as synchronized, for those JVMs that don't always pull via
|
||||
* nextBytes (cough ibm)
|
||||
*/
|
||||
@Override
|
||||
public double nextGaussian() { return super.nextGaussian(); }
|
||||
/**
|
||||
* override as synchronized, for those JVMs that don't always pull via
|
||||
* nextBytes (cough ibm)
|
||||
*/
|
||||
@Override
|
||||
public int nextInt() { return super.nextInt(); }
|
||||
/**
|
||||
* override as synchronized, for those JVMs that don't always pull via
|
||||
* nextBytes (cough ibm)
|
||||
*/
|
||||
@Override
|
||||
public long nextLong() { return super.nextLong(); }
|
||||
|
||||
public EntropyHarvester harvester() { return _entropyHarvester; }
|
||||
|
||||
@Override
|
||||
public void feedEntropy(String source, long data, int bitoffset, int bits) {
|
||||
if (bitoffset == 0)
|
||||
setSeed(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void feedEntropy(String source, byte[] data, int offset, int len) {
|
||||
if ( (offset == 0) && (len == data.length) ) {
|
||||
setSeed(data);
|
||||
|
@ -60,6 +60,7 @@ public class ResettableGZIPInputStream extends InflaterInputStream {
|
||||
verifyHeader();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
if (_complete) {
|
||||
// shortcircuit so the inflater doesn't try to refill
|
||||
@ -73,9 +74,11 @@ public class ResettableGZIPInputStream extends InflaterInputStream {
|
||||
return _buf1[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(byte buf[]) throws IOException {
|
||||
return read(buf, 0, buf.length);
|
||||
}
|
||||
@Override
|
||||
public int read(byte buf[], int off, int len) throws IOException {
|
||||
if (_complete) {
|
||||
// shortcircuit so the inflater doesn't try to refill
|
||||
|
@ -91,25 +91,30 @@ public class ResettableGZIPOutputStream extends DeflaterOutputStream {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
finish();
|
||||
super.close();
|
||||
}
|
||||
@Override
|
||||
public void finish() throws IOException {
|
||||
ensureHeaderIsWritten();
|
||||
super.finish();
|
||||
writeFooter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
ensureHeaderIsWritten();
|
||||
_crc32.update(b);
|
||||
_writtenSize++;
|
||||
super.write(b);
|
||||
}
|
||||
@Override
|
||||
public void write(byte buf[]) throws IOException {
|
||||
write(buf, 0, buf.length);
|
||||
}
|
||||
@Override
|
||||
public void write(byte buf[], int off, int len) throws IOException {
|
||||
ensureHeaderIsWritten();
|
||||
_crc32.update(buf, off, len);
|
||||
|
@ -47,6 +47,7 @@ public class ReusableGZIPOutputStream extends ResettableGZIPOutputStream {
|
||||
_buffer = (ByteArrayOutputStream)out;
|
||||
}
|
||||
/** clear the data so we can start again afresh */
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
_buffer.reset();
|
||||
|
@ -59,6 +59,7 @@ public class ShellCommand {
|
||||
this.consumeOutput = consumeOutput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
_commandSuccessful = execute(shellCommand, consumeOutput, WAIT_FOR_EXIT_STATUS);
|
||||
if (_isTimerRunning) {
|
||||
@ -90,6 +91,7 @@ public class ShellCommand {
|
||||
this.bufferedReader = new BufferedReader(inputStreamReader);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
String streamData;
|
||||
@ -123,6 +125,7 @@ public class ShellCommand {
|
||||
this.bufferedReader = new BufferedReader(inputStreamReader);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
char[] buffer = new char[BUFFER_SIZE];
|
||||
@ -159,6 +162,7 @@ public class ShellCommand {
|
||||
this.bufferedWriter = new BufferedWriter(outputStreamWriter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
String input;
|
||||
|
@ -56,6 +56,7 @@ public class SocketTimeout implements SimpleTimer.TimedEvent {
|
||||
|
||||
private static final SimpleDateFormat _fmt = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss.SSS");
|
||||
private static String ts(long when) { synchronized (_fmt) { return _fmt.format(new Date(when)); } }
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append("started on ");
|
||||
|
Reference in New Issue
Block a user