Permalink
Browse files

Merged changes from current master

  • Loading branch information...
2 parents d0bb21a + 9f69898 commit 958f8cb642db40051a58f194757182ff00f4a714 Chinmay Soman committed Feb 17, 2012
Showing with 15,183 additions and 3,497 deletions.
  1. +7 −2 .classpath
  2. +2 −0 .gitignore
  3. +5 −2 .settings/org.eclipse.jdt.core.prefs
  4. +1 −0 CONTRIBUTORS
  5. +3 −3 NOTES
  6. +2 −2 bin/voldemort-server.sh
  7. +1 −1 build.properties
  8. +338 −51 clients/python/voldemort/protocol/voldemort_admin_pb2.py
  9. +9 −9 clients/ruby/lib/connection/connection.rb
  10. +4 −4 clients/ruby/lib/connection/tcp_connection.rb
  11. +1 −1 clients/ruby/lib/voldemort-serializer.rb
  12. +1 −1 clients/ruby/voldemort-rb.gemspec
  13. +1 −0 config/test_config1/config/server.properties
  14. +1 −0 config/test_config2/config/server.properties
  15. +183 −0 contrib/collections/src/java/voldemort/collections/AddNodeAction.java
  16. +113 −0 contrib/collections/src/java/voldemort/collections/MappedListIterator.java
  17. +63 −0 contrib/collections/src/java/voldemort/collections/UpdateElementById.java
  18. +51 −0 contrib/collections/src/java/voldemort/collections/UpdatePageIndex.java
  19. +28 −0 contrib/collections/src/java/voldemort/collections/VLinkedPagedKey.java
  20. +224 −0 contrib/collections/src/java/voldemort/collections/VLinkedPagedList.java
  21. +206 −0 contrib/collections/src/java/voldemort/collections/VLinkedPagedListIterator.java
  22. +264 −0 contrib/collections/src/java/voldemort/collections/VListIterator.java
  23. +90 −0 contrib/collections/src/java/voldemort/collections/VListIteratorValues.java
  24. +33 −0 contrib/collections/src/java/voldemort/collections/VListKey.java
  25. +70 −0 contrib/collections/src/java/voldemort/collections/VListNode.java
  26. +60 −0 contrib/collections/src/java/voldemort/collections/VPageIndexEntry.java
  27. +354 −0 contrib/collections/src/java/voldemort/collections/VStack.java
  28. +12 −0 contrib/collections/src/java/voldemort/utils/Identifiable.java
  29. +33 −0 contrib/collections/src/java/voldemort/utils/Identified.java
  30. +260 −0 contrib/collections/test/voldemort/collections/TestVLinkedPagedList.java
  31. +168 −0 contrib/collections/test/voldemort/collections/TestVStack.java
  32. +90 −71 contrib/ec2-testing/test/voldemort/utils/Ec2GossipTest.java
  33. +7 −4 contrib/ec2-testing/test/voldemort/utils/Ec2RebalanceTest.java
  34. +5 −5 contrib/krati/src/java/voldemort/store/krati/KratiStorageEngine.java
  35. BIN lib/commons-httpclient-3.1.jar
  36. BIN lib/compress-lzf-0.9.1.jar
  37. BIN lib/httpclient-4.1.2.jar
  38. BIN lib/httpcore-4.1.2.jar
  39. BIN lib/snappy-0.2.jar
  40. +21 −0 release_notes.txt
  41. +63 −6 src/java/voldemort/VoldemortAdminTool.java
  42. +18 −0 src/java/voldemort/client/AbstractStoreClientFactory.java
  43. +34 −29 src/java/voldemort/client/HttpStoreClientFactory.java
  44. +160 −7 src/java/voldemort/client/protocol/admin/AdminClient.java
  45. +1 −1 src/java/voldemort/client/protocol/admin/AdminClientConfig.java
  46. +37 −0 src/java/voldemort/client/protocol/pb/ProtoUtils.java
  47. +3,523 −1,167 src/java/voldemort/client/protocol/pb/VAdminProto.java
  48. +22 −64 src/java/voldemort/client/rebalance/OrderedClusterTransition.java
  49. +28 −2 src/java/voldemort/client/rebalance/RebalanceCLI.java
  50. +29 −1 src/java/voldemort/client/rebalance/RebalanceClientConfig.java
  51. +55 −12 src/java/voldemort/client/rebalance/RebalanceClusterPlan.java
  52. +237 −182 src/java/voldemort/client/rebalance/RebalanceController.java
  53. +23 −8 src/java/voldemort/client/rebalance/RebalanceNodePlan.java
  54. +77 −0 src/java/voldemort/client/rebalance/task/DonorBasedRebalanceTask.java
  55. +58 −0 src/java/voldemort/client/rebalance/task/RebalanceTask.java
  56. +47 −45 src/java/voldemort/client/rebalance/{RebalanceTask.java → task/StealerBasedRebalanceTask.java}
  57. +19 −0 src/java/voldemort/cluster/Cluster.java
  58. +2 −1 src/java/voldemort/cluster/Node.java
  59. +3 −0 src/java/voldemort/cluster/failuredetector/AbstractFailureDetector.java
  60. +1 −2 src/java/voldemort/cluster/failuredetector/BasicStoreVerifier.java
  61. +12 −4 src/java/voldemort/cluster/failuredetector/FailureDetectorConfig.java
  62. +25 −3 src/java/voldemort/routing/ConsistentRoutingStrategy.java
  63. +10 −1 src/java/voldemort/routing/ZoneRoutingStrategy.java
  64. +14 −0 src/java/voldemort/server/StoreRepository.java
  65. +62 −23 src/java/voldemort/server/VoldemortConfig.java
  66. +3 −1 src/java/voldemort/server/VoldemortJsvcDaemon.java
  67. +42 −1 src/java/voldemort/server/VoldemortServer.java
  68. +19 −3 src/java/voldemort/server/jmx/JmxService.java
  69. +9 −1 src/java/voldemort/server/protocol/SocketRequestHandlerFactory.java
  70. +177 −35 src/java/voldemort/server/protocol/admin/AdminServiceRequestHandler.java
  71. +2 −0 src/java/voldemort/server/protocol/admin/FetchEntriesStreamRequestHandler.java
  72. +2 −0 src/java/voldemort/server/protocol/admin/FetchKeysStreamRequestHandler.java
  73. +5 −0 src/java/voldemort/server/protocol/admin/UpdatePartitionEntriesStreamRequestHandler.java
  74. +92 −9 src/java/voldemort/server/rebalance/Rebalancer.java
  75. +398 −0 src/java/voldemort/server/rebalance/async/DonorBasedRebalanceAsyncOperation.java
  76. +223 −0 src/java/voldemort/server/rebalance/async/DonorBasedRebalancePusherSlave.java
  77. +60 −0 src/java/voldemort/server/rebalance/async/RebalanceAsyncOperation.java
  78. +72 −89 .../server/rebalance/{RebalanceAsyncOperation.java → async/StealerBasedRebalanceAsyncOperation.java}
  79. +23 −21 src/java/voldemort/server/scheduler/slop/StreamingSlopPusherJob.java
  80. +28 −52 src/java/voldemort/server/{scheduler/slop → storage}/RepairJob.java
  81. +53 −26 src/java/voldemort/server/storage/StorageService.java
  82. +51 −0 src/java/voldemort/store/InsufficientOperationalNodesException.java
  83. +1 −0 src/java/voldemort/store/StoreDefinition.java
  84. +27 −0 src/java/voldemort/store/backup/NativeBackupable.java
  85. +297 −0 src/java/voldemort/store/bdb/BdbNativeBackup.java
  86. +47 −0 src/java/voldemort/store/bdb/BdbRuntimeConfig.java
  87. +15 −17 src/java/voldemort/store/bdb/BdbStorageConfiguration.java
  88. +34 −28 src/java/voldemort/store/bdb/BdbStorageEngine.java
  89. +209 −0 src/java/voldemort/store/bdb/stats/BdbEnvironmentStats.java
  90. +2 −0 src/java/voldemort/store/compress/CompressionStrategyFactory.java
  91. +2 −2 src/java/voldemort/store/compress/LzfCompressionStrategy.java
  92. +34 −0 src/java/voldemort/store/compress/SnappyCompressionStrategy.java
  93. +0 −188 src/java/voldemort/store/compress/lzf/ChunkEncoder.java
  94. +0 −88 src/java/voldemort/store/compress/lzf/LZF.java
  95. +0 −96 src/java/voldemort/store/compress/lzf/LZFChunk.java
  96. +0 −163 src/java/voldemort/store/compress/lzf/LZFDecoder.java
  97. +0 −70 src/java/voldemort/store/compress/lzf/LZFEncoder.java
  98. +0 −5 src/java/voldemort/store/compress/lzf/package.html
  99. +4 −4 src/java/voldemort/store/configuration/ConfigurationStorageEngine.java
  100. +39 −38 src/java/voldemort/store/http/HttpStore.java
  101. +5 −5 src/java/voldemort/store/memory/InMemoryStorageEngine.java
  102. +5 −5 src/java/voldemort/store/mysql/MysqlStorageEngine.java
  103. +97 −42 src/java/voldemort/store/readonly/swapper/HttpStoreSwapper.java
  104. +16 −12 src/java/voldemort/store/readonly/swapper/StoreSwapper.java
  105. +10 −0 src/java/voldemort/store/routed/PipelineData.java
  106. +28 −0 src/java/voldemort/store/routed/PipelineRoutedStore.java
  107. +4 −4 src/java/voldemort/store/routed/ReadRepairer.java
  108. +32 −8 src/java/voldemort/store/routed/action/AbstractConfigureNodes.java
  109. +11 −1 src/java/voldemort/store/routed/action/ConfigureNodes.java
  110. +5 −2 src/java/voldemort/store/routed/action/PerformParallelDeleteRequests.java
  111. +1 −1 src/java/voldemort/store/routed/action/PerformParallelGetAllRequests.java
  112. +5 −2 src/java/voldemort/store/routed/action/PerformParallelPutRequests.java
  113. +11 −2 src/java/voldemort/store/routed/action/PerformParallelRequests.java
  114. +5 −2 src/java/voldemort/store/routed/action/PerformSerialPutRequests.java
  115. +5 −2 src/java/voldemort/store/routed/action/PerformSerialRequests.java
  116. +1 −1 src/java/voldemort/store/slop/HintedHandoff.java
  117. +24 −18 src/java/voldemort/store/socket/SocketStore.java
  118. +10 −0 src/java/voldemort/store/socket/clientrequest/AbstractClientRequest.java
  119. +8 −0 src/java/voldemort/store/socket/clientrequest/BlockingClientRequest.java
  120. +19 −0 src/java/voldemort/store/socket/clientrequest/ClientRequest.java
  121. +7 −3 src/java/voldemort/store/socket/clientrequest/ClientRequestExecutor.java
  122. +1 −1 src/java/voldemort/store/socket/clientrequest/ClientRequestExecutorPool.java
  123. +12 −1 src/java/voldemort/store/stats/RequestCounter.java
  124. +9 −0 src/java/voldemort/store/stats/StoreStats.java
  125. +29 −3 src/java/voldemort/store/stats/StoreStatsJmx.java
  126. +45 −0 src/java/voldemort/utils/CachedCallable.java
  127. +133 −27 src/java/voldemort/utils/Entropy.java
  128. +1 −1 src/java/voldemort/utils/KeyDistributionGenerator.java
  129. +64 −0 src/java/voldemort/utils/KeyLocationValidation.java
  130. +242 −130 src/java/voldemort/utils/RebalanceUtils.java
  131. +108 −0 src/java/voldemort/utils/VoldemortIOUtils.java
  132. +1 −1 src/java/voldemort/versioning/{Occured.java → Occurred.java}
  133. +6 −6 src/java/voldemort/versioning/VectorClock.java
  134. +3 −3 src/java/voldemort/versioning/VectorClockInconsistencyResolver.java
  135. +1 −1 src/java/voldemort/versioning/Version.java
  136. +3 −3 src/java/voldemort/versioning/Versioned.java
  137. +36 −0 src/proto/voldemort-admin.proto
  138. +1 −0 test/common/voldemort/FailureDetectorTestUtils.java
  139. +54 −10 test/common/voldemort/ServerTestUtils.java
  140. +7 −0 test/common/voldemort/VoldemortTestConstants.java
  141. +38 −30 test/common/voldemort/{ → cluster/failuredetector}/MutableStoreVerifier.java
  142. +86 −0 test/common/voldemort/config/ten-node-cluster.xml
  143. +2 −1 test/integration/voldemort/CatBdbStore.java
  144. +1 −2 test/integration/voldemort/cluster/failuredetector/FailureDetectorPerformanceTest.java
  145. +46 −38 test/integration/voldemort/performance/HttpClientBench.java
  146. +35 −24 test/integration/voldemort/performance/RemoteStoreComparisonTest.java
  147. +35 −19 test/integration/voldemort/performance/RequestFileFilter.java
  148. +1 −1 test/integration/voldemort/performance/RoutedStoreParallelismTest.java
  149. +11 −4 test/integration/voldemort/performance/benchmark/Benchmark.java
  150. +65 −7 test/integration/voldemort/performance/benchmark/Workload.java
  151. +18 −0 test/integration/voldemort/rebalance/BootstrapAll.sh
  152. +23 −0 test/integration/voldemort/rebalance/CheckAndRestoreMetadata.sh
  153. +23 −0 test/integration/voldemort/rebalance/DataGen.sh
  154. +24 −0 test/integration/voldemort/rebalance/Deploy.sh
  155. +14 −0 test/integration/voldemort/rebalance/KillAllServers.sh
  156. +53 −0 test/integration/voldemort/rebalance/RandomKillStealer.sh
  157. +102 −0 test/integration/voldemort/rebalance/RandomWaitKillAndVerify.sh
  158. +126 −0 test/integration/voldemort/rebalance/RebalanceBBFail.sh
  159. +11 −0 test/integration/voldemort/rebalance/RestoreKeys.sh
  160. +15 −0 test/integration/voldemort/rebalance/RestoreMetadata.sh
  161. +19 −0 test/integration/voldemort/rebalance/StartRebalanceProcess.sh
  162. +18 −0 test/integration/voldemort/rebalance/StartServer.sh
  163. +20 −0 test/integration/voldemort/rebalance/ValidateData.sh
  164. +24 −0 test/integration/voldemort/rebalance/WaitforOutput.sh
  165. +23 −0 test/integration/voldemort/rebalance/config/test_config1/config/server.properties
  166. +23 −0 test/integration/voldemort/rebalance/config/test_config2/config/server.properties
  167. +23 −0 test/integration/voldemort/rebalance/config/test_config3/config/server.properties
  168. +23 −0 test/integration/voldemort/rebalance/config/test_config4/config/server.properties
  169. +23 −0 test/integration/voldemort/rebalance/config/test_config5/config/server.properties
  170. +23 −0 test/integration/voldemort/rebalance/config/test_config6/config/server.properties
  171. +23 −0 test/integration/voldemort/rebalance/gen.sh
  172. +21 −0 test/integration/voldemort/rebalance/initWorkloadGen.sh
  173. +65 −0 test/integration/voldemort/rebalance/metadata/final-cluster.xml
  174. +65 −0 test/integration/voldemort/rebalance/metadata/initial-cluster.xml
  175. +32 −0 test/integration/voldemort/rebalance/metadata/stores.xml
  176. +47 −0 test/integration/voldemort/rebalance/metadata/target-cluster.xml
  177. +48 −0 test/integration/voldemort/rebalance/metadata/voldemort-server.sh
  178. +48 −0 test/integration/voldemort/rebalance/setup_env.inc
  179. +1 −4 test/unit/voldemort/client/AdminServiceBasicTest.java
  180. +10 −2 test/unit/voldemort/client/HttpStoreClientFactoryTest.java
  181. +301 −14 test/unit/voldemort/client/rebalance/AbstractRebalanceTest.java
  182. +7 −21 test/unit/voldemort/client/rebalance/AdminRebalanceTest.java
  183. +233 −101 test/unit/voldemort/client/rebalance/RebalanceClusterPlanTest.java
  184. +9 −2 test/unit/voldemort/client/rebalance/RebalanceTest.java
  185. +1 −1 test/unit/voldemort/cluster/TestCluster.java
  186. +1 −1 test/unit/voldemort/cluster/failuredetector/BannagePeriodFailureDetectorTest.java
  187. +20 −3 test/unit/voldemort/cluster/failuredetector/ThresholdFailureDetectorTest.java
  188. +0 −218 test/unit/voldemort/scheduled/RepairTest.java
  189. +126 −0 test/unit/voldemort/scheduled/StreamingSlopPusherTest.java
  190. +5 −5 test/unit/voldemort/server/EndToEndTest.java
  191. +2 −2 test/unit/voldemort/store/bdb/BdbSplitStorageEngineTest.java
  192. +55 −8 test/unit/voldemort/store/bdb/BdbStorageEngineTest.java
  193. +1 −1 test/unit/voldemort/store/compress/CompressingStoreTest.java
  194. +2 −0 test/unit/voldemort/store/compress/lzf/TestLZF.java
  195. +28 −5 test/unit/voldemort/store/http/HttpStoreTest.java
  196. +22 −16 test/unit/voldemort/store/readonly/swapper/StoreSwapperTest.java
  197. +1 −4 test/unit/voldemort/store/rebalancing/RedirectingStoreTest.java
  198. +1 −1 test/unit/voldemort/store/routed/HintedHandoffTest.java
  199. +1 −1 test/unit/voldemort/store/routed/ReadRepairerTest.java
  200. +57 −6 test/unit/voldemort/store/routed/RoutedStoreTest.java
  201. +10 −0 test/unit/voldemort/store/stats/StoreStatsJmxTest.java
  202. +58 −0 test/unit/voldemort/utils/CachedCallableTest.java
  203. +52 −0 test/unit/voldemort/utils/VoldemortIOUtilsTest.java
  204. +2,562 −0 test/unit/voldemort/utils/Xtranslcl.c.input
  205. +7 −0 test/unit/voldemort/utils/maze.c.input
  206. +7 −7 test/unit/voldemort/versioning/VectorClockTest.java
