forked from I2P_Developers/i2p.i2p
add Closeable/Flushable interfaces
This commit is contained in:
@ -22,6 +22,7 @@
|
|||||||
package net.i2p.addressbook;
|
package net.i2p.addressbook;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
import java.io.Closeable;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -41,7 +42,7 @@ import java.util.NoSuchElementException;
|
|||||||
*
|
*
|
||||||
* @since 0.8.7
|
* @since 0.8.7
|
||||||
*/
|
*/
|
||||||
class ConfigIterator implements Iterator<Map.Entry<String, String>> {
|
class ConfigIterator implements Iterator<Map.Entry<String, String>>, Closeable {
|
||||||
|
|
||||||
private BufferedReader input;
|
private BufferedReader input;
|
||||||
private ConfigEntry next;
|
private ConfigEntry next;
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
package org.klomp.snark;
|
package org.klomp.snark;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -50,7 +51,7 @@ import net.i2p.util.SystemVersion;
|
|||||||
/**
|
/**
|
||||||
* Maintains pieces on disk. Can be used to store and retrieve pieces.
|
* Maintains pieces on disk. Can be used to store and retrieve pieces.
|
||||||
*/
|
*/
|
||||||
public class Storage
|
public class Storage implements Closeable
|
||||||
{
|
{
|
||||||
private final MetaInfo metainfo;
|
private final MetaInfo metainfo;
|
||||||
private final List<TorrentFile> _torrentFiles;
|
private final List<TorrentFile> _torrentFiles;
|
||||||
|
@ -9,6 +9,7 @@ package net.i2p.sam;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.Closeable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
@ -31,7 +32,7 @@ import net.i2p.util.Log;
|
|||||||
*
|
*
|
||||||
* @author human
|
* @author human
|
||||||
*/
|
*/
|
||||||
abstract class SAMMessageSession {
|
abstract class SAMMessageSession implements Closeable {
|
||||||
|
|
||||||
protected final Log _log;
|
protected final Log _log;
|
||||||
private I2PSession session;
|
private I2PSession session;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.i2p.client.streaming.impl;
|
package net.i2p.client.streaming.impl;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -25,7 +26,7 @@ import net.i2p.util.SimpleTimer2;
|
|||||||
*<p>
|
*<p>
|
||||||
* MessageOutputStream -> ConnectionDataReceiver -> Connection -> PacketQueue -> I2PSession
|
* MessageOutputStream -> ConnectionDataReceiver -> Connection -> PacketQueue -> I2PSession
|
||||||
*/
|
*/
|
||||||
class PacketQueue implements SendMessageStatusListener {
|
class PacketQueue implements SendMessageStatusListener, Closeable {
|
||||||
private final I2PAppContext _context;
|
private final I2PAppContext _context;
|
||||||
private final Log _log;
|
private final Log _log;
|
||||||
private final ByteCache _cache = ByteCache.getInstance(64, 36*1024);
|
private final ByteCache _cache = ByteCache.getInstance(64, 36*1024);
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package net.i2p.client.streaming.impl;
|
package net.i2p.client.streaming.impl;
|
||||||
|
|
||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
|
import java.io.Closeable;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.Flushable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
@ -41,7 +43,7 @@ import net.i2p.data.DataHelper;
|
|||||||
*
|
*
|
||||||
* @since 0.9.4
|
* @since 0.9.4
|
||||||
*/
|
*/
|
||||||
public class PcapWriter {
|
public class PcapWriter implements Closeable, Flushable {
|
||||||
|
|
||||||
/** big-endian, see file format ref - 24 bytes */
|
/** big-endian, see file format ref - 24 bytes */
|
||||||
private static final byte[] FILE_HEADER = { (byte) 0xa1, (byte) 0xb2, (byte) 0xc3, (byte) 0xd4,
|
private static final byte[] FILE_HEADER = { (byte) 0xa1, (byte) 0xb2, (byte) 0xc3, (byte) 0xd4,
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package net.i2p.internal;
|
package net.i2p.internal;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
|
|
||||||
import net.i2p.data.i2cp.I2CPMessage;
|
import net.i2p.data.i2cp.I2CPMessage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -15,7 +17,7 @@ import net.i2p.data.i2cp.I2CPMessage;
|
|||||||
* @author zzz
|
* @author zzz
|
||||||
* @since 0.8.3
|
* @since 0.8.3
|
||||||
*/
|
*/
|
||||||
public abstract class I2CPMessageQueue {
|
public abstract class I2CPMessageQueue implements Closeable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a message, nonblocking.
|
* Send a message, nonblocking.
|
||||||
|
@ -10,6 +10,7 @@ package net.i2p.util;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.Flushable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
@ -37,7 +38,7 @@ import net.i2p.data.DataHelper;
|
|||||||
* writes them where appropriate.
|
* writes them where appropriate.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class LogManager {
|
public class LogManager implements Flushable {
|
||||||
public final static String CONFIG_LOCATION_PROP = "loggerConfigLocation";
|
public final static String CONFIG_LOCATION_PROP = "loggerConfigLocation";
|
||||||
public final static String FILENAME_OVERRIDE_PROP = "loggerFilenameOverride";
|
public final static String FILENAME_OVERRIDE_PROP = "loggerFilenameOverride";
|
||||||
public final static String CONFIG_LOCATION_DEFAULT = "logger.config";
|
public final static String CONFIG_LOCATION_DEFAULT = "logger.config";
|
||||||
|
@ -28,9 +28,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
*/
|
*/
|
||||||
package net.metanotion.io;
|
package net.metanotion.io;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public interface RandomAccessInterface {
|
public interface RandomAccessInterface extends Closeable {
|
||||||
public long getFilePointer() throws IOException;
|
public long getFilePointer() throws IOException;
|
||||||
public long length() throws IOException;
|
public long length() throws IOException;
|
||||||
public int read() throws IOException;
|
public int read() throws IOException;
|
||||||
|
@ -28,6 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
*/
|
*/
|
||||||
package net.metanotion.io.block;
|
package net.metanotion.io.block;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.RandomAccessFile;
|
import java.io.RandomAccessFile;
|
||||||
@ -64,7 +65,7 @@ import net.i2p.util.Log;
|
|||||||
* Pages are 1 KB and are numbered starting from 1.
|
* Pages are 1 KB and are numbered starting from 1.
|
||||||
* e.g. the Metaindex skiplist is at offset 1024 bytes
|
* e.g. the Metaindex skiplist is at offset 1024 bytes
|
||||||
*/
|
*/
|
||||||
public class BlockFile {
|
public class BlockFile implements Closeable {
|
||||||
public static final int PAGESIZE = 1024;
|
public static final int PAGESIZE = 1024;
|
||||||
public static final long OFFSET_MOUNTED = 20;
|
public static final long OFFSET_MOUNTED = 20;
|
||||||
public final Log log = I2PAppContext.getGlobalContext().logManager().getLog(BlockFile.class);
|
public final Log log = I2PAppContext.getGlobalContext().logManager().getLog(BlockFile.class);
|
||||||
|
@ -28,6 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
*/
|
*/
|
||||||
package net.metanotion.io.block.index;
|
package net.metanotion.io.block.index;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
@ -50,7 +51,7 @@ import net.i2p.util.Log;
|
|||||||
*
|
*
|
||||||
* Always fits on one page.
|
* Always fits on one page.
|
||||||
*/
|
*/
|
||||||
public class BSkipList extends SkipList {
|
public class BSkipList extends SkipList implements Closeable {
|
||||||
private static final long MAGIC = 0x536b69704c697374l; // "SkipList"
|
private static final long MAGIC = 0x536b69704c697374l; // "SkipList"
|
||||||
public int firstSpanPage = 0;
|
public int firstSpanPage = 0;
|
||||||
public int firstLevelPage = 0;
|
public int firstLevelPage = 0;
|
||||||
|
@ -28,12 +28,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
*/
|
*/
|
||||||
package net.metanotion.util.skiplist;
|
package net.metanotion.util.skiplist;
|
||||||
|
|
||||||
|
import java.io.Flushable;
|
||||||
|
|
||||||
import net.metanotion.io.block.BlockFile;
|
import net.metanotion.io.block.BlockFile;
|
||||||
|
|
||||||
import net.i2p.I2PAppContext;
|
import net.i2p.I2PAppContext;
|
||||||
import net.i2p.util.Log;
|
import net.i2p.util.Log;
|
||||||
|
|
||||||
public class SkipLevels {
|
public class SkipLevels implements Flushable {
|
||||||
/** We can't have more than 2**32 pages */
|
/** We can't have more than 2**32 pages */
|
||||||
public static final int MAX_SIZE = 32;
|
public static final int MAX_SIZE = 32;
|
||||||
|
|
||||||
|
@ -28,13 +28,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
*/
|
*/
|
||||||
package net.metanotion.util.skiplist;
|
package net.metanotion.util.skiplist;
|
||||||
|
|
||||||
|
import java.io.Flushable;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import net.i2p.util.RandomSource;
|
import net.i2p.util.RandomSource;
|
||||||
|
|
||||||
//import net.metanotion.io.block.BlockFile;
|
//import net.metanotion.io.block.BlockFile;
|
||||||
|
|
||||||
public class SkipList {
|
public class SkipList implements Flushable {
|
||||||
/** the probability of each next higher level */
|
/** the probability of each next higher level */
|
||||||
protected static final int P = 2;
|
protected static final int P = 2;
|
||||||
private static final int MIN_SLOTS = 4;
|
private static final int MIN_SLOTS = 4;
|
||||||
|
@ -28,9 +28,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
*/
|
*/
|
||||||
package net.metanotion.util.skiplist;
|
package net.metanotion.util.skiplist;
|
||||||
|
|
||||||
|
import java.io.Flushable;
|
||||||
|
|
||||||
//import net.metanotion.io.block.BlockFile;
|
//import net.metanotion.io.block.BlockFile;
|
||||||
|
|
||||||
public class SkipSpan {
|
public class SkipSpan implements Flushable {
|
||||||
/** This is actually limited by BlockFile.spanSize which is much smaller */
|
/** This is actually limited by BlockFile.spanSize which is much smaller */
|
||||||
public static final int MAX_SIZE = 256;
|
public static final int MAX_SIZE = 256;
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ import java.io.BufferedOutputStream;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FilenameFilter;
|
import java.io.FilenameFilter;
|
||||||
|
import java.io.Flushable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
@ -193,7 +194,7 @@ class PersistentDataStore extends TransientDataStore {
|
|||||||
* we will soon have to implement a scheme for keeping only
|
* we will soon have to implement a scheme for keeping only
|
||||||
* a subset of all DatabaseEntrys in memory and keeping the rest on disk.
|
* a subset of all DatabaseEntrys in memory and keeping the rest on disk.
|
||||||
*/
|
*/
|
||||||
private class Writer implements Runnable {
|
private class Writer implements Runnable, Flushable {
|
||||||
private final Map<Hash, DatabaseEntry>_keys;
|
private final Map<Hash, DatabaseEntry>_keys;
|
||||||
private final Object _waitLock;
|
private final Object _waitLock;
|
||||||
private volatile boolean _quit;
|
private volatile boolean _quit;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.i2p.router.transport.ntcp;
|
package net.i2p.router.transport.ntcp;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.Inet6Address;
|
import java.net.Inet6Address;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
@ -64,7 +65,7 @@ import net.i2p.util.VersionComparator;
|
|||||||
*</pre>
|
*</pre>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class NTCPConnection {
|
class NTCPConnection implements Closeable {
|
||||||
private final RouterContext _context;
|
private final RouterContext _context;
|
||||||
private final Log _log;
|
private final Log _log;
|
||||||
private SocketChannel _chan;
|
private SocketChannel _chan;
|
||||||
|
Reference in New Issue
Block a user