Return-Path: X-Original-To: apmail-hbase-commits-archive@www.apache.org Delivered-To: apmail-hbase-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 64F26188C9 for ; Thu, 3 Mar 2016 17:16:56 +0000 (UTC) Received: (qmail 70632 invoked by uid 500); 3 Mar 2016 17:16:49 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 70542 invoked by uid 500); 3 Mar 2016 17:16:49 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 68940 invoked by uid 99); 3 Mar 2016 17:16:48 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Mar 2016 17:16:48 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 58142E78FF; Thu, 3 Mar 2016 17:16:48 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: misty@apache.org To: commits@hbase.apache.org Date: Thu, 03 Mar 2016 17:17:16 -0000 Message-Id: In-Reply-To: <0956c332793142c0a2f193526c17722f@git.apache.org> References: <0956c332793142c0a2f193526c17722f@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [30/49] hbase-site git commit: Published site at 4b3e38705cb24aee82615b1b9af47ed549ea1358. http://git-wip-us.apache.org/repos/asf/hbase-site/blob/4ce8323f/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/AnnotationReadingPriorityFunction.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/AnnotationReadingPriorityFunction.html b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/AnnotationReadingPriorityFunction.html index 6948cc6..f80501b 100644 --- a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/AnnotationReadingPriorityFunction.html +++ b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/AnnotationReadingPriorityFunction.html @@ -51,261 +51,247 @@ 043import com.google.common.annotations.VisibleForTesting; 044import com.google.protobuf.Message; 045import com.google.protobuf.TextFormat; -046import org.apache.hadoop.hbase.security.Superusers; -047import org.apache.hadoop.hbase.security.User; -048 -049/** -050 * Reads special method annotations and table names to figure a priority for use by QoS facility in -051 * ipc; e.g: rpcs to hbase:meta get priority. -052 */ -053// TODO: Remove. This is doing way too much work just to figure a priority. Do as Elliott -054// suggests and just have the client specify a priority. -055 -056//The logic for figuring out high priority RPCs is as follows: -057//1. if the method is annotated with a QosPriority of QOS_HIGH, -058// that is honored -059//2. parse out the protobuf message and see if the request is for meta -060// region, and if so, treat it as a high priority RPC -061//Some optimizations for (2) are done here - -062//Clients send the argument classname as part of making the RPC. The server -063//decides whether to deserialize the proto argument message based on the -064//pre-established set of argument classes (knownArgumentClasses below). -065//This prevents the server from having to deserialize all proto argument -066//messages prematurely. -067//All the argument classes declare a 'getRegion' method that returns a -068//RegionSpecifier object. Methods can be invoked on the returned object -069//to figure out whether it is a meta region or not. -070@InterfaceAudience.Private -071public class AnnotationReadingPriorityFunction implements PriorityFunction { -072 private static final Log LOG = -073 LogFactory.getLog(AnnotationReadingPriorityFunction.class.getName()); -074 -075 /** Used to control the scan delay, currently sqrt(numNextCall * weight) */ -076 public static final String SCAN_VTIME_WEIGHT_CONF_KEY = "hbase.ipc.server.scan.vtime.weight"; -077 -078 protected final Map<String, Integer> annotatedQos; -079 //We need to mock the regionserver instance for some unit tests (set via -080 //setRegionServer method. -081 private RSRpcServices rpcServices; -082 @SuppressWarnings("unchecked") -083 private final Class<? extends Message>[] knownArgumentClasses = new Class[]{ -084 GetRegionInfoRequest.class, -085 GetStoreFileRequest.class, -086 CloseRegionRequest.class, -087 FlushRegionRequest.class, -088 SplitRegionRequest.class, -089 CompactRegionRequest.class, -090 GetRequest.class, -091 MutateRequest.class, -092 ScanRequest.class -093 }; -094 -095 // Some caches for helping performance -096 private final Map<String, Class<? extends Message>> argumentToClassMap = -097 new HashMap<String, Class<? extends Message>>(); -098 private final Map<String, Map<Class<? extends Message>, Method>> methodMap = -099 new HashMap<String, Map<Class<? extends Message>, Method>>(); -100 -101 private final float scanVirtualTimeWeight; -102 -103 /** -104 * Calls {@link #AnnotationReadingPriorityFunction(RSRpcServices, Class)} using the result of -105 * {@code rpcServices#getClass()} -106 * -107 * @param rpcServices -108 * The RPC server implementation -109 */ -110 public AnnotationReadingPriorityFunction(final RSRpcServices rpcServices) { -111 this(rpcServices, rpcServices.getClass()); -112 } -113 -114 /** -115 * Constructs the priority function given the RPC server implementation and the annotations on the -116 * methods in the provided {@code clz}. -117 * -118 * @param rpcServices -119 * The RPC server implementation -120 * @param clz -121 * The concrete RPC server implementation's class -122 */ -123 public AnnotationReadingPriorityFunction(final RSRpcServices rpcServices, -124 Class<? extends RSRpcServices> clz) { -125 Map<String,Integer> qosMap = new HashMap<String,Integer>(); -126 for (Method m : clz.getMethods()) { -127 QosPriority p = m.getAnnotation(QosPriority.class); -128 if (p != null) { -129 // Since we protobuf'd, and then subsequently, when we went with pb style, method names -130 // are capitalized. This meant that this brittle compare of method names gotten by -131 // reflection no longer matched the method names coming in over pb. TODO: Get rid of this -132 // check. For now, workaround is to capitalize the names we got from reflection so they -133 // have chance of matching the pb ones. -134 String capitalizedMethodName = capitalize(m.getName()); -135 qosMap.put(capitalizedMethodName, p.priority()); -136 } -137 } -138 this.rpcServices = rpcServices; -139 this.annotatedQos = qosMap; -140 if (methodMap.get("getRegion") == null) { -141 methodMap.put("hasRegion", new HashMap<Class<? extends Message>, Method>()); -142 methodMap.put("getRegion", new HashMap<Class<? extends Message>, Method>()); -143 } -144 for (Class<? extends Message> cls : knownArgumentClasses) { -145 argumentToClassMap.put(cls.getName(), cls); -146 try { -147 methodMap.get("hasRegion").put(cls, cls.getDeclaredMethod("hasRegion")); -148 methodMap.get("getRegion").put(cls, cls.getDeclaredMethod("getRegion")); -149 } catch (Exception e) { -150 throw new RuntimeException(e); -151 } -152 } -153 -154 Configuration conf = rpcServices.getConfiguration(); -155 scanVirtualTimeWeight = conf.getFloat(SCAN_VTIME_WEIGHT_CONF_KEY, 1.0f); -156 } -157 -158 private String capitalize(final String s) { -159 StringBuilder strBuilder = new StringBuilder(s); -160 strBuilder.setCharAt(0, Character.toUpperCase(strBuilder.charAt(0))); -161 return strBuilder.toString(); -162 } -163 -164 /** -165 * Returns a 'priority' based on the request type. -166 * -167 * Currently the returned priority is used for queue selection. -168 * See the SimpleRpcScheduler as example. It maintains a queue per 'priory type' -169 * HIGH_QOS (meta requests), REPLICATION_QOS (replication requests), -170 * NORMAL_QOS (user requests). -171 */ -172 @Override -173 public int getPriority(RequestHeader header, Message param, User user) { -174 int priorityByAnnotation = getAnnotatedPriority(header); -175 -176 if (priorityByAnnotation >= 0) { -177 return priorityByAnnotation; -178 } -179 -180 // all requests executed by super users have high QoS -181 try { -182 if (Superusers.isSuperUser(user)) { -183 return HConstants.ADMIN_QOS; -184 } -185 } catch (IllegalStateException ex) { -186 // Not good throwing an exception out of here, a runtime anyways. Let the query go into the -187 // server and have it throw the exception if still an issue. Just mark it normal priority. -188 if (LOG.isTraceEnabled()) LOG.trace("Marking normal priority after getting exception=" + ex); -189 return HConstants.NORMAL_QOS; -190 } -191 -192 return getBasePriority(header, param); -193 } -194 -195 /** -196 * See if the method has an annotation. -197 * @param header -198 * @return Return the priority from the annotation. If there isn't -199 * an annotation, this returns something below zero. +046import org.apache.hadoop.hbase.security.User; +047 +048/** +049 * Reads special method annotations and table names to figure a priority for use by QoS facility in +050 * ipc; e.g: rpcs to hbase:meta get priority. +051 */ +052// TODO: Remove. This is doing way too much work just to figure a priority. Do as Elliott +053// suggests and just have the client specify a priority. +054 +055//The logic for figuring out high priority RPCs is as follows: +056//1. if the method is annotated with a QosPriority of QOS_HIGH, +057// that is honored +058//2. parse out the protobuf message and see if the request is for meta +059// region, and if so, treat it as a high priority RPC +060//Some optimizations for (2) are done here - +061//Clients send the argument classname as part of making the RPC. The server +062//decides whether to deserialize the proto argument message based on the +063//pre-established set of argument classes (knownArgumentClasses below). +064//This prevents the server from having to deserialize all proto argument +065//messages prematurely. +066//All the argument classes declare a 'getRegion' method that returns a +067//RegionSpecifier object. Methods can be invoked on the returned object +068//to figure out whether it is a meta region or not. +069@InterfaceAudience.Private +070public class AnnotationReadingPriorityFunction implements PriorityFunction { +071 private static final Log LOG = +072 LogFactory.getLog(AnnotationReadingPriorityFunction.class.getName()); +073 +074 /** Used to control the scan delay, currently sqrt(numNextCall * weight) */ +075 public static final String SCAN_VTIME_WEIGHT_CONF_KEY = "hbase.ipc.server.scan.vtime.weight"; +076 +077 protected final Map<String, Integer> annotatedQos; +078 //We need to mock the regionserver instance for some unit tests (set via +079 //setRegionServer method. +080 private RSRpcServices rpcServices; +081 @SuppressWarnings("unchecked") +082 private final Class<? extends Message>[] knownArgumentClasses = new Class[]{ +083 GetRegionInfoRequest.class, +084 GetStoreFileRequest.class, +085 CloseRegionRequest.class, +086 FlushRegionRequest.class, +087 SplitRegionRequest.class, +088 CompactRegionRequest.class, +089 GetRequest.class, +090 MutateRequest.class, +091 ScanRequest.class +092 }; +093 +094 // Some caches for helping performance +095 private final Map<String, Class<? extends Message>> argumentToClassMap = +096 new HashMap<String, Class<? extends Message>>(); +097 private final Map<String, Map<Class<? extends Message>, Method>> methodMap = +098 new HashMap<String, Map<Class<? extends Message>, Method>>(); +099 +100 private final float scanVirtualTimeWeight; +101 +102 /** +103 * Calls {@link #AnnotationReadingPriorityFunction(RSRpcServices, Class)} using the result of +104 * {@code rpcServices#getClass()} +105 * +106 * @param rpcServices +107 * The RPC server implementation +108 */ +109 public AnnotationReadingPriorityFunction(final RSRpcServices rpcServices) { +110 this(rpcServices, rpcServices.getClass()); +111 } +112 +113 /** +114 * Constructs the priority function given the RPC server implementation and the annotations on the +115 * methods in the provided {@code clz}. +116 * +117 * @param rpcServices +118 * The RPC server implementation +119 * @param clz +120 * The concrete RPC server implementation's class +121 */ +122 public AnnotationReadingPriorityFunction(final RSRpcServices rpcServices, +123 Class<? extends RSRpcServices> clz) { +124 Map<String,Integer> qosMap = new HashMap<String,Integer>(); +125 for (Method m : clz.getMethods()) { +126 QosPriority p = m.getAnnotation(QosPriority.class); +127 if (p != null) { +128 // Since we protobuf'd, and then subsequently, when we went with pb style, method names +129 // are capitalized. This meant that this brittle compare of method names gotten by +130 // reflection no longer matched the method names coming in over pb. TODO: Get rid of this +131 // check. For now, workaround is to capitalize the names we got from reflection so they +132 // have chance of matching the pb ones. +133 String capitalizedMethodName = capitalize(m.getName()); +134 qosMap.put(capitalizedMethodName, p.priority()); +135 } +136 } +137 this.rpcServices = rpcServices; +138 this.annotatedQos = qosMap; +139 if (methodMap.get("getRegion") == null) { +140 methodMap.put("hasRegion", new HashMap<Class<? extends Message>, Method>()); +141 methodMap.put("getRegion", new HashMap<Class<? extends Message>, Method>()); +142 } +143 for (Class<? extends Message> cls : knownArgumentClasses) { +144 argumentToClassMap.put(cls.getName(), cls); +145 try { +146 methodMap.get("hasRegion").put(cls, cls.getDeclaredMethod("hasRegion")); +147 methodMap.get("getRegion").put(cls, cls.getDeclaredMethod("getRegion")); +148 } catch (Exception e) { +149 throw new RuntimeException(e); +150 } +151 } +152 +153 Configuration conf = rpcServices.getConfiguration(); +154 scanVirtualTimeWeight = conf.getFloat(SCAN_VTIME_WEIGHT_CONF_KEY, 1.0f); +155 } +156 +157 private String capitalize(final String s) { +158 StringBuilder strBuilder = new StringBuilder(s); +159 strBuilder.setCharAt(0, Character.toUpperCase(strBuilder.charAt(0))); +160 return strBuilder.toString(); +161 } +162 +163 /** +164 * Returns a 'priority' based on the request type. +165 * +166 * Currently the returned priority is used for queue selection. +167 * See the SimpleRpcScheduler as example. It maintains a queue per 'priory type' +168 * HIGH_QOS (meta requests), REPLICATION_QOS (replication requests), +169 * NORMAL_QOS (user requests). +170 */ +171 @Override +172 public int getPriority(RequestHeader header, Message param, User user) { +173 int priorityByAnnotation = getAnnotatedPriority(header); +174 +175 if (priorityByAnnotation >= 0) { +176 return priorityByAnnotation; +177 } +178 return getBasePriority(header, param); +179 } +180 +181 /** +182 * See if the method has an annotation. +183 * @param header +184 * @return Return the priority from the annotation. If there isn't +185 * an annotation, this returns something below zero. +186 */ +187 protected int getAnnotatedPriority(RequestHeader header) { +188 String methodName = header.getMethodName(); +189 Integer priorityByAnnotation = annotatedQos.get(methodName); +190 if (priorityByAnnotation != null) { +191 return priorityByAnnotation; +192 } +193 return -1; +194 } +195 +196 /** +197 * Get the priority for a given request from the header and the param +198 * This doesn't consider which user is sending the request at all. +199 * This doesn't consider annotations 200 */ -201 protected int getAnnotatedPriority(RequestHeader header) { -202 String methodName = header.getMethodName(); -203 Integer priorityByAnnotation = annotatedQos.get(methodName); -204 if (priorityByAnnotation != null) { -205 return priorityByAnnotation; -206 } -207 return -1; -208 } -209 -210 /** -211 * Get the priority for a given request from the header and the param -212 * This doesn't consider which user is sending the request at all. -213 * This doesn't consider annotations -214 */ -215 protected int getBasePriority(RequestHeader header, Message param) { -216 if (param == null) { -217 return HConstants.NORMAL_QOS; -218 } -219 -220 // Trust the client-set priorities if set -221 if (header.hasPriority()) { -222 return header.getPriority(); -223 } -224 -225 String cls = param.getClass().getName(); -226 Class<? extends Message> rpcArgClass = argumentToClassMap.get(cls); -227 RegionSpecifier regionSpecifier = null; -228 //check whether the request has reference to meta region or now. -229 try { -230 // Check if the param has a region specifier; the pb methods are hasRegion and getRegion if -231 // hasRegion returns true. Not all listed methods have region specifier each time. For -232 // example, the ScanRequest has it on setup but thereafter relies on the scannerid rather than -233 // send the region over every time. -234 Method hasRegion = methodMap.get("hasRegion").get(rpcArgClass); -235 if (hasRegion != null && (Boolean)hasRegion.invoke(param, (Object[])null)) { -236 Method getRegion = methodMap.get("getRegion").get(rpcArgClass); -237 regionSpecifier = (RegionSpecifier)getRegion.invoke(param, (Object[])null); -238 Region region = rpcServices.getRegion(regionSpecifier); -239 if (region.getRegionInfo().isSystemTable()) { -240 if (LOG.isTraceEnabled()) { -241 LOG.trace("High priority because region=" + -242 region.getRegionInfo().getRegionNameAsString()); -243 } -244 return HConstants.SYSTEMTABLE_QOS; -245 } -246 } -247 } catch (Exception ex) { -248 // Not good throwing an exception out of here, a runtime anyways. Let the query go into the -249 // server and have it throw the exception if still an issue. Just mark it normal priority. -250 if (LOG.isTraceEnabled()) LOG.trace("Marking normal priority after getting exception=" + ex); -251 return HConstants.NORMAL_QOS; -252 } -253 -254 if (param instanceof ScanRequest) { // scanner methods... -255 ScanRequest request = (ScanRequest)param; -256 if (!request.hasScannerId()) { -257 return HConstants.NORMAL_QOS; -258 } -259 RegionScanner scanner = rpcServices.getScanner(request.getScannerId()); -260 if (scanner != null && scanner.getRegionInfo().isSystemTable()) { -261 if (LOG.isTraceEnabled()) { -262 // Scanner requests are small in size so TextFormat version should not overwhelm log. -263 LOG.trace("High priority scanner request " + TextFormat.shortDebugString(request)); -264 } -265 return HConstants.SYSTEMTABLE_QOS; -266 } -267 } -268 -269 return HConstants.NORMAL_QOS; -270 } -271 -272 /** -273 * Based on the request content, returns the deadline of the request. -274 * -275 * @param header -276 * @param param -277 * @return Deadline of this request. 0 now, otherwise msec of 'delay' -278 */ -279 @Override -280 public long getDeadline(RequestHeader header, Message param) { -281 if (param instanceof ScanRequest) { -282 ScanRequest request = (ScanRequest)param; -283 if (!request.hasScannerId()) { -284 return 0; -285 } -286 -287 // get the 'virtual time' of the scanner, and applies sqrt() to get a -288 // nice curve for the delay. More a scanner is used the less priority it gets. -289 // The weight is used to have more control on the delay. -290 long vtime = rpcServices.getScannerVirtualTime(request.getScannerId()); -291 return Math.round(Math.sqrt(vtime * scanVirtualTimeWeight)); -292 } -293 return 0; -294 } -295 -296 @VisibleForTesting -297 void setRegionServer(final HRegionServer hrs) { -298 this.rpcServices = hrs.getRSRpcServices(); -299 } -300} +201 protected int getBasePriority(RequestHeader header, Message param) { +202 if (param == null) { +203 return HConstants.NORMAL_QOS; +204 } +205 +206 // Trust the client-set priorities if set +207 if (header.hasPriority()) { +208 return header.getPriority(); +209 } +210 +211 String cls = param.getClass().getName(); +212 Class<? extends Message> rpcArgClass = argumentToClassMap.get(cls); +213 RegionSpecifier regionSpecifier = null; +214 //check whether the request has reference to meta region or now. +215 try { +216 // Check if the param has a region specifier; the pb methods are hasRegion and getRegion if +217 // hasRegion returns true. Not all listed methods have region specifier each time. For +218 // example, the ScanRequest has it on setup but thereafter relies on the scannerid rather than +219 // send the region over every time. +220 Method hasRegion = methodMap.get("hasRegion").get(rpcArgClass); +221 if (hasRegion != null && (Boolean)hasRegion.invoke(param, (Object[])null)) { +222 Method getRegion = methodMap.get("getRegion").get(rpcArgClass); +223 regionSpecifier = (RegionSpecifier)getRegion.invoke(param, (Object[])null); +224 Region region = rpcServices.getRegion(regionSpecifier); +225 if (region.getRegionInfo().isSystemTable()) { +226 if (LOG.isTraceEnabled()) { +227 LOG.trace("High priority because region=" + +228 region.getRegionInfo().getRegionNameAsString()); +229 } +230 return HConstants.SYSTEMTABLE_QOS; +231 } +232 } +233 } catch (Exception ex) { +234 // Not good throwing an exception out of here, a runtime anyways. Let the query go into the +235 // server and have it throw the exception if still an issue. Just mark it normal priority. +236 if (LOG.isTraceEnabled()) LOG.trace("Marking normal priority after getting exception=" + ex); +237 return HConstants.NORMAL_QOS; +238 } +239 +240 if (param instanceof ScanRequest) { // scanner methods... +241 ScanRequest request = (ScanRequest)param; +242 if (!request.hasScannerId()) { +243 return HConstants.NORMAL_QOS; +244 } +245 RegionScanner scanner = rpcServices.getScanner(request.getScannerId()); +246 if (scanner != null && scanner.getRegionInfo().isSystemTable()) { +247 if (LOG.isTraceEnabled()) { +248 // Scanner requests are small in size so TextFormat version should not overwhelm log. +249 LOG.trace("High priority scanner request " + TextFormat.shortDebugString(request)); +250 } +251 return HConstants.SYSTEMTABLE_QOS; +252 } +253 } +254 +255 return HConstants.NORMAL_QOS; +256 } +257 +258 /** +259 * Based on the request content, returns the deadline of the request. +260 * +261 * @param header +262 * @param param +263 * @return Deadline of this request. 0 now, otherwise msec of 'delay' +264 */ +265 @Override +266 public long getDeadline(RequestHeader header, Message param) { +267 if (param instanceof ScanRequest) { +268 ScanRequest request = (ScanRequest)param; +269 if (!request.hasScannerId()) { +270 return 0; +271 } +272 +273 // get the 'virtual time' of the scanner, and applies sqrt() to get a +274 // nice curve for the delay. More a scanner is used the less priority it gets. +275 // The weight is used to have more control on the delay. +276 long vtime = rpcServices.getScannerVirtualTime(request.getScannerId()); +277 return Math.round(Math.sqrt(vtime * scanVirtualTimeWeight)); +278 } +279 return 0; +280 } +281 +282 @VisibleForTesting +283 void setRegionServer(final HRegionServer hrs) { +284 this.rpcServices = hrs.getRSRpcServices(); +285 } +286} http://git-wip-us.apache.org/repos/asf/hbase-site/blob/4ce8323f/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/DefaultMemStore.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/DefaultMemStore.html b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/DefaultMemStore.html index 5d3c7c4..4fad2a6 100644 --- a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/DefaultMemStore.html +++ b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/DefaultMemStore.html @@ -126,94 +126,80 @@ 118 } 119 120 /** -121 * Remove n key from the memstore. Only cells that have the same key and the -122 * same memstoreTS are removed. It is ok to not update timeRangeTracker -123 * in this call. It is possible that we can optimize this method by using -124 * tailMap/iterator, but since this method is called rarely (only for -125 * error recovery), we can leave those optimization for the future. -126 * @param cell -127 */ -128 @Override -129 public void rollback(Cell cell) { -130 rollbackInSnapshot(cell); -131 rollbackInActive(cell); +121 * @param cell Find the row that comes after this one. If null, we return the +122 * first. +123 * @return Next row or null if none found. +124 */ +125 Cell getNextRow(final Cell cell) { +126 return getLowest( +127 getNextRow(cell, getActive().getCellSet()), +128 getNextRow(cell, getSnapshot().getCellSet())); +129 } +130 +131 @Override public void updateLowestUnflushedSequenceIdInWal(boolean onlyIfMoreRecent) { 132 } 133 134 /** -135 * @param cell Find the row that comes after this one. If null, we return the -136 * first. -137 * @return Next row or null if none found. -138 */ -139 Cell getNextRow(final Cell cell) { -140 return getLowest( -141 getNextRow(cell, getActive().getCellSet()), -142 getNextRow(cell, getSnapshot().getCellSet())); -143 } -144 -145 @Override public void updateLowestUnflushedSequenceIdInWal(boolean onlyIfMoreRecent) { -146 } -147 -148 /** -149 * @return Total memory occupied by this MemStore. -150 */ +135 * @return Total memory occupied by this MemStore. +136 */ +137 @Override +138 public long size() { +139 return heapSize(); +140 } +141 +142 /** +143 * Check whether anything need to be done based on the current active set size +144 * Nothing need to be done for the DefaultMemStore +145 */ +146 @Override +147 protected void checkActiveSize() { +148 return; +149 } +150 151 @Override -152 public long size() { -153 return heapSize(); -154 } -155 -156 /** -157 * Check whether anything need to be done based on the current active set size -158 * Nothing need to be done for the DefaultMemStore -159 */ -160 @Override -161 protected void checkActiveSize() { -162 return; -163 } -164 -165 @Override -166 public void finalizeFlush() { -167 } -168 -169 /** -170 * Code to help figure if our approximation of object heap sizes is close -171 * enough. See hbase-900. Fills memstores then waits so user can heap -172 * dump and bring up resultant hprof in something like jprofiler which -173 * allows you get 'deep size' on objects. -174 * @param args main args -175 */ -176 public static void main(String [] args) { -177 RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean(); -178 LOG.info("vmName=" + runtime.getVmName() + ", vmVendor=" + -179 runtime.getVmVendor() + ", vmVersion=" + runtime.getVmVersion()); -180 LOG.info("vmInputArguments=" + runtime.getInputArguments()); -181 DefaultMemStore memstore1 = new DefaultMemStore(); -182 // TODO: x32 vs x64 -183 long size = 0; -184 final int count = 10000; -185 byte [] fam = Bytes.toBytes("col"); -186 byte [] qf = Bytes.toBytes("umn"); -187 byte [] empty = new byte[0]; -188 for (int i = 0; i < count; i++) { -189 // Give each its own ts -190 size += memstore1.add(new KeyValue(Bytes.toBytes(i), fam, qf, i, empty)); -191 } -192 LOG.info("memstore1 estimated size=" + size); -193 for (int i = 0; i < count; i++) { -194 size += memstore1.add(new KeyValue(Bytes.toBytes(i), fam, qf, i, empty)); -195 } -196 LOG.info("memstore1 estimated size (2nd loading of same data)=" + size); -197 // Make a variably sized memstore. -198 DefaultMemStore memstore2 = new DefaultMemStore(); -199 for (int i = 0; i < count; i++) { -200 size += memstore2.add(new KeyValue(Bytes.toBytes(i), fam, qf, i, new byte[i])); -201 } -202 LOG.info("memstore2 estimated size=" + size); -203 final int seconds = 30; -204 LOG.info("Waiting " + seconds + " seconds while heap dump is taken"); -205 LOG.info("Exiting."); -206 } -207 -208} +152 public void finalizeFlush() { +153 } +154 +155 /** +156 * Code to help figure if our approximation of object heap sizes is close +157 * enough. See hbase-900. Fills memstores then waits so user can heap +158 * dump and bring up resultant hprof in something like jprofiler which +159 * allows you get 'deep size' on objects. +160 * @param args main args +161 */ +162 public static void main(String [] args) { +163 RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean(); +164 LOG.info("vmName=" + runtime.getVmName() + ", vmVendor=" + +165 runtime.getVmVendor() + ", vmVersion=" + runtime.getVmVersion()); +166 LOG.info("vmInputArguments=" + runtime.getInputArguments()); +167 DefaultMemStore memstore1 = new DefaultMemStore(); +168 // TODO: x32 vs x64 +169 long size = 0; +170 final int count = 10000; +171 byte [] fam = Bytes.toBytes("col"); +172 byte [] qf = Bytes.toBytes("umn"); +173 byte [] empty = new byte[0]; +174 for (int i = 0; i < count; i++) { +175 // Give each its own ts +176 size += memstore1.add(new KeyValue(Bytes.toBytes(i), fam, qf, i, empty)); +177 } +178 LOG.info("memstore1 estimated size=" + size); +179 for (int i = 0; i < count; i++) { +180 size += memstore1.add(new KeyValue(Bytes.toBytes(i), fam, qf, i, empty)); +181 } +182 LOG.info("memstore1 estimated size (2nd loading of same data)=" + size); +183 // Make a variably sized memstore. +184 DefaultMemStore memstore2 = new DefaultMemStore(); +185 for (int i = 0; i < count; i++) { +186 size += memstore2.add(new KeyValue(Bytes.toBytes(i), fam, qf, i, new byte[i])); +187 } +188 LOG.info("memstore2 estimated size=" + size); +189 final int seconds = 30; +190 LOG.info("Waiting " + seconds + " seconds while heap dump is taken"); +191 LOG.info("Exiting."); +192 } +193 +194} http://git-wip-us.apache.org/repos/asf/hbase-site/blob/4ce8323f/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/ImmutableSegment.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/ImmutableSegment.html b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/ImmutableSegment.html index 7157068..44be699 100644 --- a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/ImmutableSegment.html +++ b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/ImmutableSegment.html @@ -26,58 +26,32 @@ 018 */ 019package org.apache.hadoop.hbase.regionserver; 020 -021import org.apache.commons.lang.NotImplementedException; -022import org.apache.hadoop.hbase.Cell; -023import org.apache.hadoop.hbase.classification.InterfaceAudience; -024 -025/** -026 * ImmutableSegment is an abstract class that extends the API supported by a {@link Segment}, -027 * and is not needed for a {@link MutableSegment}. Specifically, the method -028 * {@link ImmutableSegment#getKeyValueScanner()} builds a special scanner for the -029 * {@link MemStoreSnapshot} object. -030 * In addition, this class overrides methods that are not likely to be supported by an immutable -031 * segment, e.g. {@link Segment#rollback(Cell)} and {@link Segment#getCellSet()}, which -032 * can be very inefficient. -033 */ -034@InterfaceAudience.Private -035public abstract class ImmutableSegment extends Segment { +021import org.apache.hadoop.hbase.classification.InterfaceAudience; +022import org.apache.hadoop.hbase.util.CollectionBackedScanner; +023 +024/** +025 * ImmutableSegment is an abstract class that extends the API supported by a {@link Segment}, +026 * and is not needed for a {@link MutableSegment}. Specifically, the method +027 * {@link ImmutableSegment#getKeyValueScanner()} builds a special scanner for the +028 * {@link MemStoreSnapshot} object. +029 */ +030@InterfaceAudience.Private +031public class ImmutableSegment extends Segment { +032 +033 protected ImmutableSegment(Segment segment) { +034 super(segment); +035 } 036 -037 public ImmutableSegment(Segment segment) { -038 super(segment); -039 } -040 -041 /** -042 * Removes the given cell from this segment. -043 * By default immutable store segment can not rollback -044 * It may be invoked by tests in specific cases where it is known to be supported {@link -045 * ImmutableSegmentAdapter} -046 */ -047 @Override -048 public long rollback(Cell cell) { -049 return 0; -050 } -051 -052 /** -053 * Returns a set of all the cells in the segment. -054 * The implementation of this method might be very inefficient for some immutable segments -055 * that do not maintain a cell set. Therefore by default this method is not supported. -056 * It may be invoked by tests in specific cases where it is known to be supported {@link -057 * ImmutableSegmentAdapter} -058 */ -059 @Override -060 public CellSet getCellSet() { -061 throw new NotImplementedException("Immutable Segment does not support this operation by " + -062 "default"); -063 } -064 -065 /** -066 * Builds a special scanner for the MemStoreSnapshot object that may be different than the -067 * general segment scanner. -068 * @return a special scanner for the MemStoreSnapshot object -069 */ -070 public abstract KeyValueScanner getKeyValueScanner(); -071 -072} +037 /** +038 * Builds a special scanner for the MemStoreSnapshot object that is different than the +039 * general segment scanner. +040 * @return a special scanner for the MemStoreSnapshot object +041 */ +042 public KeyValueScanner getKeyValueScanner() { +043 return new CollectionBackedScanner(getCellSet(), getComparator()); +044 } +045 +046} http://git-wip-us.apache.org/repos/asf/hbase-site/blob/4ce8323f/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/ImmutableSegmentAdapter.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/ImmutableSegmentAdapter.html b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/ImmutableSegmentAdapter.html deleted file mode 100644 index cb291b7..0000000 --- a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/ImmutableSegmentAdapter.html +++ /dev/null @@ -1,179 +0,0 @@ - - - -Source code - - - -
-
001/**
-002 *
-003 * Licensed to the Apache Software Foundation (ASF) under one
-004 * or more contributor license agreements.  See the NOTICE file
-005 * distributed with this work for additional information
-006 * regarding copyright ownership.  The ASF licenses this file
-007 * to you under the Apache License, Version 2.0 (the
-008 * "License"); you may not use this file except in compliance
-009 * with the License.  You may obtain a copy of the License at
-010 *
-011 *     http://www.apache.org/licenses/LICENSE-2.0
-012 *
-013 * Unless required by applicable law or agreed to in writing, software
-014 * distributed under the License is distributed on an "AS IS" BASIS,
-015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-016 * See the License for the specific language governing permissions and
-017 * limitations under the License.
-018 */
-019package org.apache.hadoop.hbase.regionserver;
-020
-021import org.apache.commons.logging.Log;
-022import org.apache.hadoop.hbase.Cell;
-023import org.apache.hadoop.hbase.classification.InterfaceAudience;
-024import org.apache.hadoop.hbase.util.CollectionBackedScanner;
-025
-026/**
-027 * This segment is adapting a mutable segment making it into an immutable segment.
-028 * This is used when a mutable segment is moved to being a snapshot or pushed into a compaction
-029 * pipeline, that consists only of immutable segments.
-030 * The compaction may generate different type of immutable segment
-031 */
-032@InterfaceAudience.Private
-033public class ImmutableSegmentAdapter extends ImmutableSegment {
-034
-035  final private MutableSegment adaptee;
-036
-037  public ImmutableSegmentAdapter(MutableSegment segment) {
-038    super(segment);
-039    this.adaptee = segment;
-040  }
-041
-042  @Override
-043  public KeyValueScanner getKeyValueScanner() {
-044    return new CollectionBackedScanner(adaptee.getCellSet(), adaptee.getComparator());
-045  }
-046
-047  @Override
-048  public SegmentScanner getSegmentScanner(long readPoint) {
-049    return adaptee.getSegmentScanner(readPoint);
-050  }
-051
-052  @Override
-053  public boolean isEmpty() {
-054    return adaptee.isEmpty();
-055  }
-056
-057  @Override
-058  public int getCellsCount() {
-059    return adaptee.getCellsCount();
-060  }
-061
-062  @Override
-063  public long add(Cell cell) {
-064    return adaptee.add(cell);
-065  }
-066
-067  @Override
-068  public Cell getFirstAfter(Cell cell) {
-069    return adaptee.getFirstAfter(cell);
-070  }
-071
-072  @Override
-073  public void close() {
-074    adaptee.close();
-075  }
-076
-077  @Override
-078  public Cell maybeCloneWithAllocator(Cell cell) {
-079    return adaptee.maybeCloneWithAllocator(cell);
-080  }
-081
-082  @Override
-083  public Segment setSize(long size) {
-084    adaptee.setSize(size);
-085    return this;
-086  }
-087
-088  @Override
-089  public long getSize() {
-090    return adaptee.getSize();
-091  }
-092
-093  @Override
-094  public long rollback(Cell cell) {
-095    return adaptee.rollback(cell);
-096  }
-097
-098  @Override
-099  public CellSet getCellSet() {
-100    return adaptee.getCellSet();
-101  }
-102
-103  @Override
-104  public void dump(Log log) {
-105    adaptee.dump(log);
-106  }
-107}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -