Update of /cvsroot/jrobin/src/org/jrobin/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2815/org/jrobin/core Modified Files: RrdBackend.java RrdBackendFactory.java RrdDb.java RrdFileBackend.java RrdFileBackendFactory.java RrdNioBackend.java RrdNioBackendFactory.java Log Message: Default factory switched to NIO. Minor code changes Index: RrdBackend.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/RrdBackend.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** RrdBackend.java 30 May 2004 10:06:47 -0000 1.4 --- RrdBackend.java 1 Jun 2004 14:41:01 -0000 1.5 *************** *** 35,41 **** * <ul> * <li>{@link RrdFileBackend}: objects of this class are created from the ! * {@link RrdFileBackendFactory} class. This is the default backend used in all ! * JRobin releases. It uses java.io.* package and RandomAccessFile class to store ! * RRD data in files on the disk. * * <li>{@link RrdNioBackend}: objects of this class are created from the --- 35,41 ---- * <ul> * <li>{@link RrdFileBackend}: objects of this class are created from the ! * {@link RrdFileBackendFactory} class. This was the default backend used in all ! * JRobin releases prior to 1.4.0. It uses java.io.* package and ! * RandomAccessFile class to store RRD data in files on the disk. * * <li>{@link RrdNioBackend}: objects of this class are created from the *************** *** 43,47 **** * classes (mapped ByteBuffer) to store RRD data in files on the disk. This backend is fast, very fast, * but consumes a lot of memory (borrowed not from the JVM but from the underlying operating system ! * directly). * * <li>{@link RrdMemoryBackend}: objects of this class are created from the --- 43,47 ---- * classes (mapped ByteBuffer) to store RRD data in files on the disk. This backend is fast, very fast, * but consumes a lot of memory (borrowed not from the JVM but from the underlying operating system ! * directly). <b>This is the default backend used in JRobin since 1.4.0 release.</b> * * <li>{@link RrdMemoryBackend}: objects of this class are created from the *************** *** 137,144 **** /** ! * Closes the storage. * @throws IOException Thrown in case of I/O error */ ! public abstract void close() throws IOException; /** --- 137,146 ---- /** ! * Closes the storage. Calls sync() implicitly. * @throws IOException Thrown in case of I/O error */ ! public void close() throws IOException { ! sync(); ! } /** Index: RrdNioBackend.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/RrdNioBackend.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** RrdNioBackend.java 31 May 2004 09:04:50 -0000 1.5 --- RrdNioBackend.java 1 Jun 2004 14:41:01 -0000 1.6 *************** *** 117,126 **** */ protected void sync() { - //long t1 = System.currentTimeMillis(); synchronized(byteBuffer) { byteBuffer.force(); } - //long t2 = System.currentTimeMillis(); - //System.out.println("** SYNC ** " + (t2 - t1) + " millis"); } --- 117,124 ---- */ protected void sync() { synchronized(byteBuffer) { + // System.out.println("** SYNC **"); byteBuffer.force(); } } Index: RrdBackendFactory.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/RrdBackendFactory.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** RrdBackendFactory.java 25 May 2004 11:35:58 -0000 1.5 --- RrdBackendFactory.java 1 Jun 2004 14:41:01 -0000 1.6 *************** *** 40,50 **** * <ul> * <li>{@link RrdFileBackend}: objects of this class are created from the ! * {@link RrdFileBackendFactory} class. This is the default backend used in all ! * JRobin releases. It uses java.io.* package and RandomAccessFile class to store * RRD data in files on the disk. * * <li>{@link RrdNioBackend}: objects of this class are created from the * {@link RrdNioBackendFactory} class. The backend uses java.io.* and java.nio.* ! * classes (mapped ByteBuffer) to store RRD data in files on the disk. * * <li>{@link RrdMemoryBackend}: objects of this class are created from the --- 40,51 ---- * <ul> * <li>{@link RrdFileBackend}: objects of this class are created from the ! * {@link RrdFileBackendFactory} class. This was the default backend used in all ! * JRobin releases before 1.4.0 release. It uses java.io.* package and RandomAccessFile class to store * RRD data in files on the disk. * * <li>{@link RrdNioBackend}: objects of this class are created from the * {@link RrdNioBackendFactory} class. The backend uses java.io.* and java.nio.* ! * classes (mapped ByteBuffer) to store RRD data in files on the disk. This is the default backend ! * since 1.4.0 release. * * <li>{@link RrdMemoryBackend}: objects of this class are created from the *************** *** 73,77 **** // Here is the default backend factory ! defaultFactory = fileFactory; } catch (RrdException e) { --- 74,78 ---- // Here is the default backend factory ! defaultFactory = nioFactory; } catch (RrdException e) { *************** *** 124,127 **** --- 125,141 ---- /** + * Registers new (custom) backend factory within the JRobin framework and sets this + * factory as the default. + * @param factory Factory to be registered and set as default + * @throws RrdException Thrown if the name of the specified factory is already + * used. + */ + public static synchronized void registerAndSetAsDefaultFactory(RrdBackendFactory factory) + throws RrdException { + registerFactory(factory); + setDefaultFactory(factory.getFactoryName()); + } + + /** * Returns the defaul backend factory. This factory is used to construct * {@link RrdDb} objects if no factory is specified in the RrdDb constructor. Index: RrdFileBackend.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/RrdFileBackend.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RrdFileBackend.java 28 May 2004 10:22:47 -0000 1.3 --- RrdFileBackend.java 1 Jun 2004 14:41:01 -0000 1.4 *************** *** 33,37 **** /** ! * Default JRobin backend which is used to store RRD data to ordinary files on the disk.<p> * * This backend is based on the RandomAccessFile class (java.io.* package). --- 33,38 ---- /** ! * JRobin backend which is used to store RRD data to ordinary files on the disk. This was the ! * default factory before 1.4.0 version<p> * * This backend is based on the RandomAccessFile class (java.io.* package). *************** *** 82,86 **** */ public void close() throws IOException { ! sync(); unlockFile(); file.close(); --- 83,87 ---- */ public void close() throws IOException { ! super.close(); // calls sync() unlockFile(); file.close(); Index: RrdFileBackendFactory.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/RrdFileBackendFactory.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RrdFileBackendFactory.java 25 May 2004 11:35:58 -0000 1.3 --- RrdFileBackendFactory.java 1 Jun 2004 14:41:01 -0000 1.4 *************** *** 30,35 **** /** ! * Factory class which creates actual {@link RrdFileBackend} objects. This is the default ! * backend factory in JRobin. */ public class RrdFileBackendFactory extends RrdBackendFactory { --- 30,35 ---- /** ! * Factory class which creates actual {@link RrdFileBackend} objects. This was the default ! * backend factory in JRobin before 1.4.0 release. */ public class RrdFileBackendFactory extends RrdBackendFactory { Index: RrdNioBackendFactory.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/RrdNioBackendFactory.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** RrdNioBackendFactory.java 31 May 2004 09:04:51 -0000 1.5 --- RrdNioBackendFactory.java 1 Jun 2004 14:41:01 -0000 1.6 *************** *** 29,33 **** /** ! * Factory class which creates actual {@link RrdNioBackend} objects. */ public class RrdNioBackendFactory extends RrdFileBackendFactory{ --- 29,34 ---- /** ! * Factory class which creates actual {@link RrdNioBackend} objects. This is the default factory since ! * 1.4.0 version */ public class RrdNioBackendFactory extends RrdFileBackendFactory{ Index: RrdDb.java =================================================================== RCS file: /cvsroot/jrobin/src/org/jrobin/core/RrdDb.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** RrdDb.java 30 May 2004 10:06:47 -0000 1.18 --- RrdDb.java 1 Jun 2004 14:41:01 -0000 1.19 *************** *** 89,93 **** /** * <p>Constructor used to create new RRD object from the definition. This RRD object will be backed ! * with a storage (backend) of the default type. Initially, storage type defaults to "FILE" * (RRD bytes will be put in a file on the disk). Default storage type can be changed with a static * {@link RrdBackendFactory#setDefaultFactory(String)} method call.</p> --- 89,93 ---- /** * <p>Constructor used to create new RRD object from the definition. This RRD object will be backed ! * with a storage (backend) of the default type. Initially, storage type defaults to "NIO" * (RRD bytes will be put in a file on the disk). Default storage type can be changed with a static * {@link RrdBackendFactory#setDefaultFactory(String)} method call.</p> |