From: <sgo...@us...> - 2010-09-14 17:52:29
|
Revision: 3547 http://bigdata.svn.sourceforge.net/bigdata/?rev=3547&view=rev Author: sgossard Date: 2010-09-14 17:52:22 +0000 (Tue, 14 Sep 2010) Log Message: ----------- [maven_scaleout] : Breaking transitive dependency cycle between util, io, and counters packages. Modified Paths: -------------- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegmentCheckpoint.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/AbstractJournal.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/FileMetadata.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/RWStrategy.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/RootBlockView.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/TemporaryRawStore.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/rwstore/BlobAllocator.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/rwstore/FixedAllocator.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/rwstore/RWStore.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/journal/TestAbort.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/journal/TestRollbackCommit.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/journal/TestRootBlockView.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/util/TestChecksumUtility.java Added Paths: ----------- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/io/ChecksumUtility.java Removed Paths: ------------- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/util/ChecksumUtility.java Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegmentCheckpoint.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegmentCheckpoint.java 2010-09-14 17:41:47 UTC (rev 3546) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegmentCheckpoint.java 2010-09-14 17:52:22 UTC (rev 3547) @@ -37,7 +37,7 @@ import com.bigdata.journal.RootBlockException; import com.bigdata.rawstore.Bytes; import com.bigdata.rawstore.IAddressManager; -import com.bigdata.util.ChecksumUtility; +import com.bigdata.io.ChecksumUtility; /** * The checkpoint record for an {@link IndexSegment}. Copied: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/io/ChecksumUtility.java (from rev 3544, branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/util/ChecksumUtility.java) =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/io/ChecksumUtility.java (rev 0) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/io/ChecksumUtility.java 2010-09-14 17:52:22 UTC (rev 3547) @@ -0,0 +1,160 @@ +/** + +Copyright (C) SYSTAP, LLC 2006-2007. All rights reserved. + +Contact: + SYSTAP, LLC + 4501 Tower Road + Greensboro, NC 27410 + lic...@bi... + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +/* + * Created on Nov 5, 2006 + */ + +package com.bigdata.io; + +import java.nio.BufferUnderflowException; +import java.nio.ByteBuffer; +import java.util.zip.Adler32; + +/** + * Utility class for computing the {@link Adler32} checksum of a buffer. This + * class is NOT thread-safe. + * + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id$ + */ +public class ChecksumUtility { + + private static ThreadLocal threadChk = new ThreadLocal(); + /** + * static access to a ThreadLocal Checksum utility + * + * @return the ChecksumUtility + */ + public static ChecksumUtility getCHK() { + ChecksumUtility chk = (ChecksumUtility) threadChk.get(); + + if (chk == null) { + chk = new ChecksumUtility(); + threadChk.set(chk); + } + + return chk; + } + + /** + * Private helper object. + */ + private final Adler32 chk = new Adler32(); + + /** + * Compute the {@link Adler32} checksum of the buffer. The position, + * mark, and limit are unchanged by this operation. The operation is + * optimized when the buffer is backed by an array. + * + * @param buf + * The buffer. + * @param pos + * The starting position. + * @param limit + * The limit. + * + * @return The checksum. + */ + public int checksum(final ByteBuffer buf, final int pos, final int limit) { + + assert buf != null; + assert pos >= 0; + assert limit > pos; + + // reset before computing the checksum. + chk.reset(); + + if (buf.hasArray()) { + + /* + * Optimized when the buffer is backed by an array. + */ + + final byte[] bytes = buf.array(); + + final int len = limit - pos; + + if (pos > bytes.length - len) { + + throw new BufferUnderflowException(); + + } + + chk.update(bytes, pos + buf.arrayOffset(), len); + + } else { + + for (int i = pos; i < limit; i++) { + + chk.update(buf.get(i)); + + } + + } + + /* + * The Adler checksum is a 32-bit value. + */ + + return (int) chk.getValue(); + + } + + public int checksum(final IByteArraySlice slice) { + + assert slice != null; + + // reset before computing the checksum. + chk.reset(); + + chk.update(slice.array(), slice.off(), slice.len()); + + /* + * The Adler checksum is a 32-bit value. + */ + + return (int) chk.getValue(); + + } + + public int checksum(final byte[] buf, int sze) { + return checksum(buf, 0, sze); + } + + public int checksum(final byte[] buf, int off, int sze) { + + assert buf != null; + + // reset before computing the checksum. + chk.reset(); + + chk.update(buf, off, sze); + + /* + * The Adler checksum is a 32-bit value. + */ + + return (int) chk.getValue(); + } +} Property changes on: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/io/ChecksumUtility.java ___________________________________________________________________ Added: svn:keywords + Id Date Revision Author HeadURL Added: svn:eol-style + native Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/AbstractJournal.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/AbstractJournal.java 2010-09-14 17:41:47 UTC (rev 3546) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/AbstractJournal.java 2010-09-14 17:52:22 UTC (rev 3547) @@ -41,6 +41,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock; import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock; +import com.bigdata.io.ChecksumUtility; import org.apache.log4j.Logger; import com.bigdata.BigdataStatics; @@ -70,7 +71,6 @@ import com.bigdata.rawstore.WormAddressManager; import com.bigdata.relation.locator.IResourceLocator; import com.bigdata.resources.ResourceManager; -import com.bigdata.util.ChecksumUtility; /** * <p> Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/FileMetadata.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/FileMetadata.java 2010-09-14 17:41:47 UTC (rev 3546) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/FileMetadata.java 2010-09-14 17:52:22 UTC (rev 3547) @@ -31,6 +31,7 @@ import java.nio.channels.FileChannel; import java.util.UUID; +import com.bigdata.io.ChecksumUtility; import org.apache.log4j.Logger; import com.bigdata.io.DirectBufferPool; @@ -38,7 +39,6 @@ import com.bigdata.io.IReopenChannel; import com.bigdata.rawstore.Bytes; import com.bigdata.rawstore.WormAddressManager; -import com.bigdata.util.ChecksumUtility; /** * Helper object used when opening or creating journal file in any of the Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/RWStrategy.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/RWStrategy.java 2010-09-14 17:41:47 UTC (rev 3546) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/RWStrategy.java 2010-09-14 17:52:22 UTC (rev 3547) @@ -30,10 +30,10 @@ import java.io.IOException; import java.io.RandomAccessFile; import java.nio.ByteBuffer; -import java.nio.channels.ClosedByInterruptException; import java.nio.channels.FileChannel; import java.util.UUID; +import com.bigdata.io.ChecksumUtility; import org.apache.log4j.Logger; import com.bigdata.counters.CounterSet; @@ -41,7 +41,6 @@ import com.bigdata.rawstore.AbstractRawStore; import com.bigdata.rawstore.IAddressManager; import com.bigdata.rwstore.RWStore; -import com.bigdata.util.ChecksumUtility; /** * The hook that accesses the RWStore to provide read/write services as opposed Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/RootBlockView.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/RootBlockView.java 2010-09-14 17:41:47 UTC (rev 3546) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/RootBlockView.java 2010-09-14 17:52:22 UTC (rev 3547) @@ -30,6 +30,7 @@ import java.nio.ByteBuffer; import java.util.UUID; +import com.bigdata.io.ChecksumUtility; import org.apache.log4j.Logger; import com.bigdata.btree.IndexMetadata; @@ -38,7 +39,6 @@ import com.bigdata.rawstore.WormAddressManager; import com.bigdata.resources.ResourceManager; import com.bigdata.rwstore.RWStore; -import com.bigdata.util.ChecksumUtility; /** * A view onto a root block of the {@link Journal}. Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/TemporaryRawStore.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/TemporaryRawStore.java 2010-09-14 17:41:47 UTC (rev 3546) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/TemporaryRawStore.java 2010-09-14 17:52:22 UTC (rev 3547) @@ -44,7 +44,7 @@ import com.bigdata.rawstore.IMRMW; import com.bigdata.rawstore.WormAddressManager; import com.bigdata.relation.locator.ILocatableResource; -import com.bigdata.util.ChecksumUtility; +import com.bigdata.io.ChecksumUtility; /** * A non-restart-safe store for temporary data that buffers data in memory until Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/rwstore/BlobAllocator.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/rwstore/BlobAllocator.java 2010-09-14 17:41:47 UTC (rev 3546) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/rwstore/BlobAllocator.java 2010-09-14 17:52:22 UTC (rev 3547) @@ -5,9 +5,8 @@ import java.io.DataOutputStream; import java.io.IOException; import java.util.ArrayList; -import java.util.Iterator; -import com.bigdata.util.ChecksumUtility; +import com.bigdata.io.ChecksumUtility; /** * BlobAllocator Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/rwstore/FixedAllocator.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/rwstore/FixedAllocator.java 2010-09-14 17:41:47 UTC (rev 3546) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/rwstore/FixedAllocator.java 2010-09-14 17:52:22 UTC (rev 3547) @@ -27,10 +27,9 @@ import java.util.*; import java.io.*; +import com.bigdata.io.ChecksumUtility; import org.apache.log4j.Logger; -import com.bigdata.util.ChecksumUtility; - /** * FixedAllocator * Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/rwstore/RWStore.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/rwstore/RWStore.java 2010-09-14 17:41:47 UTC (rev 3546) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/rwstore/RWStore.java 2010-09-14 17:52:22 UTC (rev 3547) @@ -45,7 +45,7 @@ import com.bigdata.journal.FileMetadata; import com.bigdata.journal.IRootBlockView; import com.bigdata.journal.RWStrategy.FileMetadataView; -import com.bigdata.util.ChecksumUtility; +import com.bigdata.io.ChecksumUtility; /** * Storage class Deleted: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/util/ChecksumUtility.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/util/ChecksumUtility.java 2010-09-14 17:41:47 UTC (rev 3546) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/util/ChecksumUtility.java 2010-09-14 17:52:22 UTC (rev 3547) @@ -1,162 +0,0 @@ -/** - -Copyright (C) SYSTAP, LLC 2006-2007. All rights reserved. - -Contact: - SYSTAP, LLC - 4501 Tower Road - Greensboro, NC 27410 - lic...@bi... - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; version 2 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -/* - * Created on Nov 5, 2006 - */ - -package com.bigdata.util; - -import java.nio.BufferUnderflowException; -import java.nio.ByteBuffer; -import java.util.zip.Adler32; - -import com.bigdata.io.IByteArraySlice; - -/** - * Utility class for computing the {@link Adler32} checksum of a buffer. This - * class is NOT thread-safe. - * - * @author <a href="mailto:tho...@us...">Bryan Thompson</a> - * @version $Id$ - */ -public class ChecksumUtility { - - private static ThreadLocal threadChk = new ThreadLocal(); - /** - * static access to a ThreadLocal Checksum utility - * - * @return the ChecksumUtility - */ - public static ChecksumUtility getCHK() { - ChecksumUtility chk = (ChecksumUtility) threadChk.get(); - - if (chk == null) { - chk = new ChecksumUtility(); - threadChk.set(chk); - } - - return chk; - } - - /** - * Private helper object. - */ - private final Adler32 chk = new Adler32(); - - /** - * Compute the {@link Adler32} checksum of the buffer. The position, - * mark, and limit are unchanged by this operation. The operation is - * optimized when the buffer is backed by an array. - * - * @param buf - * The buffer. - * @param pos - * The starting position. - * @param limit - * The limit. - * - * @return The checksum. - */ - public int checksum(final ByteBuffer buf, final int pos, final int limit) { - - assert buf != null; - assert pos >= 0; - assert limit > pos; - - // reset before computing the checksum. - chk.reset(); - - if (buf.hasArray()) { - - /* - * Optimized when the buffer is backed by an array. - */ - - final byte[] bytes = buf.array(); - - final int len = limit - pos; - - if (pos > bytes.length - len) { - - throw new BufferUnderflowException(); - - } - - chk.update(bytes, pos + buf.arrayOffset(), len); - - } else { - - for (int i = pos; i < limit; i++) { - - chk.update(buf.get(i)); - - } - - } - - /* - * The Adler checksum is a 32-bit value. - */ - - return (int) chk.getValue(); - - } - - public int checksum(final IByteArraySlice slice) { - - assert slice != null; - - // reset before computing the checksum. - chk.reset(); - - chk.update(slice.array(), slice.off(), slice.len()); - - /* - * The Adler checksum is a 32-bit value. - */ - - return (int) chk.getValue(); - - } - - public int checksum(final byte[] buf, int sze) { - return checksum(buf, 0, sze); - } - - public int checksum(final byte[] buf, int off, int sze) { - - assert buf != null; - - // reset before computing the checksum. - chk.reset(); - - chk.update(buf, off, sze); - - /* - * The Adler checksum is a 32-bit value. - */ - - return (int) chk.getValue(); - } -} Modified: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/journal/TestAbort.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/journal/TestAbort.java 2010-09-14 17:41:47 UTC (rev 3546) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/journal/TestAbort.java 2010-09-14 17:52:22 UTC (rev 3547) @@ -35,7 +35,7 @@ import com.bigdata.btree.IndexMetadata; import com.bigdata.cache.IGlobalLRU.ILRUCache; import com.bigdata.io.DirectBufferPool; -import com.bigdata.util.ChecksumUtility; +import com.bigdata.io.ChecksumUtility; /** * Test the ability to abort (discard an uncommitted write set). This is a test Modified: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/journal/TestRollbackCommit.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/journal/TestRollbackCommit.java 2010-09-14 17:41:47 UTC (rev 3546) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/journal/TestRollbackCommit.java 2010-09-14 17:52:22 UTC (rev 3547) @@ -29,7 +29,7 @@ import java.nio.ByteBuffer; -import com.bigdata.util.ChecksumUtility; +import com.bigdata.io.ChecksumUtility; /** * Test the ability to rollback a commit. Modified: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/journal/TestRootBlockView.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/journal/TestRootBlockView.java 2010-09-14 17:41:47 UTC (rev 3546) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/journal/TestRootBlockView.java 2010-09-14 17:52:22 UTC (rev 3547) @@ -31,11 +31,11 @@ import java.util.Random; import java.util.UUID; +import com.bigdata.io.ChecksumUtility; import junit.framework.TestCase2; import com.bigdata.rawstore.TestWormAddressManager; import com.bigdata.rawstore.WormAddressManager; -import com.bigdata.util.ChecksumUtility; import com.bigdata.util.MillisecondTimestampFactory; /** Modified: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/util/TestChecksumUtility.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/util/TestChecksumUtility.java 2010-09-14 17:41:47 UTC (rev 3546) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/util/TestChecksumUtility.java 2010-09-14 17:52:22 UTC (rev 3547) @@ -31,6 +31,7 @@ import java.util.Random; import java.util.zip.Adler32; +import com.bigdata.io.ChecksumUtility; import junit.framework.TestCase; /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sgo...@us...> - 2010-09-15 14:30:23
|
Revision: 3556 http://bigdata.svn.sourceforge.net/bigdata/?rev=3556&view=rev Author: sgossard Date: 2010-09-15 14:30:14 +0000 (Wed, 15 Sep 2010) Log Message: ----------- [maven_scaleout] : Finished breaking dependency cycles with 'com.bigdata.util' by moving Util class to 'com.bigdata.jini' package. Also moved unit test TestChecksumUtility to 'com.bigdata.io', should have been moved in r3547 with ChecksumUtility class. Modified Paths: -------------- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/disco/DiscoveryTool.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/executor/ServiceImpl.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/loadbalancer/ServiceImpl.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/metadata/ServiceImpl.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/process/ServiceImpl.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/quorum/ServiceImpl.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/shard/ServiceImpl.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/transaction/ServiceImpl.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/io/TestAll.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/util/TestAll.java Added Paths: ----------- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/jini/Util.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/io/TestChecksumUtility.java Removed Paths: ------------- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/util/Util.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/util/TestChecksumUtility.java Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/disco/DiscoveryTool.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/disco/DiscoveryTool.java 2010-09-15 10:22:34 UTC (rev 3555) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/disco/DiscoveryTool.java 2010-09-15 14:30:14 UTC (rev 3556) @@ -24,7 +24,7 @@ */ package com.bigdata.disco; -import com.bigdata.util.Util; +import com.bigdata.jini.Util; import com.sun.jini.config.Config; import net.jini.config.Configuration; @@ -34,7 +34,6 @@ import net.jini.core.discovery.LookupLocator; import net.jini.core.entry.Entry; import net.jini.core.lookup.ServiceItem; -import net.jini.core.lookup.ServiceTemplate; import net.jini.discovery.ConstrainableLookupLocator; import net.jini.discovery.DiscoveryManagement; import net.jini.discovery.DiscoveryGroupManagement; Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/executor/ServiceImpl.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/executor/ServiceImpl.java 2010-09-15 10:22:34 UTC (rev 3555) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/executor/ServiceImpl.java 2010-09-15 14:30:14 UTC (rev 3556) @@ -28,8 +28,8 @@ import static com.bigdata.executor.Constants.*; import com.bigdata.attr.ServiceInfo; +import com.bigdata.jini.Util; import com.bigdata.util.BootStateUtil; -import com.bigdata.util.Util; import com.bigdata.util.config.ConfigDeployUtil; import com.bigdata.util.config.LogUtil; import com.bigdata.util.config.NicUtil; @@ -37,26 +37,20 @@ import org.apache.log4j.Level; import org.apache.log4j.Logger; -import com.sun.jini.config.Config; import com.sun.jini.start.LifeCycle; import com.sun.jini.thread.ReadyState; import net.jini.config.Configuration; import net.jini.config.ConfigurationProvider; import net.jini.config.ConfigurationException; -import net.jini.config.NoSuchEntryException; import net.jini.core.entry.Entry; import net.jini.core.discovery.LookupLocator; -import net.jini.core.lease.Lease; import net.jini.core.lookup.ServiceID; -import net.jini.core.lookup.ServiceItem; -import net.jini.core.lookup.ServiceTemplate; import net.jini.discovery.DiscoveryManagement; import net.jini.discovery.DiscoveryGroupManagement; import net.jini.discovery.DiscoveryLocatorManagement; -import net.jini.discovery.LookupDiscoveryManager; import net.jini.export.Exporter; import net.jini.jeri.BasicILFactory; @@ -65,7 +59,6 @@ import net.jini.jeri.ServerEndpoint; import net.jini.jeri.tcp.TcpServerEndpoint; import net.jini.lookup.JoinManager; -import net.jini.lookup.ServiceDiscoveryManager; import java.io.IOException; import java.rmi.RemoteException; Copied: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/jini/Util.java (from rev 3547, branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/util/Util.java) =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/jini/Util.java (rev 0) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/jini/Util.java 2010-09-15 14:30:14 UTC (rev 3556) @@ -0,0 +1,527 @@ +/* + +Copyright (C) SYSTAP, LLC 2006-2008. All rights reserved. + +Contact: + SYSTAP, LLC + 4501 Tower Road + Greensboro, NC 27410 + lic...@bi... + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*/ + +package com.bigdata.jini; + +import com.bigdata.util.config.ConfigDeployUtil; +import com.bigdata.util.config.LogUtil; +import com.bigdata.service.proxy.ClientFuture; +import com.bigdata.service.proxy.RemoteFuture; +import com.bigdata.service.proxy.RemoteFutureImpl; + +import org.apache.log4j.Level; +import org.apache.log4j.Logger; + +import com.sun.jini.config.Config; +import com.sun.jini.thread.InterruptedStatusThread; +import net.jini.config.Configuration; +import net.jini.config.ConfigurationException; +import net.jini.config.NoSuchEntryException; +import net.jini.core.lookup.ServiceID; +import net.jini.discovery.DiscoveryManagement; +import net.jini.discovery.DiscoveryGroupManagement; +import net.jini.discovery.DiscoveryLocatorManagement; +import net.jini.discovery.LookupDiscoveryManager; +import net.jini.export.Exporter; +import net.jini.jeri.BasicILFactory; +import net.jini.jeri.BasicJeriExporter; +import net.jini.jeri.InvocationLayerFactory; +import net.jini.jeri.ServerEndpoint; +import net.jini.jeri.tcp.TcpServerEndpoint; + +import net.jini.lookup.JoinManager; +import net.jini.lookup.ServiceDiscoveryEvent; +import net.jini.lookup.ServiceDiscoveryManager; + +import java.io.IOException; +import java.rmi.server.ExportException; +import java.util.Collection; +import java.util.Iterator; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.Future; + +/** + * Miscellaneous, convenient utility methods. + * + */ + +//TODO: Not the best home for this class, but having it in 'com.bigdata.util' caused circular package dependencies that were giving me issues. -gossard +public class Util { + + public static <T extends Comparable<T>> T max(final T... elements){ + T max = elements[0]; + for (final T element : elements) { + if(0 < element.compareTo(max)) { + max = element; + } + } + return max; + } + + public static <T extends Comparable<T>> T min(final T... elements){ + T min = elements[0]; + for (final T element : elements) { + if(0 > element.compareTo(min)) { + min = element; + } + } + return min; + } + + /* Convenience method that can be called when a service exits, or + * when failure occurs during the service's initialization process. + * This method un-does any work that may have already been completed; + * for example, un-exports the service if it has already been + * exported, closes any open sockets or file descriptors, terminates + * threads that may have been started, etc. + * <p> + * Note that multiple versions of this method are provided. One version + * is intended to be used by entities that act only as a service (that + * is, entities that export a proxy and use a <code>JoinManager</code>). + * One version is intended to be used by entities that act only as a client + * (that is, entites that use a <code>ServiceDiscoveryManager</code>). + * And the final version can be used by entities that act as both a + * service and as a client. + */ + public static void cleanupOnExit + (Object innerProxy, + Exporter serverExporter, + JoinManager joinManager, + DiscoveryManagement discoveryManager) + { + cleanupOnExit(innerProxy, serverExporter, null, joinManager, + null, discoveryManager); + + } + + public static void cleanupOnExit + (ServiceDiscoveryManager serviceDiscoveryManager, + DiscoveryManagement discoveryManager) + { + cleanupOnExit(null, null, null, null, + serviceDiscoveryManager, discoveryManager); + } + + + public static void cleanupOnExit + (Object innerProxy, + Exporter serverExporter, + JoinManager joinManager, + ServiceDiscoveryManager serviceDiscoveryManager, + DiscoveryManagement discoveryManager) + { + cleanupOnExit(innerProxy, serverExporter, null, joinManager, + serviceDiscoveryManager, discoveryManager); + } + + public static void cleanupOnExit + (Object innerProxy, + Exporter serverExporter, + Set<Exporter> futureExporters, + JoinManager joinManager, + ServiceDiscoveryManager serviceDiscoveryManager, + DiscoveryManagement discoveryManager) + { + if(innerProxy != null) { + try { + if(serverExporter != null) serverExporter.unexport(true); + } catch(Throwable t) { } + } + + if(futureExporters != null) { + for(Exporter exporter : futureExporters) { + if(exporter != null) { + try { + exporter.unexport(true); + exporter = null; + } catch(Throwable t) { } + } + } + synchronized(futureExporters) { + for(Iterator<Exporter> itr = futureExporters.iterator(); + itr.hasNext(); ) + { + itr.next(); + itr.remove(); + } + } + } + + if(joinManager != null) { + try { + joinManager.terminate(); + } catch(Throwable t) { } + } + + if(serviceDiscoveryManager != null) { + try { + serviceDiscoveryManager.terminate(); + } catch(Throwable t) { } + } + + if(discoveryManager != null) { + try { + discoveryManager.terminate(); + } catch(Throwable t) { } + } + } + + + /** + * Unexports the remote object that was exported by the given + * <code>Exporter</code> parameter; which removes the object + * from the RMI runtime so that the object can no longer accept + * incoming remote calls.er accept incoming RMI calls. + * <P> + * This method first makes an attempt to unexport the object + * 'gracefully'. That is, for a finite period of time, an attempt + * is made to allow all calls to the object that are in progress, + * or pending, to complete before the object is actually unexported. + * If, after that finite period of time, the object has not been + * successfully unexported, the object is then 'forcibly' unexported; + * that is, the object is unexported even if there are calls to + * the object that are in progress or still pending. + * <P> + * Upon successfully unexporting the given <code>Exporter</code>, + * <code>true</code> is returned. If the given <code>Exporter</code> + * cannot be unexported, or if the value input for that parameter + * is <code>null</code> or has not exported any interfaces, then + * <code>false</code> is returned. + */ + public static boolean unexportRemoteObject(Exporter exporter) { + if (exporter == null) return false; + + // delay no more than 1 minute + final long endTime = System.currentTimeMillis() + (1L*60L*1000L); + boolean unexported = false; + try { + // Unexport only if there are no pending or in-progress calls + while (!unexported && System.currentTimeMillis() < endTime) { + unexported = exporter.unexport(false);//do not force + if (!unexported) Thread.yield(); + }//end loop + if (!unexported) unexported = exporter.unexport(true);//force + } catch ( IllegalStateException e ) { + // Thrown if no object has been exported with the + // Exporter instance + return false; + } + return unexported; + } + + + /** + * Convenience method that can be called in an entity's constructor + * when failure occurs during the initialization process. This + * method simply rethrows the given <code>Throwable</code> so the + * constructor doesn't have to. + */ + public static void handleInitThrowable(Throwable t, Logger logger) + throws IOException, + ConfigurationException + { + if( logger != null ) { + logger.log(Level.FATAL, "initialization failure ... ", t); + } else { + System.err.println("FATAL: initialization failure ... "+t); + }//endif + if (t instanceof IOException) { + throw (IOException)t; + } else if (t instanceof ConfigurationException) { + throw (ConfigurationException)t; + } else if (t instanceof RuntimeException) { + throw (RuntimeException)t; + } else if (t instanceof Error) { + throw (Error)t; + }//endif + } + + /** + * Convenience method that returns a <code>String</code> containing + * a common-separated list the elements (group names) of the given + * array. + */ + public static String writeGroupArrayToString(String[] groups) { + if(groups == null) { + return new String("[ALL_GROUPS]"); + }//endif + if(groups.length <= 0) { + return new String("[]"); + }//endif + StringBuffer strBuf = null; + if(groups[0].compareTo("") == 0) { + strBuf = new StringBuffer("[The PUBLIC Group"); + } else { + strBuf = new StringBuffer("["+groups[0]); + }//endif + for(int i=1;i<groups.length;i++) { + if(groups[i].compareTo("") == 0) { + strBuf.append(", The PUBLIC Group"); + } else { + strBuf.append(", ").append(groups[i]); + }//endif + }//end loop + strBuf.append("]"); + return strBuf.toString(); + } + + /** + * Convenience method that returns a <code>String</code> containing + * a common-separated list the elements (locators) of the given + * array. + */ + public static String writeArrayElementsToString(Object[] arr) { + if(arr == null) return new String("[]"); + if(arr.length <= 0) { + return new String("[]"); + }//endif + StringBuffer strBuf = new StringBuffer("["+arr[0]); + for(int i=1;i<arr.length;i++){ + strBuf.append(", ").append(arr[i]); + }//end loop + strBuf.append("]"); + return strBuf.toString(); + } + + /** + * Convenience method to simplify the throwing of exceptions with embedded + * causes (avoids having to cast the return value of Throwable.initCause + * back to the exception's type). Use as follows: + * <pre> + * throw Util.initCause(new SomeException("foo"), cause); + * </pre> + */ + public static <T extends Throwable> T initCause(T t, Throwable cause) { + t.initCause(cause); + return t; + } + + /** + * Verifies that all non-<code>null</code> elements of the given + * <code>Collection</code> are assignable to the specified type, + * throwing a <code>ClassCastException</code> if any are not. + */ + public static void checkElementTypes(Collection<?> c, Class<?> type) { + for (Object elt : c) { + if (!type.isInstance(elt)) { + throw new ClassCastException( + elt + " not assignable to " + type); + } + } + } + + /** + * Returns a UUID with the same bit value as the given + * <code>ServiceID</code>. + */ + public static UUID toUUID(ServiceID serviceId) { + return new UUID( serviceId.getMostSignificantBits(), + serviceId.getLeastSignificantBits() ); + } + + /** + * Returns a string representation of the given + * <code>ServiceDiscoveryEvent</code> (since + * <code>ServiceDiscoveryEvent</code> doesn't define + * its own <code>toString</code> method). + */ + public static String eventToString(ServiceDiscoveryEvent event) { + return "ServiceDiscoveryEvent[source=" + event.getSource() + + ",preEventItem=" + event.getPreEventServiceItem() + + ",postEventItem=" + event.getPostEventServiceItem() + "]"; + } + + /** + * Convenience method that encapsulates common functions that services + * or clients may wish to perform to be able to discover lookup services + * in the system. + * <p> + * This method retrieves and returns a lookup discovery manager from + * the given <code>Configuration</code>. If no lookup discovery manager + * has been configured, this method will return an instance of the + * <code>LookupDiscoveryManager</code> helper utility class, + * initialized to discover NO_GROUPS and no locators. When such a + * discovery manager is returned, the calling entity can call the + * <code>setGroups</code> and/or </code>setLocators</code> method + * to initiate the lookup discovery process. + * <p> + * Note that this method expects that the discovery manager + * that has been configured is an instance of both + * <code>DiscoveryGroupManagement</code> and + * <code>DiscoveryLocatorManagement</code>. + * + * @param config The calling service's <code>Configuration</code> + * from which this method will retrieve the items + * needed to perform the desired initialization. + * + * @param componentName <code>String</code> whose value is the name of + * the <i>component</i> used to index the calling + * service's configuration <i>entries</i>. + * + * @param entryName <code>String</code> whose value is the name of + * the configuration entry that references the + * the desired lookup discovery manager instance + * specified in the configuration. + * + * @return An instance of <code>DiscoveryManagement</code> that supports + * both group and locator discovery; where the instance returned + * is either retrieved from the given <code>Configuration</code>, + * or is a default instance of <code>LookupDiscoveryManager</code>. + * + * @throws <code>ConfigurationException</code> when there is a problem + * retrieving the desired entry from the configuration. + * + * @throws IOException when there is a problem with multicast discovery. + */ + public static DiscoveryManagement getDiscoveryManager + (Configuration config, + String componentName, + String entryName ) + throws ConfigurationException, + IOException + { + // The discovery manager must be an instance of both + // DiscoveryGroupManagement and DiscoveryLocatorManagement, so that + // the groupsToJoin and locatorsToJoin can both be retrieved from + //the discovery manager and displayed. + DiscoveryManagement dMgr; + try { + dMgr = (DiscoveryManagement)Config.getNonNullEntry + (config, + componentName, + entryName, + DiscoveryManagement.class); + if( !(dMgr instanceof DiscoveryGroupManagement) ) { + throw new ConfigurationException + (entryName + " entry must " + +"implement DiscoveryGroupManagment"); + } + if( !(dMgr instanceof DiscoveryLocatorManagement) ) { + throw new ConfigurationException + (entryName + " entry must " + +"implement DiscoveryLocatorManagement"); + } + } catch (NoSuchEntryException e) { + return ( new LookupDiscoveryManager + (ConfigDeployUtil.getGroupsToDiscover(), + ConfigDeployUtil.getLocatorsToDiscover(), + null, config) ); + } + return dMgr; + } + + /** + * Retrieves and returns a lookup discovery manager from the given + * <code>Configuration</code>, using a default entry name of + * <i>discoveryManager</i>. + */ + public static DiscoveryManagement getDiscoveryManager + (Configuration config, + String componentName) + throws ConfigurationException, + IOException + { + return getDiscoveryManager(config, componentName, "discoveryManager"); + } + + public static Exporter getExporter(Configuration config, + String componentName, + String entryName, + boolean defaultEnableDgc, + boolean defaultKeepAlive) + throws ConfigurationException + { + if(config == null) { + throw new NullPointerException("null config"); + } + if(componentName == null) { + throw new NullPointerException("null componentName"); + } + if(entryName == null) { + throw new NullPointerException("null entryName"); + } + Exporter exporter = null; + ServerEndpoint endpoint = TcpServerEndpoint.getInstance(0); + InvocationLayerFactory ilFactory = new BasicILFactory(); + Exporter defaultExporter = + new BasicJeriExporter + (endpoint, ilFactory, defaultEnableDgc, defaultKeepAlive); + exporter = + (Exporter)config.getEntry + (componentName, entryName, Exporter.class, defaultExporter); + if(exporter == null) { + throw new ConfigurationException("null exporter"); + } + return exporter; + } + + public static <E> Future<E> wrapFuture(Exporter exporter, + Future<E> future) + throws ExportException + { + if(exporter == null) { + throw new NullPointerException("null exporter"); + } + if(future == null) { + throw new NullPointerException("null future"); + } + + // 1. Wrap the given future in a remote (proxyable) object + // 2. Export the remote object to produce a dynamic proxy (stub) + // 3. Return the proxied future (the stub) wrapped in a Serializable + // wrapper class implementing the Future interface. + + final RemoteFuture<E> impl = new RemoteFutureImpl<E>(future); + + final RemoteFuture<E> stub = (RemoteFuture<E>)exporter.export(impl); + + return new ClientFuture<E>(stub); + } + + public static class WaitOnInterruptThread extends InterruptedStatusThread { + private Logger logger; + public WaitOnInterruptThread(final Logger logger) { + super("WaitOnInterruptThread"); + setDaemon(true); + this.logger = (logger == null ? + LogUtil.getLog4jLogger((this.getClass()).getName()) : + logger); + } + public void run() { + while (!hasBeenInterrupted()) { + try { + Thread.sleep(Long.MAX_VALUE); + } catch (InterruptedException e) { + if( logger.isDebugEnabled() ) { + logger.log(Level.DEBUG, + "Util.WaitOnInterruptThread: " + +"interrupt received"); + } + } + } + } + } +} Property changes on: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/jini/Util.java ___________________________________________________________________ Added: svn:keywords + Id Date Revision Author HeadURL Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/loadbalancer/ServiceImpl.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/loadbalancer/ServiceImpl.java 2010-09-15 10:22:34 UTC (rev 3555) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/loadbalancer/ServiceImpl.java 2010-09-15 14:30:14 UTC (rev 3556) @@ -28,11 +28,11 @@ import static com.bigdata.loadbalancer.Constants.*; import com.bigdata.attr.ServiceInfo; +import com.bigdata.jini.Util; import com.bigdata.jini.start.BigdataZooDefs; import com.bigdata.service.Event; import com.bigdata.service.IServiceShutdown.ShutdownType; import com.bigdata.util.BootStateUtil; -import com.bigdata.util.Util; import com.bigdata.util.config.ConfigDeployUtil; import com.bigdata.util.config.LogUtil; import com.bigdata.util.config.NicUtil; @@ -40,29 +40,22 @@ import org.apache.log4j.Level; import org.apache.log4j.Logger; -import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.KeeperException.NodeExistsException; -import com.sun.jini.config.Config; import com.sun.jini.start.LifeCycle; import com.sun.jini.thread.ReadyState; import net.jini.config.Configuration; import net.jini.config.ConfigurationProvider; import net.jini.config.ConfigurationException; -import net.jini.config.NoSuchEntryException; import net.jini.core.entry.Entry; import net.jini.core.discovery.LookupLocator; -import net.jini.core.lease.Lease; import net.jini.core.lookup.ServiceID; -import net.jini.core.lookup.ServiceItem; -import net.jini.core.lookup.ServiceTemplate; import net.jini.discovery.DiscoveryManagement; import net.jini.discovery.DiscoveryGroupManagement; import net.jini.discovery.DiscoveryLocatorManagement; -import net.jini.discovery.LookupDiscoveryManager; import net.jini.export.Exporter; import net.jini.jeri.BasicILFactory; Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/metadata/ServiceImpl.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/metadata/ServiceImpl.java 2010-09-15 10:22:34 UTC (rev 3555) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/metadata/ServiceImpl.java 2010-09-15 14:30:14 UTC (rev 3556) @@ -32,12 +32,12 @@ import com.bigdata.btree.ResultSet; import com.bigdata.btree.filter.IFilterConstructor; import com.bigdata.btree.proc.IIndexProcedure; +import com.bigdata.jini.Util; import com.bigdata.jini.start.BigdataZooDefs; import com.bigdata.jini.util.ConfigMath; import com.bigdata.mdi.PartitionLocator; import com.bigdata.service.IServiceShutdown.ShutdownType; import com.bigdata.util.BootStateUtil; -import com.bigdata.util.Util; import com.bigdata.util.config.ConfigDeployUtil; import com.bigdata.util.config.LogUtil; import com.bigdata.util.config.NicUtil; @@ -45,7 +45,6 @@ import org.apache.log4j.Level; import org.apache.log4j.Logger; -import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.KeeperException.NodeExistsException; import com.sun.jini.config.Config; @@ -55,19 +54,14 @@ import net.jini.config.Configuration; import net.jini.config.ConfigurationProvider; import net.jini.config.ConfigurationException; -import net.jini.config.NoSuchEntryException; import net.jini.core.entry.Entry; import net.jini.core.discovery.LookupLocator; -import net.jini.core.lease.Lease; import net.jini.core.lookup.ServiceID; -import net.jini.core.lookup.ServiceItem; -import net.jini.core.lookup.ServiceTemplate; import net.jini.discovery.DiscoveryManagement; import net.jini.discovery.DiscoveryGroupManagement; import net.jini.discovery.DiscoveryLocatorManagement; -import net.jini.discovery.LookupDiscoveryManager; import net.jini.export.Exporter; import net.jini.lookup.JoinManager; @@ -590,7 +584,7 @@ String[] groups = ((DiscoveryGroupManagement)ldm).getGroups(); LookupLocator[] locs = ((DiscoveryLocatorManagement)ldm).getLocators(); logger.log(Level.INFO, killStr+" [groups=" - +Util.writeGroupArrayToString(groupsToJoin) + + Util.writeGroupArrayToString(groupsToJoin) +", locators=" +Util.writeArrayElementsToString(locatorsToJoin)+"]"); Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/process/ServiceImpl.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/process/ServiceImpl.java 2010-09-15 10:22:34 UTC (rev 3555) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/process/ServiceImpl.java 2010-09-15 14:30:14 UTC (rev 3556) @@ -31,9 +31,9 @@ import com.bigdata.boot.ProcessEventListener; import com.bigdata.boot.ProcessState; import com.bigdata.boot.ProcessStateChangeEvent; +import com.bigdata.jini.Util; import com.bigdata.util.BootStateUtil; import com.bigdata.util.Format; -import com.bigdata.util.Util; import com.bigdata.util.config.ConfigDeployUtil; import com.bigdata.util.config.LogUtil; import com.bigdata.util.config.NicUtil; Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/quorum/ServiceImpl.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/quorum/ServiceImpl.java 2010-09-15 10:22:34 UTC (rev 3555) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/quorum/ServiceImpl.java 2010-09-15 14:30:14 UTC (rev 3556) @@ -29,9 +29,9 @@ import com.bigdata.attr.QuorumPeerAttr; import com.bigdata.attr.ServiceInfo; +import com.bigdata.jini.Util; import com.bigdata.service.QuorumPeerService; import com.bigdata.service.QuorumPeerService.QuorumPeerData; -import com.bigdata.util.Util; import com.bigdata.util.config.ConfigDeployUtil; import com.bigdata.util.config.LogUtil; import com.bigdata.util.config.NicUtil; @@ -45,9 +45,7 @@ import org.apache.log4j.Level; import org.apache.log4j.Logger; -import com.sun.jini.config.Config; import com.sun.jini.start.LifeCycle; -import com.sun.jini.thread.InterruptedStatusThread; import com.sun.jini.thread.ReadyState; import net.jini.config.Configuration; @@ -57,7 +55,6 @@ import net.jini.core.entry.Entry; import net.jini.core.discovery.LookupLocator; -import net.jini.core.lease.Lease; import net.jini.core.lookup.ServiceID; import net.jini.core.lookup.ServiceItem; import net.jini.core.lookup.ServiceTemplate; @@ -65,7 +62,6 @@ import net.jini.discovery.DiscoveryManagement; import net.jini.discovery.DiscoveryGroupManagement; import net.jini.discovery.DiscoveryLocatorManagement; -import net.jini.discovery.LookupDiscoveryManager; import net.jini.export.Exporter; import net.jini.jeri.BasicILFactory; @@ -88,18 +84,12 @@ import java.io.ObjectOutputStream; import java.io.ObjectStreamClass; import java.io.PrintWriter; -import java.io.Serializable; import java.net.InetAddress; -import java.net.Inet4Address; import java.net.InetSocketAddress; import java.net.InterfaceAddress; import java.net.NetworkInterface; -import java.net.SocketException; -import java.net.UnknownHostException; import java.rmi.RemoteException; -import java.rmi.server.ExportException; import java.util.ArrayList; -import java.util.Collections; import java.util.Enumeration; import java.util.HashMap; import java.util.Iterator; Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/shard/ServiceImpl.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/shard/ServiceImpl.java 2010-09-15 10:22:34 UTC (rev 3555) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/shard/ServiceImpl.java 2010-09-15 14:30:14 UTC (rev 3556) @@ -32,10 +32,10 @@ import com.bigdata.btree.ResultSet; import com.bigdata.btree.filter.IFilterConstructor; import com.bigdata.btree.proc.IIndexProcedure; +import com.bigdata.jini.Util; import com.bigdata.mdi.IResourceMetadata; import com.bigdata.rawstore.IBlock; import com.bigdata.util.BootStateUtil; -import com.bigdata.util.Util; import com.bigdata.util.config.ConfigDeployUtil; import com.bigdata.util.config.LogUtil; import com.bigdata.util.config.NicUtil; @@ -43,26 +43,20 @@ import org.apache.log4j.Level; import org.apache.log4j.Logger; -import com.sun.jini.config.Config; import com.sun.jini.start.LifeCycle; import com.sun.jini.thread.ReadyState; import net.jini.config.Configuration; import net.jini.config.ConfigurationProvider; import net.jini.config.ConfigurationException; -import net.jini.config.NoSuchEntryException; import net.jini.core.entry.Entry; import net.jini.core.discovery.LookupLocator; -import net.jini.core.lease.Lease; import net.jini.core.lookup.ServiceID; -import net.jini.core.lookup.ServiceItem; -import net.jini.core.lookup.ServiceTemplate; import net.jini.discovery.DiscoveryManagement; import net.jini.discovery.DiscoveryGroupManagement; import net.jini.discovery.DiscoveryLocatorManagement; -import net.jini.discovery.LookupDiscoveryManager; import net.jini.export.Exporter; import net.jini.jeri.BasicILFactory; @@ -71,7 +65,6 @@ import net.jini.jeri.ServerEndpoint; import net.jini.jeri.tcp.TcpServerEndpoint; import net.jini.lookup.JoinManager; -import net.jini.lookup.ServiceDiscoveryManager; import java.io.IOException; import java.rmi.RemoteException; @@ -426,7 +419,7 @@ String[] groups = ((DiscoveryGroupManagement)ldm).getGroups(); LookupLocator[] locs = ((DiscoveryLocatorManagement)ldm).getLocators(); logger.log(Level.INFO, killStr+" [groups=" - +Util.writeGroupArrayToString(groupsToJoin) + + Util.writeGroupArrayToString(groupsToJoin) +", locators=" +Util.writeArrayElementsToString(locatorsToJoin)+"]"); Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/transaction/ServiceImpl.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/transaction/ServiceImpl.java 2010-09-15 10:22:34 UTC (rev 3555) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/transaction/ServiceImpl.java 2010-09-15 14:30:14 UTC (rev 3556) @@ -28,12 +28,11 @@ import static com.bigdata.transaction.Constants.*; import com.bigdata.attr.ServiceInfo; +import com.bigdata.jini.Util; import com.bigdata.jini.start.BigdataZooDefs; import com.bigdata.journal.ValidationError; -import com.bigdata.service.Event; import com.bigdata.service.IServiceShutdown.ShutdownType; import com.bigdata.util.BootStateUtil; -import com.bigdata.util.Util; import com.bigdata.util.config.ConfigDeployUtil; import com.bigdata.util.config.LogUtil; import com.bigdata.util.config.NicUtil; @@ -41,7 +40,6 @@ import org.apache.log4j.Level; import org.apache.log4j.Logger; -import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.KeeperException.NodeExistsException; import com.sun.jini.config.Config; @@ -51,19 +49,14 @@ import net.jini.config.Configuration; import net.jini.config.ConfigurationProvider; import net.jini.config.ConfigurationException; -import net.jini.config.NoSuchEntryException; import net.jini.core.entry.Entry; import net.jini.core.discovery.LookupLocator; -import net.jini.core.lease.Lease; import net.jini.core.lookup.ServiceID; -import net.jini.core.lookup.ServiceItem; -import net.jini.core.lookup.ServiceTemplate; import net.jini.discovery.DiscoveryManagement; import net.jini.discovery.DiscoveryGroupManagement; import net.jini.discovery.DiscoveryLocatorManagement; -import net.jini.discovery.LookupDiscoveryManager; import net.jini.export.Exporter; import net.jini.jeri.BasicILFactory; Deleted: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/util/Util.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/util/Util.java 2010-09-15 10:22:34 UTC (rev 3555) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/util/Util.java 2010-09-15 14:30:14 UTC (rev 3556) @@ -1,524 +0,0 @@ -/* - -Copyright (C) SYSTAP, LLC 2006-2008. All rights reserved. - -Contact: - SYSTAP, LLC - 4501 Tower Road - Greensboro, NC 27410 - lic...@bi... - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; version 2 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*/ - -package com.bigdata.util; - -import com.bigdata.util.config.ConfigDeployUtil; -import com.bigdata.util.config.LogUtil; -import com.bigdata.service.proxy.ClientFuture; -import com.bigdata.service.proxy.RemoteFuture; -import com.bigdata.service.proxy.RemoteFutureImpl; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -import com.sun.jini.config.Config; -import com.sun.jini.thread.InterruptedStatusThread; -import net.jini.config.Configuration; -import net.jini.config.ConfigurationException; -import net.jini.config.NoSuchEntryException; -import net.jini.core.lookup.ServiceID; -import net.jini.discovery.DiscoveryManagement; -import net.jini.discovery.DiscoveryGroupManagement; -import net.jini.discovery.DiscoveryLocatorManagement; -import net.jini.discovery.LookupDiscoveryManager; -import net.jini.export.Exporter; -import net.jini.jeri.BasicILFactory; -import net.jini.jeri.BasicJeriExporter; -import net.jini.jeri.InvocationLayerFactory; -import net.jini.jeri.ServerEndpoint; -import net.jini.jeri.tcp.TcpServerEndpoint; - -import net.jini.lookup.JoinManager; -import net.jini.lookup.ServiceDiscoveryEvent; -import net.jini.lookup.ServiceDiscoveryManager; - -import java.io.IOException; -import java.rmi.server.ExportException; -import java.util.Collection; -import java.util.Iterator; -import java.util.Set; -import java.util.UUID; -import java.util.concurrent.Future; - -/** - * Miscellaneous, convenient utility methods. - */ -public class Util { - - public static <T extends Comparable<T>> T max(final T... elements){ - T max = elements[0]; - for (final T element : elements) { - if(0 < element.compareTo(max)) { - max = element; - } - } - return max; - } - - public static <T extends Comparable<T>> T min(final T... elements){ - T min = elements[0]; - for (final T element : elements) { - if(0 > element.compareTo(min)) { - min = element; - } - } - return min; - } - - /* Convenience method that can be called when a service exits, or - * when failure occurs during the service's initialization process. - * This method un-does any work that may have already been completed; - * for example, un-exports the service if it has already been - * exported, closes any open sockets or file descriptors, terminates - * threads that may have been started, etc. - * <p> - * Note that multiple versions of this method are provided. One version - * is intended to be used by entities that act only as a service (that - * is, entities that export a proxy and use a <code>JoinManager</code>). - * One version is intended to be used by entities that act only as a client - * (that is, entites that use a <code>ServiceDiscoveryManager</code>). - * And the final version can be used by entities that act as both a - * service and as a client. - */ - public static void cleanupOnExit - (Object innerProxy, - Exporter serverExporter, - JoinManager joinManager, - DiscoveryManagement discoveryManager) - { - cleanupOnExit(innerProxy, serverExporter, null, joinManager, - null, discoveryManager); - - } - - public static void cleanupOnExit - (ServiceDiscoveryManager serviceDiscoveryManager, - DiscoveryManagement discoveryManager) - { - cleanupOnExit(null, null, null, null, - serviceDiscoveryManager, discoveryManager); - } - - - public static void cleanupOnExit - (Object innerProxy, - Exporter serverExporter, - JoinManager joinManager, - ServiceDiscoveryManager serviceDiscoveryManager, - DiscoveryManagement discoveryManager) - { - cleanupOnExit(innerProxy, serverExporter, null, joinManager, - serviceDiscoveryManager, discoveryManager); - } - - public static void cleanupOnExit - (Object innerProxy, - Exporter serverExporter, - Set<Exporter> futureExporters, - JoinManager joinManager, - ServiceDiscoveryManager serviceDiscoveryManager, - DiscoveryManagement discoveryManager) - { - if(innerProxy != null) { - try { - if(serverExporter != null) serverExporter.unexport(true); - } catch(Throwable t) { } - } - - if(futureExporters != null) { - for(Exporter exporter : futureExporters) { - if(exporter != null) { - try { - exporter.unexport(true); - exporter = null; - } catch(Throwable t) { } - } - } - synchronized(futureExporters) { - for(Iterator<Exporter> itr = futureExporters.iterator(); - itr.hasNext(); ) - { - itr.next(); - itr.remove(); - } - } - } - - if(joinManager != null) { - try { - joinManager.terminate(); - } catch(Throwable t) { } - } - - if(serviceDiscoveryManager != null) { - try { - serviceDiscoveryManager.terminate(); - } catch(Throwable t) { } - } - - if(discoveryManager != null) { - try { - discoveryManager.terminate(); - } catch(Throwable t) { } - } - } - - - /** - * Unexports the remote object that was exported by the given - * <code>Exporter</code> parameter; which removes the object - * from the RMI runtime so that the object can no longer accept - * incoming remote calls.er accept incoming RMI calls. - * <P> - * This method first makes an attempt to unexport the object - * 'gracefully'. That is, for a finite period of time, an attempt - * is made to allow all calls to the object that are in progress, - * or pending, to complete before the object is actually unexported. - * If, after that finite period of time, the object has not been - * successfully unexported, the object is then 'forcibly' unexported; - * that is, the object is unexported even if there are calls to - * the object that are in progress or still pending. - * <P> - * Upon successfully unexporting the given <code>Exporter</code>, - * <code>true</code> is returned. If the given <code>Exporter</code> - * cannot be unexported, or if the value input for that parameter - * is <code>null</code> or has not exported any interfaces, then - * <code>false</code> is returned. - */ - public static boolean unexportRemoteObject(Exporter exporter) { - if (exporter == null) return false; - - // delay no more than 1 minute - final long endTime = System.currentTimeMillis() + (1L*60L*1000L); - boolean unexported = false; - try { - // Unexport only if there are no pending or in-progress calls - while (!unexported && System.currentTimeMillis() < endTime) { - unexported = exporter.unexport(false);//do not force - if (!unexported) Thread.yield(); - }//end loop - if (!unexported) unexported = exporter.unexport(true);//force - } catch ( IllegalStateException e ) { - // Thrown if no object has been exported with the - // Exporter instance - return false; - } - return unexported; - } - - - /** - * Convenience method that can be called in an entity's constructor - * when failure occurs during the initialization process. This - * method simply rethrows the given <code>Throwable</code> so the - * constructor doesn't have to. - */ - public static void handleInitThrowable(Throwable t, Logger logger) - throws IOException, - ConfigurationException - { - if( logger != null ) { - logger.log(Level.FATAL, "initialization failure ... ", t); - } else { - System.err.println("FATAL: initialization failure ... "+t); - }//endif - if (t instanceof IOException) { - throw (IOException)t; - } else if (t instanceof ConfigurationException) { - throw (ConfigurationException)t; - } else if (t instanceof RuntimeException) { - throw (RuntimeException)t; - } else if (t instanceof Error) { - throw (Error)t; - }//endif - } - - /** - * Convenience method that returns a <code>String</code> containing - * a common-separated list the elements (group names) of the given - * array. - */ - public static String writeGroupArrayToString(String[] groups) { - if(groups == null) { - return new String("[ALL_GROUPS]"); - }//endif - if(groups.length <= 0) { - return new String("[]"); - }//endif - StringBuffer strBuf = null; - if(groups[0].compareTo("") == 0) { - strBuf = new StringBuffer("[The PUBLIC Group"); - } else { - strBuf = new StringBuffer("["+groups[0]); - }//endif - for(int i=1;i<groups.length;i++) { - if(groups[i].compareTo("") == 0) { - strBuf.append(", The PUBLIC Group"); - } else { - strBuf.append(", ").append(groups[i]); - }//endif - }//end loop - strBuf.append("]"); - return strBuf.toString(); - } - - /** - * Convenience method that returns a <code>String</code> containing - * a common-separated list the elements (locators) of the given - * array. - */ - public static String writeArrayElementsToString(Object[] arr) { - if(arr == null) return new String("[]"); - if(arr.length <= 0) { - return new String("[]"); - }//endif - StringBuffer strBuf = new StringBuffer("["+arr[0]); - for(int i=1;i<arr.length;i++){ - strBuf.append(", ").append(arr[i]); - }//end loop - strBuf.append("]"); - return strBuf.toString(); - } - - /** - * Convenience method to simplify the throwing of exceptions with embedded - * causes (avoids having to cast the return value of Throwable.initCause - * back to the exception's type). Use as follows: - * <pre> - * throw Util.initCause(new SomeException("foo"), cause); - * </pre> - */ - public static <T extends Throwable> T initCause(T t, Throwable cause) { - t.initCause(cause); - return t; - } - - /** - * Verifies that all non-<code>null</code> elements of the given - * <code>Collection</code> are assignable to the specified type, - * throwing a <code>ClassCastException</code> if any are not. - */ - public static void checkElementTypes(Collection<?> c, Class<?> type) { - for (Object elt : c) { - if (!type.isInstance(elt)) { - throw new ClassCastException( - elt + " not assignable to " + type); - } - } - } - - /** - * Returns a UUID with the same bit value as the given - * <code>ServiceID</code>. - */ - public static UUID toUUID(ServiceID serviceId) { - return new UUID( serviceId.getMostSignificantBits(), - serviceId.getLeastSignificantBits() ); - } - - /** - * Returns a string representation of the given - * <code>ServiceDiscoveryEvent</code> (since - * <code>ServiceDiscoveryEvent</code> doesn't define - * its own <code>toString</code> method). - */ - public static String eventToString(ServiceDiscoveryEvent event) { - return "ServiceDiscoveryEvent[source=" + event.getSource() + - ",preEventItem=" + event.getPreEventServiceItem() + - ",postEventItem=" + event.getPostEventServiceItem() + "]"; - } - - /** - * Convenience method that encapsulates common functions that services - * or clients may wish to perform to be able to discover lookup services - * in the system. - * <p> - * This method retrieves and returns a lookup discovery manager from - * the given <code>Configuration</code>. If no lookup discovery manager - * has been configured, this method will return an instance of the - * <code>LookupDiscoveryManager</code> helper utility class, - * initialized to discover NO_GROUPS and no locators. When such a - * discovery manager is returned, the calling entity can call the - * <code>setGroups</code> and/or </code>setLocators</code> method - * to initiate the lookup discovery process. - * <p> - * Note that this method expects that the discovery manager - * that has been configured is an instance of both - * <code>DiscoveryGroupManagement</code> and - * <code>DiscoveryLocatorManagement</code>. - * - * @param config The calling service's <code>Configuration</code> - * from which this method will retrieve the items - * needed to perform the desired initialization. - * - * @param componentName <code>String</code> whose value is the name of - * the <i>component</i> used to index the calling - * service's configuration <i>entries</i>. - * - * @param entryName <code>String</code> whose value is the name of - * the configuration entry that references the - * the desired lookup discovery manager instance - * specified in the configuration. - * - * @return An instance of <code>DiscoveryManagement</code> that supports - * both group and locator discovery; where the instance returned - * is either retrieved from the given <code>Configuration</code>, - * or is a default instance of <code>LookupDiscoveryManager</code>. - * - * @throws <code>ConfigurationException</code> when there is a problem - * retrieving the desired entry from the configuration. - * - * @throws IOException when there is a problem with multicast discovery. - */ - public static DiscoveryManagement getDiscoveryManager - (Configuration config, - String componentName, - String entryName ) - throws ConfigurationException, - IOException - { - // The discovery manager must be an instance of both - // DiscoveryGroupManagement and DiscoveryLocatorManagement, so that - // the groupsToJoin and locatorsToJoin can both be retrieved from - //the discovery manager and displayed. - DiscoveryManagement dMgr; - try { - dMgr = (DiscoveryManagement)Config.getNonNullEntry - (config, - componentName, - entryName, - DiscoveryManagement.class); - if( !(dMgr instanceof DiscoveryGroupManagement) ) { - throw new ConfigurationException - (entryName + " entry must " - +"implement DiscoveryGroupManagment"); - } - if( !(dMgr instanceof DiscoveryLocatorManagement) ) { - throw new ConfigurationException - (entryName + " entry must " - +"implement DiscoveryLocatorManagement"); - } - } catch (NoSuchEntryException e) { - return ( new LookupDiscoveryManager - (ConfigDeployUtil.getGroupsToDiscover(), - ConfigDeployUtil.getLocatorsToDiscover(), - null, config) ); - } - return dMgr; - } - - /** - * Retrieves and returns a lookup discovery manager from the given - * <code>Configuration</code>, using a default entry name of - * <i>discoveryManager</i>. - */ - public static DiscoveryManagement getDiscoveryManager - (Configuration config, - String componentName) - throws ConfigurationException, - IOException - { - return getDiscoveryManager(config, componentName, "discoveryManager"); - } - - public static Exporter getExporter(Configuration config, - String componentName, - String entryName, - boolean defaultEnableDgc, - boolean defaultKeepAlive) - throws ConfigurationException - { - if(config == null) { - throw new NullPointerException("null config"); - } - if(componentName == null) { - throw new NullPointerException("null componentName"); - } - if(entryName == null) { - throw new NullPointerException("null entryName"); - } - Exporter exporter = null; - ServerEndpoint endpoint = TcpServerEndpoint.getInstance(0); - InvocationLayerFactory ilFactory = new BasicILFactory(); - Exporter defaultExporter = - new BasicJeriExporter - (endpoint, ilFactory, defaultEnableDgc, defaultKeepAlive); - exporter = - (Exporter)config.getEntry - (componentName, entryName, Exporter.class, defaultExporter); - if(exporter == null) { - throw new ConfigurationException("null exporter"); - } - return exporter; - } - - public static <E> Future<E> wrapFuture(Exporter exporter, - Future<E> future) - throws ExportException - { - if(exporter == null) { - throw new NullPointerException("null exporter"); - } - if(future == null) { - throw new NullPointerException("null future"); - } - - // 1. Wrap the given future in a remote (proxyable) object - // 2. Export the remote object to produce a dynamic proxy (stub) - // 3. Return the proxied future (the stub) wrapped in a Serializable - // wrapper class implementing the Future interface. - - final RemoteFuture<E> impl = new RemoteFutureImpl<E>(future); - - final RemoteFuture<E> stub = (RemoteFuture<E>)exporter.export(impl); - - return new ClientFuture<E>(stub); - } - - public static class WaitOnInterruptThread extends InterruptedStatusThread { - private Logger logger; - public WaitOnInterruptThread(final Logger logger) { - super("WaitOnInterruptThread"); - setDaemon(true); - this.logger = (logger == null ? - LogUtil.getLog4jLogger((this.getClass()).getName()) : - logger); - } - public void run() { - while (!hasBeenInterrupted()) { - try { - Thread.sleep(Long.MAX_VALUE); - } catch (InterruptedException e) { - if( logger.isDebugEnabled() ) { - logger.log(Level.DEBUG, - "Util.WaitOnInterruptThread: " - +"interrupt received"); - } - } - } - } - } -} Modified: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/... [truncated message content] |
From: <sgo...@us...> - 2010-09-15 23:01:28
|
Revision: 3563 http://bigdata.svn.sourceforge.net/bigdata/?rev=3563&view=rev Author: sgossard Date: 2010-09-15 23:01:17 +0000 (Wed, 15 Sep 2010) Log Message: ----------- [maven_scaleout] : Breaking all direct dependency cycles with package 'com.bigdata.io', mainly via moving BytesUtil into io package. Most files touched are just an import change. Package still has major transitive cycles, again via package 'com.bigdata.counters'. Modified Paths: -------------- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/LRUNexus.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/bfs/AtomicBlockAppendProc.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractBTree.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractBTreeTupleCursor.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractChunkedTupleIterator.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractNode.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/BigdataMap.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/FixedLengthPrefixSplits.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IRangeQuery.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegmentBuilder.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegmentMultiBlockIterator.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/KeyAfterPartitionException.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/KeyBeforePartitionException.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/Leaf.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/Node.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/ResultSet.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/data/DefaultLeafCoder.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/filter/Advancer.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/filter/PrefixFilter.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/filter/TupleFilter.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/keys/IKeyBuilder.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/keys/KVO.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/keys/KeyBuilder.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/proc/AbstractKeyRangeIndexProcedure.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/proc/BatchRemove.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/raba/AbstractRaba.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/raba/MutableKeyBuffer.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/raba/ReadOnlyKeysRaba.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/raba/ReadOnlyValuesRaba.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/raba/codec/CanonicalHuffmanRabaCoder.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/raba/codec/FixedLengthValueRabaCoder.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/raba/codec/SimpleRabaCoder.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/view/FusedTupleCursor.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/view/FusedTupleIterator.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/io/AbstractFixedByteArrayBuffer.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/io/ByteArrayBuffer.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/io/FileLockUtility.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/io/FixedByteArrayBuffer.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/DumpJournal.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/mdi/LocalPartitionMetadata.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/mdi/PartitionLocator.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/metadata/EmbeddedShardLocator.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/rdf/lexicon/LexiconRelation.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/rdf/lexicon/Term2IdWriteProc.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/rdf/load/AssignedSplits.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/rdf/spo/FastRDFValueCoder2.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/rdf/spo/SPOIndexWriteProc.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/rdf/store/AbstractTripleStore.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/relation/accesspath/AbstractAccessPath.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/relation/rule/eval/pipeline/JoinTask.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/JoinIndexPartitionTask.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/SplitUtility.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/search/FullTextIndex.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/search/ReadIndexTask.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/AbstractScaleOutFederation.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/ListIndicesTask.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/MetadataService.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/jini/benchmark/ThroughputMaster.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/jini/util/DumpFederation.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/ndx/AbstractScaleOutClientIndexView.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/ndx/AbstractSplitter.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/ndx/PartitionedTupleIterator.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/ndx/RawDataServiceTupleIterator.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/ndx/pipeline/DefaultDuplicateRemover.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/sparse/AbstractAtomicRowReadOrWrite.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/sparse/AtomicRowFilter.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/sparse/KeyDecoder.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/sparse/LogicalRowSplitHandler.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/striterator/DistinctFilter.java branches/maven_scaleout/bigdata-core/src/main/native/com/bigdata/io/BytesUtil.c branches/maven_scaleout/bigdata-core/src/test/deploy/testing/data/com/bigdata/btree/raba/codec/AbstractRabaCoderTestCase.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/AbstractBTreeTestCase.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/TestAll.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/TestChunkedIterators.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/TestConstrainKeys.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/TestIndexSegmentMultiBlockIterators.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/TestIndexSegmentWithBloomFilter.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/TestInsertLookupRemoveKeysInRootLeaf.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/TestIterators.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/data/AbstractNodeOrLeafDataRecordTestCase.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/filter/TestPrefixFilter.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/isolation/TestIsolatedFusedView.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/keys/AbstractUnicodeKeyBuilderTestCase.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/keys/TestICUUnicodeKeyBuilder.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/keys/TestKeyBuilder.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/raba/TestKeyBufferSearch.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/raba/codec/AbstractRabaCoderTestCase.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/raba/codec/RandomKeysGenerator.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/raba/codec/RandomURIGenerator.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/raba/codec/TestCanonicalHuffmanRabaCoder.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/raba/codec/TokenizeKeysGenerator.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/view/TestFusedView.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/counters/TestHistoryInstrument.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/io/TestByteArrayBuffer.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/io/TestDataOutputBuffer.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/io/TestFileChannelUtility.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/io/TestFixedByteArrayBuffer.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/journal/TestUnisolatedWriteTasks.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/rdf/lexicon/TestComparators.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/rdf/lexicon/TestId2TermTupleSerializer.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/rdf/lexicon/TestSerialization.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/rdf/lexicon/TestTerm2IdTupleSerializer.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/rdf/spo/TestSPOKeyOrder.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/rdf/spo/TestSPOTupleSerializer.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/rdf/store/AbstractTestCase.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/rdf/store/TestInsertRate.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/resources/TestSegSplitter.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/search/TestKeyBuilder.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/service/AbstractEmbeddedFederationTestCase.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/service/TestRangeQuery.java Added Paths: ----------- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/io/BytesUtil.java branches/maven_scaleout/bigdata-core/src/main/native/com/bigdata/io/ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/io/TestBytesUtil.java Removed Paths: ------------- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/BytesUtil.java branches/maven_scaleout/bigdata-core/src/main/native/com/bigdata/btree/ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/TestBytesUtil.java Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/LRUNexus.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/LRUNexus.java 2010-09-15 21:51:13 UTC (rev 3562) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/LRUNexus.java 2010-09-15 23:01:17 UTC (rev 3563) @@ -35,7 +35,7 @@ import org.apache.log4j.Logger; -import com.bigdata.btree.BytesUtil; +import com.bigdata.io.BytesUtil; import com.bigdata.btree.IndexMetadata; import com.bigdata.btree.IndexSegment; import com.bigdata.btree.IndexSegmentBuilder; Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/bfs/AtomicBlockAppendProc.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/bfs/AtomicBlockAppendProc.java 2010-09-15 21:51:13 UTC (rev 3562) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/bfs/AtomicBlockAppendProc.java 2010-09-15 23:01:17 UTC (rev 3563) @@ -12,7 +12,7 @@ import com.bigdata.btree.AbstractBTree; import com.bigdata.btree.BTree; -import com.bigdata.btree.BytesUtil; +import com.bigdata.io.BytesUtil; import com.bigdata.btree.IIndex; import com.bigdata.btree.ILinearList; import com.bigdata.btree.IRangeQuery; Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractBTree.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractBTree.java 2010-09-15 21:51:13 UTC (rev 3562) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractBTree.java 2010-09-15 23:01:17 UTC (rev 3563) @@ -41,6 +41,7 @@ import java.util.concurrent.Executor; import java.util.concurrent.FutureTask; +import com.bigdata.io.BytesUtil; import org.apache.log4j.Level; import org.apache.log4j.Logger; Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractBTreeTupleCursor.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractBTreeTupleCursor.java 2010-09-15 21:51:13 UTC (rev 3562) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractBTreeTupleCursor.java 2010-09-15 23:01:17 UTC (rev 3563) @@ -30,6 +30,7 @@ import java.util.NoSuchElementException; +import com.bigdata.io.BytesUtil; import org.apache.log4j.Logger; import com.bigdata.btree.Leaf.ILeafListener; Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractChunkedTupleIterator.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractChunkedTupleIterator.java 2010-09-15 21:51:13 UTC (rev 3562) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractChunkedTupleIterator.java 2010-09-15 23:01:17 UTC (rev 3563) @@ -32,6 +32,7 @@ import java.util.Iterator; import java.util.NoSuchElementException; +import com.bigdata.io.BytesUtil; import org.apache.log4j.Logger; import com.bigdata.btree.filter.IFilterConstructor; Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractNode.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractNode.java 2010-09-15 21:51:13 UTC (rev 3562) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractNode.java 2010-09-15 23:01:17 UTC (rev 3563) @@ -39,6 +39,7 @@ import com.bigdata.btree.raba.IRaba; import com.bigdata.btree.raba.MutableKeyBuffer; import com.bigdata.cache.HardReferenceQueue; +import com.bigdata.io.BytesUtil; import cutthecrap.utils.striterators.Expander; import cutthecrap.utils.striterators.IStriterator; Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/BigdataMap.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/BigdataMap.java 2010-09-15 21:51:13 UTC (rev 3562) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/BigdataMap.java 2010-09-15 23:01:17 UTC (rev 3563) @@ -40,6 +40,7 @@ import com.bigdata.btree.filter.FilterConstructor; import com.bigdata.btree.filter.TupleFilter; import com.bigdata.btree.keys.KeyBuilder; +import com.bigdata.io.BytesUtil; import com.bigdata.journal.ConcurrencyManager; /** Deleted: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/BytesUtil.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/BytesUtil.java 2010-09-15 21:51:13 UTC (rev 3562) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/BytesUtil.java 2010-09-15 23:01:17 UTC (rev 3563) @@ -1,956 +0,0 @@ -/** - -Copyright (C) SYSTAP, LLC 2006-2007. All rights reserved. - -Contact: - SYSTAP, LLC - 4501 Tower Road - Greensboro, NC 27410 - lic...@bi... - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; version 2 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -package com.bigdata.btree; - -import it.unimi.dsi.fastutil.bytes.custom.CustomByteArrayFrontCodedList; -import it.unimi.dsi.io.InputBitStream; -import it.unimi.dsi.io.OutputBitStream; - -import java.util.Comparator; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.apache.log4j.Logger; - -import com.bigdata.rawstore.Bytes; - -/** - * Class supporting operations on variable length byte[] keys. - * <p> - * Comparison operations that accept a starting offset are used when the byte[]s - * are known to share a leading prefix that may be skipped during comparison. - * <p> - * Comparison operations that accept a starting offset and length are used when - * immutable keys are stored in a single byte[] and an index into starting - * positions in that byte[] is maintained. - * <p> - * JNI methods are provided for unsigned byte[] comparison. However, note that - * the JNI methods do not appear to be as fast as the pure Java methods - - * presumably because of the overhead of going from Java to C. In order to - * execute using the JNI methods you MUST define the optional boolean system - * property, e.g., - * - * <pre> - * java -Dcom.bigdata.btree.BytesUtil.jni=true ... - * </pre> - * - * See BytesUtil.c in this package for instructions on compiling the JNI - * methods. - * </p> - * See {@link #main(String[])} which provides a test for the JNI integration and - * some pointers on how to get this running on your platform. - * - * @author <a href="mailto:tho...@us...">Bryan Thompson</a> - * @version $Id$ - */ -public class BytesUtil { - - protected static final transient Logger log = Logger.getLogger(BytesUtil.class); - - /** - * An empty <code>byte[]</code>. - */ - public static final byte[] EMPTY = new byte[0]; - - /** - * An empty <code>byte[][]</code>. - */ - public static final byte[][] EMPTY2 = new byte[0][]; - - /** - * Flag set iff JNI linking succeeds. When this flag is false we run with - * the pure Java implementations of these methods. When the flag is true, - * the JNI versions are used. - */ - static boolean linked = false; - - /** - * JNI routines are not invoked unless we will compare byte[]s with at least - * this many potential bytes to compare (the actual# may be much less of - * course since comparisons may fail fast). - */ - static public final int minlen = 100; - - static private native int _compareBytes(int alen, byte[] a, int blen, byte[] b); - static private native int _compareBytesWithOffsetAndLen(int aoff, int alen, byte[] a, int boff, int blen, byte[] b); - - static { - - final boolean jni; - - String val = System.getProperty("com.bigdata.btree.BytesUtil.jni"); - - if (val != null) { - - jni = Boolean.parseBoolean(val); - - } else { - - jni = false; // Note: We will not even try to use JNI by default! - - } - - if (jni) { - - /* - * Attempt to load the JNI library. - */ - - loadJNILibrary(); - - } - - } - - /** - * Attempt to load the JNI library. - * <p> - * Note: this is done automatically if the optional boolean system property - * <code>com.bigdata.btree.BytesUtil.jni=true</code> is specified, e.g., - * using - * - * <pre> - * java -Dcom.bigdata.btree.BytesUtil.jni=true ... - * </pre> - * - * @return True iff the JNI library was successfully linked. - */ - public static boolean loadJNILibrary() { - - if (!linked) { - - try { - - System.loadLibrary("BytesUtil"); - - if (log.isInfoEnabled()) - log.info("BytesUtil JNI linked"); - - linked = true; - - } catch (UnsatisfiedLinkError ex) { - - log.warn("BytesUtil JNI NOT linked: " + ex); - - linked = false; - - } - } - - return linked; - - } - - /** - * True iff the two arrays compare as equal. This is somewhat optimized in - * that it tests the array lengths first, assumes that it is being used on - * sorted data and therefore compares the last bytes first, and does not - * convert the bytes to unsigned integers before testing for equality. - * - * @param a - * A byte[]. - * @param b - * Another byte[]. - * - * @return If the two arrays have the same reference (including - * <code>null</code>) or if they have the same data. - */ - final public static boolean bytesEqual(final byte[] a, final byte[] b) { - - if (a == b) - return true; - - final int alen = a.length; - - final int blen = b.length; - - if (alen != blen) - return false; - - int i = alen - 1; - - while (i >= 0) { - - if (a[i] != b[i]) - return false; - - i--; - - } - -// for (int i = 0; i < alen; i++) { -// -// if( a[i] != b[i] ) return false; -// -// } - - return true; - - } - - /** - * Byte-wise comparison of byte[]s (the arrays are treated as arrays of - * unsigned bytes). - * - * @param a - * A byte[]. - * - * @param b - * A byte[]. - * - * @return a negative integer, zero, or a positive integer if the first - * argument is less than, equal to, or greater than the second. - * - * @todo Return the index of the byte at which the difference with the sign - * adjusted to indicate the relative order of the data rather than the - * difference of the bytes at that index. The index would be negative - * or positive depending on which way the comparison went. See - * {@link CustomByteArrayFrontCodedList} for an implementation - * guideline. - * <p> - * Change all implementations in this class and also BytesUtil.c, - * which needs to be recompiled for Windows. Also makes sure that it - * gets compiled and linked for Un*x. That should be tested from the - * ant installer and the result reported. Do the same for ICU4JNI. - */ - final public static int compareBytes(final byte[] a, final byte[] b) { - if(a==b) return 0; - final int alen = a.length; - final int blen = b.length; - if (linked && alen > minlen && blen > minlen) { - /* - * JNI implementation. - * - * @todo test for trade off when max(len) is short. unroll loop for - * small N. - */ - return _compareBytes(alen,a, blen,b); - } - for (int i = 0; i < alen && i < blen; i++) { - // promotes to signed integers in [0:255] for comparison. - final int ret = (a[i] & 0xff) - (b[i] & 0xff); - // int ret = a[i] - b[i]; - if (ret != 0) - return ret; - } - return alen - blen; - } - -// /** -// * Byte-wise comparison of a {@link ByteBuffer} and a byte[]. The data are -// * treated as arrays of unsigned bytes. The {@link ByteBuffer} position, -// * limit and mark are unchanged by this procedure. -// * -// * @param a -// * A {@link ByteBuffer}. -// * @param aoff -// * The offset of the starting byte in the buffer. -// * @param blen -// * The number of bytes to be compared. -// * @param b -// * A byte[]. -// * -// * @return a negative integer, zero, or a positive integer if the first -// * argument is less than, equal to, or greater than the second. -// */ -// final public static int compareBytes(final ByteBuffer a, final int aoff, -// final int alen, final byte[] b) { -// final int blen = b.length; -// for (int i = 0; i < alen && i < blen; i++) { -// // promotes to signed integers in [0:255] for comparison. -// final int ret = (a.get(aoff + i) & 0xff) - (b[i] & 0xff); -// if (ret != 0) -// return ret; -// } -// return alen - blen; -// } - -// /** -// * Byte-wise comparison of byte[]s (the arrays are treated as arrays of -// * unsigned bytes). -// * -// * @param aoff -// * The offset into <i>a</i> at which the comparison will -// * begin. -// * @param a -// * A byte[]. -// * @param boff -// * The offset into <i>b</i> at which the comparison will -// * begin. -// * @param b -// * A byte[]. -// * -// * @return a negative integer, zero, or a positive integer as the first -// * argument is less than, equal to, or greater than the second. -// */ -// final public static int compareBytes(int aoff, final byte[] a, int boff, -// final byte[] b) { -// final int alen = a.length; -// final int blen = b.length; -// for (int i = aoff, j = boff; i < alen && j < blen; i++, j++) { -// // promotes to signed integers in [0:255] for comaprison. -// int ret = (a[i] & 0xff) - (b[j] & 0xff); -// // int ret = a[i] - b[j]; -// if (ret != 0) -// return ret; -// } -// return (alen - aoff) - (blen - boff); -// } - - /** - * Byte-wise comparison of byte[]s (the arrays are treated as arrays of - * unsigned bytes). - * - * @param aoff - * The offset into <i>a</i> at which the comparison will - * begin. - * @param alen - * The #of bytes in <i>a</i> to consider starting at <i>aoff</i>. - * @param a - * A byte[]. - * @param boff - * The offset into <i>b</i> at which the comparison will - * begin. - * @param blen - * The #of bytes in <i>b</i> to consider starting at <i>boff</i>. - * @param b - * A byte[]. - * - * @return a negative integer, zero, or a positive integer as the first - * argument is less than, equal to, or greater than the second. - */ - final public static int compareBytesWithLenAndOffset(// - int aoff, int alen, final byte[] a,// - int boff, int blen, final byte[] b// - ) { - - if (linked && alen > minlen && blen > minlen) { - - // JNI implementation. - return _compareBytesWithOffsetAndLen(aoff, alen, a, boff, blen, b); - - } - - // last index to consider in a[]. - final int alimit = aoff + alen; - - // last index to consider in b[]. - final int blimit = boff + blen; - - for (int i = aoff, j = boff; i < alimit && j < blimit; i++, j++) { - - // promotes to signed integers in [0:255] for comaprison. - int ret = (a[i] & 0xff) - (b[j] & 0xff); - - if (ret != 0) - return ret; - - } - - return alen - blen; - - } - - /** - * Return the #of leading bytes in common. This is used to compute the - * prefix for a node or leaf, which is formed by the leading bytes in common - * between the first and last key for a node or leaf. - * - * @param a - * A variable length unsigned byte array. - * @param b - * A variable length unsigned byte array. - * - * @return The #of leading bytes in common (aka the index of the first byte - * in which the two arrays differ, although that index could lie - * beyond the end of one of the arrays). - */ - public final static int getPrefixLength(final byte[] a, final byte[] b) { - - final int alen = a.length; - - final int blen = b.length; - - int i; - - for (i = 0; i < alen && i < blen; i++) { - - if (a[i] != b[i]) - break; - - } - - return i; - - } - - /** - * Return a new byte[] containing the leading bytes in common between two - * byte[]s. This is often used to compute the minimum length separator key. - * - * @param a - * A variable length unsigned byte array[]. - * @param b - * A variable length unsigned byte array[]. - * - * @return A new byte[] containing the leading bytes in common between the - * two arrays. - */ - public final static byte[] getPrefix(final byte[] a, final byte[] b) { - - final int len = getPrefixLength(a, b); - - final byte[] prefix = new byte[len]; - - System.arraycopy(a, 0, prefix, 0, len); - - return prefix; - - } - - /** - * Computes the successor of a variable length byte array by appending a - * unsigned zero(0) byte to the end of the array. - * - * @param key - * A variable length unsigned byte array. - * - * @return A new unsigned byte[] that is the successor of the key. - */ - public final static byte[] successor(final byte[] key) { - - final int keylen = key.length; - - final byte[] tmp = new byte[keylen + 1]; - - System.arraycopy(key, 0, tmp, 0, keylen); - - return tmp; - - } - - /** - * <p> - * The keys in the nodes of a btree are known as <i>separator keys</i>. The - * role of the separator keys is to direct search towards the leaf in which - * a key exists or would exist by always searching the first child having a - * separator key that is greater than or equal to the search key. - * </p> - * <p> - * Separator keys separate leaves and must be choosen with that purpose in - * mind. The simplest way to choose the separator key is to just take the - * first key of the leaf - this is always correct. However, shorter - * separator keys may be choosen by defining the separator key as the - * shortest key that is less than or equal to the first key of a leaf and - * greater than the last key of the left sibling of that leaf (that is, the - * key for the entry that immediately proceeds the first entry on the leaf). - * </p> - * <p> - * There are several advantages to always choosing the shortest separator - * key. The original rationale (in "Prefix <i>B</i>-Trees" by Bayer and - * Unterauer) was to increase the branching factors for fixed size pages. - * Since we use variable size serialized record, that is not an issue. - * However, using the shortest separator keys in this implementation - * provides both smaller serialized records for nodes and faster search - * since fewer bytes must be tested. - * </p> - * <p> - * Note that this trick can not be used at higher levels in the btree - - * separator keys are always formed based on the keys in the leaves and then - * propagated through the tree. - * </p> - * <p> - * The rules are simple enough: - * <ol> - * <li>The separator contains all bytes in the shared prefix (if any) plus - * the 1st byte at which the given key differs from the prior key.</li> - * <li>If the separator key would equal the given key by value then return - * the reference to the given key.</li> - * </ol> - * </p> - * - * @param givenKey - * A key. - * - * @param priorKey - * Another key that <em>proceeds</em> the <i>givenKey</i>. - * - * @return The shortest key that is less than or equal to <i>givenKey</i> - * and greater than <i>priorKey</i>. This will be a reference to - * the <i>givenKey</i> iff that is also the shortest separator. - * - * @see http://portal.acm.org/citation.cfm?doid=320521.320530 - * - * @throws IllegalArgumentException - * if either key is <code>null</code>. - * @throws IllegalArgumentException - * if both keys are the same reference. - */ -// * @throws IllegalArgumentException -// * if the keys are equal. -// * @throws IllegalArgumentException -// * if the keys are out of order. - final public static byte[] getSeparatorKey(final byte[] givenKey, - final byte[] priorKey) { - - if (givenKey == null) - throw new IllegalArgumentException(); - - if (priorKey == null) - throw new IllegalArgumentException(); - - if (givenKey == priorKey) - throw new IllegalArgumentException(); - - final int prefixLen = getPrefixLength(givenKey, priorKey); - - if (prefixLen == givenKey.length - 1) { - - /* - * The given key is the shortest separator. Examples would include: - * - * given: 0 1 2 - * prior: 0 1 - * - * or - * - * given: 0 1 2 - * prior: 0 1 1 - * - * or - * - * given: 0 1 2 - * prior: 0 1 1 2 - */ - - return givenKey; - - } - - /* - * The separator includes all bytes in the shared prefix plus the next - * byte from the given key. - */ - - // allocate to right size. - final byte[] tmp = new byte[prefixLen+1]; - - // copy shared prefix plus the following byte. - System.arraycopy(givenKey, 0, tmp, 0, prefixLen+1); - - return tmp; - - } - - /** - * Formats a key as a series of comma delimited unsigned bytes. - * - * @param key - * The key. - * - * @return The string representation of the array as unsigned bytes. - */ - final public static String toString(final byte[] key) { - - if (key == null) - return NULL; - - return toString(key, 0, key.length); - - } - - /** - * Formats a key as a series of comma delimited unsigned bytes. - * - * @param key - * The key. - * @param off - * The index of the first byte that will be visited. - * @param len - * The #of bytes to visit. - * - * @return The string representation of the array as unsigned bytes. - */ - final public static String toString(final byte[] key, final int off, - final int len) { - - if (key == null) - return NULL; - - final StringBuilder sb = new StringBuilder(len * 4 + 2); - - sb.append("["); - - for (int i = off; i < off + len; i++) { - - if (i > 0) - sb.append(", "); - - // as an unsigned integer. -// sb.append(Integer.toHexString(key[i] & 0xff)); - sb.append(Integer.toString(key[i] & 0xff)); - - } - - sb.append("]"); - - return sb.toString(); - - } - - private static transient String NULL = "null"; - - /** - * Formats the data into a {@link String}. - * - * @param data - * An array of unsigned byte arrays. - */ - static public String toString(final byte[][] data) { - - final StringBuilder sb = new StringBuilder(); - - final int n = data.length; - - sb.append("data(n=" + n + ")={"); - - for (int i = 0; i < n; i++) { - - final byte[] a = data[i]; - - sb.append("\n"); - - sb.append("data[" + i + "]="); - - sb.append(BytesUtil.toString(a)); - - if (i + 1 < n) - sb.append(","); - - } - - sb.append("}"); - - return sb.toString(); - - } - - /** - * Binary search on an array whose members are variable length unsigned - * byte[]s. - * - * @param keys - * The buffer. - * @param base - * The offset of the base of the array within the buffer. - * @param nmem - * The #of members in the array. When [nmem == 0], the array is - * empty. - * @param key - * The key for the search. - * - * @return index of the search key, if it is contained in <i>keys</i>; - * otherwise, <code>(-(insertion point) - 1)</code>. The - * insertion point is defined as the point at which the key would be - * inserted into the array of keys. Note that this guarantees that - * the return value will be >= 0 if and only if the key is found. - */ - static final public int binarySearch(final byte[][] keys, final int base, - final int nmem, final byte[] key) { - - int low = 0; - - int high = nmem - 1; - - while (low <= high) { - - final int mid = (low + high) >> 1; - - final int offset = base + mid; - - final byte[] midVal = keys[offset]; - - // compare actual vs probe - final int tmp = BytesUtil.compareBytes(midVal, key); - - if (tmp < 0) { - - // Actual LT probe, restrict lower bound and try again. - low = mid + 1; - - } else if (tmp > 0) { - - // Actual GT probe, restrict upper bound and try again. - high = mid - 1; - - } else { - - // Actual EQ probe. Found : return offset. - - return offset; - - } - - } - - // Not found: return insertion point. - - final int offset = (base + low); - - return -(offset + 1); - - } - - /** - * Compares two unsigned byte[]s. - * - * @author <a href="mailto:tho...@us...">Bryan Thompson</a> - * @version $Id$ - */ - public static class UnsignedByteArrayComparator implements Comparator<byte[]> { - - public static transient final Comparator<byte[]> INSTANCE = new UnsignedByteArrayComparator(); - - public int compare(final byte[] o1, final byte[] o2) { - - return BytesUtil.compareBytes(o1, o2); - - } - - } - - /** - * This method forces the load of the JNI library and tries to execute the - * JNI methods. - * <p> - * In order to use the JNI library under Windows, you must specify the JNI - * library location using the PATH environment variable, e.g., - * - * <pre> - * cd bigdata - * set PATH=%PATH%;lib - * java -cp bin com.bigdata.btree.BytesUtil - * </pre> - * - * <p> - * In order to use the JNI library under un*x, you must specify the JNI - * library location - * - * <pre> - * java -Djava.library.path=lib com.bigdata.btree.BytesUtil - * </pre> - * - * @param args - * - * @exception UnsatisfiedLinkError - * if the JNI methods can not be resolved. - * @exception AssertionError - * if the JNI methods do not produce the expected answers. - */ - public static void main(final String[] args) { - - // Force load of the JNI library. - loadJNILibrary(); - - if( 0 != BytesUtil._compareBytes(3, new byte[]{1,2,3}, 3, new byte[]{1,2,3}) ) { - - throw new AssertionError(); - - } - - if( 0 != BytesUtil._compareBytesWithOffsetAndLen(0, 3, new byte[]{1,2,3}, 0, 3, new byte[]{1,2,3}) ) { - - throw new AssertionError(); - - } - - System.out.println("JNI library routines Ok."); - - } - - /** - * Return the #of bytes required to bit code the specified #of bits. - * - * @param nbits - * The #of bit flags. - * - * @return The #of bytes required. This will be zero iff <i>nbits</i> is - * zero. - */ - final public static int bitFlagByteLength(final int nbits) { - - return nbits / 8 + (nbits % 8 == 0 ? 0 : 1); - -// return nbits>>>3; - -// if (nbits == 0) -// return 0; -// -// return ((int) ((nbits / 8) + 1)); - - } - - /** - * Return the index of the byte in which the bit with the given index is - * encoded. - * - * @param bitIndex - * The bit index. - * - * @return The byte index. - */ - final public static int byteIndexForBit(final long bitIndex) { - - return ((int) (bitIndex / 8)); - - } - - /** - * Return the offset within the byte in which the bit is coded of the bit - * (this is just the remainder <code>bitIndex % 8</code>). - * <p> - * Note, the computation of the bit offset is intentionally aligned with - * {@link OutputBitStream} and {@link InputBitStream}. - * - * @param bitIndex - * The bit index into the byte[]. - * - * @return The offset of the bit in the appropriate byte. - */ - final public static int withinByteIndexForBit(final long bitIndex) { - - return 7 - ((int) bitIndex) % 8; - - } - - /** - * Get the value of a bit. - * <p> - * Note, the computation of the bit offset is intentionally aligned with - * {@link OutputBitStream} and {@link InputBitStream}. - * - * @param bitIndex - * The index of the bit. - * - * @return The value of the bit. - */ - final public static boolean getBit(final byte[] buf, final long bitIndex) { - - final int mask = (1 << withinByteIndexForBit(bitIndex)); - - final int off = byteIndexForBit(bitIndex); - - final byte b = buf[off]; - - return (b & mask) != 0; - - } - - /** - * Set the value of a bit - this is NOT thread-safe (contention for the byte - * in the backing buffer can cause lost updates). - * <p> - * Note, the computation of the bit offset is intentionally aligned with - * {@link OutputBitStream} and {@link InputBitStream}. - * - * @param bitIndex - * The index of the bit. - * - * @return The old value of the bit. - */ - final public static boolean setBit(final byte[] buf, final long bitIndex, - final boolean value) { - - final int mask = (1 << withinByteIndexForBit(bitIndex)); - - final int off = byteIndexForBit(bitIndex); - - // current byte at that index. - byte b = buf[off]; - - final boolean oldValue = (b & mask) != 0; - - if (value) - b |= mask; - else - b &= ~mask; - - buf[off] = b; - - return oldValue; - - } - - /** - * Decode a string of the form <code>[0-9]+(k|kb|m|mb|g|gb)?</code>, - * returning the number of bytes. When a suffix indicates kilobytes, - * megabytes, or gigabytes then the returned value is scaled accordingly. - * The suffix is NOT case sensitive. - * - * @param s - * The string value. - * - * @return The byte count. - * - * @throws IllegalArgumentException - * if there is a problem with the argument (<code>null</code>, - * ill-formed, etc). - */ - static public long getByteCount(final String s) { - - if (s == null) - throw new IllegalArgumentException(); - - final Matcher m = PATTERN_BYTE_COUNT.matcher(s); - - if (!m.matches()) - throw new IllegalArgumentException(s); - - // the numeric component. - final String g1 = m.group(1); - - final long c = Long.valueOf(g1); - - // the units (null if not given). - final String g2 = m.group(2); - - final long count; - if (g2 == null) { - count = c; - } else if (g2.equalsIgnoreCase("k") || g2.equalsIgnoreCase("kb")) { - count = c * Bytes.kilobyte; - } else if (g2.equalsIgnoreCase("m") || g2.equalsIgnoreCase("mb")) { - count = c * Bytes.megabyte; - } else if (g2.equalsIgnoreCase("g") || g2.equalsIgnoreCase("gb")) { - count = c * Bytes.gigabyte; - } else { - throw new AssertionError(); - } - return count; - } - - static final private Pattern PATTERN_BYTE_COUNT = Pattern.compile( - "([0-9]+)(k|kb|m|mb|g|gb)?", Pattern.CASE_INSENSITIVE); - -} Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/FixedLengthPrefixSplits.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/FixedLengthPrefixSplits.java 2010-09-15 21:51:13 UTC (rev 3562) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/FixedLengthPrefixSplits.java 2010-09-15 23:01:17 UTC (rev 3563) @@ -6,6 +6,7 @@ import java.io.ObjectOutput; import java.io.Serializable; +import com.bigdata.io.BytesUtil; import org.apache.log4j.Logger; import com.bigdata.rawstore.Bytes; Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IRangeQuery.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IRangeQuery.java 2010-09-15 21:51:13 UTC (rev 3562) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IRangeQuery.java 2010-09-15 23:01:17 UTC (rev 3563) @@ -316,7 +316,7 @@ * @see SuccessorUtil, which may be used to compute the successor of a value * before encoding it as a component of a key. * - * @see BytesUtil#successor(byte[]), which may be used to compute the + * @see com.bigdata.io.BytesUtil#successor(byte[]), which may be used to compute the * successor of an encoded key. * * @see EntryFilter, which may be used to filter the entries visited by the @@ -361,7 +361,7 @@ * @see SuccessorUtil, which may be used to compute the successor of a value * before encoding it as a component of a key. * - * @see BytesUtil#successor(byte[]), which may be used to compute the + * @see com.bigdata.io.BytesUtil#successor(byte[]), which may be used to compute the * successor of an encoded key. * * @see IFilterConstructor, which may be used to construct an iterator stack Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegmentBuilder.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegmentBuilder.java 2010-09-15 21:51:13 UTC (rev 3562) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegmentBuilder.java 2010-09-15 23:01:17 UTC (rev 3563) @@ -42,6 +42,7 @@ import java.util.concurrent.Callable; import java.util.concurrent.atomic.AtomicLong; +import com.bigdata.io.*; import org.apache.log4j.Logger; import com.bigdata.LRUNexus; @@ -53,13 +54,6 @@ import com.bigdata.btree.raba.MutableValueBuffer; import com.bigdata.btree.view.FusedView; import com.bigdata.cache.IGlobalLRU.ILRUCache; -import com.bigdata.io.AbstractFixedByteArrayBuffer; -import com.bigdata.io.ByteArrayBuffer; -import com.bigdata.io.DataInputBuffer; -import com.bigdata.io.FileChannelUtility; -import com.bigdata.io.NOPReopener; -import com.bigdata.io.SerializerUtil; -import com.bigdata.io.WriteCache; import com.bigdata.journal.Journal; import com.bigdata.journal.Name2Addr; import com.bigdata.journal.TemporaryRawStore; Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegmentMultiBlockIterator.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegmentMultiBlockIterator.java 2010-09-15 21:51:13 UTC (rev 3562) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegmentMultiBlockIterator.java 2010-09-15 23:01:17 UTC (rev 3563) @@ -4,6 +4,7 @@ import java.nio.ByteBuffer; import java.util.NoSuchElementException; +import com.bigdata.io.BytesUtil; import org.apache.log4j.Logger; import com.bigdata.btree.IndexSegment.IndexSegmentTupleCursor; @@ -538,7 +539,7 @@ return super.toString() + // "{file=" + store.getFile() + // ",checkpoint="+store.getCheckpoint()+// - ",fromKey="+BytesUtil.toString(fromKey)+// + ",fromKey="+ BytesUtil.toString(fromKey)+// ",toKey="+BytesUtil.toString(toKey)+// ",firstLeafAddr=" + store.toString(firstLeafAddr) + // ",lastLeafAddr=" + store.toString(lastLeafAddr) + // Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/KeyAfterPartitionException.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/KeyAfterPartitionException.java 2010-09-15 21:51:13 UTC (rev 3562) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/KeyAfterPartitionException.java 2010-09-15 23:01:17 UTC (rev 3563) @@ -30,6 +30,7 @@ import java.io.File; +import com.bigdata.io.BytesUtil; import com.bigdata.mdi.LocalPartitionMetadata; /** Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/KeyBeforePartitionException.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/KeyBeforePartitionException.java 2010-09-15 21:51:13 UTC (rev 3562) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/KeyBeforePartitionException.java 2010-09-15 23:01:17 UTC (rev 3563) @@ -30,6 +30,7 @@ import java.io.File; +import com.bigdata.io.BytesUtil; import com.bigdata.mdi.LocalPartitionMetadata; /** Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/Leaf.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/Leaf.java 2010-09-15 21:51:13 UTC (rev 3562) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/Leaf.java 2010-09-15 23:01:17 UTC (rev 3563) @@ -30,6 +30,7 @@ import java.util.Iterator; import java.util.WeakHashMap; +import com.bigdata.io.BytesUtil; import org.apache.log4j.Level; import com.bigdata.btree.data.DefaultLeafCoder; Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/Node.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/Node.java 2010-09-15 21:51:13 UTC (rev 3562) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/Node.java 2010-09-15 23:01:17 UTC (rev 3563) @@ -32,11 +32,11 @@ import java.util.Iterator; import java.util.Set; import java.util.concurrent.Executor; -import java.util.concurrent.ExecutorService; import java.util.concurrent.FutureTask; import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReferenceArray; +import com.bigdata.io.BytesUtil; import org.apache.log4j.Level; import com.bigdata.BigdataStatics; Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/ResultSet.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/ResultSet.java 2010-09-15 21:51:13 UTC (rev 3562) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/ResultSet.java 2010-09-15 23:01:17 UTC (rev 3563) @@ -24,6 +24,7 @@ */ package com.bigdata.btree; +import com.bigdata.io.BytesUtil; import it.unimi.dsi.bits.BitVector; import it.unimi.dsi.bits.LongArrayBitVector; import it.unimi.dsi.io.InputBitStream; Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/data/DefaultLeafCoder.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/data/DefaultLeafCoder.java 2010-09-15 21:51:13 UTC (rev 3562) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/data/DefaultLeafCoder.java 2010-09-15 23:01:17 UTC (rev 3563) @@ -27,6 +27,7 @@ package com.bigdata.btree.data; +import com.bigdata.io.BytesUtil; import it.unimi.dsi.bits.Fast; import it.unimi.dsi.io.InputBitStream; import it.unimi.dsi.io.OutputBitStream; @@ -38,7 +39,6 @@ import org.apache.log4j.Logger; -import com.bigdata.btree.BytesUtil; import com.bigdata.btree.IndexMetadata; import com.bigdata.btree.raba.IRaba; import com.bigdata.btree.raba.codec.ICodedRaba; Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/filter/Advancer.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/filter/Advancer.java 2010-09-15 21:51:13 UTC (rev 3562) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/filter/Advancer.java 2010-09-15 23:01:17 UTC (rev 3563) @@ -2,9 +2,9 @@ import java.util.Iterator; +import com.bigdata.io.BytesUtil; import org.apache.log4j.Logger; -import com.bigdata.btree.BytesUtil; import com.bigdata.btree.IIndex; import com.bigdata.btree.ITuple; import com.bigdata.btree.ITupleCursor; Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/filter/PrefixFilter.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/filter/PrefixFilter.java 2010-09-15 21:51:13 UTC (rev 3562) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/filter/PrefixFilter.java 2010-09-15 23:01:17 UTC (rev 3563) @@ -5,7 +5,7 @@ import org.apache.log4j.Logger; -import com.bigdata.btree.BytesUtil; +import com.bigdata.io.BytesUtil; import com.bigdata.btree.ITuple; import com.bigdata.btree.ITupleCursor; import com.bigdata.btree.ITupleIterator; Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/filter/TupleFilter.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/filter/TupleFilter.java 2010-09-15 21:51:13 UTC (rev 3562) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/filter/TupleFilter.java 2010-09-15 23:01:17 UTC (rev 3563) @@ -8,7 +8,7 @@ import com.bigdata.btree.AbstractBTree; import com.bigdata.btree.AbstractTuple; import com.bigdata.btree.BTree; -import com.bigdata.btree.BytesUtil; +import com.bigdata.io.BytesUtil; import com.bigdata.btree.IRangeQuery; import com.bigdata.btree.ITuple; import com.bigdata.btree.ITupleCursor; Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/keys/IKeyBuilder.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/keys/IKeyBuilder.java 2010-09-15 21:51:13 UTC (rev 3562) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/keys/IKeyBuilder.java 2010-09-15 23:01:17 UTC (rev 3563) @@ -34,7 +34,6 @@ import java.util.Properties; import java.util.UUID; -import com.bigdata.btree.BytesUtil; import com.bigdata.btree.keys.KeyBuilder.Options; /** @@ -129,7 +128,7 @@ * * @return A new array containing the key. * - * @see BytesUtil#compareBytes(byte[], byte[]) + * @see com.bigdata.io.BytesUtil#compareBytes(byte[], byte[]) */ public byte[] getKey(); Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/keys/KVO.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/keys/KVO.java 2010-09-15 21:51:13 UTC (rev 3562) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/keys/KVO.java 2010-09-15 23:01:17 UTC (rev 3563) @@ -30,7 +30,7 @@ import java.util.Arrays; -import com.bigdata.btree.BytesUtil; +import com.bigdata.io.BytesUtil; import com.bigdata.service.ndx.pipeline.KVOC; /** Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/keys/KeyBuilder.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/keys/KeyBuilder.java 2010-09-15 21:51:13 UTC (rev 3562) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/keys/KeyBuilder.java 2010-09-15 23:01:17 UTC (rev 3563) @@ -35,7 +35,6 @@ import java.util.Properties; import java.util.UUID; import org.apache.log4j.Logger; -import com.bigdata.btree.BytesUtil; import com.bigdata.btree.ITuple; import com.bigdata.btree.ITupleSerializer; @@ -53,7 +52,7 @@ * @see SuccessorUtil Compute the successor of a value before encoding it as a * component of a key. * - * @see BytesUtil#successor(byte[]) Compute the successor of an encoded key. + * @see com.bigdata.io.BytesUtil#successor(byte[]) Compute the successor of an encoded key. * * @todo introduce a mark and restore feature for generating multiple keys that * share some leading prefix. in general, this is as easy as resetting the Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/proc/AbstractKeyRangeIndexProcedure.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/proc/AbstractKeyRangeIndexProcedure.java 2010-09-15 21:51:13 UTC (rev 3562) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/proc/AbstractKeyRangeIndexProcedure.java 2010-09-15 23:01:17 UTC (rev 3563) @@ -33,7 +33,7 @@ import ... [truncated message content] |
From: <sgo...@us...> - 2010-09-17 17:50:50
|
Revision: 3584 http://bigdata.svn.sourceforge.net/bigdata/?rev=3584&view=rev Author: sgossard Date: 2010-09-17 17:50:43 +0000 (Fri, 17 Sep 2010) Log Message: ----------- [maven_scaleout] : Broke all direct dependency cycles with package 'com.bigdata.config' by removing ignored IIndexManager parameter from Configuration.getProperty() calls. Modified Paths: -------------- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexMetadata.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/config/Configuration.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/AbstractJournal.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/rdf/rules/RDFJoinNexus.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/relation/AbstractResource.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/config/TestConfiguration.java Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexMetadata.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexMetadata.java 2010-09-17 15:04:56 UTC (rev 3583) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexMetadata.java 2010-09-17 17:50:43 UTC (rev 3584) @@ -3053,20 +3053,20 @@ } /** - * @see Configuration#getProperty(IIndexManager, Properties, String, String, + * @see Configuration#getProperty(Properties, String, String, * String) */ protected String getProperty(final IIndexManager indexManager, final Properties properties, final String namespace, final String globalName, final String defaultValue) { - return Configuration.getProperty(indexManager, properties, namespace, + return Configuration.getProperty(properties, namespace, globalName, defaultValue); } /** - * @see Configuration#getProperty(IIndexManager, Properties, String, String, + * @see Configuration#getProperty(Properties, String, String, * String, IValidator) */ protected <E> E getProperty(final IIndexManager indexManager, @@ -3074,7 +3074,7 @@ final String globalName, final String defaultValue, IValidator<E> validator) { - return Configuration.getProperty(indexManager, properties, namespace, + return Configuration.getProperty(properties, namespace, globalName, defaultValue, validator); } Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/config/Configuration.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/config/Configuration.java 2010-09-17 15:04:56 UTC (rev 3583) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/config/Configuration.java 2010-09-17 17:50:43 UTC (rev 3584) @@ -28,19 +28,10 @@ package com.bigdata.config; -import java.io.IOException; import java.util.Properties; -import java.util.UUID; import org.apache.log4j.Logger; -import com.bigdata.btree.BTree; -import com.bigdata.btree.IndexMetadata; -import com.bigdata.journal.IIndexManager; -import com.bigdata.relation.RelationSchema; -import com.bigdata.service.DataService; -import com.bigdata.service.IBigdataFederation; -import com.bigdata.service.IDataService; import com.bigdata.util.NV; /** @@ -64,7 +55,7 @@ * <p> * This presumes a fixed syntactic relation between a resource/index and * its container rather than the explicit relation defined by - * {@link RelationSchema#CONTAINER}. + * {@link com.bigdata.relation.RelationSchema#CONTAINER}. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> * @version $Id$ @@ -99,8 +90,8 @@ * * <li>The default value may be globally overridden using the property name. * For example, you can override the default branching factor for all - * {@link BTree}s by specifying a value for - * {@link IndexMetadata.Options#BTREE_BRANCHING_FACTOR}. In general, the + * {@link com.bigdata.btree.BTree}s by specifying a value for + * {@link com.bigdata.btree.IndexMetadata.Options#BTREE_BRANCHING_FACTOR}. In general, the * name of the property is declared by an interface along with its default * value. </li> * @@ -112,7 +103,7 @@ * <code>com.bigdata.namespace.foo.myIndex.com.bigdata.btree.BTree.branchingFactor</code> ({@value #NAMESPACE} * is the {@link #NAMESPACE} prefix for overrides, <code>foo.myIndex</code> * is the name of the index, and - * {@value IndexMetadata.Options#BTREE_BRANCHING_FACTOR} is the name of the + * com.bigdata.btree.IndexMetadata.Options#BTREE_BRANCHING_FACTOR is the name of the * property that will be overridden for that index). Alternatively you can * override the branching factor for all indices in the "foo" relation by * specifying a value for the property name @@ -123,8 +114,6 @@ * * </ol> * - * @param indexManagerIsIgnored - * The value specified to the ctor (optional). * @param properties * The properties object against which the value of the property * will be resolved. @@ -141,11 +130,11 @@ * * @todo test when namespace is empty (journal uses that) and possibly null. */ - public static String getProperty(final IIndexManager indexManagerIsIgnored, + public static String getProperty( final Properties properties, final String namespace, final String propertyName, final String defaultValue) { - final NV nv = getProperty2(indexManagerIsIgnored, properties, namespace, + final NV nv = getProperty2(properties, namespace, propertyName, defaultValue); if(nv == null) return null; @@ -158,15 +147,13 @@ * Variant returns both the name under which the value was discovered and * the value. * - * @param indexManagerIsIgnored * @param properties * @param namespace * @param globalName * @param defaultValue * @return */ - public static NV getProperty2(final IIndexManager indexManagerIsIgnored, - final Properties properties, final String namespace, + public static NV getProperty2(final Properties properties, final String namespace, final String globalName, final String defaultValue) { // indexManager MAY be null. @@ -263,7 +250,6 @@ * Variant converts to the specified generic type and validates the value. * * @param <E> - * @param indexManager * @param properties * @param namespace * @param globalName @@ -273,7 +259,7 @@ * @return The validated value -or- <code>null</code> if there was no * default. */ - public static <E> E getProperty(final IIndexManager indexManager, + public static <E> E getProperty( final Properties properties, final String namespace, final String globalName, final String defaultValue, final IValidator<E> validator) @@ -282,7 +268,7 @@ if (validator == null) throw new IllegalArgumentException(); - final NV nv = getProperty2(indexManager, properties, namespace, + final NV nv = getProperty2(properties, namespace, globalName, defaultValue); if (nv == null) @@ -315,84 +301,7 @@ // return localName; // // } - - /** - * Resolve the value to a {@link DataService} {@link UUID}. - * - * @param indexManager - * The index manager (optional). - * @param val - * The value is either a {@link UUID} or a service name. - * - * @return The {@link UUID} of the identified service -or- <code>null</code> - * if no service is identified for that value or if the - * <i>indexManager</i> is either not given or not an - * {@link IBigdataFederation}. - * - * @throws IllegalArgumentException - * if the <i>val</i> is <code>null</code>. - */ - static protected UUID resolveDataService(final IIndexManager indexManager, - final String val) { - if (indexManager == null) - return null; - - if (val == null) - throw new IllegalArgumentException(); - - if (!(indexManager instanceof IBigdataFederation)) - return null; - - final IBigdataFederation fed = ((IBigdataFederation) indexManager); - - /* - * Value is a UUID? - */ - try { - - // valid UUID? - return UUID.fromString(val); - - } catch (IllegalArgumentException ex) { - - // Ignore. - - } - - /* - * Value is the name of a data service? - */ - { - - final IDataService dataService = fed.getDataServiceByName(val); - - if (dataService != null) { - - try { - - return dataService.getServiceUUID(); - - } catch (IOException ex) { - - throw new RuntimeException(ex); - - } - - } - - // fall through. - - } - - // can't interpret the value. - - log.warn("Could not resolve: "+val); - - return null; - - } - /** * Return the name that can be used to override the specified property for * the given namespace. Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/AbstractJournal.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/AbstractJournal.java 2010-09-17 15:04:56 UTC (rev 3583) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/AbstractJournal.java 2010-09-17 17:50:43 UTC (rev 3584) @@ -564,13 +564,13 @@ /** * Resolves the property value (static variant for ctor initialization). * - * @see Configuration#getProperty(IIndexManager, Properties, String, String, + * @see Configuration#getProperty(Properties, String, String, * String) */ static protected String getProperty(final Properties properties, final String name, final String defaultValue) { - return Configuration.getProperty(null/* indexManager */, properties, + return Configuration.getProperty(properties, ""/* no namespace */, name, defaultValue); } @@ -578,12 +578,12 @@ /** * Resolves the property value. * - * @see Configuration#getProperty(IIndexManager, Properties, String, String, + * @see Configuration#getProperty(Properties, String, String, * String) */ protected String getProperty(final String name, final String defaultValue) { - return Configuration.getProperty(this, properties, + return Configuration.getProperty(properties, ""/* no namespace */, name, defaultValue); } @@ -597,7 +597,7 @@ protected <E> E getProperty(final String name, final String defaultValue, IValidator<E> validator) { - return Configuration.getProperty(this, properties, + return Configuration.getProperty(properties, ""/* no namespace */, name, defaultValue, validator); } Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/rdf/rules/RDFJoinNexus.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/rdf/rules/RDFJoinNexus.java 2010-09-17 15:04:56 UTC (rev 3583) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/rdf/rules/RDFJoinNexus.java 2010-09-17 17:50:43 UTC (rev 3584) @@ -223,7 +223,7 @@ public String getProperty(final String name, final String defaultValue) { // @todo pass namespace in with the RDFJoinNexusFactory? - return Configuration.getProperty(indexManager, + return Configuration.getProperty( joinNexusFactory.properties, null/* namespace */, name, defaultValue); @@ -233,7 +233,7 @@ final IValidator<T> validator) { // @todo pass namespace in with the RDFJoinNexusFactory? - return Configuration.getProperty(indexManager, + return Configuration.getProperty( joinNexusFactory.properties, null/* namespace */, name, defaultValue, validator); Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/relation/AbstractResource.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/relation/AbstractResource.java 2010-09-17 15:04:56 UTC (rev 3583) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/relation/AbstractResource.java 2010-09-17 17:50:43 UTC (rev 3584) @@ -734,9 +734,7 @@ * Resolve the property value using the {@link IIndexManager}, the * namespace of the resource, and the {@link Properties} instance to be * tested as hidden parameters. - * - * @param globalName - * The global property name. + * * @param defaultValue * The default. * @@ -747,7 +745,7 @@ protected String getProperty(final String localName, final String defaultValue) { - return Configuration.getProperty(indexManager, properties, namespace, + return Configuration.getProperty(properties, namespace, localName, defaultValue); } @@ -764,7 +762,7 @@ protected <T> T getProperty(final String name, final String defaultValue, final IValidator<T> validator) { - return Configuration.getProperty(indexManager, properties, namespace, + return Configuration.getProperty(properties, namespace, name, defaultValue, validator); } Modified: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/config/TestConfiguration.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/config/TestConfiguration.java 2010-09-17 15:04:56 UTC (rev 3583) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/config/TestConfiguration.java 2010-09-17 17:50:43 UTC (rev 3584) @@ -32,11 +32,6 @@ import junit.framework.TestCase; -import com.bigdata.btree.IndexMetadata; -import com.bigdata.journal.IIndexManager; -import com.bigdata.rdf.lexicon.LexiconKeyOrder; -import com.bigdata.rdf.lexicon.LexiconRelation; - /** * Unit tests for {@link Configuration}. * @@ -44,6 +39,12 @@ * @version $Id$ */ public class TestConfiguration extends TestCase { + //These constants happen line up with constants further up the bigdata tree, but the Configuration class really doesn't care. -gossard + private static final String NAME_LEXICON_RELATION = "lex"; + private static final String TERM_2_ID = "TERM2ID"; + private static final String ID_2_TERM = "ID2TERM"; + private static final String SCATTER_SPLIT_DATA_SERVICE_COUNT = "com.bigdata.btree.ScatterSplitConfiguration.dataServiceCount"; + private static final String SCATTER_SPLIT_ENABLED = "com.bigdata.btree.ScatterSplitConfiguration.enabled"; public TestConfiguration() { @@ -63,8 +64,6 @@ */ public void testGlobalOverride() { - final IIndexManager indexManager = null; - final Properties properties = new Properties(); final String namespace = "foo.bar"; @@ -76,12 +75,12 @@ final String globalOverride = "boo"; - assertEquals(defaultValue, Configuration.getProperty(indexManager, + assertEquals(defaultValue, Configuration.getProperty( properties, namespace, globalName, defaultValue)); properties.setProperty(globalName, globalOverride); - assertEquals(globalOverride, Configuration.getProperty(indexManager, + assertEquals(globalOverride, Configuration.getProperty( properties, namespace, globalName, defaultValue)); } @@ -92,8 +91,6 @@ */ public void test_exactNamespaceOverride() { - final IIndexManager indexManager = null; - final Properties properties = new Properties(); final String namespace = "foo.baz"; @@ -108,7 +105,7 @@ final String overrideValue = "boo"; - assertEquals(defaultValue, Configuration.getProperty(indexManager, + assertEquals(defaultValue, Configuration.getProperty( properties, namespace, globalName, defaultValue)); final String overrideName = Configuration.getOverrideProperty( @@ -116,7 +113,7 @@ properties.setProperty(overrideName, overrideValue); - assertEquals(overrideValue, Configuration.getProperty(indexManager, + assertEquals(overrideValue, Configuration.getProperty( properties, namespace, globalName, defaultValue)); } @@ -126,8 +123,6 @@ * the namespace ("foo" vs "foo.baz"). */ public void test_prefixNamespaceOverride() { - - final IIndexManager indexManager = null; final Properties properties = new Properties(); @@ -146,12 +141,12 @@ final String overrideValue = "boo"; - assertEquals(defaultValue, Configuration.getProperty(indexManager, + assertEquals(defaultValue, Configuration.getProperty( properties, namespace, globalName, defaultValue)); properties.setProperty(overrideName, overrideValue); - assertEquals(overrideValue, Configuration.getProperty(indexManager, + assertEquals(overrideValue, Configuration.getProperty( properties, namespace, globalName, defaultValue)); } @@ -161,11 +156,11 @@ final String namespace = "U8000"; final String namespace2 = "U100"; - final String propertyName = IndexMetadata.Options.SCATTER_SPLIT_ENABLED; + final String propertyName = SCATTER_SPLIT_ENABLED; final String overrideName = Configuration.getOverrideProperty(namespace - + "." + LexiconRelation.NAME_LEXICON_RELATION + "." - + LexiconKeyOrder.TERM2ID, propertyName); + + "." + NAME_LEXICON_RELATION + "." + + TERM_2_ID, propertyName); System.err.println(overrideName); @@ -176,31 +171,29 @@ // override this property. p.setProperty(overrideName, "false"); - final IIndexManager indexManager = null; - /* * Verify override used for U8000.lex.TERM2ID (this is the specific case * for the override). */ - assertEquals("false", Configuration.getProperty(indexManager, p, - namespace + "." + LexiconRelation.NAME_LEXICON_RELATION + "." - + LexiconKeyOrder.TERM2ID, propertyName, defaultValue)); + assertEquals("false", Configuration.getProperty( p, + namespace + "." + NAME_LEXICON_RELATION + "." + + TERM_2_ID, propertyName, defaultValue)); /* * Verify override ignored for U8000.lex.ID2TERM (another index in the * same relation). */ - assertEquals(defaultValue, Configuration.getProperty(indexManager, p, - namespace + "." + LexiconRelation.NAME_LEXICON_RELATION + "." - + LexiconKeyOrder.ID2TERM, propertyName, defaultValue)); + assertEquals(defaultValue, Configuration.getProperty(p, + namespace + "." + NAME_LEXICON_RELATION + "." + + ID_2_TERM, propertyName, defaultValue)); /* * Verify override ignored for U100.lex.TERM2ID (an index in a different * relation). */ - assertEquals(defaultValue, Configuration.getProperty(indexManager, p, - namespace2 + "." + LexiconRelation.NAME_LEXICON_RELATION + "." - + LexiconKeyOrder.TERM2ID, propertyName, defaultValue)); + assertEquals(defaultValue, Configuration.getProperty(p, + namespace2 + "." + NAME_LEXICON_RELATION + "." + + TERM_2_ID, propertyName, defaultValue)); } @@ -210,12 +203,12 @@ final String namespace1 = "U100"; final String namespace2 = "U50"; - final String propertyName = IndexMetadata.Options.SCATTER_SPLIT_DATA_SERVICE_COUNT; + final String propertyName = SCATTER_SPLIT_DATA_SERVICE_COUNT; // override of a specific index in a specific relation. final String overrideName = Configuration.getOverrideProperty(namespace - + "." + LexiconRelation.NAME_LEXICON_RELATION + "." - + LexiconKeyOrder.TERM2ID, propertyName); + + "." + NAME_LEXICON_RELATION + "." + + TERM_2_ID, propertyName); // override of all indices in a different relation. final String overrideName2 = Configuration.getOverrideProperty( @@ -243,41 +236,39 @@ // a different override for a different relation. p.setProperty(overrideName2, otherOverride); - final IIndexManager indexManager = null; - /* * Verify override used for U8000.lex.TERM2ID (this is the specific case * for the override). */ - assertEquals("2", Configuration.getProperty(indexManager, p, - namespace + "." + LexiconRelation.NAME_LEXICON_RELATION + "." - + LexiconKeyOrder.TERM2ID, propertyName, defaultValue)); + assertEquals("2", Configuration.getProperty(p, + namespace + "." + NAME_LEXICON_RELATION + "." + + TERM_2_ID, propertyName, defaultValue)); /* * Verify global override used for a different index in the same * relation. */ - assertEquals(globalOverride, Configuration.getProperty(indexManager, p, - namespace + "." + LexiconRelation.NAME_LEXICON_RELATION + "." - + LexiconKeyOrder.ID2TERM, propertyName, defaultValue)); + assertEquals(globalOverride, Configuration.getProperty(p, + namespace + "." + NAME_LEXICON_RELATION + "." + + ID_2_TERM, propertyName, defaultValue)); /* * Verify global override used for an index in another relation. */ - assertEquals(globalOverride, Configuration.getProperty(indexManager, p, - namespace1 + "." + LexiconRelation.NAME_LEXICON_RELATION + "." - + LexiconKeyOrder.TERM2ID, propertyName, defaultValue)); + assertEquals(globalOverride, Configuration.getProperty(p, + namespace1 + "." + NAME_LEXICON_RELATION + "." + + TERM_2_ID, propertyName, defaultValue)); /* * Verify other override used for all indices in the namespace2 * relation. */ - assertEquals(otherOverride, Configuration.getProperty(indexManager, p, - namespace2 + "." + LexiconRelation.NAME_LEXICON_RELATION + "." - + LexiconKeyOrder.TERM2ID, propertyName, defaultValue)); - assertEquals(otherOverride, Configuration.getProperty(indexManager, p, - namespace2 + "." + LexiconRelation.NAME_LEXICON_RELATION + "." - + LexiconKeyOrder.ID2TERM, propertyName, defaultValue)); + assertEquals(otherOverride, Configuration.getProperty(p, + namespace2 + "." + NAME_LEXICON_RELATION + "." + + TERM_2_ID, propertyName, defaultValue)); + assertEquals(otherOverride, Configuration.getProperty(p, + namespace2 + "." + NAME_LEXICON_RELATION + "." + + ID_2_TERM, propertyName, defaultValue)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sgo...@us...> - 2010-09-21 20:49:58
|
Revision: 3607 http://bigdata.svn.sourceforge.net/bigdata/?rev=3607&view=rev Author: sgossard Date: 2010-09-21 20:49:50 +0000 (Tue, 21 Sep 2010) Log Message: ----------- [maven_scaleout] : Moved AbstractStatisticsCollector into 'com.bigdata.counters.httpd' package to break dependency cycles with 'com.bigdata.counters' package. This has also broken out a few other packages that had transitive cycles, notably 'com.bigdata.io' and 'com.bigdata.util.concurrent'. Modified Paths: -------------- branches/maven_scaleout/bigdata-core/src/main/deploy/legacy/scripts/testStatisticsCollector.sh branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/counters/AbstractProcessCollector.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/counters/httpd/DummyEventReportingService.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/counters/linux/StatisticsCollectorForLinux.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/counters/linux/SysstatUtil.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/counters/win/StatisticsCollectorForWindows.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/DiskOnlyStrategy.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/WORMStrategy.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/loadbalancer/EmbeddedLoadBalancer.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/metadata/EmbeddedShardLocator.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/AbstractFederation.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/AbstractService.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/DataService.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/DefaultClientDelegate.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/EmbeddedFederation.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/Event.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/IBigdataClient.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/LoadBalancerService.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/jini/AbstractServer.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/service/StressTestConcurrent.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/service/TestMove.java Added Paths: ----------- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/counters/httpd/AbstractStatisticsCollector.java Removed Paths: ------------- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/counters/AbstractStatisticsCollector.java Modified: branches/maven_scaleout/bigdata-core/src/main/deploy/legacy/scripts/testStatisticsCollector.sh =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/deploy/legacy/scripts/testStatisticsCollector.sh 2010-09-21 18:45:41 UTC (rev 3606) +++ branches/maven_scaleout/bigdata-core/src/main/deploy/legacy/scripts/testStatisticsCollector.sh 2010-09-21 20:49:50 UTC (rev 3607) @@ -4,11 +4,11 @@ # # usage: [interval [count]] # -# See com.bigdata.counters.AbstractStatisticsCollector#main(String[]) +# See com.bigdata.counters.httpd.AbstractStatisticsCollector#main(String[]) source `dirname $0`/bigdataenv java ${JAVA_OPTS} \ -cp ${CLASSPATH} \ - com.bigdata.counters.AbstractStatisticsCollector \ + com.bigdata.counters.httpd.AbstractStatisticsCollector \ $* Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/counters/AbstractProcessCollector.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/counters/AbstractProcessCollector.java 2010-09-21 18:45:41 UTC (rev 3606) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/counters/AbstractProcessCollector.java 2010-09-21 20:49:50 UTC (rev 3607) @@ -78,8 +78,8 @@ /** * Creates the {@link ActiveProcess} and the - * {@link ActiveProcess#start(com.bigdata.counters.AbstractStatisticsCollector.AbstractProcessReader)}s - * it passing in the value returned by the {@link #getProcessReader()} + * {@link ActiveProcess#start}s + * it, passing in the value returned by the {@link #getProcessReader()} */ public void start() { Deleted: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/counters/AbstractStatisticsCollector.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/counters/AbstractStatisticsCollector.java 2010-09-21 18:45:41 UTC (rev 3606) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/counters/AbstractStatisticsCollector.java 2010-09-21 20:49:50 UTC (rev 3607) @@ -1,720 +0,0 @@ -/* - -Copyright (C) SYSTAP, LLC 2006-2008. All rights reserved. - -Contact: - SYSTAP, LLC - 4501 Tower Road - Greensboro, NC 27410 - lic...@bi... - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; version 2 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*/ -/* - * Created on Mar 13, 2008 - */ - -package com.bigdata.counters; - -import java.io.IOException; -import java.lang.management.GarbageCollectorMXBean; -import java.lang.management.ManagementFactory; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.util.Arrays; -import java.util.Enumeration; -import java.util.List; -import java.util.Properties; -import java.util.UUID; - -import org.apache.log4j.Logger; -import org.apache.system.SystemUtil; - -import com.bigdata.counters.httpd.CounterSetHTTPD; -import com.bigdata.counters.linux.StatisticsCollectorForLinux; -import com.bigdata.counters.win.StatisticsCollectorForWindows; -import com.bigdata.io.DirectBufferPool; -import com.bigdata.rawstore.Bytes; -import com.bigdata.util.config.ConfigDeployUtil; -import com.bigdata.util.config.NicUtil; -import com.bigdata.util.httpd.AbstractHTTPD; - -/** - * Base class for collecting data on a host. The data are described by a - * hierarchical collection of {@link ICounterSet}s and {@link ICounter}s. A - * {@link IRequiredHostCounters minimum set of counters} is defined which SHOULD - * be available for decision-making. Implementations are free to report any - * additional data which they can make available. Reporting is assumed to be - * periodic, e.g., every 60 seconds or so. The purpose of these data is to - * support decision-making concerning the over- and under-utilization of hosts - * in support of load balancing of services deployed over those hosts. - * <p> - * An effort has been made to align the core set of counters for both Windows - * and Un*x platforms so as to support the declared counters on all platforms. - * - * @author <a href="mailto:tho...@us...">Bryan Thompson</a> - */ -abstract public class AbstractStatisticsCollector implements IStatisticsCollector { - - protected static final String ps = ICounterSet.pathSeparator; - - final protected static Logger log = Logger - .getLogger(AbstractStatisticsCollector.class); - - /** {@link InetAddress#getCanonicalHostName()} for this host. */ - static final public String fullyQualifiedHostName; - - /** The path prefix under which all counters for this host are found. */ - static final public String hostPathPrefix; - - static { - - String s; - try { - s = NicUtil.getIpAddress("default.nic", ConfigDeployUtil.getString("node.serviceNetwork"), false); - } catch(Throwable t) {//for now, maintain same failure logic as used previously - t.printStackTrace(); - s = NicUtil.getIpAddressByLocalHost(); - } - - fullyQualifiedHostName = s; - - hostPathPrefix = ICounterSet.pathSeparator + fullyQualifiedHostName - + ICounterSet.pathSeparator; - - if (log.isInfoEnabled()) { -// log.info("hostname : " + hostname); - log.info("FQDN : " + fullyQualifiedHostName); - log.info("hostPrefix: " + hostPathPrefix); - } - - } - - /** Reporting interval in seconds. */ - final protected int interval; - - /** - * The interval in seconds at which the counter values are read from the - * host platform. - */ - public int getInterval() { - - return interval; - - } - - protected AbstractStatisticsCollector(int interval) { - - if (interval <= 0) - throw new IllegalArgumentException(); - - if(log.isInfoEnabled()) log.info("interval=" + interval); - - this.interval = interval; - - } - -// /** -// * Return the load average for the last minute if available and -1 -// * otherwise. -// * <p> -// * Note: The load average is available on 1.6+ JVMs. -// * -// * @see OperatingSystemMXBean -// */ -// public double getSystemLoadAverage() -// { -// -//// double version = Double.parseDouble(System.getProperty("java.vm.version")); -//// if(version>=1.6) { -// -// double loadAverage = -1; -// -// final OperatingSystemMXBean mbean = ManagementFactory -// .getOperatingSystemMXBean(); -// -// /* -// * Use reflection since method is only available as of 1.6 -// */ -// Method method; -// try { -// method = mbean.getClass().getMethod("getSystemLoadAverage", -// new Class[] {}); -// loadAverage = (Double) method.invoke(mbean, new Object[] {}); -// } catch (SecurityException e) { -// log.warn(e.getMessage(), e); -// } catch (NoSuchMethodException e) { -// // Note: method is only defined since 1.6 -// log.warn(e.getMessage(), e); -// } catch (IllegalAccessException e) { -// log.warn(e.getMessage(), e); -// } catch (InvocationTargetException e) { -// log.warn(e.getMessage(), e); -// } -// -// return loadAverage; -// -// } - - /** - * {@link CounterSet} hierarchy. - */ - private CounterSet countersRoot; - - /** - * Return the counter hierarchy. The returned hierarchy only includes those - * counters whose values are available from the JVM. This collection is - * normally augmented with platform specific performance counters collected - * using an {@link AbstractProcessCollector}. - * <p> - * Note: Subclasses MUST extend this method to initialize their own - * counters. - */ - synchronized public CounterSet getCounters() { - - if (countersRoot == null) { - - countersRoot = new CounterSet(); - - // os.arch - countersRoot.addCounter(hostPathPrefix - + IHostCounters.Info_Architecture, - new OneShotInstrument<String>(System.getProperty("os.arch"))); - - // os.name - countersRoot.addCounter(hostPathPrefix - + IHostCounters.Info_OperatingSystemName, - new OneShotInstrument<String>(System.getProperty("os.name"))); - - // os.version - countersRoot.addCounter(hostPathPrefix - + IHostCounters.Info_OperatingSystemVersion, - new OneShotInstrument<String>(System.getProperty("os.version"))); - - // #of processors. - countersRoot.addCounter(hostPathPrefix - + IHostCounters.Info_NumProcessors, - new OneShotInstrument<Integer>(SystemUtil.numProcessors())); - - // processor info - countersRoot.addCounter(hostPathPrefix - + IHostCounters.Info_ProcessorInfo, - new OneShotInstrument<String>(SystemUtil.cpuInfo())); - - } - - return countersRoot; - - } - - /** - * Adds the Info and Memory counter sets under the <i>serviceRoot</i>. - * - * @param serviceRoot - * The {@link CounterSet} corresponding to the service (or - * client). - * @param serviceName - * The name of the service. - * @param serviceIface - * The class or interface that best represents the service or - * client. - * @param properties - * The properties used to configure that service or client. - */ - static public void addBasicServiceOrClientCounters(CounterSet serviceRoot, - String serviceName, Class serviceIface, Properties properties) { - - // Service info. - { - - final CounterSet serviceInfoSet = serviceRoot.makePath("Info"); - - serviceInfoSet.addCounter("Service Type", - new OneShotInstrument<String>(serviceIface.getName())); - - serviceInfoSet.addCounter("Service Name", - new OneShotInstrument<String>(serviceName)); - - AbstractStatisticsCollector.addServiceProperties(serviceInfoSet, - properties); - - } - - // Service per-process memory data - { - - serviceRoot.addCounter( - IProcessCounters.Memory_runtimeMaxMemory, - new OneShotInstrument<Long>(Runtime.getRuntime().maxMemory())); - - serviceRoot.addCounter(IProcessCounters.Memory_runtimeFreeMemory, - new Instrument<Long>() { - public void sample() { - setValue(Runtime.getRuntime().freeMemory()); - } - }); - - serviceRoot.addCounter(IProcessCounters.Memory_runtimeTotalMemory, - new Instrument<Long>() { - public void sample() { - setValue(Runtime.getRuntime().totalMemory()); - } - }); - - // add counters for garbage collection. - AbstractStatisticsCollector - .addGarbageCollectorMXBeanCounters(serviceRoot - .makePath(ICounterHierarchy.Memory_GarbageCollectors)); - - // Moved since counters must be dynamically reattached to reflect pool hierarchy. -// /* -// * Add counters reporting on the various DirectBufferPools. -// */ -// { -// -// serviceRoot.makePath( -// IProcessCounters.Memory + ICounterSet.pathSeparator -// + "DirectBufferPool").attach( -// DirectBufferPool.getCounters()); -// -// } - - } - - } - - /** - * Lists out all of the properties and then report each property using a - * {@link OneShotInstrument}. - * - * @param serviceInfoSet - * The {@link ICounterHierarchy#Info} {@link CounterSet} for the - * service. - * @param properties - * The properties to be reported out. - */ - static public void addServiceProperties(final CounterSet serviceInfoSet, - final Properties properties) { - - final CounterSet ptmp = serviceInfoSet.makePath("Properties"); - - final Enumeration<?> e = properties.propertyNames(); - - while (e.hasMoreElements()) { - - final String name; - final String value; - try { - - name = (String) e.nextElement(); - - value = (String) properties.getProperty(name); - - } catch (ClassCastException ex) { - - log.warn(ex.getMessage()); - - continue; - - } - - if (value == null) - continue; - - ptmp.addCounter(name, new OneShotInstrument<String>(value)); - - } - - } - - /** - * Adds/updates counters relating to JVM Garbage Collection. These counters - * should be located within a per-service path. - * - * @param counterSet - * The counters set that is the direct parent. - */ - static public void addGarbageCollectorMXBeanCounters(CounterSet counterSet) { - - final String name_pools = "Memory Pool Names"; - - final String name_count = "Collection Count"; - - final String name_time = "Cumulative Collection Time"; - - synchronized (counterSet) { - - final List<GarbageCollectorMXBean> list = ManagementFactory - .getGarbageCollectorMXBeans(); - - for (final GarbageCollectorMXBean bean : list) { - - final String name = bean.getName(); - - // counter set for this GC bean (may be pre-existing). - final CounterSet tmp = counterSet.makePath(name); - - synchronized (tmp) { - - // memory pool names. - { - if (tmp.getChild(name_pools) == null) { - - tmp.addCounter(name_pools, - new Instrument<String>() { - - @Override - protected void sample() { - - setValue(Arrays.toString(bean - .getMemoryPoolNames())); - - } - - }); - - } - - } - - // collection count. - { - if (tmp.getChild(name_count) == null) { - tmp.addCounter(name_count, new Instrument<Long>() { - - @Override - protected void sample() { - - setValue(bean.getCollectionCount()); - - } - }); - } - } - - // collection time. - { - if (tmp.getChild(name_time) == null) { - tmp.addCounter(name_time, new Instrument<Long>() { - - @Override - protected void sample() { - - setValue(bean.getCollectionTime()); - - } - }); - } - } - - } - - } - - } - - } - - /** - * Start collecting host performance data -- must be extended by the - * concrete subclass. - */ - public void start() { - - if (log.isInfoEnabled()) - log.info("Starting collection."); - - installShutdownHook(); - - } - - /** - * Stop collecting host performance data -- must be extended by the concrete - * subclass. - */ - public void stop() { - - if (log.isInfoEnabled()) - log.info("Stopping collection."); - - } - - /** - * Installs a {@link Runtime#addShutdownHook(Thread)} that executes - * {@link #stop()}. - * <p> - * Note: The runtime shutdown hook appears to be a robust way to handle ^C - * by providing a clean service termination. However, under eclipse (at - * least when running under Windows) you may find that the shutdown hook - * does not run when you terminate a Java application and that typedef - * process build up in the Task Manager as a result. This should not be the - * case during normal deployment. - */ - protected void installShutdownHook() { - - final Thread t = new Thread() { - - public void run() { - - AbstractStatisticsCollector.this.stop(); - - } - - }; - - t.setDaemon(true); - - Runtime.getRuntime().addShutdownHook(t); - - } - - /** - * Options for {@link AbstractStatisticsCollector} - * - * @author <a href="mailto:tho...@us...">Bryan Thompson</a> - */ - public interface Options { - - /** - * The interval in seconds at which the performance counters of the host - * platform will be sampled (default 60). - */ - public String PERFORMANCE_COUNTERS_SAMPLE_INTERVAL = AbstractStatisticsCollector.class - .getPackage().getName() - + ".interval"; - - public String DEFAULT_PERFORMANCE_COUNTERS_SAMPLE_INTERVAL = "60"; - - /** - * The name of the process whose per-process performance counters are to - * be collected (required, no default). This causes the per-process - * counters to be reported using the path: - * - * <strong>/<i>fullyQualifiedHostname</i>/<i>processName</i>/...</strong> - * <p> - * Note: Services are generally associated with a {@link UUID} and that - * {@link UUID} is generally used as the service name. A single host may - * run many different services and will report the counters for each - * service using the path formed as described above. - */ - public String PROCESS_NAME = AbstractStatisticsCollector.class - .getPackage().getName() - + ".processName"; - - } - - /** - * Create an instance appropriate for the operating system on which the JVM - * is running. - * - * @param properties - * See {@link Options} - * - * @throws UnsupportedOperationException - * If there is no implementation available on the operating - * system on which you are running. - * - * @see Options - */ - public static AbstractStatisticsCollector newInstance( - final Properties properties) { - - final int interval = Integer.parseInt(properties.getProperty( - Options.PERFORMANCE_COUNTERS_SAMPLE_INTERVAL, - Options.DEFAULT_PERFORMANCE_COUNTERS_SAMPLE_INTERVAL)); - - if (interval <= 0) - throw new IllegalArgumentException(); - - final String processName = properties.getProperty(Options.PROCESS_NAME); - - if (processName == null) - throw new IllegalArgumentException( - "Required option not specified: " + Options.PROCESS_NAME); - - final String osname = System.getProperty("os.name").toLowerCase(); - - if(osname.equalsIgnoreCase("linux")) { - - return new StatisticsCollectorForLinux(interval, processName); - - } else if(osname.contains("windows")) { - - return new StatisticsCollectorForWindows(interval); - - } else { - - throw new UnsupportedOperationException( - "No implementation available on " - + System.getProperty("os.getname")); - - } - - } - - /** - * Utility runs the {@link AbstractStatisticsCollector} appropriate for your - * operating system. Before performance counter collection starts the static - * counters will be written on stdout. The appropriate process(es) are then - * started to collect the dynamic performance counters. Collection will - * occur every {@link Options#PERFORMANCE_COUNTERS_SAMPLE_INTERVAL} seconds. - * The program will make 10 collections by default and will write the - * updated counters on stdout every - * {@link Options#PERFORMANCE_COUNTERS_SAMPLE_INTERVAL} seconds. - * <p> - * Parameters also may be specified using <code>-D</code>. See - * {@link Options}. - * - * @param args <code>[<i>interval</i> [<i>count</i>]]</code> - * <p> - * <i>interval</i> is the collection interval in seconds and - * defaults to - * {@link Options#DEFAULT_PERFORMANCE_COUNTERS_SAMPLE_INTERVAL}. - * <p> - * <i>count</i> is the #of collections to be made and defaults - * to <code>10</code>. Specify zero (0) to run until halted. - * - * @throws InterruptedException - * @throws RuntimeException - * if the arguments are not valid. - * @throws UnsupportedOperationException - * if no implementation is available for your operating system. - */ - public static void main(final String[] args) throws InterruptedException { - - final int DEFAULT_COUNT = 10; - final int nargs = args.length; - final int interval; - final int count; - if (nargs == 0) { - interval = Integer.parseInt(Options.DEFAULT_PERFORMANCE_COUNTERS_SAMPLE_INTERVAL); - count = DEFAULT_COUNT; - } else if (nargs == 1) { - interval = Integer.parseInt(args[0]); - count = DEFAULT_COUNT; - } else if (nargs == 2) { - interval = Integer.parseInt(args[0]); - count = Integer.parseInt(args[1]); - } else { - throw new RuntimeException("usage: [interval [count]]"); - } - - if (interval <= 0) - throw new RuntimeException("interval must be positive"); - - if (count < 0) - throw new RuntimeException("count must be non-negative"); - - Properties properties = new Properties(System.getProperties()); - - if (nargs != 0) { - - // Override the interval property from the command line. - properties.setProperty(Options.PERFORMANCE_COUNTERS_SAMPLE_INTERVAL,""+interval); - - } - - if(properties.getProperty(Options.PROCESS_NAME)==null) { - - /* - * Set a default process name if none was specified in the - * environment. - * - * Note: Normally the process name is specified explicitly by the - * service which instantiates the performance counter collection for - * that process. We specify a default here since main() is used for - * testing purposes only. - */ - - properties.setProperty(Options.PROCESS_NAME,"testService"); - - } - - final AbstractStatisticsCollector client = AbstractStatisticsCollector - .newInstance( properties ); - - // write counters before we start the client - System.out.println(client.getCounters().toString()); - - System.err.println("Starting performance counter collection: interval=" - + client.interval + ", count=" + count); - - client.start(); - - /* - * HTTPD service reporting out statistics. - */ - AbstractHTTPD httpd = null; - { - final int port = 8080; - if (port != 0) { - try { - httpd = new CounterSetHTTPD(port,client.countersRoot); - } catch (IOException e) { - log.warn("Could not start httpd: port=" + port+" : "+e); - } - } - - } - - int n = 0; - - final long begin = System.currentTimeMillis(); - - // Note: runs until killed when count==0. - while (count == 0 || n < count) { - - Thread.sleep(client.interval * 1000/*ms*/); - - final long elapsed = System.currentTimeMillis() - begin; - - System.err.println("Report #"+n+" after "+(elapsed/1000)+" seconds "); - - System.out.println(client.getCounters().toString()); - - n++; - - } - - System.err.println("Stopping performance counter collection"); - - client.stop(); - - if (httpd != null) - httpd.shutdown(); - - System.err.println("Done"); - - } - - /** - * Converts KB to bytes. - * - * @param kb - * The #of kilobytes. - * - * @return The #of bytes. - */ - static public Double kb2b(final String kb) { - - final double d = Double.parseDouble(kb); - - final double x = d * Bytes.kilobyte32; - - return x; - - } - -} Copied: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/counters/httpd/AbstractStatisticsCollector.java (from rev 3601, branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/counters/AbstractStatisticsCollector.java) =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/counters/httpd/AbstractStatisticsCollector.java (rev 0) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/counters/httpd/AbstractStatisticsCollector.java 2010-09-21 20:49:50 UTC (rev 3607) @@ -0,0 +1,718 @@ +/* + +Copyright (C) SYSTAP, LLC 2006-2008. All rights reserved. + +Contact: + SYSTAP, LLC + 4501 Tower Road + Greensboro, NC 27410 + lic...@bi... + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*/ +/* + * Created on Mar 13, 2008 + */ + +package com.bigdata.counters.httpd; + +import java.io.IOException; +import java.lang.management.GarbageCollectorMXBean; +import java.lang.management.ManagementFactory; +import java.net.InetAddress; +import java.util.Arrays; +import java.util.Enumeration; +import java.util.List; +import java.util.Properties; +import java.util.UUID; + +import com.bigdata.counters.*; +import org.apache.log4j.Logger; +import org.apache.system.SystemUtil; + +import com.bigdata.counters.linux.StatisticsCollectorForLinux; +import com.bigdata.counters.win.StatisticsCollectorForWindows; +import com.bigdata.rawstore.Bytes; +import com.bigdata.util.config.ConfigDeployUtil; +import com.bigdata.util.config.NicUtil; +import com.bigdata.util.httpd.AbstractHTTPD; + +/** + * Base class for collecting data on a host. The data are described by a + * hierarchical collection of {@link com.bigdata.counters.ICounterSet}s and {@link com.bigdata.counters.ICounter}s. A + * {@link com.bigdata.counters.IRequiredHostCounters minimum set of counters} is defined which SHOULD + * be available for decision-making. Implementations are free to report any + * additional data which they can make available. Reporting is assumed to be + * periodic, e.g., every 60 seconds or so. The purpose of these data is to + * support decision-making concerning the over- and under-utilization of hosts + * in support of load balancing of services deployed over those hosts. + * <p> + * An effort has been made to align the core set of counters for both Windows + * and Un*x platforms so as to support the declared counters on all platforms. + * + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + */ +abstract public class AbstractStatisticsCollector implements IStatisticsCollector { + + protected static final String ps = ICounterSet.pathSeparator; + + final protected static Logger log = Logger + .getLogger(AbstractStatisticsCollector.class); + + /** {@link InetAddress#getCanonicalHostName()} for this host. */ + static final public String fullyQualifiedHostName; + + /** The path prefix under which all counters for this host are found. */ + static final public String hostPathPrefix; + + static { + + String s; + try { + s = NicUtil.getIpAddress("default.nic", ConfigDeployUtil.getString("node.serviceNetwork"), false); + } catch(Throwable t) {//for now, maintain same failure logic as used previously + t.printStackTrace(); + s = NicUtil.getIpAddressByLocalHost(); + } + + fullyQualifiedHostName = s; + + hostPathPrefix = ICounterSet.pathSeparator + fullyQualifiedHostName + + ICounterSet.pathSeparator; + + if (log.isInfoEnabled()) { +// log.info("hostname : " + hostname); + log.info("FQDN : " + fullyQualifiedHostName); + log.info("hostPrefix: " + hostPathPrefix); + } + + } + + /** Reporting interval in seconds. */ + final protected int interval; + + /** + * The interval in seconds at which the counter values are read from the + * host platform. + */ + public int getInterval() { + + return interval; + + } + + protected AbstractStatisticsCollector(int interval) { + + if (interval <= 0) + throw new IllegalArgumentException(); + + if(log.isInfoEnabled()) log.info("interval=" + interval); + + this.interval = interval; + + } + +// /** +// * Return the load average for the last minute if available and -1 +// * otherwise. +// * <p> +// * Note: The load average is available on 1.6+ JVMs. +// * +// * @see OperatingSystemMXBean +// */ +// public double getSystemLoadAverage() +// { +// +//// double version = Double.parseDouble(System.getProperty("java.vm.version")); +//// if(version>=1.6) { +// +// double loadAverage = -1; +// +// final OperatingSystemMXBean mbean = ManagementFactory +// .getOperatingSystemMXBean(); +// +// /* +// * Use reflection since method is only available as of 1.6 +// */ +// Method method; +// try { +// method = mbean.getClass().getMethod("getSystemLoadAverage", +// new Class[] {}); +// loadAverage = (Double) method.invoke(mbean, new Object[] {}); +// } catch (SecurityException e) { +// log.warn(e.getMessage(), e); +// } catch (NoSuchMethodException e) { +// // Note: method is only defined since 1.6 +// log.warn(e.getMessage(), e); +// } catch (IllegalAccessException e) { +// log.warn(e.getMessage(), e); +// } catch (InvocationTargetException e) { +// log.warn(e.getMessage(), e); +// } +// +// return loadAverage; +// +// } + + /** + * {@link com.bigdata.counters.CounterSet} hierarchy. + */ + private CounterSet countersRoot; + + /** + * Return the counter hierarchy. The returned hierarchy only includes those + * counters whose values are available from the JVM. This collection is + * normally augmented with platform specific performance counters collected + * using an {@link com.bigdata.counters.AbstractProcessCollector}. + * <p> + * Note: Subclasses MUST extend this method to initialize their own + * counters. + */ + synchronized public CounterSet getCounters() { + + if (countersRoot == null) { + + countersRoot = new CounterSet(); + + // os.arch + countersRoot.addCounter(hostPathPrefix + + IHostCounters.Info_Architecture, + new OneShotInstrument<String>(System.getProperty("os.arch"))); + + // os.name + countersRoot.addCounter(hostPathPrefix + + IHostCounters.Info_OperatingSystemName, + new OneShotInstrument<String>(System.getProperty("os.name"))); + + // os.version + countersRoot.addCounter(hostPathPrefix + + IHostCounters.Info_OperatingSystemVersion, + new OneShotInstrument<String>(System.getProperty("os.version"))); + + // #of processors. + countersRoot.addCounter(hostPathPrefix + + IHostCounters.Info_NumProcessors, + new OneShotInstrument<Integer>(SystemUtil.numProcessors())); + + // processor info + countersRoot.addCounter(hostPathPrefix + + IHostCounters.Info_ProcessorInfo, + new OneShotInstrument<String>(SystemUtil.cpuInfo())); + + } + + return countersRoot; + + } + + /** + * Adds the Info and Memory counter sets under the <i>serviceRoot</i>. + * + * @param serviceRoot + * The {@link CounterSet} corresponding to the service (or + * client). + * @param serviceName + * The name of the service. + * @param serviceIface + * The class or interface that best represents the service or + * client. + * @param properties + * The properties used to configure that service or client. + */ + static public void addBasicServiceOrClientCounters(CounterSet serviceRoot, + String serviceName, Class serviceIface, Properties properties) { + + // Service info. + { + + final CounterSet serviceInfoSet = serviceRoot.makePath("Info"); + + serviceInfoSet.addCounter("Service Type", + new OneShotInstrument<String>(serviceIface.getName())); + + serviceInfoSet.addCounter("Service Name", + new OneShotInstrument<String>(serviceName)); + + AbstractStatisticsCollector.addServiceProperties(serviceInfoSet, + properties); + + } + + // Service per-process memory data + { + + serviceRoot.addCounter( + IProcessCounters.Memory_runtimeMaxMemory, + new OneShotInstrument<Long>(Runtime.getRuntime().maxMemory())); + + serviceRoot.addCounter(IProcessCounters.Memory_runtimeFreeMemory, + new Instrument<Long>() { + public void sample() { + setValue(Runtime.getRuntime().freeMemory()); + } + }); + + serviceRoot.addCounter(IProcessCounters.Memory_runtimeTotalMemory, + new Instrument<Long>() { + public void sample() { + setValue(Runtime.getRuntime().totalMemory()); + } + }); + + // add counters for garbage collection. + AbstractStatisticsCollector + .addGarbageCollectorMXBeanCounters(serviceRoot + .makePath(ICounterHierarchy.Memory_GarbageCollectors)); + + // Moved since counters must be dynamically reattached to reflect pool hierarchy. +// /* +// * Add counters reporting on the various DirectBufferPools. +// */ +// { +// +// serviceRoot.makePath( +// IProcessCounters.Memory + ICounterSet.pathSeparator +// + "DirectBufferPool").attach( +// DirectBufferPool.getCounters()); +// +// } + + } + + } + + /** + * Lists out all of the properties and then report each property using a + * {@link OneShotInstrument}. + * + * @param serviceInfoSet + * The {@link ICounterHierarchy#Info} {@link CounterSet} for the + * service. + * @param properties + * The properties to be reported out. + */ + static public void addServiceProperties(final CounterSet serviceInfoSet, + final Properties properties) { + + final CounterSet ptmp = serviceInfoSet.makePath("Properties"); + + final Enumeration<?> e = properties.propertyNames(); + + while (e.hasMoreElements()) { + + final String name; + final String value; + try { + + name = (String) e.nextElement(); + + value = (String) properties.getProperty(name); + + } catch (ClassCastException ex) { + + log.warn(ex.getMessage()); + + continue; + + } + + if (value == null) + continue; + + ptmp.addCounter(name, new OneShotInstrument<String>(value)); + + } + + } + + /** + * Adds/updates counters relating to JVM Garbage Collection. These counters + * should be located within a per-service path. + * + * @param counterSet + * The counters set that is the direct parent. + */ + static public void addGarbageCollectorMXBeanCounters(CounterSet counterSet) { + + final String name_pools = "Memory Pool Names"; + + final String name_count = "Collection Count"; + + final String name_time = "Cumulative Collection Time"; + + synchronized (counterSet) { + + final List<GarbageCollectorMXBean> list = ManagementFactory + .getGarbageCollectorMXBeans(); + + for (final GarbageCollectorMXBean bean : list) { + + final String name = bean.getName(); + + // counter set for this GC bean (may be pre-existing). + final CounterSet tmp = counterSet.makePath(name); + + synchronized (tmp) { + + // memory pool names. + { + if (tmp.getChild(name_pools) == null) { + + tmp.addCounter(name_pools, + new Instrument<String>() { + + @Override + protected void sample() { + + setValue(Arrays.toString(bean + .getMemoryPoolNames())); + + } + + }); + + } + + } + + // collection count. + { + if (tmp.getChild(name_count) == null) { + tmp.addCounter(name_count, new Instrument<Long>() { + + @Override + protected void sample() { + + setValue(bean.getCollectionCount()); + + } + }); + } + } + + // collection time. + { + if (tmp.getChild(name_time) == null) { + tmp.addCounter(name_time, new Instrument<Long>() { + + @Override + protected void sample() { + + setValue(bean.getCollectionTime()); + + } + }); + } + } + + } + + } + + } + + } + + /** + * Start collecting host performance data -- must be extended by the + * concrete subclass. + */ + public void start() { + + if (log.isInfoEnabled()) + log.info("Starting collection."); + + installShutdownHook(); + + } + + /** + * Stop collecting host performance data -- must be extended by the concrete + * subclass. + */ + public void stop() { + + if (log.isInfoEnabled()) + log.info("Stopping collection."); + + } + + /** + * Installs a {@link Runtime#addShutdownHook(Thread)} that executes + * {@link #stop()}. + * <p> + * Note: The runtime shutdown hook appears to be a robust way to handle ^C + * by providing a clean service termination. However, under eclipse (at + * least when running under Windows) you may find that the shutdown hook + * does not run when you terminate a Java application and that typedef + * process build up in the Task Manager as a result. This should not be the + * case during normal deployment. + */ + protected void installShutdownHook() { + + final Thread t = new Thread() { + + public void run() { + + AbstractStatisticsCollector.this.stop(); + + } + + }; + + t.setDaemon(true); + + Runtime.getRuntime().addShutdownHook(t); + + } + + /** + * Options for {@link AbstractStatisticsCollector} + * + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + */ + public interface Options { + + /** + * The interval in seconds at which the performance counters of the host + * platform will be sampled (default 60). + */ + public String PERFORMANCE_COUNTERS_SAMPLE_INTERVAL = AbstractStatisticsCollector.class + .getPackage().getName() + + ".interval"; + + public String DEFAULT_PERFORMANCE_COUNTERS_SAMPLE_INTERVAL = "60"; + + /** + * The name of the process whose per-process performance counters are to + * be collected (required, no default). This causes the per-process + * counters to be reported using the path: + * + * <strong>/<i>fullyQualifiedHostname</i>/<i>processName</i>/...</strong> + * <p> + * Note: Services are generally associated with a {@link UUID} and that + * {@link UUID} is generally used as the service name. A single host may + * run many different services and will report the counters for each + * service using the path formed as described above. + */ + public String PROCESS_NAME = AbstractStatisticsCollector.class + .getPackage().getName() + + ".processName"; + + } + + /** + * Create an instance appropriate for the operating system on which the JVM + * is running. + * + * @param properties + * See {@link Options} + * + * @throws UnsupportedOperationException + * If there is no implementation available on the operating + * system on which you are running. + * + * @see Options + */ + public static AbstractStatisticsCollector newInstance( + final Properties properties) { + + final int interval = Integer.parseInt(properties.getProperty( + Options.PERFORMANCE_COUNTERS_SAMPLE_INTERVAL, + Options.DEFAULT_PERFORMANCE_COUNTERS_SAMPLE_INTERVAL)); + + if (interval <= 0) + throw new IllegalArgumentException(); + + final String processName = properties.getProperty(Options.PROCESS_NAME); + + if (processName == null) + throw new IllegalArgumentException( + "Required option not specified: " + Options.PROCESS_NAME); + + final String osname = System.getProperty("os.name").toLowerCase(); + + if(osname.equalsIgnoreCase("linux")) { + + return new StatisticsCollectorForLinux(interval, processName); + + } else if(osname.contains("windows")) { + + return new StatisticsCollectorForWindows(interval); + + } else { + + throw new UnsupportedOperationException( + "No implementation available on " + + System.getProperty("os.getname")); + + } + + } + + /** + * Utility runs the {@link AbstractStatisticsCollector} appropriate for your + * operating system. Before performance counter collection starts the static + * counters will be written on stdout. The appropriate process(es) are then + * started to collect the dynamic performance counters. Collection will + * occur every {@link Options#PERFORMANCE_COUNTERS_SAMPLE_INTERVAL} seconds. + * The program will make 10 collections by default and will write the + * updated counters on stdout every + * {@link Options#PERFORMANCE_COUNTERS_SAMPLE_INTERVAL} seconds. + * <p> + * Parameters also may be specified using <code>-D</code>. See + * {@link Options}. + * + * @param args <code>[<i>interval</i> [<i>count</i>]]</code> + * <p> + * <i>interval</i> is the collection interval in seconds and + * defaults to + * {@link Options#DEFAULT_PERFORMANCE_COUNTERS_SAMPLE_INTERVAL}. + * <p> + * <i>count</i> is the #of collections to be made and defaults + * to <code>10</code>. Specify zero (0) to run until halted. + * + * @throws InterruptedException + * @throws RuntimeException + * if the arguments are not valid. + * @throws UnsupportedOperationException + * if no implementation is available for your operating system. + */ + public static void main(final String[] args) throws InterruptedException { + + final int DEFAULT_COUNT = 10; + final int nargs = args.length; + final int interval; + final int count; + if (nargs == 0) { + interval = Integer.parseInt(Options.DEFAULT_PERFORMANCE_COUNTERS_SAMPLE_INTERVAL); + count = DEFAULT_COUNT; + } else if (nargs == 1) { + interval = Integer.parseInt(args[0]); + count = DEFAULT_COUNT; + } else if (nargs == 2) { + interval = Integer.parseInt(args[0]); + count = Integer.parseInt(args[1]); + } else { + throw new RuntimeException("usage: [interval [count]]"); + } + + if (interval <= 0) + throw new RuntimeException("interval must be positive"); + + if (count < 0) + throw new RuntimeException("count must be non-negative"); + + Properties properties = new Properties(System.getProperties()); + + if (nargs != 0) { + + // Override the interval property from the command line. + properties.setProperty(Options.PERFORMANCE_COUNTERS_SAMPLE_INTERVAL,""+interval); + + } + + if(properties.getProperty(Options.PROCESS_NAME)==null) { + + /* + * Set a default process name if none was specified in the + * environment. + * + * Note: Normally the process name is specified explicitly by the + * service which instantiates the performance counter collection for + * that process. We specify a default here since main() is used for + * testing purposes only. + */ + + properties.setProperty(Options.PROCESS_NAME,"testService"); + + } + + final AbstractStatisticsCollector client = AbstractStatisticsCollector + .newInstance( properties ); + + // write counters before we start the client + System.out.println(client.getCounters().toString()); + + System.err.println("Starting performance counter collection: interval=" + + client.interval + ", count=" + count); + + client.start(); + + /* + * HTTPD service reporting out statistics. + */ + AbstractHTTPD httpd = null; + { + final int port = 8080; + if (port != 0) { + try { + httpd = new CounterSetHTTPD(port,client.countersRoot); + } catch (IOException e) { + log.warn("Could not start httpd: port=" + port+" : "+e); + } + } + + } + + int n = 0; + + final long begin = System.currentTimeMillis(); + + // Note: runs until killed when count==0. + while (count == 0 || n < count) { + + Thread.sleep(client.interval * 1000/*ms*/); + + final long elapsed = System.currentTimeMillis() - begin; + + System.err.println("Report #"+n+" after "+(elapsed/1000)+" seconds "); + + System.out.println(client.getCounters().toString()); + + n++; + + } + + System.err.println("Stopping performance counter collection"); + + client.stop(); + + if (httpd != null) + httpd.shutdown(); + + System.err.println("Done"); + + } + + /** + * Converts KB to bytes. + * + * @param kb + * The #of kilobytes. + * + * @return The #of bytes. + */ + static public Double kb2b(final String kb) { + + final double d = Double.parseDouble(kb); + + final double x = d * Bytes.kilobyte32; + + return x; + + } + +} Property changes on: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/counters/httpd/AbstractStatisticsCollector.java ___________________________________________________________________ Added: svn:keywords + Id Date Revision Author HeadURL Added: svn:eol-style + native Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/counters/httpd/DummyEventReportingService.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/counters/httpd/DummyEventReportingService.java 2010-09-21 18:45:41 UTC (rev 3606) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/counters/httpd/DummyEventReportingService.java 2010-09-21 20:49:50 UTC (rev 3607) @@ -8,7 +8,6 @@ import java.util.List; import java.util.UUID; -import com.bigdata.counters.AbstractStatisticsCollector; import com.bigdata.service.Event; import com.bigdata.service.EventReceiver; import com.bigdata.service.IEventReportingService; Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/counters/linux/StatisticsCollectorForLinux.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/counters/linux/StatisticsCollectorForLinux.java 2010-09-21 18:45:41 UTC (rev 3606) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/counters/linux/StatisticsCollectorForLinux.java 2010-09-21 20:49:50 UTC (rev 3607) @@ -2,7 +2,7 @@ import java.util.UUID; -import com.bigdata.counters.AbstractStatisticsCollector; +import com.bigdata.counters.httpd.AbstractStatisticsCollector; import com.bigdata.counters.CounterSet; import com.bigdata.counters.PIDUtil; Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/counters/linux/SysstatUtil.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/counters/linux/SysstatUtil.java 2010-09-21 18:45:41 UTC (rev 3606) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/counters/linux/SysstatUtil.java 2010-09-21 20:49:50 UTC (rev 3607) @@ -34,10 +34,9 @@ import java.util.Arrays; import java.util.Map; +import com.bigdata.counters.httpd.AbstractStatisticsCollector; import org.apache.log4j.Logger; -import com.bigdata.counters.AbstractStatisticsCollector; - /** * Some utility methods related to integration with <code>sysstat</code>. * Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/counters/win/StatisticsCollectorForWindows.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/counters/win/StatisticsCollectorForWindows.java 2010-09-21 18:45:41 UTC (rev 3606) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/counters/win/StatisticsCollectorForWindows.java 2010-09-21 20:49:50 UTC (rev 3607) @@ -1,6 +1,6 @@ package com.bigdata.counters.win; -import com.bigdata.counters.AbstractStatisticsCollector; +import com.bigdata.counters.httpd.AbstractStatisticsCollector; import com.bigdata.counters.CounterSet; /** Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/DiskOnlyStrategy.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/DiskOnlyStrategy.java 2010-09-21 18:45:41 UTC (rev 3606) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/DiskOnlyStrategy.java 2010-09-21 20:49:50 UTC (rev 3607) @@ -39,7 +39,7 @@ import com.bigdata.BigdataStatics; import com.bigdata.btree.BTree.Counter; -import com.bigdata.counters.AbstractStatisticsCollector; +import com.bigdata.counters.httpd.AbstractStatisticsCollector; import com.bigdata.counters.CounterSet; import com.bigdata.counters.Instrument; import com.bigdata.counters.OneShotInstrument; Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/WORMStrategy.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/WORMStrategy.java 2010-09-21 18:45:41 UTC (rev 3606) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/WORMStrategy.java 2010-09-21 20:49:50 UTC (rev 3607) @@ -40,7 +40,6 @@ import java.util.concurrent.locks.ReentrantReadWriteLock; import com.bigdata.btree.BTree.Counter; -import com.bigdata.counters.AbstractStatisticsCollector; import com.bigdata.counters.CounterSet; import com.bigdata.counters.Instrument; import com.bigdata.counters.OneShotInstrument; @@ -85,7 +84,7 @@ * </pre> * * @todo report whether or not the on-disk write cache is enabled for each - * platform in {@link AbstractStatisticsCollector}. offer guidence on how + * platform in {@link com.bigdata.counters.httpd.AbstractStatisticsCollector}. offer guidence on how * to disable that write cache. * * @todo The flush of the write cache could be made asynchronous if we had two Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/loadbalancer/EmbeddedLoadBalancer.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/loadbalancer/EmbeddedLoadBalancer.java 2010-09-21 18:45:41 UTC (rev 3606) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/loadbalancer/EmbeddedLoadBalancer.java ... [truncated message content] |
From: <sgo...@us...> - 2010-09-22 21:39:58
|
Revision: 3612 http://bigdata.svn.sourceforge.net/bigdata/?rev=3612&view=rev Author: sgossard Date: 2010-09-22 21:39:51 +0000 (Wed, 22 Sep 2010) Log Message: ----------- [maven_scaleout] : Breaking cyclical dependencies with 'com.bigdata.rawstore'. Moved the call IResourceMetadata getResourceMetadata() on IRawStore to IJournal. All rawstore implementers stubbed out functionality or threw exceptions, and info returned by IResourceMetadata calls made sense for a journals or segments, but really didn't at all for rawstores. This convieniently broke all remaining transitive cycles for 'com.bigdata.cache', 'com.bigdata.io.compression', and 'com.bigdata.btree.data' Modified Paths: -------------- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractBTree.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/view/FusedView.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/AbstractBufferStrategy.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/IJournal.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/RWStrategy.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/TemporaryRawStore.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/rawstore/IRawStore.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/rawstore/SimpleMemoryRawStore.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/BuildResult.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/TestBTree.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/TestTransientBTree.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/journal/ReplicatedStore.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/rawstore/SimpleFileRawStore.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/resources/AbstractResourceManagerTestCase.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/resources/TestReleaseResources.java Added Paths: ----------- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/SimpleResourceMetadata.java Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractBTree.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractBTree.java 2010-09-22 20:21:19 UTC (rev 3611) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractBTree.java 2010-09-22 21:39:51 UTC (rev 3612) @@ -52,7 +52,6 @@ import com.bigdata.btree.IndexMetadata.Options; import com.bigdata.btree.IndexSegment.IndexSegmentTupleCursor; import com.bigdata.btree.data.IAbstractNodeData; -import com.bigdata.btree.data.ILeafData; import com.bigdata.btree.data.INodeData; import com.bigdata.btree.filter.IFilterConstructor; import com.bigdata.btree.filter.Reverserator; @@ -68,7 +67,6 @@ import com.bigdata.cache.HardReferenceQueueWithBatchingUpdates; import com.bigdata.cache.IHardReferenceQueue; import com.bigdata.cache.RingBuffer; -import com.bigdata.cache.IGlobalLRU.ILRUCache; import com.bigdata.counters.CounterSet; import com.bigdata.counters.ICounterSet; import com.bigdata.counters.Instrument; @@ -1357,7 +1355,7 @@ return new IResourceMetadata[] { - store.getResourceMetadata() + new SimpleResourceMetadata(store.getUUID()) }; Added: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/SimpleResourceMetadata.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/SimpleResourceMetadata.java (rev 0) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/SimpleResourceMetadata.java 2010-09-22 21:39:51 UTC (rev 3612) @@ -0,0 +1,104 @@ +/* + * Created by IntelliJ IDEA. + * User: gossard + * Date: Sep 22, 2010 + * Time: 2:40:37 PM + */ +package com.bigdata.btree; + +import com.bigdata.mdi.IResourceMetadata; +import com.bigdata.rawstore.SimpleMemoryRawStore; + +import java.util.UUID; + +/** + * Dumb metadata object, used by a btree to return metadata about rawstores. + * This class was previously an inner-class in {@link com.bigdata.rawstore.SimpleMemoryRawStore SimpleMemoryRawStore}, + * but was moved into the btree package to remove a rawstore dependency on the mdi package. + * + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + */ +public class SimpleResourceMetadata implements IResourceMetadata { + + /** + * + */ + private static final long serialVersionUID = -8333003625527191826L; + + private final UUID uuid; + + public SimpleResourceMetadata(UUID uuid) { + if (uuid == null) + throw new NullPointerException("uuid cannot be null"); + this.uuid = uuid; + } + + @Override + public int hashCode() { + return uuid.hashCode(); + } + + //from java.lang.Object + public boolean equals(Object obj){ + if (obj instanceof SimpleResourceMetadata){ + SimpleResourceMetadata other = (SimpleResourceMetadata)obj; + return uuid.equals(other.uuid); + } else + return false; + } + + //from com.bigdata.mdi.IResourceMetadata, *NOT* java.lang.Object + public boolean equals(IResourceMetadata o) { + + return this.equals((Object)o); + } + + public long getCreateTime() { + + // does not support commit + return 0L; + + } + + public long getCommitTime() { + + // does not support commit + return 0L; + + } + + public String getFile() { + + // no backing file. + return null; + + } + + public UUID getUUID() { + + return uuid; + + } + + public boolean isIndexSegment() { + + // not index segment. + return false; + + } + + public boolean isJournal() { + + // not journal. + return false; + + } + +// public long size() { +// +// // #of bytes not available. +// return 0L; +// +// } + +} \ No newline at end of file Property changes on: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/SimpleResourceMetadata.java ___________________________________________________________________ Added: svn:keywords + Id Date Revision Author HeadURL Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/view/FusedView.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/view/FusedView.java 2010-09-22 20:21:19 UTC (rev 3611) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/view/FusedView.java 2010-09-22 21:39:51 UTC (rev 3612) @@ -399,7 +399,11 @@ for(AbstractBTree t : sources) { // for (int i = 0; i < srcs.length; i++) { - resources[i++] = t.getStore().getResourceMetadata(); + IResourceMetadata[] metaAboutBTree = t.getResourceMetadata(); + if (metaAboutBTree.length == 1) + resources[i++] = metaAboutBTree[0]; + else + throw new RuntimeException("BTree had wrong number of metadata items, should have been caught in unit tests."); } Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/AbstractBufferStrategy.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/AbstractBufferStrategy.java 2010-09-22 20:21:19 UTC (rev 3611) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/AbstractBufferStrategy.java 2010-09-22 21:39:51 UTC (rev 3612) @@ -585,18 +585,6 @@ } /** - * Not supported - this is available on the {@link AbstractJournal}. - * - * @throws UnsupportedOperationException - * always - */ - public IResourceMetadata getResourceMetadata() { - - throw new UnsupportedOperationException(); - - } - - /** * Sets the <code>readOnly</code> flag. * <p> * Note: This method SHOULD be extended to release write caches, etc. Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/IJournal.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/IJournal.java 2010-09-22 20:21:19 UTC (rev 3611) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/IJournal.java 2010-09-22 21:39:51 UTC (rev 3612) @@ -26,6 +26,7 @@ import java.util.Properties; import com.bigdata.btree.keys.IKeyBuilderFactory; +import com.bigdata.mdi.IResourceMetadata; import com.bigdata.rawstore.IMRMW; /** @@ -55,5 +56,9 @@ * Immediate shutdown. */ public void shutdownNow(); - + + /** + * A description of this store in support of the scale-out architecture. + */ + public IResourceMetadata getResourceMetadata(); } Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/RWStrategy.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/RWStrategy.java 2010-09-22 20:21:19 UTC (rev 3611) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/RWStrategy.java 2010-09-22 21:39:51 UTC (rev 3612) @@ -479,10 +479,6 @@ return m_fileMetadata.raf; } - public IResourceMetadata getResourceMetadata() { - // TODO Auto-generated method stub - return null; - } public UUID getUUID() { return m_fileMetadata.rootBlock.getUUID(); Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/TemporaryRawStore.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/TemporaryRawStore.java 2010-09-22 20:21:19 UTC (rev 3611) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/TemporaryRawStore.java 2010-09-22 21:39:51 UTC (rev 3612) @@ -400,61 +400,6 @@ } - /** - * Note: Temporary stores do not have persistent resource descriptions. - */ - final public IResourceMetadata getResourceMetadata() { - - final File file = buf.getFile(); - - final String fileStr = file == null ? "" : file.toString(); - - return new ResourceMetadata(this, fileStr); - - } - - /** - * Static class since must be {@link Serializable}. - * - * @author <a href="mailto:tho...@us...">Bryan Thompson</a> - * @version $Id$ - */ - static final class ResourceMetadata extends AbstractResourceMetadata { - - /** - * De-serializator ctor. - */ - public ResourceMetadata() { - - } - - public ResourceMetadata(final TemporaryRawStore store, - final String fileStr) { - - super(fileStr, // store.buf.getExtent() - store.uuid,// - store.createTime, // - 0L// commitTime - ); - - } - - private static final long serialVersionUID = 1L; - - public boolean isJournal() { - - return false; - - } - - public boolean isIndexSegment() { - - return false; - - } - - } - final public DiskOnlyStrategy getBufferStrategy() { return buf; Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/rawstore/IRawStore.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/rawstore/IRawStore.java 2010-09-22 20:21:19 UTC (rev 3611) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/rawstore/IRawStore.java 2010-09-22 21:39:51 UTC (rev 3612) @@ -36,7 +36,6 @@ import com.bigdata.counters.CounterSet; import com.bigdata.io.IByteArrayBuffer; import com.bigdata.journal.AbstractJournal; -import com.bigdata.mdi.IResourceMetadata; /** * <p> @@ -242,12 +241,7 @@ * Return the {@link UUID} which identifies this {@link IRawStore}. This * supports {@link #getResourceMetadata()} */ - public UUID getUUID(); - - /** - * A description of this store in support of the scale-out architecture. - */ - public IResourceMetadata getResourceMetadata(); + public UUID getUUID(); /** * True iff backed by stable storage. Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/rawstore/SimpleMemoryRawStore.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/rawstore/SimpleMemoryRawStore.java 2010-09-22 20:21:19 UTC (rev 3611) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/rawstore/SimpleMemoryRawStore.java 2010-09-22 21:39:51 UTC (rev 3612) @@ -28,7 +28,6 @@ package com.bigdata.rawstore; import java.io.File; -import java.io.Serializable; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.HashMap; @@ -37,8 +36,6 @@ import java.util.concurrent.ExecutorService; import com.bigdata.counters.CounterSet; -import com.bigdata.journal.TemporaryRawStore; -import com.bigdata.mdi.IResourceMetadata; /** * A purely transient append-only implementation useful when data need to be @@ -48,7 +45,7 @@ * implementation does not contain things like {@link ExecutorService}s that * would hang around unless explicitly shutdown. * - * @see {@link TemporaryRawStore}, which provides a more scalable solution for + * @see {@link com.bigdata.journal.TemporaryRawStore TemporaryRawStore}, which provides a more scalable solution for * temporary data. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> @@ -147,91 +144,8 @@ return uuid; } - - public IResourceMetadata getResourceMetadata() { - return new ResourceMetadata(uuid); - - } - /** - * Static class since must be {@link Serializable}. - * - * @author <a href="mailto:tho...@us...">Bryan Thompson</a> - * @version $Id$ - */ - private static class ResourceMetadata implements IResourceMetadata { - - /** - * - */ - private static final long serialVersionUID = -8333003625527191826L; - - private final UUID uuid; - - public ResourceMetadata(UUID uuid) { - - this.uuid = uuid; - - } - - public boolean equals(IResourceMetadata o) { - - return this == o; - - } - - public long getCreateTime() { - - // does not support commit - return 0L; - - } - - public long getCommitTime() { - - // does not support commit - return 0L; - - } - - public String getFile() { - - // no backing file. - return null; - - } - - public UUID getUUID() { - - return uuid; - - } - - public boolean isIndexSegment() { - - // not index segment. - return false; - - } - - public boolean isJournal() { - - // not journal. - return false; - - } - -// public long size() { -// -// // #of bytes not available. -// return 0L; -// -// } - - } - - /** * This always returns <code>null</code>. */ public File getFile() { Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/BuildResult.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/BuildResult.java 2010-09-22 20:21:19 UTC (rev 3611) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/BuildResult.java 2010-09-22 21:39:51 UTC (rev 3612) @@ -126,9 +126,11 @@ this.sources = new IResourceMetadata[sourceCount]; for (int i = 0; i < sourceCount; i++) { - - this.sources[i] = sources[i].getStore().getResourceMetadata(); - + IResourceMetadata[] metaAboutBTree = sources[i].getResourceMetadata(); + if (metaAboutBTree.length == 1) + this.sources[i] = metaAboutBTree[0]; + else + throw new RuntimeException("BTree had wrong number of metadata items, should have been caught in unit tests."); } this.segmentMetadata = segmentMetadata; Modified: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/TestBTree.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/TestBTree.java 2010-09-22 20:21:19 UTC (rev 3611) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/TestBTree.java 2010-09-22 21:39:51 UTC (rev 3612) @@ -23,6 +23,8 @@ */ package com.bigdata.btree; +import com.bigdata.mdi.IResourceMetadata; + /** * Stress tests for basic tree operations (insert, lookup, and remove) without * causing node or leaf evictions (IO is disabled). @@ -198,6 +200,20 @@ } + public void test_verify_getResourceMetadata(){ + //transient requirements on getResourceMetadata() are verified in TestTrasientBTree. + + BTree tree = getBTree(3);//branching doesn't matter. + assertNotNull("didn't expect btree.store to be null in this test, transient tests are in TestTransientBTree",tree.store); + + IResourceMetadata[] metaList = tree.getResourceMetadata(); + + assertNotNull("cannot return null",metaList); + assertEquals("must return only one item", 1, metaList.length); + assertNotNull("item cannot be null",metaList[0]); + assertEquals("item uuid should match store uuid ",tree.getStore().getUUID(),metaList[0].getUUID()); + } + // /** // * The branching factors that will be used in the stress tests. The larger // * the branching factor, the longer the run for these tests. The very small Modified: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/TestTransientBTree.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/TestTransientBTree.java 2010-09-22 20:21:19 UTC (rev 3611) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/TestTransientBTree.java 2010-09-22 21:39:51 UTC (rev 3612) @@ -36,6 +36,7 @@ import com.bigdata.btree.AbstractBTree.HardReference; import com.bigdata.btree.keys.TestKeyBuilder; +import com.bigdata.mdi.IResourceMetadata; import com.bigdata.rawstore.IRawStore; import com.bigdata.rawstore.SimpleMemoryRawStore; @@ -443,7 +444,7 @@ * Loop until GC activity has caused references to be cleared. */ final int limit = 100; - for (int x = 0; x < limit; x++) { + for (int x = 0; x < limit; x++) { System.gc(); @@ -473,4 +474,15 @@ } + public void test_verify_getResourceMetadata(){ + //non-transient requirements on getResourceMetadata() are verified in TestBTree. + BTree tree = BTree.createTransient(new IndexMetadata(UUID.randomUUID())); + + IResourceMetadata[] metaList = tree.getResourceMetadata(); + + assertNotNull("cannot return null",metaList); + assertEquals("must return only one item", 1, metaList.length); + assertNotNull("item cannot be null",metaList[0]); + } + } Modified: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/journal/ReplicatedStore.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/journal/ReplicatedStore.java 2010-09-22 20:21:19 UTC (rev 3611) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/journal/ReplicatedStore.java 2010-09-22 21:39:51 UTC (rev 3612) @@ -576,11 +576,7 @@ public UUID getUUID() { return localStore.getUUID(); - } - - public IResourceMetadata getResourceMetadata() { - return localStore.getResourceMetadata(); - } + } // public void packAddr(DataOutput out, long addr) throws IOException { // localStore.packAddr(out, addr); Modified: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/rawstore/SimpleFileRawStore.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/rawstore/SimpleFileRawStore.java 2010-09-22 20:21:19 UTC (rev 3611) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/rawstore/SimpleFileRawStore.java 2010-09-22 21:39:51 UTC (rev 3612) @@ -138,97 +138,9 @@ return uuid; - } - - public IResourceMetadata getResourceMetadata() { + } - return new ResourceMetadata(uuid, file); - - } - /** - * Static class since must be {@link Serializable}. - * - * @author <a href="mailto:tho...@us...">Bryan Thompson</a> - * @version $Id$ - */ - private static final class ResourceMetadata implements IResourceMetadata { - - /** - * - */ - private static final long serialVersionUID = -419665851049132640L; - - private final UUID uuid; - private final String fileStr; - -// private final long length; - - public ResourceMetadata(final UUID uuid, final File file) { - - this.uuid = uuid; - - this.fileStr = file.toString(); - -// this.length = file.length(); - - } - - public boolean equals(IResourceMetadata o) { - - return this == o; - - } - - public long getCreateTime() { - - // does not support commit - return 0L; - - } - - public long getCommitTime() { - - // does not support commit - return 0L; - - } - - public String getFile() { - - return fileStr; - - } - - public UUID getUUID() { - - return uuid; - - } - - public boolean isIndexSegment() { - - // not index segment. - return false; - - } - - public boolean isJournal() { - - // not journal. - return false; - - } - -// public long size() { -// -// return length; -// -// } - - } - - /** * This also releases the lock if any obtained by the constructor. */ public void close() { Modified: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/resources/AbstractResourceManagerTestCase.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/resources/AbstractResourceManagerTestCase.java 2010-09-22 20:21:19 UTC (rev 3611) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/resources/AbstractResourceManagerTestCase.java 2010-09-22 21:39:51 UTC (rev 3612) @@ -48,13 +48,8 @@ import com.bigdata.btree.keys.IKeyBuilder; import com.bigdata.btree.proc.IIndexProcedure; import com.bigdata.counters.CounterSet; -import com.bigdata.journal.AbstractLocalTransactionManager; -import com.bigdata.journal.BufferMode; -import com.bigdata.journal.ConcurrencyManager; -import com.bigdata.journal.IResourceLockService; +import com.bigdata.journal.*; //BTM import com.bigdata.journal.ITransactionService; -import com.bigdata.journal.RegisterIndexTask; -import com.bigdata.journal.TemporaryStore; import com.bigdata.mdi.IMetadataIndex; import com.bigdata.mdi.IResourceMetadata; import com.bigdata.mdi.IndexPartitionCause; @@ -79,7 +74,6 @@ import com.bigdata.util.httpd.AbstractHTTPD; //BTM -import com.bigdata.journal.TransactionService; import com.bigdata.service.IServiceShutdown; import com.bigdata.service.LoadBalancer; import com.bigdata.service.Service; @@ -692,7 +686,7 @@ * @param expected * @param actual */ - protected void assertSameResources(IRawStore[] expected, Set<UUID> actual) { + protected void assertSameResources(IJournal[] expected, Set<UUID> actual) { if(log.isInfoEnabled()) { Modified: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/resources/TestReleaseResources.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/resources/TestReleaseResources.java 2010-09-22 20:21:19 UTC (rev 3611) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/resources/TestReleaseResources.java 2010-09-22 21:39:51 UTC (rev 3612) @@ -35,6 +35,7 @@ import java.util.concurrent.ExecutionException; import com.bigdata.journal.AbstractJournal; +import com.bigdata.journal.IJournal; import com.bigdata.rawstore.IRawStore; import com.bigdata.service.AbstractTransactionService; @@ -262,7 +263,7 @@ final Set<UUID> actual = resourceManager.getResourcesForTimestamp(commitTime); - assertSameResources(new IRawStore[] { j0, j1 }, actual); + assertSameResources(new IJournal[] { j0, j1 }, actual); } @@ -278,7 +279,7 @@ final Set<UUID> actual = resourceManager .getResourcesForTimestamp(commitTime); - assertSameResources(new IRawStore[] { j1 }, actual); + assertSameResources(new IJournal[] { j1 }, actual); } @@ -434,7 +435,7 @@ System.err.println("resources="+actualResourceUUIDs); - assertSameResources(new IRawStore[] { j1 }, // + assertSameResources(new IJournal[] { j1 }, // actualResourceUUIDs); } @@ -554,7 +555,7 @@ * Verify that the resources required for [A] after overflow are * exactly [j1]. */ - assertSameResources(new IRawStore[] { j1 }, // + assertSameResources(new IJournal[] { j1 }, // resourceManager.getResourcesForTimestamp(j1.getRootBlockView() .getFirstCommitTime())); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ble...@us...> - 2010-09-23 14:00:42
|
Revision: 3615 http://bigdata.svn.sourceforge.net/bigdata/?rev=3615&view=rev Author: blevine218 Date: 2010-09-23 14:00:36 +0000 (Thu, 23 Sep 2010) Log Message: ----------- Allow federation.name to be overridden by settting -Dfederation.name=... when executing ANT script. Value of federation.name property is set to the empty string by default in which case the application code assigns a consistent default value. Modified Paths: -------------- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/jini/util/LookupStarter.java branches/maven_scaleout/bigdata-core/src/test/deploy/testing/test.xml Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/jini/util/LookupStarter.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/jini/util/LookupStarter.java 2010-09-22 23:37:50 UTC (rev 3614) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/jini/util/LookupStarter.java 2010-09-23 14:00:36 UTC (rev 3615) @@ -71,21 +71,18 @@ private String jiniLib = System.getProperty("jini.lib"); private String jiniLibDl = System.getProperty("jini.lib.dl"); private String localPolicy = System.getProperty("java.security.policy"); - + private static String group = null; private static String thisHost = null; - private static String defaultGroup = null; + static { try { thisHost = NicUtil.getIpAddress("default.nic", "default", false); - //defaultGroup = System.getProperty("federation.name","bigdata.test.group-"+thisHost); - defaultGroup = ConfigDeployUtil.getFederationName(); - + group = ConfigDeployUtil.getFederationName(); } catch (Throwable t) { /* swallow */ } } + private static String defaultCodebasePort = "23333"; - private static String group = - System.getProperty("federation.name", defaultGroup); private static String codebasePortStr = System.getProperty("codebase.port", defaultCodebasePort); private static int codebasePort = Integer.parseInt(codebasePortStr); Modified: branches/maven_scaleout/bigdata-core/src/test/deploy/testing/test.xml =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/deploy/testing/test.xml 2010-09-22 23:37:50 UTC (rev 3614) +++ branches/maven_scaleout/bigdata-core/src/test/deploy/testing/test.xml 2010-09-23 14:00:36 UTC (rev 3615) @@ -32,7 +32,10 @@ <target name="setup" > <exec executable="hostname" outputproperty="this.hostname" /> <property name="test.codebase" value="http://${this.hostname}:${test.codebase.port}/jsk-dl.jar" /> - <!-- <property name="federation.name" value="bigdata.test.group-${this.hostname}" /> --> + + <!-- Set to the empty string to indicate "unset". Application code will determine correct + default value. --> + <property name="federation.name" value="" /> </target> <target name="junit" description="starts http class server, lookup service, runs junit tests, stops lookup service, stops http class server." @@ -100,9 +103,7 @@ <sysproperty key="log4j.configuration" value="${log4j.configuration}" /> <sysproperty key="codebase.port" value="${test.codebase.port}" /> <sysproperty key="java.net.preferIPv4Stack" value="${java.net.preferIPv4Stack}" /> - <!-- <sysproperty key="federation.name" value="${federation.name}" /> - --> <sysproperty key="default.nic" value="${default.nic}" /> </java> </target> @@ -122,9 +123,9 @@ <sysproperty key="java.security.policy" value="${java.security.policy}" /> <sysproperty key="log4j.configuration" value="${log4j.configuration}" /> <sysproperty key="java.net.preferIPv4Stack" value="${java.net.preferIPv4Stack}" /> - <!-- + <sysproperty key="federation.name" value="${federation.name}" /> - --> + <sysproperty key="default.nic" value="${default.nic}" /> <arg value="-stop" /> </java> @@ -215,13 +216,11 @@ <sysproperty key="app.home" value="${app.home}" /> <!-- This is the deployment directory, easily accessed by the DataFinder class. --> <sysproperty key="log4j.path" value="${log4j.configuration}" /> <sysproperty key="default.nic" value="${default.nic}" /> - <!-- Jini group name --> - <!-- + + <!-- Jini group name --> <sysproperty key="federation.name" value="${federation.name}" /> - --> - + <sysproperty key="java.class.path" value="${junit.classpath.text}" /> - <sysproperty key="classserver.jar" value="${deploy.lib}/classserver.jar" /> <sysproperty key="colt.jar" value="${deploy.lib}/colt.jar" /> <sysproperty key="ctc_utils.jar" value="${deploy.lib}/ctc_utils.jar" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sgo...@us...> - 2010-09-24 17:46:12
|
Revision: 3627 http://bigdata.svn.sourceforge.net/bigdata/?rev=3627&view=rev Author: sgossard Date: 2010-09-24 17:46:05 +0000 (Fri, 24 Sep 2010) Log Message: ----------- [maven_scaleout] : Fix for broken IndexSegment caused by r3612, which did not account for IndexSegment btrees being constructed by reflection. IndexSegment now properly returns SegmentMetadata, and this is verified in unit tests. This change also introduces a common super-type for IJournal and IndexSegmentStore, the new IStoreFile interface. Modified Paths: -------------- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractBTree.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/BTree.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegment.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegmentStore.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/IJournal.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/IResourceManager.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/Journal.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/IndexManager.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/StoreManager.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/jini/util/DumpFederation.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/TestAll_IndexSegment.java Added Paths: ----------- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/IStoreFile.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/TestIndexSegment.java Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractBTree.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractBTree.java 2010-09-24 17:25:48 UTC (rev 3626) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractBTree.java 2010-09-24 17:46:05 UTC (rev 3627) @@ -1335,7 +1335,7 @@ */ abstract public IRawStore getStore(); - final public IResourceMetadata[] getResourceMetadata() { + public IResourceMetadata[] getResourceMetadata() { if (store == null) { @@ -1351,14 +1351,12 @@ }; + } else { + //This is a default metadata, appropriate for rawstores. + return new IResourceMetadata[] { + new SimpleResourceMetadata(store.getUUID()) + }; } - - return new IResourceMetadata[] { - - new SimpleResourceMetadata(store.getUUID()) - - }; - } /** Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/BTree.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/BTree.java 2010-09-24 17:25:48 UTC (rev 3626) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/BTree.java 2010-09-24 17:46:05 UTC (rev 3627) @@ -190,6 +190,11 @@ } + public final IResourceMetadata[] getResourceMetadata() { + //override to make final so sub-classes cannot modify behavior. + return super.getResourceMetadata(); + } + /** * Returns an {@link ICounter}. The {@link ICounter} is mutable iff the * {@link BTree} is mutable. All {@link ICounter}s returned by this method Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegment.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegment.java 2010-09-24 17:25:48 UTC (rev 3626) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegment.java 2010-09-24 17:46:05 UTC (rev 3627) @@ -34,6 +34,7 @@ import com.bigdata.btree.raba.ReadOnlyValuesRaba; import com.bigdata.io.AbstractFixedByteArrayBuffer; import com.bigdata.io.FixedByteArrayBuffer; +import com.bigdata.mdi.IResourceMetadata; import com.bigdata.service.Event; import com.bigdata.service.EventResource; import com.bigdata.service.EventType; @@ -676,6 +677,13 @@ } + public final IResourceMetadata[] getResourceMetadata() { + //Overrides the default returned metadata, providing IndexSegmentStore specific metadata. + return new IResourceMetadata[] { + fileStore.getResourceMetadata() + }; + } + /* * INodeFactory */ Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegmentStore.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegmentStore.java 2010-09-24 17:25:48 UTC (rev 3626) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegmentStore.java 2010-09-24 17:46:05 UTC (rev 3627) @@ -37,10 +37,10 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.ReentrantLock; +import com.bigdata.journal.IStoreFile; import org.apache.log4j.Logger; import com.bigdata.cache.IGlobalLRU; -import com.bigdata.cache.IGlobalLRU.ILRUCache; import com.bigdata.counters.CounterSet; import com.bigdata.counters.Instrument; import com.bigdata.counters.OneShotInstrument; @@ -67,7 +67,7 @@ * @author <a href="mailto:tho...@us...">Bryan Thompson</a> * @version $Id$ */ -public class IndexSegmentStore extends AbstractRawStore { +public class IndexSegmentStore extends AbstractRawStore implements IStoreFile { /** * Logger. Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/IJournal.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/IJournal.java 2010-09-24 17:25:48 UTC (rev 3626) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/IJournal.java 2010-09-24 17:46:05 UTC (rev 3627) @@ -25,8 +25,6 @@ import java.util.Properties; -import com.bigdata.btree.keys.IKeyBuilderFactory; -import com.bigdata.mdi.IResourceMetadata; import com.bigdata.rawstore.IMRMW; /** @@ -39,7 +37,7 @@ * @author <a href="mailto:tho...@us...">Bryan Thompson</a> * @version $Id$ */ -public interface IJournal extends IMRMW, IAtomicStore, IBTreeManager { +public interface IJournal extends IMRMW, IAtomicStore, IBTreeManager, IStoreFile { /** * A copy of the properties used to initialize this journal. @@ -56,9 +54,5 @@ * Immediate shutdown. */ public void shutdownNow(); - - /** - * A description of this store in support of the scale-out architecture. - */ - public IResourceMetadata getResourceMetadata(); + } Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/IResourceManager.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/IResourceManager.java 2010-09-24 17:25:48 UTC (rev 3626) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/IResourceManager.java 2010-09-24 17:46:05 UTC (rev 3627) @@ -40,7 +40,6 @@ import com.bigdata.btree.IndexSegmentStore; import com.bigdata.btree.view.FusedView; import com.bigdata.counters.CounterSet; -import com.bigdata.rawstore.IRawStore; import com.bigdata.resources.ResourceManager; import com.bigdata.resources.StaleLocatorException; import com.bigdata.resources.StaleLocatorReason; @@ -99,17 +98,17 @@ public AbstractJournal getJournal(long timestamp); /** - * Opens an {@link IRawStore}. + * Opens an {@link IStoreFile}. * * @param uuid * The UUID identifying that store file. * - * @return The open {@link IRawStore}. + * @return The open {@link IStoreFile}. * * @throws RuntimeException * if something goes wrong. */ - public IRawStore openStore(UUID uuid); + public IStoreFile openStore(UUID uuid); /** * Return the ordered {@link AbstractBTree} sources for an index or a view Added: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/IStoreFile.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/IStoreFile.java (rev 0) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/IStoreFile.java 2010-09-24 17:46:05 UTC (rev 3627) @@ -0,0 +1,53 @@ +/* + +Copyright (C) SYSTAP, LLC 2006-2010. All rights reserved. + +Contact: + SYSTAP, LLC + 4501 Tower Road + Greensboro, NC 27410 + lic...@bi... + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +*/ + +package com.bigdata.journal; + +import com.bigdata.mdi.IResourceMetadata; +import com.bigdata.rawstore.IRawStore; + +import com.bigdata.btree.IndexSegmentStore; +import com.bigdata.journal.IJournal; + +/** + * An {@link IRawStore} that exposes additional serializable metadata allowing it to be managed by an + * {@link IResourceManager}. Currently this is common interface between the two main store + * file types that are used to store btree indices. + * <b /> + * The methods on this interface have been moved from <code>IRawStore</code> in order to reduce the burden on + * rawstore implementations which we often needed to stub methods out even though they were never used. + * It also improves encapsulation by removing direct knowledge of resource management related classes in the rawstore + * package. + * + * {@see IndexSegmentStore} + * {@see IJournal} + */ +public interface IStoreFile extends IRawStore { + + /** + * A description of this store in support of the scale-out architecture. + */ + public IResourceMetadata getResourceMetadata(); +} Property changes on: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/IStoreFile.java ___________________________________________________________________ Added: svn:keywords + Id Date Revision Author HeadURL Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/Journal.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/Journal.java 2010-09-24 17:25:48 UTC (rev 3626) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/Journal.java 2010-09-24 17:46:05 UTC (rev 3627) @@ -49,7 +49,6 @@ import com.bigdata.config.IntegerValidator; import com.bigdata.config.LongValidator; import com.bigdata.counters.CounterSet; -import com.bigdata.rawstore.IRawStore; import com.bigdata.relation.locator.DefaultResourceLocator; import com.bigdata.relation.locator.ILocatableResource; import com.bigdata.relation.locator.IResourceLocator; @@ -292,7 +291,7 @@ * Note: This will only succeed if the <i>uuid</i> identifies <i>this</i> * journal. */ - public IRawStore openStore(final UUID uuid) { + public IStoreFile openStore(final UUID uuid) { if(uuid == getRootBlockView().getUUID()) { Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/IndexManager.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/IndexManager.java 2010-09-24 17:25:48 UTC (rev 3626) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/IndexManager.java 2010-09-24 17:46:05 UTC (rev 3627) @@ -42,6 +42,7 @@ import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.locks.Lock; +import com.bigdata.journal.*; import org.apache.log4j.Logger; import com.bigdata.btree.AbstractBTree; @@ -66,24 +67,12 @@ import com.bigdata.counters.CounterSet; import com.bigdata.counters.ICounterSet; import com.bigdata.io.DataInputBuffer; -import com.bigdata.journal.AbstractJournal; -import com.bigdata.journal.AbstractTask; -import com.bigdata.journal.ConcurrencyManager; -import com.bigdata.journal.ICommitRecord; -import com.bigdata.journal.IJournal; -import com.bigdata.journal.ITx; -import com.bigdata.journal.Journal; -import com.bigdata.journal.Name2Addr; -import com.bigdata.journal.NoSuchIndexException; -import com.bigdata.journal.TimestampUtility; -import com.bigdata.journal.Tx; import com.bigdata.journal.Name2Addr.Entry; import com.bigdata.journal.Name2Addr.EntrySerializer; import com.bigdata.mdi.IResourceMetadata; import com.bigdata.mdi.LocalPartitionMetadata; import com.bigdata.mdi.SegmentMetadata; import com.bigdata.rawstore.Bytes; -import com.bigdata.rawstore.IRawStore; import com.bigdata.service.Event; import com.bigdata.service.EventType; import com.bigdata.service.IBigdataClient; @@ -134,11 +123,11 @@ * Note: The {@link IIndex}s managed by this class are a * {@link FusedView} of {@link AbstractBTree}s. Each * {@link AbstractBTree} has a hard reference to the backing - * {@link IRawStore} and will keep the {@link IRawStore} from being + * {@link com.bigdata.journal.IStoreFile} and will keep the {@link IStoreFile} from being * finalized as long as a hard reference exists to the - * {@link AbstractBTree} (the reverse is not true - an {@link IRawStore} + * {@link AbstractBTree} (the reverse is not true - an {@link IStoreFile} * reference does NOT hold a hard reference to {@link AbstractBTree}s - * on that {@link IRawStore}). + * on that {@link IStoreFile}). * <p> * Note: The retention of the {@link BTree}s on the live * {@link ManagedJournal}s is governed by @@ -923,7 +912,7 @@ * {@link StoreManager#openStores}. */ public AbstractBTree getIndexOnStore(final String name, - final long timestamp, final IRawStore store) { + final long timestamp, final IStoreFile store) { if (name == null) throw new IllegalArgumentException(); @@ -1232,7 +1221,7 @@ final IResourceMetadata resource = a[i]; - final IRawStore store; + final IStoreFile store; try { store = openStore(resource.getUUID()); @@ -2021,7 +2010,7 @@ /** * Canonical per-index partition {@link BTreeCounters}. These counters are * set on each {@link AbstractBTree} that is materialized by - * {@link #getIndexOnStore(String, long, IRawStore)}. The same + * {@link #getIndexOnStore(String, long, IStoreFile)}. The same * {@link BTreeCounters} object is used for the unisolated, read-committed, * read-historical and isolated views of the index partition and for each * source in the view regardless of whether the source is a mutable Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/StoreManager.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/StoreManager.java 2010-09-24 17:25:48 UTC (rev 3626) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/StoreManager.java 2010-09-24 17:46:05 UTC (rev 3627) @@ -44,13 +44,13 @@ import java.util.UUID; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantReadWriteLock; +import com.bigdata.journal.*; import org.apache.log4j.Logger; import com.bigdata.bfs.BigdataFileSystem; @@ -67,25 +67,7 @@ import com.bigdata.cache.IGlobalLRU.ILRUCache; import com.bigdata.concurrent.NamedLock; import com.bigdata.io.SerializerUtil; -import com.bigdata.journal.AbstractJournal; -import com.bigdata.journal.AbstractLocalTransactionManager; -import com.bigdata.journal.BufferMode; -import com.bigdata.journal.CommitRecordIndex; -import com.bigdata.journal.ConcurrencyManager; -import com.bigdata.journal.DiskOnlyStrategy; -import com.bigdata.journal.IBufferStrategy; -import com.bigdata.journal.ICommitRecord; -import com.bigdata.journal.IConcurrencyManager; -import com.bigdata.journal.ILocalTransactionManager; -import com.bigdata.journal.IResourceLockService; -import com.bigdata.journal.IResourceManager; -import com.bigdata.journal.IRootBlockView; //BTM import com.bigdata.journal.ITransactionService; -import com.bigdata.journal.ITx; -import com.bigdata.journal.Name2Addr; -import com.bigdata.journal.TemporaryStore; -import com.bigdata.journal.WORMStrategy; -import com.bigdata.journal.WriteExecutorService; import com.bigdata.journal.WORMStrategy.StoreCounters; import com.bigdata.mdi.IPartitionMetadata; import com.bigdata.mdi.IResourceMetadata; @@ -94,7 +76,6 @@ import com.bigdata.mdi.LocalPartitionMetadata; import com.bigdata.mdi.SegmentMetadata; import com.bigdata.rawstore.Bytes; -import com.bigdata.rawstore.IRawStore; import com.bigdata.relation.locator.DefaultResourceLocator; import com.bigdata.service.DataService; import com.bigdata.service.Event; @@ -108,8 +89,8 @@ import static java.util.concurrent.TimeUnit.*; //BTM -import com.bigdata.journal.TransactionService; + /** * Class encapsulates logic for managing the store files (journals and index * segments), including the logic to compute the effective release time for the @@ -178,7 +159,7 @@ String DATA_DIR = StoreManager.class.getName()+".dataDir"; /** - * The capacity of the LRU cache of open {@link IRawStore}s. The + * The capacity of the LRU cache of open {@link IStoreFile}s. The * capacity of this cache indirectly controls how many stores will be * held open. The main reason for keeping an store open is to reuse its * buffers if another request arrives "soon" which would read on that @@ -213,7 +194,7 @@ * The time in milliseconds before an entry in the store cache will be * cleared from the backing {@link HardReferenceQueue} (default * {@value #DEFAULT_STORE_CACHE_TIMEOUT}). This property controls how - * long the store cache will retain an {@link IRawStore} which has not + * long the store cache will retain an {@link IStoreFile} which has not * been recently used. This is in contrast to the cache capacity. */ String STORE_CACHE_TIMEOUT = StoreManager.class.getName() @@ -574,8 +555,8 @@ * @see Options#STORE_CACHE_CAPACITY * @see Options#STORE_CACHE_TIMEOUT */ -// final protected WeakValueCache<UUID, IRawStore> storeCache; - final protected ConcurrentWeakValueCacheWithTimeout<UUID, IRawStore> storeCache; +// final protected WeakValueCache<UUID, IStoreFile> storeCache; + final protected ConcurrentWeakValueCacheWithTimeout<UUID, IStoreFile> storeCache; /** * Provides locks on a per-{resourceUUID} basis for higher concurrency. @@ -583,11 +564,11 @@ private final transient NamedLock<UUID> namedLock = new NamedLock<UUID>(); /** - * The #of entries in the hard reference cache for {@link IRawStore}s, + * The #of entries in the hard reference cache for {@link IStoreFile}s, * including both {@link ManagedJournal}s and IndexSegment}s. There MAY be - * more {@link IRawStore}s open than are reported by this method if there - * are hard references held by the application to those {@link IRawStore}s. - * {@link IRawStore}s that are not fixed by a hard reference will be + * more {@link IStoreFile}s open than are reported by this method if there + * are hard references held by the application to those {@link IStoreFile}s. + * {@link IStoreFile}s that are not fixed by a hard reference will be * quickly finalized by the JVM. */ public int getStoreCacheSize() { @@ -1123,12 +1104,12 @@ throw new RuntimeException(Options.STORE_CACHE_TIMEOUT + " must be non-negative"); - storeCache = new ConcurrentWeakValueCacheWithTimeout<UUID, IRawStore>( + storeCache = new ConcurrentWeakValueCacheWithTimeout<UUID, IStoreFile>( storeCacheCapacity, MILLISECONDS .toNanos(storeCacheTimeout)); -// storeCache = new WeakValueCache<UUID, IRawStore>( -// new LRUCache<UUID, IRawStore>(storeCacheCapacity)); +// storeCache = new WeakValueCache<UUID, IStoreFile>( +// new LRUCache<UUID, IStoreFile>(storeCacheCapacity)); } @@ -2036,7 +2017,7 @@ * that we can find the relevant journal quickly for a given timestamp. * <p> * Note: This requires that we open each resource in order to extract its - * {@link IResourceMetadata} description. We only open the {@link IRawStore} + * {@link IResourceMetadata} description. We only open the {@link IStoreFile} * for the resource, not its indices. The stores are closed again * immediately. * @@ -2249,15 +2230,15 @@ */ private void closeStores() { -// final Iterator<IRawStore> itr = storeCache.iterator(); +// final Iterator<IStoreFile> itr = storeCache.iterator(); - final Iterator<WeakReference<IRawStore>> itr = storeCache.iterator(); + final Iterator<WeakReference<IStoreFile>> itr = storeCache.iterator(); while (itr.hasNext()) { -// final IRawStore store = itr.next(); +// final IStoreFile store = itr.next(); - final IRawStore store = itr.next().get(); + final IStoreFile store = itr.next().get(); if (store == null) { // weak reference has been cleared. @@ -2804,12 +2785,12 @@ } /** - * Opens an {@link IRawStore}. + * Opens an {@link IStoreFile}. * * @param uuid * The UUID identifying that store file. * - * @return The open {@link IRawStore}. + * @return The open {@link IStoreFile}. * * @throws IllegalStateException * if the {@link StoreManager} is not open. @@ -2830,7 +2811,7 @@ * something goes wrong (except that I was planning to drop the file * name from that interface). */ - public IRawStore openStore(final UUID uuid) { + public IStoreFile openStore(final UUID uuid) { assertRunning(); @@ -2854,7 +2835,7 @@ * Check to see if the given resource is already open. */ - IRawStore store; + IStoreFile store; // synchronized(storeCache) { store = storeCache.get(uuid); @@ -3311,9 +3292,9 @@ // if(false) {// @todo remove code. // int nstores = 0, nindices = 0; // { -// Iterator<WeakReference<IRawStore>> itr = storeCache.iterator(); +// Iterator<WeakReference<IStoreFile>> itr = storeCache.iterator(); // while (itr.hasNext()) { -// IRawStore store = itr.next().get(); +// IStoreFile store = itr.next().get(); // if (store != null) { // log.warn("Store: " + store); // nstores++; @@ -3837,7 +3818,7 @@ */ { - final IRawStore store = storeCache.remove(uuid); + final IStoreFile store = storeCache.remove(uuid); if (store != null) { @@ -4094,7 +4075,7 @@ */ { - final IRawStore store = storeCache.remove(uuid); + final IStoreFile store = storeCache.remove(uuid); if (store != null) { Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/jini/util/DumpFederation.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/jini/util/DumpFederation.java 2010-09-24 17:25:48 UTC (rev 3626) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/jini/util/DumpFederation.java 2010-09-24 17:46:05 UTC (rev 3627) @@ -49,6 +49,7 @@ import java.util.concurrent.TimeoutException; import com.bigdata.io.BytesUtil; +import com.bigdata.journal.IStoreFile; import net.jini.config.ConfigurationException; import net.jini.core.entry.Entry; import net.jini.core.lookup.ServiceItem; @@ -72,7 +73,6 @@ import com.bigdata.mdi.IResourceMetadata; import com.bigdata.mdi.LocalPartitionMetadata; import com.bigdata.mdi.PartitionLocator; -import com.bigdata.rawstore.IRawStore; import com.bigdata.resources.ResourceManager; import com.bigdata.resources.StoreManager; import com.bigdata.resources.StoreManager.ManagedJournal; @@ -1379,7 +1379,7 @@ * expensive IO. */ - final IRawStore store = resourceManager.getJournal(timestamp); + final IStoreFile store = resourceManager.getJournal(timestamp); if (store == null) { @@ -1441,7 +1441,7 @@ * IndexSegmentStore, but not of the IndexSegment on that * store! */ - final IRawStore store = resourceManager.openStore(x + final IStoreFile store = resourceManager.openStore(x .getUUID()); if (store == null) { Modified: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/TestAll_IndexSegment.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/TestAll_IndexSegment.java 2010-09-24 17:25:48 UTC (rev 3626) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/TestAll_IndexSegment.java 2010-09-24 17:46:05 UTC (rev 3627) @@ -65,7 +65,9 @@ * * See DumpIndexSegment. */ - + + //basic unit tests for IndexSegment. + suite.addTestSuite(TestIndexSegment.class); // test static methods for the index builder. suite.addTestSuite(TestIndexSegmentPlan.class); // test encoding and decoding of child node/leaf addresses. Added: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/TestIndexSegment.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/TestIndexSegment.java (rev 0) +++ branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/TestIndexSegment.java 2010-09-24 17:46:05 UTC (rev 3627) @@ -0,0 +1,81 @@ +/* + * Created by IntelliJ IDEA. + * User: gossard + * Date: Sep 23, 2010 + * Time: 2:40:27 PM + */ +package com.bigdata.btree; + +import com.bigdata.mdi.IResourceMetadata; +import com.bigdata.mdi.SegmentMetadata; +import com.bigdata.rawstore.SimpleMemoryRawStore; +import junit.framework.TestCase; + +import java.io.File; +import java.util.UUID; + +/** + * Basic unit tests for IndexSegment class. + */ +public class TestIndexSegment extends TestCase { + File outputDirectory; + File outputFile; + + BTree sampleTree; + + @Override + protected void setUp() throws Exception { + super.setUp(); + + outputFile = new File(getClass().getName() + ".seg").getAbsoluteFile(); + outputDirectory = outputFile.getParentFile(); + + if ( outputFile.exists() && !outputFile.delete() ) + throw new RuntimeException("Could not delete test file -" + outputFile.getAbsolutePath()); + + //just to be sure. + outputFile.deleteOnExit(); + + + + sampleTree = BTree.create(new SimpleMemoryRawStore(), + new IndexMetadata(UUID.randomUUID()) + ); + + for (int i = 0;i < 10;i++) + sampleTree.insert("key-"+i, "value-"+i); + + } + + @Override + protected void tearDown() throws Exception { + super.tearDown(); + outputFile.delete(); + } + + public void test_verify_getResourceMetadata() throws Exception { + //write segment file from sample tree to disk. + IndexSegmentCheckpoint checkpoint = IndexSegmentBuilder + .newInstance(outputFile, outputDirectory, sampleTree.getEntryCount(), + sampleTree.rangeIterator(), 3, sampleTree.getIndexMetadata(), + System.currentTimeMillis() , true/* compactingMerge */, true /*bufferNodes*/) + .call(); + + //load the segment file from disk. + IndexSegmentStore segStore = new IndexSegmentStore(outputFile); + IndexSegment seg = segStore.loadIndexSegment(); + + IResourceMetadata[] metaList = seg.getResourceMetadata(); + assertNotNull("cannot return null",metaList); + assertEquals("must return only one item", 1, metaList.length); + assertNotNull("item cannot be null",metaList[0]); + assertTrue("resource metadata for IndexSegment must be instanceof SegmentMetadata", (metaList[0] instanceof SegmentMetadata) ); + + SegmentMetadata meta = (SegmentMetadata)metaList[0]; + assertTrue("index segment metadata must return true for isIndexSegment()", meta.isIndexSegment() ); + assertFalse("index segment metadata must return false for isJournal()", meta.isJournal() ); + + //expect short filename like 'foo.seg' , not absolute path. + assertEquals("index metadata backing filename wasn't same as original?", outputFile.getName() , meta.getFile() ); + } +} \ No newline at end of file Property changes on: branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/btree/TestIndexSegment.java ___________________________________________________________________ Added: svn:keywords + Id Date Revision Author HeadURL This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |