├── .gitignore ├── .mvn-compat └── src │ ├── main │ └── java │ │ └── org │ │ └── hbase │ │ └── async │ └── test │ └── java │ └── org │ └── hbase │ └── async ├── AUTHORS ├── COPYING ├── HACKING ├── INSTALL ├── Makefile ├── NEWS ├── README ├── THANKS ├── build-aux └── fetchdep.sh ├── logback.xml ├── pom.xml.in ├── src ├── AtomicIncrementRequest.java ├── BatchableRpc.java ├── BrokenMetaException.java ├── BufferedIncrement.java ├── Bytes.java ├── ClientStats.java ├── ColumnPrefixFilter.java ├── ColumnRangeFilter.java ├── CompareAndSetRequest.java ├── ConnectionResetException.java ├── Counter.java ├── DeleteRequest.java ├── FilterList.java ├── GetRequest.java ├── HBaseClient.java ├── HBaseException.java ├── HBaseRpc.java ├── HasFailedRpcException.java ├── InvalidResponseException.java ├── KeyRegexpFilter.java ├── KeyValue.java ├── MultiAction.java ├── NoSuchColumnFamilyException.java ├── NonRecoverableException.java ├── NotServingRegionException.java ├── PleaseThrottleException.java ├── PutRequest.java ├── RecoverableException.java ├── RegionClient.java ├── RegionInfo.java ├── RegionOfflineException.java ├── RemoteException.java ├── RowLock.java ├── RowLockRequest.java ├── ScanFilter.java ├── Scanner.java ├── SingletonList.java ├── TableNotFoundException.java ├── UnknownRowLockException.java ├── UnknownScannerException.java ├── VersionMismatchException.java └── jsr166e │ ├── LongAdder.java │ ├── README │ ├── Striped64.java │ └── package-info.java ├── test ├── Common.java ├── Test.java ├── TestIncrementCoalescing.java ├── TestIntegration.java ├── TestMETALookup.java └── TestNSREs.java └── third_party ├── .gitignore ├── guava ├── guava-12.0.jar.md5 ├── guava-13.0.1.jar.md5 └── include.mk ├── hamcrest ├── hamcrest-core-1.3.jar.md5 └── include.mk ├── include.mk ├── javassist ├── include.mk ├── javassist-3.15.0-GA.jar.md5 └── javassist-3.17.1-GA.jar.md5 ├── junit ├── include.mk ├── junit-4.10.jar.md5 └── junit-4.11.jar.md5 ├── logback ├── include.mk ├── logback-classic-1.0.0.jar.md5 ├── logback-classic-1.0.9.jar.md5 ├── logback-core-1.0.0.jar.md5 └── logback-core-1.0.9.jar.md5 ├── mockito ├── include.mk ├── mockito-1.8.5.jar.md5 ├── mockito-1.9.0.jar.md5 └── mockito-core-1.9.5.jar.md5 ├── netty ├── include.mk ├── netty-3.5.9.Final.jar.md5 └── netty-3.6.2.Final.jar.md5 ├── objenesis ├── include.mk └── objenesis-1.3.jar.md5 ├── powermock ├── include.mk ├── powermock-mockito-1.4.10.jar.md5 ├── powermock-mockito-1.4.9.jar.md5 └── powermock-mockito-1.5.jar.md5 ├── slf4j ├── include.mk ├── log4j-over-slf4j-1.6.4.jar.md5 ├── log4j-over-slf4j-1.7.2.jar.md5 ├── slf4j-api-1.6.4.jar.md5 └── slf4j-api-1.7.2.jar.md5 ├── suasync ├── include.mk ├── suasync-1.2.0.jar.md5 ├── suasync-1.3.1.jar.md5 └── suasync-1.3.2.jar.md5 └── zookeeper ├── include.mk ├── zookeeper-3.3.4.jar.md5 └── zookeeper-3.3.6.jar.md5 /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | pom.xml 3 | target/ 4 | -------------------------------------------------------------------------------- /.mvn-compat/src/main/java/org/hbase/async: -------------------------------------------------------------------------------- 1 | ../../../../../../src -------------------------------------------------------------------------------- /.mvn-compat/src/test/java/org/hbase/async: -------------------------------------------------------------------------------- 1 | ../../../../../../test -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | The Async HBase Authors 2 | ----------------------- 3 | 4 | Async HBase ("asynchbase") was originally written by Benoit Sigoure. 5 | The following organizations and people have contributed code to Async HBase. 6 | (Please keep both lists sorted alphabetically.) 7 | 8 | 9 | Arista Networks, Inc. 10 | StumbleUpon, Inc. 11 | 12 | 13 | Viral Bajaria 14 | Benoit Sigoure 15 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Copyright (C) 2010-2012 The Async HBase Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | - Redistributions of source code must retain the above copyright notice, 6 | this list of conditions and the following disclaimer. 7 | - Redistributions in binary form must reproduce the above copyright notice, 8 | this list of conditions and the following disclaimer in the documentation 9 | and/or other materials provided with the distribution. 10 | - Neither the name of the StumbleUpon nor the names of its contributors 11 | may be used to endorse or promote products derived from this software 12 | without specific prior written permission. 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 14 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 17 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 23 | POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /HACKING: -------------------------------------------------------------------------------- 1 | Want to contribute? Great! This file will guide you through some of 2 | design decision / ideology you should try to adhere to. 3 | 4 | The basics: 5 | - Know the complexity of your algorithms. When you're calling a 6 | method in another library, make sure you're aware of the its 7 | complexity. Is it O(n2) or O(n log n)? How much memory will it 8 | allocate? For instance, Collections.sort() works in O(n log n) 9 | as expected but it does 3 array copies! So it's O(3n) = O(n) in 10 | space instead of O(1). 11 | - Avoid allocating objects whenever you can. If you can, re-use the 12 | same objects in a loop in order to avoid generating too much garbage 13 | for the GC to collect. Objects that are expected to be used very 14 | frequently should be create once and stored in an attribute. 15 | 16 | The build system: 17 | - No Ant / Ivy / Maven madness. Using XML to specify a build system 18 | is a dumb idea and those tools are way too slow and don't even do 19 | proper dependency tracking out of the box. They don't come with a 20 | set of standard rules that make packaging easy. 21 | - Don't add new dependencies unless you have a compelling reason to do 22 | so. The code of any dependency will be audited before we can allow 23 | this new dependency. 24 | 25 | Code: 26 | - The #1 rule is to write readable code. How much time will it take 27 | for someone else to understand that method? If something is not 28 | obvious, it should be commented. 29 | - Stick to the coding style in the files you're editing. 30 | - Avoid lines longer than 80 characters. There are a few cases where 31 | Java is so verbose that trying to wrap things around to avoid long 32 | lines makes the code unnecessarily hard to read. 33 | - Everything should be properly Javadoc'ed. Everything. Including 34 | private stuff (except maybe 1-line private helper functions). 35 | Document the RuntimeExceptions one should expect to handle. 36 | All javadoc comments are to be written in proper English. 37 | - The javadoc (internal and user-facing) must document the 38 | synchronization requirements. What is thread-safe? Which monitor 39 | needs to be acquired before accessing this attribute? 40 | - No checked exceptions. People should RTFM and handle whatever 41 | exceptions they want to handle. There's a disagreement in the 42 | community about the usefulness and effectiveness of checked 43 | exceptions. I haven't been convinced about the pros so I chose 44 | to not use them. 45 | - Use fine-grained exception types. Everything must derive from 46 | HBaseException. Exceptions should contain all the data required to 47 | help the user code recover from them. HBase's own code is a very 48 | good example of how to not (ab)use IOException. 49 | - Local variables are named_like_this, I think it's more readable 50 | compared to somethingLikeThis. I think there's a reason why latin 51 | languages put a space between words. 52 | 53 | Testing: 54 | - Write unit tests whenever possible, especially regression tests. 55 | - Integration tests need to exercise the functionality against a real 56 | HBase instance. You can run them with this command: 57 | $ HBASE_HOME=~/src/hbase make integration ARGS='test f' 58 | This will run the tests against a set of tables that all have names 59 | starting with `test' and families starting with `f'. The tables will 60 | be created / dropped when needed. 61 | - Tip: After you've run the integration tests once, you can speed up 62 | subsequent runs by passing TEST_NO_TRUNCATE=1 before HBASE_HOME on 63 | the command above. This will skip truncating the table in between 64 | tests, which makes them run much faster. 65 | - Tip: You can also specify only one integration test to run, by adding 66 | the following before HBASE_HOME on the command above: TEST_NAME=XXX. 67 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | Installation Instructions 2 | ************************* 3 | 4 | Copyright (C) 2010-2012 The Async HBase Authors. 5 | 6 | This file is free documentation; StumbleUpon, Inc gives 7 | unlimited permission to copy, distribute and modify it. 8 | 9 | Basic Installation 10 | ================== 11 | 12 | Just type `make', and everything should work as long as you have Java 13 | and GNU make installed in your PATH. On some BSD systems, you may have 14 | to type `gmake' instead. 15 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2010-2012 The Async HBase Authors. All rights reserved. 2 | # This file is part of Async HBase. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are met: 6 | # - Redistributions of source code must retain the above copyright notice, 7 | # this list of conditions and the following disclaimer. 8 | # - Redistributions in binary form must reproduce the above copyright notice, 9 | # this list of conditions and the following disclaimer in the documentation 10 | # and/or other materials provided with the distribution. 11 | # - Neither the name of the StumbleUpon nor the names of its contributors 12 | # may be used to endorse or promote products derived from this software 13 | # without specific prior written permission. 14 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | # POSSIBILITY OF SUCH DAMAGE. 25 | 26 | all: jar $(UNITTESTS) 27 | # TODO(tsuna): Use automake to avoid relying on GNU make extensions. 28 | 29 | include third_party/include.mk 30 | 31 | JAVA := java 32 | PACKAGE_BUGREPORT := opentsdb@googlegroups.com 33 | 34 | top_builddir := build 35 | package := org.hbase.async 36 | spec_title := Asynchronous HBase Client 37 | spec_vendor := The Async HBase Authors 38 | # Semantic Versioning (see http://semver.org/). 39 | spec_version := 1.5.0-SNAPSHOT 40 | jar := $(top_builddir)/asynchbase-$(spec_version).jar 41 | asynchbase_SOURCES := \ 42 | src/AtomicIncrementRequest.java \ 43 | src/BatchableRpc.java \ 44 | src/BrokenMetaException.java \ 45 | src/BufferedIncrement.java \ 46 | src/Bytes.java \ 47 | src/ClientStats.java \ 48 | src/ColumnPrefixFilter.java \ 49 | src/ColumnRangeFilter.java \ 50 | src/CompareAndSetRequest.java \ 51 | src/ConnectionResetException.java \ 52 | src/Counter.java \ 53 | src/DeleteRequest.java \ 54 | src/FilterList.java \ 55 | src/GetRequest.java \ 56 | src/HBaseClient.java \ 57 | src/HBaseException.java \ 58 | src/HBaseRpc.java \ 59 | src/HasFailedRpcException.java \ 60 | src/InvalidResponseException.java \ 61 | src/KeyRegexpFilter.java \ 62 | src/KeyValue.java \ 63 | src/MultiAction.java \ 64 | src/NoSuchColumnFamilyException.java \ 65 | src/NonRecoverableException.java \ 66 | src/NotServingRegionException.java \ 67 | src/PleaseThrottleException.java \ 68 | src/PutRequest.java \ 69 | src/RecoverableException.java \ 70 | src/RegionClient.java \ 71 | src/RegionInfo.java \ 72 | src/RegionOfflineException.java \ 73 | src/RemoteException.java \ 74 | src/RowLock.java \ 75 | src/RowLockRequest.java \ 76 | src/ScanFilter.java \ 77 | src/Scanner.java \ 78 | src/SingletonList.java \ 79 | src/TableNotFoundException.java \ 80 | src/UnknownRowLockException.java \ 81 | src/UnknownScannerException.java \ 82 | src/VersionMismatchException.java \ 83 | src/jsr166e/LongAdder.java \ 84 | src/jsr166e/Striped64.java \ 85 | 86 | asynchbase_LIBADD := \ 87 | $(NETTY) \ 88 | $(SLF4J_API) \ 89 | $(ZOOKEEPER) \ 90 | $(SUASYNC) \ 91 | $(GUAVA) \ 92 | 93 | test_SOURCES := \ 94 | test/Common.java \ 95 | test/Test.java \ 96 | test/TestIncrementCoalescing.java \ 97 | test/TestIntegration.java \ 98 | 99 | unittest_SRC := \ 100 | test/TestMETALookup.java \ 101 | test/TestNSREs.java 102 | 103 | test_LIBADD := \ 104 | $(asynchbase_LIBADD) \ 105 | $(LOG4J_OVER_SLF4J) \ 106 | $(LOGBACK_CLASSIC) \ 107 | $(LOGBACK_CORE) \ 108 | $(JAVASSIST) \ 109 | $(JUNIT) \ 110 | $(HAMCREST) \ 111 | $(MOCKITO) \ 112 | $(OBJENESIS) \ 113 | $(POWERMOCK_MOCKITO) \ 114 | $(jar) 115 | 116 | package_dir := $(subst .,/,$(package)) 117 | AM_JAVACFLAGS := -Xlint 118 | JVM_ARGS := 119 | classes := $(asynchbase_SOURCES:src/%.java=$(top_builddir)/$(package_dir)/%.class) 120 | test_classes := $(test_SOURCES:test/%.java=$(top_builddir)/$(package_dir)/test/%.class) 121 | UNITTESTS := $(unittest_SRC:test/%.java=$(top_builddir)/$(package_dir)/%.class) 122 | 123 | jar: $(jar) 124 | 125 | get_dep_classpath = `echo $(asynchbase_LIBADD) | tr ' ' ':'` 126 | $(top_builddir)/.javac-stamp: $(asynchbase_SOURCES) $(asynchbase_LIBADD) 127 | @mkdir -p $(top_builddir) 128 | javac $(AM_JAVACFLAGS) -cp $(get_dep_classpath) \ 129 | -d $(top_builddir) $(asynchbase_SOURCES) 130 | @touch "$@" 131 | 132 | get_runtime_dep_classpath = `echo $(test_LIBADD) | tr ' ' ':'` 133 | $(test_classes): $(jar) $(test_SOURCES) $(test_LIBADD) 134 | javac $(AM_JAVACFLAGS) -cp $(get_runtime_dep_classpath) \ 135 | -d $(top_builddir) $(test_SOURCES) 136 | $(top_builddir)/.javac-test-stamp: $(jar) $(unittest_SRC) $(test_LIBADD) 137 | javac $(AM_JAVACFLAGS) -cp $(get_runtime_dep_classpath) \ 138 | -d $(top_builddir) $(unittest_SRC) 139 | 140 | classes_with_nested_classes := $(classes:$(top_builddir)/%.class=%*.class) 141 | unittest_classes_with_nested_classes := $(UNITTESTS:$(top_builddir)/%.class=%*.class) 142 | test_classes_with_nested_classes := $(test_classes:$(top_builddir)/%.class=%*.class) 143 | 144 | run: $(test_classes) 145 | @test -n "$(CLASS)" || { echo 'usage: $(MAKE) run CLASS='; exit 1; } 146 | $(JAVA) -ea -esa $(JVM_ARGS) -cp "$(get_runtime_dep_classpath):$(top_builddir)" $(package).test.$(CLASS) $(ARGS) 147 | 148 | cli: 149 | $(MAKE) run CLASS=Test 150 | 151 | integration: 152 | $(MAKE) run CLASS=TestIntegration 153 | 154 | 155 | # Little sed script to make a pretty-ish banner. 156 | BANNER := sed 's/^.*/ & /;h;s/./=/g;p;x;p;x' 157 | check: $(top_builddir)/.javac-test-stamp $(UNITTESTS) 158 | classes=`cd $(top_builddir) && echo $(unittest_classes_with_nested_classes)` \ 159 | && tests=0 && failures=0 \ 160 | && cp="$(get_runtime_dep_classpath):$(top_builddir)" && \ 161 | for i in $$classes; do \ 162 | case $$i in (*[$$]*) continue;; (*/Test*) :;; (*) continue;; esac; \ 163 | case $$i in (*$(TESTS)*) :;; (*) continue;; esac; \ 164 | tests=$$((tests + 1)); \ 165 | echo "Running tests for `basename $$i .class`" | $(BANNER); \ 166 | $(JAVA) -ea -esa $(JVM_ARGS) -cp "$$cp" org.junit.runner.JUnitCore `echo $${i%.class} | tr / .` $(ARGS) \ 167 | || failures=$$((failures + 1)); \ 168 | done; \ 169 | if test "$$failures" -eq 0; then \ 170 | echo "All $$tests tests passed" | $(BANNER); \ 171 | else \ 172 | echo "$$failures out of $$tests failed, please send a report to $(PACKAGE_BUGREPORT)" | $(BANNER); \ 173 | fi 174 | @touch $(top_builddir)/.javac-test-stamp 175 | 176 | pkg_version = \ 177 | `git rev-list --pretty=format:%h HEAD --max-count=1 | sed 1d || echo unknown` 178 | $(top_builddir)/manifest: $(top_builddir)/.javac-stamp .git/HEAD 179 | { echo "Specification-Title: $(spec_title)"; \ 180 | echo "Specification-Version: $(spec_version)"; \ 181 | echo "Specification-Vendor: $(spec_vendor)"; \ 182 | echo "Implementation-Title: $(package)"; \ 183 | echo "Implementation-Version: $(pkg_version)"; \ 184 | echo "Implementation-Vendor: $(spec_vendor)"; } >"$@" 185 | 186 | $(jar): $(top_builddir)/manifest $(top_builddir)/.javac-stamp $(classes) 187 | cd $(top_builddir) && jar cfm `basename $(jar)` manifest $(classes_with_nested_classes) \ 188 | || { rv=$$? && rm -f `basename $(jar)` && exit $$rv; } 189 | # ^^^^^^^^^^^^^^^^^^^^^^^ 190 | # I've seen cases where `jar' exits with an error but leaves a partially built .jar file! 191 | 192 | doc: $(top_builddir)/api/index.html 193 | 194 | JDK_JAVADOC := http://download.oracle.com/javase/6/docs/api 195 | NETTY_JAVADOC := http://docs.jboss.org/netty/3.2/api 196 | SUASYNC_JAVADOC := http://tsunanet.net/~tsuna/async/api 197 | GUAVA_JAVADOC := http://docs.guava-libraries.googlecode.com/git/javadoc 198 | JAVADOCS = $(JDK_JAVADOC) $(NETTY_JAVADOC) $(SUASYNC_JAVADOC) $(GUAVA_JAVADOC) 199 | $(top_builddir)/api/index.html: $(asynchbase_SOURCES) 200 | javadoc -d $(top_builddir)/api -classpath $(get_dep_classpath) \ 201 | `echo $(JAVADOCS) | sed 's/\([^ ]*\)/-link \1/g'` $(asynchbase_SOURCES) \ 202 | `find src -name package-info.java` 203 | 204 | clean: 205 | @rm -f $(top_builddir)/.javac*-stamp 206 | rm -f $(top_builddir)/manifest 207 | cd $(top_builddir) || exit 0 \ 208 | && rm -f $(classes_with_nested_classes) \ 209 | $(unittest_classes_with_nested_classes) \ 210 | $(test_classes_with_nested_classes) \ 211 | *.class 212 | cd $(top_builddir) || exit 0 \ 213 | && test -d $(package_dir) || exit 0 \ 214 | && dir=$(package_dir) \ 215 | && rmdir $(package_dir)/*/ \ 216 | && while test x"$$dir" != x"$${dir%/*}"; do \ 217 | rmdir "$$dir" && dir=$${dir%/*} || break; \ 218 | done \ 219 | && rmdir "$$dir" 220 | 221 | distclean: clean 222 | rm -f $(jar) 223 | rm -rf $(top_builddir)/api target 224 | test ! -d $(top_builddir) || rmdir $(top_builddir) 225 | 226 | pom.xml: pom.xml.in Makefile 227 | { \ 228 | echo ''; \ 229 | sed <$< \ 230 | -e 's/@GUAVA_VERSION@/$(GUAVA_VERSION)/' \ 231 | -e 's/@HAMCREST_VERSION@/$(HAMCREST_VERSION)/' \ 232 | -e 's/@JAVASSIST_VERSION@/$(JAVASSIST_VERSION)/' \ 233 | -e 's/@JCL_OVER_SLF4J_VERSION@/$(JCL_OVER_SLF4J_VERSION)/' \ 234 | -e 's/@JUNIT_VERSION@/$(JUNIT_VERSION)/' \ 235 | -e 's/@LOG4J_OVER_SLF4J_VERSION@/$(LOG4J_OVER_SLF4J_VERSION)/' \ 236 | -e 's/@MOCKITO_VERSION@/$(MOCKITO_VERSION)/' \ 237 | -e 's/@NETTY_VERSION@/$(NETTY_VERSION)/' \ 238 | -e 's/@OBJENESIS_VERSION@/$(OBJENESIS_VERSION)/' \ 239 | -e 's/@POWERMOCK_MOCKITO_VERSION@/$(POWERMOCK_MOCKITO_VERSION)/' \ 240 | -e 's/@SLF4J_API_VERSION@/$(SLF4J_API_VERSION)/' \ 241 | -e 's/@SUASYNC_VERSION@/$(SUASYNC_VERSION)/' \ 242 | -e 's/@ZOOKEEPER_VERSION@/$(ZOOKEEPER_VERSION)/' \ 243 | -e 's/@spec_title@/$(spec_title)/' \ 244 | -e 's/@spec_vendor@/$(spec_vendor)/' \ 245 | -e 's/@spec_version@/$(spec_version)/' \ 246 | ; \ 247 | } >$@-t 248 | mv $@-t $@ 249 | 250 | .PHONY: all jar clean cli distclean doc check run 251 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | AsyncHBase - User visible and noteworthy changes. 2 | This project uses Semantic Versioning (see http://semver.org/). 3 | 4 | * Version 1.5.0 (2013-??-??) [???????] 5 | 6 | New public APIs: 7 | - Scanners can now use a variety of different filters via the new 8 | `ScanFilter' interfaces and its various implementations. 9 | - HBaseRpc now has a `failfast()' and a `setFailfast(boolean)' pair 10 | of methods to allow RPCs to fail as soon as their encounter an 11 | issue out of the ordinary (e.g. not just a `NotSuchRegionException'). 12 | 13 | Noteworthy bug fixes: 14 | - DeleteRequest wasn't honoring its timestamp if one was given (#58). 15 | 16 | 17 | * Version 1.4.1 (2013-02-14) [1cbc303] 18 | 19 | Noteworthy bug fixes: 20 | - Under certain failure modes, especially during RegionServer failures 21 | or regions split, asynchbase could incorrectly discard an RPC instead 22 | of retrying it. This made the client look like it was stuck if the 23 | RPC was a ROOT or META lookup (#1). 24 | - Update all dependencies. Due to new dependencies in Junit and PowerMock, 25 | asynchbase now depends on hamcrest-core and objenesis respectively. 26 | These are test-only dependencies. 27 | - Maven releases are now signed with the GPG key of tsunanet@gmail.com 28 | 29 | 30 | * Version 1.4.0 (2012-11-10) [fae1a04] 31 | 32 | New public APIs: 33 | - Scanners can now scan multiple qualifiers at a time (#35). 34 | - Scanner and GetRequest now enable you to specify how many versions 35 | to read from HBase. 36 | 37 | Noteworthy changes: 38 | - Fixed cases where calling `flush()' or `shutdown()' while the 39 | client is still starting up could cause it to terminate too early 40 | and to not execute all pending/buffered RPCs (#2). 41 | - Fixed an RPC serialization bug when batching whole-row deletes. 42 | See issue #25. 43 | - The Deferred returned by `flush()' now guarantees that buffered 44 | atomic increments have also completed (#38). 45 | - Upgraded to Netty 3.5.9 to avoid an IndexOutOfBoundsException 46 | when deserializing a KeyValue with an empty qualifier or 47 | value, under certain circumstances (#40). 48 | - Fix increment coalescing to prevent overflowing Deferred callback 49 | chains when too many increments pile up for some counter (#40). 50 | - Increment coalescing now also supports negative values as well as 51 | large positive values (previously the limit was 65535). 52 | - Upgraded to suasync 1.3.1 and Netty 3.5.9. 53 | - Added a series of integration tests to help ongoing QA. 54 | 55 | 56 | * Version 1.3.2 (2012-07-10) [2af9f55] 57 | 58 | Noteworthy changes: 59 | - Upgraded to Netty 3.5.2. 60 | - KeyValue now allows a timestamp of 0. 61 | 62 | 63 | * Version 1.3.1 (2012-06-16) [7ea151b] 64 | 65 | - Critical bug fix of issue #27 that makes some keys unusable 66 | given certain region boundaries, in rare circumstances. 67 | - `ensureTableFamilyExists' and `ensureTableExists' are cheaper 68 | as they partially work around HBASE-3170. 69 | 70 | 71 | * Version 1.3.0 (2012-05-06) [bb9168c] 72 | 73 | New public APIs: 74 | - PleaseThrottleException can now give you a Deferred. 75 | - There is now a `Counter' class that provides a highly concurrent 76 | replacement for AtomicLong from jsr166e's LongAdder. 77 | - HBaseClient now has a `bufferAtomicIncrement' method used to 78 | coalesce atomic counter increments. 79 | - A new method, `stats()', provides detailed statistics on the client's 80 | activities (number of calls for various RPCs, number of connections 81 | created, etc.) 82 | - `HBaseClient' has a new `compareAndSet(PutRequests, byte[])' method 83 | for atomic Compare-And-Set (CAS) operation. 84 | - The Scanner has new methods to allow specifying a time range to scan. 85 | - `PutRequest' has extra constructors so as to be able to affect multiple 86 | columns in a row. This is required to be able to atomically CAS more 87 | than one column at a time on a given row. 88 | 89 | Deprecated public APIs: 90 | - In HBaseClient, the methods `rootLookupCount()', 91 | `uncontendedMetaLookupCount()', and `contendedMetaLookupCount()' are 92 | deprecated in favor of the new `stats()' API. These methods will be 93 | removed in the 2.0 release. 94 | 95 | Noteworthy changes: 96 | - Upgraded to Netty 3.4.3, suasync to 1.2.0. 97 | - asynchbase now depends on Google's Guava library (v12.0). 98 | 99 | 100 | * Version 1.2.0 (2012-02-21) [a7ae238] 101 | 102 | Noteworthy changes: 103 | - Add support for HBase 0.92, as the on-wire RPC format underwent 104 | significant changes that aren't compatible with previous versions. 105 | NOTE: HBase never had a release in the 0.91 branch, and as such 106 | this branch isn't fully supported. 107 | - When talking to HBase 0.92, we automatically batch `DeleteRequests' 108 | with `PutRequests'. Note that batching is enabled by default, and 109 | will thus introduce a delay before sending out `DeleteRequests' to 110 | HBase, whereas in earlier versions (or when talking to HBase 0.90 111 | and before) the `DeleteRequests' are sent out immediately. 112 | 113 | New public APIs: 114 | - KeyValue now supports timestamps. 115 | - HBaseClient now accepts a custom socket factory or executor, which can 116 | be used to share an existing thread pool instead of having its own. 117 | - The Netty Timer used by asynchbase is now available through an API, so 118 | that code dependent on asynchbase can re-use the existing Timer thread 119 | instead of having to create its own. 120 | 121 | 122 | * Version 1.1.0 (2011-12-22) [1272a9e] 123 | 124 | Noteworthy changes: 125 | - Add support for CDH3b3's non-standard authentication code. This support 126 | is enabled by specifying the Java system property "org.hbase.async.cdh3b3". 127 | - Add support for HBase 0.90, as on-wire protocol changed in a non-backward 128 | compatible way for the `get' RPC. 129 | - Fix a dumb mistake in the `memcmp()' version that uses an offset and a 130 | length. This function wasn't called either by asynchbase or by OpenTSDB. 131 | - Bytes.pretty() no longer renders control characters like `^X' (which is 132 | similar to what `cat -t' does). Instead they're now rendered like other 133 | non-ASCII characters, using the hex notation `\xXX'. This makes the output 134 | non-ambiguous and pastable into a Python shell. 135 | - HBaseClient.shutdown() could callback too early, while the shutdown 136 | sequence was still running. 137 | - After doing a full-table scan, calling Scanner.close() would trigger an 138 | error as the scanner would attempt to close itself again. 139 | - When disconnecting from a RegionServer, if the socket wasn't getting 140 | closed immediately, a Deferred could get called back twice, which would 141 | trigger an AssertionError. 142 | - DeleteRequest used to delete the last version of a cell, which wasn't the 143 | intended behavior. It has been changed to delete all the previous 144 | versions of a cell. 145 | - Fixed various other race conditions during startup / shutdown that would 146 | generally affect short-lived programs or MapReduce users. 147 | 148 | New public APIs: 149 | - DeleteRequest now has constructors for deleting multiple qualifiers per 150 | row at once and deleting a whole family at once. 151 | - New `qualifiers' method in GetRequest for getting multiple qualifiers per 152 | row at once. 153 | - Add new interfaces nested in `HBaseRpc' to provide public APIs to be able 154 | to introspect the contents of RPCs. 155 | 156 | 157 | * Version 1.0 (2010-11-08) [dafc645] 158 | 159 | Initial beta release (bundled with OpenTSDB): 160 | - Switched from LGPLv3+ to BSD license. 161 | - Fixed many bugs, including incorrect or inefficient error handling, 162 | synchronization bugs (race conditions). 163 | - Shutting down the client now correctly waits until all RPCs in flight 164 | have successfully completed. 165 | - No public API changes. 166 | 167 | 168 | * Version 0.1 (2010-09-08) [d0646bb] 169 | 170 | Initial alpha release: 171 | - Get, Put, Scan, ICV, with row locks and time-based edit buffering. 172 | 173 | ----- 174 | 175 | Copyright (C) 2010-2012 The Async HBase Authors. All rights reserved. 176 | This file is part of Async HBase. 177 | 178 | Redistribution and use in source and binary forms, with or without 179 | modification, are permitted provided that the following conditions are met: 180 | - Redistributions of source code must retain the above copyright notice, 181 | this list of conditions and the following disclaimer. 182 | - Redistributions in binary form must reproduce the above copyright notice, 183 | this list of conditions and the following disclaimer in the documentation 184 | and/or other materials provided with the distribution. 185 | - Neither the name of the StumbleUpon nor the names of its contributors 186 | may be used to endorse or promote products derived from this software 187 | without specific prior written permission. 188 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 189 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 190 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 191 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 192 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 193 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 194 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 195 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 196 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 197 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 198 | POSSIBILITY OF SUCH DAMAGE. 199 | 200 | Local Variables: 201 | mode: outline 202 | End: 203 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | ,--------------------. 2 | | Asynchronous HBase | 3 | `--------------------' 4 | 5 | This is an alternative Java library to use HBase in applications that require 6 | a fully asynchronous, non-blocking, thread-safe, high-performance HBase API. 7 | 8 | This HBase client differs significantly from HBase's client (HTable). 9 | Switching to it is not easy as it requires to rewrite all the code that was 10 | interacting with any HBase API. This pays off in applications that are 11 | asynchronous by nature or that want to use several threads to interact 12 | efficiently with HBase. 13 | 14 | Please read the Javadoc starting from the HBaseClient class. This class 15 | replaces all your HTable instances. Unlike HTable, you should have only 16 | one instance of HBaseClient in your application, regardless of the number 17 | of tables or threads you want to use. The Javadoc also spells out rules 18 | you have to follow in order to use the API properly in a multi-threaded 19 | application. 20 | -------------------------------------------------------------------------------- /THANKS: -------------------------------------------------------------------------------- 1 | Async HBase THANKS File 2 | ----------------------- 3 | 4 | The following persons contributed to the library by reporting problems, 5 | suggesting improvements, submitting patches or proofreading the code. 6 | 7 | Andrey Stepachev 8 | Arthur van Hoff 9 | Berk D. Demir 10 | Guo Sijie 11 | Ishan Chhabra 12 | Jonathan Payne 13 | Michael Rose 14 | Michael Stack 15 | Nicolas Thiébaud 16 | Shrijeet Paliwal 17 | Xun Liu 18 | -------------------------------------------------------------------------------- /build-aux/fetchdep.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (C) 2011-2012 The Async HBase Authors. All rights reserved. 3 | # This file is part of Async HBase. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are met: 7 | # - Redistributions of source code must retain the above copyright notice, 8 | # this list of conditions and the following disclaimer. 9 | # - Redistributions in binary form must reproduce the above copyright notice, 10 | # this list of conditions and the following disclaimer in the documentation 11 | # and/or other materials provided with the distribution. 12 | # - Neither the name of the StumbleUpon nor the names of its contributors 13 | # may be used to endorse or promote products derived from this software 14 | # without specific prior written permission. 15 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | # POSSIBILITY OF SUCH DAMAGE. 26 | 27 | set -e 28 | MKDIR_P="mkdir -p" 29 | for i in md5sum md5 "$MD5"; do 30 | sum=`echo a | $i 2>/dev/null` || continue 31 | case $sum in 32 | (*60b725f10c9c85c70d97880dfe8191b3*) MD5=$i; break;; 33 | (*) :;; # continue 34 | esac 35 | done 36 | test -n "$MD5" || { 37 | echo >&2 "couldn't find a working md5sum command" 38 | exit 1 39 | } 40 | if wget --version >/dev/null 2>&1; then 41 | WGET=wget 42 | elif curl --version >/dev/null 2>&1; then 43 | CURL=curl 44 | else 45 | echo >&2 "couldn't find either curl or wget" 46 | exit 1 47 | fi 48 | srcdir=`dirname "$0"` 49 | # The ".." is because we need to go out of the build-aux directory. 50 | srcdir=`cd "$srcdir"; cd ..; pwd -P` 51 | 52 | f=`basename "$2"` 53 | d=`dirname "$2"` 54 | 55 | validate_checksum() { 56 | cksum=`$MD5 "$1" | sed 's/.*\([0-9a-fA-F]\{32\}\).*/\1/'` 57 | valid=`< "$srcdir/${1%-t}.md5"` 58 | test "x$cksum" = "x$valid" 59 | } 60 | 61 | # Don't re-download if we happen to have the right file already. 62 | test -f "$2" && validate_checksum "$2" && touch "$2" && rm -f "$2-t" && exit 63 | 64 | rm -f "$2" 65 | $MKDIR_P "$d" 66 | 67 | if test -n "$WGET"; then 68 | $WGET "$1/$f" -O "$2-t" 69 | elif test -n "$CURL"; then 70 | $CURL "$1/$f" -o "$2-t" 71 | else 72 | echo >&2 "cannot find a tool to download $1/$f" 73 | exit 1 74 | fi 75 | 76 | if validate_checksum "$2-t"; then 77 | mv "$2-t" "$2" 78 | # wget sets the timestamp to whatever is the Last-Modified header, so 79 | # make sure we have a recent mtime on the file to keep `make' happy. 80 | touch "$2" 81 | else 82 | echo >&2 "error: invalid checksum for $2" 83 | echo >&2 "error: expected: $valid" 84 | echo >&2 "error: found: $cksum" 85 | rm -f "$2-t" 86 | exit 1 87 | fi 88 | -------------------------------------------------------------------------------- /logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %d{ISO8601} %-5level [%thread] %logger{0}: %msg%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /pom.xml.in: -------------------------------------------------------------------------------- 1 | 4 | 4.0.0 5 | 6 | org.hbase 7 | asynchbase 8 | @spec_version@ 9 | @spec_title@ 10 | 11 | @spec_vendor@ 12 | http://opentsdb.net 13 | 14 | 15 | An alternative HBase client library for applications requiring fully 16 | asynchronous, non-blocking and thread-safe HBase connectivity. 17 | 18 | https://github.com/OpenTSDB/asynchbase 19 | 20 | 21 | BSD 22 | http://www.opensource.org/licenses/BSD-3-Clause 23 | repo 24 | 25 | 26 | 27 | scm:git:git@github.com:OpenTSDB/asynchbase.git 28 | https://github.com/OpenTSDB/asynchbase 29 | 30 | 31 | GitHub 32 | https://github.com/OpenTSDB/asynchbase/issues 33 | 34 | 35 | 36 | User List 37 | asynchbase@googlegroups.com 38 | asynchbase+subscribe@googlegroups.com 39 | asynchbase+unsubscribe@googlegroups.com 40 | https://groups.google.com/group/asynchbase 41 | 42 | 43 | 44 | 45 | tsuna 46 | Benoit "tsuna" Sigoure 47 | tsunanet@gmail.com 48 | 49 | developer 50 | 51 | -8 52 | 53 | 54 | 2010 55 | 56 | jar 57 | 58 | 59 | .mvn-compat/src/main/java 60 | test 61 | 62 | 63 | 64 | 65 | org.apache.maven.plugins 66 | maven-compiler-plugin 67 | 2.5.1 68 | 69 | 1.6 70 | 1.6 71 | -Xlint 72 | 73 | 74 | 75 | 76 | org.apache.maven.plugins 77 | maven-source-plugin 78 | 2.1.2 79 | 80 | 81 | attach-sources 82 | 83 | jar 84 | 85 | 86 | 87 | 88 | 89 | 90 | org.apache.maven.plugins 91 | maven-javadoc-plugin 92 | 2.8.1 93 | 94 | 95 | attach-javadocs 96 | 97 | jar 98 | 99 | 100 | 101 | 102 | true 103 | true 104 | 105 | Copyright © {inceptionYear}-{currentYear}, 106 | ${project.organization.name} 107 | 108 | 109 | 110 | 111 | 112 | org.apache.maven.plugins 113 | maven-gpg-plugin 114 | 1.4 115 | 116 | 117 | sign-artifacts 118 | verify 119 | 120 | sign 121 | 122 | 123 | 124 | 125 | tsunanet@gmail.com 126 | 127 | 128 | 129 | 130 | org.apache.maven.plugins 131 | maven-surefire-plugin 132 | 2.12.4 133 | 134 | ${skipTests} 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | com.google.guava 145 | guava 146 | @GUAVA_VERSION@ 147 | 148 | 149 | 150 | io.netty 151 | netty 152 | @NETTY_VERSION@ 153 | 154 | 155 | 156 | com.stumbleupon 157 | async 158 | @SUASYNC_VERSION@ 159 | 160 | 161 | 162 | org.apache.zookeeper 163 | zookeeper 164 | @ZOOKEEPER_VERSION@ 165 | 166 | 167 | log4j 168 | log4j 169 | 170 | 171 | org.slf4j 172 | slf4j-log4j12 173 | 174 | 175 | jline 176 | jline 177 | 178 | 179 | junit 180 | junit 181 | 182 | 183 | 184 | 185 | 186 | org.slf4j 187 | slf4j-api 188 | @SLF4J_API_VERSION@ 189 | 190 | 191 | 192 | 193 | 194 | org.slf4j 195 | log4j-over-slf4j 196 | @LOG4J_OVER_SLF4J_VERSION@ 197 | runtime 198 | 199 | 200 | 201 | 202 | 203 | org.hamcrest 204 | hamcrest-core 205 | @HAMCREST_VERSION@ 206 | test 207 | 208 | 209 | 210 | junit 211 | junit 212 | @JUNIT_VERSION@ 213 | test 214 | 215 | 216 | 217 | org.javassist 218 | javassist 219 | @JAVASSIST_VERSION@ 220 | test 221 | 222 | 223 | 224 | org.mockito 225 | mockito-all 226 | @MOCKITO_VERSION@ 227 | test 228 | 229 | 230 | 231 | org.objenesis 232 | objenesis 233 | @OBJENESIS_VERSION@ 234 | test 235 | 236 | 237 | 238 | org.powermock 239 | powermock-module-junit4 240 | @POWERMOCK_MOCKITO_VERSION@ 241 | test 242 | 243 | 244 | 245 | org.powermock 246 | powermock-api-mockito 247 | @POWERMOCK_MOCKITO_VERSION@ 248 | test 249 | 250 | 251 | 252 | 253 | 254 | UTF-8 255 | true 256 | 257 | 258 | 259 | org.sonatype.oss 260 | oss-parent 261 | 7 262 | 263 | 264 | 265 | -------------------------------------------------------------------------------- /src/AtomicIncrementRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010-2012 The Async HBase Authors. All rights reserved. 3 | * This file is part of Async HBase. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * - Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright notice, 10 | * this list of conditions and the following disclaimer in the documentation 11 | * and/or other materials provided with the distribution. 12 | * - Neither the name of the StumbleUpon nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | * POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package org.hbase.async; 28 | 29 | 30 | import org.jboss.netty.buffer.ChannelBuffer; 31 | 32 | /** 33 | * Atomically increments a value in HBase. 34 | * 35 | *

