http://git-wip-us.apache.org/repos/asf/hbase-site/blob/670bf1f0/devapidocs/src-html/org/apache/hadoop/hbase/mapreduce/RowCounter.RowCounterMapper.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/mapreduce/RowCounter.RowCounterMapper.html b/devapidocs/src-html/org/apache/hadoop/hbase/mapreduce/RowCounter.RowCounterMapper.html index 571c70a..c037057 100644 --- a/devapidocs/src-html/org/apache/hadoop/hbase/mapreduce/RowCounter.RowCounterMapper.html +++ b/devapidocs/src-html/org/apache/hadoop/hbase/mapreduce/RowCounter.RowCounterMapper.html @@ -126,118 +126,117 @@ <span class="sourceLineNo">118</span> }<a name="line.118"></a> <span class="sourceLineNo">119</span> startKey = startEnd[0];<a name="line.119"></a> <span class="sourceLineNo">120</span> endKey = startEnd[1];<a name="line.120"></a> -<span class="sourceLineNo">121</span> }<a name="line.121"></a> -<span class="sourceLineNo">122</span> if (startTime < endTime) {<a name="line.122"></a> -<span class="sourceLineNo">123</span> printUsage("--endtime=" + endTime + " needs to be greater than --starttime=" + startTime);<a name="line.123"></a> -<span class="sourceLineNo">124</span> return null;<a name="line.124"></a> -<span class="sourceLineNo">125</span> }<a name="line.125"></a> -<span class="sourceLineNo">126</span> if (args[i].startsWith(startTimeArgKey)) {<a name="line.126"></a> -<span class="sourceLineNo">127</span> startTime = Long.parseLong(args[i].substring(startTimeArgKey.length()));<a name="line.127"></a> -<span class="sourceLineNo">128</span> continue;<a name="line.128"></a> -<span class="sourceLineNo">129</span> }<a name="line.129"></a> -<span class="sourceLineNo">130</span> if (args[i].startsWith(endTimeArgKey)) {<a name="line.130"></a> -<span class="sourceLineNo">131</span> endTime = Long.parseLong(args[i].substring(endTimeArgKey.length()));<a name="line.131"></a> -<span class="sourceLineNo">132</span> continue;<a name="line.132"></a> -<span class="sourceLineNo">133</span> }<a name="line.133"></a> -<span class="sourceLineNo">134</span> if (args[i].startsWith(expectedCountArg)) {<a name="line.134"></a> -<span class="sourceLineNo">135</span> conf.setLong(EXPECTED_COUNT_KEY,<a name="line.135"></a> -<span class="sourceLineNo">136</span> Long.parseLong(args[i].substring(expectedCountArg.length())));<a name="line.136"></a> -<span class="sourceLineNo">137</span> continue;<a name="line.137"></a> -<span class="sourceLineNo">138</span> }<a name="line.138"></a> -<span class="sourceLineNo">139</span> else {<a name="line.139"></a> -<span class="sourceLineNo">140</span> // if no switch, assume column names<a name="line.140"></a> -<span class="sourceLineNo">141</span> sb.append(args[i]);<a name="line.141"></a> -<span class="sourceLineNo">142</span> sb.append(" ");<a name="line.142"></a> -<span class="sourceLineNo">143</span> }<a name="line.143"></a> -<span class="sourceLineNo">144</span> }<a name="line.144"></a> -<span class="sourceLineNo">145</span><a name="line.145"></a> -<span class="sourceLineNo">146</span> Job job = Job.getInstance(conf, conf.get(JOB_NAME_CONF_KEY, NAME + "_" + tableName));<a name="line.146"></a> -<span class="sourceLineNo">147</span> job.setJarByClass(RowCounter.class);<a name="line.147"></a> -<span class="sourceLineNo">148</span> Scan scan = new Scan();<a name="line.148"></a> -<span class="sourceLineNo">149</span> scan.setCacheBlocks(false);<a name="line.149"></a> -<span class="sourceLineNo">150</span> if (startKey != null && !startKey.equals("")) {<a name="line.150"></a> -<span class="sourceLineNo">151</span> scan.setStartRow(Bytes.toBytes(startKey));<a name="line.151"></a> -<span class="sourceLineNo">152</span> }<a name="line.152"></a> -<span class="sourceLineNo">153</span> if (endKey != null && !endKey.equals("")) {<a name="line.153"></a> -<span class="sourceLineNo">154</span> scan.setStopRow(Bytes.toBytes(endKey));<a name="line.154"></a> -<span class="sourceLineNo">155</span> }<a name="line.155"></a> -<span class="sourceLineNo">156</span> if (sb.length() > 0) {<a name="line.156"></a> -<span class="sourceLineNo">157</span> for (String columnName : sb.toString().trim().split(" ")) {<a name="line.157"></a> -<span class="sourceLineNo">158</span> String family = StringUtils.substringBefore(columnName, ":");<a name="line.158"></a> -<span class="sourceLineNo">159</span> String qualifier = StringUtils.substringAfter(columnName, ":");<a name="line.159"></a> -<span class="sourceLineNo">160</span><a name="line.160"></a> -<span class="sourceLineNo">161</span> if (StringUtils.isBlank(qualifier)) {<a name="line.161"></a> -<span class="sourceLineNo">162</span> scan.addFamily(Bytes.toBytes(family));<a name="line.162"></a> -<span class="sourceLineNo">163</span> }<a name="line.163"></a> -<span class="sourceLineNo">164</span> else {<a name="line.164"></a> -<span class="sourceLineNo">165</span> scan.addColumn(Bytes.toBytes(family), Bytes.toBytes(qualifier));<a name="line.165"></a> -<span class="sourceLineNo">166</span> }<a name="line.166"></a> -<span class="sourceLineNo">167</span> }<a name="line.167"></a> -<span class="sourceLineNo">168</span> }<a name="line.168"></a> -<span class="sourceLineNo">169</span> scan.setFilter(new FirstKeyOnlyFilter());<a name="line.169"></a> -<span class="sourceLineNo">170</span> scan.setTimeRange(startTime, endTime == 0 ? HConstants.LATEST_TIMESTAMP : endTime);<a name="line.170"></a> -<span class="sourceLineNo">171</span> job.setOutputFormatClass(NullOutputFormat.class);<a name="line.171"></a> -<span class="sourceLineNo">172</span> TableMapReduceUtil.initTableMapperJob(tableName, scan,<a name="line.172"></a> -<span class="sourceLineNo">173</span> RowCounterMapper.class, ImmutableBytesWritable.class, Result.class, job);<a name="line.173"></a> -<span class="sourceLineNo">174</span> job.setNumReduceTasks(0);<a name="line.174"></a> -<span class="sourceLineNo">175</span> return job;<a name="line.175"></a> -<span class="sourceLineNo">176</span> }<a name="line.176"></a> -<span class="sourceLineNo">177</span><a name="line.177"></a> -<span class="sourceLineNo">178</span> /*<a name="line.178"></a> -<span class="sourceLineNo">179</span> * @param errorMessage Can attach a message when error occurs.<a name="line.179"></a> -<span class="sourceLineNo">180</span> */<a name="line.180"></a> -<span class="sourceLineNo">181</span> private static void printUsage(String errorMessage) {<a name="line.181"></a> -<span class="sourceLineNo">182</span> System.err.println("ERROR: " + errorMessage);<a name="line.182"></a> -<span class="sourceLineNo">183</span> printUsage();<a name="line.183"></a> -<span class="sourceLineNo">184</span> }<a name="line.184"></a> -<span class="sourceLineNo">185</span><a name="line.185"></a> -<span class="sourceLineNo">186</span> /**<a name="line.186"></a> -<span class="sourceLineNo">187</span> * Prints usage without error message.<a name="line.187"></a> -<span class="sourceLineNo">188</span> * Note that we don't document --expected-count, because it's intended for test.<a name="line.188"></a> -<span class="sourceLineNo">189</span> */<a name="line.189"></a> -<span class="sourceLineNo">190</span> private static void printUsage() {<a name="line.190"></a> -<span class="sourceLineNo">191</span> System.err.println("Usage: RowCounter [options] <tablename> " +<a name="line.191"></a> -<span class="sourceLineNo">192</span> "[--starttime=[start] --endtime=[end] " +<a name="line.192"></a> -<span class="sourceLineNo">193</span> "[--range=[startKey],[endKey]] [<column1> <column2>...]");<a name="line.193"></a> -<span class="sourceLineNo">194</span> System.err.println("For performance consider the following options:\n"<a name="line.194"></a> -<span class="sourceLineNo">195</span> + "-Dhbase.client.scanner.caching=100\n"<a name="line.195"></a> -<span class="sourceLineNo">196</span> + "-Dmapreduce.map.speculative=false");<a name="line.196"></a> -<span class="sourceLineNo">197</span> }<a name="line.197"></a> -<span class="sourceLineNo">198</span><a name="line.198"></a> -<span class="sourceLineNo">199</span> @Override<a name="line.199"></a> -<span class="sourceLineNo">200</span> public int run(String[] args) throws Exception {<a name="line.200"></a> -<span class="sourceLineNo">201</span> if (args.length < 1) {<a name="line.201"></a> -<span class="sourceLineNo">202</span> printUsage("Wrong number of parameters: " + args.length);<a name="line.202"></a> -<span class="sourceLineNo">203</span> return -1;<a name="line.203"></a> -<span class="sourceLineNo">204</span> }<a name="line.204"></a> -<span class="sourceLineNo">205</span> Job job = createSubmittableJob(getConf(), args);<a name="line.205"></a> -<span class="sourceLineNo">206</span> if (job == null) {<a name="line.206"></a> -<span class="sourceLineNo">207</span> return -1;<a name="line.207"></a> -<span class="sourceLineNo">208</span> }<a name="line.208"></a> -<span class="sourceLineNo">209</span> boolean success = job.waitForCompletion(true);<a name="line.209"></a> -<span class="sourceLineNo">210</span> final long expectedCount = getConf().getLong(EXPECTED_COUNT_KEY, -1);<a name="line.210"></a> -<span class="sourceLineNo">211</span> if (success && expectedCount != -1) {<a name="line.211"></a> -<span class="sourceLineNo">212</span> final Counter counter = job.getCounters().findCounter(RowCounterMapper.Counters.ROWS);<a name="line.212"></a> -<span class="sourceLineNo">213</span> success = expectedCount == counter.getValue();<a name="line.213"></a> -<span class="sourceLineNo">214</span> if (!success) {<a name="line.214"></a> -<span class="sourceLineNo">215</span> LOG.error("Failing job because count of '" + counter.getValue() +<a name="line.215"></a> -<span class="sourceLineNo">216</span> "' does not match expected count of '" + expectedCount + "'");<a name="line.216"></a> -<span class="sourceLineNo">217</span> }<a name="line.217"></a> -<span class="sourceLineNo">218</span> }<a name="line.218"></a> -<span class="sourceLineNo">219</span> return (success ? 0 : 1);<a name="line.219"></a> -<span class="sourceLineNo">220</span> }<a name="line.220"></a> -<span class="sourceLineNo">221</span><a name="line.221"></a> -<span class="sourceLineNo">222</span> /**<a name="line.222"></a> -<span class="sourceLineNo">223</span> * Main entry point.<a name="line.223"></a> -<span class="sourceLineNo">224</span> * @param args The command line parameters.<a name="line.224"></a> -<span class="sourceLineNo">225</span> * @throws Exception When running the job fails.<a name="line.225"></a> -<span class="sourceLineNo">226</span> */<a name="line.226"></a> -<span class="sourceLineNo">227</span> public static void main(String[] args) throws Exception {<a name="line.227"></a> -<span class="sourceLineNo">228</span> int errCode = ToolRunner.run(HBaseConfiguration.create(), new RowCounter(), args);<a name="line.228"></a> -<span class="sourceLineNo">229</span> System.exit(errCode);<a name="line.229"></a> -<span class="sourceLineNo">230</span> }<a name="line.230"></a> -<span class="sourceLineNo">231</span><a name="line.231"></a> -<span class="sourceLineNo">232</span>}<a name="line.232"></a> +<span class="sourceLineNo">121</span> continue;<a name="line.121"></a> +<span class="sourceLineNo">122</span> }<a name="line.122"></a> +<span class="sourceLineNo">123</span> if (args[i].startsWith(startTimeArgKey)) {<a name="line.123"></a> +<span class="sourceLineNo">124</span> startTime = Long.parseLong(args[i].substring(startTimeArgKey.length()));<a name="line.124"></a> +<span class="sourceLineNo">125</span> continue;<a name="line.125"></a> +<span class="sourceLineNo">126</span> }<a name="line.126"></a> +<span class="sourceLineNo">127</span> if (args[i].startsWith(endTimeArgKey)) {<a name="line.127"></a> +<span class="sourceLineNo">128</span> endTime = Long.parseLong(args[i].substring(endTimeArgKey.length()));<a name="line.128"></a> +<span class="sourceLineNo">129</span> continue;<a name="line.129"></a> +<span class="sourceLineNo">130</span> }<a name="line.130"></a> +<span class="sourceLineNo">131</span> if (args[i].startsWith(expectedCountArg)) {<a name="line.131"></a> +<span class="sourceLineNo">132</span> conf.setLong(EXPECTED_COUNT_KEY,<a name="line.132"></a> +<span class="sourceLineNo">133</span> Long.parseLong(args[i].substring(expectedCountArg.length())));<a name="line.133"></a> +<span class="sourceLineNo">134</span> continue;<a name="line.134"></a> +<span class="sourceLineNo">135</span> }<a name="line.135"></a> +<span class="sourceLineNo">136</span> // if no switch, assume column names<a name="line.136"></a> +<span class="sourceLineNo">137</span> sb.append(args[i]);<a name="line.137"></a> +<span class="sourceLineNo">138</span> sb.append(" ");<a name="line.138"></a> +<span class="sourceLineNo">139</span> }<a name="line.139"></a> +<span class="sourceLineNo">140</span> if (endTime < startTime) {<a name="line.140"></a> +<span class="sourceLineNo">141</span> printUsage("--endtime=" + endTime + " needs to be greater than --starttime=" + startTime);<a name="line.141"></a> +<span class="sourceLineNo">142</span> return null;<a name="line.142"></a> +<span class="sourceLineNo">143</span> }<a name="line.143"></a> +<span class="sourceLineNo">144</span><a name="line.144"></a> +<span class="sourceLineNo">145</span> Job job = Job.getInstance(conf, conf.get(JOB_NAME_CONF_KEY, NAME + "_" + tableName));<a name="line.145"></a> +<span class="sourceLineNo">146</span> job.setJarByClass(RowCounter.class);<a name="line.146"></a> +<span class="sourceLineNo">147</span> Scan scan = new Scan();<a name="line.147"></a> +<span class="sourceLineNo">148</span> scan.setCacheBlocks(false);<a name="line.148"></a> +<span class="sourceLineNo">149</span> if (startKey != null && !startKey.equals("")) {<a name="line.149"></a> +<span class="sourceLineNo">150</span> scan.setStartRow(Bytes.toBytes(startKey));<a name="line.150"></a> +<span class="sourceLineNo">151</span> }<a name="line.151"></a> +<span class="sourceLineNo">152</span> if (endKey != null && !endKey.equals("")) {<a name="line.152"></a> +<span class="sourceLineNo">153</span> scan.setStopRow(Bytes.toBytes(endKey));<a name="line.153"></a> +<span class="sourceLineNo">154</span> }<a name="line.154"></a> +<span class="sourceLineNo">155</span> if (sb.length() > 0) {<a name="line.155"></a> +<span class="sourceLineNo">156</span> for (String columnName : sb.toString().trim().split(" ")) {<a name="line.156"></a> +<span class="sourceLineNo">157</span> String family = StringUtils.substringBefore(columnName, ":");<a name="line.157"></a> +<span class="sourceLineNo">158</span> String qualifier = StringUtils.substringAfter(columnName, ":");<a name="line.158"></a> +<span class="sourceLineNo">159</span><a name="line.159"></a> +<span class="sourceLineNo">160</span> if (StringUtils.isBlank(qualifier)) {<a name="line.160"></a> +<span class="sourceLineNo">161</span> scan.addFamily(Bytes.toBytes(family));<a name="line.161"></a> +<span class="sourceLineNo">162</span> }<a name="line.162"></a> +<span class="sourceLineNo">163</span> else {<a name="line.163"></a> +<span class="sourceLineNo">164</span> scan.addColumn(Bytes.toBytes(family), Bytes.toBytes(qualifier));<a name="line.164"></a> +<span class="sourceLineNo">165</span> }<a name="line.165"></a> +<span class="sourceLineNo">166</span> }<a name="line.166"></a> +<span class="sourceLineNo">167</span> }<a name="line.167"></a> +<span class="sourceLineNo">168</span> scan.setFilter(new FirstKeyOnlyFilter());<a name="line.168"></a> +<span class="sourceLineNo">169</span> scan.setTimeRange(startTime, endTime == 0 ? HConstants.LATEST_TIMESTAMP : endTime);<a name="line.169"></a> +<span class="sourceLineNo">170</span> job.setOutputFormatClass(NullOutputFormat.class);<a name="line.170"></a> +<span class="sourceLineNo">171</span> TableMapReduceUtil.initTableMapperJob(tableName, scan,<a name="line.171"></a> +<span class="sourceLineNo">172</span> RowCounterMapper.class, ImmutableBytesWritable.class, Result.class, job);<a name="line.172"></a> +<span class="sourceLineNo">173</span> job.setNumReduceTasks(0);<a name="line.173"></a> +<span class="sourceLineNo">174</span> return job;<a name="line.174"></a> +<span class="sourceLineNo">175</span> }<a name="line.175"></a> +<span class="sourceLineNo">176</span><a name="line.176"></a> +<span class="sourceLineNo">177</span> /*<a name="line.177"></a> +<span class="sourceLineNo">178</span> * @param errorMessage Can attach a message when error occurs.<a name="line.178"></a> +<span class="sourceLineNo">179</span> */<a name="line.179"></a> +<span class="sourceLineNo">180</span> private static void printUsage(String errorMessage) {<a name="line.180"></a> +<span class="sourceLineNo">181</span> System.err.println("ERROR: " + errorMessage);<a name="line.181"></a> +<span class="sourceLineNo">182</span> printUsage();<a name="line.182"></a> +<span class="sourceLineNo">183</span> }<a name="line.183"></a> +<span class="sourceLineNo">184</span><a name="line.184"></a> +<span class="sourceLineNo">185</span> /**<a name="line.185"></a> +<span class="sourceLineNo">186</span> * Prints usage without error message.<a name="line.186"></a> +<span class="sourceLineNo">187</span> * Note that we don't document --expected-count, because it's intended for test.<a name="line.187"></a> +<span class="sourceLineNo">188</span> */<a name="line.188"></a> +<span class="sourceLineNo">189</span> private static void printUsage() {<a name="line.189"></a> +<span class="sourceLineNo">190</span> System.err.println("Usage: RowCounter [options] <tablename> " +<a name="line.190"></a> +<span class="sourceLineNo">191</span> "[--starttime=[start] --endtime=[end] " +<a name="line.191"></a> +<span class="sourceLineNo">192</span> "[--range=[startKey],[endKey]] [<column1> <column2>...]");<a name="line.192"></a> +<span class="sourceLineNo">193</span> System.err.println("For performance consider the following options:\n"<a name="line.193"></a> +<span class="sourceLineNo">194</span> + "-Dhbase.client.scanner.caching=100\n"<a name="line.194"></a> +<span class="sourceLineNo">195</span> + "-Dmapreduce.map.speculative=false");<a name="line.195"></a> +<span class="sourceLineNo">196</span> }<a name="line.196"></a> +<span class="sourceLineNo">197</span><a name="line.197"></a> +<span class="sourceLineNo">198</span> @Override<a name="line.198"></a> +<span class="sourceLineNo">199</span> public int run(String[] args) throws Exception {<a name="line.199"></a> +<span class="sourceLineNo">200</span> if (args.length < 1) {<a name="line.200"></a> +<span class="sourceLineNo">201</span> printUsage("Wrong number of parameters: " + args.length);<a name="line.201"></a> +<span class="sourceLineNo">202</span> return -1;<a name="line.202"></a> +<span class="sourceLineNo">203</span> }<a name="line.203"></a> +<span class="sourceLineNo">204</span> Job job = createSubmittableJob(getConf(), args);<a name="line.204"></a> +<span class="sourceLineNo">205</span> if (job == null) {<a name="line.205"></a> +<span class="sourceLineNo">206</span> return -1;<a name="line.206"></a> +<span class="sourceLineNo">207</span> }<a name="line.207"></a> +<span class="sourceLineNo">208</span> boolean success = job.waitForCompletion(true);<a name="line.208"></a> +<span class="sourceLineNo">209</span> final long expectedCount = getConf().getLong(EXPECTED_COUNT_KEY, -1);<a name="line.209"></a> +<span class="sourceLineNo">210</span> if (success && expectedCount != -1) {<a name="line.210"></a> +<span class="sourceLineNo">211</span> final Counter counter = job.getCounters().findCounter(RowCounterMapper.Counters.ROWS);<a name="line.211"></a> +<span class="sourceLineNo">212</span> success = expectedCount == counter.getValue();<a name="line.212"></a> +<span class="sourceLineNo">213</span> if (!success) {<a name="line.213"></a> +<span class="sourceLineNo">214</span> LOG.error("Failing job because count of '" + counter.getValue() +<a name="line.214"></a> +<span class="sourceLineNo">215</span> "' does not match expected count of '" + expectedCount + "'");<a name="line.215"></a> +<span class="sourceLineNo">216</span> }<a name="line.216"></a> +<span class="sourceLineNo">217</span> }<a name="line.217"></a> +<span class="sourceLineNo">218</span> return (success ? 0 : 1);<a name="line.218"></a> +<span class="sourceLineNo">219</span> }<a name="line.219"></a> +<span class="sourceLineNo">220</span><a name="line.220"></a> +<span class="sourceLineNo">221</span> /**<a name="line.221"></a> +<span class="sourceLineNo">222</span> * Main entry point.<a name="line.222"></a> +<span class="sourceLineNo">223</span> * @param args The command line parameters.<a name="line.223"></a> +<span class="sourceLineNo">224</span> * @throws Exception When running the job fails.<a name="line.224"></a> +<span class="sourceLineNo">225</span> */<a name="line.225"></a> +<span class="sourceLineNo">226</span> public static void main(String[] args) throws Exception {<a name="line.226"></a> +<span class="sourceLineNo">227</span> int errCode = ToolRunner.run(HBaseConfiguration.create(), new RowCounter(), args);<a name="line.227"></a> +<span class="sourceLineNo">228</span> System.exit(errCode);<a name="line.228"></a> +<span class="sourceLineNo">229</span> }<a name="line.229"></a> +<span class="sourceLineNo">230</span><a name="line.230"></a> +<span class="sourceLineNo">231</span>}<a name="line.231"></a>
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/670bf1f0/devapidocs/src-html/org/apache/hadoop/hbase/mapreduce/RowCounter.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/mapreduce/RowCounter.html b/devapidocs/src-html/org/apache/hadoop/hbase/mapreduce/RowCounter.html index 571c70a..c037057 100644 --- a/devapidocs/src-html/org/apache/hadoop/hbase/mapreduce/RowCounter.html +++ b/devapidocs/src-html/org/apache/hadoop/hbase/mapreduce/RowCounter.html @@ -126,118 +126,117 @@ <span class="sourceLineNo">118</span> }<a name="line.118"></a> <span class="sourceLineNo">119</span> startKey = startEnd[0];<a name="line.119"></a> <span class="sourceLineNo">120</span> endKey = startEnd[1];<a name="line.120"></a> -<span class="sourceLineNo">121</span> }<a name="line.121"></a> -<span class="sourceLineNo">122</span> if (startTime < endTime) {<a name="line.122"></a> -<span class="sourceLineNo">123</span> printUsage("--endtime=" + endTime + " needs to be greater than --starttime=" + startTime);<a name="line.123"></a> -<span class="sourceLineNo">124</span> return null;<a name="line.124"></a> -<span class="sourceLineNo">125</span> }<a name="line.125"></a> -<span class="sourceLineNo">126</span> if (args[i].startsWith(startTimeArgKey)) {<a name="line.126"></a> -<span class="sourceLineNo">127</span> startTime = Long.parseLong(args[i].substring(startTimeArgKey.length()));<a name="line.127"></a> -<span class="sourceLineNo">128</span> continue;<a name="line.128"></a> -<span class="sourceLineNo">129</span> }<a name="line.129"></a> -<span class="sourceLineNo">130</span> if (args[i].startsWith(endTimeArgKey)) {<a name="line.130"></a> -<span class="sourceLineNo">131</span> endTime = Long.parseLong(args[i].substring(endTimeArgKey.length()));<a name="line.131"></a> -<span class="sourceLineNo">132</span> continue;<a name="line.132"></a> -<span class="sourceLineNo">133</span> }<a name="line.133"></a> -<span class="sourceLineNo">134</span> if (args[i].startsWith(expectedCountArg)) {<a name="line.134"></a> -<span class="sourceLineNo">135</span> conf.setLong(EXPECTED_COUNT_KEY,<a name="line.135"></a> -<span class="sourceLineNo">136</span> Long.parseLong(args[i].substring(expectedCountArg.length())));<a name="line.136"></a> -<span class="sourceLineNo">137</span> continue;<a name="line.137"></a> -<span class="sourceLineNo">138</span> }<a name="line.138"></a> -<span class="sourceLineNo">139</span> else {<a name="line.139"></a> -<span class="sourceLineNo">140</span> // if no switch, assume column names<a name="line.140"></a> -<span class="sourceLineNo">141</span> sb.append(args[i]);<a name="line.141"></a> -<span class="sourceLineNo">142</span> sb.append(" ");<a name="line.142"></a> -<span class="sourceLineNo">143</span> }<a name="line.143"></a> -<span class="sourceLineNo">144</span> }<a name="line.144"></a> -<span class="sourceLineNo">145</span><a name="line.145"></a> -<span class="sourceLineNo">146</span> Job job = Job.getInstance(conf, conf.get(JOB_NAME_CONF_KEY, NAME + "_" + tableName));<a name="line.146"></a> -<span class="sourceLineNo">147</span> job.setJarByClass(RowCounter.class);<a name="line.147"></a> -<span class="sourceLineNo">148</span> Scan scan = new Scan();<a name="line.148"></a> -<span class="sourceLineNo">149</span> scan.setCacheBlocks(false);<a name="line.149"></a> -<span class="sourceLineNo">150</span> if (startKey != null && !startKey.equals("")) {<a name="line.150"></a> -<span class="sourceLineNo">151</span> scan.setStartRow(Bytes.toBytes(startKey));<a name="line.151"></a> -<span class="sourceLineNo">152</span> }<a name="line.152"></a> -<span class="sourceLineNo">153</span> if (endKey != null && !endKey.equals("")) {<a name="line.153"></a> -<span class="sourceLineNo">154</span> scan.setStopRow(Bytes.toBytes(endKey));<a name="line.154"></a> -<span class="sourceLineNo">155</span> }<a name="line.155"></a> -<span class="sourceLineNo">156</span> if (sb.length() > 0) {<a name="line.156"></a> -<span class="sourceLineNo">157</span> for (String columnName : sb.toString().trim().split(" ")) {<a name="line.157"></a> -<span class="sourceLineNo">158</span> String family = StringUtils.substringBefore(columnName, ":");<a name="line.158"></a> -<span class="sourceLineNo">159</span> String qualifier = StringUtils.substringAfter(columnName, ":");<a name="line.159"></a> -<span class="sourceLineNo">160</span><a name="line.160"></a> -<span class="sourceLineNo">161</span> if (StringUtils.isBlank(qualifier)) {<a name="line.161"></a> -<span class="sourceLineNo">162</span> scan.addFamily(Bytes.toBytes(family));<a name="line.162"></a> -<span class="sourceLineNo">163</span> }<a name="line.163"></a> -<span class="sourceLineNo">164</span> else {<a name="line.164"></a> -<span class="sourceLineNo">165</span> scan.addColumn(Bytes.toBytes(family), Bytes.toBytes(qualifier));<a name="line.165"></a> -<span class="sourceLineNo">166</span> }<a name="line.166"></a> -<span class="sourceLineNo">167</span> }<a name="line.167"></a> -<span class="sourceLineNo">168</span> }<a name="line.168"></a> -<span class="sourceLineNo">169</span> scan.setFilter(new FirstKeyOnlyFilter());<a name="line.169"></a> -<span class="sourceLineNo">170</span> scan.setTimeRange(startTime, endTime == 0 ? HConstants.LATEST_TIMESTAMP : endTime);<a name="line.170"></a> -<span class="sourceLineNo">171</span> job.setOutputFormatClass(NullOutputFormat.class);<a name="line.171"></a> -<span class="sourceLineNo">172</span> TableMapReduceUtil.initTableMapperJob(tableName, scan,<a name="line.172"></a> -<span class="sourceLineNo">173</span> RowCounterMapper.class, ImmutableBytesWritable.class, Result.class, job);<a name="line.173"></a> -<span class="sourceLineNo">174</span> job.setNumReduceTasks(0);<a name="line.174"></a> -<span class="sourceLineNo">175</span> return job;<a name="line.175"></a> -<span class="sourceLineNo">176</span> }<a name="line.176"></a> -<span class="sourceLineNo">177</span><a name="line.177"></a> -<span class="sourceLineNo">178</span> /*<a name="line.178"></a> -<span class="sourceLineNo">179</span> * @param errorMessage Can attach a message when error occurs.<a name="line.179"></a> -<span class="sourceLineNo">180</span> */<a name="line.180"></a> -<span class="sourceLineNo">181</span> private static void printUsage(String errorMessage) {<a name="line.181"></a> -<span class="sourceLineNo">182</span> System.err.println("ERROR: " + errorMessage);<a name="line.182"></a> -<span class="sourceLineNo">183</span> printUsage();<a name="line.183"></a> -<span class="sourceLineNo">184</span> }<a name="line.184"></a> -<span class="sourceLineNo">185</span><a name="line.185"></a> -<span class="sourceLineNo">186</span> /**<a name="line.186"></a> -<span class="sourceLineNo">187</span> * Prints usage without error message.<a name="line.187"></a> -<span class="sourceLineNo">188</span> * Note that we don't document --expected-count, because it's intended for test.<a name="line.188"></a> -<span class="sourceLineNo">189</span> */<a name="line.189"></a> -<span class="sourceLineNo">190</span> private static void printUsage() {<a name="line.190"></a> -<span class="sourceLineNo">191</span> System.err.println("Usage: RowCounter [options] <tablename> " +<a name="line.191"></a> -<span class="sourceLineNo">192</span> "[--starttime=[start] --endtime=[end] " +<a name="line.192"></a> -<span class="sourceLineNo">193</span> "[--range=[startKey],[endKey]] [<column1> <column2>...]");<a name="line.193"></a> -<span class="sourceLineNo">194</span> System.err.println("For performance consider the following options:\n"<a name="line.194"></a> -<span class="sourceLineNo">195</span> + "-Dhbase.client.scanner.caching=100\n"<a name="line.195"></a> -<span class="sourceLineNo">196</span> + "-Dmapreduce.map.speculative=false");<a name="line.196"></a> -<span class="sourceLineNo">197</span> }<a name="line.197"></a> -<span class="sourceLineNo">198</span><a name="line.198"></a> -<span class="sourceLineNo">199</span> @Override<a name="line.199"></a> -<span class="sourceLineNo">200</span> public int run(String[] args) throws Exception {<a name="line.200"></a> -<span class="sourceLineNo">201</span> if (args.length < 1) {<a name="line.201"></a> -<span class="sourceLineNo">202</span> printUsage("Wrong number of parameters: " + args.length);<a name="line.202"></a> -<span class="sourceLineNo">203</span> return -1;<a name="line.203"></a> -<span class="sourceLineNo">204</span> }<a name="line.204"></a> -<span class="sourceLineNo">205</span> Job job = createSubmittableJob(getConf(), args);<a name="line.205"></a> -<span class="sourceLineNo">206</span> if (job == null) {<a name="line.206"></a> -<span class="sourceLineNo">207</span> return -1;<a name="line.207"></a> -<span class="sourceLineNo">208</span> }<a name="line.208"></a> -<span class="sourceLineNo">209</span> boolean success = job.waitForCompletion(true);<a name="line.209"></a> -<span class="sourceLineNo">210</span> final long expectedCount = getConf().getLong(EXPECTED_COUNT_KEY, -1);<a name="line.210"></a> -<span class="sourceLineNo">211</span> if (success && expectedCount != -1) {<a name="line.211"></a> -<span class="sourceLineNo">212</span> final Counter counter = job.getCounters().findCounter(RowCounterMapper.Counters.ROWS);<a name="line.212"></a> -<span class="sourceLineNo">213</span> success = expectedCount == counter.getValue();<a name="line.213"></a> -<span class="sourceLineNo">214</span> if (!success) {<a name="line.214"></a> -<span class="sourceLineNo">215</span> LOG.error("Failing job because count of '" + counter.getValue() +<a name="line.215"></a> -<span class="sourceLineNo">216</span> "' does not match expected count of '" + expectedCount + "'");<a name="line.216"></a> -<span class="sourceLineNo">217</span> }<a name="line.217"></a> -<span class="sourceLineNo">218</span> }<a name="line.218"></a> -<span class="sourceLineNo">219</span> return (success ? 0 : 1);<a name="line.219"></a> -<span class="sourceLineNo">220</span> }<a name="line.220"></a> -<span class="sourceLineNo">221</span><a name="line.221"></a> -<span class="sourceLineNo">222</span> /**<a name="line.222"></a> -<span class="sourceLineNo">223</span> * Main entry point.<a name="line.223"></a> -<span class="sourceLineNo">224</span> * @param args The command line parameters.<a name="line.224"></a> -<span class="sourceLineNo">225</span> * @throws Exception When running the job fails.<a name="line.225"></a> -<span class="sourceLineNo">226</span> */<a name="line.226"></a> -<span class="sourceLineNo">227</span> public static void main(String[] args) throws Exception {<a name="line.227"></a> -<span class="sourceLineNo">228</span> int errCode = ToolRunner.run(HBaseConfiguration.create(), new RowCounter(), args);<a name="line.228"></a> -<span class="sourceLineNo">229</span> System.exit(errCode);<a name="line.229"></a> -<span class="sourceLineNo">230</span> }<a name="line.230"></a> -<span class="sourceLineNo">231</span><a name="line.231"></a> -<span class="sourceLineNo">232</span>}<a name="line.232"></a> +<span class="sourceLineNo">121</span> continue;<a name="line.121"></a> +<span class="sourceLineNo">122</span> }<a name="line.122"></a> +<span class="sourceLineNo">123</span> if (args[i].startsWith(startTimeArgKey)) {<a name="line.123"></a> +<span class="sourceLineNo">124</span> startTime = Long.parseLong(args[i].substring(startTimeArgKey.length()));<a name="line.124"></a> +<span class="sourceLineNo">125</span> continue;<a name="line.125"></a> +<span class="sourceLineNo">126</span> }<a name="line.126"></a> +<span class="sourceLineNo">127</span> if (args[i].startsWith(endTimeArgKey)) {<a name="line.127"></a> +<span class="sourceLineNo">128</span> endTime = Long.parseLong(args[i].substring(endTimeArgKey.length()));<a name="line.128"></a> +<span class="sourceLineNo">129</span> continue;<a name="line.129"></a> +<span class="sourceLineNo">130</span> }<a name="line.130"></a> +<span class="sourceLineNo">131</span> if (args[i].startsWith(expectedCountArg)) {<a name="line.131"></a> +<span class="sourceLineNo">132</span> conf.setLong(EXPECTED_COUNT_KEY,<a name="line.132"></a> +<span class="sourceLineNo">133</span> Long.parseLong(args[i].substring(expectedCountArg.length())));<a name="line.133"></a> +<span class="sourceLineNo">134</span> continue;<a name="line.134"></a> +<span class="sourceLineNo">135</span> }<a name="line.135"></a> +<span class="sourceLineNo">136</span> // if no switch, assume column names<a name="line.136"></a> +<span class="sourceLineNo">137</span> sb.append(args[i]);<a name="line.137"></a> +<span class="sourceLineNo">138</span> sb.append(" ");<a name="line.138"></a> +<span class="sourceLineNo">139</span> }<a name="line.139"></a> +<span class="sourceLineNo">140</span> if (endTime < startTime) {<a name="line.140"></a> +<span class="sourceLineNo">141</span> printUsage("--endtime=" + endTime + " needs to be greater than --starttime=" + startTime);<a name="line.141"></a> +<span class="sourceLineNo">142</span> return null;<a name="line.142"></a> +<span class="sourceLineNo">143</span> }<a name="line.143"></a> +<span class="sourceLineNo">144</span><a name="line.144"></a> +<span class="sourceLineNo">145</span> Job job = Job.getInstance(conf, conf.get(JOB_NAME_CONF_KEY, NAME + "_" + tableName));<a name="line.145"></a> +<span class="sourceLineNo">146</span> job.setJarByClass(RowCounter.class);<a name="line.146"></a> +<span class="sourceLineNo">147</span> Scan scan = new Scan();<a name="line.147"></a> +<span class="sourceLineNo">148</span> scan.setCacheBlocks(false);<a name="line.148"></a> +<span class="sourceLineNo">149</span> if (startKey != null && !startKey.equals("")) {<a name="line.149"></a> +<span class="sourceLineNo">150</span> scan.setStartRow(Bytes.toBytes(startKey));<a name="line.150"></a> +<span class="sourceLineNo">151</span> }<a name="line.151"></a> +<span class="sourceLineNo">152</span> if (endKey != null && !endKey.equals("")) {<a name="line.152"></a> +<span class="sourceLineNo">153</span> scan.setStopRow(Bytes.toBytes(endKey));<a name="line.153"></a> +<span class="sourceLineNo">154</span> }<a name="line.154"></a> +<span class="sourceLineNo">155</span> if (sb.length() > 0) {<a name="line.155"></a> +<span class="sourceLineNo">156</span> for (String columnName : sb.toString().trim().split(" ")) {<a name="line.156"></a> +<span class="sourceLineNo">157</span> String family = StringUtils.substringBefore(columnName, ":");<a name="line.157"></a> +<span class="sourceLineNo">158</span> String qualifier = StringUtils.substringAfter(columnName, ":");<a name="line.158"></a> +<span class="sourceLineNo">159</span><a name="line.159"></a> +<span class="sourceLineNo">160</span> if (StringUtils.isBlank(qualifier)) {<a name="line.160"></a> +<span class="sourceLineNo">161</span> scan.addFamily(Bytes.toBytes(family));<a name="line.161"></a> +<span class="sourceLineNo">162</span> }<a name="line.162"></a> +<span class="sourceLineNo">163</span> else {<a name="line.163"></a> +<span class="sourceLineNo">164</span> scan.addColumn(Bytes.toBytes(family), Bytes.toBytes(qualifier));<a name="line.164"></a> +<span class="sourceLineNo">165</span> }<a name="line.165"></a> +<span class="sourceLineNo">166</span> }<a name="line.166"></a> +<span class="sourceLineNo">167</span> }<a name="line.167"></a> +<span class="sourceLineNo">168</span> scan.setFilter(new FirstKeyOnlyFilter());<a name="line.168"></a> +<span class="sourceLineNo">169</span> scan.setTimeRange(startTime, endTime == 0 ? HConstants.LATEST_TIMESTAMP : endTime);<a name="line.169"></a> +<span class="sourceLineNo">170</span> job.setOutputFormatClass(NullOutputFormat.class);<a name="line.170"></a> +<span class="sourceLineNo">171</span> TableMapReduceUtil.initTableMapperJob(tableName, scan,<a name="line.171"></a> +<span class="sourceLineNo">172</span> RowCounterMapper.class, ImmutableBytesWritable.class, Result.class, job);<a name="line.172"></a> +<span class="sourceLineNo">173</span> job.setNumReduceTasks(0);<a name="line.173"></a> +<span class="sourceLineNo">174</span> return job;<a name="line.174"></a> +<span class="sourceLineNo">175</span> }<a name="line.175"></a> +<span class="sourceLineNo">176</span><a name="line.176"></a> +<span class="sourceLineNo">177</span> /*<a name="line.177"></a> +<span class="sourceLineNo">178</span> * @param errorMessage Can attach a message when error occurs.<a name="line.178"></a> +<span class="sourceLineNo">179</span> */<a name="line.179"></a> +<span class="sourceLineNo">180</span> private static void printUsage(String errorMessage) {<a name="line.180"></a> +<span class="sourceLineNo">181</span> System.err.println("ERROR: " + errorMessage);<a name="line.181"></a> +<span class="sourceLineNo">182</span> printUsage();<a name="line.182"></a> +<span class="sourceLineNo">183</span> }<a name="line.183"></a> +<span class="sourceLineNo">184</span><a name="line.184"></a> +<span class="sourceLineNo">185</span> /**<a name="line.185"></a> +<span class="sourceLineNo">186</span> * Prints usage without error message.<a name="line.186"></a> +<span class="sourceLineNo">187</span> * Note that we don't document --expected-count, because it's intended for test.<a name="line.187"></a> +<span class="sourceLineNo">188</span> */<a name="line.188"></a> +<span class="sourceLineNo">189</span> private static void printUsage() {<a name="line.189"></a> +<span class="sourceLineNo">190</span> System.err.println("Usage: RowCounter [options] <tablename> " +<a name="line.190"></a> +<span class="sourceLineNo">191</span> "[--starttime=[start] --endtime=[end] " +<a name="line.191"></a> +<span class="sourceLineNo">192</span> "[--range=[startKey],[endKey]] [<column1> <column2>...]");<a name="line.192"></a> +<span class="sourceLineNo">193</span> System.err.println("For performance consider the following options:\n"<a name="line.193"></a> +<span class="sourceLineNo">194</span> + "-Dhbase.client.scanner.caching=100\n"<a name="line.194"></a> +<span class="sourceLineNo">195</span> + "-Dmapreduce.map.speculative=false");<a name="line.195"></a> +<span class="sourceLineNo">196</span> }<a name="line.196"></a> +<span class="sourceLineNo">197</span><a name="line.197"></a> +<span class="sourceLineNo">198</span> @Override<a name="line.198"></a> +<span class="sourceLineNo">199</span> public int run(String[] args) throws Exception {<a name="line.199"></a> +<span class="sourceLineNo">200</span> if (args.length < 1) {<a name="line.200"></a> +<span class="sourceLineNo">201</span> printUsage("Wrong number of parameters: " + args.length);<a name="line.201"></a> +<span class="sourceLineNo">202</span> return -1;<a name="line.202"></a> +<span class="sourceLineNo">203</span> }<a name="line.203"></a> +<span class="sourceLineNo">204</span> Job job = createSubmittableJob(getConf(), args);<a name="line.204"></a> +<span class="sourceLineNo">205</span> if (job == null) {<a name="line.205"></a> +<span class="sourceLineNo">206</span> return -1;<a name="line.206"></a> +<span class="sourceLineNo">207</span> }<a name="line.207"></a> +<span class="sourceLineNo">208</span> boolean success = job.waitForCompletion(true);<a name="line.208"></a> +<span class="sourceLineNo">209</span> final long expectedCount = getConf().getLong(EXPECTED_COUNT_KEY, -1);<a name="line.209"></a> +<span class="sourceLineNo">210</span> if (success && expectedCount != -1) {<a name="line.210"></a> +<span class="sourceLineNo">211</span> final Counter counter = job.getCounters().findCounter(RowCounterMapper.Counters.ROWS);<a name="line.211"></a> +<span class="sourceLineNo">212</span> success = expectedCount == counter.getValue();<a name="line.212"></a> +<span class="sourceLineNo">213</span> if (!success) {<a name="line.213"></a> +<span class="sourceLineNo">214</span> LOG.error("Failing job because count of '" + counter.getValue() +<a name="line.214"></a> +<span class="sourceLineNo">215</span> "' does not match expected count of '" + expectedCount + "'");<a name="line.215"></a> +<span class="sourceLineNo">216</span> }<a name="line.216"></a> +<span class="sourceLineNo">217</span> }<a name="line.217"></a> +<span class="sourceLineNo">218</span> return (success ? 0 : 1);<a name="line.218"></a> +<span class="sourceLineNo">219</span> }<a name="line.219"></a> +<span class="sourceLineNo">220</span><a name="line.220"></a> +<span class="sourceLineNo">221</span> /**<a name="line.221"></a> +<span class="sourceLineNo">222</span> * Main entry point.<a name="line.222"></a> +<span class="sourceLineNo">223</span> * @param args The command line parameters.<a name="line.223"></a> +<span class="sourceLineNo">224</span> * @throws Exception When running the job fails.<a name="line.224"></a> +<span class="sourceLineNo">225</span> */<a name="line.225"></a> +<span class="sourceLineNo">226</span> public static void main(String[] args) throws Exception {<a name="line.226"></a> +<span class="sourceLineNo">227</span> int errCode = ToolRunner.run(HBaseConfiguration.create(), new RowCounter(), args);<a name="line.227"></a> +<span class="sourceLineNo">228</span> System.exit(errCode);<a name="line.228"></a> +<span class="sourceLineNo">229</span> }<a name="line.229"></a> +<span class="sourceLineNo">230</span><a name="line.230"></a> +<span class="sourceLineNo">231</span>}<a name="line.231"></a> http://git-wip-us.apache.org/repos/asf/hbase-site/blob/670bf1f0/devapidocs/src-html/org/apache/hadoop/hbase/master/normalizer/SimpleRegionNormalizer.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/master/normalizer/SimpleRegionNormalizer.html b/devapidocs/src-html/org/apache/hadoop/hbase/master/normalizer/SimpleRegionNormalizer.html index fbe1757..85bd1ae 100644 --- a/devapidocs/src-html/org/apache/hadoop/hbase/master/normalizer/SimpleRegionNormalizer.html +++ b/devapidocs/src-html/org/apache/hadoop/hbase/master/normalizer/SimpleRegionNormalizer.html @@ -152,7 +152,7 @@ <span class="sourceLineNo">144</span> // if the region is > 2 times larger than average, we split it, split<a name="line.144"></a> <span class="sourceLineNo">145</span> // is more high priority normalization action than merge.<a name="line.145"></a> <span class="sourceLineNo">146</span> if (regionSize > 2 * avgRegionSize) {<a name="line.146"></a> -<span class="sourceLineNo">147</span> LOG.debug("Table " + table + ", large region " + hri.getRegionNameAsString() + " has size "<a name="line.147"></a> +<span class="sourceLineNo">147</span> LOG.info("Table " + table + ", large region " + hri.getRegionNameAsString() + " has size "<a name="line.147"></a> <span class="sourceLineNo">148</span> + regionSize + ", more than twice avg size, splitting");<a name="line.148"></a> <span class="sourceLineNo">149</span> plans.add(new SplitNormalizationPlan(hri, null));<a name="line.149"></a> <span class="sourceLineNo">150</span> } else {<a name="line.150"></a> @@ -162,7 +162,7 @@ <span class="sourceLineNo">154</span> HRegionInfo hri2 = tableRegions.get(candidateIdx+1);<a name="line.154"></a> <span class="sourceLineNo">155</span> long regionSize2 = getRegionSize(hri2);<a name="line.155"></a> <span class="sourceLineNo">156</span> if (regionSize + regionSize2 < avgRegionSize) {<a name="line.156"></a> -<span class="sourceLineNo">157</span> LOG.debug("Table " + table + ", small region size: " + regionSize<a name="line.157"></a> +<span class="sourceLineNo">157</span> LOG.info("Table " + table + ", small region size: " + regionSize<a name="line.157"></a> <span class="sourceLineNo">158</span> + " plus its neighbor size: " + regionSize2<a name="line.158"></a> <span class="sourceLineNo">159</span> + ", less than the avg size " + avgRegionSize + ", merging them");<a name="line.159"></a> <span class="sourceLineNo">160</span> plans.add(new MergeNormalizationPlan(hri, hri2));<a name="line.160"></a>