Update of /cvsroot/cweb/bigdata/src/java/com/bigdata/journal In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv10595/src/java/com/bigdata/journal Modified Files: AbstractBufferStrategy.java ITransactionManager.java Name2Addr.java IJournal.java CommitRecord.java Tx.java ITx.java IAtomicStore.java AbstractTx.java TemporaryRawStore.java ReadCommittedTx.java Journal.java Added Files: ITxCommitProtocol.java ResourceManager.java AbstractJournal.java Removed Files: TransactionServer.java JournalServer.java Log Message: Refactoring to define service apis (data service, transaction manager service) and some approximate implementations of those services (not supporting service discovery, network protocol, or service robustness). Copied in the UML model so that it will actually get committed to CVS.... --- NEW FILE: AbstractJournal.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 [...1967 lines suppressed...] if (name == null) { throw new IllegalArgumentException(); } ITx tx = activeTx.get(ts); if (tx == null) { throw new IllegalStateException(); } return tx.getIndex(name); } } Index: IJournal.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/journal/IJournal.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** IJournal.java 11 Mar 2007 11:42:45 -0000 1.9 --- IJournal.java 15 Mar 2007 16:11:12 -0000 1.10 *************** *** 62,67 **** * @version $Id$ */ ! public interface IJournal extends IMROW, IAtomicStore, IIndexManager, ! ITransactionManager { /** --- 62,66 ---- * @version $Id$ */ ! public interface IJournal extends IMROW, IAtomicStore, IIndexManager { /** Index: CommitRecord.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/journal/CommitRecord.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** CommitRecord.java 12 Mar 2007 18:06:11 -0000 1.4 --- CommitRecord.java 15 Mar 2007 16:11:12 -0000 1.5 *************** *** 63,67 **** /** * @todo this may not be the correct commit counter unless this method is ! * synchronized with the commitService. * * @todo are commit counters global or local? --- 63,67 ---- /** * @todo this may not be the correct commit counter unless this method is ! * synchronized with the writeService. * * @todo are commit counters global or local? Index: Name2Addr.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/journal/Name2Addr.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Name2Addr.java 12 Mar 2007 18:06:11 -0000 1.6 --- Name2Addr.java 15 Mar 2007 16:11:12 -0000 1.7 *************** *** 181,188 **** // re-load btree from the store. btree = BTree.load(this.store, entry.addr); ! // save name -> btree mapping in transient cache. indexCache.put(name,btree); // return btree. return btree; --- 181,191 ---- // re-load btree from the store. btree = BTree.load(this.store, entry.addr); ! // save name -> btree mapping in transient cache. indexCache.put(name,btree); + // report event (loaded btree). + ResourceManager.openUnisolatedBTree(name); + // return btree. return btree; --- NEW FILE: ITxCommitProtocol.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 15, 2007 */ package com.bigdata.journal; import com.bigdata.service.IDataService; /** * An interface implemented by an {@link IDataService} for the commit / abort of * the local write set for a transaction as directed by a centralized * {@link ITransactionManager} in response to client requests. * <p> * Clients DO NOT make direct calls against this API. Instead, they MUST locate * the {@link ITransactionManager} service and direct messages to that service. * <p> * Note: These methods should be invoked iff the transaction manager knows that * the {@link IDataService} is buffering writes for the transaction. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> * @version $Id$ * * FIXME in order to support 2-/3-phase commit, the [commitTime] from the * transaction manager service must be passed through to the journal. There also * needs to be a distinct "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 { /** * Request commit of the transaction write set. */ public void commit(long tx); /** * Request abort of the transaction write set. */ public void abort(long tx); } Index: ITx.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/journal/ITx.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ITx.java 11 Mar 2007 11:42:44 -0000 1.6 --- ITx.java 15 Mar 2007 16:11:12 -0000 1.7 *************** *** 131,134 **** --- 131,139 ---- /** + * The type-safe isolation level for this transaction. + */ + public IsolationEnum getIsolationLevel(); + + /** * When true, the transaction will reject writes. */ *************** *** 136,139 **** --- 141,149 ---- /** + * When true, the transaction has an empty write set. + */ + public boolean isEmptyWriteSet(); + + /** * A transaction is "active" when it is created and remains active until it * prepares or aborts. An active transaction accepts READ, WRITE, DELETE, Index: TemporaryRawStore.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/journal/TemporaryRawStore.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TemporaryRawStore.java 6 Mar 2007 20:38:06 -0000 1.3 --- TemporaryRawStore.java 15 Mar 2007 16:11:13 -0000 1.4 *************** *** 111,117 **** /** ! * Create a {@link TemporaryRawStore} with an initial in-memory capacity of 10M ! * that will grow up to 100M before converting into a disk-based store ! * backed by a temporary file. * * @todo the memory growth strategy does not respect the in-memory maximum --- 111,122 ---- /** ! * Create a {@link TemporaryRawStore} with an initial in-memory capacity of ! * 10M that will grow up to 100M before converting into a disk-based store ! * backed by a temporary file. These defaults are appropriate for a ! * relatively small number of processes that will write a lot of data. If ! * you have a lot of processes then you need to be more conservative with ! * RAM in the initial allocation and switch over to disk sooner. For ! * example, transactions use smaller defaults in order to support a large ! * #of concurrent transactions without a large memory burden. * * @todo the memory growth strategy does not respect the in-memory maximum *************** *** 170,177 **** open = false; - // buf.close(); - // - // buf.deleteFile(); - buf.closeAndDelete(); --- 175,178 ---- *************** *** 241,244 **** --- 242,249 ---- try { + /* + * Note: this operation will transparently extend the in-memory + * buffer as necessary up to the specified maximum capacity. + */ return buf.write(data); Index: ITransactionManager.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/journal/ITransactionManager.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ITransactionManager.java 11 Mar 2007 11:42:45 -0000 1.4 --- ITransactionManager.java 15 Mar 2007 16:11:12 -0000 1.5 *************** *** 1,45 **** /** ! 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 Feb 19, 2007 --- 1,45 ---- /** ! 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 Feb 19, 2007 *************** *** 50,54 **** import com.bigdata.isolation.IConflictResolver; import com.bigdata.isolation.UnisolatedBTree; - import com.bigdata.objndx.IIndex; import com.bigdata.objndx.IndexSegment; --- 50,53 ---- *************** *** 62,73 **** /** - * Create a new fully-isolated read-write transaction. - * - * @return The transaction start time, which serves as the unique identifier - * for the transaction. - */ - public long newTx(); - - /** * Create a new transaction. * <p> --- 61,64 ---- *************** *** 107,135 **** public long newTx(IsolationEnum level); - // /** - // * Create a new fully-isolated transaction. - // * - // * @param readOnly - // * When true, the transaction will reject writes. - // * - // * @return The transaction start time, which serves as the unique identifier - // * for the transaction. - // */ - // public long newTx(boolean readOnly); - // - // /** - // * Create a new read-committed transaction. The transaction will reject - // * writes. Any data committed by concurrent transactions will become visible - // * to indices isolated by this transaction (hence, "read comitted"). - // * <p> - // * This provides more isolation than "read dirty" since the concurrent - // * transactions MUST commit before their writes become visible to the a - // * read-committed transaction. - // * - // * @return The transaction start time, which serves as the unique identifier - // * for the transaction. - // */ - // public long newReadCommittedTx(); - /** * Abort the transaction. --- 98,101 ---- *************** *** 150,154 **** * The transaction start time, which serves as the unique * identifier for the transaction. ! * * @return The commit timestamp assigned to the transaction. * --- 116,120 ---- * The transaction start time, which serves as the unique * identifier for the transaction. ! * * @return The commit timestamp assigned to the transaction. * *************** *** 156,160 **** * if there is no active transaction with that timestamp. */ ! public long commit(long startTime); } --- 122,126 ---- * if there is no active transaction with that timestamp. */ ! public long commit(long startTime) throws ValidationError; } --- TransactionServer.java DELETED --- Index: Tx.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/journal/Tx.java,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** Tx.java 12 Mar 2007 18:06:11 -0000 1.36 --- Tx.java 15 Mar 2007 16:11:12 -0000 1.37 *************** *** 92,100 **** * @version $Id$ * ! * @todo track whether or not the transaction has written any isolated data. do ! * this at the same time that I modify the isolated indices use a * delegation strategy so that I can trap attempts to access an isolated ! * index once the transaction is no longer active. define "active" as ! * up to the point where a "commit" or "abort" is _requested_ for the tx. * * @todo Support transactions where the indices isolated by the transactions are --- 92,111 ---- * @version $Id$ * ! * @todo In order to support a distributed transaction commit protocol the write ! * set of a validated transaction needs to be made restart safe without ! * making it restart safe on the corresponding unisolated index on the ! * journal. It may be that the right thing to do is to write the validated ! * data onto the unisolated indices but not commit the journal and not ! * permit other unisolated writes until the commit message arives, e.g., ! * block in the {@link AbstractJournal#writeService} waiting on the commit ! * message. A timeout would cause the buffered writes to be discarded (by ! * an abort). ! * ! * @todo track whether or not the transaction has written any isolated data (I ! * currently rangeCount the isolated indices in {@link #isEmptyWriteSet()}). ! * do this at the same time that I modify the isolated indices use a * delegation strategy so that I can trap attempts to access an isolated ! * index once the transaction is no longer active. define "active" as up ! * to the point where a "commit" or "abort" is _requested_ for the tx. * * @todo Support transactions where the indices isolated by the transactions are *************** *** 167,173 **** * {@link #prepare()} and {@link #commit()} will be NOPs. */ ! public Tx(Journal journal, long startTime, boolean readOnly) { ! super(journal, startTime, readOnly); /* --- 178,185 ---- * {@link #prepare()} and {@link #commit()} will be NOPs. */ ! public Tx(AbstractJournal journal, long startTime, boolean readOnly) { ! super(journal, startTime, readOnly ? IsolationEnum.ReadOnly ! : IsolationEnum.ReadWrite); /* *************** *** 315,321 **** if (!isActive()) { ! ! throw new IllegalStateException(); ! } --- 327,333 ---- if (!isActive()) { ! ! throw new IllegalStateException(NOT_ACTIVE); ! } *************** *** 360,363 **** --- 372,378 ---- // writeable index backed by the temp. store. index = new IsolatedBTree(tmpStore,src); + + // report event. + ResourceManager.isolateIndex(startTime, name); } *************** *** 371,373 **** --- 386,417 ---- } + final public boolean isEmptyWriteSet() { + + if(isReadOnly()) { + + // Read-only transactions always have empty write sets. + return true; + + } + + Iterator<IIsolatedIndex> itr = btrees.values().iterator(); + + while(itr.hasNext()) { + + IsolatedBTree ndx = (IsolatedBTree) itr.next(); + + if(!ndx.isEmptyWriteSet()) { + + // At least one isolated index was written on. + + return false; + + } + + } + + return true; + + } + } Index: Journal.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/journal/Journal.java,v retrieving revision 1.61 retrieving revision 1.62 diff -C2 -d -r1.61 -r1.62 *** Journal.java 12 Mar 2007 18:06:11 -0000 1.61 --- Journal.java 15 Mar 2007 16:11:13 -0000 1.62 *************** *** 80,946 **** /** ! * <p> ! * The {@link Journal} is an append-only persistence capable data structure ! * supporting atomic commit, named indices, and transactions. Writes are ! * logically appended to the journal to minimize disk head movement. ! * </p> ! * <p> ! * Commit processing. The journal maintains two root blocks. Commit updates the ! * root blocks using the Challis algorithm. (The root blocks are updated using [...1773 lines suppressed...] - } - - return tx; - - } - - public IIndex getIndex(String name, long ts) { - - if(name == null) throw new IllegalArgumentException(); - - ITx tx = activeTx.get(ts); - - if(tx==null) throw new IllegalStateException(); - - return tx.getIndex(name); - - } } --- 146,149 ---- Index: ReadCommittedTx.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/journal/ReadCommittedTx.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ReadCommittedTx.java 12 Mar 2007 18:06:11 -0000 1.2 --- ReadCommittedTx.java 15 Mar 2007 16:11:13 -0000 1.3 *************** *** 92,98 **** public class ReadCommittedTx extends AbstractTx implements ITx { ! public ReadCommittedTx(Journal journal, long startTime ) { ! super(journal, startTime, true /*readOnly*/); } --- 92,107 ---- public class ReadCommittedTx extends AbstractTx implements ITx { ! public ReadCommittedTx(AbstractJournal journal, long startTime ) { ! super(journal, startTime, IsolationEnum.ReadCommitted); ! ! } ! ! /** ! * The write set is always empty. ! */ ! final public boolean isEmptyWriteSet() { ! ! return true; } *************** *** 106,109 **** --- 115,124 ---- public IIndex getIndex(String name) { + if (!isActive()) { + + throw new IllegalStateException(NOT_ACTIVE); + + } + if (journal.getIndex(name) == null) { --- NEW FILE: ResourceManager.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 13, 2007 */ package com.bigdata.journal; import java.text.NumberFormat; import org.apache.log4j.Level; import org.apache.log4j.Logger; import com.bigdata.objndx.IndexSegment; import com.bigdata.objndx.IndexSegmentBuilder; import com.bigdata.rawstore.Bytes; import com.bigdata.scaleup.MasterJournal; /** * This class is responsible for integrating events that report on resource * consumption and latency and taking actions that may seek to minimize latency * or resource consumption. * <p> * Resource consumption events include * <ol> * <li>mutable unisolated indices open on the journal</li> * <li>mutable isolated indices open in writable transactions</li> * <li>historical read-only indices open on old journals</li> * <li>historical read-only index segments</li> * </ol> * * The latter two classes of event sources exist iff {@link Journal#overflow()} * is handled by creating a new {@link Journal} and evicting data from the old * {@link Journal} asynchronously onto read-optimized {@link IndexSegment}s. * * Other resource consumption events deal directly with transactions * <ol> * <li>open a transaction</li> * <li>close a transaction</li> * <li>a heartbeat for each write operation on a transaction is used to update * the resource consumption of the store</li> * </ol> * * <p> * Latency events include * <ol> * <li>request latency, that is, the time that a request waits on a queue * before being serviced</li> * <li>transactions per second</li> * </ol> * * @todo report the partition identifier as part of the index segment events. * * @todo use a hard reference queue to track recently used AbstractBTrees. a a * public referenceCount field on AbstractBTree and close the * AbstractBTree on eviction from the hard reference queue iff the * referenceCount is zero (no references to that AbstractBTree remain on * the hard reference queue). * * @todo consider handling close out of index partitions "whole at once" to * include all index segments in the current view of that partition. this * probably does not matter might be a nicer level of aggregation than the * individual index segment. * * @todo this still does not suggest a mechanism for close by timeout. one * solutions is to just close down all open indices if the server quieses. * if the server is not quiesent then unused indices will get shutdown in * any case. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> * @version $Id$ */ public class ResourceManager { /** * Logger. * * @todo change the logger configuration to write on a JMS queue or JINI * discovered service in order to aggregate results from multiple * hosts in a scale-out solution. * * @todo a scale-out solution will need to report the data service identity * with each event so that we can model load by data service and host. * * @todo actions taken based on this information must be directed to the * appropriate data service. */ public static final Logger log = Logger.getLogger(ResourceManager.class); /** * True iff the {@link #log} level is INFO or less. */ final public static boolean INFO = log.getEffectiveLevel().toInt() <= Level.INFO .toInt(); static NumberFormat cf; static NumberFormat fpf; static { cf = NumberFormat.getNumberInstance(); cf.setGroupingUsed(true); fpf = NumberFormat.getNumberInstance(); fpf.setGroupingUsed(false); fpf.setMaximumFractionDigits(2); } // /* // * Unisolated index reporting. // */ // private Map<String/*name*/,Counters> unisolated = new ConcurrentHashMap<String, Counters>(); /** * Report opening of a mutable unisolated named index on an {@link IJournal}. * * @param name * The index name. */ static public void openUnisolatedBTree(String name) { if(INFO) log.info("name="+name); } /** * Report closing of a mutable unisolated named index on an {@link IJournal}. * * @param name * The index name. * * @todo never invoked since we do not explicitly close out indices and are * not really able to differentiate the nature of the index when it is * finalized (unisolated vs isolated vs index segment can be * identified based on their interfaces). */ static public void closeUnisolatedBTree(String name) { if(INFO) log.info("name="+name); } /** * Report drop of a named unisolated index. * * @param name * The index name. */ static public void dropUnisolatedBTree(String name) { if(INFO) log.info("name="+name); } /* * Index segment reporting. */ /** * Report that an {@link IndexSegment} has been opened. * * @param name * The index name or null if this is not a named index. * @param filename * The name of the file containing the {@link IndexSegment}. * @param nbytes * The size of that file in bytes. * * @todo memory burden depends on the buffered data (nodes or nodes + * leaves) * * @todo the index name is not being reported since it is not part of the * extension metadata record at this time. this means that we can not * aggregate events for index segments for a given named index at this * time. */ static public void openIndexSegment(String name, String filename, long nbytes) { if(INFO) log.info("name="+name+", filename="+filename+", #bytes="+nbytes); } /** * Report that an {@link IndexSegment} has been closed. * * @param filename * * @todo we do not close out index segments based on non-use (e.g., timeout * or LRU). */ static public void closeIndexSegment(String filename) { if(INFO) log.info("filename="+filename); } /** * Report on a bulk merge/build of an {@link IndexSegment}. * * @param name * The index name or null if this is not a named index. * @param filename * The name of the file on which the index segment was written. * @param nentries * The #of entries in the {@link IndexSegment}. * @param elapsed * The elapsed time of the operation that built the index segment * (merge + build). * @param nbytes * The #of bytes in the {@link IndexSegment}. * * @todo the event is reported from {@link IndexSegmentBuilder} and does not * report the index name and does not account for resources * (time/space) required by the merge aspect of a bulk build. */ static public void buildIndexSegment(String name, String filename, int nentries, long elapsed, long nbytes) { if (INFO) { // data rate in MB/sec. float mbPerSec = (elapsed == 0 ? 0 : nbytes / Bytes.megabyte32 / (elapsed / 1000f)); log.info("name=" + name + ", filename=" + filename + ", nentries=" + nentries + ", elapsed=" + elapsed + ", " + fpf.format(((double) nbytes / Bytes.megabyte32)) + "MB" + ", rate=" + fpf.format(mbPerSec) + "MB/sec"); } } /* * Transaction reporting. * * @todo the clock time for a distributed transaction can be quite different * from the time that a given transaction was actually open on a given data * service. the former is simply [commitTime - startTime] while the latter * depends on the clock times at which the transaction was opened and closed * on the data service. */ /** * Report the start of a new transaction. * * @param startTime * Both the transaction identifier and its global start time. * @param level * The isolation level of the transaction. */ static public void openTx(long startTime, IsolationEnum level) { if(INFO) log.info("tx="+startTime+", level="+level); } /** * Report completion of a transaction. * * @param startTime * The transaction identifier. * @param commitTime * The commit timestamp (non-zero iff this was a writable * transaction that committed successfully and zero otherwise). * @param aborted * True iff the transaction aborted vs completing successfully. */ static public void closeTx(long startTime, long commitTime, boolean aborted) { if(INFO) log.info("tx=" + startTime + ", commitTime=" + commitTime + ", aborted=" + aborted + ", elapsed=" + (commitTime - startTime)); } /** * Report the extension of the {@link TemporaryRawStore} associated with a * transaction and whether or not it has spilled onto the disk. * * @param startTime * The transaction identifier. * @param nbytes * The #of bytes written on the {@link TemporaryRawStore} for * that transaction. * @param onDisk * True iff the {@link TemporaryRawStore} has spilled over to * disk for the transaction. * * @todo event is not reported. */ static public void extendTx(long startTime, long nbytes, boolean onDisk) { } /** * Report the isolation of a named index by a transaction. * * @param startTime * The transaction identifier. * @param name * The index name. */ static public void isolateIndex(long startTime, String name) { if(INFO) log.info("tx="+startTime+", name="+name); /* * Note: there is no separate close for isolated indices - they are * closed when the transaction commits or aborts. read-write indices can * not be closed before the transactions completes, but read-only * indices can be closed early and reopened as required. read-committed * indices are always changing over to the most current committed state * for an index. both read-only and read-committed indices MAY be shared * by more than one transaction (@todo verify that the protocol for * sharing is in place on the journal). */ } /* * Journal file reporting. */ /** * Report the opening of an {@link IJournal} resource. * * @param filename * The filename or null iff the journal was not backed by a file. * @param nbytes * The total #of bytes available on the journal. * @param bufferMode * The buffer mode in use by the journal. */ static public void openJournal(String filename, long nbytes, BufferMode bufferMode) { if(INFO) log.info("filename="+filename+", #bytes="+nbytes+", mode="+bufferMode); } /** * Report the extension of an {@link IJournal}. * * @param filename * The filename or null iff the journal was not backed by a file. * @param nbytes * The total #of bytes available (vs written) on the journal. * * @todo this does not differentiate between extension of a buffer backing a * journal and extension of a {@link TemporaryRawStore}. This means * that the resources allocated to a transaction vs the unisolated * indices on a journal can not be differentiated. */ static public void extendJournal(String filename, long nbytes) { if(INFO) log.info("filename="+filename+", #bytes="+nbytes); } /** * Report an overflow event. * * @param filename * The filename or null iff the journal was not backed by a file. * @param nbytes * The total #of bytes written on the journal. */ static public void overflowJournal(String filename, long nbytes) { if(INFO) log.info("filename="+filename+", #bytes="+nbytes); } /** * Report close of an {@link IJournal} resource. * * @param filename * The filename or null iff the journal was not backed by a file. */ static public void closeJournal(String filename) { if(INFO) log.info("filename="+filename); } /** * Report deletion of an {@link IJournal} resource. * * @param filename * The filename or null iff the journal was not backed by a file. * * @todo also report deletion of resources for journals that were already * closed but not yet deleted pending client leases or updates of the * metadata index (in the {@link MasterJournal}). */ static public void deleteJournal(String filename) { if(INFO) log.info("filename="+filename); } } Index: AbstractTx.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/journal/AbstractTx.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AbstractTx.java 11 Mar 2007 11:42:45 -0000 1.3 --- AbstractTx.java 15 Mar 2007 16:11:13 -0000 1.4 *************** *** 69,73 **** * commit protocol and to locate the named indices that it isolates. */ ! final protected Journal journal; /** --- 69,73 ---- * commit protocol and to locate the named indices that it isolates. */ ! final protected AbstractJournal journal; /** *************** *** 97,103 **** final protected boolean readOnly; private RunState runState; ! protected AbstractTx(Journal journal, long startTime, boolean readOnly ) { if (journal == null) --- 97,109 ---- final protected boolean readOnly; + /** + * The type-safe enumeration representing the isolation level of this + * transaction. + */ + final protected IsolationEnum level; + private RunState runState; ! protected AbstractTx(AbstractJournal journal, long startTime, IsolationEnum level ) { if (journal == null) *************** *** 110,115 **** this.startTime = startTime; ! this.readOnly = readOnly; // pre-compute the hash code for the transaction. this.hashCode = Long.valueOf(startTime).hashCode(); --- 116,123 ---- this.startTime = startTime; ! this.readOnly = level != IsolationEnum.ReadWrite;; + this.level = level; + // pre-compute the hash code for the transaction. this.hashCode = Long.valueOf(startTime).hashCode(); *************** *** 119,122 **** --- 127,133 ---- this.runState = RunState.Active; + // report event. + ResourceManager.openTx(startTime, level); + } *************** *** 178,182 **** } ! final public boolean isReadOnly() { --- 189,199 ---- } ! ! final public IsolationEnum getIsolationLevel() { ! ! return level; ! ! } ! final public boolean isReadOnly() { *************** *** 226,229 **** --- 243,248 ---- journal.completedTx(this); + ResourceManager.closeTx(startTime, commitTime, true); + } finally { *************** *** 344,347 **** --- 363,368 ---- journal.completedTx(this); + ResourceManager.closeTx(startTime, commitTime, false); + } catch( Throwable t) { Index: IAtomicStore.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/journal/IAtomicStore.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** IAtomicStore.java 12 Mar 2007 18:06:11 -0000 1.6 --- IAtomicStore.java 15 Mar 2007 16:11:13 -0000 1.7 *************** *** 61,70 **** /** ! * Abandon the current write set. */ public void abort(); /** ! * Request an atomic commit. * * @return The timestamp assigned to the {@link ICommitRecord} -or- 0L if --- 61,70 ---- /** ! * Abandon the current write set (immediate, synchronous). */ public void abort(); /** ! * Atomic commit (immediate, synchronous). * * @return The timestamp assigned to the {@link ICommitRecord} -or- 0L if --- JournalServer.java DELETED --- Index: AbstractBufferStrategy.java =================================================================== RCS file: /cvsroot/cweb/bigdata/src/java/com/bigdata/journal/AbstractBufferStrategy.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** AbstractBufferStrategy.java 6 Mar 2007 20:38:06 -0000 1.12 --- AbstractBufferStrategy.java 15 Mar 2007 16:11:12 -0000 1.13 *************** *** 159,162 **** --- 159,166 ---- */ truncate( newExtent ); + + // report event. + ResourceManager.extendJournal(getFile() == null ? null : getFile() + .toString(), newExtent); // Retry the write operation. |