A note on passing {@code byte} arrays in argument

36 | * None of the method that receive a {@code byte[]} in argument will copy it. 37 | * For more info, please refer to the documentation of {@link HBaseRpc}. 38 | *

A note on passing {@code String}s in argument

39 | * All strings are assumed to use the platform's default charset. 40 | */ 41 | public final class AtomicIncrementRequest extends HBaseRpc 42 | implements HBaseRpc.HasTable, HBaseRpc.HasKey, 43 | HBaseRpc.HasFamily, HBaseRpc.HasQualifier, HBaseRpc.IsEdit { 44 | 45 | private static final byte[] INCREMENT_COLUMN_VALUE = new byte[] { 46 | 'i', 'n', 'c', 'r', 'e', 'm', 'e', 'n', 't', 47 | 'C', 'o', 'l', 'u', 'm', 'n', 48 | 'V', 'a', 'l', 'u', 'e' 49 | }; 50 | 51 | private final byte[] family; 52 | private final byte[] qualifier; 53 | private long amount; 54 | private boolean durable = true; 55 | 56 | /** 57 | * Constructor. 58 | * These byte arrays will NOT be copied. 59 | * @param table The non-empty name of the table to use. 60 | * @param key The row key of the value to increment. 61 | * @param family The column family of the value to increment. 62 | * @param qualifier The column qualifier of the value to increment. 63 | * @param amount Amount by which to increment the value in HBase. 64 | * If negative, the value in HBase will be decremented. 65 | */ 66 | public AtomicIncrementRequest(final byte[] table, 67 | final byte[] key, 68 | final byte[] family, 69 | final byte[] qualifier, 70 | final long amount) { 71 | super(INCREMENT_COLUMN_VALUE, table, key); 72 | KeyValue.checkFamily(family); 73 | KeyValue.checkQualifier(qualifier); 74 | this.family = family; 75 | this.qualifier = qualifier; 76 | this.amount = amount; 77 | } 78 | 79 | /** 80 | * Constructor. This is equivalent to: 81 | * {@link #AtomicIncrementRequest(byte[], byte[], byte[], byte[], long) 82 | * AtomicIncrementRequest}{@code (table, key, family, qualifier, 1)} 83 | *

