Return-Path: Delivered-To: apmail-hadoop-hbase-commits-archive@minotaur.apache.org Received: (qmail 30092 invoked from network); 7 May 2010 19:19:46 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 7 May 2010 19:19:46 -0000 Received: (qmail 40612 invoked by uid 500); 7 May 2010 19:19:46 -0000 Delivered-To: apmail-hadoop-hbase-commits-archive@hadoop.apache.org Received: (qmail 40586 invoked by uid 500); 7 May 2010 19:19:46 -0000 Mailing-List: contact hbase-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hbase-dev@hadoop.apache.org Delivered-To: mailing list hbase-commits@hadoop.apache.org Received: (qmail 40578 invoked by uid 99); 7 May 2010 19:19:46 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 May 2010 19:19:46 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED,T_FILL_THIS_FORM_SHORT X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 May 2010 19:19:31 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 905FD2388ADA; Fri, 7 May 2010 19:18:06 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r942184 [8/15] - in /hadoop/hbase/branches/0.20: ./ src/java/org/apache/hadoop/hbase/ src/java/org/apache/hadoop/hbase/client/ src/java/org/apache/hadoop/hbase/filter/ src/java/org/apache/hadoop/hbase/io/ src/java/org/apache/hadoop/hbase/io... Date: Fri, 07 May 2010 19:17:55 -0000 To: hbase-commits@hadoop.apache.org From: stack@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100507191806.905FD2388ADA@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/RegionManager.java URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/RegionManager.java?rev=942184&r1=942183&r2=942184&view=diff ============================================================================== --- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/RegionManager.java (original) +++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/RegionManager.java Fri May 7 19:17:48 2010 @@ -58,18 +58,18 @@ import org.apache.hadoop.hbase.util.Writ /** * Class to manage assigning regions to servers, state of root and meta, etc. - */ + */ class RegionManager implements HConstants { protected static final Log LOG = LogFactory.getLog(RegionManager.class); - + private AtomicReference rootRegionLocation = new AtomicReference(null); - + private volatile boolean safeMode = true; - + private final RootScanner rootScannerThread; final MetaScanner metaScannerThread; - + /** Set by root scanner to indicate the number of meta regions */ private final AtomicInteger numberOfMetaRegions = new AtomicInteger(); @@ -78,20 +78,20 @@ class RegionManager implements HConstant new ConcurrentSkipListMap(Bytes.BYTES_COMPARATOR); private static final byte[] OVERLOADED = Bytes.toBytes("Overloaded"); - + private static final byte [] META_REGION_PREFIX = Bytes.toBytes(".META.,"); /** * Map of region name to RegionState for regions that are in transition such as - * + * * unassigned -> pendingOpen -> open * closing -> pendingClose -> closed; if (closed && !offline) -> unassigned - * + * * At the end of a transition, removeRegion is used to remove the region from * the map (since it is no longer in transition) - * + * * Note: Needs to be SortedMap so we can specify a comparator - * + * * @see RegionState inner-class below */ final SortedMap regionsInTransition = @@ -149,7 +149,7 @@ class RegionManager implements HConstant Threads.setDaemonThreadRunning(rootScannerThread, "RegionManager.rootScanner"); Threads.setDaemonThreadRunning(metaScannerThread, - "RegionManager.metaScanner"); + "RegionManager.metaScanner"); } void unsetRootRegion() { @@ -160,7 +160,7 @@ class RegionManager implements HConstant LOG.info("-ROOT- region unset (but not set to be reassigned)"); } } - + void reassignRootRegion() { unsetRootRegion(); if (!master.shutdownRequested.get()) { @@ -173,12 +173,12 @@ class RegionManager implements HConstant } } } - + /* * Assigns regions to region servers attempting to balance the load across - * all region servers. Note that no synchronization is necessary as the caller + * all region servers. Note that no synchronization is necessary as the caller * (ServerManager.processMsgs) already owns the monitor for the RegionManager. - * + * * @param info * @param mostLoadedRegions * @param returnMsgs @@ -204,21 +204,21 @@ class RegionManager implements HConstant if (isSingleServer) { assignRegionsToOneServer(regionsToAssign, info, returnMsgs); } else { - // otherwise, give this server a few regions taking into account the + // otherwise, give this server a few regions taking into account the // load of all the other servers. assignRegionsToMultipleServers(thisServersLoad, regionsToAssign, info, returnMsgs); } } } - + /* * Make region assignments taking into account multiple servers' loads. * * Note that no synchronization is needed while we iterate over * regionsInTransition because this method is only called by assignRegions * whose caller owns the monitor for RegionManager - * + * * TODO: This code is unintelligible. REWRITE. Add TESTS! St.Ack 09/30/2009 * @param thisServersLoad * @param regionsToAssign @@ -226,7 +226,7 @@ class RegionManager implements HConstant * @param returnMsgs */ private void assignRegionsToMultipleServers(final HServerLoad thisServersLoad, - final Set regionsToAssign, final HServerInfo info, + final Set regionsToAssign, final HServerInfo info, final ArrayList returnMsgs) { boolean isMetaAssign = false; for (RegionState s : regionsToAssign) { @@ -306,11 +306,11 @@ class RegionManager implements HConstant /* * Assign all to the only server. An unlikely case but still possible. - * + * * Note that no synchronization is needed on regionsInTransition while - * iterating on it because the only caller is assignRegions whose caller owns + * iterating on it because the only caller is assignRegions whose caller owns * the monitor for RegionManager - * + * * @param regionsToAssign * @param serverName * @param returnMsgs @@ -378,11 +378,11 @@ class RegionManager implements HConstant /* * Get the set of regions that should be assignable in this pass. - * + * * Note that no synchronization on regionsInTransition is needed because the * only caller (assignRegions, whose caller is ServerManager.processMsgs) owns * the monitor for RegionManager - */ + */ private Set regionsAwaitingAssignment(HServerAddress addr, boolean isSingleServer) { // set of regions we want to assign to this server @@ -441,14 +441,14 @@ class RegionManager implements HConstant return regionsToAssign; } } - + /* * Figure out the load that is next highest amongst all regionservers. Also, - * return how many servers exist at that load. + * return how many servers exist at that load. */ - private int computeNextHeaviestLoad(HServerLoad referenceLoad, + private int computeNextHeaviestLoad(HServerLoad referenceLoad, HServerLoad heavierLoad) { - + SortedMap> heavyServers = new TreeMap>(); synchronized (master.serverManager.loadToServers) { @@ -479,14 +479,14 @@ class RegionManager implements HConstant * some or all of its most loaded regions, allowing it to reduce its load. * The closed regions will then get picked up by other underloaded machines. * - * Note that no synchronization is needed because the only caller + * Note that no synchronization is needed because the only caller * (assignRegions) whose caller owns the monitor for RegionManager */ - void unassignSomeRegions(final HServerInfo info, + void unassignSomeRegions(final HServerInfo info, int numRegionsToClose, final HRegionInfo[] mostLoadedRegions, ArrayList returnMsgs) { - LOG.debug("Choosing to reassign " + numRegionsToClose - + " regions. mostLoadedRegions has " + mostLoadedRegions.length + LOG.debug("Choosing to reassign " + numRegionsToClose + + " regions. mostLoadedRegions has " + mostLoadedRegions.length + " regions in it."); int regionIdx = 0; int regionsClosed = 0; @@ -531,23 +531,23 @@ class RegionManager implements HConstant return !pathname.equals(HLog.HREGION_LOGDIR_NAME) && !pathname.equals(VERSION_FILE_NAME); } - + } /* * PathFilter that accepts all but compaction.dir names. */ static class RegionDirFilter implements PathFilter { - public boolean accept(Path path) { + public boolean accept(Path path) { return !path.getName().equals(HREGION_COMPACTIONDIR_NAME); } } /** * @return the rough number of the regions on fs - * Note: this method simply counts the regions on fs by accumulating all the dirs + * Note: this method simply counts the regions on fs by accumulating all the dirs * in each table dir (${HBASE_ROOT}/$TABLE) and skipping logfiles, compaction dirs. - * @throws IOException + * @throws IOException */ public int countRegionsOnFS() throws IOException { int regions = 0; @@ -563,7 +563,7 @@ class RegionManager implements HConstant } return regions; } - + /** * @return Read-only map of online regions. */ @@ -584,7 +584,7 @@ class RegionManager implements HConstant } return false; } - + /** * Return a map of the regions in transition on a server. * Returned map entries are region name -> RegionState @@ -619,9 +619,9 @@ class RegionManager implements HConstant LOG.debug("meta and root scanners notified"); } } - + /** Stop the region assigner */ - public void stop() { + public void stop() { try { if (rootScannerThread.isAlive()) { rootScannerThread.join(); // Wait for the root scanner to finish. @@ -639,7 +639,7 @@ class RegionManager implements HConstant master.getZooKeeperWrapper().clearRSDirectory(); master.getZooKeeperWrapper().close(); } - + /** * Block until meta regions are online or we're shutting down. * @return true if we found meta regions, false if we're closing. @@ -650,9 +650,9 @@ class RegionManager implements HConstant numberOfMetaRegions.get() == onlineMetaRegions.size()); } } - + /** - * Search our map of online meta regions to find the first meta region that + * Search our map of online meta regions to find the first meta region that * should contain a pointer to newRegion. * @param newRegion * @return MetaRegion where the newRegion should live @@ -666,13 +666,13 @@ class RegionManager implements HConstant } else { if (onlineMetaRegions.containsKey(newRegion.getRegionName())) { return onlineMetaRegions.get(newRegion.getRegionName()); - } + } return onlineMetaRegions.get(onlineMetaRegions.headMap( newRegion.getRegionName()).lastKey()); } } } - + /** * Get a set of all the meta regions that contain info about a given table. * @param tableName Table you need to know all the meta regions for @@ -738,8 +738,8 @@ class RegionManager implements HConstant * written * @throws IOException */ - public void createRegion(HRegionInfo newRegion, HRegionInterface server, - byte [] metaRegionName) + public void createRegion(HRegionInfo newRegion, HRegionInterface server, + byte [] metaRegionName) throws IOException { // 2. Create the HRegion HRegion region = HRegion.createHRegion(newRegion, master.rootdir, @@ -748,12 +748,12 @@ class RegionManager implements HConstant // 3. Insert into meta HRegionInfo info = region.getRegionInfo(); byte [] regionName = region.getRegionName(); - + Put put = new Put(regionName); - + put.add(CATALOG_FAMILY, REGIONINFO_QUALIFIER, Writables.getBytes(info)); server.put(metaRegionName, put); - + // 4. Close the new region to flush it to disk. Close its log file too. region.close(); region.getLog().closeAndDelete(); @@ -761,17 +761,17 @@ class RegionManager implements HConstant // 5. Get it assigned to a server setUnassigned(info, true); } - - /** - * Set a MetaRegion as online. - * @param metaRegion + + /** + * Set a MetaRegion as online. + * @param metaRegion */ public void putMetaRegionOnline(MetaRegion metaRegion) { onlineMetaRegions.put(metaRegion.getStartKey(), metaRegion); } - /** - * Get a list of online MetaRegions + /** + * Get a list of online MetaRegions * @return list of MetaRegion objects */ public List getListOfOnlineMetaRegions() { @@ -781,26 +781,26 @@ class RegionManager implements HConstant } return regions; } - - /** - * Count of online meta regions + + /** + * Count of online meta regions * @return count of online meta regions */ public int numOnlineMetaRegions() { return onlineMetaRegions.size(); } - - /** - * Check if a meta region is online by its name + + /** + * Check if a meta region is online by its name * @param startKey name of the meta region to check * @return true if the region is online, false otherwise */ public boolean isMetaRegionOnline(byte [] startKey) { return onlineMetaRegions.containsKey(startKey); } - - /** - * Set an online MetaRegion offline - remove it from the map. + + /** + * Set an online MetaRegion offline - remove it from the map. * @param startKey region name * @return the MetaRegion that was taken offline. */ @@ -950,7 +950,7 @@ class RegionManager implements HConstant /** * Remove a region from the region state map. - * + * * @param info */ public void removeRegion(HRegionInfo info) { @@ -958,7 +958,7 @@ class RegionManager implements HConstant this.regionsInTransition.remove(info.getRegionNameAsString()); } } - + /** * @param regionName * @return true if the named region is in a transition state @@ -983,8 +983,8 @@ class RegionManager implements HConstant } } - /** - * Set a region to unassigned + /** + * Set a region to unassigned * @param info Region to set unassigned * @param force if true mark region unassigned whatever its current state */ @@ -1001,8 +1001,8 @@ class RegionManager implements HConstant s.setUnassigned(); } } - - /** + + /** * Check if a region is on the unassigned list * @param info HRegionInfo to check for * @return true if on the unassigned list, false if it isn't. Note that this @@ -1018,11 +1018,11 @@ class RegionManager implements HConstant } return false; } - + /** * Check if a region has been assigned and we're waiting for a response from * the region server. - * + * * @param regionName name of the region * @return true if open, false otherwise */ @@ -1048,7 +1048,7 @@ class RegionManager implements HConstant } } } - + /** * @param regionName * @return true if region is marked to be offlined. @@ -1063,8 +1063,8 @@ class RegionManager implements HConstant return false; } - /** - * Mark a region as closing + /** + * Mark a region as closing * @param serverName * @param regionInfo * @param setOffline @@ -1087,11 +1087,11 @@ class RegionManager implements HConstant this.regionsInTransition.put(regionInfo.getRegionNameAsString(), s); } } - - /** - * Remove the map of region names to region infos waiting to be offlined for a + + /** + * Remove the map of region names to region infos waiting to be offlined for a * given server - * + * * @param serverName * @return set of infos to close */ @@ -1107,10 +1107,10 @@ class RegionManager implements HConstant } return result; } - + /** * Called when we have told a region server to close the region - * + * * @param regionName */ public void setPendingClose(String regionName) { @@ -1121,7 +1121,7 @@ class RegionManager implements HConstant } } } - + /** * @param regionName */ @@ -1140,8 +1140,8 @@ class RegionManager implements HConstant public void addMetaRegionToScan(MetaRegion m) { metaScannerThread.addMetaRegionToScan(m); } - - /** + + /** * Check if the initial root scan has been completed. * @return true if scan completed, false otherwise */ @@ -1149,10 +1149,10 @@ class RegionManager implements HConstant return rootScannerThread.isInitialScanComplete(); } - /** + /** * Check if the initial meta scan has been completed. * @return true if meta completed, false otherwise - */ + */ public boolean isInitialMetaScanComplete() { return metaScannerThread.isInitialScanComplete(); } @@ -1172,7 +1172,7 @@ class RegionManager implements HConstant return false; } - /** + /** * @return true if the initial meta scan is complete and there are no * unassigned or pending regions */ @@ -1191,15 +1191,15 @@ class RegionManager implements HConstant } return safeMode; } - - /** + + /** * Get the root region location. * @return HServerAddress describing root region server. */ public HServerAddress getRootRegionLocation() { return rootRegionLocation.get(); } - + /** * Block until either the root region location is available or we're shutting * down. @@ -1219,7 +1219,7 @@ class RegionManager implements HConstant } } } - + /** * Return the number of meta regions. * @return number of meta regions @@ -1227,7 +1227,7 @@ class RegionManager implements HConstant public int numMetaRegions() { return numberOfMetaRegions.get(); } - + /** * Bump the count of meta regions up one */ @@ -1276,9 +1276,9 @@ class RegionManager implements HConstant synchronized (rootRegionLocation) { rootRegionLocation.set(new HServerAddress(address)); rootRegionLocation.notifyAll(); - } + } } - + /** * Set the number of meta regions. * @param num Number of meta regions @@ -1372,7 +1372,7 @@ class RegionManager implements HConstant applyActions(serverInfo, returnMsgs, this.regionsToMajorCompact, HMsg.Type.MSG_REGION_MAJOR_COMPACT); } - + private void applyActions(final HServerInfo serverInfo, final ArrayList returnMsgs, final SortedMap> map, @@ -1397,28 +1397,28 @@ class RegionManager implements HConstant * Class to balance region servers load. * It keeps Region Servers load in slop range by unassigning Regions * from most loaded servers. - * + * * Equilibrium is reached when load of all serves are in slop range - * [avgLoadMinusSlop, avgLoadPlusSlop], where + * [avgLoadMinusSlop, avgLoadPlusSlop], where * avgLoadPlusSlop = Math.ceil(avgLoad * (1 + this.slop)), and * avgLoadMinusSlop = Math.floor(avgLoad * (1 - this.slop)) - 1. */ private class LoadBalancer { private float slop; // hbase.regions.slop private final int maxRegToClose; // hbase.regions.close.max - + LoadBalancer(HBaseConfiguration conf) { this.slop = conf.getFloat("hbase.regions.slop", (float)0.3); if (this.slop <= 0) this.slop = 1; //maxRegToClose to constrain balance closing per one iteration - // -1 to turn off + // -1 to turn off // TODO: change default in HBASE-862, need a suggestion this.maxRegToClose = conf.getInt("hbase.regions.close.max", -1); } /** * Balance server load by unassigning some regions. - * + * * @param info - server info * @param mostLoadedRegions - array of most loaded regions * @param returnMsgs - array of return massages @@ -1432,27 +1432,27 @@ class RegionManager implements HConstant if(servLoad.getLoad() <= Math.ceil(avg) || avg <= 2.0) { return; } - + // check if current server is overloaded int numRegionsToClose = balanceFromOverloaded(servLoad, avg); - + // check if we can unload server by low loaded servers if(numRegionsToClose <= 0) { - numRegionsToClose = balanceToLowloaded(info.getServerName(), servLoad, + numRegionsToClose = balanceToLowloaded(info.getServerName(), servLoad, avg); } - + if(maxRegToClose > 0) { numRegionsToClose = Math.min(numRegionsToClose, maxRegToClose); } - + if(numRegionsToClose > 0) { - unassignSomeRegions(info, numRegionsToClose, mostLoadedRegions, + unassignSomeRegions(info, numRegionsToClose, mostLoadedRegions, returnMsgs); } } - /* + /* * Check if server load is not overloaded (with load > avgLoadPlusSlop). * @return number of regions to unassign. */ @@ -1469,31 +1469,31 @@ class RegionManager implements HConstant return 0; } - /* - * Check if server is most loaded and can be unloaded to + /* + * Check if server is most loaded and can be unloaded to * low loaded servers (with load < avgLoadMinusSlop). * @return number of regions to unassign. */ - private int balanceToLowloaded(String srvName, HServerLoad srvLoad, + private int balanceToLowloaded(String srvName, HServerLoad srvLoad, double avgLoad) { - SortedMap> loadToServers = + SortedMap> loadToServers = master.serverManager.getLoadToServers(); // check if server most loaded if (!loadToServers.get(loadToServers.lastKey()).contains(srvName)) return 0; - + // this server is most loaded, we will try to unload it by lowest // loaded servers int avgLoadMinusSlop = (int)Math.floor(avgLoad * (1 - this.slop)) - 1; int lowestLoad = loadToServers.firstKey().getNumberOfRegions(); - + if(lowestLoad >= avgLoadMinusSlop) return 0; // there is no low loaded servers - + int lowSrvCount = loadToServers.get(loadToServers.firstKey()).size(); int numRegionsToClose = 0; - + int numSrvRegs = srvLoad.getNumberOfRegions(); int numMoveToLowLoaded = (avgLoadMinusSlop - lowestLoad) * lowSrvCount; numRegionsToClose = numSrvRegs - (int)Math.ceil(avgLoad); @@ -1549,7 +1549,7 @@ class RegionManager implements HConstant */ static class RegionState implements Comparable { private final HRegionInfo regionInfo; - + enum State { UNASSIGNED, // awaiting a server to be assigned PENDING_OPEN, // told a server to open, hasn't opened yet @@ -1557,13 +1557,13 @@ class RegionManager implements HConstant CLOSING, // a msg has been enqueued to close ths region, but not delivered to RS yet PENDING_CLOSE, // msg has been delivered to RS to close this region CLOSED // region has been closed but not yet marked in meta - + } - + private State state; - + private boolean isOfflined; - + /* Set when region is assigned or closing */ private String serverName = null; @@ -1572,11 +1572,11 @@ class RegionManager implements HConstant this.regionInfo = info; this.state = state; } - + synchronized HRegionInfo getRegionInfo() { return this.regionInfo; } - + synchronized byte [] getRegionName() { return this.regionInfo.getRegionName(); } @@ -1592,7 +1592,7 @@ class RegionManager implements HConstant * @return true if the region is being opened */ synchronized boolean isOpening() { - return state == State.UNASSIGNED || + return state == State.UNASSIGNED || state == State.PENDING_OPEN || state == State.OPEN; } @@ -1605,7 +1605,7 @@ class RegionManager implements HConstant } /* - * Note: callers of this method (reassignRootRegion, + * Note: callers of this method (reassignRootRegion, * regionsAwaitingAssignment, setUnassigned) ensure that this method is not * called unless it is safe to do so. */ @@ -1651,7 +1651,7 @@ class RegionManager implements HConstant this.serverName = serverName; this.isOfflined = setOffline; } - + synchronized boolean isPendingClose() { return state == State.PENDING_CLOSE; } @@ -1667,7 +1667,7 @@ class RegionManager implements HConstant synchronized boolean isClosed() { return state == State.CLOSED; } - + synchronized void setClosed() { if (state != State.PENDING_CLOSE && state != State.PENDING_OPEN && @@ -1678,7 +1678,7 @@ class RegionManager implements HConstant } state = State.CLOSED; } - + synchronized boolean isOfflined() { return (state == State.CLOSING || state == State.PENDING_CLOSE) && isOfflined; @@ -1689,7 +1689,7 @@ class RegionManager implements HConstant return ("name=" + Bytes.toString(getRegionName()) + ", state=" + this.state); } - + @Override public boolean equals(Object o) { if (this == o) { @@ -1700,12 +1700,12 @@ class RegionManager implements HConstant } return this.compareTo((RegionState) o) == 0; } - + @Override public int hashCode() { return Bytes.toString(getRegionName()).hashCode(); } - + public int compareTo(RegionState o) { if (o == null) { return 1; Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/RegionServerOperation.java URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/RegionServerOperation.java?rev=942184&r1=942183&r2=942184&view=diff ============================================================================== --- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/RegionServerOperation.java (original) +++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/RegionServerOperation.java Fri May 7 19:17:48 2010 @@ -28,14 +28,14 @@ import org.apache.commons.logging.LogFac import org.apache.hadoop.hbase.HConstants; abstract class RegionServerOperation implements Delayed, HConstants { - protected static final Log LOG = + protected static final Log LOG = LogFactory.getLog(RegionServerOperation.class.getName()); - + private long expire; protected final HMaster master; protected final int numRetries; private int expirationDuration; - + protected RegionServerOperation(HMaster master) { this.master = master; this.numRetries = master.numRetries; @@ -71,7 +71,7 @@ abstract class RegionServerOperation imp int getExpirationDuration() { return this.expirationDuration; } - + void setExpirationDuration(final int d) { this.expirationDuration = d; } @@ -96,9 +96,9 @@ abstract class RegionServerOperation imp // in the run queue, put this request on the delay queue to give // other threads the opportunity to get the meta regions on-line. if (LOG.isDebugEnabled()) { - LOG.debug("numberOfMetaRegions: " + + LOG.debug("numberOfMetaRegions: " + master.regionManager.numMetaRegions() + - ", onlineMetaRegions.size(): " + + ", onlineMetaRegions.size(): " + master.regionManager.numOnlineMetaRegions()); LOG.debug("Requeuing because not all meta regions are online"); } Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/RegionServerOperationQueue.java URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/RegionServerOperationQueue.java?rev=942184&r1=942183&r2=942184&view=diff ============================================================================== --- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/RegionServerOperationQueue.java (original) +++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/RegionServerOperationQueue.java Fri May 7 19:17:48 2010 @@ -32,7 +32,7 @@ import org.apache.hadoop.ipc.RemoteExcep public class RegionServerOperationQueue { // TODO: Build up the junit test of this class. private final Log LOG = LogFactory.getLog(this.getClass()); - + /** * Enums returned by {@link RegionServerOperationQueue#process()}; */ @@ -95,7 +95,7 @@ public class RegionServerOperationQueue * @return {@link ProcessingResultCode#PROCESSED}, * {@link ProcessingResultCode#REQUEUED}, * {@link ProcessingResultCode#REQUEUED_BUT_PROBLEM} - */ + */ public synchronized ProcessingResultCode process(final HServerAddress rootRegionLocation) { RegionServerOperation op = null; // Only process the delayed queue if root region is online. If offline, Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/RetryableMetaOperation.java URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/RetryableMetaOperation.java?rev=942184&r1=942183&r2=942184&view=diff ============================================================================== --- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/RetryableMetaOperation.java (original) +++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/RetryableMetaOperation.java Fri May 7 19:17:48 2010 @@ -44,15 +44,15 @@ abstract class RetryableMetaOperation protected final Sleeper sleeper; protected final MetaRegion m; protected final HMaster master; - + protected HRegionInterface server; - + protected RetryableMetaOperation(MetaRegion m, HMaster master) { this.m = m; this.master = master; this.sleeper = new Sleeper(master.threadWakeFrequency, master.closed); } - + protected T doWithRetries() throws IOException, RuntimeException { List exceptions = new ArrayList(); @@ -76,7 +76,7 @@ abstract class RetryableMetaOperation if (tries == master.numRetries - 1) { if (LOG.isDebugEnabled()) { StringBuilder message = new StringBuilder( - "Trying to contact region server for regionName '" + + "Trying to contact region server for regionName '" + Bytes.toString(m.getRegionName()) + "', but failed after " + (tries + 1) + " attempts.\n"); int i = 1; @@ -97,6 +97,6 @@ abstract class RetryableMetaOperation } this.sleeper.sleep(); } - return null; + return null; } } \ No newline at end of file Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/RootScanner.java URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/RootScanner.java?rev=942184&r1=942183&r2=942184&view=diff ============================================================================== --- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/RootScanner.java (original) +++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/RootScanner.java Fri May 7 19:17:48 2010 @@ -61,7 +61,7 @@ class RootScanner extends BaseScanner { // Make sure the file system is still available master.checkFileSystem(); } catch (Exception e) { - // If for some reason we get some other kind of exception, + // If for some reason we get some other kind of exception, // at least log it rather than go out silently. LOG.error("Unexpected exception", e); } Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/ServerManager.java URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/ServerManager.java?rev=942184&r1=942183&r2=942184&view=diff ============================================================================== --- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/ServerManager.java (original) +++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/ServerManager.java Fri May 7 19:17:48 2010 @@ -55,7 +55,7 @@ import org.apache.zookeeper.Watcher; import org.apache.zookeeper.Watcher.Event.EventType; /** - * The ServerManager class manages info about region servers - HServerInfo, + * The ServerManager class manages info about region servers - HServerInfo, * load numbers, dying servers, etc. */ class ServerManager implements HConstants { @@ -68,7 +68,7 @@ class ServerManager implements HConstant private static final HMsg CALL_SERVER_STARTUP = new HMsg(Type.MSG_CALL_SERVER_STARTUP); private static final HMsg [] EMPTY_HMSG_ARRAY = new HMsg[0]; - + private final AtomicInteger quiescedServers = new AtomicInteger(0); /** The map of known server names to server info */ @@ -77,7 +77,7 @@ class ServerManager implements HConstant final Map serverAddressToServerInfo = new ConcurrentHashMap(); - + /** * Set of known dead servers. On znode expiration, servers are added here. * This is needed in case of a network partitioning where the server's lease @@ -94,10 +94,10 @@ class ServerManager implements HConstant /** Map of server names -> server load */ final Map serversToLoad = - new ConcurrentHashMap(); + new ConcurrentHashMap(); protected HMaster master; - + /* The regionserver will not be assigned or asked close regions if it * is currently opening >= this many regions. */ @@ -127,10 +127,10 @@ class ServerManager implements HConstant sb.append("]"); deadServersList = sb.toString(); } - LOG.info(numServers + " region servers, " + numDeadServers + + LOG.info(numServers + " region servers, " + numDeadServers + " dead, average load " + averageLoad + (deadServersList != null? deadServers: "")); } - + } ServerMonitor serverMonitorThread; @@ -147,13 +147,13 @@ class ServerManager implements HConstant master.shutdownRequested); this.serverMonitorThread.start(); } - + /** * Let the server manager know a new regionserver has come online * @param serverInfo * @throws Leases.LeaseStillHeldException */ - public void regionServerStartup(final HServerInfo serverInfo) + public void regionServerStartup(final HServerInfo serverInfo) throws Leases.LeaseStillHeldException { HServerInfo info = new HServerInfo(serverInfo); String serverName = info.getServerName(); @@ -164,7 +164,7 @@ class ServerManager implements HConstant LOG.debug("deadServers.contains: " + deadServers.contains(serverName)); throw new Leases.LeaseStillHeldException(serverName); } - + LOG.info("Received start message from: " + serverName); // Go on to process the regionserver registration. HServerLoad load = serversToLoad.remove(serverName); @@ -192,8 +192,8 @@ class ServerManager implements HConstant } recordNewServer(info); } - - + + /** * Adds the HSI to the RS list and creates an empty load * @param info The region server informations @@ -201,7 +201,7 @@ class ServerManager implements HConstant public void recordNewServer(HServerInfo info) { recordNewServer(info, false); } - + /** * Adds the HSI to the RS list * @param info The region server informations @@ -228,18 +228,18 @@ class ServerManager implements HConstant loadToServers.put(load, servers); } } - + /** * Called to process the messages sent from the region server to the master * along with the heart beat. - * + * * @param serverInfo * @param msgs * @param mostLoadedRegions Array of regions the region server is submitting * as candidates to be rebalanced, should it be overloaded * @return messages from master to region server indicating what region * server should do. - * + * * @throws IOException */ public HMsg [] regionServerReport(final HServerInfo serverInfo, @@ -300,12 +300,12 @@ class ServerManager implements HConstant // This state is reachable if: // // 1) RegionServer A started - // 2) RegionServer B started on the same machine, then + // 2) RegionServer B started on the same machine, then // clobbered A in regionServerStartup. // 3) RegionServer A returns, expecting to work as usual. // // The answer is to ask A to shut down for good. - + if (LOG.isDebugEnabled()) { LOG.debug("region server race condition detected: " + info.getServerName()); @@ -315,7 +315,7 @@ class ServerManager implements HConstant removeServerInfo(info.getServerName(), info.getServerAddress()); serversToServerInfo.notifyAll(); } - + return new HMsg[] {REGIONSERVER_STOP}; } else { return processRegionServerAllsWell(info, mostLoadedRegions, msgs); @@ -324,13 +324,13 @@ class ServerManager implements HConstant /** * Region server is exiting with a clean shutdown. - * + * * In this case, the server sends MSG_REPORT_EXITING in msgs[0] followed by - * a MSG_REPORT_CLOSE for each region it was serving. + * a MSG_REPORT_CLOSE for each region it was serving. */ private void processRegionServerExit(HServerInfo serverInfo, HMsg[] msgs) { assert msgs[0].getType() == Type.MSG_REPORT_EXITING; - + synchronized (serversToServerInfo) { try { // This method removes ROOT/META from the list and marks them to be reassigned @@ -362,7 +362,7 @@ class ServerManager implements HConstant } } } - + // There should not be any regions in transition for this server - the // server should finish transitions itself before closing Map inTransition = @@ -380,7 +380,7 @@ class ServerManager implements HConstant } finally { serversToServerInfo.notifyAll(); } - } + } } /** @@ -467,7 +467,7 @@ class ServerManager implements HConstant case MSG_REPORT_PROCESS_OPEN: openingCount++; break; - + case MSG_REPORT_OPEN: processRegionOpen(serverInfo, region, returnMsgs); break; @@ -480,7 +480,7 @@ class ServerManager implements HConstant processSplitRegion(region, incomingMsgs[++i].getRegionInfo(), incomingMsgs[++i].getRegionInfo()); break; - + case MSG_REPORT_SPLIT_INCLUDES_DAUGHTERS: processSplitRegion(region, incomingMsgs[i].getDaughterA(), incomingMsgs[i].getDaughterB()); @@ -501,9 +501,9 @@ class ServerManager implements HConstant master.regionManager.setPendingClose(i.getRegionNameAsString()); } - + // Figure out what the RegionServer ought to do, and write back. - + // Should we tell it close regions because its overloaded? If its // currently opening regions, leave it alone till all are open. if (openingCount < this.nobalancingCount) { @@ -516,7 +516,7 @@ class ServerManager implements HConstant } return returnMsgs.toArray(new HMsg[returnMsgs.size()]); } - + /* * A region has split. * @@ -529,7 +529,7 @@ class ServerManager implements HConstant synchronized (master.regionManager) { // Cancel any actions pending for the affected region. // This prevents the master from sending a SPLIT message if the table - // has already split by the region server. + // has already split by the region server. master.regionManager.endActions(region.getRegionName()); assignSplitDaughter(a); assignSplitDaughter(b); @@ -574,7 +574,7 @@ class ServerManager implements HConstant * @param region * @param returnMsgs */ - private void processRegionOpen(HServerInfo serverInfo, + private void processRegionOpen(HServerInfo serverInfo, HRegionInfo region, ArrayList returnMsgs) { boolean duplicateAssignment = false; synchronized (master.regionManager) { @@ -594,7 +594,7 @@ class ServerManager implements HConstant } } else { // Not root region. If it is not a pending region, then we are - // going to treat it as a duplicate assignment, although we can't + // going to treat it as a duplicate assignment, although we can't // tell for certain that's the case. if (master.regionManager.isPendingOpen( region.getRegionNameAsString())) { @@ -604,20 +604,20 @@ class ServerManager implements HConstant duplicateAssignment = true; } } - + if (duplicateAssignment) { LOG.warn("region server " + serverInfo.getServerAddress().toString() + " should not have opened region " + Bytes.toString(region.getRegionName())); // This Region should not have been opened. - // Ask the server to shut it down, but don't report it as closed. - // Otherwise the HMaster will think the Region was closed on purpose, + // Ask the server to shut it down, but don't report it as closed. + // Otherwise the HMaster will think the Region was closed on purpose, // and then try to reopen it elsewhere; that's not what we want. returnMsgs.add(new HMsg(HMsg.Type.MSG_REGION_CLOSE_WITHOUT_REPORT, region, "Duplicate assignment".getBytes())); } else { if (region.isRootRegion()) { - // it was assigned, and it's not a duplicate assignment, so take it out + // it was assigned, and it's not a duplicate assignment, so take it out // of the unassigned list. master.regionManager.removeRegion(region); @@ -676,7 +676,7 @@ class ServerManager implements HConstant this.master.getRegionServerOperationQueue().put(op); } } - + /** Update a server load information because it's shutting down*/ private boolean removeServerInfo(final String serverName, final HServerAddress serverAddress) { @@ -720,10 +720,10 @@ class ServerManager implements HConstant } return infoUpdated; } - - /** - * Compute the average load across all region servers. - * Currently, this uses a very naive computation - just uses the number of + + /** + * Compute the average load across all region servers. + * Currently, this uses a very naive computation - just uses the number of * regions being served, ignoring stats about number of requests. * @return the average load */ @@ -745,7 +745,7 @@ class ServerManager implements HConstant public int numServers() { return serversToServerInfo.size(); } - + /** * @param name server name * @return HServerInfo for the given server address @@ -753,7 +753,7 @@ class ServerManager implements HConstant public HServerInfo getServerInfo(String name) { return serversToServerInfo.get(name); } - + /** * @return Read-only map of servers to serverinfo. */ @@ -796,7 +796,7 @@ class ServerManager implements HConstant serversToServerInfo.notifyAll(); } } - + /* * Wait on regionservers to report in * with {@link #regionServerReport(HServerInfo, HMsg[])} so they get notice @@ -821,7 +821,7 @@ class ServerManager implements HConstant } } } - + /** Watcher triggered when a RS znode is deleted */ private class ServerExpirer implements Watcher { private String server; @@ -870,7 +870,7 @@ class ServerManager implements HConstant public void removeDeadServer(String serverName) { deadServers.remove(serverName); } - + /** * @param serverName * @return true if server is dead Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/TableDelete.java URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/TableDelete.java?rev=942184&r1=942183&r2=942184&view=diff ============================================================================== --- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/TableDelete.java (original) +++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/TableDelete.java Fri May 7 19:17:48 2010 @@ -31,7 +31,7 @@ import org.apache.hadoop.hbase.ipc.HRegi import org.apache.hadoop.hbase.regionserver.HRegion; import org.apache.hadoop.hbase.util.Bytes; -/** +/** * Instantiated to delete a table. Table must be offline. */ class TableDelete extends TableOperation { @@ -62,13 +62,13 @@ class TableDelete extends TableOperation try { HRegion.removeRegionFromMETA(server, m.getRegionName(), i.getRegionName()); HRegion.deleteRegion(this.master.fs, this.master.rootdir, i); - + } catch (IOException e) { LOG.error("failed to delete region " + Bytes.toString(i.getRegionName()), RemoteExceptionHandler.checkIOException(e)); } } - + // delete the table's folder from fs. master.fs.delete(new Path(master.rootdir, Bytes.toString(tableName)), true); } Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/TableOperation.java URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/TableOperation.java?rev=942184&r1=942183&r2=942184&view=diff ============================================================================== --- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/TableOperation.java (original) +++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/TableOperation.java Fri May 7 19:17:48 2010 @@ -37,7 +37,7 @@ import org.apache.hadoop.hbase.ipc.HRegi import org.apache.hadoop.hbase.util.Bytes; /** - * Abstract base class for operations that need to examine all HRegionInfo + * Abstract base class for operations that need to examine all HRegionInfo * objects in a table. (For a table, operate on each of its rows * in .META.). */ @@ -64,7 +64,7 @@ abstract class TableOperation implements // assigned and scanned. if (master.regionManager.metaScannerThread.waitForMetaRegionsOrClose()) { // We're shutting down. Forget it. - throw new MasterNotRunningException(); + throw new MasterNotRunningException(); } } this.metaRegions = master.regionManager.getMetaRegionsForTable(tableName); @@ -156,7 +156,7 @@ abstract class TableOperation implements } } } - + protected boolean isBeingServed(String serverName) { boolean result = false; if (serverName != null && serverName.length() > 0) { Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/ZKMasterAddressWatcher.java URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/ZKMasterAddressWatcher.java?rev=942184&r1=942183&r2=942184&view=diff ============================================================================== --- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/ZKMasterAddressWatcher.java (original) +++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/ZKMasterAddressWatcher.java Fri May 7 19:17:48 2010 @@ -67,7 +67,7 @@ public class ZKMasterAddressWatcher impl notifyAll(); } } - else if(type.equals(EventType.NodeCreated) && + else if(type.equals(EventType.NodeCreated) && event.getPath().equals(this.zooKeeper.clusterStateZNode)) { LOG.debug("Resetting the watch on the cluster state node."); this.zooKeeper.setClusterStateWatch(this); Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/metrics/MasterMetrics.java URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/metrics/MasterMetrics.java?rev=942184&r1=942183&r2=942184&view=diff ============================================================================== --- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/metrics/MasterMetrics.java (original) +++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/metrics/MasterMetrics.java Fri May 7 19:17:48 2010 @@ -28,7 +28,7 @@ import org.apache.hadoop.metrics.jvm.Jvm import org.apache.hadoop.metrics.util.MetricsRegistry; -/** +/** * This class is for maintaining the various master statistics * and publishing them through the metrics interfaces. *

@@ -43,7 +43,7 @@ public class MasterMetrics implements Up /* * Count of requests to the cluster since last call to metrics update */ - private final MetricsRate cluster_requests = + private final MetricsRate cluster_requests = new MetricsRate("cluster_requests", registry); public MasterMetrics() { @@ -59,16 +59,16 @@ public class MasterMetrics implements Up LOG.info("Initialized"); } - + public void shutdown() { if (masterStatistics != null) masterStatistics.shutdown(); } - + /** * Since this object is a registered updater, this method will be called * periodically, e.g. every 5 seconds. - * @param unused + * @param unused */ public void doUpdates(MetricsContext unused) { synchronized (this) { @@ -76,7 +76,7 @@ public class MasterMetrics implements Up } this.metricsRecord.update(); } - + public void resetAllMinMax() { // Nothing to do } @@ -87,7 +87,7 @@ public class MasterMetrics implements Up public float getRequests() { return this.cluster_requests.getPreviousIntervalValue(); } - + /** * @param inc How much to add to requests. */ Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/metrics/MasterStatistics.java URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/metrics/MasterStatistics.java?rev=942184&r1=942183&r2=942184&view=diff ============================================================================== --- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/metrics/MasterStatistics.java (original) +++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/metrics/MasterStatistics.java Fri May 7 19:17:48 2010 @@ -32,7 +32,7 @@ public class MasterStatistics extends Me public MasterStatistics(MetricsRegistry registry) { super(registry, "MasterStatistics"); - mbeanName = MBeanUtil.registerMBean("Master", "MasterStatistics", this); + mbeanName = MBeanUtil.registerMBean("Master", "MasterStatistics", this); } public void shutdown() { Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/metrics/MetricsMBeanBase.java URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/metrics/MetricsMBeanBase.java?rev=942184&r1=942183&r2=942184&view=diff ============================================================================== --- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/metrics/MetricsMBeanBase.java (original) +++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/metrics/MetricsMBeanBase.java Fri May 7 19:17:48 2010 @@ -38,8 +38,8 @@ import org.apache.hadoop.metrics.util.Me /** * Extends the Hadoop MetricsDynamicMBeanBase class to provide JMX support for - * custom HBase MetricsBase implementations. MetricsDynamicMBeanBase ignores - * registered MetricsBase instance that are not instances of one of the + * custom HBase MetricsBase implementations. MetricsDynamicMBeanBase ignores + * registered MetricsBase instance that are not instances of one of the * org.apache.hadoop.metrics.util implementations. * */ @@ -50,13 +50,13 @@ public class MetricsMBeanBase extends Me protected final MetricsRegistry registry; protected final String description; protected int registryLength; - /** HBase MetricsBase implementations that MetricsDynamicMBeanBase does - * not understand + /** HBase MetricsBase implementations that MetricsDynamicMBeanBase does + * not understand */ - protected Map extendedAttributes = + protected Map extendedAttributes = new HashMap(); protected MBeanInfo extendedInfo; - + protected MetricsMBeanBase( MetricsRegistry mr, String description ) { super(copyMinusHBaseMetrics(mr), description); this.registry = mr; @@ -87,45 +87,45 @@ public class MetricsMBeanBase extends Me attributes.add(attr); parentAttributes.add(attr.getName()); } - + this.registryLength = this.registry.getMetricsList().size(); - + for (MetricsBase metric : this.registry.getMetricsList()) { if (metric.getName() == null || parentAttributes.contains(metric.getName())) continue; - + // add on custom HBase metric types if (metric instanceof org.apache.hadoop.hbase.metrics.MetricsRate) { - attributes.add( new MBeanAttributeInfo(metric.getName(), + attributes.add( new MBeanAttributeInfo(metric.getName(), "java.lang.Float", metric.getDescription(), true, false, false) ); extendedAttributes.put(metric.getName(), metric); } // else, its probably a hadoop metric already registered. Skip it. } - this.extendedInfo = new MBeanInfo( this.getClass().getName(), - this.description, attributes.toArray( new MBeanAttributeInfo[0] ), - parentInfo.getConstructors(), parentInfo.getOperations(), + this.extendedInfo = new MBeanInfo( this.getClass().getName(), + this.description, attributes.toArray( new MBeanAttributeInfo[0] ), + parentInfo.getConstructors(), parentInfo.getOperations(), parentInfo.getNotifications() ); } private void checkAndUpdateAttributes() { - if (this.registryLength != this.registry.getMetricsList().size()) + if (this.registryLength != this.registry.getMetricsList().size()) this.init(); } - + @Override public Object getAttribute( String name ) throws AttributeNotFoundException, MBeanException, ReflectionException { - + if (name == null) { throw new IllegalArgumentException("Attribute name is NULL"); } /* * Ugly. Since MetricsDynamicMBeanBase implementation is private, - * we need to first check the parent class for the attribute. + * we need to first check the parent class for the attribute. * In case that the MetricsRegistry contents have changed, this will * allow the parent to update it's internal structures (which we rely on * to update our own. @@ -133,9 +133,9 @@ public class MetricsMBeanBase extends Me try { return super.getAttribute(name); } catch (AttributeNotFoundException ex) { - + checkAndUpdateAttributes(); - + MetricsBase metric = this.extendedAttributes.get(name); if (metric != null) { if (metric instanceof MetricsRate) { @@ -146,7 +146,7 @@ public class MetricsMBeanBase extends Me } } } - + throw new AttributeNotFoundException(); } Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/metrics/MetricsRate.java URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/metrics/MetricsRate.java?rev=942184&r1=942183&r2=942184&view=diff ============================================================================== --- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/metrics/MetricsRate.java (original) +++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/metrics/MetricsRate.java Fri May 7 19:17:48 2010 @@ -30,12 +30,12 @@ import org.apache.hadoop.util.StringUtil */ public class MetricsRate extends MetricsBase { private static final Log LOG = LogFactory.getLog("org.apache.hadoop.hbase.metrics"); - + private int value; private float prevRate; private long ts; - - public MetricsRate(final String name, final MetricsRegistry registry, + + public MetricsRate(final String name, final MetricsRegistry registry, final String description) { super(name, description); this.value = 0; @@ -43,19 +43,19 @@ public class MetricsRate extends Metrics this.ts = System.currentTimeMillis(); registry.add(name, this); } - + public MetricsRate(final String name, final MetricsRegistry registry) { this(name, registry, NO_DESCRIPTION); } - + public synchronized void inc(final int incr) { value += incr; } - + public synchronized void inc() { value++; } - + private synchronized void intervalHeartBeat() { long now = System.currentTimeMillis(); long diff = (now-ts)/1000; @@ -64,18 +64,18 @@ public class MetricsRate extends Metrics this.value = 0; this.ts = now; } - + @Override public synchronized void pushMetric(final MetricsRecord mr) { intervalHeartBeat(); try { mr.setMetric(getName(), getPreviousIntervalValue()); } catch (Exception e) { - LOG.info("pushMetric failed for " + getName() + "\n" + + LOG.info("pushMetric failed for " + getName() + "\n" + StringUtils.stringifyException(e)); } } - + public synchronized float getPreviousIntervalValue() { return this.prevRate; } Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/metrics/file/TimeStampingFileContext.java URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/metrics/file/TimeStampingFileContext.java?rev=942184&r1=942183&r2=942184&view=diff ============================================================================== --- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/metrics/file/TimeStampingFileContext.java (original) +++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/metrics/file/TimeStampingFileContext.java Fri May 7 19:17:48 2010 @@ -40,7 +40,7 @@ public class TimeStampingFileContext ext private File file = null; private PrintWriter writer = null; private final SimpleDateFormat sdf; - + public TimeStampingFileContext() { super(); this.sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/migration/nineteen/HStoreFileToStoreFile.java URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/migration/nineteen/HStoreFileToStoreFile.java?rev=942184&r1=942183&r2=942184&view=diff ============================================================================== --- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/migration/nineteen/HStoreFileToStoreFile.java (original) +++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/migration/nineteen/HStoreFileToStoreFile.java Fri May 7 19:17:48 2010 @@ -91,7 +91,7 @@ public class HStoreFileToStoreFile exten if (out != null) out.close(); } } - + private static void gathermapfiles(final HBaseConfiguration conf, final FileSystem fs, final FSDataOutputStream out) throws IOException { Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/migration/nineteen/HStoreKey.java URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/migration/nineteen/HStoreKey.java?rev=942184&r1=942183&r2=942184&view=diff ============================================================================== --- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/migration/nineteen/HStoreKey.java (original) +++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/migration/nineteen/HStoreKey.java Fri May 7 19:17:48 2010 @@ -40,7 +40,7 @@ public class HStoreKey implements Writab * Colon character in UTF-8 */ public static final char COLUMN_FAMILY_DELIMITER = ':'; - + private byte [] row = HConstants.EMPTY_BYTE_ARRAY; private byte [] column = HConstants.EMPTY_BYTE_ARRAY; private long timestamp = Long.MAX_VALUE; @@ -50,7 +50,7 @@ public class HStoreKey implements Writab * It is not serialized. See https://issues.apache.org/jira/browse/HBASE-832 */ private HRegionInfo regionInfo = null; - + /** * Estimated size tax paid for each instance of HSK. Estimate based on * study of jhat and jprofiler numbers. @@ -63,12 +63,12 @@ public class HStoreKey implements Writab public HStoreKey() { super(); } - + /** * Create an HStoreKey specifying only the row * The column defaults to the empty string, the time stamp defaults to * Long.MAX_VALUE and the table defaults to empty string - * + * * @param row - row key */ public HStoreKey(final byte [] row) { @@ -79,7 +79,7 @@ public class HStoreKey implements Writab * Create an HStoreKey specifying only the row * The column defaults to the empty string, the time stamp defaults to * Long.MAX_VALUE and the table defaults to empty string - * + * * @param row - row key */ public HStoreKey(final String row) { @@ -89,18 +89,18 @@ public class HStoreKey implements Writab /** * Create an HStoreKey specifying the row and timestamp * The column and table names default to the empty string - * + * * @param row row key * @param hri */ public HStoreKey(final byte [] row, final HRegionInfo hri) { this(row, HConstants.EMPTY_BYTE_ARRAY, hri); } - + /** * Create an HStoreKey specifying the row and timestamp * The column and table names default to the empty string - * + * * @param row row key * @param timestamp timestamp value * @param hri HRegionInfo @@ -112,7 +112,7 @@ public class HStoreKey implements Writab /** * Create an HStoreKey specifying the row and timestamp * The column and table names default to the empty string - * + * * @param row row key * @param timestamp timestamp value */ @@ -123,7 +123,7 @@ public class HStoreKey implements Writab /** * Create an HStoreKey specifying the row and timestamp * The column and table names default to the empty string - * + * * @param row row key * @param timestamp timestamp value */ @@ -135,7 +135,7 @@ public class HStoreKey implements Writab * Create an HStoreKey specifying the row and column names * The timestamp defaults to LATEST_TIMESTAMP * and table name defaults to the empty string - * + * * @param row row key * @param column column key */ @@ -147,45 +147,45 @@ public class HStoreKey implements Writab * Create an HStoreKey specifying the row and column names * The timestamp defaults to LATEST_TIMESTAMP * and table name defaults to the empty string - * + * * @param row row key * @param column column key */ public HStoreKey(final byte [] row, final byte [] column) { this(row, column, HConstants.LATEST_TIMESTAMP); } - + /** * Create an HStoreKey specifying the row, column names and table name * The timestamp defaults to LATEST_TIMESTAMP - * + * * @param row row key * @param column column key * @param regionInfo region info */ - public HStoreKey(final byte [] row, + public HStoreKey(final byte [] row, final byte [] column, final HRegionInfo regionInfo) { this(row, column, HConstants.LATEST_TIMESTAMP, regionInfo); } /** * Create an HStoreKey specifying all the fields - * Does not make copies of the passed byte arrays. Presumes the passed + * Does not make copies of the passed byte arrays. Presumes the passed * arrays immutable. * @param row row key * @param column column key * @param timestamp timestamp value * @param regionInfo region info */ - public HStoreKey(final String row, + public HStoreKey(final String row, final String column, long timestamp, final HRegionInfo regionInfo) { - this (Bytes.toBytes(row), Bytes.toBytes(column), + this (Bytes.toBytes(row), Bytes.toBytes(column), timestamp, regionInfo); } /** * Create an HStoreKey specifying all the fields with unspecified table - * Does not make copies of the passed byte arrays. Presumes the passed + * Does not make copies of the passed byte arrays. Presumes the passed * arrays immutable. * @param row row key * @param column column key @@ -194,17 +194,17 @@ public class HStoreKey implements Writab public HStoreKey(final byte [] row, final byte [] column, long timestamp) { this(row, column, timestamp, null); } - + /** * Create an HStoreKey specifying all the fields with specified table - * Does not make copies of the passed byte arrays. Presumes the passed + * Does not make copies of the passed byte arrays. Presumes the passed * arrays immutable. * @param row row key * @param column column key * @param timestamp timestamp value * @param regionInfo region info */ - public HStoreKey(final byte [] row, + public HStoreKey(final byte [] row, final byte [] column, long timestamp, final HRegionInfo regionInfo) { // Make copies this.row = row; @@ -215,26 +215,26 @@ public class HStoreKey implements Writab /** * Constructs a new HStoreKey from another - * + * * @param other the source key */ public HStoreKey(HStoreKey other) { this(other.getRow(), other.getColumn(), other.getTimestamp(), other.getHRegionInfo()); } - + /** * Change the value of the row key - * + * * @param newrow new row key value */ public void setRow(byte [] newrow) { this.row = newrow; } - + /** * Change the value of the column in this key - * + * * @param c new column family value */ public void setColumn(byte [] c) { @@ -243,16 +243,16 @@ public class HStoreKey implements Writab /** * Change the value of the timestamp field - * + * * @param timestamp new timestamp value */ public void setVersion(long timestamp) { this.timestamp = timestamp; } - + /** * Set the value of this HStoreKey from the supplied key - * + * * @param k key value to copy */ public void set(HStoreKey k) { @@ -260,12 +260,12 @@ public class HStoreKey implements Writab this.column = k.getColumn(); this.timestamp = k.getTimestamp(); } - + /** @return value of row key */ public byte [] getRow() { return row; } - + /** @return value of column */ public byte [] getColumn() { return this.column; @@ -275,36 +275,36 @@ public class HStoreKey implements Writab public long getTimestamp() { return this.timestamp; } - + /** @return value of regioninfo */ public HRegionInfo getHRegionInfo() { return this.regionInfo; } - + /** * @param hri */ public void setHRegionInfo(final HRegionInfo hri) { this.regionInfo = hri; } - + /** * Compares the row and column of two keys * @param other Key to compare against. Compares row and column. * @return True if same row and column. * @see #matchesWithoutColumn(HStoreKey) * @see #matchesRowFamily(HStoreKey) - */ + */ public boolean matchesRowCol(HStoreKey other) { return HStoreKey.equalsTwoRowKeys(getHRegionInfo(), getRow(), other.getRow()) && Bytes.equals(getColumn(), other.getColumn()); } - + /** * Compares the row and timestamp of two keys - * + * * @param other Key to copmare against. Compares row and timestamp. - * + * * @return True if same row and timestamp is greater than other * @see #matchesRowCol(HStoreKey) * @see #matchesRowFamily(HStoreKey) @@ -313,12 +313,12 @@ public class HStoreKey implements Writab return equalsTwoRowKeys(getHRegionInfo(), getRow(), other.getRow()) && getTimestamp() >= other.getTimestamp(); } - + /** * Compares the row and column family of two keys - * + * * @param that Key to compare against. Compares row and column family - * + * * @return true if same row and column family * @see #matchesRowCol(HStoreKey) * @see #matchesWithoutColumn(HStoreKey) @@ -329,13 +329,13 @@ public class HStoreKey implements Writab Bytes.compareTo(getColumn(), 0, delimiterIndex, that.getColumn(), 0, delimiterIndex) == 0; } - + @Override public String toString() { return Bytes.toString(this.row) + "/" + Bytes.toString(this.column) + "/" + timestamp; } - + @Override public boolean equals(Object obj) { if (!(obj instanceof HStoreKey)) { @@ -350,7 +350,7 @@ public class HStoreKey implements Writab } return compareTo(other) == 0; } - + @Override public int hashCode() { int result = Bytes.hashCode(getRow()); @@ -364,14 +364,14 @@ public class HStoreKey implements Writab public int compareTo(final HStoreKey o) { return compareTo(this.regionInfo, this, o); } - + static int compareTo(final HRegionInfo hri, final HStoreKey left, final HStoreKey right) { // We can be passed null if (left == null && right == null) return 0; if (left == null) return -1; if (right == null) return 1; - + int result = compareTwoRowKeys(hri, left.getRow(), right.getRow()); if (result != 0) { return result; @@ -403,7 +403,7 @@ public class HStoreKey implements Writab * @param column * @return New byte array that holds column family prefix only * (Does not include the colon DELIMITER). - * @throws ColumnNameParseException + * @throws ColumnNameParseException * @see #parseColumn(byte[]) */ public static byte [] getFamily(final byte [] column) @@ -418,7 +418,7 @@ public class HStoreKey implements Writab System.arraycopy(column, 0, result, 0, index); return result; } - + /** * @param column * @return Return hash of family portion of passed column. @@ -429,7 +429,7 @@ public class HStoreKey implements Writab // delimiter return Bytes.mapKey(column, index > 0? index: column.length); } - + /** * @param family * @param column @@ -444,7 +444,7 @@ public class HStoreKey implements Writab } return Bytes.compareTo(family, 0, index, column, 0, index) == 0; } - + /** * @param family * @return Return family plus the family delimiter. @@ -475,14 +475,14 @@ public class HStoreKey implements Writab * @return Return array of size two whose first element has the family * prefix of passed column c and whose second element is the * column qualifier. - * @throws ColumnNameParseException + * @throws ColumnNameParseException */ public static byte [][] parseColumn(final byte [] c) throws ColumnNameParseException { byte [][] result = new byte [2][]; int index = getFamilyDelimiterIndex(c); if (index == -1) { - throw new ColumnNameParseException("Impossible column name: " + + throw new ColumnNameParseException("Impossible column name: " + Bytes.toStringBinary(c)); } result[0] = new byte [index]; @@ -493,7 +493,7 @@ public class HStoreKey implements Writab len); return result; } - + /** * @param b * @return Index of the family-qualifier colon delimiter character in passed @@ -521,7 +521,7 @@ public class HStoreKey implements Writab public static byte[] getBytes(final HStoreKey hsk) { return Bytes.add(hsk.getRow(), hsk.getColumn()); } - + /** * Utility method to compare two row keys. * This is required because of the meta delimiters. @@ -531,7 +531,7 @@ public class HStoreKey implements Writab * @param rowB * @return value of the comparison */ - public static int compareTwoRowKeys(HRegionInfo regionInfo, + public static int compareTwoRowKeys(HRegionInfo regionInfo, byte[] rowA, byte[] rowB) { if (regionInfo != null && regionInfo.isMetaRegion()) { byte[][] keysA = stripStartKeyMeta(rowA); @@ -543,7 +543,7 @@ public class HStoreKey implements Writab } return Bytes.compareTo(rowA, rowB); } - + /** * Utility method to check if two row keys are equal. * This is required because of the meta delimiters @@ -553,13 +553,13 @@ public class HStoreKey implements Writab * @param rowB * @return if it's equal */ - public static boolean equalsTwoRowKeys(HRegionInfo regionInfo, + public static boolean equalsTwoRowKeys(HRegionInfo regionInfo, byte[] rowA, byte[] rowB) { return ((rowA == null) && (rowB == null)) ? true: (rowA == null) || (rowB == null) || (rowA.length != rowB.length) ? false: compareTwoRowKeys(regionInfo,rowA,rowB) == 0; } - + private static byte[][] stripStartKeyMeta(byte[] rowKey) { int offset = -1; for (int i = rowKey.length - 1; i > 0; i--) { @@ -581,7 +581,7 @@ public class HStoreKey implements Writab elements[1] = timestamp; return elements; } - + // Writable public void write(DataOutput out) throws IOException { @@ -607,13 +607,13 @@ public class HStoreKey implements Writab */ public static class HStoreKeyWritableComparator extends WritableComparator { private final HRegionInfo hri; - + /** @param hri */ public HStoreKeyWritableComparator(final HRegionInfo hri) { super(HStoreKey.class); this.hri = hri; } - + @SuppressWarnings("unchecked") @Override public int compare(final WritableComparable left, @@ -621,7 +621,7 @@ public class HStoreKey implements Writab return compareTo(this.hri, (HStoreKey)left, (HStoreKey)right); } } - + /** * Pass this class into {@link org.apache.hadoop.io.MapFile}.getClosest when * searching for the key that comes BEFORE this one but NOT this one. This @@ -636,19 +636,19 @@ public class HStoreKey implements Writab private final HStoreKey beforeThisKey; /** - * @param beforeThisKey + * @param beforeThisKey */ public BeforeThisStoreKey(final HStoreKey beforeThisKey) { super(); this.beforeThisKey = beforeThisKey; } - + @Override public int compareTo(final HStoreKey o) { int result = this.beforeThisKey.compareTo(o); return result == 0? -1: result; } - + @Override public boolean equals(Object obj) { if (obj == null || !(obj instanceof HStoreKey)) { @@ -731,12 +731,12 @@ public class HStoreKey implements Writab public void write(DataOutput out) throws IOException { this.beforeThisKey.write(out); } - + @Override public HRegionInfo getHRegionInfo() { return this.beforeThisKey.getHRegionInfo(); } - + @Override public void setHRegionInfo(final HRegionInfo hri) { this.beforeThisKey.setHRegionInfo(hri); Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/migration/nineteen/io/BloomFilterMapFile.java URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/migration/nineteen/io/BloomFilterMapFile.java?rev=942184&r1=942183&r2=942184&view=diff ============================================================================== --- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/migration/nineteen/io/BloomFilterMapFile.java (original) +++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/migration/nineteen/io/BloomFilterMapFile.java Fri May 7 19:17:48 2010 @@ -62,7 +62,7 @@ public class BloomFilterMapFile extends * @throws IOException */ public Reader(FileSystem fs, String dirName, Configuration conf, - final boolean filter, final boolean blockCacheEnabled, + final boolean filter, final boolean blockCacheEnabled, HRegionInfo hri) throws IOException { super(fs, dirName, conf, blockCacheEnabled, hri); @@ -89,7 +89,7 @@ public class BloomFilterMapFile extends } return filter; } - + @Override public Writable get(WritableComparable key, Writable val) throws IOException { @@ -126,7 +126,7 @@ public class BloomFilterMapFile extends } return null; } - + /** * @return size of the bloom filter */ @@ -134,13 +134,13 @@ public class BloomFilterMapFile extends return bloomFilter == null ? 0 : bloomFilter.getVectorSize(); } } - + public static class Writer extends HBaseWriter { private static final double DEFAULT_NUMBER_OF_HASH_FUNCTIONS = 4.0; private final BloomFilter bloomFilter; private final String dirName; private final FileSystem fs; - + /** * @param conf * @param fs @@ -159,25 +159,25 @@ public class BloomFilterMapFile extends this.dirName = dirName; this.fs = fs; if (filter) { - /* + /* * There is no way to automatically determine the vector size and the * number of hash functions to use. In particular, bloom filters are * very sensitive to the number of elements inserted into them. For * HBase, the number of entries depends on the size of the data stored * in the column. Currently the default region size is 256MB, so the - * number of entries is approximately + * number of entries is approximately * 256MB / (average value size for column). - * + * * If m denotes the number of bits in the Bloom filter (vectorSize), * n denotes the number of elements inserted into the Bloom filter and * k represents the number of hash functions used (nbHash), then * according to Broder and Mitzenmacher, - * + * * ( http://www.eecs.harvard.edu/~michaelm/NEWWORK/postscripts/BloomFilterSurvey.pdf ) - * + * * the probability of false positives is minimized when k is * approximately m/n ln(2). - * + * * If we fix the number of hash functions and know the number of * entries, then the optimal vector size m = (k * n) / ln(2) */ @@ -215,10 +215,10 @@ public class BloomFilterMapFile extends flushBloomFilter(); } } - + /** * Flushes bloom filter to disk - * + * * @throws IOException */ private void flushBloomFilter() throws IOException { Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/migration/nineteen/io/HBaseMapFile.java URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/migration/nineteen/io/HBaseMapFile.java?rev=942184&r1=942183&r2=942184&view=diff ============================================================================== --- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/migration/nineteen/io/HBaseMapFile.java (original) +++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/migration/nineteen/io/HBaseMapFile.java Fri May 7 19:17:48 2010 @@ -36,7 +36,7 @@ import org.apache.hadoop.io.Writable; public class HBaseMapFile extends MapFile { // TODO not used. remove?! // private static final Log LOG = LogFactory.getLog(HBaseMapFile.class); - + /** * Values are instances of this class. */ @@ -61,7 +61,7 @@ public class HBaseMapFile extends MapFil throws IOException { this(fs, dirName, conf, false, hri); } - + /** * @param fs * @param dirName @@ -73,11 +73,11 @@ public class HBaseMapFile extends MapFil public HBaseReader(FileSystem fs, String dirName, Configuration conf, boolean blockCacheEnabled, HRegionInfo hri) throws IOException { - super(fs, dirName, new org.apache.hadoop.hbase.migration.nineteen.HStoreKey.HStoreKeyWritableComparator(hri), + super(fs, dirName, new org.apache.hadoop.hbase.migration.nineteen.HStoreKey.HStoreKeyWritableComparator(hri), conf, false); // defer opening streams this.blockCacheEnabled = blockCacheEnabled; open(fs, dirName, new org.apache.hadoop.hbase.migration.nineteen.HStoreKey.HStoreKeyWritableComparator(hri), conf); - + // Force reading of the mapfile index by calling midKey. Reading the // index will bring the index into memory over here on the client and // then close the index file freeing up socket connection and resources @@ -85,8 +85,8 @@ public class HBaseMapFile extends MapFil // load the index force the issue in HStoreFile MapFiles because an // access may not happen for some time; meantime we're using up datanode // resources (See HADOOP-2341). midKey() goes to index. Does not seek. - - + + // Disable for migration !!! midKey(); } } Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/migration/nineteen/io/HalfMapFileReader.java URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/migration/nineteen/io/HalfMapFileReader.java?rev=942184&r1=942183&r2=942184&view=diff ============================================================================== --- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/migration/nineteen/io/HalfMapFileReader.java (original) +++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/migration/nineteen/io/HalfMapFileReader.java Fri May 7 19:17:48 2010 @@ -41,10 +41,10 @@ import org.apache.hadoop.io.WritableComp * of the file with keys that sort greater than those of the bottom half. * The top includes the split files midkey, of the key that follows if it does * not exist in the file. - * + * *

This type works in tandem with the {@link Reference} type. This class * is used reading while Reference is used writing. - * + * *

This file is not splitable. Calls to {@link #midKey()} return null. */ //TODO should be fixed generic warnings from MapFile methods @@ -54,7 +54,7 @@ public class HalfMapFileReader extends B private final boolean top; private final HStoreKey midkey; private boolean firstNextCall = true; - + /** * @param fs * @param dirName @@ -64,14 +64,14 @@ public class HalfMapFileReader extends B * @param hri * @throws IOException */ - public HalfMapFileReader(final FileSystem fs, final String dirName, + public HalfMapFileReader(final FileSystem fs, final String dirName, final Configuration conf, final Range r, final WritableComparable mk, final HRegionInfo hri) throws IOException { this(fs, dirName, conf, r, mk, false, false, hri); } - + /** * @param fs * @param dirName @@ -83,7 +83,7 @@ public class HalfMapFileReader extends B * @param hri * @throws IOException */ - public HalfMapFileReader(final FileSystem fs, final String dirName, + public HalfMapFileReader(final FileSystem fs, final String dirName, final Configuration conf, final Range r, final WritableComparable mk, final boolean filter, final boolean blockCacheEnabled, @@ -100,7 +100,7 @@ public class HalfMapFileReader extends B // Is it top or bottom half? this.top = Reference.isTopFileRegion(r); } - + /* * Check key is not bleeding into wrong half of the file. * @param key @@ -124,7 +124,7 @@ public class HalfMapFileReader extends B public synchronized void finalKey(WritableComparable key) throws IOException { if (top) { - super.finalKey(key); + super.finalKey(key); } else { Writable value = new ImmutableBytesWritable(); WritableComparable found = super.getClosest(midkey, value, true); @@ -194,7 +194,7 @@ public class HalfMapFileReader extends B Writables.copyWritable(nearest, key); return true; } - return false; + return false; } } boolean result = super.next(key, val); @@ -208,7 +208,7 @@ public class HalfMapFileReader extends B } return result; } - + @Override public synchronized void reset() throws IOException { if (top) { Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/migration/nineteen/io/Reference.java URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/migration/nineteen/io/Reference.java?rev=942184&r1=942183&r2=942184&view=diff ============================================================================== --- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/migration/nineteen/io/Reference.java (original) +++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/migration/nineteen/io/Reference.java Fri May 7 19:17:48 2010 @@ -33,7 +33,7 @@ import org.apache.hadoop.io.Writable; * half of the file. References are made at region split time. Being lazy * about copying data between the parent of the split and the split daughters * makes splitting faster. - * + * *

References work with {@link HalfMapFileReader}. References know how to * write out the reference format in the file system and are whats juggled when * references are mixed in with direct store files. The @@ -58,8 +58,8 @@ public class Reference implements Writab private long fileid; private Range region; private HStoreKey midkey; - - /** + + /** * For split HStoreFiles, it specifies if the file covers the lower half or * the upper half of the key range */ @@ -69,7 +69,7 @@ public class Reference implements Writab /** HStoreFile contains lower half of key range */ bottom } - + public Reference(final int ern, final long fid, final HStoreKey m, final Range fr) { this.encodedRegionName = ern; @@ -77,7 +77,7 @@ public class Reference implements Writab this.region = fr; this.midkey = m; } - + public Reference() { this(-1, -1, null, Range.bottom); } @@ -89,11 +89,11 @@ public class Reference implements Writab public Range getFileRegion() { return region; } - + public HStoreKey getMidkey() { return midkey; } - + public int getEncodedRegionName() { return this.encodedRegionName; } @@ -127,7 +127,7 @@ public class Reference implements Writab midkey = new HStoreKey(); midkey.readFields(in); } - + public static boolean isTopFileRegion(final Range r) { return r.equals(Range.top); }