View
@@ -12,11 +12,11 @@
<classpathentry kind="src" path="example/java"/>
<classpathentry kind="src" path="contrib/krati/src/java"/>
<classpathentry kind="src" path="contrib/krati/test"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="src" path="contrib/collections/src/java"/>
+ <classpathentry kind="src" path="contrib/collections/test"/>
<classpathentry kind="lib" path="lib/catalina-ant.jar"/>
<classpathentry kind="lib" path="lib/commons-codec-1.3.jar"/>
<classpathentry kind="lib" path="lib/commons-dbcp-1.2.2.jar"/>
- <classpathentry kind="lib" path="lib/commons-httpclient-3.1.jar"/>
<classpathentry kind="lib" path="lib/colt-1.2.0.jar"/>
<classpathentry kind="lib" path="contrib/hadoop-store-builder/lib/commons-cli-2.0-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="contrib/hadoop-store-builder/lib/hadoop-0.20.2-core.jar"/>
@@ -49,5 +49,10 @@
<classpathentry kind="lib" path="lib/mockito-all-1.8.5.jar"/>
<classpathentry kind="lib" path="lib/avro-1.4.0.jar"/>
<classpathentry kind="lib" path="lib/libthrift-0.5.0.jar"/>
+ <classpathentry kind="lib" path="lib/compress-lzf-0.9.1.jar"/>
+ <classpathentry kind="lib" path="lib/snappy-0.2.jar"/>
+ <classpathentry kind="lib" path="lib/httpclient-4.1.2.jar" />
+ <classpathentry kind="lib" path="lib/httpcore-4.1.2.jar" />
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="output" path="classes"/>
</classpath>
View
@@ -6,8 +6,10 @@ dist
*.iws
*#
.#*
+test-output
node.id
rebalancing.slave.list
server.state
.version
.temp
+.idea
@@ -1,4 +1,4 @@
-#Fri Sep 18 15:20:52 BST 2009
+#Fri Dec 30 14:37:10 PST 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.codeComplete.argumentPrefixes=
org.eclipse.jdt.core.codeComplete.argumentSuffixes=
@@ -149,9 +149,12 @@ org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true
org.eclipse.jdt.core.formatter.indentation.size=4
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
View
@@ -12,6 +12,7 @@ Eric Evans
Geir Magnusson Jr.
Ismael Juma
Jakob Homan
+James Roper
Janne Hietamäki
Jay Kreps
Jonathan Traupman
View
6 NOTES
@@ -17,13 +17,13 @@ Commands:
put key value -- Associate the given value with the key.
get key -- Retrieve the value associated with the key.
delete key -- Remove all values associated with the key.
-locate key -- Determine which servers host the give key.
+preflist key -- Get node preference list for given key.
help -- Print this message.
exit -- Exit from this shell.
> put "hello" "there"
> get "hello"
version(0:1): "there"
-> locate "hello"
+> preflist "hello"
Node 0
host: localhost
port: 6666
@@ -71,4 +71,4 @@ Socket servers share threadpool?
A WireProtocol takes bytes and creates a voldemort request, and takes objects to create a voldemort response.
Likewise the client does the opposite
-Connector.handleRequest()
+Connector.handleRequest()
View
@@ -16,9 +16,9 @@
# limitations under the License.
#
-if [ $# -gt 1 ];
+if [ $# -gt 2 ];
then
- echo 'USAGE: bin/voldemort-server.sh [voldemort_home]'
+ echo 'USAGE: bin/voldemort-server.sh [voldemort_home] [voldemort_config_dir]'
exit 1
fi
View
@@ -34,4 +34,4 @@ tomcat.manager.password=tomcat
tomcat.context=/voldemort
## Release
-curr.release=0.90
+curr.release=0.90.1

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -85,12 +85,12 @@ def parse_nodes_from(doc)
nodes = []
doc.xpath("/cluster/server").each do |n|
node = VoldemortNode.new
- node.id = n.xpath("//id").text
- node.host = n.xpath("//host").text
- node.port = n.xpath("//socket-port").text
- node.http_port = n.xpath("//http_port").text
- node.admin_port = n.xpath("//admin-port").text
- node.partitions = n.xpath("//partitions").text
+ node.id = n.xpath("id").text
+ node.host = n.xpath("host").text
+ node.port = n.xpath("socket-port").text
+ node.http_port = n.xpath("http_port").text
+ node.admin_port = n.xpath("admin-port").text
+ node.partitions = n.xpath("partitions").text
nodes << node
end
nodes
@@ -128,15 +128,15 @@ def rebalance_connection_if_needed
def get(key)
self.rebalance_connection_if_needed
- self.get_from(self.db_name, key, true)
+ self.get_from(self.db_name, key, false)
end
def get_all(keys)
self.rebalance_connection_if_needed
- self.get_all_from(self.db_name, keys, true)
+ self.get_all_from(self.db_name, keys, false)
end
- def put(key, value, version = nil, route = true)
+ def put(key, value, version = nil, route = false)
self.rebalance_connection_if_needed
self.put_from(self.db_name, key, value, version, route)
end
@@ -28,7 +28,7 @@ def connect_to(host, port)
end
end
- def get_from(db_name, key, route = true)
+ def get_from(db_name, key, route = false)
request = VoldemortRequest.new
request.should_route = route
request.store = db_name
@@ -43,7 +43,7 @@ def get_from(db_name, key, route = true)
response
end
- def get_all_from(db_name, keys, route = true)
+ def get_all_from(db_name, keys, route = false)
request = VoldemortRequest.new
request.should_route = route
request.store = db_name
@@ -58,7 +58,7 @@ def get_all_from(db_name, keys, route = true)
response
end
- def put_from(db_name, key, value, version = nil, route = true)
+ def put_from(db_name, key, value, version = nil, route = false)
version = get_version(key) unless version
request = VoldemortRequest.new
request.should_route = route
@@ -80,7 +80,7 @@ def put_from(db_name, key, value, version = nil, route = true)
version
end
- def delete_from(db_name, key, version = nil, route = true)
+ def delete_from(db_name, key, version = nil, route = false)
version = get_version(key) unless version
request = VoldemortRequest.new
request.should_route = route
@@ -54,7 +54,7 @@ def read_slice(length, bytes)
def to_bytes(object)
bytes = ''
- newest_version = 0 # TODO get highest number from map
+ newest_version = type_def_versions.size > 0 ? (type_def_versions.size-1) : 0
type_def = @type_def_versions[newest_version]
if(@has_version)
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'voldemort-rb'
- s.version = '0.1.5'
+ s.version = '0.1.8'
s.summary = %{A Ruby client for the Voldemort distributed key value store}
s.description = %Q{voldemort-rb allows you to connect to the Voldemort descentralized key value store.}
s.authors = ["Alejandro Crosa"]
@@ -2,6 +2,7 @@
node.id=0
max.threads=100
+enable.repair=true
############### DB options ######################
@@ -4,6 +4,7 @@ bdb.flush.transactions=false
bdb.cache.size=100MB
max.threads=100
+enable.repair=true
http.enable=true
socket.enable=true
@@ -0,0 +1,183 @@
+package voldemort.collections;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import voldemort.client.StoreClient;
+import voldemort.client.UpdateAction;
+import voldemort.versioning.ObsoleteVersionException;
+import voldemort.versioning.Versioned;
+
+/**
+ * Adds a node E to the front of the list identified by K. Inserts the node to
+ * the front of the list, with id 0, and then modifies the pointers for the
+ * first node and next node accordingly.
+ *
+ * @param <E> the type of the value
+ * @param <K> the type of the key identifying the list
+ */
+public class AddNodeAction<K, E> extends UpdateAction<Map<String, Object>, Map<String, Object>> {
+
+ private final K _key;
+ private final E _value;
+
+ @SuppressWarnings("unchecked")
+ private StoreClient<Map<String, Object>, Map<String, Object>> _storeClient = null;
+ private Map<Integer, Map<String, Object>> _rollback = new HashMap<Integer, Map<String, Object>>();
+
+ public AddNodeAction(K key, E value) {
+ _key = key;
+ _value = value;
+ }
+
+ @Override
+ public void rollback() {
+ if(_storeClient == null)
+ return;
+
+ for(Entry<Integer, Map<String, Object>> entry: _rollback.entrySet()) {
+ VListKey<K> key = new VListKey<K>(_key, entry.getKey());
+ _storeClient.put(key.mapValue(), entry.getValue());
+ }
+ }
+
+ /**
+ * @throws ObsoleteVersionException if a concurrent modification (remove or
+ * another add) has not completed modifying the structure.
+ * @throws ArrayIndexOutOfBoundsException if no more ids left to identify
+ * object
+ */
+ @Override
+ public void update(StoreClient<Map<String, Object>, Map<String, Object>> storeClient) {
+ _storeClient = storeClient;
+ VListKey<K> newKey = new VListKey<K>(_key, 0);
+ Versioned<Map<String, Object>> firstNodeMap = storeClient.get(newKey.mapValue());
+ // adding first node of the list
+ if(firstNodeMap == null) {
+ Versioned<Map<String, Object>> newNode = new Versioned<Map<String, Object>>((new VListNode<E>(_value,
+ 0,
+ VStack.NULL_ID,
+ VStack.NULL_ID,
+ true)).mapValue());
+ // throws ObsoleteVersionException if another process has created a
+ // new node already
+ storeClient.put(newKey.mapValue(), newNode);
+ } else // add to front of list
+ {
+ Versioned<VListNode<E>> firstNode = new Versioned<VListNode<E>>(VListNode.<E> valueOf(firstNodeMap.getValue()),
+ firstNodeMap.getVersion());
+
+ if(!firstNode.getValue().isStable()) {
+ throw new ObsoleteVersionException("cannot add when list node is not stable");
+ }
+
+ // set stable flag to false
+ Map<String, Object> tmpMap = new HashMap<String, Object>(firstNodeMap.getValue());
+ tmpMap.put(VListNode.STABLE, false);
+ storeClient.put(newKey.mapValue(),
+ new Versioned<Map<String, Object>>(tmpMap, firstNodeMap.getVersion()));
+ _rollback.put(0, firstNodeMap.getValue());
+
+ int newId;
+ int nextId = firstNode.getValue().getNextId();
+ newId = (nextId == VStack.NULL_ID) ? 1 : nextId + 1;
+ if(newId == Integer.MAX_VALUE)
+ throw new ArrayIndexOutOfBoundsException(newId + " out of bounds");
+
+ Versioned<VListNode<E>> nextNode = null;
+ VListKey<K> nextKey = new VListKey<K>(_key, nextId);
+ if(nextId != VStack.NULL_ID) {
+ Versioned<Map<String, Object>> nextNodeMap = storeClient.get(nextKey.mapValue());
+ if(nextNodeMap == null)
+ throw new ObsoleteVersionException("possible concurrent modification");
+ nextNode = new Versioned<VListNode<E>>(VListNode.<E> valueOf(nextNodeMap.getValue()),
+ nextNodeMap.getVersion());
+ if(!nextNode.getValue().isStable()) {
+ throw new ObsoleteVersionException("cannot add when list node is not stable");
+ }
+
+ // set stable flag to false
+ tmpMap = new HashMap<String, Object>(nextNode.getValue().mapValue());
+ tmpMap.put(VListNode.STABLE, false);
+ storeClient.put(nextKey.mapValue(),
+ new Versioned<Map<String, Object>>(tmpMap, nextNode.getVersion()));
+ _rollback.put(nextId, nextNode.getValue().mapValue());
+ }
+
+ // insert new node
+ Map<String, Object> newNode = (new VListNode<E>(_value, 0, VStack.NULL_ID, newId, true)).mapValue();
+ // don't need to specify versioned because node is already "locked"
+ storeClient.put(newKey.mapValue(), newNode);
+
+ // move first node to next index
+ VListKey<K> firstKey = new VListKey<K>(_key, newId);
+ firstNode = new Versioned<VListNode<E>>(new VListNode<E>(firstNode.getValue()
+ .getValue(),
+ newId,
+ 0,
+ firstNode.getValue()
+ .getNextId(),
+ true));
+ // don't need to specify versioned because node is already "locked"
+ storeClient.put(firstKey.mapValue(), firstNode.getValue().mapValue());
+
+ // redefine previous pointer on next node
+ if(nextNode != null) {
+ if(!storeClient.applyUpdate(new UpdateNextNode<K, E>(nextNode, nextKey, newId)))
+ throw new ObsoleteVersionException("unable to update node");
+ }
+ }
+ }
+
+ /**
+ * Updates a the previous pointer of a node specified by key to a newId.
+ *
+ * @param <K>
+ * @param <E>
+ */
+ private static class UpdateNextNode<K, E> extends
+ UpdateAction<Map<String, Object>, Map<String, Object>> {
+
+ private final VListKey<K> _key;
+ private final int _newId;
+
+ private Versioned<VListNode<E>> _listNode;
+ private int numCalls = 0;
+
+ /**
+ * @param listNode
+ * @param key
+ * @param newId
+ */
+ public UpdateNextNode(Versioned<VListNode<E>> listNode, VListKey<K> key, int newId) {
+ _listNode = listNode;
+ _key = key;
+ _newId = newId;
+ }
+
+ @Override
+ public void update(StoreClient<Map<String, Object>, Map<String, Object>> storeClient) {
+ if(numCalls > 0) {
+ // TODO jko maybe delete this if unnecessary
+ Versioned<Map<String, Object>> nextNodeMap = storeClient.get(_key.mapValue());
+ if(nextNodeMap == null)
+ throw new ObsoleteVersionException("possible concurrent modification");
+ _listNode = new Versioned<VListNode<E>>(VListNode.<E> valueOf(nextNodeMap.getValue()),
+ nextNodeMap.getVersion());
+ }
+
+ VListNode<E> nodeValue = _listNode.getValue();
+ _listNode.setObject(new VListNode<E>(nodeValue.getValue(),
+ nodeValue.getId(),
+ _newId,
+ nodeValue.getNextId(),
+ true));
+ Map<String, Object> nextNodeMap = _listNode.getValue().mapValue();
+ storeClient.put(_key.mapValue(), nextNodeMap);
+
+ numCalls++;
+ }
+
+ }
+}
Oops, something went wrong.

0 comments on commit 958f8cb

Please sign in to comment.