84 | * These byte arrays will NOT be copied. 85 | * @param table The non-empty name of the table to use. 86 | * @param key The row key of the value to increment. 87 | * @param family The column family of the value to increment. 88 | * @param qualifier The column qualifier of the value to increment. 89 | */ 90 | public AtomicIncrementRequest(final byte[] table, 91 | final byte[] key, 92 | final byte[] family, 93 | final byte[] qualifier) { 94 | this(table, key, family, qualifier, 1); 95 | } 96 | 97 | /** 98 | * Constructor. 99 | * All strings are assumed to use the platform's default charset. 100 | * @param table The non-empty name of the table to use. 101 | * @param key The row key of the value to increment. 102 | * @param family The column family of the value to increment. 103 | * @param qualifier The column qualifier of the value to increment. 104 | * @param amount Amount by which to increment the value in HBase. 105 | * If negative, the value in HBase will be decremented. 106 | */ 107 | public AtomicIncrementRequest(final String table, 108 | final String key, 109 | final String family, 110 | final String qualifier, 111 | final long amount) { 112 | this(table.getBytes(), key.getBytes(), family.getBytes(), 113 | qualifier.getBytes(), amount); 114 | } 115 | 116 | /** 117 | * Constructor. This is equivalent to: 118 | * All strings are assumed to use the platform's default charset. 119 | * {@link #AtomicIncrementRequest(String, String, String, String, long) 120 | * AtomicIncrementRequest}{@code (table, key, family, qualifier, 1)} 121 | * @param table The non-empty name of the table to use. 122 | * @param key The row key of the value to increment. 123 | * @param family The column family of the value to increment. 124 | * @param qualifier The column qualifier of the value to increment. 125 | */ 126 | public AtomicIncrementRequest(final String table, 127 | final String key, 128 | final String family, 129 | final String qualifier) { 130 | this(table.getBytes(), key.getBytes(), family.getBytes(), 131 | qualifier.getBytes(), 1); 132 | } 133 | 134 | /** 135 | * Returns the amount by which the value is going to be incremented. 136 | */ 137 | public long getAmount() { 138 | return amount; 139 | } 140 | 141 | /** 142 | * Changes the amount by which the value is going to be incremented. 143 | * @param amount The new amount. If negative, the value will be decremented. 144 | */ 145 | public void setAmount(final long amount) { 146 | this.amount = amount; 147 | } 148 | 149 | @Override 150 | public byte[] table() { 151 | return table; 152 | } 153 | 154 | @Override 155 | public byte[] key() { 156 | return key; 157 | } 158 | 159 | @Override 160 | public byte[] family() { 161 | return family; 162 | } 163 | 164 | @Override 165 | public byte[] qualifier() { 166 | return qualifier; 167 | } 168 | 169 | public String toString() { 170 | return super.toStringWithQualifier("AtomicIncrementRequest", 171 | family, qualifier, 172 | ", amount=" + amount); 173 | } 174 | 175 | // ---------------------- // 176 | // Package private stuff. // 177 | // ---------------------- // 178 | 179 | /** 180 | * Changes whether or not this atomic increment should use the WAL. 181 | * @param durable {@code true} to use the WAL, {@code false} otherwise. 182 | */ 183 | void setDurable(final boolean durable) { 184 | this.durable = durable; 185 | } 186 | 187 | private int predictSerializedSize() { 188 | int size = 0; 189 | size += 4; // int: Number of parameters. 190 | size += 1; // byte: Type of the 1st parameter. 191 | size += 3; // vint: region name length (3 bytes => max length = 32768). 192 | size += region.name().length; // The region name. 193 | size += 1; // byte: Type of the 2nd parameter. 194 | size += 3; // vint: row key length (3 bytes => max length = 32768). 195 | size += key.length; // The row key. 196 | size += 1; // byte: Type of the 3rd parameter. 197 | size += 1; // vint: Family length (guaranteed on 1 byte). 198 | size += family.length; // The family. 199 | size += 1; // byte: Type of the 4th parameter. 200 | size += 3; // vint: Qualifier length. 201 | size += qualifier.length; // The qualifier. 202 | size += 1; // byte: Type of the 5th parameter. 203 | size += 8; // long: Amount. 204 | size += 1; // byte: Type of the 6th parameter. 205 | size += 1; // bool: Whether or not to write to the WAL. 206 | return size; 207 | } 208 | 209 | /** Serializes this request. */ 210 | ChannelBuffer serialize(final byte server_version) { 211 | final ChannelBuffer buf = newBuffer(server_version, 212 | predictSerializedSize()); 213 | buf.writeInt(6); // Number of parameters. 214 | 215 | writeHBaseByteArray(buf, region.name()); 216 | writeHBaseByteArray(buf, key); 217 | writeHBaseByteArray(buf, family); 218 | writeHBaseByteArray(buf, qualifier); 219 | writeHBaseLong(buf, amount); 220 | writeHBaseBool(buf, durable); 221 | 222 | return buf; 223 | } 224 | 225 | } 226 | -------------------------------------------------------------------------------- /src/BatchableRpc.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012-2012 The Async HBase Authors. All rights reserved. 3 | * This file is part of Async HBase. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * - Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright notice, 10 | * this list of conditions and the following disclaimer in the documentation 11 | * and/or other materials provided with the distribution. 12 | * - Neither the name of the StumbleUpon nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | * POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package org.hbase.async; 28 | 29 | import org.jboss.netty.buffer.ChannelBuffer; 30 | 31 | /** 32 | * An intermediate abstract class for all RPC requests that can be batched. 33 | *

34 | * This class is internal only and doesn't provide any user-facing API other 35 | * than guaranteeing that the RPC has a family and a timestamp. 36 | */ 37 | abstract class BatchableRpc extends HBaseRpc 38 | implements HBaseRpc.HasFamily, HBaseRpc.HasTimestamp { 39 | 40 | // Attributes should have `protected' visibility, but doing so exposes 41 | // them as part of the public API and in Javadoc, which we don't want. 42 | // So instead we make them package-private so that subclasses can still 43 | // access them directly. 44 | 45 | /** Family affected by this RPC. */ 46 | /*protected*/ final byte[] family; 47 | 48 | /** The timestamp to use for {@link KeyValue}s of this RPC. */ 49 | /*protected*/ final long timestamp; 50 | 51 | /** 52 | * Explicit row lock to use, if any. 53 | * @see RowLock 54 | */ 55 | /*protected*/ final long lockid; 56 | 57 | /** 58 | * Whether or not this batchable RPC can be buffered on the client side. 59 | * Please call {@link #canBuffer} to check if this RPC can be buffered, 60 | * don't test this field directly. 61 | */ 62 | /*protected*/ boolean bufferable = true; 63 | 64 | /** 65 | * Whether or not the RegionServer must write to its WAL (Write Ahead Log). 66 | */ 67 | /*protected*/ boolean durable = true; 68 | 69 | /** 70 | * Package private constructor. 71 | * @param method The name of the method to invoke on the RegionServer. 72 | * @param table The name of the table this RPC is for. 73 | * @param row The name of the row this RPC is for. 74 | * @param family The column family to edit in that table. Subclass must 75 | * validate, this class doesn't perform any validation on the family. 76 | * @param timestamp The timestamp to use for {@link KeyValue}s of this RPC. 77 | * @param lockid Explicit row lock to use, or {@link RowLock#NO_LOCK}. 78 | */ 79 | BatchableRpc(final byte[] method, final byte[] table, 80 | final byte[] key, final byte[] family, 81 | final long timestamp, final long lockid) { 82 | super(method, table, key); 83 | this.family = family; 84 | this.timestamp = timestamp; 85 | this.lockid = lockid; 86 | } 87 | 88 | /** 89 | * Sets whether or not this RPC is can be buffered on the client side. 90 | * The default is {@code true}. 91 | *

92 | * Setting this to {@code false} bypasses the client-side buffering, which 93 | * is used to send RPCs in batches for greater throughput, and causes this 94 | * RPC to be sent directly to the server. 95 | * @param bufferable Whether or not this RPC can be buffered (i.e. delayed) 96 | * before being sent out to HBase. 97 | * @see HBaseClient#setFlushInterval 98 | */ 99 | public final void setBufferable(final boolean bufferable) { 100 | this.bufferable = bufferable; 101 | } 102 | 103 | /** 104 | * Changes the durability setting of this edit. 105 | * The default is {@code true}. 106 | * Make sure you've read and understood the 107 | * data durability section before 108 | * setting this to {@code false}. 109 | * @param durable Whether or not this edit should be stored with data 110 | * durability guarantee. 111 | */ 112 | public final void setDurable(final boolean durable) { 113 | this.durable = durable; 114 | } 115 | 116 | @Override 117 | public final byte[] family() { 118 | return family; 119 | } 120 | 121 | @Override 122 | public final long timestamp() { 123 | return timestamp; 124 | } 125 | 126 | // ---------------------- // 127 | // Package private stuff. // 128 | // ---------------------- // 129 | 130 | /** Returns whether or not it's OK to buffer this RPC on the client side. */ 131 | final boolean canBuffer() { 132 | // Don't buffer edits that have a row-lock, we want those to 133 | // complete ASAP so as to not hold the lock for too long. 134 | return lockid == RowLock.NO_LOCK && bufferable; 135 | } 136 | 137 | /** 138 | * Serialization version for this RPC. 139 | * Only used when this RPC is serialized as part of a {@link MultiAction}. 140 | * @param server_version What RPC protocol version the server is running. 141 | */ 142 | abstract byte version(final byte server_version); 143 | 144 | /** HBase code type for this kind of serialized RPC. */ 145 | abstract byte code(); 146 | 147 | /** 148 | * How many {@link KeyValue}s will be serialized by {@link #serializePayload}. 149 | */ 150 | abstract int numKeyValues(); 151 | 152 | /** 153 | * An estimate of the number of bytes needed for {@link #serializePayload}. 154 | * The estimate is conservative. 155 | */ 156 | abstract int payloadSize(); 157 | 158 | /** 159 | * Serialize the part of this RPC for a {@link MultiAction}. 160 | */ 161 | abstract void serializePayload(final ChannelBuffer buf); 162 | 163 | } 164 | -------------------------------------------------------------------------------- /src/BrokenMetaException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010-2012 The Async HBase Authors. All rights reserved. 3 | * This file is part of Async HBase. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * - Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright notice, 10 | * this list of conditions and the following disclaimer in the documentation 11 | * and/or other materials provided with the distribution. 12 | * - Neither the name of the StumbleUpon nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | * POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package org.hbase.async; 28 | 29 | /** 30 | * Indicates that the {@code .META.} or {@code -ROOT-} table is corrupted. 31 | */ 32 | public final class BrokenMetaException extends NonRecoverableException { 33 | 34 | private final byte[] table; 35 | 36 | /** 37 | * Constructor. 38 | * @param region The region we were looking up 39 | * (if known, can be {@code null} if not known). 40 | * @param msg A message describing as precisely as possible what's wrong 41 | * with the META table. 42 | */ 43 | BrokenMetaException(final RegionInfo region, final String msg) { 44 | super("Your .META. table seems broken for " 45 | + (region == null ? "(unknown table)" : region) 46 | + ". " + msg); 47 | this.table = region.table(); 48 | } 49 | 50 | /** 51 | * Returns the name of the table for which we were trying to lookup a region. 52 | * @return A possibly {@code null} byte array. 53 | */ 54 | public byte[] table() { 55 | return table; 56 | } 57 | 58 | /** 59 | * Helper to complain about a particular {@link KeyValue} found. 60 | * @param region The region we were looking up 61 | * (if known, can be {@code null} if not known). 62 | * @param msg A message describing as precisely as possible what's wrong 63 | * with the META table. 64 | * @param kv The {@link KeyValue} in which the problem was found. 65 | */ 66 | static BrokenMetaException badKV(final RegionInfo region, 67 | final String msg, 68 | final KeyValue kv) { 69 | return new BrokenMetaException(region, "I found a row where " + msg 70 | + ". KeyValue=" + kv); 71 | } 72 | 73 | private static final long serialVersionUID = 1280222742; 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/ClientStats.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The Async HBase Authors. All rights reserved. 3 | * This file is part of Async HBase. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * - Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright notice, 10 | * this list of conditions and the following disclaimer in the documentation 11 | * and/or other materials provided with the distribution. 12 | * - Neither the name of the StumbleUpon nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | * POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package org.hbase.async; 28 | 29 | import com.google.common.cache.CacheStats; 30 | 31 | /** 32 | * {@link HBaseClient} usage statistics. 33 | *

