You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
(414) |
Apr
(123) |
May
(448) |
Jun
(180) |
Jul
(17) |
Aug
(49) |
Sep
(3) |
Oct
(92) |
Nov
(101) |
Dec
(64) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(132) |
Feb
(230) |
Mar
(146) |
Apr
(146) |
May
|
Jun
|
Jul
(34) |
Aug
(4) |
Sep
(3) |
Oct
(10) |
Nov
(12) |
Dec
(24) |
2008 |
Jan
(6) |
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(11) |
Nov
(4) |
Dec
|
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
From: Bryan T. <tho...@us...> - 2007-03-22 21:11:59
|
Update of /cvsroot/cweb/bigdata/src/java/com/bigdata/journal In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv3112/src/java/com/bigdata/journal Modified Files: IRootBlockView.java RootBlockView.java TemporaryRawStore.java Options.java FileMetadata.java Journal.java AbstractJournal.java Log Message: Working on service startup and signal handling. Index: TemporaryRawStore.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/journal/TemporaryRawStore.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TemporaryRawStore.java 15 Mar 2007 16:11:13 -0000 1.4 --- TemporaryRawStore.java 22 Mar 2007 21:11:25 -0000 1.5 *************** *** 273,278 **** TransientBufferStrategy tmp = (TransientBufferStrategy)buf; - int segmentId = 0; - File file; --- 273,276 ---- *************** *** 309,313 **** * will be pre-extended to the requested initialExtent. */ ! FileMetadata fileMetadata = new FileMetadata(segmentId, file, BufferMode.Disk, useDirectBuffers, initialExtent, maximumDiskExtent, create, isEmptyFile, deleteOnExit, --- 307,311 ---- * will be pre-extended to the requested initialExtent. */ ! FileMetadata fileMetadata = new FileMetadata(file, BufferMode.Disk, useDirectBuffers, initialExtent, maximumDiskExtent, create, isEmptyFile, deleteOnExit, Index: FileMetadata.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/journal/FileMetadata.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** FileMetadata.java 22 Feb 2007 16:59:34 -0000 1.14 --- FileMetadata.java 22 Mar 2007 21:11:25 -0000 1.15 *************** *** 51,54 **** --- 51,57 ---- import java.nio.channels.FileChannel; import java.nio.channels.FileLock; + import java.util.UUID; + + import org.apache.log4j.Logger; import com.bigdata.rawstore.Bytes; *************** *** 63,66 **** --- 66,74 ---- public class FileMetadata { + /** + * Logger. + */ + public static final Logger log = Logger.getLogger(FileMetadata.class); + static final int SIZE_MAGIC = Bytes.SIZEOF_INT; static final int SIZE_VERSION = Bytes.SIZEOF_INT; *************** *** 77,84 **** final int VERSION1 = 0x1; ! /** ! * The unique segment identifier. ! */ ! final int segment; /** --- 85,92 ---- final int VERSION1 = 0x1; ! // /** ! // * The unique segment identifier. ! // */ ! // final int segment; /** *************** *** 156,161 **** * Prepare a journal file for use by an {@link IBufferStrategy}. * - * @param segmentId - * The unique segment identifier. * @param file * The name of the file to be opened. --- 164,167 ---- *************** *** 197,201 **** * journal. */ ! FileMetadata(int segmentId, File file, BufferMode bufferMode, boolean useDirectBuffers, long initialExtent, long maximumExtent, boolean create, boolean isEmptyFile, boolean deleteOnExit, --- 203,207 ---- * journal. */ ! FileMetadata(File file, BufferMode bufferMode, boolean useDirectBuffers, long initialExtent, long maximumExtent, boolean create, boolean isEmptyFile, boolean deleteOnExit, *************** *** 231,235 **** } ! this.segment = segmentId; this.bufferMode = bufferMode; --- 237,241 ---- } ! // this.segment = segmentId; this.bufferMode = bufferMode; *************** *** 245,249 **** if (exists) { ! System.err.println("Opening existing file: " + file.getAbsoluteFile()); --- 251,255 ---- if (exists) { ! log.info("Opening existing file: " + file.getAbsoluteFile()); *************** *** 266,270 **** } ! System.err.println("Will create file: " + file.getAbsoluteFile()); } --- 272,276 ---- } ! log.info("Will create file: " + file.getAbsoluteFile()); } *************** *** 382,391 **** rootBlock0 = new RootBlockView(true,tmp0); } catch(RootBlockException ex ) { ! System.err.println("Bad root block zero: "+ex); } try { rootBlock1 = new RootBlockView(false,tmp1); } catch(RootBlockException ex ) { ! System.err.println("Bad root block one: "+ex); } if( rootBlock0 == null && rootBlock1 == null ) { --- 388,397 ---- rootBlock0 = new RootBlockView(true,tmp0); } catch(RootBlockException ex ) { ! log.warn("Bad root block zero: "+ex); } try { rootBlock1 = new RootBlockView(false,tmp1); } catch(RootBlockException ex ) { ! log.warn("Bad root block one: "+ex); } if( rootBlock0 == null && rootBlock1 == null ) { *************** *** 518,527 **** final long commitRecordAddr = 0L; final long commitRecordIndexAddr = 0L; ! IRootBlockView rootBlock0 = new RootBlockView(true, segmentId, nextOffset, firstTxId, lastTxId, commitTimestamp, ! commitCounter, commitRecordAddr, commitRecordIndexAddr); ! IRootBlockView rootBlock1 = new RootBlockView(false, segmentId, nextOffset, firstTxId, lastTxId, commitTimestamp, ! commitCounter, commitRecordAddr, commitRecordIndexAddr); FileChannel channel = raf.getChannel(); channel.write(rootBlock0.asReadOnlyBuffer(), OFFSET_ROOT_BLOCK0); --- 524,536 ---- final long commitRecordAddr = 0L; final long commitRecordIndexAddr = 0L; ! final UUID uuid = UUID.randomUUID(); ! IRootBlockView rootBlock0 = new RootBlockView(true, nextOffset, firstTxId, lastTxId, commitTimestamp, ! commitCounter, commitRecordAddr, commitRecordIndexAddr, ! uuid); ! IRootBlockView rootBlock1 = new RootBlockView(false, nextOffset, firstTxId, lastTxId, commitTimestamp, ! commitCounter, commitRecordAddr, commitRecordIndexAddr, ! uuid); FileChannel channel = raf.getChannel(); channel.write(rootBlock0.asReadOnlyBuffer(), OFFSET_ROOT_BLOCK0); Index: AbstractJournal.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/journal/AbstractJournal.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AbstractJournal.java 17 Mar 2007 23:14:59 -0000 1.4 --- AbstractJournal.java 22 Mar 2007 21:11:25 -0000 1.5 *************** *** 53,56 **** --- 53,57 ---- import java.util.Map; import java.util.Properties; + import java.util.UUID; import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentHashMap; *************** *** 76,79 **** --- 77,81 ---- import com.bigdata.rawstore.Bytes; import com.bigdata.rawstore.IRawStore; + import com.bigdata.scaleup.IMetadataIndexManager; import com.bigdata.scaleup.MasterJournal; import com.bigdata.scaleup.SlaveJournal; *************** *** 306,310 **** public AbstractJournal(Properties properties) { ! int segmentId; long initialExtent = Options.DEFAULT_INITIAL_EXTENT; long maximumExtent = Options.DEFAULT_MAXIMUM_EXTENT; --- 308,312 ---- public AbstractJournal(Properties properties) { ! // int segmentId; long initialExtent = Options.DEFAULT_INITIAL_EXTENT; long maximumExtent = Options.DEFAULT_MAXIMUM_EXTENT; *************** *** 352,377 **** } ! /* ! * "segment". ! */ ! ! val = properties.getProperty(Options.SEGMENT); ! ! if (val == null) { ! ! if (bufferMode == BufferMode.Transient) { ! ! val = "0"; ! ! } else { ! ! throw new RuntimeException("Required property: '" ! + Options.SEGMENT + "'"); ! ! } ! ! } ! ! segmentId = Integer.parseInt(val); /* --- 354,379 ---- } ! // /* ! // * "segment". ! // */ ! // ! // val = properties.getProperty(Options.SEGMENT); ! // ! // if (val == null) { ! // ! // if (bufferMode == BufferMode.Transient) { ! // ! // val = "0"; ! // ! // } else { ! // ! // throw new RuntimeException("Required property: '" ! // + Options.SEGMENT + "'"); ! // ! // } ! // ! // } ! // ! // segmentId = Integer.parseInt(val); /* *************** *** 618,627 **** final long commitRecordAddr = 0L; final long commitRecordIndexAddr = 0L; ! IRootBlockView rootBlock0 = new RootBlockView(true, segmentId, nextOffset, firstTxId, lastTxId, commitTimestamp, ! commitCounter, commitRecordAddr, commitRecordIndexAddr); ! IRootBlockView rootBlock1 = new RootBlockView(false, segmentId, nextOffset, firstTxId, lastTxId, commitTimestamp, ! commitCounter, commitRecordAddr, commitRecordIndexAddr); _bufferStrategy.writeRootBlock(rootBlock0, ForceEnum.No); _bufferStrategy.writeRootBlock(rootBlock1, ForceEnum.No); --- 620,632 ---- final long commitRecordAddr = 0L; final long commitRecordIndexAddr = 0L; ! final UUID uuid = UUID.randomUUID(); ! IRootBlockView rootBlock0 = new RootBlockView(true, nextOffset, firstTxId, lastTxId, commitTimestamp, ! commitCounter, commitRecordAddr, commitRecordIndexAddr, ! uuid); ! IRootBlockView rootBlock1 = new RootBlockView(false, nextOffset, firstTxId, lastTxId, commitTimestamp, ! commitCounter, commitRecordAddr, commitRecordIndexAddr, ! uuid); _bufferStrategy.writeRootBlock(rootBlock0, ForceEnum.No); _bufferStrategy.writeRootBlock(rootBlock1, ForceEnum.No); *************** *** 639,643 **** */ ! FileMetadata fileMetadata = new FileMetadata(segmentId, file, BufferMode.Direct, useDirectBuffers, initialExtent, maximumExtent, create, isEmptyFile, deleteOnExit, --- 644,648 ---- */ ! FileMetadata fileMetadata = new FileMetadata(file, BufferMode.Direct, useDirectBuffers, initialExtent, maximumExtent, create, isEmptyFile, deleteOnExit, *************** *** 659,663 **** */ ! FileMetadata fileMetadata = new FileMetadata(segmentId, file, BufferMode.Mapped, useDirectBuffers, initialExtent, maximumExtent, create, isEmptyFile, deleteOnExit, --- 664,668 ---- */ ! FileMetadata fileMetadata = new FileMetadata(file, BufferMode.Mapped, useDirectBuffers, initialExtent, maximumExtent, create, isEmptyFile, deleteOnExit, *************** *** 679,683 **** */ ! FileMetadata fileMetadata = new FileMetadata(segmentId, file, BufferMode.Disk, useDirectBuffers, initialExtent, maximumExtent, create, isEmptyFile, deleteOnExit, --- 684,688 ---- */ ! FileMetadata fileMetadata = new FileMetadata(file, BufferMode.Disk, useDirectBuffers, initialExtent, maximumExtent, create, isEmptyFile, deleteOnExit, *************** *** 1114,1121 **** // Create the new root block. IRootBlockView newRootBlock = new RootBlockView( ! !old.isRootBlock0(), old.getSegmentId(), _bufferStrategy .getNextOffset(), firstCommitTime, lastCommitTime, commitTime, newCommitCounter, ! commitRecordAddr, commitRecordIndexAddr); _bufferStrategy.writeRootBlock(newRootBlock, forceOnCommit); --- 1119,1127 ---- // Create the new root block. IRootBlockView newRootBlock = new RootBlockView( ! !old.isRootBlock0(), /*old.getSegmentId(),*/ _bufferStrategy .getNextOffset(), firstCommitTime, lastCommitTime, commitTime, newCommitCounter, ! commitRecordAddr, commitRecordIndexAddr, ! old.getUUID()); _bufferStrategy.writeRootBlock(newRootBlock, forceOnCommit); Index: Options.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/journal/Options.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Options.java 22 Feb 2007 16:59:34 -0000 1.10 --- Options.java 22 Mar 2007 21:11:25 -0000 1.11 *************** *** 116,128 **** /** - * <code>segment</code> - The unique int32 segment identifier (required - * unless this is a {@link BufferMode#Transient} journal). Segment - * identifiers are assigned by a bigdata federation (scale out solution). - * When using the journal as part of an embedded or scale up database you - * may safely assign an arbitrary segment identifier, e.g., zero(0). - */ - public static final String SEGMENT = "segment"; - - /** * <code>create</code> - An optional boolean property (default is * <code>true</code>). When true and the named file is not found, a new --- 116,119 ---- Index: Journal.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/journal/Journal.java,v retrieving revision 1.62 retrieving revision 1.63 diff -C2 -d -r1.62 -r1.63 *** Journal.java 15 Mar 2007 16:11:13 -0000 1.62 --- Journal.java 22 Mar 2007 21:11:25 -0000 1.63 *************** *** 48,81 **** package com.bigdata.journal; - import java.io.File; - import java.io.IOException; - import java.nio.ByteBuffer; - import java.util.Map; import java.util.Properties; - import java.util.concurrent.Callable; - import java.util.concurrent.ConcurrentHashMap; - import java.util.concurrent.ExecutionException; - import java.util.concurrent.ExecutorService; - import java.util.concurrent.Executors; - import org.apache.log4j.Level; - import org.apache.log4j.Logger; - - import com.bigdata.cache.LRUCache; - import com.bigdata.cache.WeakValueCache; - import com.bigdata.isolation.ReadOnlyIsolatedIndex; - import com.bigdata.isolation.UnisolatedBTree; - import com.bigdata.journal.ReadCommittedTx.ReadCommittedIndex; - import com.bigdata.objndx.BTree; - import com.bigdata.objndx.IIndex; - import com.bigdata.objndx.IndexSegment; - import com.bigdata.objndx.ReadOnlyIndex; - import com.bigdata.rawstore.Addr; - import com.bigdata.rawstore.Bytes; - import com.bigdata.rawstore.IRawStore; - import com.bigdata.scaleup.MasterJournal; - import com.bigdata.scaleup.SlaveJournal; import com.bigdata.scaleup.MasterJournal.Options; - import com.bigdata.util.concurrent.DaemonThreadFactory; /** --- 48,54 ---- Index: RootBlockView.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/journal/RootBlockView.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** RootBlockView.java 28 Feb 2007 13:59:10 -0000 1.13 --- RootBlockView.java 22 Mar 2007 21:11:25 -0000 1.14 *************** *** 49,53 **** --- 49,55 ---- import java.nio.ByteBuffer; + import java.util.UUID; + import com.bigdata.objndx.BTreeMetadata; import com.bigdata.rawstore.Addr; import com.bigdata.rawstore.Bytes; *************** *** 63,67 **** * need a magic for the root blocks if we use a checksum. or maybe it is * [magic,checksum,[data]] with the timestamps inside of the checksumed ! * data region. */ public class RootBlockView implements IRootBlockView { --- 65,70 ---- * need a magic for the root blocks if we use a checksum. or maybe it is * [magic,checksum,[data]] with the timestamps inside of the checksumed ! * data region. the {@link #OFFSET_UNUSED1} field might be put to this ! * purpose. */ public class RootBlockView implements IRootBlockView { *************** *** 70,78 **** static final transient short SIZEOF_MAGIC = Bytes.SIZEOF_INT; static final transient short SIZEOF_VERSION = Bytes.SIZEOF_INT; ! static final transient short SIZEOF_SEGMENT_ID = Bytes.SIZEOF_INT; static final transient short SIZEOF_ADDR = Bytes.SIZEOF_LONG; static final transient short SIZEOF_COUNTER = Bytes.SIZEOF_LONG; static final transient short SIZEOF_OFFSET = Bytes.SIZEOF_INT; ! static final transient short SIZEOF_UNUSED = 256; // Note: a chunk of reserved bytes. // static final transient short OFFSET_CHECKSUM = --- 73,82 ---- static final transient short SIZEOF_MAGIC = Bytes.SIZEOF_INT; static final transient short SIZEOF_VERSION = Bytes.SIZEOF_INT; ! // static final transient short SIZEOF_SEGMENT_ID = Bytes.SIZEOF_INT; static final transient short SIZEOF_ADDR = Bytes.SIZEOF_LONG; static final transient short SIZEOF_COUNTER = Bytes.SIZEOF_LONG; static final transient short SIZEOF_OFFSET = Bytes.SIZEOF_INT; ! // Note: a chunk of reserved bytes. ! static final transient short SIZEOF_UNUSED = 256-Bytes.SIZEOF_UUID; // static final transient short OFFSET_CHECKSUM = *************** *** 80,85 **** static final transient short OFFSET_MAGIC = OFFSET_TIMESTAMP0 + SIZEOF_TIMESTAMP; static final transient short OFFSET_VERSION = OFFSET_MAGIC + SIZEOF_MAGIC; ! static final transient short OFFSET_SEGMENT_ID = OFFSET_VERSION + SIZEOF_VERSION; ! static final transient short OFFSET_NEXT_OFFSET= OFFSET_SEGMENT_ID + SIZEOF_SEGMENT_ID; static final transient short OFFSET_FIRST_CMIT = OFFSET_NEXT_OFFSET + SIZEOF_OFFSET; static final transient short OFFSET_LAST_CMIT = OFFSET_FIRST_CMIT + SIZEOF_TIMESTAMP; --- 84,89 ---- static final transient short OFFSET_MAGIC = OFFSET_TIMESTAMP0 + SIZEOF_TIMESTAMP; static final transient short OFFSET_VERSION = OFFSET_MAGIC + SIZEOF_MAGIC; ! static final transient short OFFSET_UNUSED1 = OFFSET_VERSION + SIZEOF_VERSION; ! static final transient short OFFSET_NEXT_OFFSET= OFFSET_UNUSED1 + Bytes.SIZEOF_INT; static final transient short OFFSET_FIRST_CMIT = OFFSET_NEXT_OFFSET + SIZEOF_OFFSET; static final transient short OFFSET_LAST_CMIT = OFFSET_FIRST_CMIT + SIZEOF_TIMESTAMP; *************** *** 89,93 **** static final transient short OFFSET_COMMIT_NDX = OFFSET_COMMIT_REC + SIZEOF_ADDR; static final transient short OFFSET_UNUSED = OFFSET_COMMIT_NDX + SIZEOF_ADDR; ! static final transient short OFFSET_TIMESTAMP1 = OFFSET_UNUSED + SIZEOF_UNUSED; static final transient short SIZEOF_ROOT_BLOCK = OFFSET_TIMESTAMP1 + SIZEOF_TIMESTAMP; --- 93,98 ---- static final transient short OFFSET_COMMIT_NDX = OFFSET_COMMIT_REC + SIZEOF_ADDR; static final transient short OFFSET_UNUSED = OFFSET_COMMIT_NDX + SIZEOF_ADDR; ! static final transient short OFFSET_UUID = OFFSET_UNUSED + SIZEOF_UNUSED; ! static final transient short OFFSET_TIMESTAMP1 = OFFSET_UUID + Bytes.SIZEOF_UUID; static final transient short SIZEOF_ROOT_BLOCK = OFFSET_TIMESTAMP1 + SIZEOF_TIMESTAMP; *************** *** 116,121 **** * other fields are populated from the supplied parameters. * - * @param segmentId - * The segment identifier for the journal. * @param nextOffset * The next offset at which a record will be written on the --- 121,124 ---- *************** *** 147,155 **** * are no historical {@link ICommitRecord}s (this is true when * the store is first created). */ ! RootBlockView(boolean rootBlock0, int segmentId, int nextOffset, long firstCommitTime, long lastCommitTime, long commitTimestamp, long commitCounter, long commitRecordAddr, ! long commitRecordIndexAddr) { if (nextOffset < 0) --- 150,162 ---- * are no historical {@link ICommitRecord}s (this is true when * the store is first created). + * @param uuid + * The unique journal identifier. */ ! // * @param segmentId ! // * The segment identifier for the journal. ! RootBlockView(boolean rootBlock0, /*int segmentId,*/ int nextOffset, long firstCommitTime, long lastCommitTime, long commitTimestamp, long commitCounter, long commitRecordAddr, ! long commitRecordIndexAddr, UUID uuid) { if (nextOffset < 0) *************** *** 186,189 **** --- 193,199 ---- "The commit record address must exist if there is a commit record index."); } + if(uuid == null) { + throw new IllegalArgumentException("UUID is null"); + } buf = ByteBuffer.allocate(SIZEOF_ROOT_BLOCK); *************** *** 196,200 **** buf.putInt(MAGIC); buf.putInt(VERSION0); ! buf.putInt(segmentId); buf.putInt(nextOffset); buf.putLong(firstCommitTime); --- 206,210 ---- buf.putInt(MAGIC); buf.putInt(VERSION0); ! buf.putInt(0); // unused field buf.putInt(nextOffset); buf.putLong(firstCommitTime); *************** *** 205,208 **** --- 215,220 ---- buf.putLong(commitRecordIndexAddr); buf.position(buf.position()+SIZEOF_UNUSED); // skip unused region. + buf.putLong(uuid.getMostSignificantBits()); + buf.putLong(uuid.getLeastSignificantBits()); buf.putLong(rootBlockTimestamp); *************** *** 351,359 **** } ! public int getSegmentId() { ! ! return buf.getInt(OFFSET_SEGMENT_ID); } public String toString() { --- 363,378 ---- } ! public UUID getUUID() { ! ! return new UUID(buf.getLong(OFFSET_UUID)/* MSB */, buf ! .getLong(OFFSET_UUID + 8)/*LSB*/); } + + // public int getSegmentId() { + // + // return buf.getInt(OFFSET_SEGMENT_ID); + // + // } public String toString() { *************** *** 365,369 **** sb.append("{ rootBlockTimestamp="+getRootBlockTimestamp()); sb.append(", version="+getVersion()); ! sb.append(", segmentId="+getSegmentId()); sb.append(", nextOffset="+getNextOffset()); sb.append(", firstCommitTime="+getFirstCommitTime()); --- 384,388 ---- sb.append("{ rootBlockTimestamp="+getRootBlockTimestamp()); sb.append(", version="+getVersion()); ! // sb.append(", segmentId="+getSegmentId()); sb.append(", nextOffset="+getNextOffset()); sb.append(", firstCommitTime="+getFirstCommitTime()); *************** *** 373,376 **** --- 392,396 ---- sb.append(", commitRecordAddr="+Addr.toString(getCommitRecordAddr())); sb.append(", commitRecordIndexAddr="+Addr.toString(getCommitRecordIndexAddr())); + sb.append(", uuid="+getUUID()); sb.append("}"); Index: IRootBlockView.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/journal/IRootBlockView.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** IRootBlockView.java 11 Mar 2007 11:42:45 -0000 1.10 --- IRootBlockView.java 22 Mar 2007 21:11:25 -0000 1.11 *************** *** 49,52 **** --- 49,53 ---- import java.nio.ByteBuffer; + import java.util.UUID; import com.bigdata.rawstore.Addr; *************** *** 97,105 **** /** - * The segment identifier. - */ - public int getSegmentId(); - - /** * The next offset at which a data item would be written on the store. */ --- 98,101 ---- *************** *** 193,196 **** --- 189,197 ---- /** + * The unique journal identifier + */ + public UUID getUUID(); + + /** * A read-only buffer whose contents are the root block. */ |
From: Bryan T. <tho...@us...> - 2007-03-22 21:11:49
|
Update of /cvsroot/cweb/bigdata-rdf/src/test/com/bigdata/rdf In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv3441/src/test/com/bigdata/rdf Modified Files: AbstractTripleStoreTestCase.java Log Message: Working on service startup and signal handling. Index: AbstractTripleStoreTestCase.java =================================================================== RCS file: /cvsroot/cweb/bigdata-rdf/src/test/com/bigdata/rdf/AbstractTripleStoreTestCase.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** AbstractTripleStoreTestCase.java 11 Mar 2007 11:43:31 -0000 1.12 --- AbstractTripleStoreTestCase.java 22 Mar 2007 21:11:29 -0000 1.13 *************** *** 94,98 **** // properties.setProperty(Options.FORCE_WRITES,ForceEnum.ForceMetadata.toString()); - properties.setProperty(Options.SEGMENT, "0"); if(properties.getProperty(Options.FILE)==null) { properties.setProperty(Options.FILE, getName()+".jnl"); --- 94,97 ---- |
From: Bryan T. <tho...@us...> - 2007-03-22 21:11:45
|
Update of /cvsroot/cweb/bigdata/src/test/com/bigdata/objndx In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv3112/src/test/com/bigdata/objndx Modified Files: TestIndexSegmentWithBloomFilter.java TestIndexSegmentBuilderWithLargeTrees.java TestRestartSafe.java Log Message: Working on service startup and signal handling. Index: TestRestartSafe.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/test/com/bigdata/objndx/TestRestartSafe.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TestRestartSafe.java 11 Mar 2007 11:42:49 -0000 1.6 --- TestRestartSafe.java 22 Mar 2007 21:11:24 -0000 1.7 *************** *** 86,90 **** .toString()); - properties.setProperty(Options.SEGMENT, "0"); properties.setProperty(Options.CREATE_TEMP_FILE, "true"); // properties.setProperty(Options.FILE, getName()+".jnl"); --- 86,89 ---- Index: TestIndexSegmentBuilderWithLargeTrees.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/test/com/bigdata/objndx/TestIndexSegmentBuilderWithLargeTrees.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** TestIndexSegmentBuilderWithLargeTrees.java 15 Mar 2007 16:11:09 -0000 1.12 --- TestIndexSegmentBuilderWithLargeTrees.java 22 Mar 2007 21:11:24 -0000 1.13 *************** *** 81,86 **** .toString()); - properties.setProperty(Options.SEGMENT, "0"); - properties.setProperty(Options.CREATE_TEMP_FILE, "true"); --- 81,84 ---- Index: TestIndexSegmentWithBloomFilter.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/test/com/bigdata/objndx/TestIndexSegmentWithBloomFilter.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** TestIndexSegmentWithBloomFilter.java 15 Mar 2007 16:11:09 -0000 1.10 --- TestIndexSegmentWithBloomFilter.java 22 Mar 2007 21:11:24 -0000 1.11 *************** *** 97,102 **** .toString()); - properties.setProperty(Options.SEGMENT, "0"); - properties.setProperty(Options.CREATE_TEMP_FILE, "true"); --- 97,100 ---- |
From: Bryan T. <tho...@us...> - 2007-03-22 21:11:35
|
Update of /cvsroot/cweb/bigdata-rdf/src/test/com/bigdata/rdf/inf In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv3441/src/test/com/bigdata/rdf/inf Modified Files: AbstractInferenceEngineTestCase.java Log Message: Working on service startup and signal handling. Index: AbstractInferenceEngineTestCase.java =================================================================== RCS file: /cvsroot/cweb/bigdata-rdf/src/test/com/bigdata/rdf/inf/AbstractInferenceEngineTestCase.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** AbstractInferenceEngineTestCase.java 11 Mar 2007 11:43:32 -0000 1.7 --- AbstractInferenceEngineTestCase.java 22 Mar 2007 21:11:29 -0000 1.8 *************** *** 91,95 **** // .toString()); // properties.setProperty(Options.SLOT_SIZE, ""+Bytes.kilobyte32); - properties.setProperty(Options.SEGMENT, "0"); if(properties.getProperty(Options.FILE)==null) { properties.setProperty(Options.FILE, getName()+".jnl"); --- 91,94 ---- |
From: Bryan T. <tho...@us...> - 2007-03-22 21:11:32
|
Update of /cvsroot/cweb/bigdata/src/test/com/bigdata/scaleup In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv3112/src/test/com/bigdata/scaleup Modified Files: TestMetadataIndex.java TestPartitionedJournal.java Log Message: Working on service startup and signal handling. Index: TestMetadataIndex.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/test/com/bigdata/scaleup/TestMetadataIndex.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** TestMetadataIndex.java 11 Mar 2007 11:42:48 -0000 1.10 --- TestMetadataIndex.java 22 Mar 2007 21:11:25 -0000 1.11 *************** *** 197,202 **** properties.setProperty(Options.FILE,file.toString()); - properties.setProperty(Options.SEGMENT,"0"); - // setup a store to hold the metadata index. Journal store = new Journal(properties); --- 197,200 ---- *************** *** 400,405 **** properties.setProperty(Options.FILE,file.toString()); - properties.setProperty(Options.SEGMENT,"0"); - Journal store = new Journal(properties); --- 398,401 ---- *************** *** 503,508 **** properties.setProperty(Options.FILE,file.toString()); - properties.setProperty(Options.SEGMENT,"0"); - Journal store = new Journal(properties); --- 499,502 ---- *************** *** 675,680 **** properties.setProperty(Options.DELETE_ON_EXIT,"true"); - properties.setProperty(Options.SEGMENT,"0"); - Journal store = new Journal(properties); --- 669,672 ---- *************** *** 971,976 **** properties.setProperty(Options.FILE,file.toString()); - properties.setProperty(Options.SEGMENT,"0"); - Journal store = new Journal(properties); --- 963,966 ---- Index: TestPartitionedJournal.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/test/com/bigdata/scaleup/TestPartitionedJournal.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TestPartitionedJournal.java 11 Mar 2007 11:42:48 -0000 1.6 --- TestPartitionedJournal.java 22 Mar 2007 21:11:25 -0000 1.7 *************** *** 134,140 **** properties.setProperty(Options.DELETE_ON_CLOSE, "false"); ! ! properties.setProperty(Options.SEGMENT, "0"); ! properties.setProperty(Options.BASENAME,getName()); --- 134,138 ---- properties.setProperty(Options.DELETE_ON_CLOSE, "false"); ! properties.setProperty(Options.BASENAME,getName()); *************** *** 201,206 **** properties.setProperty(Options.DELETE_ON_CLOSE, "false"); - properties.setProperty(Options.SEGMENT, "0"); - properties.setProperty(Options.BASENAME,getName()); --- 199,202 ---- *************** *** 235,240 **** properties.setProperty(Options.DELETE_ON_CLOSE, "false"); - properties.setProperty(Options.SEGMENT, "0"); - properties.setProperty(Options.BASENAME,getName()); --- 231,234 ---- *************** *** 282,287 **** properties.setProperty(Options.DELETE_ON_CLOSE, "false"); - properties.setProperty(Options.SEGMENT, "0"); - properties.setProperty(Options.BASENAME,getName()); --- 276,279 ---- *************** *** 346,352 **** properties.setProperty(Options.DELETE_ON_CLOSE, "false"); ! ! properties.setProperty(Options.SEGMENT, "0"); ! properties.setProperty(Options.BASENAME,getName()); --- 338,342 ---- properties.setProperty(Options.DELETE_ON_CLOSE, "false"); ! properties.setProperty(Options.BASENAME,getName()); |
From: Bryan T. <tho...@us...> - 2007-03-22 21:11:32
|
Update of /cvsroot/cweb/bigdata/src/resources/logging In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv3112/src/resources/logging Modified Files: log4j.properties Log Message: Working on service startup and signal handling. Index: log4j.properties =================================================================== RCS file: /cvsroot/cweb/bigdata/src/resources/logging/log4j.properties,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** log4j.properties 17 Mar 2007 23:14:59 -0000 1.7 --- log4j.properties 22 Mar 2007 21:11:25 -0000 1.8 *************** *** 16,20 **** log4j.logger.com.bigdata.objndx.IndexSegmentBuilder=INFO log4j.logger.com.bigdata.objndx.AbstractBTreeTestCase=INFO ! log4j.logger.org.CognitiveWeb.bigdata.jini=DEBUG log4j.appender.dest1=org.apache.log4j.ConsoleAppender --- 16,20 ---- log4j.logger.com.bigdata.objndx.IndexSegmentBuilder=INFO log4j.logger.com.bigdata.objndx.AbstractBTreeTestCase=INFO ! log4j.logger.com.bigdata.service=DEBUG log4j.appender.dest1=org.apache.log4j.ConsoleAppender |
From: Bryan T. <tho...@us...> - 2007-03-22 21:11:32
|
Update of /cvsroot/cweb/bigdata/src/java/com/bigdata/service In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv3112/src/java/com/bigdata/service Modified Files: EmbeddedDataService.java package.html DataService.java IDataService.java DataServiceClient.java Added Files: AbstractServer.java DataServer.java IRemoteTxCommitProtocol.java Removed Files: AbstractService.java Log Message: Working on service startup and signal handling. --- NEW FILE: DataServer.java --- /** The Notice below must appear in each file of the Source Code of any copy you distribute of the Licensed Product. Contributors to any Modifications may add their own copyright notices to identify their own contributions. License: The contents of this file are subject to the CognitiveWeb Open Source License Version 1.1 (the License). You may not copy or use this file, in either source code or executable form, except in compliance with the License. You may obtain a copy of the License from http://www.CognitiveWeb.org/legal/license/ Software distributed under the License is distributed on an AS IS basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. Copyrights: Portions created by or assigned to CognitiveWeb are Copyright (c) 2003-2003 CognitiveWeb. All Rights Reserved. Contact information for CognitiveWeb is available at http://www.CognitiveWeb.org Portions Copyright (c) 2002-2003 Bryan Thompson. Acknowledgements: Special thanks to the developers of the Jabber Open Source License 1.0 (JOSL), from which this License was derived. This License contains terms that differ from JOSL. Special thanks to the CognitiveWeb Open Source Contributors for their suggestions and support of the Cognitive Web. Modifications: */ /* * Created on Mar 22, 2007 */ package com.bigdata.service; import java.rmi.Remote; import java.util.Properties; /** * The bigdata data server. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> * @version $Id$ */ public class DataServer extends AbstractServer { /** * @param args */ public DataServer(String[] args) { super(args); } public static void main(String[] args) { new DataServer(args).run(); } protected Remote newService(Properties properties) { return new DataService(properties); } } Index: DataService.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/service/DataService.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DataService.java 22 Mar 2007 15:04:15 -0000 1.4 --- DataService.java 22 Mar 2007 21:11:23 -0000 1.5 *************** *** 48,52 **** --- 48,54 ---- package com.bigdata.service; + import java.io.IOException; import java.net.InetSocketAddress; + import java.rmi.Remote; import java.util.Properties; import java.util.concurrent.Callable; *************** *** 93,96 **** --- 95,100 ---- * @version $Id$ * + * @see DataServer, which is used to start this service. + * * @see NIODataService, which contains some old code that can be refactored for * an NIO interface to the data service. *************** *** 139,144 **** * {read,write,create,delete} access to a temporary directory and a data * directory. */ ! public class DataService extends AbstractService implements IDataService, IWritePipeline, IResourceTransfer { --- 143,152 ---- * {read,write,create,delete} access to a temporary directory and a data * directory. + * + * @todo all of the interfaces implemented by this class need to extend + * {@link Remote} in order to be made visible on the proxy object + * exported by JERI. */ ! public class DataService implements IDataService, IWritePipeline, IResourceTransfer { *************** *** 292,296 **** */ ! public long commit(long tx) { // will place task on writeService and block iff necessary. --- 300,304 ---- */ ! public long commit(long tx) throws IOException { // will place task on writeService and block iff necessary. *************** *** 299,303 **** } ! public void abort(long tx) { // will place task on writeService iff read-write tx. --- 307,311 ---- } ! public void abort(long tx) throws IOException { // will place task on writeService iff read-write tx. Index: IDataService.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/service/IDataService.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** IDataService.java 17 Mar 2007 23:14:58 -0000 1.2 --- IDataService.java 22 Mar 2007 21:11:24 -0000 1.3 *************** *** 48,51 **** --- 48,52 ---- package com.bigdata.service; + import java.io.IOException; import java.util.concurrent.ExecutionException; *************** *** 82,86 **** * @version $Id$ */ ! public interface IDataService extends ITxCommitProtocol { /** --- 83,87 ---- * @version $Id$ */ ! public interface IDataService extends IRemoteTxCommitProtocol { /** *************** *** 128,132 **** */ public void batchOp(long tx, String name, IBatchOp op) ! throws InterruptedException, ExecutionException; /** --- 129,133 ---- */ public void batchOp(long tx, String name, IBatchOp op) ! throws InterruptedException, ExecutionException, IOException; /** *************** *** 160,164 **** */ public void submit(long tx, IProcedure proc) throws InterruptedException, ! ExecutionException; /** --- 161,165 ---- */ public void submit(long tx, IProcedure proc) throws InterruptedException, ! ExecutionException, IOException; /** *************** *** 189,193 **** */ public RangeQueryResult rangeQuery(long tx, String name, byte[] fromKey, ! byte[] toKey, int flags) throws InterruptedException, ExecutionException; // /** --- 190,195 ---- */ public RangeQueryResult rangeQuery(long tx, String name, byte[] fromKey, ! byte[] toKey, int flags) throws InterruptedException, ! ExecutionException, IOException, IOException; // /** --- NEW FILE: IRemoteTxCommitProtocol.java --- /** The Notice below must appear in each file of the Source Code of any copy you distribute of the Licensed Product. Contributors to any Modifications may add their own copyright notices to identify their own contributions. License: The contents of this file are subject to the CognitiveWeb Open Source License Version 1.1 (the License). You may not copy or use this file, in either source code or executable form, except in compliance with the License. You may obtain a copy of the License from http://www.CognitiveWeb.org/legal/license/ Software distributed under the License is distributed on an AS IS basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. Copyrights: Portions created by or assigned to CognitiveWeb are Copyright (c) 2003-2003 CognitiveWeb. All Rights Reserved. Contact information for CognitiveWeb is available at http://www.CognitiveWeb.org Portions Copyright (c) 2002-2003 Bryan Thompson. Acknowledgements: Special thanks to the developers of the Jabber Open Source License 1.0 (JOSL), from which this License was derived. This License contains terms that differ from JOSL. Special thanks to the CognitiveWeb Open Source Contributors for their suggestions and support of the Cognitive Web. Modifications: */ /* * Created on Mar 22, 2007 */ package com.bigdata.service; import java.io.IOException; import java.rmi.Remote; import java.rmi.RemoteException; import com.bigdata.journal.AbstractJournal; import com.bigdata.journal.ITxCommitProtocol; import com.bigdata.journal.ValidationError; /** * Remote interface. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> * @version $Id$ * * @todo reconcile API with {@link ITxCommitProtocol} which is declared by * {@link AbstractJournal}. I do not want to have IOException on all of * the bigdata interfaces, but you need either that or * {@link RemoteException} for an interface that will be exposed by a jini * service (unless you use a smart proxy?). */ public interface IRemoteTxCommitProtocol extends Remote { /** * Request commit of the transaction write set. */ public long commit(long tx) throws ValidationError, IOException; /** * Request abort of the transaction write set. */ public void abort(long tx) throws IOException; } Index: DataServiceClient.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/service/DataServiceClient.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DataServiceClient.java 17 Mar 2007 23:14:58 -0000 1.2 --- DataServiceClient.java 22 Mar 2007 21:11:24 -0000 1.3 *************** *** 48,54 **** --- 48,56 ---- package com.bigdata.service; + import java.io.IOException; import java.util.Properties; import java.util.concurrent.ExecutionException; + import com.bigdata.journal.ValidationError; import com.bigdata.objndx.IBatchOp; import com.bigdata.service.DataService.RangeQueryResult; *************** *** 112,116 **** } ! public void batchOp(long tx, String name, IBatchOp op) throws InterruptedException, ExecutionException { delegate.batchOp(tx, name, op); } --- 114,118 ---- } ! public void batchOp(long tx, String name, IBatchOp op) throws InterruptedException, ExecutionException, IOException { delegate.batchOp(tx, name, op); } *************** *** 120,136 **** // } ! public RangeQueryResult rangeQuery(long tx, String name, byte[] fromKey, byte[] toKey, int flags) throws InterruptedException, ExecutionException { return delegate.rangeQuery(tx, name, fromKey, toKey, flags); } ! public void submit(long tx, IProcedure proc) throws InterruptedException, ExecutionException { delegate.submit(tx, proc); } ! public void abort(long tx) { delegate.abort(tx); } ! public long commit(long tx) { return delegate.commit(tx); } --- 122,138 ---- // } ! public RangeQueryResult rangeQuery(long tx, String name, byte[] fromKey, byte[] toKey, int flags) throws InterruptedException, ExecutionException, IOException { return delegate.rangeQuery(tx, name, fromKey, toKey, flags); } ! public void submit(long tx, IProcedure proc) throws InterruptedException, ExecutionException, IOException { delegate.submit(tx, proc); } ! public void abort(long tx) throws IOException { delegate.abort(tx); } ! public long commit(long tx) throws ValidationError, IOException { return delegate.commit(tx); } Index: package.html =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/service/package.html,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** package.html 22 Mar 2007 15:04:15 -0000 1.2 --- package.html 22 Mar 2007 21:11:23 -0000 1.3 *************** *** 140,143 **** --- 140,191 ---- </p> + <h2>unique identifiers</h2> + + <dl> + + <dt>Data Service</dt><dd><p>The serviceID identifies the data + service. If the service dies and then restarts on the same host with + the same data, then it is still the same service instance. If the + service dies and is recreated on another host with the same data, then + it is still the same instance. What is important is that (a) the + service has the same data (journals, index segments, and serviceID); + and (b) that the data for that service has not become <em>stale</em> + (or inconsistent).</p><p> The easiest way in which the data can become + stale is for the service to fail. When failover is operating, clients + will be redirected to one or more other services having consistent + data for the same index partitions. If clients then write on _any_ of + those index partitions and commit, then the old service now has stale + (aka inconsistent) data. A service with inconsistent data MUST NOT be + used. + </p><p>In general, the majority of state for a service will live in + its index segments. This can be hundreds or thousands of times more + data in the index segments than there is in any single journal. This + can make it worth while to make the service consistent again. + </p></dd> + + <dt>Journal</dt><dd>Each journal has a UUID that is generated when the + journal is created (it is stored in the root block). This serves to + uniquely identify the journal as a resource regardless of where it may + be located on the host or in the file system.</dd> + + <dt>Index Segment</dt><dd>Each index segment has a UUID that is + generated when the index segment is created (it is stored in the fixed + length index segment metadata record). This serves to uniquely + identify the index segment as a resource regardless of where it may be + located on the host or in the file system.</dd> + + <dt>Index</dt><dd>Named indices are assigned UUIDs when they are + created. This makes it possible to rename an index, since its UUID + remains the same.</dd> + + <dt>metadata service</dt><dd></dd> + + <dt>transaction manager service</dt><dd></dd> + + <dt>job scheduler service</dt><dd></dd> + + </dl> + + <h2>downloaded code</h2> Index: EmbeddedDataService.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/service/EmbeddedDataService.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** EmbeddedDataService.java 17 Mar 2007 23:14:58 -0000 1.2 --- EmbeddedDataService.java 22 Mar 2007 21:11:23 -0000 1.3 *************** *** 48,51 **** --- 48,52 ---- package com.bigdata.service; + import java.io.IOException; import java.util.Properties; import java.util.concurrent.ExecutionException; *************** *** 53,56 **** --- 54,58 ---- import java.util.concurrent.Executors; + import com.bigdata.journal.ValidationError; import com.bigdata.objndx.IBatchOp; import com.bigdata.service.DataService.RangeQueryResult; *************** *** 124,132 **** } ! public void abort(long tx) { delegate.abort(tx); } ! public long commit(long tx) { return delegate.commit(tx); } --- 126,134 ---- } ! public void abort(long tx) throws IOException { delegate.abort(tx); } ! public long commit(long tx) throws ValidationError, IOException { return delegate.commit(tx); } --- NEW FILE: AbstractServer.java --- /** The Notice below must appear in each file of the Source Code of any copy you distribute of the Licensed Product. Contributors to any Modifications may add their own copyright notices to identify their own contributions. License: The contents of this file are subject to the CognitiveWeb Open Source License Version 1.1 (the License). You may not copy or use this file, in either source code or executable form, except in compliance with the License. You may obtain a copy of the License from http://www.CognitiveWeb.org/legal/license/ Software distributed under the License is distributed on an AS IS basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. Copyrights: Portions created by or assigned to CognitiveWeb are Copyright (c) 2003-2003 CognitiveWeb. All Rights Reserved. Contact information for CognitiveWeb is available at http://www.CognitiveWeb.org Portions Copyright (c) 2002-2003 Bryan Thompson. Acknowledgements: Special thanks to the developers of the Jabber Open Source License 1.0 (JOSL), from which this License was derived. This License contains terms that differ from JOSL. Special thanks to the CognitiveWeb Open Source Contributors for their suggestions and support of the Cognitive Web. Modifications: */ /* * Created on Mar 18, 2007 */ package com.bigdata.service; import java.io.BufferedInputStream; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.rmi.Remote; import java.rmi.server.ExportException; import java.util.Properties; import net.jini.admin.JoinAdmin; import net.jini.config.Configuration; import net.jini.config.ConfigurationException; import net.jini.config.ConfigurationProvider; import net.jini.core.discovery.LookupLocator; import net.jini.core.entry.Entry; import net.jini.core.lookup.ServiceID; import net.jini.discovery.DiscoveryManagement; import net.jini.discovery.LookupDiscovery; import net.jini.discovery.LookupDiscoveryManager; import net.jini.export.Exporter; import net.jini.lease.LeaseListener; import net.jini.lease.LeaseRenewalEvent; import net.jini.lease.LeaseRenewalManager; import net.jini.lookup.JoinManager; import net.jini.lookup.ServiceIDListener; import org.apache.log4j.Logger; import sun.misc.Signal; import sun.misc.SignalHandler; /** * Abstract base class for configurable services discoverable using JINI. * Services are started using a <code>main</code> routine: * <pre> public static void main(String[] args) { new MyServer(args).run(); } * </pre> * * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> * @version $Id$ */ abstract public class AbstractServer implements LeaseListener, ServiceIDListener { public static final transient Logger log = Logger .getLogger(AbstractServer.class); private ServiceID serviceID; private DiscoveryManagement discoveryManager; private JoinManager joinManager; private Configuration config; /** * The file where the {@link ServiceID} will be written/read. */ private File serviceIdFile; /** * Responsible for exporting a proxy for the service. */ private Exporter exporter; /** * The service implementation object. */ private Remote impl; /** * The exported proxy for the service implementation object. */ private Remote proxy; /** * Server startup reads {@link Configuration} data from the file(s) named by * <i>args</i>, starts the service, and advertises the service for * discovery. Aside from the server class to start, the behavior is more or * less entirely parameterized by the {@link Configuration}. * * @param args * The command line arguments. */ protected AbstractServer(String[] args) { final String SERVICE_LABEL = "ServiceDescription"; final String ADVERT_LABEL = "AdvertDescription"; Entry[] entries = null; LookupLocator[] unicastLocators = null; String[] groups = null; try { config = ConfigurationProvider.getInstance(args); /* * Extract how the service will perform service discovery. */ groups = (String[]) config.getEntry(ADVERT_LABEL, "groups", String[].class, LookupDiscovery.ALL_GROUPS/* default */); unicastLocators = (LookupLocator[]) config.getEntry( ADVERT_LABEL, "unicastLocators", LookupLocator[].class, null/* default */); /* * Extract how the service will advertise itself from the * Configuration. */ entries = (Entry[]) config.getEntry(ADVERT_LABEL, "entries", Entry[].class, null/* default */); serviceIdFile = (File) config.getEntry(ADVERT_LABEL, "serviceIdFile", File.class); // default if(serviceIdFile.exists()) { try { serviceID = readServiceId(serviceIdFile); } catch(IOException ex) { log.fatal("Could not read serviceID from existing file: " + serviceIdFile); System.exit(1); } } else { log.info("New service instance - ServiceID will be assigned"); } /* * Extract how the service will provision itself from the * Configuration. */ // use the configuration to construct an exporter exporter = (Exporter) config.getEntry(// SERVICE_LABEL, // component "exporter", // name Exporter.class // type (of the return object) ); /* * Access the properties file used to configure the service. */ File propertyFile = (File) config.getEntry(SERVICE_LABEL, "propertyFile", File.class); Properties properties = new Properties(); try { InputStream is = new BufferedInputStream(new FileInputStream( propertyFile)); properties.load(is); is.close(); } catch (IOException ex) { log.fatal("Configuration error: "+ex, ex); System.exit(1); } // create the service object. impl = newService(properties); // export a proxy object for this service instance. proxy = exporter.export(impl); log.info("Proxy is " + proxy + "(" + proxy.getClass() + ")"); } catch(ConfigurationException ex) { log.fatal("Configuration error: "+ex, ex); System.exit(1); } catch (ExportException ex) { log.fatal("Export error: "+ex, ex); System.exit(1); } try { /* * Note: This class will perform multicast discovery if ALL_GROUPS * is specified and otherwise requires you to specify one or more * unicast locators (URIs of hosts running discovery services). As * an alternative, you can use LookupDiscovery, which always does * multicast discovery. */ discoveryManager = new LookupDiscoveryManager( groups, unicastLocators, null // DiscoveryListener ); // DiscoveryManagement discoveryManager = new LookupDiscovery( // groups); if (serviceID != null) { /* * We read the serviceID from local storage. */ joinManager = new JoinManager(proxy, // service proxy entries, // attr sets serviceID, // ServiceIDListener discoveryManager, // DiscoveryManager new LeaseRenewalManager()); } else { /* * We are requesting a serviceID from the registrar. */ joinManager = new JoinManager(proxy, // service proxy entries, // attr sets this, // ServiceIDListener discoveryManager, // DiscoveryManager new LeaseRenewalManager()); } } catch (IOException ex) { log.fatal("Lookup service discovery error: "+ex, ex); try { /* unexport the proxy */ unexport(true); joinManager.terminate(); discoveryManager.terminate(); } catch (Throwable t) { /* ignore */ } System.exit(1); } } /** * Unexports the proxy. * * @param force * When true, the object is unexported even if there are pending * or in progress service requests. * * @return true iff the object is (or was) unexported. * * @see Exporter#unexport(boolean) */ public boolean unexport(boolean force) { if(exporter.unexport(true)) { proxy = null; return true; } return false; } /** * Read and return the {@link ServiceID} from an existing local file. * * @param file * The file whose contents are the serialized {@link ServiceID}. * * @return The {@link ServiceID} read from that file. * * @exception IOException * if the {@link ServiceID} could not be read from the file. */ public ServiceID readServiceId(File file) throws IOException { FileInputStream is = new FileInputStream(file); ServiceID serviceID = new ServiceID(new DataInputStream(is)); is.close(); log.info("Read ServiceID=" + serviceID+" from "+file); return serviceID; } /** * This method is responsible for saving the {@link ServiceID} on stable * storage when it is invoked. It will be invoked iff the {@link ServiceID} * was not defined and one was therefore assigned. * * @param serviceID * The assigned {@link ServiceID}. */ public void serviceIDNotify(ServiceID serviceID) { log.info("serviceID=" + serviceID); if (serviceIdFile != null) { try { DataOutputStream dout = new DataOutputStream( new FileOutputStream(serviceIdFile)); serviceID.writeBytes(dout); dout.flush(); dout.close(); log.info("ServiceID saved: " + serviceIdFile); } catch (Exception ex) { log.error("Could not save ServiceID", ex); } } } /** * Note: This is only invoked if the automatic lease renewal by the lease * manager is denied by the service registrar. * * @todo how should we handle being denied a lease? Wait a bit and try * re-registration? There can be multiple discovery services and this * is only one lease rejection, so perhaps the service is still under * lease on another discovery service? */ public void notify(LeaseRenewalEvent event) { log.error("Lease could not be renewed: " + event); } /** * Run the server (this should be invoked from <code>main</code>. * * FIXME work through the install a signal handler that will shutdown the * service politely when it is invoked. Do we need -Xrs on the command * line for this to work? Which signals should be trapped? Does this * vary by OS? * * SIGINT Interactive attention (CTRL-C). JVM will exit normally. Yes <br> * SIGTERM Termination request. JVM will exit normally. Yes <br> * SIGHUP Hang up. JVM will exit normally. Yes * * @see http://www-128.ibm.com/developerworks/java/library/i-signalhandling/ */ protected void run() { log.info("Started server."); /* * Install signal handlers. */ ServerShutdownSignalHandler.install("SIGINT",this); // ServerShutdownSignalHandler.install("SIGTERM",this); /* * Wait until the server is terminated. */ Object keepAlive = new Object(); synchronized (keepAlive) { try { keepAlive.wait(); } catch (InterruptedException ex) { log.info(""+ex); } } } /** * Shutdown the server taking time only to unregister it from jini. * * @todo make this extensible? provide for normal shutdown vs this? support * the jini Admin interface. */ private void shutdownNow() { /* * Terminate manager threads. */ try { log.info("Terminating manager threads."); joinManager.terminate(); discoveryManager.terminate(); } catch (Exception ex) { log.error("Could not terminate: "+ex, ex); } /* * Unexport the proxy, making the service no longer available. If you do * not do this then the client can still make requests even after you * have terminated the join manager and the service is no longer visible * in the service browser. */ log.info("Unexporting the service proxy."); unexport(true); } /** * Signal handler shuts down the server politely. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> * @version $Id$ */ static class ServerShutdownSignalHandler implements SignalHandler { private final AbstractServer server; private SignalHandler oldHandler; protected ServerShutdownSignalHandler(AbstractServer server) { if(server == null) throw new IllegalArgumentException(); this.server = server; } /** * Install the signal handler. */ public static SignalHandler install(String signalName, AbstractServer server) { Signal signal = new Signal(signalName); ServerShutdownSignalHandler newHandler = new ServerShutdownSignalHandler( server); newHandler.oldHandler = Signal.handle(signal, newHandler); log.info("Installed handler: " + signal + ", oldHandler=" + newHandler.oldHandler); return newHandler; } public void handle(Signal sig) { log.warn("Signal: "+sig); /* * Handle signal. */ server.shutdownNow(); try { // Chain back to previous handler, if one exists if ( oldHandler != SIG_DFL && oldHandler != SIG_IGN ) { oldHandler.handle(sig); } } catch (Exception ex) { log.fatal("Signal handler failed, reason "+ex); System.exit(1); } } } /** * This method is responsible for creating the remote service implementation * object. This object MUST declare one or more interfaces that extent the * {@link Remote} interface. The server will use JERI to create a proxy for * the remote object and configure and manage the protocol for * communications between the client (service proxy) and the remote object * (the service implementation). * <p> * Note: You have to implement {@link JoinAdmin} in order to show up as an * administerable service (blue folder) in the jini Service Browser. * * @param properties * The contents of the {@link Properties} file whose name was * given by the <code>propertyFile</code> value in the * {@link Configuration} identified to <code>main</code> by its * command line arguments. */ abstract protected Remote newService(Properties properties); // /** // * The remote service implementation object. This implements the // * {@link Remote} interface and uses JERI to create a proxy for the remote // * object and configure and manage the protocol for communications between // * the client (service proxy) and the remote object (the service // * implementation). // * <p> // * Note: You have to implement {@link JoinAdmin} in order to show up as an // * administerable service (blue folder) in the jini Service Browser. // * // * @version $Id$ // * @author <a href="mailto:tho...@us...">Bryan Thompson // * </a> // */ // public static class TestServiceImpl implements ITestService // { // // /** // * Service constructor. // * // * @param properties // */ // public TestServiceImpl(Properties properties) { // // log.info("Created: " + this ); // // new Journal(properties); // // } // // public void invoke() { // // log.info("invoked: "+this); // // } // // } } --- AbstractService.java DELETED --- |
From: Bryan T. <tho...@us...> - 2007-03-22 21:11:32
|
Update of /cvsroot/cweb/bigdata In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv3112 Modified Files: .cvsignore build.xml Log Message: Working on service startup and signal handling. Index: .cvsignore =================================================================== RCS file: /cvsroot/cweb/bigdata/.cvsignore,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** .cvsignore 17 Mar 2007 23:14:59 -0000 1.12 --- .cvsignore 22 Mar 2007 21:11:25 -0000 1.13 *************** *** 16,17 **** --- 16,18 ---- ant-deploy log + TestService.id Index: build.xml =================================================================== RCS file: /cvsroot/cweb/bigdata/build.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** build.xml 22 Mar 2007 15:04:16 -0000 1.3 --- build.xml 22 Mar 2007 21:11:25 -0000 1.4 *************** *** 26,29 **** --- 26,30 ---- <javac destdir="${build.dir}" classpathref="build.classpath" debug="on"> <src path="${bigdata.dir}/src/java" /> + <!-- @todo do not bundle the tests in the jar. --> <src path="${bigdata.dir}/src/test" /> </javac> *************** *** 44,48 **** <!-- @todo could be main routine for services startup, or perhaps a standalone instance startup. --> ! <attribute name="Main-Class" value="org/CognitiveWeb/bigdata/TestServiceDiscovery" /> </manifest> </jar> --- 45,49 ---- <!-- @todo could be main routine for services startup, or perhaps a standalone instance startup. --> ! <attribute name="Main-Class" value="com/bigdata/service/TestServiceDiscovery" /> </manifest> </jar> |
Update of /cvsroot/cweb/bigdata/src/test/com/bigdata/service In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv3112/src/test/com/bigdata/service Added Files: TestServiceDiscovery.java TestService.properties ITestService.java TestServer.java TestServer.config TestAll.java Log Message: Working on service startup and signal handling. --- NEW FILE: TestService.properties --- file=TestService.jnl --- NEW FILE: TestServiceDiscovery.java --- /** The Notice below must appear in each file of the Source Code of any copy you distribute of the Licensed Product. Contributors to any Modifications may add their own copyright notices to identify their own contributions. License: The contents of this file are subject to the CognitiveWeb Open Source License Version 1.1 (the License). You may not copy or use this file, in either source code or executable form, except in compliance with the License. You may obtain a copy of the License from http://www.CognitiveWeb.org/legal/license/ Software distributed under the License is distributed on an AS IS basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. Copyrights: Portions created by or assigned to CognitiveWeb are Copyright (c) 2003-2003 CognitiveWeb. All Rights Reserved. Contact information for CognitiveWeb is available at http://www.CognitiveWeb.org Portions Copyright (c) 2002-2003 Bryan Thompson. Acknowledgements: Special thanks to the developers of the Jabber Open Source License 1.0 (JOSL), from which this License was derived. This License contains terms that differ from JOSL. Special thanks to the CognitiveWeb Open Source Contributors for their suggestions and support of the Cognitive Web. Modifications: */ /* * Created on Jun 16, 2006 */ package com.bigdata.service; import java.io.IOException; import java.net.InetAddress; import java.rmi.ConnectException; import junit.framework.TestCase; import net.jini.core.discovery.LookupLocator; import net.jini.core.lookup.ServiceRegistrar; import net.jini.core.lookup.ServiceTemplate; import org.apache.log4j.Logger; /** * <p> * Test the ability to register, discover, and invoke a jini service. * </p> * <p> * Note: jini MUST be running. You can get the jini starter kit and install it * to get jini running. * </p> * <p> * Note: The registered service will NOT show up correctly in the Service * Browser (you will see "Unknown service") unless you set the codebase when * executing this test class and the .class files are available for download * from the codebase URL. I jump start the tests myself by copying them onto an * HTTP server and using the following options in the command line to execute * the test: * </p> * * <pre> * -Djava.security.policy=policy.all * -Djava.rmi.server.codebase=http://proto.cognitiveweb.org/maven-repository/bigdata/jars/ * </pre> * * <p> * which presuposes that the required class files are on that server available * for download. The security policy is overlax, but you do need to grant some * privledges in order to partitipate in discovery, etc. * </p> * * @todo While service lookup is unicast, service registration is multicast. * Probably both should be unicast for the purposes of this test. * * @todo The basic configuration should require only jini-core.jar. Figure out * how to get remote class loading working so that the requirements on a * client remain that minimal. Right now I am also using jini-ext.jar, * reggie.jar and sun-util.jar to run this test. jini-ext.jar is the big * one at over 1M. (this can be facilitated using the dljar ant task and * specifing jini-core as the target platform.) * * @todo Figure out how to divide the service into a proxy and a remote object. * We need this in order to measure the cost of sending data across the * network. * * @todo Explore the jini {@link net.jini.core.transaction.Transaction} model. * Perhaps we can use this as is to support two phase commits across the * database segments? The transaction model does not impose any semantics, * e.g., there is no locking, but we can handle all of that. * * @version $Id$ * @author <a href="mailto:tho...@us...">Bryan Thompson * </a> */ public class TestServiceDiscovery extends TestCase { public static Logger log = Logger.getLogger(TestServiceDiscovery.class); /** * Tests spans several services and verifies that we can discovery each of * them. * * @throws IOException * @throws ClassNotFoundException */ public void test_serviceDiscovery() throws IOException, ClassNotFoundException { /* * Install suitable security manager. this is required before the client * can download code. The code will be downloaded from the HTTP server * identified by the codebase property specified for the VM running the * service. For the purposes of this test, we are using the _same_ VM to * run the client and the service, so you have to specify the codebase * property when running the test. */ System.setSecurityManager(new SecurityManager()); /* * Launch the server to which we will connect (this is being done by the * test harness rather than setting up activation for the service since * we want to explicitly control the service instances for the purpose * of testing). */ TestServer.launchServer(); /* * Lookup the discover service (unicast on localhost). */ // get the hostname. InetAddress addr = InetAddress.getLocalHost(); String hostname = addr.getHostName(); // Find the service registrar (unicast protocol). final int timeout = 4*1000; // seconds. System.err.println("hostname: "+hostname); LookupLocator lookupLocator = new LookupLocator("jini://"+hostname); ServiceRegistrar serviceRegistrar = lookupLocator.getRegistrar( timeout ); /* * Prepare a template for lookup search. * * Note: The client needs a local copy of the interface in order to be * able to invoke methods on the service without using reflection. The * implementation class will be downloaded from the codebase identified * by the server. */ ServiceTemplate template = new ServiceTemplate(// /* * use this to request the service by its serviceID. */ null, /* * Use this to filter services by an interface that they expose. */ new Class[] { ITestService.class }, /* * use this to filter for services by Entry attributes. */ null); /* * Lookup a service. This can fail if the service registrar has not * finished processing the service registration. If it does, you can * generally just retry the test and it will succeed. However this * points out that the client may need to wait and retry a few times if * you are starting everthing up at once (or just register for * notification events for the service if it is not found and enter a * wait state). */ ITestService service = null; for (int i = 0; i < 10 && service == null; i++) { service = (ITestService) serviceRegistrar .lookup(template /* , maxMatches */); if (service == null) { log.info("Service not found: sleeping..."); try { Thread.sleep(200); } catch (InterruptedException ex) { } } } assertNotNull("Could not find service.", service); service.invoke(); // Sleep for a bit so that I can inspect the service in the Service // Browser. try { Thread.sleep(10000); } catch (InterruptedException ex) { } /* * try service invocation again. if the service lease is canceled before * we do this then we should see an exception here. */ try { service.invoke(); fail("Expecting "+ConnectException.class); } catch(ConnectException ex) { log.info("Ignoring expected exception: "+ex); } } public static void main(String[] args) throws Exception { TestServiceDiscovery test = new TestServiceDiscovery(); test.setUp(); try { test.test_serviceDiscovery(); } finally { test.tearDown(); } } } --- NEW FILE: TestServer.java --- /** The Notice below must appear in each file of the Source Code of any copy you distribute of the Licensed Product. Contributors to any Modifications may add their own copyright notices to identify their own contributions. License: The contents of this file are subject to the CognitiveWeb Open Source License Version 1.1 (the License). You may not copy or use this file, in either source code or executable form, except in compliance with the License. You may obtain a copy of the License from http://www.CognitiveWeb.org/legal/license/ Software distributed under the License is distributed on an AS IS basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. Copyrights: Portions created by or assigned to CognitiveWeb are Copyright (c) 2003-2003 CognitiveWeb. All Rights Reserved. Contact information for CognitiveWeb is available at http://www.CognitiveWeb.org Portions Copyright (c) 2002-2003 Bryan Thompson. Acknowledgements: Special thanks to the developers of the Jabber Open Source License 1.0 (JOSL), from which this License was derived. This License contains terms that differ from JOSL. Special thanks to the CognitiveWeb Open Source Contributors for their suggestions and support of the Cognitive Web. Modifications: */ /* * Created on Jun 19, 2006 */ package com.bigdata.service; import java.io.BufferedInputStream; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.rmi.Remote; import java.rmi.server.ExportException; import java.util.Properties; import net.jini.admin.JoinAdmin; import net.jini.config.Configuration; import net.jini.config.ConfigurationException; import net.jini.config.ConfigurationProvider; import net.jini.core.discovery.LookupLocator; import net.jini.core.entry.Entry; import net.jini.core.lookup.ServiceID; import net.jini.discovery.DiscoveryEvent; import net.jini.discovery.DiscoveryManagement; import net.jini.discovery.LookupDiscovery; import net.jini.discovery.LookupDiscoveryManager; import net.jini.export.Exporter; import net.jini.lease.LeaseListener; import net.jini.lease.LeaseRenewalEvent; import net.jini.lease.LeaseRenewalManager; import net.jini.lookup.JoinManager; import net.jini.lookup.ServiceIDListener; import org.apache.log4j.Logger; import com.bigdata.journal.Journal; import com.sun.jini.start.ServiceStarter; /** * Launches a server used by the test. The server is launched in a separate * thread that will die after a timeout, taking the server with it. The server * exposes some methods for testing, notably a method to test remote method * invocation and one to shutdown the server. * * @version $Id$ * @author <a href="mailto:tho...@us...">Bryan Thompson * </a> * * @todo work through use the {@link ServiceStarter} (in start.jar). I am having * trouble getting past some classpath errors using * * <pre> * java -Djava.security.policy=policy.all -classpath ant-deploy\reggie.jar;ant-deploy\jini-core.jar;ant-deploy\jini-ext.jar;ant-deploy\sun-util.jar;ant-deploy\bigdata.jar -jar ant-deploy\start.jar src\test\org\CognitiveWeb\bigdata\jini\TestServer.config * </pre> * * @todo support NIO protocol for data intensive APIs (data service, file * transfer). Research how heavy mashalling is and what options exist to * make it faster and lighter. */ public class TestServer implements LeaseListener, ServiceIDListener { public static final transient Logger log = Logger .getLogger(TestServer.class); private ServiceID serviceID; private DiscoveryManagement discoveryManager; private JoinManager joinManager; private Configuration config; private TestServiceImpl impl; private Exporter exporter; private ITestService proxy; private File serviceIdFile = null; /** * Server startup performs asynchronous multicast lookup discovery. The * {@link #discovered(DiscoveryEvent)} method is invoked asynchronously to * register a proxy for a {@link TestServiceImpl} instance. The protocol for * remote communications between the proxy and the {@link TestServiceImpl} * is specified by a {@link Configuration}. */ public TestServer(String[] args) { final String SERVICE_LABEL = "ServiceDescription"; final String ADVERT_LABEL = "AdvertDescription"; Entry[] entries = null; LookupLocator[] unicastLocators = null; String[] groups = null; try { config = ConfigurationProvider.getInstance(args); /* * Extract how the service will perform service discovery. */ groups = (String[]) config.getEntry(ADVERT_LABEL, "groups", String[].class, LookupDiscovery.ALL_GROUPS/* default */); unicastLocators = (LookupLocator[]) config.getEntry( ADVERT_LABEL, "unicastLocators", LookupLocator[].class, null/* default */); /* * Extract how the service will advertise itself from the * Configuration. */ entries = (Entry[]) config.getEntry(ADVERT_LABEL, "entries", Entry[].class, null/* default */); serviceIdFile = (File) config.getEntry(ADVERT_LABEL, "serviceIdFile", File.class); // default if(serviceIdFile.exists()) { try { serviceID = readServiceId(serviceIdFile); } catch(IOException ex) { log.fatal("Could not read serviceID from existing file: " + serviceIdFile); System.exit(1); } } else { log.info("New service instance - ServiceID will be assigned"); } /* * Extract how the service will provision itself from the * Configuration. */ // use the configuration to construct an exporter exporter = (Exporter) config.getEntry(// SERVICE_LABEL, // component "exporter", // name Exporter.class // type (of the return object) ); /* * Access the properties file used to configure the service. */ File propertyFile = (File) config.getEntry(SERVICE_LABEL, "propertyFile", File.class); Properties properties = new Properties(); try { InputStream is = new BufferedInputStream(new FileInputStream( propertyFile)); properties.load(is); is.close(); } catch (IOException ex) { log.fatal("Configuration error: "+ex, ex); System.exit(1); } // create the service object. impl = new TestServiceImpl(properties); // export a proxy object for this service instance. proxy = (ITestService) exporter.export(impl); log.info("Proxy is " + proxy + "(" + proxy.getClass() + ")"); } catch(ConfigurationException ex) { log.fatal("Configuration error: "+ex, ex); System.exit(1); } catch (ExportException ex) { log.fatal("Export error: "+ex, ex); System.exit(1); } try { /* * Note: This class will perform multicast discovery if ALL_GROUPS * is specified and otherwise requires you to specify one or more * unicast locators (URIs of hosts running discovery services). As * an alternative, you can use LookupDiscovery, which always does * multicast discovery. */ discoveryManager = new LookupDiscoveryManager( groups, unicastLocators, null // DiscoveryListener ); // DiscoveryManagement discoveryManager = new LookupDiscovery( // groups); if (serviceID != null) { /* * We read the serviceID from local storage. */ joinManager = new JoinManager(proxy, // service proxy entries, // attr sets serviceID, // ServiceIDListener discoveryManager, // DiscoveryManager new LeaseRenewalManager()); } else { /* * We are requesting a serviceID from the registrar. */ joinManager = new JoinManager(proxy, // service proxy entries, // attr sets this, // ServiceIDListener discoveryManager, // DiscoveryManager new LeaseRenewalManager()); } } catch (IOException ex) { log.fatal("Lookup service discovery error: "+ex, ex); try { /* unexport the proxy */ unexport(true); joinManager.terminate(); discoveryManager.terminate(); } catch (Throwable t) { /* ignore */ } System.exit(1); } } // /* // * @todo look into this as an alternative means to shutdown a service. // */ // void shutdown() { // try { // Object admin = ((Administrable) proxy).getAdmin(); // DestroyAdmin destroyAdmin = (DestroyAdmin) admin; // destroyAdmin.destroy(); // } catch (RemoteException e) { // handle // // exception // // // } // } /** * Unexports the proxy. * * @param force * When true, the object is unexported even if there are pending * or in progress service requests. * * @return true iff the object is (or was) unexported. * * @see Exporter#unexport(boolean) */ public boolean unexport(boolean force) { if(exporter.unexport(true)) { proxy = null; return true; } return false; } /** * Read and return the {@link ServiceID} from an existing local file. * * @param file * The file whose contents are the serialized {@link ServiceID}. * * @return The {@link ServiceID} read from that file. * * @exception IOException * if the {@link ServiceID} could not be read from the file. */ public ServiceID readServiceId(File file) throws IOException { FileInputStream is = new FileInputStream(file); ServiceID serviceID = new ServiceID(new DataInputStream(is)); is.close(); log.info("Read ServiceID=" + serviceID+" from "+file); return serviceID; } /** * This method is responsible for saving the {@link ServiceID} on stable * storage when it is invoked. It will be invoked iff the {@link ServiceID} * was not defined and one was therefore assigned. * * @param serviceID * The assigned {@link ServiceID}. */ public void serviceIDNotify(ServiceID serviceID) { log.info("serviceID=" + serviceID); if (serviceIdFile != null) { try { DataOutputStream dout = new DataOutputStream( new FileOutputStream(serviceIdFile)); serviceID.writeBytes(dout); dout.flush(); dout.close(); log.info("ServiceID saved: " + serviceIdFile); } catch (Exception ex) { log.error("Could not save ServiceID", ex); } } } /** * Note: This is only invoked if the automatic lease renewal by the lease * manager is denied by the service registrar. * * @todo how should we handle being denied a lease? Wait a bit and try * re-registration? There can be multiple discovery services and this * is only one lease rejection, so perhaps the service is still under * lease on another discovery service? */ public void notify(LeaseRenewalEvent event) { log.error("Lease could not be renewed: " + event); } /** * Launch the server in a separate thread. * <p> * Note: The location of the test service configuration is hardwired to a * test resource. */ public static void launchServer() { new Thread("launchServer") { public void run() { TestServer .main(new String[] { "src/test/com/bigdata/service/TestServer.config" }); } }.start(); log.info("Starting service."); } /** * Run the server. It will die after a timeout. * * @param args * Ignored. */ public static void main(String[] args) { final long lifespan = 5 * 1000; // life span in seconds. log.info("Will start test server."); TestServer testServer = new TestServer(args); log.info("Started test server."); try { Thread.sleep(lifespan); } catch( InterruptedException ex ) { log.warn(ex); } /* * Terminate manager threads. */ try { log.info("Terminating manager threads."); testServer.joinManager.terminate(); testServer.discoveryManager.terminate(); } catch (Exception ex) { log.error("Could not terminate: "+ex, ex); } /* * Unexport the proxy, making the service no longer available. If you do * not do this then the client can still make requests even after you * have terminated the join manager and the service is no longer visible * in the service browser. */ log.info("Unexporting the service proxy."); testServer.unexport(true); // /* // * Note: The reference to the service instance here forces a hard // * reference to remain for the test server. If you comment out this log // * statement, then you need to do something else to hold onto the hard // * reference. // */ // log.info("Server will die: "+testServer); } // /** // * {@link Status} is abstract so a service needs to provide their own // * concrete implementation. // * // * @version $Id$ // * @author <a href="mailto:tho...@us...">Bryan Thompson</a> // * @download // */ // public static class MyStatus extends Status { // // /** // * // */ // private static final long serialVersionUID = 3431522046169284463L; // // /** // * Deserialization constructor (required). // */ // public MyStatus(){} // // public MyStatus(StatusType statusType) { // // /* // * Note: This just sets the read/write public [severity] field on // * the super class. // */ // super(statusType); // // } // // } // // /** // * {@link ServiceType} is abstract so a service basically needs to provide // * their own concrete implementation. This class does not support icons // * (always returns null for {@link ServiceType#getIcon(int)}. See // * {@link java.beans.BeanInfo} for how to interpret and support the // * getIcon() method. // * // * @version $Id$ // * @author <a href="mailto:tho...@us...">Bryan Thompson // * </a> // * @download // */ // public static class MyServiceType extends ServiceType // { // // /** // * // */ // private static final long serialVersionUID = -2088608425852657477L; // // public String displayName; // public String shortDescription; // // /** // * Deserialization constructor (required). // */ // public MyServiceType() {} // // public MyServiceType(String displayName, String shortDescription) { // this.displayName = displayName; // this.shortDescription = shortDescription; // } // // public String getDisplayName() { // return displayName; // } // // public String getShortDescription() { // return shortDescription; // } // // } /** * The remote service implementation object. This implements the * {@link Remote} interface and uses JERI to create a proxy for the remote * object and configure and manage the protocol for communications between * the client (service proxy) and the remote object (the service * implementation). * <p> * Note: You have to implement {@link JoinAdmin} in order to show up as an * administerable service (blue folder) in the jini Service Browser. * * @version $Id$ * @author <a href="mailto:tho...@us...">Bryan Thompson * </a> */ public static class TestServiceImpl implements ITestService { /** * Service constructor. * * @param properties */ public TestServiceImpl(Properties properties) { log.info("Created: " + this ); new Journal(properties); } public void invoke() { log.info("invoked: "+this); } } } --- NEW FILE: TestServer.config --- import java.io.*; import net.jini.jeri.BasicILFactory; import net.jini.jeri.BasicJeriExporter; import net.jini.jeri.tcp.TcpServerEndpoint; import net.jini.core.discovery.LookupLocator; import net.jini.discovery.LookupDiscovery; import net.jini.core.entry.Entry; import net.jini.lookup.entry.Name; import net.jini.lookup.entry.Comment; import net.jini.lookup.entry.Address; import net.jini.lookup.entry.Location; import net.jini.lookup.entry.ServiceInfo; import java.io.File; import com.sun.jini.config.ConfigUtil; import com.sun.jini.start.ServiceDescriptor; import com.sun.jini.start.NonActivatableServiceDescriptor; /* * Declares how the service will provision itself. */ ServiceDescription { /* * This object is used to export the service proxy. The choice here effects * the protocol that will be used for communications between the clients and * the service. * * @todo Explore JERI nio option and customization support for serialization. */ exporter = new BasicJeriExporter(TcpServerEndpoint.getInstance(0), new BasicILFactory()); /* * Code base for downloadable code exposed by this service. */ private static codebase = "http://proto.cognitiveweb.org/maven-repository/bigdata/jars/"; /* @todo restrict the policy to what is actually required by the service. * Among other things, we only need access to a temporary directory and * to the directory in which the journals and index segments will be * stored, not general read/write on the disk. */ private static policy = "policy.all"; /* * The directory containing the various JARs. */ private static libdir = "ant-deploy"+File.separator; /* * Declare dependencies for the server here. */ private static classpath = // jini libdir+"reggie.jar"+File.pathSeparator+ libdir+"jini-core.jar"+File.pathSeparator+ libdir+"jini-ext.jar"+File.pathSeparator+ libdir+"sun-util.jar"+File.pathSeparator+ // utility JARs. libdir+"log4j-1.2.8.jar"+File.pathSeparator+ libdir+"ctc_utils-5-4-2005.jar"+File.pathSeparator+ libdir+"lgpl-utils-1.0-b1-dev.jar"+File.pathSeparator+ libdir+"cweb-extser-0.1-b2-dev.jar"+File.pathSeparator+ // ICU (unicode support). libdir+"icu4j-3_6.jar"+File.pathSeparator+ // test suites only! libdir+"junit-3.8.1.jar"+File.pathSeparator+ libdir+"cweb-junit-ext-1.1-b2-dev.jar"+File.pathSeparator+ // main bigdata JAR. libdir+"bigdata.jar" ; /* * The name of the property file containing the configuration information for * the service itself (where it will locate its files, etc). */ propertyFile = new File("src/test/com/bigdata/service/TestService.properties"); static serviceDescriptors = new ServiceDescriptor[] { new NonActivatableServiceDescriptor( codebase, policy, classpath, "config.FileClassifierServerConfig", new String[] { propertyFile}) }; } /* * Declares how the service will advertise itself. */ AdvertDescription { /* * Entry attributes used to describe the service. */ entries = new Entry[] { new Comment("Test service"), // human facing comment. new Name("Test service"), // human facing name. new Location("floor","room","building"), new Address("street", "organization", "organizationalUnit", "locality", "stateOrProvince", "postalCode", "country"), new ServiceInfo("bigdata", // product or package name "SYSTAP,LLC", // manufacturer "SYSTAP,LLC", // vendor "0.1-beta", // version "bigdata", // model "serial#" // serialNumber ) }; /* * Note: multicast discovery is always used if LookupDiscovery.ALL_GROUPS is * specified. */ // groups = LookupDiscovery.ALL_GROUPS; groups = new String[]{"bigdata"}; /* * One or more unicast URIs of the form jini://host/ or jini://host:port/. * This MAY be an empty array if you want to use multicast discovery _and_ * you have specified LookupDiscovery.ALL_GROUPS above. */ unicastLocators = new LookupLocator[] { // empty new LookupLocator("jini://localhost/") // new LookupLocator("jini://SYSTAP-BBT.systap.com/") }; /* * The file on which the serviceID will be written. */ serviceIdFile = new File("TestService.id"); } --- NEW FILE: TestAll.java --- /** The Notice below must appear in each file of the Source Code of any copy you distribute of the Licensed Product. Contributors to any Modifications may add their own copyright notices to identify their own contributions. License: The contents of this file are subject to the CognitiveWeb Open Source License Version 1.1 (the License). You may not copy or use this file, in either source code or executable form, except in compliance with the License. You may obtain a copy of the License from http://www.CognitiveWeb.org/legal/license/ Software distributed under the License is distributed on an AS IS basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. Copyrights: Portions created by or assigned to CognitiveWeb are Copyright (c) 2003-2003 CognitiveWeb. All Rights Reserved. Contact information for CognitiveWeb is available at http://www.CognitiveWeb.org Portions Copyright (c) 2002-2003 Bryan Thompson. Acknowledgements: Special thanks to the developers of the Jabber Open Source License 1.0 (JOSL), from which this License was derived. This License contains terms that differ from JOSL. Special thanks to the CognitiveWeb Open Source Contributors for their suggestions and support of the Cognitive Web. Modifications: */ /* * Created on Jun 26, 2006 */ package com.bigdata.service; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; /** * Aggregates tests in dependency order. * * @version $Id$ * @author <a href="mailto:tho...@us...">Bryan Thompson</a> */ public class TestAll extends TestCase { public TestAll() {} public TestAll(String name) {super(name);} public static Test suite() { TestSuite suite = new TestSuite(TestAll.class.getName()); suite.addTestSuite( TestServiceDiscovery.class ); // suite.addTestSuite( TestServer.class ); // Does not implement TestCase. return suite; } } --- NEW FILE: ITestService.java --- /** The Notice below must appear in each file of the Source Code of any copy you distribute of the Licensed Product. Contributors to any Modifications may add their own copyright notices to identify their own contributions. License: The contents of this file are subject to the CognitiveWeb Open Source License Version 1.1 (the License). You may not copy or use this file, in either source code or executable form, except in compliance with the License. You may obtain a copy of the License from http://www.CognitiveWeb.org/legal/license/ Software distributed under the License is distributed on an AS IS basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. Copyrights: Portions created by or assigned to CognitiveWeb are Copyright (c) 2003-2003 CognitiveWeb. All Rights Reserved. Contact information for CognitiveWeb is available at http://www.CognitiveWeb.org Portions Copyright (c) 2002-2003 Bryan Thompson. Acknowledgements: Special thanks to the developers of the Jabber Open Source License 1.0 (JOSL), from which this License was derived. This License contains terms that differ from JOSL. Special thanks to the CognitiveWeb Open Source Contributors for their suggestions and support of the Cognitive Web. Modifications: */ /* * Created on Mar 18, 2007 */ package com.bigdata.service; import java.io.IOException; import java.rmi.Remote; import java.rmi.RemoteException; /** * The public interface for a test service. * <p> * Note: The interface extends {@link Remote} so that both the implementation of * this service and the proxy generated by jeri for the service will implement * this interface. This is necessary for service discovery or the resulting * proxy will NOT implement the interface and both service discovery (based on * the interface name) and use of the interface via the proxy will fail. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> * @version $Id$ * @download */ public interface ITestService extends Remote { /** * Method for testing remote invocation. * <p> * Note: The methods on a {@link Remote} interface MUST throw * {@link RemoteException} (or {@link IOException} if you want to reduce * your dependency on JINI for an interface that is also used outside of * JINI). */ public void invoke() throws RemoteException; } |
From: Bryan T. <tho...@us...> - 2007-03-22 21:11:29
|
Update of /cvsroot/cweb/bigdata/src/test/org/CognitiveWeb/bigdata/jini In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv3112/src/test/org/CognitiveWeb/bigdata/jini Removed Files: TestServer.config TestServiceDiscovery.java TestAll.java TestServer.java ITestService.java Log Message: Working on service startup and signal handling. --- TestServiceDiscovery.java DELETED --- --- TestServer.config DELETED --- --- TestAll.java DELETED --- --- TestServer.java DELETED --- --- ITestService.java DELETED --- |
From: Bryan T. <tho...@us...> - 2007-03-22 21:11:29
|
Update of /cvsroot/cweb/bigdata/src/test/com/bigdata/journal In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv3112/src/test/com/bigdata/journal Modified Files: AbstractMROWTestCase.java AbstractBufferStrategyTestCase.java TestRootBlockView.java AbstractBTreeWithJournalTestCase.java ComparisonTestDriver.java AbstractTestCase.java BenchmarkJournalWriteRate.java StressTestConcurrent.java Log Message: Working on service startup and signal handling. Index: AbstractBTreeWithJournalTestCase.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/test/com/bigdata/journal/AbstractBTreeWithJournalTestCase.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AbstractBTreeWithJournalTestCase.java 22 Feb 2007 16:59:34 -0000 1.2 --- AbstractBTreeWithJournalTestCase.java 22 Mar 2007 21:11:24 -0000 1.3 *************** *** 91,96 **** properties.setProperty(Options.DELETE_ON_EXIT,"true"); - properties.setProperty(Options.SEGMENT, "0"); - // // Note: also deletes the file before it is used. // properties.setProperty(Options.FILE, AbstractTestCase --- 91,94 ---- Index: AbstractMROWTestCase.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/test/com/bigdata/journal/AbstractMROWTestCase.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AbstractMROWTestCase.java 22 Feb 2007 16:59:34 -0000 1.2 --- AbstractMROWTestCase.java 22 Mar 2007 21:11:24 -0000 1.3 *************** *** 532,537 **** // properties.setProperty(Options.BUFFER_MODE, BufferMode.Disk.toString()); - properties.setProperty(Options.SEGMENT, "0"); - properties.setProperty(Options.CREATE_TEMP_FILE,"true"); --- 532,535 ---- Index: AbstractBufferStrategyTestCase.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/test/com/bigdata/journal/AbstractBufferStrategyTestCase.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AbstractBufferStrategyTestCase.java 22 Feb 2007 16:59:34 -0000 1.4 --- AbstractBufferStrategyTestCase.java 22 Mar 2007 21:11:24 -0000 1.5 *************** *** 97,102 **** properties.setProperty(Options.DELETE_ON_EXIT,"true"); - properties.setProperty(Options.SEGMENT, "0"); - // // Note: also deletes the file before it is used. // properties.setProperty(Options.FILE, AbstractTestCase --- 97,100 ---- Index: ComparisonTestDriver.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/test/com/bigdata/journal/ComparisonTestDriver.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ComparisonTestDriver.java 28 Feb 2007 13:59:09 -0000 1.3 --- ComparisonTestDriver.java 22 Mar 2007 21:11:24 -0000 1.4 *************** *** 248,252 **** properties.setProperty(Options.CREATE_TEMP_FILE,"true"); // properties.setProperty(Options.DELETE_ON_CLOSE,"true"); - properties.setProperty(Options.SEGMENT, "0"); // avoids journal overflow when running out to 60 seconds. --- 248,251 ---- Index: StressTestConcurrent.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/test/com/bigdata/journal/StressTestConcurrent.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** StressTestConcurrent.java 15 Mar 2007 16:11:09 -0000 1.9 --- StressTestConcurrent.java 22 Mar 2007 21:11:24 -0000 1.10 *************** *** 390,395 **** // properties.setProperty(Options.BUFFER_MODE, BufferMode.Disk.toString()); - properties.setProperty(Options.SEGMENT, "0"); - properties.setProperty(Options.CREATE_TEMP_FILE, "true"); --- 390,393 ---- Index: AbstractTestCase.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/test/com/bigdata/journal/AbstractTestCase.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** AbstractTestCase.java 22 Feb 2007 16:59:34 -0000 1.19 --- AbstractTestCase.java 22 Mar 2007 21:11:24 -0000 1.20 *************** *** 208,213 **** m_properties.setProperty(Options.DELETE_ON_EXIT,"true"); - m_properties.setProperty(Options.SEGMENT, "0"); - } --- 208,211 ---- Index: BenchmarkJournalWriteRate.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/test/com/bigdata/journal/BenchmarkJournalWriteRate.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** BenchmarkJournalWriteRate.java 22 Feb 2007 16:59:34 -0000 1.13 --- BenchmarkJournalWriteRate.java 22 Mar 2007 21:11:24 -0000 1.14 *************** *** 164,169 **** properties.setProperty(Options.BUFFER_MODE, getBufferMode().toString()); - properties.setProperty(Options.SEGMENT, "0"); - properties.setProperty(Options.CREATE_TEMP_FILE, "true"); --- 164,167 ---- Index: TestRootBlockView.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/test/com/bigdata/journal/TestRootBlockView.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** TestRootBlockView.java 28 Feb 2007 13:59:09 -0000 1.10 --- TestRootBlockView.java 22 Mar 2007 21:11:24 -0000 1.11 *************** *** 49,57 **** import java.util.Random; ! ! import com.bigdata.util.TimestampFactory; import junit.framework.TestCase2; /** * Test suite for {@link RootBlockView}. --- 49,58 ---- import java.util.Random; ! import java.util.UUID; import junit.framework.TestCase2; + import com.bigdata.util.TimestampFactory; + /** * Test suite for {@link RootBlockView}. *************** *** 87,91 **** final boolean rootBlock0 = r.nextBoolean(); ! final int segmentId = r.nextInt(); final boolean anyTransactions = r.nextInt(100)>90; final long firstTxId = anyTransactions?TimestampFactory.nextNanoTime():0L; --- 88,92 ---- final boolean rootBlock0 = r.nextBoolean(); ! // final int segmentId = r.nextInt(); final boolean anyTransactions = r.nextInt(100)>90; final long firstTxId = anyTransactions?TimestampFactory.nextNanoTime():0L; *************** *** 97,104 **** final long commitRecordAddr = r.nextInt(Integer.MAX_VALUE); // may be zero. final long commitRecordIndexAddr = r.nextInt(Integer.MAX_VALUE); // may be zero. ! RootBlockView rootBlock = new RootBlockView(rootBlock0, segmentId, nextOffset, firstTxId, lastTxId, commitTimestamp, ! commitCounter, commitRecordAddr, commitRecordIndexAddr); System.err.println("pass=" + i + " of " + limit + " : timestamp=" --- 98,107 ---- final long commitRecordAddr = r.nextInt(Integer.MAX_VALUE); // may be zero. final long commitRecordIndexAddr = r.nextInt(Integer.MAX_VALUE); // may be zero. + final UUID uuid = UUID.randomUUID(); ! RootBlockView rootBlock = new RootBlockView(rootBlock0, //segmentId, nextOffset, firstTxId, lastTxId, commitTimestamp, ! commitCounter, commitRecordAddr, commitRecordIndexAddr, ! uuid); System.err.println("pass=" + i + " of " + limit + " : timestamp=" *************** *** 108,112 **** rootBlock.valid(); assertEquals("rootBlock0", rootBlock0, rootBlock.isRootBlock0()); ! assertEquals("segmentId", segmentId, rootBlock.getSegmentId()); assertEquals("nextOffset", nextOffset, rootBlock.getNextOffset()); assertEquals("firstTxId", firstTxId, rootBlock.getFirstCommitTime()); --- 111,115 ---- rootBlock.valid(); assertEquals("rootBlock0", rootBlock0, rootBlock.isRootBlock0()); ! // assertEquals("segmentId", segmentId, rootBlock.getSegmentId()); assertEquals("nextOffset", nextOffset, rootBlock.getNextOffset()); assertEquals("firstTxId", firstTxId, rootBlock.getFirstCommitTime()); *************** *** 123,127 **** rootBlock.valid(); assertEquals("rootBlock0", rootBlock0, rootBlock.isRootBlock0()); ! assertEquals("segmentId", segmentId, rootBlock.getSegmentId()); assertEquals("nextOffset", nextOffset, rootBlock.getNextOffset()); assertEquals("firstTxId", firstTxId, rootBlock.getFirstCommitTime()); --- 126,130 ---- rootBlock.valid(); assertEquals("rootBlock0", rootBlock0, rootBlock.isRootBlock0()); ! // assertEquals("segmentId", segmentId, rootBlock.getSegmentId()); assertEquals("nextOffset", nextOffset, rootBlock.getNextOffset()); assertEquals("firstTxId", firstTxId, rootBlock.getFirstCommitTime()); *************** *** 145,149 **** final boolean rootBlock0 = true; // all values are legal. // ! final int segmentId = 0; // no constraint // final int nextOffsetOk = 100; --- 148,152 ---- final boolean rootBlock0 = true; // all values are legal. // ! // final int segmentId = 0; // no constraint // final int nextOffsetOk = 100; *************** *** 187,207 **** final long commitRecordIndexOk2 = 23L; final long commitRecordIndexBad = -1L; // legit. ! new RootBlockView(rootBlock0, segmentId, nextOffsetOk, firstTxIdOk, ! lastTxIdOk, commitTimeOk, commitCounterOk, rootsAddrOk, commitRecordIndexOk); // legit (firstTxIdOk2,lastTxIdOk2,commitTimeOK2). ! new RootBlockView(rootBlock0, segmentId, nextOffsetOk, firstTxIdOk2, ! lastTxIdOk2, commitTimeOk2, commitCounterOk, rootsAddrOk, commitRecordIndexOk); // legit (rootsAddr2, commitRecordIndex2) ! new RootBlockView(rootBlock0, segmentId, nextOffsetOk, firstTxIdOk, ! lastTxIdOk, commitTimeOk, commitCounterOk, rootsAddrOk2, commitRecordIndexOk2); // bad next offset try { ! new RootBlockView(rootBlock0, segmentId, nextOffsetBad, firstTxIdOk, lastTxIdOk, commitTimeOk, commitCounterOk, ! rootsAddrOk, commitRecordIndexOk); fail("Expecting: " + IllegalArgumentException.class); } catch (IllegalArgumentException ex) { --- 190,216 ---- final long commitRecordIndexOk2 = 23L; final long commitRecordIndexBad = -1L; + // + final UUID uuidOk = UUID.randomUUID(); + final UUID uuidBad = null; // legit. ! new RootBlockView(rootBlock0, nextOffsetOk, firstTxIdOk, ! lastTxIdOk, commitTimeOk, commitCounterOk, rootsAddrOk, commitRecordIndexOk, ! uuidOk); // legit (firstTxIdOk2,lastTxIdOk2,commitTimeOK2). ! new RootBlockView(rootBlock0, nextOffsetOk, firstTxIdOk2, ! lastTxIdOk2, commitTimeOk2, commitCounterOk, rootsAddrOk, commitRecordIndexOk, ! uuidOk); // legit (rootsAddr2, commitRecordIndex2) ! new RootBlockView(rootBlock0, nextOffsetOk, firstTxIdOk, ! lastTxIdOk, commitTimeOk, commitCounterOk, rootsAddrOk2, commitRecordIndexOk2, ! uuidOk); // bad next offset try { ! new RootBlockView(rootBlock0, nextOffsetBad, firstTxIdOk, lastTxIdOk, commitTimeOk, commitCounterOk, ! rootsAddrOk, commitRecordIndexOk,uuidOk); fail("Expecting: " + IllegalArgumentException.class); } catch (IllegalArgumentException ex) { *************** *** 211,217 **** // bad first,last transaction start timestamps and commit timestamp. try { ! new RootBlockView(rootBlock0, segmentId, nextOffsetOk, firstTxIdBad1, lastTxIdBad1, commitTimeBad1, ! commitCounterOk, rootsAddrOk, commitRecordIndexOk); fail("Expecting: " + IllegalArgumentException.class); } catch (IllegalArgumentException ex) { --- 220,226 ---- // bad first,last transaction start timestamps and commit timestamp. try { ! new RootBlockView(rootBlock0, nextOffsetOk, firstTxIdBad1, lastTxIdBad1, commitTimeBad1, ! commitCounterOk, rootsAddrOk, commitRecordIndexOk,uuidOk); fail("Expecting: " + IllegalArgumentException.class); } catch (IllegalArgumentException ex) { *************** *** 219,225 **** } try { ! new RootBlockView(rootBlock0, segmentId, nextOffsetOk, firstTxIdBad2, lastTxIdBad2, commitTimeBad2, ! commitCounterOk, rootsAddrOk, commitRecordIndexOk); fail("Expecting: " + IllegalArgumentException.class); } catch (IllegalArgumentException ex) { --- 228,234 ---- } try { ! new RootBlockView(rootBlock0, nextOffsetOk, firstTxIdBad2, lastTxIdBad2, commitTimeBad2, ! commitCounterOk, rootsAddrOk, commitRecordIndexOk,uuidOk); fail("Expecting: " + IllegalArgumentException.class); } catch (IllegalArgumentException ex) { *************** *** 227,233 **** } try { ! new RootBlockView(rootBlock0, segmentId, nextOffsetOk, firstTxIdBad3, lastTxIdBad3, commitTimeBad3, ! commitCounterOk, rootsAddrOk, commitRecordIndexOk); fail("Expecting: " + IllegalArgumentException.class); } catch (IllegalArgumentException ex) { --- 236,242 ---- } try { ! new RootBlockView(rootBlock0, nextOffsetOk, firstTxIdBad3, lastTxIdBad3, commitTimeBad3, ! commitCounterOk, rootsAddrOk, commitRecordIndexOk,uuidOk); fail("Expecting: " + IllegalArgumentException.class); } catch (IllegalArgumentException ex) { *************** *** 235,241 **** } try { ! new RootBlockView(rootBlock0, segmentId, nextOffsetOk, firstTxIdBad4, lastTxIdBad4, commitTimeBad4, ! commitCounterOk, rootsAddrOk, commitRecordIndexOk); fail("Expecting: " + IllegalArgumentException.class); } catch (IllegalArgumentException ex) { --- 244,250 ---- } try { ! new RootBlockView(rootBlock0, nextOffsetOk, firstTxIdBad4, lastTxIdBad4, commitTimeBad4, ! commitCounterOk, rootsAddrOk, commitRecordIndexOk,uuidOk); fail("Expecting: " + IllegalArgumentException.class); } catch (IllegalArgumentException ex) { *************** *** 245,251 **** // bad commit counter try { ! new RootBlockView(rootBlock0, segmentId, nextOffsetOk, firstTxIdOk, lastTxIdOk, commitTimeOk, commitCounterBad, rootsAddrOk ! , commitRecordIndexOk); fail("Expecting: " + IllegalArgumentException.class); } catch (IllegalArgumentException ex) { --- 254,260 ---- // bad commit counter try { ! new RootBlockView(rootBlock0, nextOffsetOk, firstTxIdOk, lastTxIdOk, commitTimeOk, commitCounterBad, rootsAddrOk ! , commitRecordIndexOk,uuidOk); fail("Expecting: " + IllegalArgumentException.class); } catch (IllegalArgumentException ex) { *************** *** 253,258 **** } try { ! new RootBlockView(rootBlock0, segmentId, nextOffsetOk, firstTxIdOk, ! lastTxIdOk, commitTimeOk, commitCounterBad2, rootsAddrOk, commitRecordIndexOk); fail("Expecting: " + IllegalArgumentException.class); } catch (IllegalArgumentException ex) { --- 262,267 ---- } try { ! new RootBlockView(rootBlock0, nextOffsetOk, firstTxIdOk, ! lastTxIdOk, commitTimeOk, commitCounterBad2, rootsAddrOk, commitRecordIndexOk,uuidOk); fail("Expecting: " + IllegalArgumentException.class); } catch (IllegalArgumentException ex) { *************** *** 262,268 **** // bad {commit record, commit record index} combinations. try { ! new RootBlockView(rootBlock0, segmentId, nextOffsetOk, firstTxIdOk, lastTxIdOk, commitTimeOk, commitCounterOk, rootsAddrBad, ! commitRecordIndexOk2); fail("Expecting: " + IllegalArgumentException.class); } catch (IllegalArgumentException ex) { --- 271,277 ---- // bad {commit record, commit record index} combinations. try { ! new RootBlockView(rootBlock0, nextOffsetOk, firstTxIdOk, lastTxIdOk, commitTimeOk, commitCounterOk, rootsAddrBad, ! commitRecordIndexOk2,uuidOk); fail("Expecting: " + IllegalArgumentException.class); } catch (IllegalArgumentException ex) { *************** *** 270,276 **** } try { ! new RootBlockView(rootBlock0, segmentId, nextOffsetOk, firstTxIdOk, lastTxIdOk, commitTimeOk, commitCounterOk, rootsAddrOk2, ! commitRecordIndexBad); fail("Expecting: " + IllegalArgumentException.class); } catch (IllegalArgumentException ex) { --- 279,285 ---- } try { ! new RootBlockView(rootBlock0, nextOffsetOk, firstTxIdOk, lastTxIdOk, commitTimeOk, commitCounterOk, rootsAddrOk2, ! commitRecordIndexBad,uuidOk); fail("Expecting: " + IllegalArgumentException.class); } catch (IllegalArgumentException ex) { *************** *** 282,288 **** * address is 0L while the commit record addr is defined. */ ! new RootBlockView(rootBlock0, segmentId, nextOffsetOk, firstTxIdOk, lastTxIdOk, commitTimeOk, commitCounterOk, rootsAddrOk2, ! commitRecordIndexOk); fail("Expecting: " + IllegalArgumentException.class); } catch (IllegalArgumentException ex) { --- 291,307 ---- * address is 0L while the commit record addr is defined. */ ! new RootBlockView(rootBlock0, nextOffsetOk, firstTxIdOk, lastTxIdOk, commitTimeOk, commitCounterOk, rootsAddrOk2, ! commitRecordIndexOk,uuidOk); ! fail("Expecting: " + IllegalArgumentException.class); ! } catch (IllegalArgumentException ex) { ! System.err.println("Ignoring expected exception: " + ex); ! } ! ! // bad UUID. ! try { ! new RootBlockView(rootBlock0, nextOffsetOk, firstTxIdOk, ! lastTxIdOk, commitTimeOk, commitCounterOk, rootsAddrBad, ! commitRecordIndexOk2,uuidBad); fail("Expecting: " + IllegalArgumentException.class); } catch (IllegalArgumentException ex) { |
From: Bryan T. <tho...@us...> - 2007-03-22 21:11:19
|
Update of /cvsroot/cweb/bigdata/src/test/com/bigdata/service In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv2967/src/test/com/bigdata/service Log Message: Directory /cvsroot/cweb/bigdata/src/test/com/bigdata/service added to the repository |
From: Bryan T. <tho...@us...> - 2007-03-22 15:04:59
|
Update of /cvsroot/cweb/bigdata/src/test/org/CognitiveWeb/bigdata/jini In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv20431/src/test/org/CognitiveWeb/bigdata/jini Modified Files: TestServiceDiscovery.java TestServer.java ITestService.java Added Files: TestServer.config Log Message: Working on services. Added some JARs for dependencies to simplify deployment. Index: TestServiceDiscovery.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/test/org/CognitiveWeb/bigdata/jini/TestServiceDiscovery.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TestServiceDiscovery.java 18 Mar 2007 22:29:43 -0000 1.3 --- TestServiceDiscovery.java 22 Mar 2007 15:04:12 -0000 1.4 *************** *** 49,52 **** --- 49,53 ---- import java.io.IOException; import java.net.InetAddress; + import java.rmi.ConnectException; import junit.framework.TestCase; *************** *** 210,213 **** --- 211,225 ---- } + /* + * try service invocation again. if the service lease is canceled before + * we do this then we should see an exception here. + */ + try { + service.invoke(); + fail("Expecting "+ConnectException.class); + } catch(ConnectException ex) { + log.info("Ignoring expected exception: "+ex); + } + } --- NEW FILE: TestServer.config --- import java.io.*; import net.jini.jeri.BasicILFactory; import net.jini.jeri.BasicJeriExporter; import net.jini.jeri.tcp.TcpServerEndpoint; import net.jini.core.discovery.LookupLocator; import net.jini.discovery.LookupDiscovery; import net.jini.core.entry.Entry; import net.jini.lookup.entry.Name; import net.jini.lookup.entry.Comment; import net.jini.lookup.entry.Address; import net.jini.lookup.entry.Location; import net.jini.lookup.entry.ServiceInfo; //import org.CognitiveWeb.bigdata.jini.TestServer$MyStatus; //import org.CognitiveWeb.bigdata.jini.TestServer$MyServiceType; import java.io.File; import com.sun.jini.config.ConfigUtil; import com.sun.jini.start.ServiceDescriptor; import com.sun.jini.start.NonActivatableServiceDescriptor; /* * Declares how the service will provision itself. */ ServiceDescription { /* * This object is used to export the service proxy. The choice here effects * the protocol that will be used for communications between the clients and * the service. * * @todo Explore JERI nio option and customization support for serialization. */ exporter = new BasicJeriExporter(TcpServerEndpoint.getInstance(0), new BasicILFactory()); /* * @todo test ability to resolve classes in JAR directly. what about an * array of codebases? */ private static codebase = "http://proto.cognitiveweb.org/maven-repository/bigdata/jars/bigdata.jar"; /* @todo restrict the policy to what is actually required by the service. * Among other things, we only need access to a temporary directory and * to the directory in which the journals and index segments will be * stored, not general read/write on the disk. */ private static policy = "policy.all"; /* * The directory containing the various JARs. */ private static libdir = "ant-deploy/"+File.separator; /* * Declare dependencies for the server here. */ private static classpath = // jini libdir+"reggie.jar"+File.pathSeparator+ libdir+"jini-core.jar"+File.pathSeparator+ libdir+"jini-ext.jar"+File.pathSeparator+ libdir+"sun-util.jar"+File.pathSeparator+ // utility JARs. libdir+"log4j-1.2.8.jar"+File.pathSeparator+ libdir+"ctc_utils-5-4-2005.jar"+File.pathSeparator+ libdir+"lgpl-utils-1.0-b1-dev.jar"+File.pathSeparator+ libdir+"cweb-extser-0.1-b2-dev.jar"+File.pathSeparator+ // ICU (unicode support). libdir+"icu4j-3_6.jar"+File.pathSeparator+ // test suites only! libdir+"junit-3.8.1.jar"+File.pathSeparator+ libdir+"cweb-junit-ext-1.1-b2-dev.jar"+File.pathSeparator+ // main bigdata JAR. libdir+"bigdata.jar" ; /* * Configuration file for the service itself. * * @todo The name of this file will be pass to the service implementation * constructor. It should probably be a file that can be read as a Properties * object. */ private static config = "resources/starter/file_classifier.config"; static serviceDescriptors = new ServiceDescriptor[] { new NonActivatableServiceDescriptor( codebase, policy, classpath, "config.FileClassifierServerConfig", new String[] { config }) }; } /* * Declares how the service will advertise itself. */ AdvertDescription { /* * Entry attributes used to describe the service. */ entries = new Entry[] { new Comment("Test service"), // human facing comment. new Name("Test service"), // human facing name. // new MyServiceType("Test service", /*display name*/ // "Test Service" /*short description*/), // service type // new MyStatus(StatusType.NORMAL), new Location("floor","room","building"), new Address("street", "organization", "organizationalUnit", "locality", "stateOrProvince", "postalCode", "country"), new ServiceInfo("bigdata", // product or package name "SYSTAP,LLC", // manufacturer "SYSTAP,LLC", // vendor "0.1-beta", // version "bigdata", // model "serial#" // serialNumber ) }; /* * Note: multicast discovery is always used if LookupDiscovery.ALL_GROUPS is * specified. */ // groups = LookupDiscovery.ALL_GROUPS; groups = new String[]{"bigdata"}; /* * One or more unicast URIs of the form jini://host/ or jini://host:port/. * This MAY be an empty array if you want to use multicast discovery _and_ * you have specified LookupDiscovery.ALL_GROUPS above. */ unicastLocators = new LookupLocator[] { // empty new LookupLocator("jini://localhost/") // new LookupLocator("jini://SYSTAP-BBT.systap.com/") }; serviceIdFile = new File("serviceId.id"); } Index: ITestService.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/test/org/CognitiveWeb/bigdata/jini/ITestService.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ITestService.java 18 Mar 2007 22:29:43 -0000 1.1 --- ITestService.java 22 Mar 2007 15:04:13 -0000 1.2 *************** *** 63,73 **** * @author <a href="mailto:tho...@us...">Bryan Thompson</a> * @version $Id$ ! * ! * @client This interface must be available to the client in order for it to ! * execute the methods defined by the interface without the use of ! * reflection. ! * ! * @server This interface must be available to the server since it exposes this ! * interface on its service. */ public interface ITestService extends Remote --- 63,67 ---- * @author <a href="mailto:tho...@us...">Bryan Thompson</a> * @version $Id$ ! * @download */ public interface ITestService extends Remote Index: TestServer.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/test/org/CognitiveWeb/bigdata/jini/TestServer.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TestServer.java 18 Mar 2007 22:29:43 -0000 1.3 --- TestServer.java 22 Mar 2007 15:04:13 -0000 1.4 *************** *** 49,79 **** import java.io.IOException; import java.rmi.Remote; ! import java.rmi.RemoteException; import net.jini.admin.JoinAdmin; import net.jini.core.entry.Entry; - import net.jini.core.lease.Lease; import net.jini.core.lookup.ServiceID; - import net.jini.core.lookup.ServiceItem; - import net.jini.core.lookup.ServiceRegistrar; - import net.jini.core.lookup.ServiceRegistration; import net.jini.discovery.DiscoveryEvent; ! import net.jini.discovery.DiscoveryListener; import net.jini.discovery.LookupDiscovery; import net.jini.export.Exporter; - import net.jini.export.ProxyAccessor; import net.jini.id.Uuid; import net.jini.id.UuidFactory; - import net.jini.jeri.BasicILFactory; - import net.jini.jeri.BasicJeriExporter; - import net.jini.jeri.tcp.TcpServerEndpoint; import net.jini.lease.LeaseListener; import net.jini.lease.LeaseRenewalEvent; import net.jini.lease.LeaseRenewalManager; ! import net.jini.lookup.entry.Address; ! import net.jini.lookup.entry.Comment; ! import net.jini.lookup.entry.Location; ! import net.jini.lookup.entry.Name; ! import net.jini.lookup.entry.ServiceInfo; import net.jini.lookup.entry.ServiceType; import net.jini.lookup.entry.Status; --- 49,72 ---- import java.io.IOException; import java.rmi.Remote; ! import java.rmi.server.ExportException; import net.jini.admin.JoinAdmin; + import net.jini.config.Configuration; + import net.jini.config.ConfigurationException; + import net.jini.config.ConfigurationProvider; + import net.jini.core.discovery.LookupLocator; import net.jini.core.entry.Entry; import net.jini.core.lookup.ServiceID; import net.jini.discovery.DiscoveryEvent; ! import net.jini.discovery.DiscoveryManagement; import net.jini.discovery.LookupDiscovery; + import net.jini.discovery.LookupDiscoveryManager; import net.jini.export.Exporter; import net.jini.id.Uuid; import net.jini.id.UuidFactory; import net.jini.lease.LeaseListener; import net.jini.lease.LeaseRenewalEvent; import net.jini.lease.LeaseRenewalManager; ! import net.jini.lookup.JoinManager; import net.jini.lookup.entry.ServiceType; import net.jini.lookup.entry.Status; *************** *** 82,85 **** --- 75,80 ---- import org.apache.log4j.Logger; + import com.sun.jini.start.ServiceStarter; + /** * Launches a server used by the test. The server is launched in a separate *************** *** 88,141 **** * invocation and one to shutdown the server. * - * @todo Look into the manager classes for service joins, discovery, etc. The - * code in this class can probably be simplified drammatically. - * * @version $Id$ * @author <a href="mailto:tho...@us...">Bryan Thompson * </a> */ ! public class TestServer implements DiscoveryListener, LeaseListener { ! public static Logger log = Logger.getLogger(TestServer.class); ! private ServiceID serviceID; ! private ServiceItem item; ! private ServiceRegistration reg; ! final private LeaseRenewalManager leaseManager = new LeaseRenewalManager(); /** * Server startup performs asynchronous multicast lookup discovery. The ! * {@link #discovered(DiscoveryEvent)}method is invoked asynchronously ! * to register {@link TestServerImpl}instances. */ ! public TestServer() { ! /* ! * Generate a ServiceID ourselves. This makes it easier to register the ! * same service against multiple lookup services. ! * ! * @todo If you want to restart (or re-register) the same service, then ! * you need to read the serviceID from some persistent location. If you ! * are using activation, then the service can be remotely started using ! * its serviceID which takes that responsibility out of your hands. When ! * using activation, you will only create a serviceID once when you ! * install the service onto some component and activition takes ! * responsiblity for starting the service on demand. ! */ ! Uuid uuid = UuidFactory.generate(); ! serviceID = new ServiceID(uuid.getMostSignificantBits(), ! uuid.getLeastSignificantBits()); try { ! LookupDiscovery discover = new LookupDiscovery( ! LookupDiscovery.ALL_GROUPS); ! discover.addDiscoveryListener(this); } catch (IOException ex) { ! throw new RuntimeException(ex); } --- 83,239 ---- * invocation and one to shutdown the server. * * @version $Id$ * @author <a href="mailto:tho...@us...">Bryan Thompson * </a> + * + * @todo work through use the {@link ServiceStarter} (in start.jar). I am + * having trouble getting past some classpath errors using + * <pre> + java -Djava.security.policy=policy.all -classpath ant-deploy\reggie.jar;ant-deploy\jini-core.jar;ant-deploy\jini-ext.jar;ant-deploy\sun-util.jar;ant-deploy\bigdata.jar -jar ant-deploy\start.jar src\test\org\CognitiveWeb\bigdata\jini\TestServer.config + * </pre> + * + * @todo The serviceID should probably be persisted as a named root object in + * the journal. Each resource (journal or index segment) should also + * have its own UUID. Finally, each index name should have its own UUID. */ ! public class TestServer implements LeaseListener /*, ServiceIDListener*/ { ! public static final transient Logger log = Logger ! .getLogger(TestServer.class); ! private ServiceID serviceID; ! private DiscoveryManagement discoveryManager; ! private JoinManager joinManager; ! private Configuration config; ! private TestServiceImpl impl; ! private Exporter exporter; ! private ITestService proxy; /** * Server startup performs asynchronous multicast lookup discovery. The ! * {@link #discovered(DiscoveryEvent)} method is invoked asynchronously to ! * register a proxy for a {@link TestServiceImpl} instance. The protocol for ! * remote communications between the proxy and the {@link TestServiceImpl} ! * is specified by a {@link Configuration}. ! * ! * @todo use a specific group (bigdata) for discovery. ! * ! * @todo support NIO protocol for data intensive APIs (data service, file ! * transfer). Research how heavy mashalling is and what options exist ! * to make it faster and lighter. */ ! public TestServer(String[] args) { ! final String SERVICE_LABEL = "ServiceDescription"; ! ! final String ADVERT_LABEL = "AdvertDescription"; ! ! Entry[] entries = null; ! LookupLocator[] unicastLocators = null; ! // File serviceIdFile = null; ! String[] groups = null; ! ! serviceID = getServiceID(); try { + + config = ConfigurationProvider.getInstance(args); ! /* ! * Extract how the service will perform service discovery. ! */ ! ! groups = (String[]) config.getEntry(ADVERT_LABEL, "groups", ! String[].class, LookupDiscovery.ALL_GROUPS/* default */); ! ! unicastLocators = (LookupLocator[]) config.getEntry( ! ADVERT_LABEL, "unicastLocators", ! LookupLocator[].class, null/* default */); ! ! /* ! * Extract how the service will advertise itself from the ! * Configuration. ! */ ! ! entries = (Entry[]) config.getEntry(ADVERT_LABEL, "entries", ! Entry[].class, null/* default */); ! ! // serviceIdFile = (File) config.getEntry(ADVERT_LABEL, ! // "serviceIdFile", File.class, null); // default ! /* ! * Extract how the service will provision itself from the ! * Configuration. ! * ! * @todo extract a Properties object to hand to the Journal ! * constructor. Some things should be injected after the ! * fact, such as the serviceID. ! */ ! ! // use the configuration to construct an exporter ! exporter = (Exporter) config.getEntry(// ! SERVICE_LABEL, // component ! "exporter", // name ! Exporter.class // type (of the return object) ! ); ! ! // create the service object (and its proxy). ! impl = new TestServiceImpl(config); ! ! // export a proxy object for this service instance. ! proxy = (ITestService) exporter.export(impl); ! ! log.info("Proxy is " + proxy + "(" + proxy.getClass() + ")"); ! ! } catch(ConfigurationException ex) { ! ! log.fatal("Configuration error: "+ex, ex); ! ! System.exit(1); ! ! } catch (ExportException ex) { ! ! log.fatal("Export error: "+ex, ex); ! ! System.exit(1); ! ! } ! ! try { ! ! /* ! * Note: This class will perform multicast discovery if ALL_GROUPS ! * is specified and otherwise requires you to specify one or more ! * unicast locators (URIs of hosts running discovery services). As ! * an alternative, you can use LookupDiscovery, which always does ! * multicast discovery. ! */ ! discoveryManager = new LookupDiscoveryManager( ! groups, unicastLocators, null // DiscoveryListener ! ); ! ! // DiscoveryManagement discoveryManager = new LookupDiscovery( ! // groups); ! ! // @todo use ServiceIDListener? ! joinManager = new JoinManager(proxy, // service proxy ! entries, // attr sets ! serviceID, // ServiceIDListener ! discoveryManager, // DiscoveryManager ! new LeaseRenewalManager()); } catch (IOException ex) { ! log.fatal("Lookup service discovery error: "+ex, ex); ! ! try { ! /* unexport the proxy */ ! unexport(true); ! } catch (Throwable t) { ! /* ignore */ ! } ! ! System.exit(1); } *************** *** 143,272 **** } /** ! * Log a message and register the {@link TestServerImpl}. Events are ! * aggregated but we can still receive multiple events depending on the ! * latency between discovery of various service registrars. Since the ! * multicast protocol was used to discover service registrars, we can wind ! * up registering with more than one registrar. * ! * @todo If we do not receive this message after some timeout then the ! * server should log an error (in main()) and exit with a non-zero ! * status code. This means that the service needs to expose an ! * indicator of whether or not it has been registered. * ! * @todo Modify service proxy to use RMI. The client stub should be ! * downloaded from the codebase and should know how to commuicate with ! * the discovered service, e.g., using RMI or a custom NIO protocol. * ! * @todo This should be a fast operation and should not make remote calls. ! * Service registration therefore needs to happen in another thread so ! * that the service registrar can continue about its business. */ ! public void discovered(DiscoveryEvent evt) { ! ! /* ! * At this point we have discovered one or more lookup services. ! */ ! registerService( evt.getRegistrars() ); ! } ! ! /** ! * Registers a service proxy with each identified registrar. The ! * registration happens in another thread to keep the latency down for the ! * {@link DiscoveryListener#discovered(net.jini.discovery.DiscoveryEvent)} ! * event. ! * ! * @param registrars ! * One or more service registrars. ! */ ! private void registerService( final ServiceRegistrar[] registrars ) { ! ! log.info("Discovered "+registrars.length+" service registrars"); ! ! new Thread("Register Service") { ! public void run() { ! // the service ! Object impl = new TestServerImpl().getProxy(); ! // Create an information item about a service ! item = new ServiceItem(serviceID, impl, new Entry[] { ! new Comment("Test service(comment)"), // human facing comment. ! new Name("Test service(name)"), // human facing name. ! new MyServiceType("Test service (display name)", ! "Test Service (short description)"), // service type ! new MyStatus(StatusType.NORMAL), ! new Location("floor","room","building"), ! new Address("street", "organization", "organizationalUnit", ! "locality", "stateOrProvince", "postalCode", ! "country"), ! new ServiceInfo("bigdata", // product or package name ! "SYSTAP,LLC", // manufacturer ! "SYSTAP,LLC", // vendor ! "0.1-beta", // version ! "bigdata", // model ! "serial#" // serialNumber ! ) }); ! ! for (int i = 0; i < registrars.length; i++) { ! /* ! * Register a service. The service requests a "long" lease using ! * Lease.FOREVER. The registrar will decide on the actual length ! * of the lease. ! */ ! ServiceRegistrar registrar = registrars[i]; ! while (reg == null) { ! try { ! // Register the service. ! reg = registrar.register(item, Lease.FOREVER); ! /* ! * Setup automatic lease renewal. ! * ! * Note: A single lease manager can handle multiple services ! * and the lease of a given service on multiple service ! * registrars. It knows which lease is about to expire and ! * preemptively extends the lease on the behalf of the ! * registered service. It will notify the LeaseListener iff ! * it is unable to renew a lease. ! */ ! log.info("lease will expire in " ! + (reg.getLease().getExpiration() - System ! .currentTimeMillis()) + "ms"); ! leaseManager ! .renewUntil(reg.getLease(), Lease.FOREVER, TestServer.this); ! /* ! * Service has been registered and lease renewal is ! * operating. ! */ ! break; ! } catch (RemoteException ex) { ! // retry until successful. ! try { ! Thread.sleep(100); ! } catch (InterruptedException ex2) { ! } ! } ! } ! } ! } ! }.start() ! ; } /** ! * Log a message. */ ! public void discarded(DiscoveryEvent arg0) { ! ! log.info(""); ! } /** ! * Note: This is only invoked if the automatic lease renewal by the ! * lease manager is denied by the service registrar. In that case we ! * should probably update the Status to indicate an error condition. */ public void notify(LeaseRenewalEvent event) { --- 241,326 ---- } + // /* + // * @todo look into this as an alternative means to shutdown a service. + // */ + // void shutdown() { + // try { + // Object admin = ((Administrable) proxy).getAdmin(); + // DestroyAdmin destroyAdmin = (DestroyAdmin) admin; + // destroyAdmin.destroy(); + // } catch (RemoteException e) { // handle + // // exception + // // + // } + // } + /** ! * Unexports the proxy. * ! * @param force ! * When true, the object is unexported even if there are pending ! * or in progress service requests. * ! * @return true iff the object is (or was) unexported. * ! * @see Exporter#unexport(boolean) */ ! public boolean unexport(boolean force) { ! if(exporter.unexport(true)) { ! proxy = null; + return true; + } + + return false; + } /** ! * Generate a ServiceID ourselves. This makes it easier to register the same ! * service against multiple lookup services. ! * ! * @todo If you want to restart (or re-register) the same service, then you ! * need to read the serviceID from some persistent location. If you ! * are using activation, then the service can be remotely started ! * using its serviceID which takes that responsibility out of your ! * hands. When using activation, you will only create a serviceID once ! * when you install the service onto some component and activition ! * takes responsiblity for starting the service on demand. */ ! private ServiceID getServiceID() { ! Uuid uuid = UuidFactory.generate(); ! ! return new ServiceID(uuid.getMostSignificantBits(), ! uuid.getLeastSignificantBits()); ! ! } ! ! // /** ! // * @todo implement {@link ServiceIDListener} and pass into the ! // * {@link JoinManager} constructor if you want to use a persistent ! // * {@link ServiceID}. This method is responsible for saving the ! // * serviceID on stable storage when it is invoked. ! // * ! // * @param serviceID ! // */ ! // public void serviceIDNotify(ServiceID serviceID) { ! // ! // log.info("serviceID=" + serviceID); ! // ! // } /** ! * Note: This is only invoked if the automatic lease renewal by the lease ! * manager is denied by the service registrar. ! * ! * @todo how should we handle being denied a lease? Wait a bit and try ! * re-registration? There can be multiple discovery services and this ! * is only one lease rejection, so perhaps the service is still under ! * lease on another discovery service? */ public void notify(LeaseRenewalEvent event) { *************** *** 278,288 **** /** * Launch the server in a separate thread. */ public static void launchServer() { new Thread("launchServer") { public void run() { ! TestServer.main(new String[] {}); } }.start(); } --- 332,347 ---- /** * Launch the server in a separate thread. + * <p> + * Note: The location of the test service configuration is hardwired to a + * test resource. */ public static void launchServer() { new Thread("launchServer") { public void run() { ! TestServer ! .main(new String[] { "src/test/org/CognitiveWeb/bigdata/jini/TestServer.config" }); } }.start(); + log.info("Starting service."); } *************** *** 294,300 **** */ public static void main(String[] args) { ! final long lifespan = 3 * 60 * 1000; // life span in seconds. log.info("Will start test server."); ! TestServer testServer = new TestServer(); log.info("Started test server."); try { --- 353,359 ---- */ public static void main(String[] args) { ! final long lifespan = 5 * 1000; // life span in seconds. log.info("Will start test server."); ! TestServer testServer = new TestServer(args); log.info("Started test server."); try { *************** *** 305,311 **** } /* ! * @todo This forces a hard reference to remain for the test server. */ ! log.info("Server will die: "+testServer); } --- 364,392 ---- } /* ! * Terminate manager threads. */ ! try { ! log.info("Terminating manager threads."); ! testServer.joinManager.terminate(); ! testServer.discoveryManager.terminate(); ! } catch (Exception ex) { ! log.error("Could not terminate: "+ex, ex); ! } ! /* ! * Unexport the proxy, making the service no longer available. If you do ! * not do this then the client can still make requests even after you ! * have terminated the join manager and the service is no longer visible ! * in the service browser. ! */ ! log.info("Unexporting the service proxy."); ! testServer.unexport(true); ! ! // /* ! // * Note: The reference to the service instance here forces a hard ! // * reference to remain for the test server. If you comment out this log ! // * statement, then you need to do something else to hold onto the hard ! // * reference. ! // */ ! // log.info("Server will die: "+testServer); } *************** *** 316,319 **** --- 397,401 ---- * @version $Id$ * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @download */ public static class MyStatus extends Status { *************** *** 351,354 **** --- 433,437 ---- * @author <a href="mailto:tho...@us...">Bryan Thompson * </a> + * @download */ public static class MyServiceType extends ServiceType *************** *** 397,550 **** * </a> */ ! public static class TestServerImpl implements ProxyAccessor, ITestService/*, Serializable*/ { /** - * Note: Mark the {@link Logger} as transient since we do NOT need to - * serialize its state. - * <p> - * - * @todo When the service uses a proxy and a remote communications - * protocol, the service instance is remote and this object is not - * instantiated on the client (test this hypothesis by removing - * log4j from the codebase). - */ - public static final transient Logger log = Logger.getLogger(TestServerImpl.class); - - // Note required when using a service proxy. the Exporter handles the proxy generation. - // /** - // * - // */ - // private static final long serialVersionUID = -920558820563934297L; - - /** - * The location of the JERI configuration file. - * - * @todo provide a command line option to override the file location. - */ - private transient static String CONFIG_FILE = "jeri/jeri.config"; - - private ITestService proxy; - - // /** - // * - // * @param args - // * @throws Exception - // * - // * @see http://jan.newmarch.name/java/jini/tutorial/Jeri.xml for an - // * explanation of what is going on here. - // */ - // public static void main(String[] args) throws Exception { - // - // String[] configArgs = new String[] { CONFIG_FILE }; - // - // // get the configuration (by default a FileConfiguration) - // Configuration config = ConfigurationProvider - // .getInstance(configArgs); - // System.out.println("Configuration: " + config.toString()); - // - // // and use the configuration to construct an exporter - // Exporter exporter = (Exporter) config.getEntry( - // // - // TestServerImpl.class.getName(), // component - // "exporter", // name - // Exporter.class, // type (of the return object) - // new BasicJeriExporter(TcpServerEndpoint.getInstance(0), - // new BasicILFactory()) /* default */,// - // Configuration.NO_DATA // data. - // ); - // - // // export an object of this class - // Remote proxy = exporter.export(new TestServerImpl()); - // System.out.println("Proxy is " + proxy.toString()); - // - // // now unexport it once finished - // exporter.unexport(true); - // - // } - - /* - * @todo presumably service shutdown should clear the proxy reference - * once the service has been removed from the registry. - */ - public Object getProxy() { - - return proxy; - - } - - /** * Service constructor. * ! * @todo can the constructor accept arguments? */ ! public TestServerImpl() /*@todo throws RemoteException ?*/ { ! ! /* ! * @todo when this is added the test will succeed the first time but ! * thereafter will fail with a connection refused to the end point ! * for the _expired_ service. While that exception makes sense in ! * that the expired service should not be connectable, I do not ! * understand why adding or dropping this line has any influence. ! * Perhaps the problem is that it changes GC behavior and the prior ! * test service is otherwise NOT expired? Look into what this ! * service is doing to shutdown after the test and what is should ! * be doing. ! * ! * So - the test does NOT attempt to close down the service - I was ! * deliberately leaving it open so that I could explore the service ! * in the Service Browser. The issue may be that this replaces the ! * SecurityManager after one was already installed in the VM by the ! * test itself! ! */ ! // System.setSecurityManager(new SecurityManager()); ! ! try { ! ! // @todo work out use of a configuration file. ! // String[] configArgs = new String[] { CONFIG_FILE }; ! // ! // // get the configuration (by default a FileConfiguration) ! // Configuration config = ConfigurationProvider ! // .getInstance(configArgs); ! // System.out.println("Configuration: " + config.toString()); ! // ! // // and use the configuration to construct an exporter ! // Exporter exporter = (Exporter) config.getEntry( ! // // ! // TestServerImpl.class.getName(), // component ! // "exporter", // name ! // Exporter.class, // type (of the return object) ! // new BasicJeriExporter(TcpServerEndpoint.getInstance(0), ! // new BasicILFactory()) /* default */,// ! // Configuration.NO_DATA // data. ! // ); ! ! // hardwired jeri exporter using TCP. ! Exporter exporter = new BasicJeriExporter(TcpServerEndpoint ! .getInstance(0), new BasicILFactory()); ! ! // export an object of this class ! proxy = (ITestService) exporter.export(this); ! log.info("Proxy is " + proxy + "(" + proxy.getClass() + ")"); ! } catch(Exception ex) { ! // @todo should we retry the operation? ! log.error(ex); ! throw new RuntimeException(ex); ! } - // @todo who will unexport the proxy? - - // // now unexport it once finished - // exporter.unexport(true); - - // System.err.println("Created: "+this); - log.info("Created: "+this); } public void invoke() { ! // System.err.println("invoked: "+this); log.info("invoked: "+this); } --- 480,502 ---- * </a> */ ! public static class TestServiceImpl implements ITestService { /** * Service constructor. * ! * @throws ConfigurationException */ ! public TestServiceImpl(Configuration config) ! throws ConfigurationException { ! log.info("Created: " + this ); } public void invoke() { ! log.info("invoked: "+this); + } |
From: Bryan T. <tho...@us...> - 2007-03-22 15:04:31
|
Update of /cvsroot/cweb/bigdata/src/architecture In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv20431/src/architecture Modified Files: segment math.xls Log Message: Working on services. Added some JARs for dependencies to simplify deployment. Index: segment math.xls =================================================================== RCS file: /cvsroot/cweb/bigdata/src/architecture/segment math.xls,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 Binary files /tmp/cvsLk3Bl6 and /tmp/cvshqezC7 differ |
From: Bryan T. <tho...@us...> - 2007-03-22 15:04:30
|
Update of /cvsroot/cweb/bigdata/src/test/org/CognitiveWeb/bigdata In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv20431/src/test/org/CognitiveWeb/bigdata Removed Files: TestAll.java TestOidMath.java Log Message: Working on services. Added some JARs for dependencies to simplify deployment. --- TestOidMath.java DELETED --- --- TestAll.java DELETED --- |
From: Bryan T. <tho...@us...> - 2007-03-22 15:04:29
|
Update of /cvsroot/cweb/bigdata/src/java/com/bigdata/gom In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv20431/src/java/com/bigdata/gom Added Files: clusterIndices.txt Log Message: Working on services. Added some JARs for dependencies to simplify deployment. --- NEW FILE: clusterIndices.txt --- @todo Clustered indices. A clustered index is where the rows are organized on disk according to some key found in or computed for each row. Clustered indices provides maximum read rates when scanning data in key order and they can be used to effectively pre-fetch rows when a known key range is being scanned. Unfortunately clustered indices are at odds with object identifiers (OIDs). I can see only two ways to reconcile these things: (1) If object lookup proceeds by indirection using an object index, then the object index can be updated each time the clustered index page on which the object is found is changed. With this approach clustered index nodes will need to track the oid for each key-value so that an object can be resolved either by its oid or by its key - this seems on the face to be pretty messy.; (2) the other option is to generalize OIDs to permit variable length byte[]s as the general case. This could be done at the API using an IOId interface. All persistent objects would implement IOId. When the OID was "direct" it would be a 64-bit integer and go through one set of lookup mechanisms. When the object was allocated using a clustered index, the OID would be the key (a byte[]) together with the index identifier and the index would know how to compare its keys. This would have an impact throughout the generic object design since we could no longer rely on the assumption that an OID was a 64-bit integer. However, it would make it possible to cluster objects disk within a dynamic structure (e.g., a btree, rtree, etc.). Thinking this through further, I am beginning to really like the idea that object identity may be defined by data fields -or- by an system defined identifier. OIDs show up in several aspects of the system, and they would all have to be modified to handle either 64-bit OIDs or byte[] OIDs interpreted by an index structure. propertyIds -- assumes long oids. Uses a persistent map from unicode name to long integer. Clearly the map itself is ammenable to an index structure, but the index might be structured as (partition.)schema.property rather than by a universal btree. Property Ids are used multiple times in a generic data record, yielding a great opportunity for compression using a bit coding algorithm with the shortest codes assigned to the most common ids. listenerIds -- assumes long oids. listener ids are used for link sets indices and also formulas. there is no reason that I can see to permit listeners to be allocated within clustered indices. for example, why would you perform an ordered scan of listeners? There is probably some redundency in listener ids in generic data records, again creating an opportunity for compression. --- IOI -- thin() : IOI - the returned IOI will not hold a hard/soft reference to the object described by that identifier. (IOIs are often created from objects, in which case they typically hold a hard reference to that object.) toString() : String - convert to external form new IOI(OM,String) - convert from external form isId() : boolean - true iff OID is generated (64-bit long). isKey() : boolean - true iff OID is application defined. getId() : long throws IllegalStateException; getIndex() : <index> throws IllegalStateException; getKey() : Object throws IllegalStateException; ---- org.CognitiveWeb.generic.core ---- AbstractBTree (and concrete implementations) long _nativeBTreeId Generic, PropertyClass:: Only very minor changes. The transient listener and property change maps on the generic object use long keys, but they are already scheduled to be re-implemented using a weak hash map with IPropertyClass keys. m_transientLinkSetChangeListeners : Map -> IOI (or PropertyClass) keys in map m_transientPropertyChangeListeners : Map (ditto) GenericData:: See IGenericData. IBlob, IBlobValue, BlobValue:: These wrap the OID of the Blob. Is there a reason to arrange blobs in order in disk? Blobs are made out of chunks and those chunks should be clustered, and even ordered, on disk, but the expectation is that blobs are used for rather larger data items. A counter example might be the multiple versions of the content of a web page stored together with their metadata where the pages are indexed by URL and one or more temporal dimensions (lastModified, harvestTime, etc.) long m_oid; -> IOI oid; long getOID() -> getOID() : IOI ILinkValue, LinkValue:: Note: Link sets may span clustered and unclustered objects, so priorId could be a 64-bit long while nextId was a {index,key} tuple. Note: LinkValue is serialized as part of the generic data record. Since it contains OIDs, all LinkValue need to participate in the bitcoding algorithm to compress object references. LinkValue currently defines serialization, but that should probably be removed (or versioned to a serializer that throws an exception) to make sure that OIDs are being compressed properly! long getTargetId(); -> getTargetId() : IOI long getPriorId(); ditto long getNextId(); ditto IPropertyClassExt:: long getPropertyId() -> ??? This method is widely used. It dates back to a time when properties were not modeled as generic objects, hence there was some ambiguity about the propertyId. Currently the propertyId is just the OID. If we restrict PropertyClass to always use a 64-bit long OID, then this method could stay as is and that would (drammatically) reduce the impact on the generic-native API. If we modify property class to be allocated within (or allow allocation within) a clustered index, then all bets are off and this needs to become getOID():IOI. I vote to defer this change for now. IReference:: extended by IBlobValue and ILinkValue. long getOID() -> getOID() : IOI. LinkSet:: No API changes, some implementation change (traversing prior and next link set members). LinkSetIterator:: long m_nextId -> m_nextId : IOI long m_lastVisited -> ?Generic or ?IOI LinkSetIndex:: transient IGeneric m_owner -> drop field. long m_ownerId -> m_owner:IOI There is a pattern here for caching a reference to the generic object that is the owned, link class or property class while only serializing its OID. This could be modified to use a "thick" IOI wrapping the referenced object and serialized using a simplistic approach (since there are only four OIDs to be serialized (owner, linkClass, propertyClass, btree)). getFooId() -> getFooOID(), where foo is Owner, Btree, etc. Or perhaps just drop those method forms completely. ILinkSetIndex:: Refactor to provide common abstraction for clustered index, link set, and link set index for ordered traversal and (for clustered index and link set) for set semantics (membership tests, etc.) ---- org.CognitiveWeb.generic.core.data ---- IGenericData:: Lots of changes - it presumes 'long oid' everywhere. The serialization logic does not not currently factor out OIds from longs for compression. Once that change is made, it should be possible to refactor further to support compression (bitcoding) for both 64-bit OIDs and keys. It is possible that there are opportunities for leading or trailing edge compression in keys. ---- org.CognitiveWeb.generic.core.ndx ---- CompositeKey, ICompositeKey:: Uses long oid to break ties. Note: A clustered index itself can not permit ties (or, rather, must apply destructive merge rules on commits resulting in ties). Therefore composite keys are not used for clustered indices. A link set index is a secondary index structure. Like a link set, it is possible that it may span objects having both 64-bit long OIDs and those allocated within one (or more) clustered indices. Breaking ties remains a requirement when the index supports duplicates and the composite key would need to be generalized (or specialized) into handling either 64-bit OIDs and {index,key} OIDs. long getObjectIdentity() -> getOID():IOI? This was given a distinct name since it introduces a clash if the composite key is also a persistent object (between the OID of the composite key and the OID of the object having that key value). This was a problem with Objectivity since keys were persistence capable objects, but it should not be a problem with any backend that supports keys inline within btree nodes. CompositeKeyComparator:: Compares composite keys and therefore must be updated to remove the assumption of long OID. FlyOId:: -> IOI implementation. ResolvingComparator ---- org.CognitiveWeb.generic.core.om ---- BaseObject:: transient long _oid; init( ObjectManager om, long oid ) long getOID(); -> IOI getOID(); int hashCode() -> delegate to getOID().hashCode(); configure on index w/ comparator. identity():String -> IOI:toString() fetch(long oid) -> fetch(IOI oid) IPersistentStore:: fetch(long oid) -> fetch(IOI oid) delete(long oid) -> delete(IOI oid) getBTree(long oid) -> ??? ObjectManager:: getPropertyName(long oid) -> Ok (convert property name to obj). getPropertyClass(long oid) -> Ok (convert property name to obj). getObject(String identity) -> IOI#fromString( String ); ?? IOI#toString(); Lazy removal of objects : assumes long OID. fetch(long oid) -> fetch(IOI) ObjectNotFoundException:: long m_oid -> IOI m_oid; ---- org.CognitiveWeb.generic.om.blob ---- Blob long headId, tailId; Segment long blobId, priorId, nextId; ---- org.CognitiveWeb.generic.core.cache ---- This needs to be refactored into an outer abstraction for IOI and inner implementations for (a) an object cache based on 64-bit longs; and (b) an object cache per-cluster index based on key values. For the latter it could either use a lookup strategy appropriate to that index type, e.g., a btree, or it could use a hash map. Index nodes should have some caching options, but that is at another level. ---- org.CognitiveWeb.generic.core.util ---- GenericResolver: assumes resolving Long to object. Modify to resolve IOI to object. ---- org.CognitiveWeb.extser ---- DataOutput void writePackedOId(); DataInput long readPackedOId(); ILinkSet (head,tail) and ILinkValue (prior,next,target) - assume long oids. Assuming that the clustered index can be viewed as an ordered link set, the prior / next members would not be used for that index as the btree would supply forward and reverse object visitation in key order. Likewise, the target would not be used since the clustered index would be the target and it can be identifed from the btree node in which the object is found. Therefore ILinkValue is NOT stored for references to prior/next objects in a clustered index. However, ILinkValue would still be used for links into objects in a clustered index. Those OIDs would then be byte[]s. There is also an issue with maintaining referential integrity under object deletion or (possibly computed) key change for an object. This is currently handled for integer OIDs and would have to be handled for clustered indices as well. Object cache -- assumes long oids. There would have to be a 2nd object cache data structure based on a btree. Supporting multiple clustered indices means that the key is actually a combination of the index identifier (a 64-bit OID) and the byte[]. This means that we need an object cache per clustered index. |
Update of /cvsroot/cweb/bigdata/src/java/com/bigdata/service In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv20431/src/java/com/bigdata/service Modified Files: package.html DataService.java MetadataService.java MapReduceService.java AbstractService.java IMetadataService.java Log Message: Working on services. Added some JARs for dependencies to simplify deployment. Index: DataService.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/service/DataService.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** DataService.java 18 Mar 2007 22:29:43 -0000 1.3 --- DataService.java 22 Mar 2007 15:04:15 -0000 1.4 *************** *** 140,144 **** * directory. */ ! public class DataService extends AbstractService implements IDataService, IWritePipeline, IResourceTransfer { protected Journal journal; --- 140,145 ---- * directory. */ ! public class DataService extends AbstractService implements IDataService, ! IWritePipeline, IResourceTransfer { protected Journal journal; Index: package.html =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/service/package.html,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** package.html 17 Mar 2007 23:14:58 -0000 1.1 --- package.html 22 Mar 2007 15:04:15 -0000 1.2 *************** *** 1,13 **** <html> <head> ! <title>Services</title> </head> <body> <p> ! This package provides implementations of services (data service, transaction ! manager service, metadata locator service). </p> </body> ! </html> \ No newline at end of file --- 1,176 ---- <html> <head> ! <title>services</title> </head> <body> <p> ! This package provides implementations of bigdata services (metadata ! service, data service, transaction manager service. ! </p> ! ! <p> ! A bigdata federation is comprised of the following essential ! services: ! ! <dl> ! ! <dt>metadata service</dt><dd>The metadata service manages indices and ! is used to locate index partitions.</dd> ! ! <dt>data service</dt><dd>The data service supports reads and writes on ! index partitions.</dd> ! ! <dt>transaction manager service</dt><dd>Clients use the transaction ! manager service to start new transactions and to coordinate the ! distributed commit protocol. The transaction manager also provides a ! centralized timestamp factory.</dd> ! ! </dl> ! ! Clients are responsible for discovering the metadata service. Clients ! then use the metadata service to manage scale-out indices and to ! locate and cache leases for data service instances having data for key ! range partitions that the client will read or write. If a client will ! use transactions (vs ACID batch operations), then the client must also ! locate the transaction manager service. Service location is performed ! using JINI, but other service locator protocols are possible. ! </p> ! ! <p> ! ! bigdata provides the following value added services. These are not ! considered essential since (a) they are not required by clients that ! make direct use of bigdata as a distributed database; and (b) they are ! themsevles applications of the services briefly described above. ! ! <dl> ! ! <dt>map/reduce service</dt><dd>Manages the distributed execution of a ! functional program.</dd> ! ! </dl> ! ! </p> ! ! <h2>deployment</h2> ! ! <p> ! ! In order to deploy a bigdata federation, the following preconditions ! must be met (a standalone deployment can be realized by meeting these ! preconditions on a single host). This will go more smoothly if JINI ! is running before you start the various bigdata services since they ! will then be able to register themselves immediately on ! startup. Service discovery by default uses the local network and the ! "public" group. If you want to run more than one bigdata federation on ! the same network, then you MUST edit the configuration file. ! ! </p> ! ! <p> ! Hosts: ! ! <ul> ! ! <li>java 5 or better is installed. The use of a server VM is highly ! recommended. The following options are recommended for some well ! known VMs: <dl> ! ! <dt>Sun</dt><dd>-server -Xms1g -Xmx1g -XX:MaxDirectMemorySize=256M</dd> ! ! <dt>JRockit</dt><dd>-Xms1g -Xmx1g</dd> ! ! </dl> ! ! @todo review the use of -Xms (sets the initial heap size). How much ! of a difference does this make? Note that JRockit defaults to 75% of ! physical memory or 1G, which ever is less.</li> ! ! <li>the bigdata-server distribution is installed.</li> ! ! <li>the data service is running.</li> ! ! </ul> ! ! </p> ! ! <p> ! In addition, there must be at least one host on which the following ! preconditions are true (a different host could be used for each of ! these services, and more than one instance of these services may be ! running on the network). These services should be started during the ! boot procedure so that they are available whenever the host is up and ! running. ! ! <ul> ! ! <li>jini 2.x is installed and running. This will be used to register ! and lookup services. It helps if jini is running before you try to ! start the bigdata sercices since they will be able to register ! themselves immediately in that case.</li> ! ! <li>the metadata service is running (this is part of the ! bigdata-server distribution).</li> ! ! <li>the transaction manager service is running (this is part of the ! bigdata-server distribution).</li> ! ! <li>the optional map/reduce service is running (this is part of the ! bigdata-server distribution).</li> ! ! </ul> ! ! </p> ! ! <p> ! Clients: ! ! <ul> ! ! <li>java 5 or better is installed. The use of a server VM ! is highly recommended</li> ! ! <li>the bigdata-client deployment package is installed. This includes ! bigdata-client.jar, but also support for generating unicode keys ! (ICU4J), etc.</li> ! ! </ul> ! ! </p> ! ! <h2>downloaded code</h2> ! ! <p> ! ! While bigdata makes use of jini for service registration and ! discovery, it does not use downloaded code for executing its basic ! services (the necessary interfaces and implementation classes are ! already bundled in bigdata.jar). However, clients MAY use downloaded ! code in order to have data servers execute remote procedures or ! extension batch operations. In this scenario, the client will create ! and register a JINI service. The service should perform <em>all</em> ! of its operations locally. The data server will lookup the service ! using jini and then execute it locally. ! </p> ! ! <p> ! In order for downloaded code to work correctly, clients must ensure ! that their classes are exposed by an HTTP server accessible to bigdata ! servers and declared to the VM in which the client starts using: ! ! <code>-Djava.rmi.server.codebase=...</code> ! ! </p> ! ! <p> ! ! @todo consider this use case further. Are there other/better ways for ! executing remote code on the data server? At a minimum, we should ! supply a base class and ant script support for creating such remote ! services. ! </p> </body> ! </html> Index: MetadataService.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/service/MetadataService.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MetadataService.java 17 Mar 2007 23:14:58 -0000 1.1 --- MetadataService.java 22 Mar 2007 15:04:15 -0000 1.2 *************** *** 64,72 **** /** - * The name of the index. - */ - protected final String name; - - /** * The name of the journal on which the metadata index is stored. * --- 64,67 ---- *************** *** 76,81 **** protected final Journal journal; - protected MetadataIndex mdi; - public MetadataService(Properties properties) { --- 71,74 ---- *************** *** 93,107 **** } ! public InetSocketAddress getDataService(byte[] key) { // TODO Auto-generated method stub return null; } ! public int getEntryCount() { // TODO Auto-generated method stub return 0; } ! public int rangeCount(byte[] fromKey,byte[] toKey) { // TODO Auto-generated method stub return 0; --- 86,100 ---- } ! public InetSocketAddress getDataService(String name,byte[] key) { // TODO Auto-generated method stub return null; } ! public int getEntryCount(String name) { // TODO Auto-generated method stub return 0; } ! public int rangeCount(String name,byte[] fromKey,byte[] toKey) { // TODO Auto-generated method stub return 0; Index: MapReduceService.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/service/MapReduceService.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MapReduceService.java 17 Mar 2007 23:14:58 -0000 1.1 --- MapReduceService.java 22 Mar 2007 15:04:15 -0000 1.2 *************** *** 220,227 **** /** ! * Resolve the metadata service for the named index. ! * ! * @param name ! * The index name. * * @return The metadata service for the named index. --- 220,224 ---- /** ! * Resolve the metadata service. * * @return The metadata service for the named index. *************** *** 229,233 **** * @todo change the return type. */ ! protected IMetadataService getMetadataService(String name) { throw new UnsupportedOperationException(); --- 226,230 ---- * @todo change the return type. */ ! protected IMetadataService getMetadataService() { throw new UnsupportedOperationException(); *************** *** 256,262 **** public Object call() throws Exception { ! IMetadataService mds = getMetadataService(name); ! final int nentries = mds.rangeCount(fromKey,toKey); return null; --- 253,259 ---- public Object call() throws Exception { ! IMetadataService mds = getMetadataService(); ! final int nentries = mds.rangeCount(name,fromKey,toKey); return null; Index: IMetadataService.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/service/IMetadataService.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IMetadataService.java 17 Mar 2007 23:14:58 -0000 1.1 --- IMetadataService.java 22 Mar 2007 15:04:15 -0000 1.2 *************** *** 66,70 **** * The approximate number of entries in the index (non-transactional). */ ! public int getEntryCount(); /** --- 66,70 ---- * The approximate number of entries in the index (non-transactional). */ ! public int getEntryCount(String name); /** *************** *** 76,80 **** * @return */ ! public int rangeCount(byte[] fromKey,byte[] toKey); /** --- 76,80 ---- * @return */ ! public int rangeCount(String name,byte[] fromKey,byte[] toKey); /** *************** *** 95,99 **** * index partitions surrounding that partition. */ ! public InetSocketAddress getDataService(byte[] key); } --- 95,99 ---- * index partitions surrounding that partition. */ ! public InetSocketAddress getDataService(String name, byte[] key); } Index: AbstractService.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/service/AbstractService.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AbstractService.java 18 Mar 2007 22:29:43 -0000 1.1 --- AbstractService.java 22 Mar 2007 15:04:15 -0000 1.2 *************** *** 50,55 **** --- 50,57 ---- import java.io.IOException; import java.io.Serializable; + import java.rmi.Remote; import java.rmi.RemoteException; + import net.jini.admin.JoinAdmin; import net.jini.core.entry.Entry; import net.jini.core.lease.Lease; *************** *** 61,66 **** --- 63,73 ---- import net.jini.discovery.DiscoveryListener; import net.jini.discovery.LookupDiscovery; + import net.jini.export.Exporter; + import net.jini.export.ProxyAccessor; import net.jini.id.Uuid; import net.jini.id.UuidFactory; + import net.jini.jeri.BasicILFactory; + import net.jini.jeri.BasicJeriExporter; + import net.jini.jeri.tcp.TcpServerEndpoint; import net.jini.lease.LeaseListener; import net.jini.lease.LeaseRenewalEvent; *************** *** 75,78 **** --- 82,90 ---- import net.jini.lookup.entry.StatusType; + import org.CognitiveWeb.bigdata.jini.ITestService; + import org.CognitiveWeb.bigdata.jini.TestServer; + import org.CognitiveWeb.bigdata.jini.TestServer.MyServiceType; + import org.CognitiveWeb.bigdata.jini.TestServer.MyStatus; + import org.CognitiveWeb.bigdata.jini.TestServer.TestServiceImpl; import org.apache.log4j.Logger; *************** *** 83,160 **** * @version $Id$ */ ! abstract public class AbstractService implements DiscoveryListener, LeaseListener, IServiceShutdown ! { public static Logger log = Logger.getLogger(AbstractService.class); ! private ServiceID serviceID; ! private ServiceItem item; ! private ServiceRegistration reg; ! final private LeaseRenewalManager leaseManager = new LeaseRenewalManager(); ! /** ! * Close down the service (no longer discoverable). ! * ! * @todo revoke lease, etc. ! */ ! private void _close() { ! ! } ! /** ! * Waits for existing leases to expire before shutting down, but does not ! * grant any new leases. ! */ ! public void shutdown() { ! ! /* ! * @todo wait for leases to expire and then shutdown. do not renew any ! * leases. ! */ ! ! _close(); ! ! } ! ! /** ! * Shutdown immediately, violating any existing leases. ! */ ! public void shutdownNow() { ! ! _close(); ! ! } ! ! /** ! * Return the {@link ServiceID}. Using a consistent {@link ServiceID} makes ! * it easier to register the same service against multiple lookup services. ! * <p> ! * This implementation generates a new {@link ServiceID} each time. ! * ! * @todo If you want to restart (or re-register) the same service, then you ! * need to read the serviceID from some persistent location. If you ! * are using activation, then the service can be remotely started ! * using its serviceID which takes that responsibility out of your ! * hands. When using activation, you will only create a serviceID once ! * when you install the service onto some component and activition ! * takes responsiblity for starting the service on demand. ! */ ! public ServiceID getServiceID() { ! Uuid uuid = UuidFactory.generate(); ! ! return new ServiceID(uuid.getMostSignificantBits(), uuid ! .getLeastSignificantBits()); ! } /** * Server startup performs asynchronous multicast lookup discovery. The * {@link #discovered(DiscoveryEvent)} method is invoked asynchronously to ! * register {@link TestServerImpl} instances. */ public AbstractService() { ! serviceID = getServiceID(); try { --- 95,135 ---- * @version $Id$ */ ! abstract public class AbstractService implements DiscoveryListener, ! LeaseListener, IServiceShutdown { public static Logger log = Logger.getLogger(AbstractService.class); ! private ServiceID serviceID; ! private ServiceItem item; ! private ServiceRegistration reg; ! final private LeaseRenewalManager leaseManager = new LeaseRenewalManager(); ! private TestServerImpl impl; /** * Server startup performs asynchronous multicast lookup discovery. The * {@link #discovered(DiscoveryEvent)} method is invoked asynchronously to ! * register {@link TestServiceImpl} instances. */ public AbstractService() { ! /* ! * Generate a ServiceID ourselves. This makes it easier to register the ! * same service against multiple lookup services. ! * ! * @todo If you want to restart (or re-register) the same service, then ! * you need to read the serviceID from some persistent location. If you ! * are using activation, then the service can be remotely started using ! * its serviceID which takes that responsibility out of your hands. When ! * using activation, you will only create a serviceID once when you ! * install the service onto some component and activition takes ! * responsiblity for starting the service on demand. ! */ ! Uuid uuid = UuidFactory.generate(); ! serviceID = new ServiceID(uuid.getMostSignificantBits(), uuid ! .getLeastSignificantBits()); try { *************** *** 162,172 **** LookupDiscovery discover = new LookupDiscovery( LookupDiscovery.ALL_GROUPS); ! discover.addDiscoveryListener(this); ! } catch (IOException ex) { ! throw new RuntimeException(ex); ! } --- 137,147 ---- LookupDiscovery discover = new LookupDiscovery( LookupDiscovery.ALL_GROUPS); ! discover.addDiscoveryListener(this); ! } catch (IOException ex) { ! throw new RuntimeException(ex); ! } *************** *** 174,178 **** /** ! * Log a message and register the {@link TestServerImpl}. Events are * aggregated but we can still receive multiple events depending on the * latency between discovery of various service registrars. Since the --- 149,153 ---- /** ! * Log a message and register the {@link TestServiceImpl}. Events are * aggregated but we can still receive multiple events depending on the * latency between discovery of various service registrars. Since the *************** *** 185,190 **** * indicator of whether or not it has been registered. * - * @todo Modify service proxy to use RMI. - * * @todo This should be a fast operation and should not make remote calls. * Service registration therefore needs to happen in another thread so --- 160,163 ---- *************** *** 197,206 **** */ ! registerService( evt.getRegistrars() ); ! } /** ! * Registers a service proxy with reach identified registrar. The * registration happens in another thread to keep the latency down for the * {@link DiscoveryListener#discovered(net.jini.discovery.DiscoveryEvent)} --- 170,179 ---- */ ! registerService(evt.getRegistrars()); ! } /** ! * Registers a service proxy with each identified registrar. The * registration happens in another thread to keep the latency down for the * {@link DiscoveryListener#discovered(net.jini.discovery.DiscoveryEvent)} *************** *** 210,222 **** * One or more service registrars. */ ! private void registerService( final ServiceRegistrar[] registrars ) { ! ! AbstractService.log.info("Discovered "+registrars.length+" service registrars"); new Thread("Register Service") { public void run() { ! // Create an information item about a service ! item = new ServiceItem(serviceID, new TestServerImpl(), new Entry[] { new Comment("Test service(comment)"), // human facing comment. new Name("Test service(name)"), // human facing name. --- 183,199 ---- * One or more service registrars. */ + private void registerService(final ServiceRegistrar[] registrars) { ! log.info("Discovered " + registrars.length + " service registrars"); new Thread("Register Service") { public void run() { ! // the service ! impl = new TestServerImpl(); ! /* Create an information item about a service. ! * ! * @todo use Configuration? ServiceStarter? ! */ ! item = new ServiceItem(serviceID, impl.getProxy(), new Entry[] { new Comment("Test service(comment)"), // human facing comment. new Name("Test service(name)"), // human facing name. *************** *** 224,231 **** "Test Service (short description)"), // service type new MyStatus(StatusType.NORMAL), ! new Location("floor","room","building"), ! new Address("street", "organization", "organizationalUnit", ! "locality", "stateOrProvince", "postalCode", ! "country"), new ServiceInfo("bigdata", // product or package name "SYSTAP,LLC", // manufacturer --- 201,208 ---- "Test Service (short description)"), // service type new MyStatus(StatusType.NORMAL), ! new Location("floor", "room", "building"), ! new Address("street", "organization", ! "organizationalUnit", "locality", ! "stateOrProvince", "postalCode", "country"), new ServiceInfo("bigdata", // product or package name "SYSTAP,LLC", // manufacturer *************** *** 247,250 **** --- 224,247 ---- // Register the service. reg = registrar.register(item, Lease.FOREVER); + /* + * Setup automatic lease renewal. + * + * Note: A single lease manager can handle multiple services + * and the lease of a given service on multiple service + * registrars. It knows which lease is about to expire and + * preemptively extends the lease on the behalf of the + * registered service. It will notify the LeaseListener iff + * it is unable to renew a lease. + */ + log.info("lease will expire in " + + (reg.getLease().getExpiration() - System + .currentTimeMillis()) + "ms"); + leaseManager.renewUntil(reg.getLease(), + Lease.FOREVER, AbstractService.this); + /* + * Service has been registered and lease renewal is + * operating. + */ + break; } catch (RemoteException ex) { // retry until successful. *************** *** 254,286 **** } } - /* - * Setup automatic lease renewal. - * - * Note: A single lease manager can handle multiple services - * and the lease of a given service on multiple service - * registrars. It knows which lease is about to expire and - * preemptively extends the lease on the behalf of the - * registered service. It will notify the LeaseListener iff - * it is unable to renew a lease. - */ - AbstractService.log.info("lease will expire in " - + (reg.getLease().getExpiration() - System - .currentTimeMillis()) + "ms"); - leaseManager - .renewUntil(reg.getLease(), Lease.FOREVER, AbstractService.this); - /* - * Service has been registered and lease renewal is - * operating. - */ - break; } } ! } ! }.start() ! ; ! ! } ! /** * Log a message. --- 251,261 ---- } } } } ! } ! }.start(); ! } ! /** * Log a message. *************** *** 288,293 **** public void discarded(DiscoveryEvent arg0) { ! AbstractService.log.info(""); ! } --- 263,268 ---- public void discarded(DiscoveryEvent arg0) { ! log.info(""); ! } *************** *** 299,306 **** public void notify(LeaseRenewalEvent event) { ! AbstractService.log.error("Lease could not be renewed: " + event); ! } ! /** * Launch the server in a separate thread. --- 274,281 ---- public void notify(LeaseRenewalEvent event) { ! log.error("Lease could not be renewed: " + event); ! } ! /** * Launch the server in a separate thread. *************** *** 309,344 **** new Thread("launchServer") { public void run() { ! AbstractService.main(new String[] {}); } }.start(); } ! /** ! * Run the server. It will die after a timeout. ! * ! * @param args ! * Ignored. ! */ ! public static void main(String[] args) { ! final long lifespan = 3 * 60 * 1000; // life span in seconds. ! AbstractService.log.info("Will start test server."); ! AbstractService testServer = new AbstractService(){ ! /* @todo this is an anonymous class - each service must provide its ! * own main() and registration information. ! */ ! }; ! AbstractService.log.info("Started test server."); ! try { ! Thread.sleep(lifespan); ! } ! catch( InterruptedException ex ) { ! AbstractService.log.warn(ex); ! } ! /* ! * @todo This forces a hard reference to remain for the test server. ! */ ! AbstractService.log.info("Server will die: "+testServer); ! } ! /** * {@link Status} is abstract so a service needs to provide their own --- 284,333 ---- new Thread("launchServer") { public void run() { ! TestServer.main(new String[] {"org.CognitiveWeb.bigdata.jini.TestServer.config"}); } }.start(); + log.info("Service started."); } ! // /** ! // * Run the server. It will die after a timeout. ! // * ! // * @param args ! // * Ignored. ! // */ ! // public static void main(String[] args) { ! // final long lifespan = 5 * 1000; // life span in seconds. ! // log.info("Will start test server."); ! // AbstractService testServer = new AbstractService(); ! // log.info("Started test server."); ! // try { ! // Thread.sleep(lifespan); ! // } catch (InterruptedException ex) { ! // log.warn(ex); ! // } ! // /* ! // * Cancel the lease. ! // */ ! // try { ! // log.info("Canceling service lease."); ! // testServer.leaseManager.cancel(testServer.reg.getLease()); ! // } catch (Exception ex) { ! // log.error(ex); ! // } ! // /* ! // * Unexport the proxy, making the service no longer available. ! // */ ! // log.info("Unexporting the service proxy."); ! // testServer.impl.unexport(true); ! // ! // // /* ! // // * Note: The reference to the service instance here forces a hard ! // // * reference to remain for the test server. If you comment out this log ! // // * statement, then you need to do something else to hold onto the hard ! // // * reference. ! // // */ ! // // log.info("Server will die: "+testServer); ! // } ! /** * {@link Status} is abstract so a service needs to provide their own *************** *** 354,363 **** */ private static final long serialVersionUID = 3431522046169284463L; ! /** * Deserialization constructor (required). */ ! public MyStatus(){} ! public MyStatus(StatusType statusType) { --- 343,353 ---- */ private static final long serialVersionUID = 3431522046169284463L; ! /** * Deserialization constructor (required). */ ! public MyStatus() { ! } ! public MyStatus(StatusType statusType) { *************** *** 367,375 **** */ super(statusType); ! } ! } ! /** * {@link ServiceType} is abstract so a service basically needs to provide --- 357,365 ---- */ super(statusType); ! } ! } ! /** * {@link ServiceType} is abstract so a service basically needs to provide *************** *** 383,388 **** * </a> */ ! public static class MyServiceType extends ServiceType ! { /** --- 373,377 ---- * </a> */ ! public static class MyServiceType extends ServiceType { /** *************** *** 390,401 **** */ private static final long serialVersionUID = -2088608425852657477L; ! public String displayName; public String shortDescription; ! /** * Deserialization constructor (required). */ ! public MyServiceType() {} public MyServiceType(String displayName, String shortDescription) { --- 379,392 ---- */ private static final long serialVersionUID = -2088608425852657477L; ! public String displayName; + public String shortDescription; ! /** * Deserialization constructor (required). */ ! public MyServiceType() { ! } public MyServiceType(String displayName, String shortDescription) { *************** *** 403,443 **** this.shortDescription = shortDescription; } ! public String getDisplayName() { return displayName; } ! public String getShortDescription() { return shortDescription; } - - } - - /** - * The interfaces implemented by the service should be made locally - * available to the client so that it can execute methods on those - * interfaces without using reflection. - * - * @author <a href="mailto:tho...@us...">Bryan Thompson</a> - * @version $Id$ - */ - public static interface ITestService - { - /** - * Method for testing remote invocation. - */ - public void invoke(); - } /** ! * The proxy object that gets passed around. ! * ! * @todo It appears that multiple instances of this class are getting ! * created. This is consistent with the notion that the instance is ! * being "passed" around by state and not by reference. This implies ! * that instances are not consumed when they are discovered but merely ! * cloned using Java serialization. * * @version $Id$ --- 394,417 ---- this.shortDescription = shortDescription; } ! public String getDisplayName() { return displayName; } ! public String getShortDescription() { return shortDescription; } } /** ! * The remote service implementation object. This implements the ! * {@link Remote} interface and uses JERI to create a proxy for the remote ! * object and configure and manage the protocol for communications between ! * the client (service proxy) and the remote object (the service ! * implementation). ! * <p> ! * Note: You have to implement {@link JoinAdmin} in order to show up as an ! * administerable service (blue folder) in the jini Service Browser. * * @version $Id$ *************** *** 445,449 **** * </a> */ ! public static class TestServerImpl implements ITestService, Serializable { --- 419,423 ---- * </a> */ ! public static class TestServerImpl implements ProxyAccessor, ITestService/*, Serializable*/ { *************** *** 451,473 **** * Note: Mark the {@link Logger} as transient since we do NOT need to * serialize its state. */ ! public static final transient Logger log = Logger.getLogger(TestServerImpl.class); /** * */ ! private static final long serialVersionUID = -920558820563934297L; /** ! * De-serialization constructor (required). */ ! public TestServerImpl() { ! // System.err.println("Created: "+this); ! log.info("Created: "+this); } public void invoke() { ! // System.err.println("invoked: "+this); ! log.info("invoked: "+this); } --- 425,504 ---- * Note: Mark the {@link Logger} as transient since we do NOT need to * serialize its state. + * <p> + * + * @todo When the service uses a proxy and a remote communications + * protocol, the service instance is remote and this object is not + * instantiated on the client (test this hypothesis by removing + * log4j from the codebase). */ ! public static final transient Logger log = Logger ! .getLogger(TestServerImpl.class); ! ! private ITestService proxy; ! ! private Exporter exporter; /** + * Service constructor. * + * @todo modify to use ServiceStarter */ ! public TestServerImpl() { ! ! try { ! ! // @todo hardwired jeri exporter using TCP. ! exporter = new BasicJeriExporter(TcpServerEndpoint ! .getInstance(0), new BasicILFactory()); ! ! // export an object of this class ! proxy = (ITestService) exporter.export(this); ! log.info("Proxy is " + proxy + "(" + proxy.getClass() + ")"); ! ! } catch (Exception ex) { ! // @todo should we retry the operation? ! log.error(ex); ! throw new RuntimeException(ex); ! } ! ! log.info("Created: " + this); ! ! } ! ! public Object getProxy() { ! ! return proxy; ! ! } /** ! * Unexports the proxy. ! * ! * @param force ! * When true, the object is unexported even if there are ! * pending or in progress service requests. ! * ! * @return true iff the object is (or was) unexported. ! * ! * @see Exporter#unexport(boolean) */ ! public boolean unexport(boolean force) { ! ! if (exporter.unexport(true)) { ! ! proxy = null; ! ! return true; ! ! } ! ! return false; ! } public void invoke() { ! ! log.info("invoked: " + this); ! } |
From: Bryan T. <tho...@us...> - 2007-03-22 15:04:22
|
Update of /cvsroot/cweb/bigdata In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv20431 Modified Files: build.xml build.properties Log Message: Working on services. Added some JARs for dependencies to simplify deployment. Index: build.xml =================================================================== RCS file: /cvsroot/cweb/bigdata/build.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** build.xml 18 Mar 2007 22:29:43 -0000 1.2 --- build.xml 22 Mar 2007 15:04:16 -0000 1.3 *************** *** 1,3 **** ! <project name="bigdata" default="deploy" basedir="."> <property file="build.properties" /> --- 1,3 ---- ! <project name="bigdata" default="jar" basedir="."> <property file="build.properties" /> *************** *** 22,53 **** </target> - <!-- @todo drop dbcache, extser, concurrent. --> - <!-- FIXME Use JARs for other packages, NOT compiled classes. This is - especially important because of the licenses on some packages. --> <target name="compile" depends="prepare"> <mkdir dir="${build.dir}" /> <javac destdir="${build.dir}" classpathref="build.classpath" debug="on"> - <src path="${cweb.dir}/commons/src/java" /> - <src path="${cweb.dir}/concurrent/src/java" /> - <src path="${cweb.dir}/dbcache/src/java" /> - <src path="${cweb.dir}/extser/src/java" /> - <src path="${cweb.dir}/junit-ext/src/java" /> - <src path="${cweb.dir}/lgpl-utils/src/java" /> <src path="${bigdata.dir}/src/java" /> <src path="${bigdata.dir}/src/test" /> </javac> - <!-- - <copy toDir="${build.dir}/classes"> - <fileset dir="${src.dir}"> - <exclude name="**/*.java"/> - </fileset> - </copy> - --> </target> <target name="jar" depends="compile"> <jar destfile="${jar.name}"> <fileset dir="${build.dir}" /> <manifest> <attribute name="Main-Class" value="org/CognitiveWeb/bigdata/TestServiceDiscovery" /> </manifest> --- 22,47 ---- </target> <target name="compile" depends="prepare"> <mkdir dir="${build.dir}" /> <javac destdir="${build.dir}" classpathref="build.classpath" debug="on"> <src path="${bigdata.dir}/src/java" /> <src path="${bigdata.dir}/src/test" /> </javac> </target> + <!-- build the main jar. + + Note: clients share much of the bigadata java code since they require + access to local temporary stores and btrees for some operations. Also, + servers require client code (including the bulky ICU package) when they + run remote jobs on the behalf of clients. Therefore, there is point in + creating both a "client" and a "server" JAR. + --> <target name="jar" depends="compile"> <jar destfile="${jar.name}"> <fileset dir="${build.dir}" /> <manifest> + <!-- @todo could be main routine for services startup, or perhaps + a standalone instance startup. --> <attribute name="Main-Class" value="org/CognitiveWeb/bigdata/TestServiceDiscovery" /> </manifest> *************** *** 55,61 **** </target> ! <!-- Prepare a bigdata deployment. you need to copy the deployment directory ! to an HTTP server so that downloadable code can be resolved for activatable ! services, e.g., assuming: --- 49,57 ---- </target> ! <!-- The following are somewhat dated notes on using jini with downloadable ! code. ! ! You need to copy downloadable code to an HTTP server so that the classes can ! be resolved for activatable services, e.g., assuming: *************** *** 134,152 **** write a test to validate the pre- and post- conditions for deployment. --> <!-- add properties to build.properties for the http server location, ! failover sites, etc. --> <target name="deploy" depends="jar"> <copy toDir="${deploy.dir}"> <fileset dir="${bigdata.dir}/lib"> ! <!-- do not deploy the jini jars for download - the client must ! have them available locally, e.g., from the jini starter ! kit. --> ! <exclude name="reggie.jar" /> <exclude name="sun-util.jar" /> <exclude name="jini-core.jar" /> <exclude name="jini-ext.jar" /> ! <exclude name="**/*.dll" /> ! <exclude name="**/*.so" /> </fileset> <fileset dir="${bigdata.dir}/LEGAL"> </fileset> <fileset file="${jar.name}/"> --- 130,163 ---- write a test to validate the pre- and post- conditions for deployment. --> <!-- add properties to build.properties for the http server location, ! failover sites, network for service discovery, jeri protocol settings, ! etc. --> ! ! <!-- builds the basic bigdata deployment. ! ! Note: clients require access to the ICU libraries for encoding unicode ! keys. However, a server can operate as a client when running submitted ! jobs, so these libraries need to be deployed to server machines as well. ! ! @todo include an ant/shell/bat script for starting bigdata services or ! just a README? ! --> <target name="deploy" depends="jar"> <copy toDir="${deploy.dir}"> <fileset dir="${bigdata.dir}/lib"> ! <!-- review necessar jini dependencies for deployment. --> ! <exclude name="reggie.jar" /> <exclude name="sun-util.jar" /> <exclude name="jini-core.jar" /> <exclude name="jini-ext.jar" /> ! <!-- ICU4JNI is not a supported configuration at this time. --> ! <exclude name="**/icu4jni.jar" /> ! <exclude name="**/icu*.dll" /> ! <exclude name="**/ICU*.dll" /> ! <!-- The BytesUtil JNI class is not recommended at this time. --> ! <exclude name="**/*BytesUtil*" /> </fileset> <fileset dir="${bigdata.dir}/LEGAL"> + <!-- Not required in the distribution. --> + <exclude name="README.txt" /> </fileset> <fileset file="${jar.name}/"> Index: build.properties =================================================================== RCS file: /cvsroot/cweb/bigdata/build.properties,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** build.properties 17 Mar 2007 23:14:59 -0000 1.1 --- build.properties 22 Mar 2007 15:04:16 -0000 1.2 *************** *** 1,6 **** - cweb.dir=.. bigdata.dir=. build.dir=ant-build deploy.dir=ant-deploy ! codebase=http://proto.cognitiveweb.org/maven-repository/bigdata/jars/ ! jar.name=bigdata.jar \ No newline at end of file --- 1,6 ---- bigdata.dir=. + jar.name=bigdata.jar build.dir=ant-build deploy.dir=ant-deploy ! #codebase=http://proto.cognitiveweb.org/maven-repository/bigdata/jars/ ! |
From: Bryan T. <tho...@us...> - 2007-03-22 15:04:20
|
Update of /cvsroot/cweb/bigdata/src/java/com/bigdata/journal In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv20431/src/java/com/bigdata/journal Modified Files: ITxCommitProtocol.java Log Message: Working on services. Added some JARs for dependencies to simplify deployment. Index: ITxCommitProtocol.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/journal/ITxCommitProtocol.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ITxCommitProtocol.java 17 Mar 2007 23:14:59 -0000 1.2 --- ITxCommitProtocol.java 22 Mar 2007 15:04:15 -0000 1.3 *************** *** 69,73 **** * "prepare" message that validates the write set of the transaction and makes * it restart safe. finally, i have to coordinate the serialization of the wait ! * for the "commit" message. */ public interface ITxCommitProtocol { --- 69,75 ---- * "prepare" message that validates the write set of the transaction and makes * it restart safe. finally, i have to coordinate the serialization of the wait ! * for the "commit" message. (The write set of the transaction also needs to be ! * restart safe when it indicates that it has "prepared" so that a commit will ! * eventually succeed.) */ public interface ITxCommitProtocol { |
From: Bryan T. <tho...@us...> - 2007-03-22 15:04:20
|
Update of /cvsroot/cweb/bigdata/src/test/com/bigdata In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv20431/src/test/com/bigdata Modified Files: TestAll.java Log Message: Working on services. Added some JARs for dependencies to simplify deployment. Index: TestAll.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/test/com/bigdata/TestAll.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TestAll.java 21 Feb 2007 20:17:22 -0000 1.3 --- TestAll.java 22 Mar 2007 15:04:16 -0000 1.4 *************** *** 81,84 **** --- 81,85 ---- TestSuite suite = new TestSuite("bigdata"); + suite.addTest( com.bigdata.cache.TestAll.suite() ); suite.addTest( com.bigdata.io.TestAll.suite() ); suite.addTest( com.bigdata.util.TestAll.suite() ); |
From: Bryan T. <tho...@us...> - 2007-03-22 15:04:19
|
Update of /cvsroot/cweb/bigdata/src/test/org/CognitiveWeb/bigdata/nio In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv20431/src/test/org/CognitiveWeb/bigdata/nio Modified Files: TestPageServer.java Log Message: Working on services. Added some JARs for dependencies to simplify deployment. Index: TestPageServer.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/test/org/CognitiveWeb/bigdata/nio/TestPageServer.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TestPageServer.java 26 Aug 2006 19:30:55 -0000 1.1 --- TestPageServer.java 22 Mar 2007 15:04:14 -0000 1.2 *************** *** 75,81 **** import junit.framework.TestCase; ! import org.CognitiveWeb.bigdata.IPageServer; ! import org.CognitiveWeb.bigdata.OId; ! import org.CognitiveWeb.dbcache.DBCache; import org.apache.log4j.Logger; --- 75,81 ---- import junit.framework.TestCase; [...5856 lines suppressed...] ! //// public final Parameter ret; ! //// ! //// public Operation(String name,Parameter[] args,Parameter ret) { ! //// ! //// } ! //// ! //// }; ! //// ! //// public final static class Parameter { ! //// ! //// public final String name; ! //// public final int type; ! //// ! //// public Parameter( String name, int type, ) ! //// ! //// }; ! // ! // } } |
From: Bryan T. <tho...@us...> - 2007-03-22 15:04:18
|
Update of /cvsroot/cweb/bigdata/lib In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv20431/lib Added Files: lgpl-utils-1.0-b1-dev.jar start.jar cweb-junit-ext-1.1-b2-dev.jar cweb-extser-0.1-b2-dev.jar Removed Files: README.txt Log Message: Working on services. Added some JARs for dependencies to simplify deployment. --- README.txt DELETED --- --- NEW FILE: start.jar --- (This appears to be a binary file; contents omitted.) --- NEW FILE: lgpl-utils-1.0-b1-dev.jar --- (This appears to be a binary file; contents omitted.) --- NEW FILE: cweb-junit-ext-1.1-b2-dev.jar --- (This appears to be a binary file; contents omitted.) --- NEW FILE: cweb-extser-0.1-b2-dev.jar --- (This appears to be a binary file; contents omitted.) |
From: Bryan T. <tho...@us...> - 2007-03-22 15:04:18
|
Update of /cvsroot/cweb/bigdata/src/java/org/CognitiveWeb/bigdata In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv20431/src/java/org/CognitiveWeb/bigdata Removed Files: IPageServer.java SegmentServer.java clusterIndices.txt package.html ITransaction.java Catalog.java PageServer.java SegmentManager.java ILockManager.java LockServer.java ISegmentServer.java OId.java Log Message: Working on services. Added some JARs for dependencies to simplify deployment. --- ILockManager.java DELETED --- --- LockServer.java DELETED --- --- clusterIndices.txt DELETED --- --- SegmentServer.java DELETED --- --- package.html DELETED --- --- ISegmentServer.java DELETED --- --- Catalog.java DELETED --- --- PageServer.java DELETED --- --- ITransaction.java DELETED --- --- SegmentManager.java DELETED --- --- OId.java DELETED --- --- IPageServer.java DELETED --- |
From: Bryan T. <tho...@us...> - 2007-03-22 15:03:54
|
Update of /cvsroot/cweb/bigdata/src/java/com/bigdata/gom In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv20417/src/java/com/bigdata/gom Log Message: Directory /cvsroot/cweb/bigdata/src/java/com/bigdata/gom added to the repository |
From: Bryan T. <tho...@us...> - 2007-03-20 14:59:40
|
Update of /cvsroot/cweb/lgpl-utils/lib In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv16387/lib Added Files: junit-3.8.1.jar Log Message: Added POM and junit JAR to facilitate builds of the JAR artifact. --- NEW FILE: junit-3.8.1.jar --- (This appears to be a binary file; contents omitted.) |