34 | * This is an immutable snapshot of usage statistics of the client. 35 | * Please note that not all the numbers in the snapshot are collected 36 | * atomically, so although each individual number is up-to-date as of 37 | * the time this object is created, small inconsistencies between numbers 38 | * can arise. 39 | * @since 1.3 40 | */ 41 | public final class ClientStats { 42 | 43 | private final long num_connections_created; 44 | private final long root_lookups; 45 | private final long meta_lookups_with_permit; 46 | private final long meta_lookups_wo_permit; 47 | private final long num_flushes; 48 | private final long num_nsres; 49 | private final long num_nsre_rpcs; 50 | private final long num_multi_rpcs; 51 | private final long num_gets; 52 | private final long num_scanners_opened; 53 | private final long num_scans; 54 | private final long num_puts; 55 | private final long num_row_locks; 56 | private final long num_deletes; 57 | private final long num_atomic_increments; 58 | private final CacheStats increment_buffer_stats; 59 | 60 | /** Package-private constructor. */ 61 | ClientStats(final long num_connections_created, 62 | final long root_lookups, 63 | final long meta_lookups_with_permit, 64 | final long meta_lookups_wo_permit, 65 | final long num_flushes, 66 | final long num_nsres, 67 | final long num_nsre_rpcs, 68 | final long num_multi_rpcs, 69 | final long num_gets, 70 | final long num_scanners_opened, 71 | final long num_scans, 72 | final long num_puts, 73 | final long num_row_locks, 74 | final long num_deletes, 75 | final long num_atomic_increments, 76 | final CacheStats increment_buffer_stats) { 77 | // JAVA Y U NO HAVE CASE CLASS LIKE SCALA?! FFFFFUUUUUUU!! 78 | this.num_connections_created = num_connections_created; 79 | this.root_lookups = root_lookups; 80 | this.meta_lookups_with_permit = meta_lookups_with_permit; 81 | this.meta_lookups_wo_permit = meta_lookups_wo_permit; 82 | this.num_flushes = num_flushes; 83 | this.num_nsres = num_nsres; 84 | this.num_nsre_rpcs = num_nsre_rpcs; 85 | this.num_multi_rpcs = num_multi_rpcs; 86 | this.num_gets = num_gets; 87 | this.num_scanners_opened = num_scanners_opened; 88 | this.num_scans = num_scans; 89 | this.num_puts = num_puts; 90 | this.num_row_locks = num_row_locks; 91 | this.num_deletes = num_deletes; 92 | this.num_atomic_increments = num_atomic_increments; 93 | this.increment_buffer_stats = increment_buffer_stats; 94 | } 95 | 96 | /** Number of connections created to connect to RegionServers. */ 97 | public long connectionsCreated() { 98 | return num_connections_created; 99 | } 100 | 101 | /** 102 | * Returns how many lookups in {@code -ROOT-} were performed. 103 | *

104 | * This number should remain low. It will be 1 after the first access to 105 | * HBase, and will increase by 1 each time the {@code .META.} region moves 106 | * to another server, which should seldom happen. 107 | *

108 | * This isn't to be confused with the number of times we looked up where 109 | * the {@code -ROOT-} region itself is located. This happens even more 110 | * rarely and a message is logged at the INFO whenever it does. 111 | */ 112 | public long rootLookups() { 113 | return root_lookups; 114 | } 115 | 116 | /** 117 | * Returns how many lookups in {@code .META.} were performed (uncontended). 118 | *

119 | * This number indicates how many times we had to lookup in {@code .META.} 120 | * where a key was located. This only counts "uncontended" lookups, where 121 | * the thread was able to acquire a "permit" to do a {@code .META.} lookup. 122 | * The majority of the {@code .META.} lookups should fall in this category. 123 | */ 124 | public long uncontendedMetaLookups() { 125 | return meta_lookups_with_permit; 126 | } 127 | 128 | /** 129 | * Returns how many lookups in {@code .META.} were performed (contended). 130 | *

131 | * This number indicates how many times we had to lookup in {@code .META.} 132 | * where a key was located. This only counts "contended" lookups, where the 133 | * thread was unable to acquire a "permit" to do a {@code .META.} lookup, 134 | * because there were already too many {@code .META.} lookups in flight. 135 | * In this case, the thread was delayed a bit in order to apply a bit of 136 | * back-pressure on the caller, to avoid creating {@code .META.} storms. 137 | * The minority of the {@code .META.} lookups should fall in this category. 138 | */ 139 | public long contendedMetaLookups() { 140 | return meta_lookups_wo_permit; 141 | } 142 | 143 | /** Number of calls to {@link HBaseClient#flush}. */ 144 | public long flushes() { 145 | return num_flushes; 146 | } 147 | 148 | /** 149 | * Number of {@code NoSuchRegionException} handled by the client. 150 | *

151 | * The {@code NoSuchRegionException} is an integral part of the way HBase 152 | * work. HBase clients keep a local cache of where they think each region 153 | * is in the cluster, but in practice things aren't static, and regions will 154 | * move due to load balancing, or get split into two new regions due to 155 | * write activity. When this happens, clients find out "the hard way" that 156 | * their RPC failed because the region they tried to get to is no longer 157 | * there. This causes the client to invalidate its local cache entry for 158 | * this region and perform a {@code .META.} lookup to find where this region 159 | * has moved, or find the new region to use in case of a split. 160 | *

161 | * While {@code NoSuchRegionException} are expected to happen due to load 162 | * balancing or write load, they tend to have a large performance impact as 163 | * they force the clients to back off and repeatedly poll the cluster to 164 | * find the new location of the region. So it's good to keep an eye on the 165 | * rate at which they happen to make sure it remains fairly constant and 166 | * low. 167 | *

168 | * In a high write throughput application, if this value increases too 169 | * quickly it typically indicates that there are too few regions, so splits 170 | * are happening too often. In this case you should manually split the hot 171 | * regions in order to better distribute the write load. 172 | *

173 | * This number is a subset of {@link #numRpcDelayedDueToNSRE}, because each 174 | * {@code NoSuchRegionException} causes multiple RPCs to be delayed. 175 | */ 176 | public long noSuchRegionExceptions() { 177 | return num_nsres; 178 | } 179 | 180 | /** 181 | * Number of RPCs delayed due to {@code NoSuchRegionException}s. 182 | *

183 | * In a high throughput application, if this value increases too quickly 184 | * it typically indicates that there are too few regions, or that some 185 | * regions are too hot, which is causing too many RPCs to back up when 186 | * a region becomes temporarily unavailable. In this case you should 187 | * manually split the hot regions in order to better distribute the write 188 | * load. 189 | * @see #noSuchRegionExceptions 190 | */ 191 | public long numRpcDelayedDueToNSRE() { 192 | return num_nsre_rpcs; 193 | } 194 | 195 | /** 196 | * Number of batched RPCs sent to the network. 197 | *

198 | * While {@link #puts} and {@link #deletes} indicate the number of RPCs 199 | * created at the application level, they don't reflect the actual number of 200 | * RPCs sent to the network because of batching (see 201 | * {@link HBaseClient#setFlushInterval}). 202 | *

203 | * Note that {@link #deletes} can only be batched if you use HBase 0.92 or 204 | * above. 205 | */ 206 | public long numBatchedRpcSent() { 207 | return num_multi_rpcs; 208 | } 209 | 210 | /** Number of calls to {@link HBaseClient#get}. */ 211 | public long gets() { 212 | return num_gets; 213 | } 214 | 215 | /** Number of scanners opened. */ 216 | public long scannersOpened() { 217 | return num_scanners_opened; 218 | } 219 | 220 | /** Number of times a scanner had to fetch data from HBase. */ 221 | public long scans() { 222 | return num_scans; 223 | } 224 | 225 | /** 226 | * Number calls to {@link HBaseClient#put}. 227 | *

228 | * Note that this doesn't necessarily reflect the number of RPCs sent to 229 | * HBase due to batching (see {@link HBaseClient#setFlushInterval}). 230 | * @see #numBatchedRpcSent 231 | */ 232 | public long puts() { 233 | return num_puts; 234 | } 235 | 236 | /** Number calls to {@link HBaseClient#lockRow}. */ 237 | public long rowLocks() { 238 | return num_row_locks; 239 | } 240 | 241 | /** 242 | * Number calls to {@link HBaseClient#delete}. 243 | *

244 | * Note that if you use HBase 0.92 or above, this doesn't necessarily 245 | * reflect the number of RPCs sent to HBase due to batching (see 246 | * {@link HBaseClient#setFlushInterval}). 247 | * @see #numBatchedRpcSent 248 | */ 249 | public long deletes() { 250 | return num_deletes; 251 | } 252 | 253 | /** 254 | * Number of {@link AtomicIncrementRequest} sent. 255 | *

256 | * This number includes {@link AtomicIncrementRequest}s sent after being 257 | * buffered by {@link HBaseClient#bufferAtomicIncrement}. The number of 258 | * evictions returned by {@link #incrementBufferStats} is a subset of this 259 | * number, and the difference between the two is the number of increments 260 | * that were sent directly without being buffered. 261 | */ 262 | public long atomicIncrements() { 263 | return num_atomic_increments; 264 | } 265 | 266 | /** Returns statistics from the buffer used to coalesce increments. */ 267 | public CacheStats incrementBufferStats() { 268 | return increment_buffer_stats; 269 | } 270 | 271 | } 272 | -------------------------------------------------------------------------------- /src/ColumnPrefixFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The Async HBase Authors. All rights reserved. 3 | * This file is part of Async HBase. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * - Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright notice, 10 | * this list of conditions and the following disclaimer in the documentation 11 | * and/or other materials provided with the distribution. 12 | * - Neither the name of the StumbleUpon nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | * POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package org.hbase.async; 28 | 29 | import org.jboss.netty.buffer.ChannelBuffer; 30 | 31 | /** 32 | * Sets a binary prefix to filter results based on the column qualifier. 33 | *

34 | * Efficiently compares the column qualifier bytes up to the length of the 35 | * prefix to see if it matches. 36 | *

37 | * Only setting this filter will return all rows that match the criteria 38 | * but at the same will cost a full table scan. 39 | * @since 1.5 40 | */ 41 | public final class ColumnPrefixFilter extends ScanFilter { 42 | 43 | private static final byte[] NAME = Bytes.ISO88591("org.apache.hadoop" 44 | + ".hbase.filter.ColumnPrefixFilter"); 45 | 46 | private final byte[] prefix; 47 | 48 | /** 49 | * Constructor for a UTF-8 prefix string. 50 | */ 51 | public ColumnPrefixFilter(final String prefix) { 52 | this(Bytes.UTF8(prefix)); 53 | } 54 | 55 | /** 56 | * Constructor. 57 | * @throws IllegalArgumentException if the prefix is an empty byte array. 58 | */ 59 | public ColumnPrefixFilter(final byte[] prefix) { 60 | if (prefix.length == 0) { 61 | throw new IllegalArgumentException("Empty prefix"); 62 | } 63 | this.prefix = prefix; 64 | } 65 | 66 | @Override 67 | int predictSerializedSize() { 68 | return 1 + NAME.length + 3 + prefix.length; 69 | } 70 | 71 | @Override 72 | void serialize(final ChannelBuffer buf) { 73 | buf.writeByte((byte) NAME.length); // 1 74 | buf.writeBytes(NAME); // 49 75 | HBaseRpc.writeByteArray(buf, prefix); // 3 + prefix.length 76 | } 77 | 78 | public String toString() { 79 | return "ColumnPrefixFilter(" + Bytes.pretty(prefix) + ")"; 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /src/ColumnRangeFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The Async HBase Authors. All rights reserved. 3 | * This file is part of Async HBase. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * - Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright notice, 10 | * this list of conditions and the following disclaimer in the documentation 11 | * and/or other materials provided with the distribution. 12 | * - Neither the name of the StumbleUpon nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | * POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package org.hbase.async; 28 | 29 | import org.jboss.netty.buffer.ChannelBuffer; 30 | 31 | /** 32 | * Filters based on a range of column qualifiers. 33 | * @since 1.5 34 | */ 35 | public final class ColumnRangeFilter extends ScanFilter { 36 | 37 | private static final byte[] NAME = Bytes.ISO88591("org.apache.hadoop.hbase" 38 | + ".filter.ColumnRangeFilter"); 39 | 40 | private final byte[] start_column; 41 | private final boolean start_inclusive; 42 | private final byte[] stop_column; 43 | private final boolean stop_inclusive; 44 | 45 | /** 46 | * Constructor for UTF-8 strings. 47 | * Equivalent to {@link #ColumnRangeFilter(byte[], boolean, byte[], boolean) 48 | * ColumnRangeFilter}{@code (start_column, true, stop_inclusive, true)} 49 | */ 50 | public ColumnRangeFilter(final String start_column, final String stop_column) { 51 | this(Bytes.UTF8(start_column), true, Bytes.UTF8(stop_column), true); 52 | } 53 | 54 | /** 55 | * Constructor. 56 | * Equivalent to {@link #ColumnRangeFilter(byte[], boolean, byte[], boolean) 57 | * ColumnRangeFilter}{@code (start_column, true, stop_inclusive, true)} 58 | */ 59 | public ColumnRangeFilter(final byte[] start_column, final byte[] stop_column) { 60 | this(start_column, true, stop_column, true); 61 | } 62 | 63 | /** 64 | * Constructor for UTF-8 strings. 65 | * @param start_column The column from which to start returning values. 66 | * If {@code null}, start scanning from the beginning of the row. 67 | * @param start_inclusive If {@code true}, the start column is inclusive. 68 | * @param stop_column The column up to which to return values. 69 | * If {@code null}, continue scanning until the end of the row. 70 | * @param stop_inclusive If {@code true}, the stop column is inclusive. 71 | */ 72 | public ColumnRangeFilter(final String start_column, final boolean start_inclusive, 73 | final String stop_column, final boolean stop_inclusive) { 74 | this(Bytes.UTF8(start_column), start_inclusive, 75 | Bytes.UTF8(stop_column), stop_inclusive); 76 | } 77 | 78 | /** 79 | * Constructor. 80 | * @param start_column The column from which to start returning values. 81 | * If {@code null}, start scanning from the beginning of the row. 82 | * @param start_inclusive If {@code true}, the start column is inclusive. 83 | * @param stop_column The column up to which to return values. 84 | * If {@code null}, continue scanning until the end of the row. 85 | * @param stop_inclusive If {@code true}, the stop column is inclusive. 86 | */ 87 | public ColumnRangeFilter(final byte[] start_column, final boolean start_inclusive, 88 | final byte[] stop_column, final boolean stop_inclusive) { 89 | this.start_column = start_column; 90 | this.start_inclusive = start_inclusive; 91 | this.stop_column = stop_column; 92 | this.stop_inclusive = stop_inclusive; 93 | } 94 | 95 | @Override 96 | int predictSerializedSize() { 97 | return 1 + NAME.length 98 | + 1 + 3 + (start_column == null ? 0 : start_column.length) + 1 99 | + 1 + 3 + (stop_column == null ? 0 : stop_column.length) + 1; 100 | } 101 | 102 | @Override 103 | void serialize(ChannelBuffer buf) { 104 | buf.writeByte((byte) NAME.length); // 1 105 | buf.writeBytes(NAME); // 48 106 | 107 | if (start_column == null) { 108 | buf.writeByte(1); // 1: False 109 | buf.writeByte(0); // 1: vint 110 | } else { 111 | buf.writeByte(0); // 1: True 112 | HBaseRpc.writeByteArray(buf, start_column); // 3 + start_column.length 113 | } 114 | buf.writeByte(start_inclusive ? 1 : 0); // 1 115 | 116 | if (stop_column == null) { 117 | buf.writeByte(1); // 1: False 118 | buf.writeByte(0); // 1: vint 119 | } else { 120 | buf.writeByte(0); // 1: True 121 | HBaseRpc.writeByteArray(buf, stop_column); // 3 + stop_column.length 122 | } 123 | buf.writeByte(stop_inclusive ? 1 : 0); // 1 124 | } 125 | 126 | public String toString() { 127 | return "ColumnRangeFilter(start=" + Bytes.pretty(start_column) 128 | + (start_inclusive ? " (in" : " (ex") 129 | + "clusive), stop=" + Bytes.pretty(stop_column) 130 | + (stop_inclusive ? " (in" : " (ex") + "clusive))"; 131 | } 132 | 133 | } 134 | -------------------------------------------------------------------------------- /src/CompareAndSetRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010, 2011 StumbleUpon, Inc. All rights reserved. 3 | * This file is part of Async HBase. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * - Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright notice, 10 | * this list of conditions and the following disclaimer in the documentation 11 | * and/or other materials provided with the distribution. 12 | * - Neither the name of the StumbleUpon nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | * POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package org.hbase.async; 28 | 29 | import org.jboss.netty.buffer.ChannelBuffer; 30 | 31 | /** 32 | * Atomically executes a Compare-And-Set (CAS) on an HBase cell. 33 | *

34 | * This class is package-private just to reduce the amount of public API, 35 | * but it could be exposed if needed. 36 | * @since 1.3 37 | */ 38 | final class CompareAndSetRequest extends HBaseRpc 39 | implements HBaseRpc.HasTable, HBaseRpc.HasKey, 40 | HBaseRpc.HasFamily, HBaseRpc.HasQualifier, HBaseRpc.HasValue, 41 | HBaseRpc.IsEdit { 42 | 43 | // Awesome RPC method name... 44 | private static final byte[] CHECKANDPUT = new byte[] { 45 | 'c', 'h', 'e', 'c', 'k', 'A', 'n', 'd', 'P', 'u', 't' 46 | }; 47 | 48 | /** New value. */ 49 | private final PutRequest put; 50 | 51 | /** Expected value. */ 52 | private final byte[] expected; 53 | 54 | /** 55 | * Constructor. 56 | * @param put Put request to execute if value matches. 57 | * @param value The expected value to compare against. 58 | * This byte array will NOT be copied. 59 | */ 60 | public CompareAndSetRequest(final PutRequest put, 61 | final byte[] expected) { 62 | super(CHECKANDPUT, put.table(), put.key()); 63 | KeyValue.checkValue(expected); 64 | this.put = put; 65 | this.expected = expected; 66 | } 67 | 68 | @Override 69 | public byte[] table() { 70 | return put.table(); 71 | } 72 | 73 | @Override 74 | public byte[] key() { 75 | return put.key(); 76 | } 77 | 78 | @Override 79 | public byte[] family() { 80 | return put.family(); 81 | } 82 | 83 | @Override 84 | public byte[] qualifier() { 85 | return put.qualifier(); 86 | } 87 | 88 | /** 89 | * Returns the expected value. 90 | *

91 | * DO NOT MODIFY THE CONTENTS OF THE ARRAY RETURNED. 92 | */ 93 | public byte[] expectedValue() { 94 | return expected; 95 | } 96 | 97 | /** 98 | * Returns the new value. 99 | * {@inheritDoc} 100 | */ 101 | @Override 102 | public byte[] value() { 103 | return put.value(); 104 | } 105 | 106 | // ---------------------- // 107 | // Package private stuff. // 108 | // ---------------------- // 109 | 110 | private int predictSerializedSize() { 111 | int size = 0; 112 | size += 4; // int: Number of parameters. 113 | size += 1; // byte: Type of the 1st parameter. 114 | size += 3; // vint: region name length (3 bytes => max length = 32768). 115 | size += region.name().length; // The region name. 116 | 117 | size += 1; // byte: Type of the 2nd parameter. 118 | size += 3; // vint: row key length (3 bytes => max length = 32768). 119 | size += key.length; // The row key. 120 | 121 | size += 1; // byte: Type of the 3rd parameter. 122 | size += 3; // vint: family length (3 bytes => max length = 32768). 123 | size += put.family().length; // The family name. 124 | 125 | size += 1; // byte: Type of the 4th parameter. 126 | size += 3; // vint: qualifier length (3 bytes => max length = 32768). 127 | size += put.qualifier().length; // The qualifier key. 128 | 129 | size += 1; // byte: Type of the 5th parameter. 130 | size += 4; // vint: data length. 131 | size += expected.length; // The data. 132 | 133 | // 6th parameter : put request 134 | size += put.predictPutSize(); 135 | 136 | return size; 137 | } 138 | 139 | @Override 140 | ChannelBuffer serialize(byte server_version) { 141 | final ChannelBuffer buf = newBuffer(server_version, predictSerializedSize()); 142 | buf.writeInt(6); // Number of parameters. 143 | 144 | // 1st param: byte array: region name. 145 | writeHBaseByteArray(buf, region.name()); 146 | 147 | // 2nd param: byte array: row key. 148 | writeHBaseByteArray(buf, put.key()); 149 | 150 | // 3rd param: byte array: column family. 151 | writeHBaseByteArray(buf, put.family()); 152 | 153 | // 4th param: byte array: qualifier. 154 | writeHBaseByteArray(buf, put.qualifier()); 155 | 156 | // 5th param: byte array: expected value. 157 | writeHBaseByteArray(buf, expected); 158 | 159 | // 6th param: New value. 160 | put.serializeInto(buf); 161 | 162 | return buf; 163 | } 164 | 165 | } 166 | -------------------------------------------------------------------------------- /src/ConnectionResetException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010-2012 The Async HBase Authors. All rights reserved. 3 | * This file is part of Async HBase. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * - Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright notice, 10 | * this list of conditions and the following disclaimer in the documentation 11 | * and/or other materials provided with the distribution. 12 | * - Neither the name of the StumbleUpon nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | * POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package org.hbase.async; 28 | 29 | import org.jboss.netty.channel.Channel; 30 | 31 | /** 32 | * Exception thrown when an RPC was in flight while we got disconnected. 33 | */ 34 | public final class ConnectionResetException extends RecoverableException { 35 | 36 | private final Channel chan; 37 | 38 | /** 39 | * Constructor. 40 | * @param table The table that wasn't found. 41 | */ 42 | ConnectionResetException(final Channel chan) { 43 | super(chan + " got disconnected"); 44 | this.chan = chan; 45 | } 46 | 47 | /** 48 | * Returns the name of the region that's offline. 49 | */ 50 | public Channel getChannel() { 51 | return chan; 52 | } 53 | 54 | private static final long serialVersionUID = 1280644142; 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/Counter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The Async HBase Authors. All rights reserved. 3 | * This file is part of Async HBase. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * - Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright notice, 10 | * this list of conditions and the following disclaimer in the documentation 11 | * and/or other materials provided with the distribution. 12 | * - Neither the name of the StumbleUpon nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | * POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package org.hbase.async; 28 | 29 | import org.hbase.async.jsr166e.LongAdder; 30 | 31 | /** 32 | * An atomic counter to replace {@link java.util.concurrent.atomic.AtomicLong}. 33 | *

34 | * This is based on JSR 166e's sharded counter, which is slated for JDK8. 35 | * This class is part of the public interface of asynchbase, and code 36 | * depending on asynchbase is encouraged to use it for their concurrent 37 | * counter needs. 38 | * @since 1.3 39 | */ 40 | public final class Counter extends LongAdder { 41 | 42 | /** 43 | * Returns the current value of the counter. 44 | */ 45 | public final long get() { 46 | return super.sum(); 47 | } 48 | 49 | private static final long serialVersionUID = 1333661542; 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/FilterList.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The Async HBase Authors. All rights reserved. 3 | * This file is part of Async HBase. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * - Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright notice, 10 | * this list of conditions and the following disclaimer in the documentation 11 | * and/or other materials provided with the distribution. 12 | * - Neither the name of the StumbleUpon nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | * POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package org.hbase.async; 28 | 29 | import org.jboss.netty.buffer.ChannelBuffer; 30 | import org.slf4j.Logger; 31 | import org.slf4j.LoggerFactory; 32 | 33 | import java.util.List; 34 | 35 | /** 36 | * Combines a list of filters into one. 37 | * Since 1.5 38 | */ 39 | public final class FilterList extends ScanFilter { 40 | 41 | private static final byte[] NAME = Bytes.ISO88591("org.apache.hadoop" 42 | + ".hbase.filter.FilterList"); 43 | 44 | private final List filters; 45 | private final Operator op; 46 | 47 | /** 48 | * Operator to combine the list of filters together. 49 | * since 1.5 50 | */ 51 | public enum Operator { 52 | /** All the filters must pass ("and" semantic). */ 53 | MUST_PASS_ALL, 54 | /** At least one of the filters must pass ("or" semantic). */ 55 | MUST_PASS_ONE, 56 | } 57 | 58 | /** 59 | * Constructor. 60 | * Equivalent to {@link #FilterList(List, Operator) 61 | * FilterList}{@code (filters, }{@link Operator#MUST_PASS_ALL}{@code )} 62 | */ 63 | public FilterList(final List filters) { 64 | this(filters, Operator.MUST_PASS_ALL); 65 | } 66 | 67 | /** 68 | * Constructor. 69 | * @param filters The filters to combine. This list does not get 70 | * copied, do not mutate it after passing it to this object. 71 | * @param op The operator to use to combine the filters together. 72 | * @throws IllegalArgumentException if the list of filters is empty. 73 | */ 74 | public FilterList(final List filters, final Operator op) { 75 | if (filters.isEmpty()) { 76 | throw new IllegalArgumentException("Empty filter list"); 77 | } 78 | this.filters = filters; 79 | this.op = op; 80 | } 81 | 82 | @Override 83 | int predictSerializedSize() { 84 | int size = 1 + NAME.length + 1 + 4; 85 | for (final ScanFilter filter : filters) { 86 | size += 2; 87 | size += filter.predictSerializedSize(); 88 | } 89 | return size; 90 | } 91 | 92 | @Override 93 | void serialize(final ChannelBuffer buf) { 94 | buf.writeByte((byte) NAME.length); // 1 95 | buf.writeBytes(NAME); //41 96 | buf.writeByte((byte) op.ordinal()); // 1 97 | buf.writeInt(filters.size()); // 4 98 | for (final ScanFilter filter : filters) { 99 | buf.writeByte(54); // 1 : code for WritableByteArrayComparable 100 | buf.writeByte(0); // 1 : code for NOT_ENCODED 101 | filter.serialize(buf); 102 | } 103 | } 104 | 105 | public String toString() { 106 | final StringBuilder buf = new StringBuilder(32 + filters.size() * 48); 107 | buf.append("FilterList(filters=["); 108 | for (final ScanFilter filter : filters) { 109 | buf.append(filter.toString()); 110 | buf.append(", "); 111 | } 112 | buf.setLength(buf.length() - 2); // Remove the last ", " 113 | buf.append("], op=").append(op).append(")"); 114 | return buf.toString(); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /src/HBaseException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010-2012 The Async HBase Authors. All rights reserved. 3 | * This file is part of Async HBase. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * - Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright notice, 10 | * this list of conditions and the following disclaimer in the documentation 11 | * and/or other materials provided with the distribution. 12 | * - Neither the name of the StumbleUpon nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | * POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package org.hbase.async; 28 | 29 | /** 30 | * The parent class of all {@link RuntimeException} created by this package. 31 | */ 32 | public abstract class HBaseException extends RuntimeException { 33 | 34 | /** 35 | * Constructor. 36 | * @param msg The message of the exception, potentially including a stack 37 | * trace. 38 | */ 39 | HBaseException(final String msg) { 40 | super(msg); 41 | } 42 | 43 | /** 44 | * Constructor. 45 | * @param msg The message of the exception, potentially including a stack 46 | * trace. 47 | * @param cause The exception that caused this one to be thrown. 48 | */ 49 | HBaseException(final String msg, final Throwable cause) { 50 | super(msg, cause); 51 | } 52 | 53 | /** 54 | * Factory method to make it possible to create an exception from another 55 | * one without having to resort to reflection, which is annoying to use. 56 | * Sub-classes that want to provide this internal functionality should 57 | * implement this method. 58 | * @param arg Some arbitrary parameter to help build the new instance. 59 | * @param rpc The RPC that failed, if any. Can be {@code null}. 60 | */ 61 | HBaseException make(final Object arg, final HBaseRpc rpc) { 62 | throw new AssertionError("Must not be used."); 63 | } 64 | 65 | private static final long serialVersionUID = 1280638842; 66 | 67 | } 68 | -------------------------------------------------------------------------------- /src/HasFailedRpcException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010-2012 The Async HBase Authors. All rights reserved. 3 | * This file is part of Async HBase. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * - Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright notice, 10 | * this list of conditions and the following disclaimer in the documentation 11 | * and/or other materials provided with the distribution. 12 | * - Neither the name of the StumbleUpon nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | * POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package org.hbase.async; 28 | 29 | /** 30 | * Interface implemented by {@link HBaseException}s that can tell you which 31 | * RPC failed. 32 | */ 33 | public interface HasFailedRpcException { 34 | 35 | /** 36 | * Returns the RPC that caused this exception. 37 | */ 38 | HBaseRpc getFailedRpc(); 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/InvalidResponseException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010-2012 The Async HBase Authors. All rights reserved. 3 | * This file is part of Async HBase. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * - Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright notice, 10 | * this list of conditions and the following disclaimer in the documentation 11 | * and/or other materials provided with the distribution. 12 | * - Neither the name of the StumbleUpon nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | * POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package org.hbase.async; 28 | 29 | /** 30 | * Exception used when the server sends an invalid response to an RPC. 31 | */ 32 | public final class InvalidResponseException extends NonRecoverableException { 33 | 34 | private final Object response; 35 | 36 | /** 37 | * Constructor. 38 | * @param msg The message of the exception, potentially including a stack 39 | * trace. 40 | * @param response The response that was received from the server. 41 | */ 42 | InvalidResponseException(final String msg, final Object response) { 43 | super(msg); 44 | this.response = response; 45 | } 46 | 47 | /** 48 | * Constructor for unexpected response types. 49 | * @param expected The type of the response that was expected. 50 | * @param response The response that was received from the server. 51 | */ 52 | InvalidResponseException(final Class expected, final Object response) { 53 | super("Unexpected response type. Expected: " + expected.getName() 54 | + ", got: " + (response == null ? "null" 55 | : response.getClass() + ", value=" + response)); 56 | this.response = response; 57 | } 58 | 59 | /** 60 | * Returns the possibly {@code null} response received from the server. 61 | */ 62 | public Object getResponse() { 63 | return response; 64 | } 65 | 66 | private static final long serialVersionUID = 1280883942; 67 | 68 | } 69 | -------------------------------------------------------------------------------- /src/KeyRegexpFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The Async HBase Authors. All rights reserved. 3 | * This file is part of Async HBase. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * - Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright notice, 10 | * this list of conditions and the following disclaimer in the documentation 11 | * and/or other materials provided with the distribution. 12 | * - Neither the name of the StumbleUpon nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | * POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package org.hbase.async; 28 | 29 | import org.jboss.netty.buffer.ChannelBuffer; 30 | import org.jboss.netty.util.CharsetUtil; 31 | 32 | import java.nio.charset.Charset; 33 | 34 | /** 35 | * Filters rows based on an expression applied to the row key. 36 | *

37 | * The regular expression will be applied on the server-side, on the row 38 | * key. Rows for which the key doesn't match will not be returned to the 39 | * scanner, which can be useful to carefully select which rows are matched 40 | * when you can't just do a prefix match, and cut down the amount of data 41 | * transfered on the network. 42 | *

43 | * Don't use an expensive regular expression, because Java's implementation 44 | * uses backtracking and matching will happen on the server side, potentially 45 | * on many many row keys. 46 | * See Regular Expression 47 | * Matching Can Be Simple And Fast for more details on regular expression 48 | * performance (or lack thereof) and what "backtracking" means. 49 | *

50 | * This means you need to be careful about using regular 51 | * expressions supplied by users as that would allow them to easily DDoS 52 | * HBase by sending prohibitively expensive regexps that would consume all 53 | * CPU cycles and cause the entire HBase node to time out. 54 | * @since 1.5 55 | */ 56 | public final class KeyRegexpFilter extends ScanFilter { 57 | 58 | private static final byte[] ROWFILTER = Bytes.ISO88591("org.apache.hadoop" 59 | + ".hbase.filter.RowFilter"); 60 | private static final byte[] REGEXSTRINGCOMPARATOR = Bytes.ISO88591("org.apache.hadoop" 61 | + ".hbase.filter.RegexStringComparator"); 62 | private static final byte[] EQUAL = new byte[] { 'E', 'Q', 'U', 'A', 'L' }; 63 | 64 | private final byte[] regexp; 65 | private final byte[] charset; 66 | 67 | /** 68 | * Sets a regular expression to filter results based on the row key. 69 | *

70 | * This is equivalent to calling {@link #KeyRegexpFilter(String, Charset)} 71 | * with the ISO-8859-1 charset in argument. 72 | * @param regexp The regular expression with which to filter the row keys. 73 | */ 74 | public KeyRegexpFilter(final String regexp) { 75 | this(regexp, CharsetUtil.ISO_8859_1); 76 | } 77 | 78 | /** 79 | * Sets a regular expression to filter results based on the row key. 80 | * @param regexp The regular expression with which to filter the row keys. 81 | * @param charset The charset used to decode the bytes of the row key into a 82 | * string. The RegionServer must support this charset, otherwise it will 83 | * unexpectedly close the connection the first time you attempt to use this 84 | * scanner. 85 | * @see #KeyRegexpFilter(byte[], Charset) 86 | */ 87 | public KeyRegexpFilter(final String regexp, final Charset charset) { 88 | this(Bytes.UTF8(regexp), charset); 89 | } 90 | 91 | /** 92 | * Sets a regular expression to filter results based on the row key. 93 | *

94 | * This is equivalent to calling {@link #KeyRegexpFilter(byte[], Charset)} 95 | * with the ISO-8859-1 charset in argument. 96 | * @param regexp The binary regular expression with which to filter 97 | * the row keys. 98 | */ 99 | public KeyRegexpFilter(final byte[] regexp) { 100 | this(regexp, CharsetUtil.ISO_8859_1); 101 | } 102 | 103 | /** 104 | * Sets a regular expression to filter results based on the row key. 105 | * @param regexp The regular expression with which to filter the row keys. 106 | * @param charset The charset used to decode the bytes of the row key into a 107 | * string. The RegionServer must support this charset, otherwise it will 108 | * unexpectedly close the connection the first time you attempt to use this 109 | * scanner. 110 | */ 111 | public KeyRegexpFilter(final byte[] regexp, final Charset charset) { 112 | this.regexp = regexp; 113 | this.charset = Bytes.UTF8(charset.name()); 114 | } 115 | 116 | @Override 117 | void serialize(ChannelBuffer buf) { 118 | buf.writeByte((byte) ROWFILTER.length); // 1 119 | buf.writeBytes(ROWFILTER); // 40 120 | // writeUTF of the comparison operator 121 | buf.writeShort(5); // 2 122 | buf.writeBytes(EQUAL); // 5 123 | // The comparator: a RegexStringComparator 124 | buf.writeByte(54); // Code for WritableByteArrayComparable // 1 125 | buf.writeByte(0); // Code for "this has no code". // 1 126 | buf.writeByte((byte) REGEXSTRINGCOMPARATOR.length); // 1 127 | buf.writeBytes(REGEXSTRINGCOMPARATOR); // 52 128 | // writeUTF the regexp 129 | buf.writeShort(regexp.length); // 2 130 | buf.writeBytes(regexp); // regexp.length 131 | // writeUTF the charset 132 | buf.writeShort(charset.length); // 2 133 | buf.writeBytes(charset); // charset.length 134 | } 135 | 136 | @Override 137 | int predictSerializedSize() { 138 | return 1 + 40 + 2 + 5 + 1 + 1 + 1 + 52 139 | + 2 + regexp.length + 2 + charset.length; 140 | } 141 | 142 | public String toString() { 143 | return "KeyRegexpFilter(\"" + new String(regexp, CharsetUtil.UTF_8) 144 | + "\", " + new String(charset, CharsetUtil.UTF_8) + ')'; 145 | } 146 | 147 | } 148 | -------------------------------------------------------------------------------- /src/NoSuchColumnFamilyException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010-2012 The Async HBase Authors. All rights reserved. 3 | * This file is part of Async HBase. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * - Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright notice, 10 | * this list of conditions and the following disclaimer in the documentation 11 | * and/or other materials provided with the distribution. 12 | * - Neither the name of the StumbleUpon nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | * POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package org.hbase.async; 28 | 29 | /** 30 | * Exception thrown when attempting to use a nonexistent column family. 31 | */ 32 | public final class NoSuchColumnFamilyException extends NonRecoverableException 33 | implements HasFailedRpcException { 34 | 35 | static final String REMOTE_CLASS = 36 | "org.apache.hadoop.hbase.regionserver.NoSuchColumnFamilyException"; 37 | 38 | final HBaseRpc failed_rpc; 39 | 40 | /** 41 | * Constructor. 42 | * @param msg The message of the exception, potentially with a stack trace. 43 | * @param failed_rpc The RPC that caused this exception, if known, or null. 44 | */ 45 | NoSuchColumnFamilyException(final String msg, final HBaseRpc failed_rpc) { 46 | super(msg + "\nCaused by RPC: " + failed_rpc); 47 | this.failed_rpc = failed_rpc; 48 | } 49 | 50 | public HBaseRpc getFailedRpc() { 51 | return failed_rpc; 52 | } 53 | 54 | @Override 55 | NoSuchColumnFamilyException make(final Object msg, final HBaseRpc rpc) { 56 | return new NoSuchColumnFamilyException(msg.toString(), rpc); 57 | } 58 | 59 | private static final long serialVersionUID = 1280993542; 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/NonRecoverableException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010-2012 The Async HBase Authors. All rights reserved. 3 | * This file is part of Async HBase. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * - Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright notice, 10 | * this list of conditions and the following disclaimer in the documentation 11 | * and/or other materials provided with the distribution. 12 | * - Neither the name of the StumbleUpon nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | * POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package org.hbase.async; 28 | 29 | /** 30 | * An exception for which it's typically pointless to retry 31 | * (such as {@link TableNotFoundException}). 32 | */ 33 | public class NonRecoverableException extends HBaseException { 34 | 35 | /** 36 | * Constructor. 37 | * @param msg The message of the exception, potentially including a stack 38 | * trace. 39 | */ 40 | NonRecoverableException(final String msg) { 41 | super(msg); 42 | } 43 | 44 | /** 45 | * Constructor. 46 | * @param msg The message of the exception, potentially including a stack 47 | * trace. 48 | * @param cause The exception that caused this one to be thrown. 49 | */ 50 | NonRecoverableException(final String msg, final Throwable cause) { 51 | super(msg, cause); 52 | } 53 | 54 | private static final long serialVersionUID = 1280638547; 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/NotServingRegionException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010-2012 The Async HBase Authors. All rights reserved. 3 | * This file is part of Async HBase. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * - Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright notice, 10 | * this list of conditions and the following disclaimer in the documentation 11 | * and/or other materials provided with the distribution. 12 | * - Neither the name of the StumbleUpon nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | * POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package org.hbase.async; 28 | 29 | /** 30 | * Exception thrown when we attempted to use a region that wasn't serving from 31 | * that particular RegionServer. It probably moved somewhere else. 32 | */ 33 | public final class NotServingRegionException extends RecoverableException 34 | implements HasFailedRpcException { 35 | 36 | static final String REMOTE_CLASS = 37 | "org.apache.hadoop.hbase.NotServingRegionException"; 38 | 39 | final HBaseRpc failed_rpc; 40 | 41 | /** 42 | * Constructor. 43 | * @param msg The message of the exception, potentially with a stack trace. 44 | * @param failed_rpc The RPC that caused this exception, if known, or null. 45 | */ 46 | NotServingRegionException(final String msg, final HBaseRpc failed_rpc) { 47 | super(msg); 48 | this.failed_rpc = failed_rpc; 49 | } 50 | 51 | @Override 52 | public String getMessage() { 53 | // In many cases this exception never makes it to the outside world, thus 54 | // its toString / getMessage methods are never called. When it's called, 55 | // it's typically called only once. So it makes sense to lazily generate 56 | // the message instead of always concatenating the toString representation 57 | // of the RPC, which is easily large because it tends to contain long byte 58 | // arrays. 59 | return super.getMessage() + "\nCaused by RPC: " + failed_rpc; 60 | } 61 | 62 | public HBaseRpc getFailedRpc() { 63 | return failed_rpc; 64 | } 65 | 66 | @Override 67 | NotServingRegionException make(final Object msg, final HBaseRpc rpc) { 68 | return new NotServingRegionException(msg.toString(), rpc); 69 | } 70 | 71 | private static final long serialVersionUID = 1281000942; 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/PleaseThrottleException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010-2012 The Async HBase Authors. All rights reserved. 3 | * This file is part of Async HBase. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * - Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright notice, 10 | * this list of conditions and the following disclaimer in the documentation 11 | * and/or other materials provided with the distribution. 12 | * - Neither the name of the StumbleUpon nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | * POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package org.hbase.async; 28 | 29 | import com.stumbleupon.async.Deferred; 30 | 31 | /** 32 | * This exception notifies the application to throttle its use of HBase. 33 | *

34 | * Since all APIs of {@link HBaseClient} are asynchronous and non-blocking, 35 | * it's possible that the application would produce RPCs at a rate higher 36 | * than HBase is able to handle. When this happens, {@link HBaseClient} 37 | * will typically do some buffering up to a certain point beyond which RPCs 38 | * will fail-fast with this exception, to prevent the application from 39 | * running itself out of memory. 40 | *

41 | * This exception is expected to be handled by having the application 42 | * throttle or pause itself for a short period of time before retrying the 43 | * RPC that failed with this exception as well as before sending other RPCs. 44 | * The reason this exception inherits from {@link NonRecoverableException} 45 | * instead of {@link RecoverableException} is that the usual course of action 46 | * when handling a {@link RecoverableException} is to retry right away, which 47 | * would defeat the whole purpose of this exception. Here, we want the 48 | * application to retry after a reasonable delay as well as throttle 49 | * the pace of creation of new RPCs. What constitutes a "reasonable 50 | * delay" depends on the nature of RPCs and rate at which they're produced. 51 | * For a write-heavy high-throughput application, this exception will 52 | * typically be used when HBase is in the process of splitting a region or 53 | * migrating a region to another server, in which case the application should 54 | * stop producing new writes for typically at least 1 second (or significantly 55 | * slow down its pace, to let {@link HBaseClient} buffer the writes). 56 | *

57 | * When {@link HBaseClient} buffers RPCs, it typically uses this exception 58 | * with a low watermark and a high watermark. When the buffer hits the low 59 | * watermark, the next (unlucky) RPC that wants to be buffered will be failed 60 | * with a {@code PleaseThrottleException}, to send an "advisory warning" to 61 | * the application that it needs to throttle itself. All subsequent RPCs 62 | * that need to be buffered will be buffered until the buffer hits the high 63 | * watermark. Once the high watermark has been hit, all subsequent RPCs that 64 | * need to be buffered will fail-fast with a {@code PleaseThrottleException}. 65 | *

66 | * One effective strategy to handle this exception is to set a flag to true 67 | * when this exception is first emitted that causes the application to pause 68 | * or throttle its use of HBase. Then you can retry the RPC that failed 69 | * (which is accessible through {@link #getFailedRpc}) and add a callback to 70 | * it in order to unset the flag once the RPC completes successfully. 71 | * Note that low-throughput applications will typically rarely (if ever) 72 | * hit the low watermark and should never hit the high watermark, so they 73 | * don't need complex throttling logic. 74 | */ 75 | public final class PleaseThrottleException extends NonRecoverableException 76 | implements HasFailedRpcException { 77 | 78 | /** The RPC that was failed with this exception. */ 79 | private final HBaseRpc rpc; 80 | 81 | /** A deferred one can wait on before retrying the failed RPC. */ 82 | private final Deferred deferred; 83 | 84 | /** 85 | * Constructor. 86 | * @param msg A message explaining why the application has to throttle. 87 | * @param cause The exception that requires the application to throttle 88 | * itself (can be {@code null}). 89 | * @param rpc The RPC that was made to fail with this exception. 90 | * @param deferred A deferred one can wait on before retrying the failed RPC. 91 | */ 92 | PleaseThrottleException(final String msg, 93 | final HBaseException cause, 94 | final HBaseRpc rpc, 95 | final Deferred deferred) { 96 | super(msg, cause); 97 | this.rpc = rpc; 98 | this.deferred = deferred; 99 | } 100 | 101 | /** 102 | * The RPC that was made to fail with this exception. 103 | */ 104 | public HBaseRpc getFailedRpc() { 105 | return rpc; 106 | } 107 | 108 | /** 109 | * Returns a deferred one can wait on before retrying the failed RPC. 110 | * @since 1.3 111 | */ 112 | public Deferred getDeferred() { 113 | return deferred; 114 | } 115 | 116 | private static final long serialVersionUID = 1286782542; 117 | 118 | } 119 | -------------------------------------------------------------------------------- /src/RecoverableException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010-2012 The Async HBase Authors. All rights reserved. 3 | * This file is part of Async HBase. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * - Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright notice, 10 | * this list of conditions and the following disclaimer in the documentation 11 | * and/or other materials provided with the distribution. 12 | * - Neither the name of the StumbleUpon nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | * POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package org.hbase.async; 28 | 29 | /** 30 | * An exception for which it's typically useful to retry 31 | * (such as {@link RegionOfflineException}). 32 | *

33 | * The retry strategy is up to you, but it's typically recommended to put an 34 | * upper bound on the number of retries and to use some kind of an exponential 35 | * backoff. 36 | */ 37 | public abstract class RecoverableException extends HBaseException { 38 | 39 | /** 40 | * Constructor. 41 | * @param msg The message of the exception, potentially including a stack 42 | * trace. 43 | */ 44 | RecoverableException(final String msg) { 45 | super(msg); 46 | } 47 | 48 | /** 49 | * Constructor. 50 | * @param msg The message of the exception, potentially including a stack 51 | * trace. 52 | * @param cause The exception that caused this one to be thrown. 53 | */ 54 | RecoverableException(final String msg, final Exception cause) { 55 | super(msg, cause); 56 | } 57 | 58 | private static final long serialVersionUID = 1280641142; 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/RegionOfflineException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010-2012 The Async HBase Authors. All rights reserved. 3 | * This file is part of Async HBase. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * - Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright notice, 10 | * this list of conditions and the following disclaimer in the documentation 11 | * and/or other materials provided with the distribution. 12 | * - Neither the name of the StumbleUpon nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | * POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package org.hbase.async; 28 | 29 | /** 30 | * Exception thrown when we attempted to find a region, but it wasn't being 31 | * served by any RegionServer (it's "offline" in HBase speak). 32 | * XXX verify those claims... Is "offline" = "disabled"? Or the region is in 33 | * transition? Or what? 34 | */ 35 | public final class RegionOfflineException extends RecoverableException { 36 | 37 | private final byte[] region; 38 | 39 | /** 40 | * Constructor. 41 | * @param region The region that was found to be offline. 42 | */ 43 | RegionOfflineException(final byte[] region) { 44 | super(Bytes.pretty(region)); 45 | this.region = region; 46 | } 47 | 48 | /** 49 | * Returns the name of the region that's offline. 50 | */ 51 | public byte[] getRegion() { 52 | return region; 53 | } 54 | 55 | private static final long serialVersionUID = 1280641842; 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/RemoteException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010-2012 The Async HBase Authors. All rights reserved. 3 | * This file is part of Async HBase. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * - Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright notice, 10 | * this list of conditions and the following disclaimer in the documentation 11 | * and/or other materials provided with the distribution. 12 | * - Neither the name of the StumbleUpon nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | * POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package org.hbase.async; 28 | 29 | /** 30 | * An unclassified exception that occurred on the server side. 31 | */ 32 | public final class RemoteException extends NonRecoverableException { 33 | 34 | private final String type; 35 | 36 | /** 37 | * Constructor. 38 | * @param type The name of the class of the remote exception. 39 | * @param msg The message of the exception, potentially including a stack 40 | * trace. 41 | */ 42 | RemoteException(final String type, final String msg) { 43 | super(msg); 44 | this.type = type; 45 | } 46 | 47 | /** 48 | * Returns the name of the class of the remote exception. 49 | */ 50 | public String getType() { 51 | return type; 52 | } 53 | 54 | @Override 55 | RemoteException make(final Object msg, final HBaseRpc rpc) { 56 | if (msg instanceof RemoteException) { 57 | final RemoteException e = (RemoteException) msg; 58 | return new RemoteException(e.getType(), e.getMessage()); 59 | } 60 | return new RemoteException(msg.getClass().getName(), msg.toString()); 61 | } 62 | 63 | private static final long serialVersionUID = 1279775242; 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/RowLock.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010-2012 The Async HBase Authors. All rights reserved. 3 | * This file is part of Async HBase. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * - Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright notice, 10 | * this list of conditions and the following disclaimer in the documentation 11 | * and/or other materials provided with the distribution. 12 | * - Neither the name of the StumbleUpon nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | * POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package org.hbase.async; 28 | 29 | 30 | /** 31 | * An explicit row lock. 32 | *

33 | * Row locks can be explicitly acquired in order to serialize edits to a given 34 | * row. This feature may disappear from HBase in the future, so try not to use 35 | * it if you can. 36 | *

37 | * While a row is locked, no one else can edit that row. Other concurrent 38 | * attempts to lock that row will block until the lock is released. Beware 39 | * that the blocking happens inside the RegionServer, so it will tie up a 40 | * thread of the RegionServer. If you have many clients contending for the 41 | * same row lock, you can literally starve a RegionServer by blocking all its 42 | * IPC threads. 43 | *

44 | * Row locks can't be held indefinitely. If you don't release a row lock after 45 | * a timeout configured on the server side, the lock will be released 46 | * automatically by the server and any further attempts to use it will yield an 47 | * {@link UnknownRowLockException}. 48 | */ 49 | public final class RowLock { 50 | 51 | /** Lock ID used to indicate that there's no explicit row lock. */ 52 | static final long NO_LOCK = -1L; 53 | 54 | private final byte[] region_name; 55 | private final long lockid; 56 | private final long acquired_tick = System.nanoTime(); 57 | 58 | /** 59 | * Constructor. 60 | * These byte arrays will NOT be copied. 61 | * @param region_name The name of the region on which the lock is held. 62 | * @param lockid The ID of the lock the server gave us. 63 | */ 64 | RowLock(final byte[] region_name, final long lockid) { 65 | this.region_name = region_name; 66 | this.lockid = lockid; 67 | } 68 | 69 | /** 70 | * Returns for how long this lock has been held in nanoseconds. 71 | *

72 | * This is a best-effort estimate of the time the lock has been held starting 73 | * from the point where the RPC response was received and de-serialized out 74 | * of the network. Meaning: it doesn't take into account network time and 75 | * time spent in the client between when the RPC was received and when it was 76 | * fully de-serialized (e.g. time spent in kernel buffers, low-level library 77 | * receive buffers, time doing GC pauses and so on and so forth). 78 | *

79 | * In addition, the precision of the return value depends on the 80 | * implementation of {@link System#nanoTime} on your platform. 81 | */ 82 | public long holdNanoTime() { 83 | return System.nanoTime() - acquired_tick; 84 | } 85 | 86 | public String toString() { 87 | return "RowLock(region_name=" + Bytes.pretty(region_name) 88 | + ", lockid=" + lockid + ", held for " + holdNanoTime() + "ns)"; 89 | } 90 | 91 | // ---------------------- // 92 | // Package private stuff. // 93 | // ---------------------- // 94 | 95 | byte[] region() { 96 | return region_name; 97 | } 98 | 99 | long id() { 100 | return lockid; 101 | } 102 | 103 | } 104 | -------------------------------------------------------------------------------- /src/RowLockRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010-2012 The Async HBase Authors. All rights reserved. 3 | * This file is part of Async HBase. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * - Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright notice, 10 | * this list of conditions and the following disclaimer in the documentation 11 | * and/or other materials provided with the distribution. 12 | * - Neither the name of the StumbleUpon nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | * POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package org.hbase.async; 28 | 29 | import org.jboss.netty.buffer.ChannelBuffer; 30 | 31 | /** 32 | * Acquires an explicit row lock. 33 | *

34 | * For a description of what row locks are, see {@link RowLock}. 35 | * 36 | *

A note on passing {@code byte} arrays in argument

37 | * None of the method that receive a {@code byte[]} in argument will copy it. 38 | * For more info, please refer to the documentation of {@link HBaseRpc}. 39 | *

A note on passing {@code String}s in argument

40 | * All strings are assumed to use the platform's default charset. 41 | */ 42 | public final class RowLockRequest extends HBaseRpc 43 | implements HBaseRpc.HasTable, HBaseRpc.HasKey { 44 | 45 | private static final byte[] LOCK_ROW = new byte[] { 46 | 'l', 'o', 'c', 'k', 'R', 'o', 'w' 47 | }; 48 | 49 | /** 50 | * Constructor. 51 | * These byte arrays will NOT be copied. 52 | * @param table The table containing the row to lock. 53 | * @param key The key of the row to lock in that table. 54 | */ 55 | public RowLockRequest(final byte[] table, final byte[] key) { 56 | super(LOCK_ROW, table, key); 57 | } 58 | 59 | /** 60 | * Constructor. 61 | * @param table The table containing the row to lock. 62 | * @param key The key of the row to lock in that table. 63 | */ 64 | public RowLockRequest(final String table, final String key) { 65 | this(table.getBytes(), key.getBytes()); 66 | } 67 | 68 | @Override 69 | public byte[] table() { 70 | return table; 71 | } 72 | 73 | @Override 74 | public byte[] key() { 75 | return key; 76 | } 77 | 78 | // ---------------------- // 79 | // Package private stuff. // 80 | // ---------------------- // 81 | 82 | private int predictSerializedSize() { 83 | int size = 0; 84 | size += 4; // int: Number of parameters. 85 | size += 1; // byte: Type of the 1st parameter. 86 | size += 3; // vint: region name length (3 bytes => max length = 32768). 87 | size += region.name().length; // The region name. 88 | size += 1; // byte: Type of the 2nd parameter. 89 | size += 3; // vint: row key length (3 bytes => max length = 32768). 90 | size += key.length; // The row key. 91 | return size; 92 | } 93 | 94 | /** Serializes this request. */ 95 | ChannelBuffer serialize(final byte server_version) { 96 | final ChannelBuffer buf = newBuffer(server_version, 97 | predictSerializedSize()); 98 | buf.writeInt(2); // Number of parameters. 99 | 100 | writeHBaseByteArray(buf, region.name()); 101 | writeHBaseByteArray(buf, key); 102 | 103 | return buf; 104 | } 105 | 106 | /** 107 | * Package-private RPC used by {@link HBaseClient} to release row locks. 108 | */ 109 | static final class ReleaseRequest extends HBaseRpc { 110 | 111 | private static final byte[] UNLOCK_ROW = new byte[] { 112 | 'u', 'n', 'l', 'o', 'c', 'k', 'R', 'o', 'w' 113 | }; 114 | 115 | private final RowLock lock; 116 | 117 | /** 118 | * Constructor. 119 | * @param lock The lock we wanna release. 120 | * @param region The region corresponding to {@code lock.region()}. 121 | */ 122 | ReleaseRequest(final RowLock lock, final RegionInfo region) { 123 | super(UNLOCK_ROW, region.table(), 124 | // This isn't actually the key we locked, but it doesn't matter 125 | // as this information is useless for this RPC, we simply supply 126 | // a key to the parent constructor to make it happy. 127 | region.stopKey()); 128 | this.lock = lock; 129 | } 130 | 131 | ChannelBuffer serialize(final byte server_version) { 132 | // num param + type 1 + region length + region + type 2 + long 133 | final ChannelBuffer buf = newBuffer(server_version, 134 | + 4 + 1 + 3 + region.name().length 135 | + 1 + 8); 136 | buf.writeInt(2); // Number of parameters. 137 | writeHBaseByteArray(buf, region.name()); 138 | writeHBaseLong(buf, lock.id()); 139 | return buf; 140 | } 141 | 142 | } 143 | 144 | } 145 | -------------------------------------------------------------------------------- /src/ScanFilter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 The Async HBase Authors. All rights reserved. 3 | * This file is part of Async HBase. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * - Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright notice, 10 | * this list of conditions and the following disclaimer in the documentation 11 | * and/or other materials provided with the distribution. 12 | * - Neither the name of the StumbleUpon nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | * POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package org.hbase.async; 28 | 29 | import org.jboss.netty.buffer.ChannelBuffer; 30 | 31 | /** 32 | * Abstract base class for {@link org.hbase.async.Scanner} filters. 33 | *

34 | * These filters are executed on the server side, inside the 35 | * {@code RegionServer}, while scanning. They are useful to 36 | * prune uninteresting data before it gets to the network, 37 | * but remember that the {@code RegionServer} still has to 38 | * load the data before it can know whether the filter passes 39 | * or not, so it's generally not efficient to filter out large 40 | * amounts of data. 41 | *

42 | * Subclasses are guaranteed to be immutable and are thus 43 | * thread-safe as well as usable concurrently on multiple 44 | * {@link org.hbase.async.Scanner} instances. 45 | * @since 1.5 46 | */ 47 | public abstract class ScanFilter { 48 | 49 | /** Package-private constructor to avoid sub-classing outside this package. */ 50 | ScanFilter() { 51 | } 52 | 53 | /** 54 | * Serializes the byte representation to the RPC channel buffer. 55 | * @param buf The RPC channel buffer to which the byte array is serialized 56 | * @since 1.5 57 | */ 58 | abstract void serialize(ChannelBuffer buf); 59 | 60 | /** 61 | * returns the number of bytes that it will write to the RPC channel buffer when {@code serialize} 62 | * is called. This method helps predict the initial size of the byte array 63 | * @return A strictly positive integer 64 | * @since 1.5 65 | */ 66 | abstract int predictSerializedSize(); 67 | 68 | } 69 | -------------------------------------------------------------------------------- /src/SingletonList.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010-2012 The Async HBase Authors. All rights reserved. 3 | * This file is part of Async HBase. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * - Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright notice, 10 | * this list of conditions and the following disclaimer in the documentation 11 | * and/or other materials provided with the distribution. 12 | * - Neither the name of the StumbleUpon nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | * POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package org.hbase.async; 28 | 29 | import java.util.Collection; 30 | import java.util.Iterator; 31 | import java.util.List; 32 | import java.util.ListIterator; 33 | import java.util.NoSuchElementException; 34 | 35 | /** 36 | * An immutable {@link List} that holds only a single non-{@code null} value. 37 | * @param The type of the singleton element. 38 | */ 39 | final class SingletonList implements List { 40 | 41 | private final E element; 42 | 43 | /** 44 | * Constructor. 45 | * @param element The only element that will ever be in this list. 46 | * Must not be {@code null}. 47 | */ 48 | public SingletonList(final E element) { 49 | if (element == null) { 50 | throw new NullPointerException("element"); 51 | } 52 | this.element = element; 53 | } 54 | 55 | public String toString() { 56 | return "[" + element + ']'; 57 | } 58 | 59 | @Override 60 | public int size() { 61 | return 1; 62 | } 63 | 64 | @Override 65 | public boolean isEmpty() { 66 | return false; 67 | } 68 | 69 | @Override 70 | public boolean contains(final Object o) { 71 | return element.equals(o); 72 | } 73 | 74 | @Override 75 | public Iterator iterator() { 76 | return new Iter(element); 77 | } 78 | 79 | @Override 80 | public Object[] toArray() { 81 | final Object[] array = new Object[1]; 82 | array[0] = element; 83 | return array; 84 | } 85 | 86 | @Override 87 | @SuppressWarnings("unchecked") 88 | public T[] toArray(final T[] a) { 89 | if (a.length < 1) { 90 | return (T[]) toArray(); 91 | } 92 | a[0] = (T) element; 93 | if (a.length > 1) { 94 | a[1] = null; 95 | } 96 | return a; 97 | } 98 | 99 | @Override 100 | public boolean add(final E e) { 101 | throw new UnsupportedOperationException(); 102 | } 103 | 104 | @Override 105 | public boolean remove(final Object o) { 106 | throw new UnsupportedOperationException(); 107 | } 108 | 109 | @Override 110 | public boolean containsAll(final Collection c) { 111 | if (c.size() != 1) { 112 | return false; 113 | } 114 | return c.contains(element); 115 | } 116 | 117 | @Override 118 | public boolean addAll(final Collection c) { 119 | throw new UnsupportedOperationException(); 120 | } 121 | 122 | @Override 123 | public boolean addAll(final int index, final Collection c) { 124 | throw new UnsupportedOperationException(); 125 | } 126 | 127 | @Override 128 | public boolean removeAll(final Collection c) { 129 | throw new UnsupportedOperationException(); 130 | } 131 | 132 | @Override 133 | public boolean retainAll(final Collection c) { 134 | throw new UnsupportedOperationException(); 135 | } 136 | 137 | @Override 138 | public void clear() { 139 | throw new UnsupportedOperationException(); 140 | } 141 | 142 | @Override 143 | public boolean equals(final Object other) { 144 | if (other == null || !(other instanceof SingletonList)) { 145 | return false; 146 | } 147 | return element.equals(((SingletonList) other).element); 148 | } 149 | 150 | @Override 151 | public int hashCode() { 152 | return 31 + element.hashCode(); 153 | } 154 | 155 | @Override 156 | public E get(final int index) { 157 | if (index != 0) { 158 | throw new IndexOutOfBoundsException("only 1 element but index=" + index); 159 | } 160 | return element; 161 | } 162 | 163 | @Override 164 | public E set(final int index, final E element) { 165 | throw new UnsupportedOperationException(); 166 | } 167 | 168 | @Override 169 | public void add(final int index, final E element) { 170 | throw new UnsupportedOperationException(); 171 | } 172 | 173 | @Override 174 | public E remove(final int index) { 175 | throw new UnsupportedOperationException(); 176 | } 177 | 178 | @Override 179 | public int indexOf(final Object o) { 180 | return o.equals(element) ? 0 : -1; 181 | } 182 | 183 | @Override 184 | public int lastIndexOf(Object o) { 185 | return o.equals(element) ? 0 : -1; 186 | } 187 | 188 | @Override 189 | public ListIterator listIterator() { 190 | return new Iter(element); 191 | } 192 | 193 | @Override 194 | public ListIterator listIterator(final int index) { 195 | if (index != 0) { 196 | throw new IndexOutOfBoundsException("only 1 element but index=" + index); 197 | } 198 | return new Iter(element); 199 | } 200 | 201 | @Override 202 | public List subList(final int fromIndex, final int toIndex) { 203 | if (fromIndex == 0 && toIndex == 1) { 204 | return this; 205 | } 206 | throw new IndexOutOfBoundsException("only 1 element but requested [" 207 | + fromIndex + "; " + toIndex + ']'); 208 | } 209 | 210 | private static final class Iter implements ListIterator { 211 | 212 | private final E element; 213 | private boolean returned = false; 214 | 215 | public Iter(final E element) { 216 | this.element = element; 217 | } 218 | 219 | @Override 220 | public boolean hasNext() { 221 | return !returned; 222 | } 223 | 224 | @Override 225 | public E next() { 226 | if (returned) { 227 | throw new NoSuchElementException(); 228 | } 229 | returned = true; 230 | return element; 231 | } 232 | 233 | @Override 234 | public boolean hasPrevious() { 235 | return returned; 236 | } 237 | 238 | @Override 239 | public E previous() { 240 | if (!returned) { 241 | throw new NoSuchElementException(); 242 | } 243 | returned = false; 244 | return element; 245 | } 246 | 247 | @Override 248 | public int nextIndex() { 249 | return returned ? 0 : 1; 250 | } 251 | 252 | @Override 253 | public int previousIndex() { 254 | return returned ? -1 : 0; 255 | } 256 | 257 | @Override 258 | public void remove() { 259 | throw new UnsupportedOperationException(); 260 | } 261 | 262 | @Override 263 | public void set(final E e) { 264 | throw new UnsupportedOperationException(); 265 | } 266 | 267 | @Override 268 | public void add(final E e) { 269 | throw new UnsupportedOperationException(); 270 | } 271 | 272 | } 273 | 274 | } 275 | -------------------------------------------------------------------------------- /src/TableNotFoundException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010-2012 The Async HBase Authors. All rights reserved. 3 | * This file is part of Async HBase. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * - Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright notice, 10 | * this list of conditions and the following disclaimer in the documentation 11 | * and/or other materials provided with the distribution. 12 | * - Neither the name of the StumbleUpon nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | * POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package org.hbase.async; 28 | 29 | /** 30 | * Exception thrown when an attempt to use an inexistent table was made. 31 | */ 32 | public final class TableNotFoundException extends NonRecoverableException { 33 | 34 | private final byte[] table; 35 | 36 | /** 37 | * Constructor. 38 | */ 39 | TableNotFoundException() { 40 | super("(unknown table)"); 41 | table = null; 42 | } 43 | 44 | /** 45 | * Constructor. 46 | * @param table The table that wasn't found. 47 | */ 48 | TableNotFoundException(final byte[] table) { 49 | super(Bytes.pretty(table)); 50 | this.table = table; 51 | } 52 | 53 | /** 54 | * Returns the table that was doesn't exist. 55 | */ 56 | public byte[] getTable() { 57 | return table; 58 | } 59 | 60 | private static final long serialVersionUID = 1280638742; 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/UnknownRowLockException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010-2012 The Async HBase Authors. All rights reserved. 3 | * This file is part of Async HBase. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * - Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright notice, 10 | * this list of conditions and the following disclaimer in the documentation 11 | * and/or other materials provided with the distribution. 12 | * - Neither the name of the StumbleUpon nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | * POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package org.hbase.async; 28 | 29 | /** 30 | * Exception thrown when we try to use an invalid or expired {@link RowLock}. 31 | */ 32 | public final class UnknownRowLockException extends NonRecoverableException 33 | implements HasFailedRpcException { 34 | 35 | static final String REMOTE_CLASS = 36 | "org.apache.hadoop.hbase.UnknownRowLockException"; 37 | 38 | final HBaseRpc failed_rpc; 39 | 40 | /** 41 | * Constructor. 42 | * @param msg The message of the exception, potentially with a stack trace. 43 | * @param failed_rpc The RPC that caused this exception, if known, or null. 44 | */ 45 | UnknownRowLockException(final String msg, final HBaseRpc failed_rpc) { 46 | super(msg + "\nCaused by RPC: " + failed_rpc); 47 | this.failed_rpc = failed_rpc; 48 | } 49 | 50 | public HBaseRpc getFailedRpc() { 51 | return failed_rpc; 52 | } 53 | 54 | @Override 55 | UnknownRowLockException make(final Object msg, final HBaseRpc rpc) { 56 | return new UnknownRowLockException(msg.toString(), rpc); 57 | } 58 | 59 | private static final long serialVersionUID = 1281540942; 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/UnknownScannerException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010-2012 The Async HBase Authors. All rights reserved. 3 | * This file is part of Async HBase. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * - Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright notice, 10 | * this list of conditions and the following disclaimer in the documentation 11 | * and/or other materials provided with the distribution. 12 | * - Neither the name of the StumbleUpon nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | * POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package org.hbase.async; 28 | 29 | /** 30 | * Exception thrown when we try to use an invalid or expired scanner ID. 31 | */ 32 | public final class UnknownScannerException extends RecoverableException 33 | implements HasFailedRpcException { 34 | 35 | static final String REMOTE_CLASS = 36 | "org.apache.hadoop.hbase.UnknownScannerException"; 37 | 38 | final HBaseRpc failed_rpc; 39 | 40 | /** 41 | * Constructor. 42 | * @param msg The message of the exception, potentially with a stack trace. 43 | * @param failed_rpc The RPC that caused this exception, if known, or null. 44 | */ 45 | UnknownScannerException(final String msg, final HBaseRpc failed_rpc) { 46 | super(msg + "\nCaused by RPC: " + failed_rpc); 47 | this.failed_rpc = failed_rpc; 48 | } 49 | 50 | public HBaseRpc getFailedRpc() { 51 | return failed_rpc; 52 | } 53 | 54 | @Override 55 | UnknownScannerException make(final Object msg, final HBaseRpc rpc) { 56 | return new UnknownScannerException(msg.toString(), rpc); 57 | } 58 | 59 | private static final long serialVersionUID = 1281457342; 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/VersionMismatchException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2012 The Async HBase Authors. All rights reserved. 3 | * This file is part of Async HBase. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * - Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright notice, 10 | * this list of conditions and the following disclaimer in the documentation 11 | * and/or other materials provided with the distribution. 12 | * - Neither the name of the StumbleUpon nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | * POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package org.hbase.async; 28 | 29 | /** 30 | * Indicates that an RPC version mismatch occurred. 31 | * The RPC sent to the server failed because the server didn't support the RPC 32 | * versions used by the client. 33 | */ 34 | public final class VersionMismatchException extends NonRecoverableException 35 | implements HasFailedRpcException { 36 | 37 | static final String REMOTE_CLASS = 38 | "org.apache.hadoop.io.VersionMismatchException"; 39 | 40 | final HBaseRpc failed_rpc; 41 | 42 | /** 43 | * Constructor. 44 | * @param msg The message of the exception, potentially with a stack trace. 45 | * @param failed_rpc The RPC that caused this exception, if known, or null. 46 | */ 47 | VersionMismatchException(final String msg, final HBaseRpc failed_rpc) { 48 | super(msg + "\nCaused by RPC: " + failed_rpc); 49 | this.failed_rpc = failed_rpc; 50 | } 51 | 52 | public HBaseRpc getFailedRpc() { 53 | return failed_rpc; 54 | } 55 | 56 | @Override 57 | VersionMismatchException make(final Object msg, final HBaseRpc rpc) { 58 | return new VersionMismatchException(msg.toString(), rpc); 59 | } 60 | 61 | private static final long serialVersionUID = 1324486442; 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/jsr166e/LongAdder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Written by Doug Lea with assistance from members of JCP JSR-166 3 | * Expert Group and released to the public domain, as explained at 4 | * http://creativecommons.org/publicdomain/zero/1.0/ 5 | */ 6 | 7 | package org.hbase.async.jsr166e; 8 | import java.util.concurrent.atomic.AtomicLong; 9 | import java.io.IOException; 10 | import java.io.Serializable; 11 | import java.io.ObjectInputStream; 12 | import java.io.ObjectOutputStream; 13 | 14 | /** 15 | * One or more variables that together maintain an initially zero 16 | * {@code long} sum. When updates (method {@link #add}) are contended 17 | * across threads, the set of variables may grow dynamically to reduce 18 | * contention. Method {@link #sum} (or, equivalently, {@link 19 | * #longValue}) returns the current total combined across the 20 | * variables maintaining the sum. 21 | * 22 | *

This class is usually preferable to {@link AtomicLong} when 23 | * multiple threads update a common sum that is used for purposes such 24 | * as collecting statistics, not for fine-grained synchronization 25 | * control. Under low update contention, the two classes have similar 26 | * characteristics. But under high contention, expected throughput of 27 | * this class is significantly higher, at the expense of higher space 28 | * consumption. 29 | * 30 | *

This class extends {@link Number}, but does not define 31 | * methods such as {@code hashCode} and {@code compareTo} because 32 | * instances are expected to be mutated, and so are not useful as 33 | * collection keys. 34 | * 35 | *

jsr166e note: This class is targeted to be placed in 36 | * java.util.concurrent.atomic 37 | * 38 | * @since 1.8 39 | * @author Doug Lea 40 | */ 41 | public class LongAdder extends Striped64 implements Serializable { 42 | private static final long serialVersionUID = 7249069246863182397L; 43 | 44 | /** 45 | * Version of plus for use in retryUpdate 46 | */ 47 | final long fn(long v, long x) { return v + x; } 48 | 49 | /** 50 | * Creates a new adder with initial sum of zero. 51 | */ 52 | public LongAdder() { 53 | } 54 | 55 | /** 56 | * Adds the given value. 57 | * 58 | * @param x the value to add 59 | */ 60 | public void add(long x) { 61 | Cell[] as; long b, v; HashCode hc; Cell a; int n; 62 | if ((as = cells) != null || !casBase(b = base, b + x)) { 63 | boolean uncontended = true; 64 | int h = (hc = threadHashCode.get()).code; 65 | if (as == null || (n = as.length) < 1 || 66 | (a = as[(n - 1) & h]) == null || 67 | !(uncontended = a.cas(v = a.value, v + x))) 68 | retryUpdate(x, hc, uncontended); 69 | } 70 | } 71 | 72 | /** 73 | * Equivalent to {@code add(1)}. 74 | */ 75 | public void increment() { 76 | add(1L); 77 | } 78 | 79 | /** 80 | * Equivalent to {@code add(-1)}. 81 | */ 82 | public void decrement() { 83 | add(-1L); 84 | } 85 | 86 | /** 87 | * Returns the current sum. The returned value is NOT an 88 | * atomic snapshot: Invocation in the absence of concurrent 89 | * updates returns an accurate result, but concurrent updates that 90 | * occur while the sum is being calculated might not be 91 | * incorporated. 92 | * 93 | * @return the sum 94 | */ 95 | public long sum() { 96 | long sum = base; 97 | Cell[] as = cells; 98 | if (as != null) { 99 | int n = as.length; 100 | for (int i = 0; i < n; ++i) { 101 | Cell a = as[i]; 102 | if (a != null) 103 | sum += a.value; 104 | } 105 | } 106 | return sum; 107 | } 108 | 109 | /** 110 | * Resets variables maintaining the sum to zero. This method may 111 | * be a useful alternative to creating a new adder, but is only 112 | * effective if there are no concurrent updates. Because this 113 | * method is intrinsically racy, it should only be used when it is 114 | * known that no threads are concurrently updating. 115 | */ 116 | public void reset() { 117 | internalReset(0L); 118 | } 119 | 120 | /** 121 | * Equivalent in effect to {@link #sum} followed by {@link 122 | * #reset}. This method may apply for example during quiescent 123 | * points between multithreaded computations. If there are 124 | * updates concurrent with this method, the returned value is 125 | * not guaranteed to be the final value occurring before 126 | * the reset. 127 | * 128 | * @return the sum 129 | */ 130 | public long sumThenReset() { 131 | long sum = base; 132 | Cell[] as = cells; 133 | base = 0L; 134 | if (as != null) { 135 | int n = as.length; 136 | for (int i = 0; i < n; ++i) { 137 | Cell a = as[i]; 138 | if (a != null) { 139 | sum += a.value; 140 | a.value = 0L; 141 | } 142 | } 143 | } 144 | return sum; 145 | } 146 | 147 | /** 148 | * Returns the String representation of the {@link #sum}. 149 | * @return the String representation of the {@link #sum} 150 | */ 151 | public String toString() { 152 | return Long.toString(sum()); 153 | } 154 | 155 | /** 156 | * Equivalent to {@link #sum}. 157 | * 158 | * @return the sum 159 | */ 160 | public long longValue() { 161 | return sum(); 162 | } 163 | 164 | /** 165 | * Returns the {@link #sum} as an {@code int} after a narrowing 166 | * primitive conversion. 167 | */ 168 | public int intValue() { 169 | return (int)sum(); 170 | } 171 | 172 | /** 173 | * Returns the {@link #sum} as a {@code float} 174 | * after a widening primitive conversion. 175 | */ 176 | public float floatValue() { 177 | return (float)sum(); 178 | } 179 | 180 | /** 181 | * Returns the {@link #sum} as a {@code double} after a widening 182 | * primitive conversion. 183 | */ 184 | public double doubleValue() { 185 | return (double)sum(); 186 | } 187 | 188 | private void writeObject(java.io.ObjectOutputStream s) 189 | throws java.io.IOException { 190 | s.defaultWriteObject(); 191 | s.writeLong(sum()); 192 | } 193 | 194 | private void readObject(ObjectInputStream s) 195 | throws IOException, ClassNotFoundException { 196 | s.defaultReadObject(); 197 | busy = 0; 198 | cells = null; 199 | base = s.readLong(); 200 | } 201 | 202 | } 203 | -------------------------------------------------------------------------------- /src/jsr166e/README: -------------------------------------------------------------------------------- 1 | The contents of this directory contains code from JSR 166e. 2 | ** THIS IS NOT PART OF THE PUBLIC INTERFACE OF ASYNCHBASE ** 3 | 4 | Code was downloaded from: 5 | http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/src/jsr166e/ 6 | 7 | The code was released to the public domain, as explained at 8 | http://creativecommons.org/publicdomain/zero/1.0/ 9 | 10 | The code is bundled in asynchbase as it is not available until JDK8 11 | becomes a reality, which is expected to take years (at time of writing). 12 | Ideally another library, such as Google Guava, would provide this 13 | code until JDK8 becomes the norm. But in the mean time it's here 14 | for asynchbase's internal use. 15 | -------------------------------------------------------------------------------- /src/jsr166e/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010-2012 The Async HBase Authors. All rights reserved. 3 | * This file is part of Async HBase. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * - Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright notice, 10 | * this list of conditions and the following disclaimer in the documentation 11 | * and/or other materials provided with the distribution. 12 | * - Neither the name of the StumbleUpon nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | * POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | /** 29 | *

This package is not part of asynchbase's public interface.

30 | * Use {@link org.hbase.async.Counter} instead. 31 | */ 32 | package org.hbase.async.jsr166e; 33 | -------------------------------------------------------------------------------- /test/Common.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The Async HBase Authors. All rights reserved. 3 | * This file is part of Async HBase. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * - Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright notice, 10 | * this list of conditions and the following disclaimer in the documentation 11 | * and/or other materials provided with the distribution. 12 | * - Neither the name of the StumbleUpon nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | * POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package org.hbase.async.test; 28 | 29 | import org.jboss.netty.logging.InternalLoggerFactory; 30 | import org.jboss.netty.logging.Slf4JLoggerFactory; 31 | 32 | import org.slf4j.Logger; 33 | import org.slf4j.LoggerFactory; 34 | 35 | import org.hbase.async.HBaseClient; 36 | 37 | final class Common { 38 | 39 | static { 40 | InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory()); 41 | } 42 | 43 | static Logger logger(final Class klass) { 44 | return LoggerFactory.getLogger(klass); 45 | } 46 | 47 | static HBaseClient getOpt(final Class klass, final String[] args) { 48 | if (args.length < 2) { 49 | System.err.println("Usage: " + klass.getSimpleName() 50 | + " [zkquorum] [znode]"); 51 | System.exit(1); 52 | } 53 | final String zkquorum; 54 | if (args.length > 2) { 55 | zkquorum = args[2]; 56 | } else { 57 | zkquorum = "localhost"; 58 | } 59 | final HBaseClient client; 60 | if (args.length > 3) { 61 | return new HBaseClient(zkquorum, args[3]); 62 | } else { 63 | return new HBaseClient(zkquorum); // Default znode 64 | } 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /test/TestIncrementCoalescing.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The Async HBase Authors. All rights reserved. 3 | * This file is part of Async HBase. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * - Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright notice, 10 | * this list of conditions and the following disclaimer in the documentation 11 | * and/or other materials provided with the distribution. 12 | * - Neither the name of the StumbleUpon nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | * POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package org.hbase.async.test; 28 | 29 | import java.util.ArrayList; 30 | import java.util.Random; 31 | 32 | import com.google.common.cache.CacheStats; 33 | 34 | import org.slf4j.Logger; 35 | 36 | import org.hbase.async.AtomicIncrementRequest; 37 | import org.hbase.async.Bytes; 38 | import org.hbase.async.DeleteRequest; 39 | import org.hbase.async.HBaseClient; 40 | import org.hbase.async.KeyValue; 41 | import org.hbase.async.Scanner; 42 | 43 | import com.stumbleupon.async.Callback; 44 | 45 | import org.hbase.async.test.Common; 46 | 47 | /** 48 | * Integration test for increment coalescing. 49 | * 50 | * Requires a locally running HBase cluster. 51 | */ 52 | final class TestIncrementCoalescing { 53 | 54 | private static final Logger LOG = 55 | Common.logger(TestIncrementCoalescing.class); 56 | 57 | public static void main(final String[] args) throws Exception { 58 | if (LOG.isDebugEnabled()) { 59 | LOG.warn("Debug logging enabled, this test will flood it pretty hard."); 60 | } 61 | if (Runtime.getRuntime().maxMemory() < 1992294400L) { 62 | LOG.error("This test requires at least 2GB of RAM to run."); 63 | LOG.error("Use JVM_ARGS='-Xmx2g -Xms2g'."); 64 | System.exit(3); 65 | } 66 | final HBaseClient client = Common.getOpt(TestIncrementCoalescing.class, 67 | args); 68 | final byte[] table = args[0].getBytes(); 69 | final byte[] family = args[1].getBytes(); 70 | try { 71 | test(client, table, family); 72 | } finally { 73 | client.shutdown().join(); 74 | } 75 | } 76 | 77 | private static volatile boolean failed = false; 78 | private static final Callback LOG_ERROR = 79 | new Callback() { 80 | public Exception call(final Exception e) { 81 | LOG.error("RPC failed", e); 82 | failed = true; 83 | return e; 84 | } 85 | }; 86 | 87 | /** Number of increments for each row. */ 88 | private static final int ICV_PER_ROW = 1000; 89 | 90 | /** Number of different keys we'll do increments on. */ 91 | private static final int NUM_ROWS = 1000; 92 | 93 | private static final byte[] QUALIFIER = {'c', 'n', 't'}; 94 | 95 | private static void test(final HBaseClient client, 96 | final byte[] table, 97 | final byte[] family) throws Exception { 98 | final Random rnd = new Random(); 99 | 100 | final class IncrementThread extends Thread { 101 | 102 | private final int num; 103 | 104 | IncrementThread(final int num) { 105 | super("IncrementThread-" + num); 106 | this.num = num; 107 | } 108 | 109 | public void run() { 110 | for (int iteration = 0; iteration < ICV_PER_ROW; iteration++) { 111 | final int r = rnd.nextInt(NUM_ROWS); 112 | final int n = r + NUM_ROWS; 113 | for (int i = r; i < n; i++) { 114 | icv(i); 115 | } 116 | } 117 | } 118 | 119 | private void icv(final int i) { 120 | final byte[] key = key(i); 121 | final AtomicIncrementRequest incr = 122 | new AtomicIncrementRequest(table, key, family, QUALIFIER); 123 | client.bufferAtomicIncrement(incr).addErrback(LOG_ERROR); 124 | } 125 | 126 | } 127 | 128 | client.ensureTableFamilyExists(table, family).join(); 129 | 130 | LOG.info("Deleting existing rows..."); 131 | for (int i = 0; i < NUM_ROWS; i++) { 132 | client.delete(new DeleteRequest(table, key(i), family, QUALIFIER)) 133 | .addErrback(LOG_ERROR); 134 | } 135 | client.flush().join(); 136 | LOG.info("Done deleting existing rows."); 137 | 138 | final int nthreads = Runtime.getRuntime().availableProcessors() * 2; 139 | final IncrementThread[] threads = new IncrementThread[nthreads]; 140 | for (int i = 0; i < nthreads; i++) { 141 | threads[i] = new IncrementThread(i); 142 | } 143 | long timing = System.nanoTime(); 144 | for (int i = 0; i < nthreads; i++) { 145 | threads[i].start(); 146 | } 147 | for (int i = 0; i < nthreads; i++) { 148 | threads[i].join(); 149 | } 150 | client.flush().join(); 151 | timing = (System.nanoTime() - timing) / 1000000; 152 | final int nrpcs = nthreads * ICV_PER_ROW * NUM_ROWS; 153 | LOG.info(nrpcs + " increments in " + timing + "ms = " 154 | + (nrpcs * 1000L / timing) + "/s"); 155 | final CacheStats stats = client.stats().incrementBufferStats(); 156 | LOG.info("Increments coalesced: " + stats.hitCount()); 157 | LOG.info("Increments sent to HBase: " + stats.missCount()); 158 | LOG.info(" due to cache evictions: " + stats.evictionCount()); 159 | 160 | LOG.info("Reading all counters back from HBase and checking values..."); 161 | final Scanner scanner = client.newScanner(table); 162 | scanner.setStartKey(key(0)); 163 | scanner.setStopKey(key(NUM_ROWS)); 164 | scanner.setFamily(family); 165 | scanner.setQualifier(QUALIFIER); 166 | ArrayList> rows; 167 | final long expected = nthreads * ICV_PER_ROW; 168 | while ((rows = scanner.nextRows().join()) != null) { 169 | for (final ArrayList row : rows) { 170 | final long value = Bytes.getLong(row.get(0).value()); 171 | if (value != expected) { 172 | LOG.error("Invalid count in " + row.get(0) + ": " + value); 173 | failed = true; 174 | } 175 | } 176 | } 177 | LOG.info("Done checking counter values."); 178 | 179 | if (failed) { 180 | LOG.error("At least one counter increment failed!"); 181 | System.exit(2); 182 | } 183 | } 184 | 185 | /** Returns the key to increment for a given number. */ 186 | private static final byte[] key(final int i) { 187 | return new byte[] { 'c', 'n', 't', 188 | (byte) ((i / 100 % 10) + '0'), 189 | (byte) ((i / 10 % 10) + '0'), 190 | (byte) ((i % 10) + '0') 191 | }; 192 | } 193 | 194 | } 195 | -------------------------------------------------------------------------------- /test/TestMETALookup.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 The Async HBase Authors. All rights reserved. 3 | * This file is part of Async HBase. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions are met: 7 | * - Redistributions of source code must retain the above copyright notice, 8 | * this list of conditions and the following disclaimer. 9 | * - Redistributions in binary form must reproduce the above copyright notice, 10 | * this list of conditions and the following disclaimer in the documentation 11 | * and/or other materials provided with the distribution. 12 | * - Neither the name of the StumbleUpon nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | * POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package org.hbase.async; 28 | 29 | import java.util.Comparator; 30 | 31 | import org.junit.Test; 32 | import org.junit.runner.RunWith; 33 | import static org.junit.Assert.fail; 34 | 35 | import org.powermock.core.classloader.annotations.PrepareForTest; 36 | import org.powermock.modules.junit4.PowerMockRunner; 37 | 38 | /** 39 | * Unit tests for META lookups and associated regressions. 40 | */ 41 | @RunWith(PowerMockRunner.class) 42 | @PrepareForTest 43 | final class TestMETALookup { 44 | 45 | private static final Comparator cmp = RegionInfo.REGION_NAME_CMP; 46 | 47 | @Test 48 | public void testRegionCmp() { 49 | // Different table names. 50 | assertGreater("table,,1234567890", ".META.,,1234567890"); 51 | // Any key is greater than the start key. 52 | assertGreater("table,foo,1234567890", "table,,1234567890"); 53 | // Different keys. 54 | assertGreater("table,foo,1234567890", "table,bar,1234567890"); 55 | // Shorter key is smaller than longer key. 56 | assertGreater("table,fool,1234567890", "table,foo,1234567890"); 57 | // Properly handle keys that contain commas. 58 | assertGreater("table,a,,c,1234567890", "table,a,,b,1234567890"); 59 | // If keys are equal, then start code should break the tie. 60 | assertGreater("table,foo,1234567891", "table,foo,1234567890"); 61 | // Make sure that a start code being a prefix of another is handled. 62 | assertGreater("table,foo,1234567890", "table,foo,123456789"); 63 | // If both are start keys, then start code should break the tie. 64 | assertGreater("table,,1234567891", "table,,1234567890"); 65 | // The value `:' is always greater than any start code. 66 | assertGreater("table,foo,:", "table,foo,9999999999"); 67 | // Issue 27: searching for key "8,\001" and region key is "8". 68 | assertGreater("table,8,\001,:", "table,8,1339667458224"); 69 | } 70 | 71 | /** Ensures that {@code sa > sb} in the META cache. */ 72 | private static void assertGreater(final String sa, final String sb) { 73 | final byte[] a = sa.getBytes(); 74 | final byte[] b = sb.getBytes(); 75 | int c = cmp.compare(a, b); 76 | if (c <= 0) { 77 | fail("compare(" + Bytes.pretty(a) + ", " + Bytes.pretty(b) + ")" 78 | + " returned " + c + ", but was expected to return > 0"); 79 | } 80 | c = cmp.compare(b, a); 81 | if (c >= 0) { 82 | fail("compare(" + Bytes.pretty(b) + ", " + Bytes.pretty(a) + ")" 83 | + " returned " + c + ", but was expected to return < 0"); 84 | } 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /third_party/.gitignore: -------------------------------------------------------------------------------- 1 | *.jar 2 | *.*-t 3 | -------------------------------------------------------------------------------- /third_party/guava/guava-12.0.jar.md5: -------------------------------------------------------------------------------- 1 | e0ff5d37fc3fa67b7fdd51a74c4bb88c 2 | -------------------------------------------------------------------------------- /third_party/guava/guava-13.0.1.jar.md5: -------------------------------------------------------------------------------- 1 | 539a72e3c7b7bd1b12b9cf7a567fb28a 2 | -------------------------------------------------------------------------------- /third_party/guava/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2012 The Async HBase Authors. All rights reserved. 2 | # This file is part of Async HBase. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are met: 6 | # - Redistributions of source code must retain the above copyright notice, 7 | # this list of conditions and the following disclaimer. 8 | # - Redistributions in binary form must reproduce the above copyright notice, 9 | # this list of conditions and the following disclaimer in the documentation 10 | # and/or other materials provided with the distribution. 11 | # - Neither the name of the StumbleUpon nor the names of its contributors 12 | # may be used to endorse or promote products derived from this software 13 | # without specific prior written permission. 14 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | # POSSIBILITY OF SUCH DAMAGE. 25 | 26 | GUAVA_VERSION := 13.0.1 27 | GUAVA := third_party/guava/guava-$(GUAVA_VERSION).jar 28 | GUAVA_BASE_URL := http://search.maven.org/remotecontent?filepath=com/google/guava/guava/$(GUAVA_VERSION) 29 | 30 | $(GUAVA): $(GUAVA).md5 31 | set dummy "$(GUAVA_BASE_URL)" "$(GUAVA)"; shift; $(FETCH_DEPENDENCY) 32 | 33 | THIRD_PARTY += $(GUAVA) 34 | -------------------------------------------------------------------------------- /third_party/hamcrest/hamcrest-core-1.3.jar.md5: -------------------------------------------------------------------------------- 1 | 6393363b47ddcbba82321110c3e07519 2 | -------------------------------------------------------------------------------- /third_party/hamcrest/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2013 The Async HBase Authors. All rights reserved. 2 | # This file is part of Async HBase. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are met: 6 | # - Redistributions of source code must retain the above copyright notice, 7 | # this list of conditions and the following disclaimer. 8 | # - Redistributions in binary form must reproduce the above copyright notice, 9 | # this list of conditions and the following disclaimer in the documentation 10 | # and/or other materials provided with the distribution. 11 | # - Neither the name of the StumbleUpon nor the names of its contributors 12 | # may be used to endorse or promote products derived from this software 13 | # without specific prior written permission. 14 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | # POSSIBILITY OF SUCH DAMAGE. 25 | 26 | HAMCREST_VERSION := 1.3 27 | HAMCREST := third_party/hamcrest/hamcrest-core-$(HAMCREST_VERSION).jar 28 | HAMCREST_BASE_URL := http://search.maven.org/remotecontent?filepath=org/hamcrest/hamcrest-core/$(HAMCREST_VERSION) 29 | 30 | $(HAMCREST): $(HAMCREST).md5 31 | set dummy "$(HAMCREST_BASE_URL)" "$(HAMCREST)"; shift; $(FETCH_DEPENDENCY) 32 | 33 | THIRD_PARTY += $(HAMCREST) 34 | -------------------------------------------------------------------------------- /third_party/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2011-2012 The Async HBase Authors. All rights reserved. 2 | # This file is part of Async HBase. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are met: 6 | # - Redistributions of source code must retain the above copyright notice, 7 | # this list of conditions and the following disclaimer. 8 | # - Redistributions in binary form must reproduce the above copyright notice, 9 | # this list of conditions and the following disclaimer in the documentation 10 | # and/or other materials provided with the distribution. 11 | # - Neither the name of the StumbleUpon nor the names of its contributors 12 | # may be used to endorse or promote products derived from this software 13 | # without specific prior written permission. 14 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | # POSSIBILITY OF SUCH DAMAGE. 25 | 26 | ASYNCHBASE_THIRD_PARTY_BASE_URL := http://opentsdb.googlecode.com/files 27 | FETCH_DEPENDENCY := ./build-aux/fetchdep.sh "$$@" 28 | THIRD_PARTY = 29 | 30 | include third_party/guava/include.mk 31 | include third_party/hamcrest/include.mk 32 | include third_party/javassist/include.mk 33 | include third_party/junit/include.mk 34 | include third_party/logback/include.mk 35 | include third_party/mockito/include.mk 36 | include third_party/netty/include.mk 37 | include third_party/objenesis/include.mk 38 | include third_party/powermock/include.mk 39 | include third_party/slf4j/include.mk 40 | include third_party/suasync/include.mk 41 | include third_party/zookeeper/include.mk 42 | -------------------------------------------------------------------------------- /third_party/javassist/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2011-2012 The Async HBase Authors. All rights reserved. 2 | # This file is part of Async HBase. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are met: 6 | # - Redistributions of source code must retain the above copyright notice, 7 | # this list of conditions and the following disclaimer. 8 | # - Redistributions in binary form must reproduce the above copyright notice, 9 | # this list of conditions and the following disclaimer in the documentation 10 | # and/or other materials provided with the distribution. 11 | # - Neither the name of the StumbleUpon nor the names of its contributors 12 | # may be used to endorse or promote products derived from this software 13 | # without specific prior written permission. 14 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | # POSSIBILITY OF SUCH DAMAGE. 25 | 26 | JAVASSIST_VERSION := 3.17.1-GA 27 | JAVASSIST := third_party/javassist/javassist-$(JAVASSIST_VERSION).jar 28 | JAVASSIST_BASE_URL := http://search.maven.org/remotecontent?filepath=org/javassist/javassist/$(JAVASSIST_VERSION) 29 | 30 | $(JAVASSIST): $(JAVASSIST).md5 31 | set dummy "$(JAVASSIST_BASE_URL)" "$(JAVASSIST)"; shift; $(FETCH_DEPENDENCY) 32 | 33 | THIRD_PARTY += $(JAVASSIST) 34 | -------------------------------------------------------------------------------- /third_party/javassist/javassist-3.15.0-GA.jar.md5: -------------------------------------------------------------------------------- 1 | 98b83db263880dc3bd9fd234ac4b8802 2 | -------------------------------------------------------------------------------- /third_party/javassist/javassist-3.17.1-GA.jar.md5: -------------------------------------------------------------------------------- 1 | d6a8586b96f0a0fb5f6100371759fa17 2 | -------------------------------------------------------------------------------- /third_party/junit/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2011-2012 The Async HBase Authors. All rights reserved. 2 | # This file is part of Async HBase. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are met: 6 | # - Redistributions of source code must retain the above copyright notice, 7 | # this list of conditions and the following disclaimer. 8 | # - Redistributions in binary form must reproduce the above copyright notice, 9 | # this list of conditions and the following disclaimer in the documentation 10 | # and/or other materials provided with the distribution. 11 | # - Neither the name of the StumbleUpon nor the names of its contributors 12 | # may be used to endorse or promote products derived from this software 13 | # without specific prior written permission. 14 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | # POSSIBILITY OF SUCH DAMAGE. 25 | 26 | JUNIT_VERSION := 4.11 27 | JUNIT := third_party/junit/junit-$(JUNIT_VERSION).jar 28 | JUNIT_BASE_URL := http://search.maven.org/remotecontent?filepath=junit/junit/$(JUNIT_VERSION) 29 | 30 | $(JUNIT): $(JUNIT).md5 31 | set dummy "$(JUNIT_BASE_URL)" "$(JUNIT)"; shift; $(FETCH_DEPENDENCY) 32 | 33 | THIRD_PARTY += $(JUNIT) 34 | -------------------------------------------------------------------------------- /third_party/junit/junit-4.10.jar.md5: -------------------------------------------------------------------------------- 1 | 972c3b8fb2cc26008cbceb01ff889ec4 2 | -------------------------------------------------------------------------------- /third_party/junit/junit-4.11.jar.md5: -------------------------------------------------------------------------------- 1 | 3c42be5ea7cbf3635716abbb429cb90d 2 | -------------------------------------------------------------------------------- /third_party/logback/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2011-2012 The Async HBase Authors. All rights reserved. 2 | # This file is part of Async HBase. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are met: 6 | # - Redistributions of source code must retain the above copyright notice, 7 | # this list of conditions and the following disclaimer. 8 | # - Redistributions in binary form must reproduce the above copyright notice, 9 | # this list of conditions and the following disclaimer in the documentation 10 | # and/or other materials provided with the distribution. 11 | # - Neither the name of the StumbleUpon nor the names of its contributors 12 | # may be used to endorse or promote products derived from this software 13 | # without specific prior written permission. 14 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | # POSSIBILITY OF SUCH DAMAGE. 25 | 26 | LOGBACK_VERSION = 1.0.9 27 | 28 | LOGBACK_CLASSIC_VERSION := $(LOGBACK_VERSION) 29 | LOGBACK_CLASSIC := third_party/logback/logback-classic-$(LOGBACK_CLASSIC_VERSION).jar 30 | LOGBACK_CLASSIC_BASE_URL := $(ASYNCHBASE_THIRD_PARTY_BASE_URL) 31 | 32 | $(LOGBACK_CLASSIC): $(LOGBACK_CLASSIC).md5 33 | set dummy "$(LOGBACK_CLASSIC_BASE_URL)" "$(LOGBACK_CLASSIC)"; shift; $(FETCH_DEPENDENCY) 34 | 35 | 36 | LOGBACK_CORE_VERSION := $(LOGBACK_VERSION) 37 | LOGBACK_CORE := third_party/logback/logback-core-$(LOGBACK_CORE_VERSION).jar 38 | LOGBACK_CORE_BASE_URL := $(ASYNCHBASE_THIRD_PARTY_BASE_URL) 39 | 40 | $(LOGBACK_CORE): $(LOGBACK_CORE).md5 41 | set dummy "$(LOGBACK_CORE_BASE_URL)" "$(LOGBACK_CORE)"; shift; $(FETCH_DEPENDENCY) 42 | 43 | THIRD_PARTY += $(LOGBACK_CLASSIC) $(LOGBACK_CORE) 44 | -------------------------------------------------------------------------------- /third_party/logback/logback-classic-1.0.0.jar.md5: -------------------------------------------------------------------------------- 1 | 7dab366c562d9f2eee771a53d04b4cf0 2 | -------------------------------------------------------------------------------- /third_party/logback/logback-classic-1.0.9.jar.md5: -------------------------------------------------------------------------------- 1 | ca99e6b10e9b2f46f264afc5cf1c13e1 2 | -------------------------------------------------------------------------------- /third_party/logback/logback-core-1.0.0.jar.md5: -------------------------------------------------------------------------------- 1 | 3081de22dc6dd5f1e97f6b3c3e5033dc 2 | -------------------------------------------------------------------------------- /third_party/logback/logback-core-1.0.9.jar.md5: -------------------------------------------------------------------------------- 1 | d1647b6efc66bd38237e4d8c484aa7b4 2 | -------------------------------------------------------------------------------- /third_party/mockito/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2011-2012 The Async HBase Authors. All rights reserved. 2 | # This file is part of Async HBase. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are met: 6 | # - Redistributions of source code must retain the above copyright notice, 7 | # this list of conditions and the following disclaimer. 8 | # - Redistributions in binary form must reproduce the above copyright notice, 9 | # this list of conditions and the following disclaimer in the documentation 10 | # and/or other materials provided with the distribution. 11 | # - Neither the name of the StumbleUpon nor the names of its contributors 12 | # may be used to endorse or promote products derived from this software 13 | # without specific prior written permission. 14 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | # POSSIBILITY OF SUCH DAMAGE. 25 | 26 | MOCKITO_VERSION := 1.9.5 27 | MOCKITO := third_party/mockito/mockito-core-$(MOCKITO_VERSION).jar 28 | MOCKITO_BASE_URL := $(ASYNCHBASE_THIRD_PARTY_BASE_URL) 29 | 30 | $(MOCKITO): $(MOCKITO).md5 31 | set dummy "$(MOCKITO_BASE_URL)" "$(MOCKITO)"; shift; $(FETCH_DEPENDENCY) 32 | 33 | THIRD_PARTY += $(MOCKITO) 34 | -------------------------------------------------------------------------------- /third_party/mockito/mockito-1.8.5.jar.md5: -------------------------------------------------------------------------------- 1 | f61b9a6feaebbfb93d299d54eccf27e9 2 | -------------------------------------------------------------------------------- /third_party/mockito/mockito-1.9.0.jar.md5: -------------------------------------------------------------------------------- 1 | cab21b44958a173a5b1d55a6aff0ab54 2 | -------------------------------------------------------------------------------- /third_party/mockito/mockito-core-1.9.5.jar.md5: -------------------------------------------------------------------------------- 1 | 98f3076e2a691d1ac291624e5a46b80b 2 | -------------------------------------------------------------------------------- /third_party/netty/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2011-2012 The Async HBase Authors. All rights reserved. 2 | # This file is part of Async HBase. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are met: 6 | # - Redistributions of source code must retain the above copyright notice, 7 | # this list of conditions and the following disclaimer. 8 | # - Redistributions in binary form must reproduce the above copyright notice, 9 | # this list of conditions and the following disclaimer in the documentation 10 | # and/or other materials provided with the distribution. 11 | # - Neither the name of the StumbleUpon nor the names of its contributors 12 | # may be used to endorse or promote products derived from this software 13 | # without specific prior written permission. 14 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | # POSSIBILITY OF SUCH DAMAGE. 25 | 26 | NETTY_MAJOR_VERSION = 3.6 27 | NETTY_VERSION := 3.6.2.Final 28 | NETTY := third_party/netty/netty-$(NETTY_VERSION).jar 29 | NETTY_BASE_URL := $(ASYNCHBASE_THIRD_PARTY_BASE_URL) 30 | 31 | $(NETTY): $(NETTY).md5 32 | set dummy "$(NETTY_BASE_URL)" "$(NETTY)"; shift; $(FETCH_DEPENDENCY) 33 | 34 | THIRD_PARTY += $(NETTY) 35 | -------------------------------------------------------------------------------- /third_party/netty/netty-3.5.9.Final.jar.md5: -------------------------------------------------------------------------------- 1 | fa33422da128c286dc2dc4d4a43ebe8e 2 | -------------------------------------------------------------------------------- /third_party/netty/netty-3.6.2.Final.jar.md5: -------------------------------------------------------------------------------- 1 | beb25141cab18d504b77914a1c3242cf 2 | -------------------------------------------------------------------------------- /third_party/objenesis/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2013 The Async HBase Authors. All rights reserved. 2 | # This file is part of Async HBase. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are met: 6 | # - Redistributions of source code must retain the above copyright notice, 7 | # this list of conditions and the following disclaimer. 8 | # - Redistributions in binary form must reproduce the above copyright notice, 9 | # this list of conditions and the following disclaimer in the documentation 10 | # and/or other materials provided with the distribution. 11 | # - Neither the name of the StumbleUpon nor the names of its contributors 12 | # may be used to endorse or promote products derived from this software 13 | # without specific prior written permission. 14 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | # POSSIBILITY OF SUCH DAMAGE. 25 | 26 | OBJENESIS_VERSION := 1.3 27 | OBJENESIS := third_party/objenesis/objenesis-$(OBJENESIS_VERSION).jar 28 | OBJENESIS_BASE_URL := http://search.maven.org/remotecontent?filepath=org/objenesis/objenesis/$(OBJENESIS_VERSION) 29 | 30 | $(OBJENESIS): $(OBJENESIS).md5 31 | set dummy "$(OBJENESIS_BASE_URL)" "$(OBJENESIS)"; shift; $(FETCH_DEPENDENCY) 32 | 33 | THIRD_PARTY += $(OBJENESIS) 34 | -------------------------------------------------------------------------------- /third_party/objenesis/objenesis-1.3.jar.md5: -------------------------------------------------------------------------------- 1 | 2d649907bd6203f2661f70d430a6ade8 2 | -------------------------------------------------------------------------------- /third_party/powermock/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2011-2012 The Async HBase Authors. All rights reserved. 2 | # This file is part of Async HBase. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are met: 6 | # - Redistributions of source code must retain the above copyright notice, 7 | # this list of conditions and the following disclaimer. 8 | # - Redistributions in binary form must reproduce the above copyright notice, 9 | # this list of conditions and the following disclaimer in the documentation 10 | # and/or other materials provided with the distribution. 11 | # - Neither the name of the StumbleUpon nor the names of its contributors 12 | # may be used to endorse or promote products derived from this software 13 | # without specific prior written permission. 14 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | # POSSIBILITY OF SUCH DAMAGE. 25 | 26 | POWERMOCK_MOCKITO_VERSION := 1.5 27 | POWERMOCK_MOCKITO := third_party/powermock/powermock-mockito-$(POWERMOCK_MOCKITO_VERSION).jar 28 | POWERMOCK_MOCKITO_BASE_URL := $(ASYNCHBASE_THIRD_PARTY_BASE_URL) 29 | 30 | $(POWERMOCK_MOCKITO): $(POWERMOCK_MOCKITO).md5 31 | set dummy "$(POWERMOCK_MOCKITO_BASE_URL)" "$(POWERMOCK_MOCKITO)"; shift; $(FETCH_DEPENDENCY) 32 | 33 | THIRD_PARTY += $(POWERMOCK_MOCKITO) 34 | -------------------------------------------------------------------------------- /third_party/powermock/powermock-mockito-1.4.10.jar.md5: -------------------------------------------------------------------------------- 1 | 4b1e653ed8b2657ac4ef27bbf440909e 2 | -------------------------------------------------------------------------------- /third_party/powermock/powermock-mockito-1.4.9.jar.md5: -------------------------------------------------------------------------------- 1 | 13a99cc9ea72ca8bdb7653d30e3b46cb 2 | -------------------------------------------------------------------------------- /third_party/powermock/powermock-mockito-1.5.jar.md5: -------------------------------------------------------------------------------- 1 | da9e7012d0e13f90c71829f2ac7d5462 2 | -------------------------------------------------------------------------------- /third_party/slf4j/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2011-2012 The Async HBase Authors. All rights reserved. 2 | # This file is part of Async HBase. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are met: 6 | # - Redistributions of source code must retain the above copyright notice, 7 | # this list of conditions and the following disclaimer. 8 | # - Redistributions in binary form must reproduce the above copyright notice, 9 | # this list of conditions and the following disclaimer in the documentation 10 | # and/or other materials provided with the distribution. 11 | # - Neither the name of the StumbleUpon nor the names of its contributors 12 | # may be used to endorse or promote products derived from this software 13 | # without specific prior written permission. 14 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | # POSSIBILITY OF SUCH DAMAGE. 25 | 26 | SLF4J_VERSION = 1.7.2 27 | 28 | 29 | LOG4J_OVER_SLF4J_VERSION := $(SLF4J_VERSION) 30 | LOG4J_OVER_SLF4J := third_party/slf4j/log4j-over-slf4j-$(LOG4J_OVER_SLF4J_VERSION).jar 31 | LOG4J_OVER_SLF4J_BASE_URL := $(ASYNCHBASE_THIRD_PARTY_BASE_URL) 32 | 33 | $(LOG4J_OVER_SLF4J): $(LOG4J_OVER_SLF4J).md5 34 | set dummy "$(LOG4J_OVER_SLF4J_BASE_URL)" "$(LOG4J_OVER_SLF4J)"; shift; $(FETCH_DEPENDENCY) 35 | 36 | 37 | SLF4J_API_VERSION := $(SLF4J_VERSION) 38 | SLF4J_API := third_party/slf4j/slf4j-api-$(SLF4J_API_VERSION).jar 39 | SLF4J_API_BASE_URL := $(ASYNCHBASE_THIRD_PARTY_BASE_URL) 40 | 41 | $(SLF4J_API): $(SLF4J_API).md5 42 | set dummy "$(SLF4J_API_BASE_URL)" "$(SLF4J_API)"; shift; $(FETCH_DEPENDENCY) 43 | 44 | THIRD_PARTY += $(JCL_OVER_SLF4J) $(LOG4J_OVER_SLF4J) $(SLF4J_API) 45 | -------------------------------------------------------------------------------- /third_party/slf4j/log4j-over-slf4j-1.6.4.jar.md5: -------------------------------------------------------------------------------- 1 | 88bec650330d2350043bac6da5baeab5 2 | -------------------------------------------------------------------------------- /third_party/slf4j/log4j-over-slf4j-1.7.2.jar.md5: -------------------------------------------------------------------------------- 1 | cbd407d8ff67a6d54fd233fc0e0d8228 2 | -------------------------------------------------------------------------------- /third_party/slf4j/slf4j-api-1.6.4.jar.md5: -------------------------------------------------------------------------------- 1 | f3e3cb3ab89d72bce36b1f914afd125b 2 | -------------------------------------------------------------------------------- /third_party/slf4j/slf4j-api-1.7.2.jar.md5: -------------------------------------------------------------------------------- 1 | ebf348e2831a3b610860fa134ad6f67f 2 | -------------------------------------------------------------------------------- /third_party/suasync/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2011-2012 The Async HBase Authors. All rights reserved. 2 | # This file is part of Async HBase. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are met: 6 | # - Redistributions of source code must retain the above copyright notice, 7 | # this list of conditions and the following disclaimer. 8 | # - Redistributions in binary form must reproduce the above copyright notice, 9 | # this list of conditions and the following disclaimer in the documentation 10 | # and/or other materials provided with the distribution. 11 | # - Neither the name of the StumbleUpon nor the names of its contributors 12 | # may be used to endorse or promote products derived from this software 13 | # without specific prior written permission. 14 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | # POSSIBILITY OF SUCH DAMAGE. 25 | 26 | SUASYNC_VERSION := 1.3.2 27 | SUASYNC := third_party/suasync/suasync-$(SUASYNC_VERSION).jar 28 | SUASYNC_BASE_URL := $(ASYNCHBASE_THIRD_PARTY_BASE_URL) 29 | 30 | $(SUASYNC): $(SUASYNC).md5 31 | set dummy "$(SUASYNC_BASE_URL)" "$(SUASYNC)"; shift; $(FETCH_DEPENDENCY) 32 | 33 | THIRD_PARTY += $(SUASYNC) 34 | -------------------------------------------------------------------------------- /third_party/suasync/suasync-1.2.0.jar.md5: -------------------------------------------------------------------------------- 1 | abca5dfd6c71c6cc02ffa830ede9c4bc 2 | -------------------------------------------------------------------------------- /third_party/suasync/suasync-1.3.1.jar.md5: -------------------------------------------------------------------------------- 1 | 68b67af908e534476b9baa6ae2edb929 2 | -------------------------------------------------------------------------------- /third_party/suasync/suasync-1.3.2.jar.md5: -------------------------------------------------------------------------------- 1 | 62cf94994a0a6c2c9e3ed32b2cef837f 2 | -------------------------------------------------------------------------------- /third_party/zookeeper/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2011-2012 The Async HBase Authors. All rights reserved. 2 | # This file is part of Async HBase. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are met: 6 | # - Redistributions of source code must retain the above copyright notice, 7 | # this list of conditions and the following disclaimer. 8 | # - Redistributions in binary form must reproduce the above copyright notice, 9 | # this list of conditions and the following disclaimer in the documentation 10 | # and/or other materials provided with the distribution. 11 | # - Neither the name of the StumbleUpon nor the names of its contributors 12 | # may be used to endorse or promote products derived from this software 13 | # without specific prior written permission. 14 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | # POSSIBILITY OF SUCH DAMAGE. 25 | 26 | ZOOKEEPER_VERSION := 3.3.6 27 | ZOOKEEPER := third_party/zookeeper/zookeeper-$(ZOOKEEPER_VERSION).jar 28 | ZOOKEEPER_BASE_URL := $(ASYNCHBASE_THIRD_PARTY_BASE_URL) 29 | 30 | $(ZOOKEEPER): $(ZOOKEEPER).md5 31 | set dummy "$(ZOOKEEPER_BASE_URL)" "$(ZOOKEEPER)"; shift; $(FETCH_DEPENDENCY) 32 | 33 | THIRD_PARTY += $(ZOOKEEPER) 34 | -------------------------------------------------------------------------------- /third_party/zookeeper/zookeeper-3.3.4.jar.md5: -------------------------------------------------------------------------------- 1 | f922a4d30df717ca3fcab8198c53d659 2 | -------------------------------------------------------------------------------- /third_party/zookeeper/zookeeper-3.3.6.jar.md5: -------------------------------------------------------------------------------- 1 | 02786e11c19d1671640992f1bda4a858 2 | --------------------------------------------------------------------------------