Browse files

Added hasKey() ability to Voldemort

  • Loading branch information...
1 parent 65d6265 commit f34b9aed2fb99ef852aac83b37c66c444b8e6085 @rsumbaly committed Sep 14, 2012
Showing with 26,824 additions and 7,558 deletions.
  1. +4 −4 .classpath
  2. +2 −1 clients/python/voldemort/protocol/slop_pb2.py
  3. +60 −2 clients/python/voldemort/protocol/voldemort_admin_pb2.py
  4. +175 −26 clients/python/voldemort/protocol/voldemort_client_pb2.py
  5. +4 −0 contrib/krati/src/java/voldemort/store/krati/KratiStorageEngine.java
  6. +37 −9 src/java/voldemort/VoldemortClientShell.java
  7. +25 −0 src/java/voldemort/client/DefaultStoreClient.java
  8. +5 −0 src/java/voldemort/client/LazyStoreClient.java
  9. +10 −0 src/java/voldemort/client/StoreClient.java
  10. +3 −0 src/java/voldemort/client/TimeoutConfig.java
  11. +10 −0 src/java/voldemort/client/protocol/RequestFormat.java
  12. +36 −0 src/java/voldemort/client/protocol/pb/ProtoBuffClientRequestFormat.java
  13. +18,003 −5,279 src/java/voldemort/client/protocol/pb/VAdminProto.java
  14. +7,026 −1,969 src/java/voldemort/client/protocol/pb/VProto.java
  15. +43 −0 src/java/voldemort/client/protocol/vold/VoldemortNativeClientRequestFormat.java
  16. +2 −0 src/java/voldemort/common/VoldemortOpCode.java
  17. +341 −131 src/java/voldemort/serialization/VSlopProto.java
  18. +0 −113 src/java/voldemort/serialization/VoldemortOperation.java
  19. +53 −3 src/java/voldemort/server/protocol/vold/VoldemortNativeRequestHandler.java
  20. +5 −0 src/java/voldemort/store/DelegatingStore.java
  21. +17 −2 src/java/voldemort/store/Store.java
  22. +10 −0 src/java/voldemort/store/StoreUtils.java
  23. +5 −0 src/java/voldemort/store/bdb/BdbStorageEngine.java
  24. +13 −4 src/java/voldemort/store/compress/CompressingStore.java
  25. +5 −1 src/java/voldemort/store/configuration/ConfigurationStorageEngine.java
  26. +20 −0 src/java/voldemort/store/http/HttpStore.java
  27. +18 −3 src/java/voldemort/store/logging/LoggingStore.java
  28. +6 −1 src/java/voldemort/store/memory/InMemoryStorageEngine.java
  29. +5 −0 src/java/voldemort/store/metadata/MetadataStore.java
  30. +6 −1 src/java/voldemort/store/mysql/MysqlStorageEngine.java
  31. +4 −0 src/java/voldemort/store/nonblockingstore/NonblockingStore.java
  32. +11 −0 src/java/voldemort/store/nonblockingstore/ThreadPoolBasedNonblockingStoreImpl.java
  33. +21 −0 src/java/voldemort/store/readonly/ReadOnlyStorageEngine.java
  34. +85 −0 src/java/voldemort/store/routed/HasKeysPipelineData.java
  35. +2 −1 src/java/voldemort/store/routed/Pipeline.java
  36. +84 −0 src/java/voldemort/store/routed/PipelineRoutedStore.java
  37. +4 −0 src/java/voldemort/store/routed/ThreadPoolRoutedStore.java
  38. +157 −0 src/java/voldemort/store/routed/action/HasKeysConfigureNodes.java
  39. +164 −0 src/java/voldemort/store/routed/action/PerformParallelHasKeysRequests.java
  40. +190 −0 src/java/voldemort/store/routed/action/PerformSerialHasKeysRequests.java
  41. +11 −0 src/java/voldemort/store/serialized/SerializingStore.java
  42. +4 −0 src/java/voldemort/store/slop/SlopStorageEngine.java
  43. +29 −3 src/java/voldemort/store/socket/SocketStore.java
  44. +56 −0 src/java/voldemort/store/socket/clientrequest/HasKeysClientRequest.java
  45. +6 −2 src/java/voldemort/store/views/ViewStorageEngine.java
  46. +17 −1 src/proto/voldemort-client.proto
  47. +4 −0 test/common/voldemort/cluster/failuredetector/MutableStoreVerifier.java
  48. +7 −2 test/common/voldemort/store/DoNothingStore.java
  49. +5 −0 test/common/voldemort/store/FailingReadsStore.java
  50. +5 −0 test/common/voldemort/store/FailingStore.java
  51. +4 −0 test/integration/voldemort/store/noop/NoopStorageEngine.java
  52. +5 −0 test/integration/voldemort/store/pausable/PausableStorageEngine.java
View
8 .classpath
@@ -37,9 +37,7 @@
<classpathentry kind="lib" path="lib/commons-logging-1.1.1.jar"/>
<classpathentry kind="lib" path="lib/jline-0.9.94.jar"/>
<classpathentry kind="lib" path="lib/commons-pool-1.5.2.jar"/>
- <classpathentry kind="lib" path="lib/protobuf-java-2.3.0.jar"/>
<classpathentry kind="lib" path="contrib/ec2-testing/lib/typica.jar"/>
- <classpathentry kind="lib" path="lib/google-collect-1.0.jar"/>
<classpathentry kind="lib" path="lib/je-4.0.92.jar"/>
<classpathentry kind="lib" path="lib/paranamer-2.1.jar"/>
<classpathentry kind="lib" path="lib/jackson-mapper-asl-1.4.0.jar"/>
@@ -51,8 +49,10 @@
<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="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="lib" path="lib/google-collect-1.0-rc2.jar"/>
+ <classpathentry kind="lib" path="lib/protobuf-java-2.3.0.jar"/>
<classpathentry kind="output" path="classes"/>
</classpath>
View
3 clients/python/voldemort/protocol/slop_pb2.py
@@ -7,6 +7,7 @@
# @@protoc_insertion_point(imports)
+
DESCRIPTOR = descriptor.FileDescriptor(
name='slop.proto',
package='voldemort',
@@ -77,7 +78,7 @@
serialized_end=127,
)
-
+DESCRIPTOR.message_types_by_name['Slop'] = _SLOP
class Slop(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
View
62 clients/python/voldemort/protocol/voldemort_admin_pb2.py
@@ -7,6 +7,8 @@
# @@protoc_insertion_point(imports)
+import voldemort_client_pb2
+
DESCRIPTOR = descriptor.FileDescriptor(
name='voldemort-admin.proto',
package='voldemort',
@@ -2415,8 +2417,6 @@
serialized_end=6968,
)
-import voldemort_client_pb2
-
_GETMETADATARESPONSE.fields_by_name['version'].message_type = voldemort_client_pb2._VERSIONED
_GETMETADATARESPONSE.fields_by_name['error'].message_type = voldemort_client_pb2._ERROR
_UPDATEMETADATAREQUEST.fields_by_name['versioned'].message_type = voldemort_client_pb2._VERSIONED
@@ -2492,6 +2492,64 @@
_VOLDEMORTADMINREQUEST.fields_by_name['delete_store_rebalance_state'].message_type = _DELETESTOREREBALANCESTATEREQUEST
_VOLDEMORTADMINREQUEST.fields_by_name['native_backup'].message_type = _NATIVEBACKUPREQUEST
_VOLDEMORTADMINREQUEST.fields_by_name['reserve_memory'].message_type = _RESERVEMEMORYREQUEST
+DESCRIPTOR.message_types_by_name['GetMetadataRequest'] = _GETMETADATAREQUEST
+DESCRIPTOR.message_types_by_name['GetMetadataResponse'] = _GETMETADATARESPONSE
+DESCRIPTOR.message_types_by_name['UpdateMetadataRequest'] = _UPDATEMETADATAREQUEST
+DESCRIPTOR.message_types_by_name['UpdateMetadataResponse'] = _UPDATEMETADATARESPONSE
+DESCRIPTOR.message_types_by_name['FileEntry'] = _FILEENTRY
+DESCRIPTOR.message_types_by_name['PartitionEntry'] = _PARTITIONENTRY
+DESCRIPTOR.message_types_by_name['UpdatePartitionEntriesRequest'] = _UPDATEPARTITIONENTRIESREQUEST
+DESCRIPTOR.message_types_by_name['UpdatePartitionEntriesResponse'] = _UPDATEPARTITIONENTRIESRESPONSE
+DESCRIPTOR.message_types_by_name['VoldemortFilter'] = _VOLDEMORTFILTER
+DESCRIPTOR.message_types_by_name['UpdateSlopEntriesRequest'] = _UPDATESLOPENTRIESREQUEST
+DESCRIPTOR.message_types_by_name['UpdateSlopEntriesResponse'] = _UPDATESLOPENTRIESRESPONSE
+DESCRIPTOR.message_types_by_name['FetchPartitionFilesRequest'] = _FETCHPARTITIONFILESREQUEST
+DESCRIPTOR.message_types_by_name['FetchPartitionEntriesRequest'] = _FETCHPARTITIONENTRIESREQUEST
+DESCRIPTOR.message_types_by_name['FetchPartitionEntriesResponse'] = _FETCHPARTITIONENTRIESRESPONSE
+DESCRIPTOR.message_types_by_name['DeletePartitionEntriesRequest'] = _DELETEPARTITIONENTRIESREQUEST
+DESCRIPTOR.message_types_by_name['DeletePartitionEntriesResponse'] = _DELETEPARTITIONENTRIESRESPONSE
+DESCRIPTOR.message_types_by_name['InitiateFetchAndUpdateRequest'] = _INITIATEFETCHANDUPDATEREQUEST
+DESCRIPTOR.message_types_by_name['AsyncOperationStatusRequest'] = _ASYNCOPERATIONSTATUSREQUEST
+DESCRIPTOR.message_types_by_name['AsyncOperationStopRequest'] = _ASYNCOPERATIONSTOPREQUEST
+DESCRIPTOR.message_types_by_name['AsyncOperationStopResponse'] = _ASYNCOPERATIONSTOPRESPONSE
+DESCRIPTOR.message_types_by_name['AsyncOperationListRequest'] = _ASYNCOPERATIONLISTREQUEST
+DESCRIPTOR.message_types_by_name['AsyncOperationListResponse'] = _ASYNCOPERATIONLISTRESPONSE
+DESCRIPTOR.message_types_by_name['PartitionTuple'] = _PARTITIONTUPLE
+DESCRIPTOR.message_types_by_name['PerStorePartitionTuple'] = _PERSTOREPARTITIONTUPLE
+DESCRIPTOR.message_types_by_name['RebalancePartitionInfoMap'] = _REBALANCEPARTITIONINFOMAP
+DESCRIPTOR.message_types_by_name['InitiateRebalanceNodeRequest'] = _INITIATEREBALANCENODEREQUEST
+DESCRIPTOR.message_types_by_name['InitiateRebalanceNodeOnDonorRequest'] = _INITIATEREBALANCENODEONDONORREQUEST
+DESCRIPTOR.message_types_by_name['AsyncOperationStatusResponse'] = _ASYNCOPERATIONSTATUSRESPONSE
+DESCRIPTOR.message_types_by_name['TruncateEntriesRequest'] = _TRUNCATEENTRIESREQUEST
+DESCRIPTOR.message_types_by_name['TruncateEntriesResponse'] = _TRUNCATEENTRIESRESPONSE
+DESCRIPTOR.message_types_by_name['AddStoreRequest'] = _ADDSTOREREQUEST
+DESCRIPTOR.message_types_by_name['AddStoreResponse'] = _ADDSTORERESPONSE
+DESCRIPTOR.message_types_by_name['DeleteStoreRequest'] = _DELETESTOREREQUEST
+DESCRIPTOR.message_types_by_name['DeleteStoreResponse'] = _DELETESTORERESPONSE
+DESCRIPTOR.message_types_by_name['FetchStoreRequest'] = _FETCHSTOREREQUEST
+DESCRIPTOR.message_types_by_name['SwapStoreRequest'] = _SWAPSTOREREQUEST
+DESCRIPTOR.message_types_by_name['SwapStoreResponse'] = _SWAPSTORERESPONSE
+DESCRIPTOR.message_types_by_name['RollbackStoreRequest'] = _ROLLBACKSTOREREQUEST
+DESCRIPTOR.message_types_by_name['RollbackStoreResponse'] = _ROLLBACKSTORERESPONSE
+DESCRIPTOR.message_types_by_name['RepairJobRequest'] = _REPAIRJOBREQUEST
+DESCRIPTOR.message_types_by_name['RepairJobResponse'] = _REPAIRJOBRESPONSE
+DESCRIPTOR.message_types_by_name['ROStoreVersionDirMap'] = _ROSTOREVERSIONDIRMAP
+DESCRIPTOR.message_types_by_name['GetROMaxVersionDirRequest'] = _GETROMAXVERSIONDIRREQUEST
+DESCRIPTOR.message_types_by_name['GetROMaxVersionDirResponse'] = _GETROMAXVERSIONDIRRESPONSE
+DESCRIPTOR.message_types_by_name['GetROCurrentVersionDirRequest'] = _GETROCURRENTVERSIONDIRREQUEST
+DESCRIPTOR.message_types_by_name['GetROCurrentVersionDirResponse'] = _GETROCURRENTVERSIONDIRRESPONSE
+DESCRIPTOR.message_types_by_name['GetROStorageFormatRequest'] = _GETROSTORAGEFORMATREQUEST
+DESCRIPTOR.message_types_by_name['GetROStorageFormatResponse'] = _GETROSTORAGEFORMATRESPONSE
+DESCRIPTOR.message_types_by_name['FailedFetchStoreRequest'] = _FAILEDFETCHSTOREREQUEST
+DESCRIPTOR.message_types_by_name['FailedFetchStoreResponse'] = _FAILEDFETCHSTORERESPONSE
+DESCRIPTOR.message_types_by_name['RebalanceStateChangeRequest'] = _REBALANCESTATECHANGEREQUEST
+DESCRIPTOR.message_types_by_name['RebalanceStateChangeResponse'] = _REBALANCESTATECHANGERESPONSE
+DESCRIPTOR.message_types_by_name['DeleteStoreRebalanceStateRequest'] = _DELETESTOREREBALANCESTATEREQUEST
+DESCRIPTOR.message_types_by_name['DeleteStoreRebalanceStateResponse'] = _DELETESTOREREBALANCESTATERESPONSE
+DESCRIPTOR.message_types_by_name['NativeBackupRequest'] = _NATIVEBACKUPREQUEST
+DESCRIPTOR.message_types_by_name['ReserveMemoryRequest'] = _RESERVEMEMORYREQUEST
+DESCRIPTOR.message_types_by_name['ReserveMemoryResponse'] = _RESERVEMEMORYRESPONSE
+DESCRIPTOR.message_types_by_name['VoldemortAdminRequest'] = _VOLDEMORTADMINREQUEST
class GetMetadataRequest(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
View
201 clients/python/voldemort/protocol/voldemort_client_pb2.py
@@ -7,10 +7,11 @@
# @@protoc_insertion_point(imports)
+
DESCRIPTOR = descriptor.FileDescriptor(
name='voldemort-client.proto',
package='voldemort',
- serialized_pb='\n\x16voldemort-client.proto\x12\tvoldemort\".\n\nClockEntry\x12\x0f\n\x07node_id\x18\x01 \x02(\x05\x12\x0f\n\x07version\x18\x02 \x02(\x03\"H\n\x0bVectorClock\x12&\n\x07\x65ntries\x18\x01 \x03(\x0b\x32\x15.voldemort.ClockEntry\x12\x11\n\ttimestamp\x18\x02 \x01(\x03\"C\n\tVersioned\x12\r\n\x05value\x18\x01 \x02(\x0c\x12\'\n\x07version\x18\x02 \x02(\x0b\x32\x16.voldemort.VectorClock\"2\n\x05\x45rror\x12\x12\n\nerror_code\x18\x01 \x02(\x05\x12\x15\n\rerror_message\x18\x02 \x02(\t\"D\n\rKeyedVersions\x12\x0b\n\x03key\x18\x01 \x02(\x0c\x12&\n\x08versions\x18\x02 \x03(\x0b\x32\x14.voldemort.Versioned\"-\n\nGetRequest\x12\x0b\n\x03key\x18\x01 \x01(\x0c\x12\x12\n\ntransforms\x18\x02 \x01(\x0c\"W\n\x0bGetResponse\x12\'\n\tversioned\x18\x01 \x03(\x0b\x32\x14.voldemort.Versioned\x12\x1f\n\x05\x65rror\x18\x02 \x01(\x0b\x32\x10.voldemort.Error\"_\n\x12GetVersionResponse\x12(\n\x08versions\x18\x01 \x03(\x0b\x32\x16.voldemort.VectorClock\x12\x1f\n\x05\x65rror\x18\x02 \x01(\x0b\x32\x10.voldemort.Error\"\x8e\x01\n\rGetAllRequest\x12\x0c\n\x04keys\x18\x01 \x03(\x0c\x12<\n\ntransforms\x18\x02 \x03(\x0b\x32(.voldemort.GetAllRequest.GetAllTransform\x1a\x31\n\x0fGetAllTransform\x12\x0b\n\x03key\x18\x01 \x02(\x0c\x12\x11\n\ttransform\x18\x02 \x02(\x0c\"[\n\x0eGetAllResponse\x12(\n\x06values\x18\x01 \x03(\x0b\x32\x18.voldemort.KeyedVersions\x12\x1f\n\x05\x65rror\x18\x02 \x01(\x0b\x32\x10.voldemort.Error\"V\n\nPutRequest\x12\x0b\n\x03key\x18\x01 \x02(\x0c\x12\'\n\tversioned\x18\x02 \x02(\x0b\x32\x14.voldemort.Versioned\x12\x12\n\ntransforms\x18\x03 \x01(\x0c\".\n\x0bPutResponse\x12\x1f\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x10.voldemort.Error\"E\n\rDeleteRequest\x12\x0b\n\x03key\x18\x01 \x02(\x0c\x12\'\n\x07version\x18\x02 \x02(\x0b\x32\x16.voldemort.VectorClock\"B\n\x0e\x44\x65leteResponse\x12\x0f\n\x07success\x18\x01 \x02(\x08\x12\x1f\n\x05\x65rror\x18\x02 \x01(\x0b\x32\x10.voldemort.Error\"\x9a\x02\n\x10VoldemortRequest\x12$\n\x04type\x18\x01 \x02(\x0e\x32\x16.voldemort.RequestType\x12\x1b\n\x0cshould_route\x18\x02 \x02(\x08:\x05\x66\x61lse\x12\r\n\x05store\x18\x03 \x02(\t\x12\"\n\x03get\x18\x04 \x01(\x0b\x32\x15.voldemort.GetRequest\x12(\n\x06getAll\x18\x05 \x01(\x0b\x32\x18.voldemort.GetAllRequest\x12\"\n\x03put\x18\x06 \x01(\x0b\x32\x15.voldemort.PutRequest\x12(\n\x06\x64\x65lete\x18\x07 \x01(\x0b\x32\x18.voldemort.DeleteRequest\x12\x18\n\x10requestRouteType\x18\x08 \x01(\x05*I\n\x0bRequestType\x12\x07\n\x03GET\x10\x00\x12\x0b\n\x07GET_ALL\x10\x01\x12\x07\n\x03PUT\x10\x02\x12\n\n\x06\x44\x45LETE\x10\x03\x12\x0f\n\x0bGET_VERSION\x10\x04\x42(\n\x1cvoldemort.client.protocol.pbB\x06VProtoH\x01')
+ serialized_pb='\n\x16voldemort-client.proto\x12\tvoldemort\".\n\nClockEntry\x12\x0f\n\x07node_id\x18\x01 \x02(\x05\x12\x0f\n\x07version\x18\x02 \x02(\x03\"H\n\x0bVectorClock\x12&\n\x07\x65ntries\x18\x01 \x03(\x0b\x32\x15.voldemort.ClockEntry\x12\x11\n\ttimestamp\x18\x02 \x01(\x03\"C\n\tVersioned\x12\r\n\x05value\x18\x01 \x02(\x0c\x12\'\n\x07version\x18\x02 \x02(\x0b\x32\x16.voldemort.VectorClock\"2\n\x05\x45rror\x12\x12\n\nerror_code\x18\x01 \x02(\x05\x12\x15\n\rerror_message\x18\x02 \x02(\t\"D\n\rKeyedVersions\x12\x0b\n\x03key\x18\x01 \x02(\x0c\x12&\n\x08versions\x18\x02 \x03(\x0b\x32\x14.voldemort.Versioned\",\n\x0cKeyedBoolean\x12\x0b\n\x03key\x18\x01 \x02(\x0c\x12\x0f\n\x07present\x18\x02 \x02(\x08\"-\n\nGetRequest\x12\x0b\n\x03key\x18\x01 \x01(\x0c\x12\x12\n\ntransforms\x18\x02 \x01(\x0c\"W\n\x0bGetResponse\x12\'\n\tversioned\x18\x01 \x03(\x0b\x32\x14.voldemort.Versioned\x12\x1f\n\x05\x65rror\x18\x02 \x01(\x0b\x32\x10.voldemort.Error\"_\n\x12GetVersionResponse\x12(\n\x08versions\x18\x01 \x03(\x0b\x32\x16.voldemort.VectorClock\x12\x1f\n\x05\x65rror\x18\x02 \x01(\x0b\x32\x10.voldemort.Error\"\x8e\x01\n\rGetAllRequest\x12\x0c\n\x04keys\x18\x01 \x03(\x0c\x12<\n\ntransforms\x18\x02 \x03(\x0b\x32(.voldemort.GetAllRequest.GetAllTransform\x1a\x31\n\x0fGetAllTransform\x12\x0b\n\x03key\x18\x01 \x02(\x0c\x12\x11\n\ttransform\x18\x02 \x02(\x0c\"[\n\x0eGetAllResponse\x12(\n\x06values\x18\x01 \x03(\x0b\x32\x18.voldemort.KeyedVersions\x12\x1f\n\x05\x65rror\x18\x02 \x01(\x0b\x32\x10.voldemort.Error\"\x1e\n\x0eHasKeysRequest\x12\x0c\n\x04keys\x18\x01 \x03(\x0c\"[\n\x0fHasKeysResponse\x12\'\n\x06values\x18\x01 \x03(\x0b\x32\x17.voldemort.KeyedBoolean\x12\x1f\n\x05\x65rror\x18\x02 \x01(\x0b\x32\x10.voldemort.Error\"V\n\nPutRequest\x12\x0b\n\x03key\x18\x01 \x02(\x0c\x12\'\n\tversioned\x18\x02 \x02(\x0b\x32\x14.voldemort.Versioned\x12\x12\n\ntransforms\x18\x03 \x01(\x0c\".\n\x0bPutResponse\x12\x1f\n\x05\x65rror\x18\x01 \x01(\x0b\x32\x10.voldemort.Error\"E\n\rDeleteRequest\x12\x0b\n\x03key\x18\x01 \x02(\x0c\x12\'\n\x07version\x18\x02 \x02(\x0b\x32\x16.voldemort.VectorClock\"B\n\x0e\x44\x65leteResponse\x12\x0f\n\x07success\x18\x01 \x02(\x08\x12\x1f\n\x05\x65rror\x18\x02 \x01(\x0b\x32\x10.voldemort.Error\"\xc6\x02\n\x10VoldemortRequest\x12$\n\x04type\x18\x01 \x02(\x0e\x32\x16.voldemort.RequestType\x12\x1b\n\x0cshould_route\x18\x02 \x02(\x08:\x05\x66\x61lse\x12\r\n\x05store\x18\x03 \x02(\t\x12\"\n\x03get\x18\x04 \x01(\x0b\x32\x15.voldemort.GetRequest\x12(\n\x06getAll\x18\x05 \x01(\x0b\x32\x18.voldemort.GetAllRequest\x12\"\n\x03put\x18\x06 \x01(\x0b\x32\x15.voldemort.PutRequest\x12(\n\x06\x64\x65lete\x18\x07 \x01(\x0b\x32\x18.voldemort.DeleteRequest\x12\x18\n\x10requestRouteType\x18\x08 \x01(\x05\x12*\n\x07hasKeys\x18\t \x01(\x0b\x32\x19.voldemort.HasKeysRequest*W\n\x0bRequestType\x12\x07\n\x03GET\x10\x00\x12\x0b\n\x07GET_ALL\x10\x01\x12\x07\n\x03PUT\x10\x02\x12\n\n\x06\x44\x45LETE\x10\x03\x12\x0f\n\x0bGET_VERSION\x10\x04\x12\x0c\n\x08HAS_KEYS\x10\x05\x42(\n\x1cvoldemort.client.protocol.pbB\x06VProtoH\x01')
_REQUESTTYPE = descriptor.EnumDescriptor(
name='RequestType',
@@ -38,11 +39,15 @@
name='GET_VERSION', index=4, number=4,
options=None,
type=None),
+ descriptor.EnumValueDescriptor(
+ name='HAS_KEYS', index=5, number=5,
+ options=None,
+ type=None),
],
containing_type=None,
options=None,
- serialized_start=1381,
- serialized_end=1454,
+ serialized_start=1596,
+ serialized_end=1683,
)
@@ -51,6 +56,7 @@
PUT = 2
DELETE = 3
GET_VERSION = 4
+HAS_KEYS = 5
@@ -229,6 +235,41 @@
)
+_KEYEDBOOLEAN = descriptor.Descriptor(
+ name='KeyedBoolean',
+ full_name='voldemort.KeyedBoolean',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ descriptor.FieldDescriptor(
+ name='key', full_name='voldemort.KeyedBoolean.key', index=0,
+ number=1, type=12, cpp_type=9, label=2,
+ has_default_value=False, default_value="",
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None),
+ descriptor.FieldDescriptor(
+ name='present', full_name='voldemort.KeyedBoolean.present', index=1,
+ number=2, type=8, cpp_type=7, label=2,
+ has_default_value=False, default_value=False,
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None),
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ options=None,
+ is_extendable=False,
+ extension_ranges=[],
+ serialized_start=350,
+ serialized_end=394,
+)
+
+
_GETREQUEST = descriptor.Descriptor(
name='GetRequest',
full_name='voldemort.GetRequest',
@@ -259,8 +300,8 @@
options=None,
is_extendable=False,
extension_ranges=[],
- serialized_start=350,
- serialized_end=395,
+ serialized_start=396,
+ serialized_end=441,
)
@@ -294,8 +335,8 @@
options=None,
is_extendable=False,
extension_ranges=[],
- serialized_start=397,
- serialized_end=484,
+ serialized_start=443,
+ serialized_end=530,
)
@@ -329,8 +370,8 @@
options=None,
is_extendable=False,
extension_ranges=[],
- serialized_start=486,
- serialized_end=581,
+ serialized_start=532,
+ serialized_end=627,
)
@@ -364,8 +405,8 @@
options=None,
is_extendable=False,
extension_ranges=[],
- serialized_start=677,
- serialized_end=726,
+ serialized_start=723,
+ serialized_end=772,
)
_GETALLREQUEST = descriptor.Descriptor(
@@ -398,8 +439,8 @@
options=None,
is_extendable=False,
extension_ranges=[],
- serialized_start=584,
- serialized_end=726,
+ serialized_start=630,
+ serialized_end=772,
)
@@ -433,8 +474,71 @@
options=None,
is_extendable=False,
extension_ranges=[],
- serialized_start=728,
- serialized_end=819,
+ serialized_start=774,
+ serialized_end=865,
+)
+
+
+_HASKEYSREQUEST = descriptor.Descriptor(
+ name='HasKeysRequest',
+ full_name='voldemort.HasKeysRequest',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ descriptor.FieldDescriptor(
+ name='keys', full_name='voldemort.HasKeysRequest.keys', index=0,
+ number=1, type=12, cpp_type=9, label=3,
+ has_default_value=False, default_value=[],
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None),
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ options=None,
+ is_extendable=False,
+ extension_ranges=[],
+ serialized_start=867,
+ serialized_end=897,
+)
+
+
+_HASKEYSRESPONSE = descriptor.Descriptor(
+ name='HasKeysResponse',
+ full_name='voldemort.HasKeysResponse',
+ filename=None,
+ file=DESCRIPTOR,
+ containing_type=None,
+ fields=[
+ descriptor.FieldDescriptor(
+ name='values', full_name='voldemort.HasKeysResponse.values', index=0,
+ number=1, type=11, cpp_type=10, label=3,
+ has_default_value=False, default_value=[],
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None),
+ descriptor.FieldDescriptor(
+ name='error', full_name='voldemort.HasKeysResponse.error', index=1,
+ number=2, type=11, cpp_type=10, label=1,
+ has_default_value=False, default_value=None,
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None),
+ ],
+ extensions=[
+ ],
+ nested_types=[],
+ enum_types=[
+ ],
+ options=None,
+ is_extendable=False,
+ extension_ranges=[],
+ serialized_start=899,
+ serialized_end=990,
)
@@ -475,8 +579,8 @@
options=None,
is_extendable=False,
extension_ranges=[],
- serialized_start=821,
- serialized_end=907,
+ serialized_start=992,
+ serialized_end=1078,
)
@@ -503,8 +607,8 @@
options=None,
is_extendable=False,
extension_ranges=[],
- serialized_start=909,
- serialized_end=955,
+ serialized_start=1080,
+ serialized_end=1126,
)
@@ -538,8 +642,8 @@
options=None,
is_extendable=False,
extension_ranges=[],
- serialized_start=957,
- serialized_end=1026,
+ serialized_start=1128,
+ serialized_end=1197,
)
@@ -573,8 +677,8 @@
options=None,
is_extendable=False,
extension_ranges=[],
- serialized_start=1028,
- serialized_end=1094,
+ serialized_start=1199,
+ serialized_end=1265,
)
@@ -641,6 +745,13 @@
message_type=None, enum_type=None, containing_type=None,
is_extension=False, extension_scope=None,
options=None),
+ descriptor.FieldDescriptor(
+ name='hasKeys', full_name='voldemort.VoldemortRequest.hasKeys', index=8,
+ number=9, type=11, cpp_type=10, label=1,
+ has_default_value=False, default_value=None,
+ message_type=None, enum_type=None, containing_type=None,
+ is_extension=False, extension_scope=None,
+ options=None),
],
extensions=[
],
@@ -650,11 +761,10 @@
options=None,
is_extendable=False,
extension_ranges=[],
- serialized_start=1097,
- serialized_end=1379,
+ serialized_start=1268,
+ serialized_end=1594,
)
-
_VECTORCLOCK.fields_by_name['entries'].message_type = _CLOCKENTRY
_VERSIONED.fields_by_name['version'].message_type = _VECTORCLOCK
_KEYEDVERSIONS.fields_by_name['versions'].message_type = _VERSIONED
@@ -666,6 +776,8 @@
_GETALLREQUEST.fields_by_name['transforms'].message_type = _GETALLREQUEST_GETALLTRANSFORM
_GETALLRESPONSE.fields_by_name['values'].message_type = _KEYEDVERSIONS
_GETALLRESPONSE.fields_by_name['error'].message_type = _ERROR
+_HASKEYSRESPONSE.fields_by_name['values'].message_type = _KEYEDBOOLEAN
+_HASKEYSRESPONSE.fields_by_name['error'].message_type = _ERROR
_PUTREQUEST.fields_by_name['versioned'].message_type = _VERSIONED
_PUTRESPONSE.fields_by_name['error'].message_type = _ERROR
_DELETEREQUEST.fields_by_name['version'].message_type = _VECTORCLOCK
@@ -675,6 +787,25 @@
_VOLDEMORTREQUEST.fields_by_name['getAll'].message_type = _GETALLREQUEST
_VOLDEMORTREQUEST.fields_by_name['put'].message_type = _PUTREQUEST
_VOLDEMORTREQUEST.fields_by_name['delete'].message_type = _DELETEREQUEST
+_VOLDEMORTREQUEST.fields_by_name['hasKeys'].message_type = _HASKEYSREQUEST
+DESCRIPTOR.message_types_by_name['ClockEntry'] = _CLOCKENTRY
+DESCRIPTOR.message_types_by_name['VectorClock'] = _VECTORCLOCK
+DESCRIPTOR.message_types_by_name['Versioned'] = _VERSIONED
+DESCRIPTOR.message_types_by_name['Error'] = _ERROR
+DESCRIPTOR.message_types_by_name['KeyedVersions'] = _KEYEDVERSIONS
+DESCRIPTOR.message_types_by_name['KeyedBoolean'] = _KEYEDBOOLEAN
+DESCRIPTOR.message_types_by_name['GetRequest'] = _GETREQUEST
+DESCRIPTOR.message_types_by_name['GetResponse'] = _GETRESPONSE
+DESCRIPTOR.message_types_by_name['GetVersionResponse'] = _GETVERSIONRESPONSE
+DESCRIPTOR.message_types_by_name['GetAllRequest'] = _GETALLREQUEST
+DESCRIPTOR.message_types_by_name['GetAllResponse'] = _GETALLRESPONSE
+DESCRIPTOR.message_types_by_name['HasKeysRequest'] = _HASKEYSREQUEST
+DESCRIPTOR.message_types_by_name['HasKeysResponse'] = _HASKEYSRESPONSE
+DESCRIPTOR.message_types_by_name['PutRequest'] = _PUTREQUEST
+DESCRIPTOR.message_types_by_name['PutResponse'] = _PUTRESPONSE
+DESCRIPTOR.message_types_by_name['DeleteRequest'] = _DELETEREQUEST
+DESCRIPTOR.message_types_by_name['DeleteResponse'] = _DELETERESPONSE
+DESCRIPTOR.message_types_by_name['VoldemortRequest'] = _VOLDEMORTREQUEST
class ClockEntry(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
@@ -706,6 +837,12 @@ class KeyedVersions(message.Message):
# @@protoc_insertion_point(class_scope:voldemort.KeyedVersions)
+class KeyedBoolean(message.Message):
+ __metaclass__ = reflection.GeneratedProtocolMessageType
+ DESCRIPTOR = _KEYEDBOOLEAN
+
+ # @@protoc_insertion_point(class_scope:voldemort.KeyedBoolean)
+
class GetRequest(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _GETREQUEST
@@ -742,6 +879,18 @@ class GetAllResponse(message.Message):
# @@protoc_insertion_point(class_scope:voldemort.GetAllResponse)
+class HasKeysRequest(message.Message):
+ __metaclass__ = reflection.GeneratedProtocolMessageType
+ DESCRIPTOR = _HASKEYSREQUEST
+
+ # @@protoc_insertion_point(class_scope:voldemort.HasKeysRequest)
+
+class HasKeysResponse(message.Message):
+ __metaclass__ = reflection.GeneratedProtocolMessageType
+ DESCRIPTOR = _HASKEYSRESPONSE
+
+ # @@protoc_insertion_point(class_scope:voldemort.HasKeysResponse)
+
class PutRequest(message.Message):
__metaclass__ = reflection.GeneratedProtocolMessageType
DESCRIPTOR = _PUTREQUEST
View
4 contrib/krati/src/java/voldemort/store/krati/KratiStorageEngine.java
@@ -104,6 +104,10 @@ public void truncate() {
}
}
+ public Map<ByteArray, Boolean> hasKeys(Iterable<ByteArray> keys) {
+ return StoreUtils.hasKeys(this, keys);
+ }
+
public ClosableIterator<Pair<ByteArray, Versioned<byte[]>>> entries() {
List<Pair<ByteArray, Versioned<byte[]>>> returnedList = new ArrayList<Pair<ByteArray, Versioned<byte[]>>>();
DataArray array = datastore.getDataArray();
View
46 src/java/voldemort/VoldemortClientShell.java
@@ -29,6 +29,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -173,6 +174,25 @@ private static void processCommands(StoreClientFactory factory,
} else {
System.out.println("null");
}
+ } else if(line.toLowerCase().startsWith("haskeys")) {
+ JsonReader jsonReader = new JsonReader(new StringReader(line.substring("haskeys".length())));
+ Set<Object> keys = new HashSet<Object>();
+ try {
+ while(true)
+ keys.add(jsonReader.read());
+ } catch(EndOfFileException e) {
+ // this is okay, just means we are done reading
+ }
+ Map<Object, Boolean> vals = client.hasKeys(keys);
+ if(vals.size() > 0) {
+ for(Map.Entry<Object, Boolean> entry: vals.entrySet()) {
+ System.out.print(entry.getKey());
+ System.out.print(" => ");
+ System.out.println(entry.getValue());
+ }
+ } else {
+ System.out.println("null");
+ }
} else if(line.toLowerCase().startsWith("getmetadata")) {
String[] args = line.substring("getmetadata".length() + 1).split("\\s+");
int remoteNodeId = Integer.valueOf(args[0]);
@@ -270,21 +290,29 @@ private static void processCommands(StoreClientFactory factory,
} else if(line.startsWith("help")) {
System.out.println();
System.out.println("Commands:");
- System.out.println(PROMPT + "put key value --- Associate the given value with the key.");
- System.out.println(PROMPT + "get key --- Retrieve the value associated with the key.");
- System.out.println(PROMPT + "getall key1 [key2...] --- Retrieve the value(s) associated with the key(s).");
- System.out.println(PROMPT + "delete key --- Remove all values associated with the key.");
- System.out.println(PROMPT + "preflist key --- Get node preference list for given key.");
+ System.out.println(PROMPT
+ + "put key value --- Associate the given value with the key.");
+ System.out.println(PROMPT
+ + "get key --- Retrieve the value associated with the key.");
+ System.out.println(PROMPT
+ + "getall key1 [key2...] --- Retrieve the value(s) associated with the key(s).");
+ System.out.println(PROMPT
+ + "delete key --- Remove all values associated with the key.");
+ System.out.println(PROMPT
+ + "preflist key --- Get node preference list for given key.");
String metaKeyValues = voldemort.store.metadata.MetadataStore.METADATA_KEYS.toString();
- System.out.println(PROMPT + "getmetadata node_id meta_key --- Get store metadata associated "
+ System.out.println(PROMPT
+ + "getmetadata node_id meta_key --- Get store metadata associated "
+ "with meta_key from node_id. meta_key may be one of "
+ metaKeyValues.substring(1, metaKeyValues.length() - 1)
+ ".");
- System.out.println(PROMPT + "fetchkeys node_id store_name partitions <file_name> --- Fetch all keys "
+ System.out.println(PROMPT
+ + "fetchkeys node_id store_name partitions <file_name> --- Fetch all keys "
+ "from given partitions (a comma separated list) of store_name on "
+ "node_id. Optionally, write to file_name. "
+ "Use getmetadata to determine appropriate values for store_name and partitions");
- System.out.println(PROMPT + "fetch node_id store_name partitions <file_name> --- Fetch all entries "
+ System.out.println(PROMPT
+ + "fetch node_id store_name partitions <file_name> --- Fetch all entries "
+ "from given partitions (a comma separated list) of store_name on "
+ "node_id. Optionally, write to file_name. "
+ "Use getmetadata to determine appropriate values for store_name and partitions");
@@ -341,7 +369,7 @@ private static void printNodeList(List<Node> nodes, FailureDetector failureDetec
}
}
- private static void printVersioned(Versioned<Object> v) {
+ private static <T> void printVersioned(Versioned<T> v) {
if(v == null) {
System.out.println("null");
} else {
View
25 src/java/voldemort/client/DefaultStoreClient.java
@@ -16,6 +16,7 @@
package voldemort.client;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -355,4 +356,28 @@ else if(versions.size() == 1)
return put(key, versioned, transforms);
}
+
+ public Map<K, Boolean> hasKeys(Iterable<K> keys) {
+ // Pre-populate with all false
+ Map<K, Boolean> returnMap = new HashMap<K, Boolean>();
+ for(K key: keys) {
+ returnMap.put(key, false);
+ }
+ for(int attempts = 0; attempts < this.metadataRefreshAttempts; attempts++) {
+ try {
+ Map<K, Boolean> items = store.hasKeys(keys);
+ for(Map.Entry<K, Boolean> value: items.entrySet()) {
+ returnMap.put(value.getKey(), value.getValue());
+ }
+ return returnMap;
+ } catch(InvalidMetadataException e) {
+ logger.info("Received invalid metadata exception during hasKeys [ "
+ + e.getMessage() + " ] on store '" + storeName + "'. Rebootstrapping");
+ bootStrap();
+ }
+ }
+ throw new VoldemortException(this.metadataRefreshAttempts
+ + " metadata refresh attempts failed.");
+ }
+
}
View
5 src/java/voldemort/client/LazyStoreClient.java
@@ -122,4 +122,9 @@ public boolean delete(K key, Version version) {
public List<Node> getResponsibleNodes(K key) {
return getStoreClient().getResponsibleNodes(key);
}
+
+ public Map<K, Boolean> hasKeys(Iterable<K> keys) {
+ return getStoreClient().hasKeys(keys);
+ }
+
}
View
10 src/java/voldemort/client/StoreClient.java
@@ -206,4 +206,14 @@
* @return a list of Nodes which should hold this key
*/
public List<Node> getResponsibleNodes(K key);
+
+ /**
+ * Given a set of keys, check if it exists
+ *
+ * @param keys Set of keys to check
+ * @return Map of key to boolean. The guarantee is number of keys = number
+ * of input keys
+ */
+ public Map<K, Boolean> hasKeys(Iterable<K> keys);
+
}
View
3 src/java/voldemort/client/TimeoutConfig.java
@@ -20,6 +20,7 @@ public TimeoutConfig(long globalTimeout, boolean allowPartialGetAlls) {
globalTimeout,
globalTimeout,
globalTimeout,
+ globalTimeout,
allowPartialGetAlls);
}
@@ -28,13 +29,15 @@ public TimeoutConfig(long getTimeout,
long deleteTimeout,
long getAllTimeout,
long getVersionsTimeout,
+ long hasKeysTimeout,
boolean allowPartialGetAlls) {
timeoutMap = new HashMap<Byte, Long>();
timeoutMap.put(VoldemortOpCode.GET_OP_CODE, getTimeout);
timeoutMap.put(VoldemortOpCode.PUT_OP_CODE, putTimeout);
timeoutMap.put(VoldemortOpCode.DELETE_OP_CODE, deleteTimeout);
timeoutMap.put(VoldemortOpCode.GET_ALL_OP_CODE, getAllTimeout);
timeoutMap.put(VoldemortOpCode.GET_VERSION_OP_CODE, getVersionsTimeout);
+ timeoutMap.put(VoldemortOpCode.HAS_KEYS_OP_CODE, hasKeysTimeout);
setPartialGetAllAllowed(allowPartialGetAlls);
}
View
10 src/java/voldemort/client/protocol/RequestFormat.java
@@ -68,6 +68,15 @@ public void writeGetAllRequest(DataOutputStream output,
public Map<ByteArray, List<Versioned<byte[]>>> readGetAllResponse(DataInputStream stream)
throws IOException;
+ public void writeHasKeysRequest(DataOutputStream output,
+ String storeName,
+ Iterable<ByteArray> keys,
+ RequestRoutingType routingType) throws IOException;
+
+ public boolean isCompleteHasKeysResponse(ByteBuffer buffer);
+
+ public Map<ByteArray, Boolean> readHasKeysResponse(DataInputStream stream) throws IOException;
+
public void writePutRequest(DataOutputStream output,
String storeName,
ByteArray key,
@@ -89,4 +98,5 @@ public void writeDeleteRequest(DataOutputStream output,
public boolean isCompleteDeleteResponse(ByteBuffer buffer);
public boolean readDeleteResponse(DataInputStream input) throws IOException;
+
}
View
36 src/java/voldemort/client/protocol/pb/ProtoBuffClientRequestFormat.java
@@ -29,6 +29,7 @@
import voldemort.client.protocol.pb.VProto.GetAllResponse;
import voldemort.client.protocol.pb.VProto.GetResponse;
import voldemort.client.protocol.pb.VProto.GetVersionResponse;
+import voldemort.client.protocol.pb.VProto.HasKeysResponse;
import voldemort.client.protocol.pb.VProto.PutResponse;
import voldemort.client.protocol.pb.VProto.RequestType;
import voldemort.server.RequestRoutingType;
@@ -242,4 +243,39 @@ private boolean isCompleteResponse(ByteBuffer buffer) {
return buffer.remaining() == size;
}
+ public void writeHasKeysRequest(DataOutputStream output,
+ String storeName,
+ Iterable<ByteArray> keys,
+ RequestRoutingType routingType) throws IOException {
+ StoreUtils.assertValidKeys(keys);
+
+ VProto.HasKeysRequest.Builder req = VProto.HasKeysRequest.newBuilder();
+ for(ByteArray key: keys)
+ req.addKeys(ByteString.copyFrom(key.get()));
+
+ ProtoUtils.writeMessage(output,
+ VProto.VoldemortRequest.newBuilder()
+ .setType(RequestType.HAS_KEYS)
+ .setStore(storeName)
+ .setShouldRoute(routingType.equals(RequestRoutingType.ROUTED))
+ .setRequestRouteType(routingType.getRoutingTypeCode())
+ .setHasKeys(req)
+ .build());
+ }
+
+ public Map<ByteArray, Boolean> readHasKeysResponse(DataInputStream input) throws IOException {
+ HasKeysResponse.Builder response = ProtoUtils.readToBuilder(input,
+ HasKeysResponse.newBuilder());
+ if(response.hasError())
+ throwException(response.getError());
+ Map<ByteArray, Boolean> vals = new HashMap<ByteArray, Boolean>(response.getValuesCount());
+ for(VProto.KeyedBoolean versions: response.getValuesList())
+ vals.put(ProtoUtils.decodeBytes(versions.getKey()), versions.getPresent());
+ return vals;
+ }
+
+ public boolean isCompleteHasKeysResponse(ByteBuffer buffer) {
+ return isCompleteResponse(buffer);
+ }
+
}
View
23,282 src/java/voldemort/client/protocol/pb/VAdminProto.java
18,003 additions, 5,279 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
8,995 src/java/voldemort/client/protocol/pb/VProto.java
7,026 additions, 1,969 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
43 src/java/voldemort/client/protocol/vold/VoldemortNativeClientRequestFormat.java
@@ -173,6 +173,45 @@ public void writeGetAllRequest(DataOutputStream output,
}
}
+ public void writeHasKeysRequest(DataOutputStream output,
+ String storeName,
+ Iterable<ByteArray> keys,
+ RequestRoutingType routingType) throws IOException {
+ StoreUtils.assertValidKeys(keys);
+ output.writeByte(VoldemortOpCode.HAS_KEYS_OP_CODE);
+ output.writeUTF(storeName);
+ output.writeBoolean(routingType.equals(RequestRoutingType.ROUTED));
+ if(protocolVersion > 1) {
+ output.writeByte(routingType.getRoutingTypeCode());
+ }
+ // write out keys
+ List<ByteArray> l = new ArrayList<ByteArray>();
+ for(ByteArray key: keys)
+ l.add(key);
+ output.writeInt(l.size());
+ for(ByteArray key: keys) {
+ output.writeInt(key.length());
+ output.write(key.get());
+ }
+ }
+
+ public Map<ByteArray, Boolean> readHasKeysResponse(DataInputStream stream) throws IOException {
+ checkException(stream);
+ int numResults = stream.readInt();
+ Map<ByteArray, Boolean> results = new HashMap<ByteArray, Boolean>(numResults);
+ for(int i = 0; i < numResults; i++) {
+ int keySize = stream.readInt();
+ byte[] key = new byte[keySize];
+ stream.readFully(key);
+ results.put(new ByteArray(key), stream.readBoolean());
+ }
+ return results;
+ }
+
+ public boolean isCompleteHasKeysResponse(ByteBuffer buffer) {
+ return isCompleteResponse(buffer, VoldemortOpCode.HAS_KEYS_OP_CODE);
+ }
+
public boolean isCompleteGetAllResponse(ByteBuffer buffer) {
return isCompleteResponse(buffer, VoldemortOpCode.GET_ALL_OP_CODE);
}
@@ -297,6 +336,10 @@ private boolean isCompleteResponse(ByteBuffer buffer, byte opCode) {
case VoldemortOpCode.PUT_OP_CODE:
readPutResponse(inputStream);
break;
+
+ case VoldemortOpCode.HAS_KEYS_OP_CODE:
+ readHasKeysResponse(inputStream);
+ break;
}
} catch(VoldemortException e) {
// Ignore application-level exceptions
View
2 src/java/voldemort/common/VoldemortOpCode.java
@@ -29,4 +29,6 @@
public static final byte REDIRECT_GET_OP_CODE = 9;
public static final byte GET_VERSION_OP_CODE = 10;
public static final byte GET_METADATA_OP_CODE = 11;
+ public static final byte HAS_KEYS_OP_CODE = 12;
+
}
View
472 src/java/voldemort/serialization/VSlopProto.java
@@ -8,11 +8,39 @@ private VSlopProto() {}
public static void registerAllExtensions(
com.google.protobuf.ExtensionRegistry registry) {
}
+ public interface SlopOrBuilder
+ extends com.google.protobuf.MessageOrBuilder {
+
+ // optional string store = 1;
+ boolean hasStore();
+ String getStore();
+
+ // optional string operation = 2;
+ boolean hasOperation();
+ String getOperation();
+
+ // optional bytes key = 3;
+ boolean hasKey();
+ com.google.protobuf.ByteString getKey();
+
+ // optional bytes value = 4;
+ boolean hasValue();
+ com.google.protobuf.ByteString getValue();
+
+ // optional int32 node_id = 5;
+ boolean hasNodeId();
+ int getNodeId();
+
+ // optional int64 arrived = 6;
+ boolean hasArrived();
+ long getArrived();
+ }
public static final class Slop extends
- com.google.protobuf.GeneratedMessage {
+ com.google.protobuf.GeneratedMessage
+ implements SlopOrBuilder {
// Use Slop.newBuilder() to construct.
- private Slop() {
- initFields();
+ private Slop(Builder builder) {
+ super(builder);
}
private Slop(boolean noInit) {}
@@ -35,74 +63,148 @@ public Slop getDefaultInstanceForType() {
return voldemort.serialization.VSlopProto.internal_static_voldemort_Slop_fieldAccessorTable;
}
+ private int bitField0_;
// optional string store = 1;
public static final int STORE_FIELD_NUMBER = 1;
- private boolean hasStore;
- private java.lang.String store_ = "";
- public boolean hasStore() { return hasStore; }
- public java.lang.String getStore() { return store_; }
+ private java.lang.Object store_;
+ public boolean hasStore() {
+ return ((bitField0_ & 0x00000001) == 0x00000001);
+ }
+ public String getStore() {
+ java.lang.Object ref = store_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ if (com.google.protobuf.Internal.isValidUtf8(bs)) {
+ store_ = s;
+ }
+ return s;
+ }
+ }
+ private com.google.protobuf.ByteString getStoreBytes() {
+ java.lang.Object ref = store_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8((String) ref);
+ store_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
// optional string operation = 2;
public static final int OPERATION_FIELD_NUMBER = 2;
- private boolean hasOperation;
- private java.lang.String operation_ = "";
- public boolean hasOperation() { return hasOperation; }
- public java.lang.String getOperation() { return operation_; }
+ private java.lang.Object operation_;
+ public boolean hasOperation() {
+ return ((bitField0_ & 0x00000002) == 0x00000002);
+ }
+ public String getOperation() {
+ java.lang.Object ref = operation_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ if (com.google.protobuf.Internal.isValidUtf8(bs)) {
+ operation_ = s;
+ }
+ return s;
+ }
+ }
+ private com.google.protobuf.ByteString getOperationBytes() {
+ java.lang.Object ref = operation_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8((String) ref);
+ operation_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
// optional bytes key = 3;
public static final int KEY_FIELD_NUMBER = 3;
- private boolean hasKey;
- private com.google.protobuf.ByteString key_ = com.google.protobuf.ByteString.EMPTY;
- public boolean hasKey() { return hasKey; }
- public com.google.protobuf.ByteString getKey() { return key_; }
+ private com.google.protobuf.ByteString key_;
+ public boolean hasKey() {
+ return ((bitField0_ & 0x00000004) == 0x00000004);
+ }
+ public com.google.protobuf.ByteString getKey() {
+ return key_;
+ }
// optional bytes value = 4;
public static final int VALUE_FIELD_NUMBER = 4;
- private boolean hasValue;
- private com.google.protobuf.ByteString value_ = com.google.protobuf.ByteString.EMPTY;
- public boolean hasValue() { return hasValue; }
- public com.google.protobuf.ByteString getValue() { return value_; }
+ private com.google.protobuf.ByteString value_;
+ public boolean hasValue() {
+ return ((bitField0_ & 0x00000008) == 0x00000008);
+ }
+ public com.google.protobuf.ByteString getValue() {
+ return value_;
+ }
// optional int32 node_id = 5;
public static final int NODE_ID_FIELD_NUMBER = 5;
- private boolean hasNodeId;
- private int nodeId_ = 0;
- public boolean hasNodeId() { return hasNodeId; }
- public int getNodeId() { return nodeId_; }
+ private int nodeId_;
+ public boolean hasNodeId() {
+ return ((bitField0_ & 0x00000010) == 0x00000010);
+ }
+ public int getNodeId() {
+ return nodeId_;
+ }
// optional int64 arrived = 6;
public static final int ARRIVED_FIELD_NUMBER = 6;
- private boolean hasArrived;
- private long arrived_ = 0L;
- public boolean hasArrived() { return hasArrived; }
- public long getArrived() { return arrived_; }
+ private long arrived_;
+ public boolean hasArrived() {
+ return ((bitField0_ & 0x00000020) == 0x00000020);
+ }
+ public long getArrived() {
+ return arrived_;
+ }
private void initFields() {
+ store_ = "";
+ operation_ = "";
+ key_ = com.google.protobuf.ByteString.EMPTY;
+ value_ = com.google.protobuf.ByteString.EMPTY;
+ nodeId_ = 0;
+ arrived_ = 0L;
}
+ private byte memoizedIsInitialized = -1;
public final boolean isInitialized() {
+ byte isInitialized = memoizedIsInitialized;
+ if (isInitialized != -1) return isInitialized == 1;
+
+ memoizedIsInitialized = 1;
return true;
}
public void writeTo(com.google.protobuf.CodedOutputStream output)
throws java.io.IOException {
getSerializedSize();
- if (hasStore()) {
- output.writeString(1, getStore());
+ if (((bitField0_ & 0x00000001) == 0x00000001)) {
+ output.writeBytes(1, getStoreBytes());
}
- if (hasOperation()) {
- output.writeString(2, getOperation());
+ if (((bitField0_ & 0x00000002) == 0x00000002)) {
+ output.writeBytes(2, getOperationBytes());
}
- if (hasKey()) {
- output.writeBytes(3, getKey());
+ if (((bitField0_ & 0x00000004) == 0x00000004)) {
+ output.writeBytes(3, key_);
}
- if (hasValue()) {
- output.writeBytes(4, getValue());
+ if (((bitField0_ & 0x00000008) == 0x00000008)) {
+ output.writeBytes(4, value_);
}
- if (hasNodeId()) {
- output.writeInt32(5, getNodeId());
+ if (((bitField0_ & 0x00000010) == 0x00000010)) {
+ output.writeInt32(5, nodeId_);
}
- if (hasArrived()) {
- output.writeInt64(6, getArrived());
+ if (((bitField0_ & 0x00000020) == 0x00000020)) {
+ output.writeInt64(6, arrived_);
}
getUnknownFields().writeTo(output);
}
@@ -113,35 +215,42 @@ public int getSerializedSize() {
if (size != -1) return size;
size = 0;
- if (hasStore()) {
+ if (((bitField0_ & 0x00000001) == 0x00000001)) {
size += com.google.protobuf.CodedOutputStream
- .computeStringSize(1, getStore());
+ .computeBytesSize(1, getStoreBytes());
}
- if (hasOperation()) {
+ if (((bitField0_ & 0x00000002) == 0x00000002)) {
size += com.google.protobuf.CodedOutputStream
- .computeStringSize(2, getOperation());
+ .computeBytesSize(2, getOperationBytes());
}
- if (hasKey()) {
+ if (((bitField0_ & 0x00000004) == 0x00000004)) {
size += com.google.protobuf.CodedOutputStream
- .computeBytesSize(3, getKey());
+ .computeBytesSize(3, key_);
}
- if (hasValue()) {
+ if (((bitField0_ & 0x00000008) == 0x00000008)) {
size += com.google.protobuf.CodedOutputStream
- .computeBytesSize(4, getValue());
+ .computeBytesSize(4, value_);
}
- if (hasNodeId()) {
+ if (((bitField0_ & 0x00000010) == 0x00000010)) {
size += com.google.protobuf.CodedOutputStream
- .computeInt32Size(5, getNodeId());
+ .computeInt32Size(5, nodeId_);
}
- if (hasArrived()) {
+ if (((bitField0_ & 0x00000020) == 0x00000020)) {
size += com.google.protobuf.CodedOutputStream
- .computeInt64Size(6, getArrived());
+ .computeInt64Size(6, arrived_);
}
size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size;
return size;
}
+ private static final long serialVersionUID = 0L;
+ @java.lang.Override
+ protected java.lang.Object writeReplace()
+ throws java.io.ObjectStreamException {
+ return super.writeReplace();
+ }
+
public static voldemort.serialization.VSlopProto.Slop parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
@@ -216,34 +325,61 @@ public static Builder newBuilder(voldemort.serialization.VSlopProto.Slop prototy
}
public Builder toBuilder() { return newBuilder(this); }
+ @java.lang.Override
+ protected Builder newBuilderForType(
+ com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+ Builder builder = new Builder(parent);
+ return builder;
+ }
public static final class Builder extends
- com.google.protobuf.GeneratedMessage.Builder<Builder> {
- private voldemort.serialization.VSlopProto.Slop result;
+ com.google.protobuf.GeneratedMessage.Builder<Builder>
+ implements voldemort.serialization.VSlopProto.SlopOrBuilder {
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return voldemort.serialization.VSlopProto.internal_static_voldemort_Slop_descriptor;
+ }
- // Construct using voldemort.serialization.VSlopProto.Slop.newBuilder()
- private Builder() {}
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return voldemort.serialization.VSlopProto.internal_static_voldemort_Slop_fieldAccessorTable;
+ }
- private static Builder create() {
- Builder builder = new Builder();
- builder.result = new voldemort.serialization.VSlopProto.Slop();
- return builder;
+ // Construct using voldemort.serialization.VSlopProto.Slop.newBuilder()
+ private Builder() {
+ maybeForceBuilderInitialization();
}
- protected voldemort.serialization.VSlopProto.Slop internalGetResult() {
- return result;
+ private Builder(BuilderParent parent) {
+ super(parent);
+ maybeForceBuilderInitialization();
+ }
+ private void maybeForceBuilderInitialization() {
+ if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
+ }
+ }
+ private static Builder create() {
+ return new Builder();
}
public Builder clear() {
- if (result == null) {
- throw new IllegalStateException(
- "Cannot call clear() after build().");
- }
- result = new voldemort.serialization.VSlopProto.Slop();
+ super.clear();
+ store_ = "";
+ bitField0_ = (bitField0_ & ~0x00000001);
+ operation_ = "";
+ bitField0_ = (bitField0_ & ~0x00000002);
+ key_ = com.google.protobuf.ByteString.EMPTY;
+ bitField0_ = (bitField0_ & ~0x00000004);
+ value_ = com.google.protobuf.ByteString.EMPTY;
+ bitField0_ = (bitField0_ & ~0x00000008);
+ nodeId_ = 0;
+ bitField0_ = (bitField0_ & ~0x00000010);
+ arrived_ = 0L;
+ bitField0_ = (bitField0_ & ~0x00000020);
return this;
}
public Builder clone() {
- return create().mergeFrom(result);
+ return create().mergeFrom(buildPartial());
}
public com.google.protobuf.Descriptors.Descriptor
@@ -255,33 +391,55 @@ public Builder clone() {
return voldemort.serialization.VSlopProto.Slop.getDefaultInstance();
}
- public boolean isInitialized() {
- return result.isInitialized();
- }
public voldemort.serialization.VSlopProto.Slop build() {
- if (result != null && !isInitialized()) {
+ voldemort.serialization.VSlopProto.Slop result = buildPartial();
+ if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
- return buildPartial();
+ return result;
}
private voldemort.serialization.VSlopProto.Slop buildParsed()
throws com.google.protobuf.InvalidProtocolBufferException {
- if (!isInitialized()) {
+ voldemort.serialization.VSlopProto.Slop result = buildPartial();
+ if (!result.isInitialized()) {
throw newUninitializedMessageException(
result).asInvalidProtocolBufferException();
}
- return buildPartial();
+ return result;
}
public voldemort.serialization.VSlopProto.Slop buildPartial() {
- if (result == null) {
- throw new IllegalStateException(
- "build() has already been called on this Builder.");
+ voldemort.serialization.VSlopProto.Slop result = new voldemort.serialization.VSlopProto.Slop(this);
+ int from_bitField0_ = bitField0_;
+ int to_bitField0_ = 0;
+ if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
+ to_bitField0_ |= 0x00000001;
+ }
+ result.store_ = store_;
+ if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
+ to_bitField0_ |= 0x00000002;
+ }
+ result.operation_ = operation_;
+ if (((from_bitField0_ & 0x00000004) == 0x00000004)) {
+ to_bitField0_ |= 0x00000004;
+ }
+ result.key_ = key_;
+ if (((from_bitField0_ & 0x00000008) == 0x00000008)) {
+ to_bitField0_ |= 0x00000008;
+ }
+ result.value_ = value_;
+ if (((from_bitField0_ & 0x00000010) == 0x00000010)) {
+ to_bitField0_ |= 0x00000010;
}
- voldemort.serialization.VSlopProto.Slop returnMe = result;
- result = null;
- return returnMe;
+ result.nodeId_ = nodeId_;
+ if (((from_bitField0_ & 0x00000020) == 0x00000020)) {
+ to_bitField0_ |= 0x00000020;
+ }
+ result.arrived_ = arrived_;
+ result.bitField0_ = to_bitField0_;
+ onBuilt();
+ return result;
}
public Builder mergeFrom(com.google.protobuf.Message other) {
@@ -317,6 +475,10 @@ public Builder mergeFrom(voldemort.serialization.VSlopProto.Slop other) {
return this;
}
+ public final boolean isInitialized() {
+ return true;
+ }
+
public Builder mergeFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
@@ -329,161 +491,212 @@ public Builder mergeFrom(
switch (tag) {
case 0:
this.setUnknownFields(unknownFields.build());
+ onChanged();
return this;
default: {
if (!parseUnknownField(input, unknownFields,
extensionRegistry, tag)) {
this.setUnknownFields(unknownFields.build());
+ onChanged();
return this;
}
break;
}
case 10: {
- setStore(input.readString());
+ bitField0_ |= 0x00000001;
+ store_ = input.readBytes();
break;
}
case 18: {
- setOperation(input.readString());
+ bitField0_ |= 0x00000002;
+ operation_ = input.readBytes();
break;
}
case 26: {
- setKey(input.readBytes());
+ bitField0_ |= 0x00000004;
+ key_ = input.readBytes();
break;
}
case 34: {
- setValue(input.readBytes());
+ bitField0_ |= 0x00000008;
+ value_ = input.readBytes();
break;
}
case 40: {
- setNodeId(input.readInt32());
+ bitField0_ |= 0x00000010;
+ nodeId_ = input.readInt32();
break;
}
case 48: {
- setArrived(input.readInt64());
+ bitField0_ |= 0x00000020;
+ arrived_ = input.readInt64();
break;
}
}
}
}
+ private int bitField0_;
// optional string store = 1;
+ private java.lang.Object store_ = "";
public boolean hasStore() {
- return result.hasStore();
- }
- public java.lang.String getStore() {
- return result.getStore();
+ return ((bitField0_ & 0x00000001) == 0x00000001);
+ }
+ public String getStore() {
+ java.lang.Object ref = store_;
+ if (!(ref instanceof String)) {
+ String s = ((com.google.protobuf.ByteString) ref).toStringUtf8();
+ store_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
}
- public Builder setStore(java.lang.String value) {
+ public Builder setStore(String value) {
if (value == null) {
throw new NullPointerException();
}
- result.hasStore = true;
- result.store_ = value;
+ bitField0_ |= 0x00000001;
+ store_ = value;
+ onChanged();
return this;
}
public Builder clearStore() {
- result.hasStore = false;
- result.store_ = getDefaultInstance().getStore();
+ bitField0_ = (bitField0_ & ~0x00000001);
+ store_ = getDefaultInstance().getStore();
+ onChanged();
return this;
}
+ void setStore(com.google.protobuf.ByteString value) {
+ bitField0_ |= 0x00000001;
+ store_ = value;
+ onChanged();
+ }
// optional string operation = 2;
+ private java.lang.Object operation_ = "";
public boolean hasOperation() {
- return result.hasOperation();
- }
- public java.lang.String getOperation() {
- return result.getOperation();
+ return ((bitField0_ & 0x00000002) == 0x00000002);
+ }
+ public String getOperation() {
+ java.lang.Object ref = operation_;
+ if (!(ref instanceof String)) {
+ String s = ((com.google.protobuf.ByteString) ref).toStringUtf8();
+ operation_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
}
- public Builder setOperation(java.lang.String value) {
+ public Builder setOperation(String value) {
if (value == null) {
throw new NullPointerException();
}
- result.hasOperation = true;
- result.operation_ = value;
+ bitField0_ |= 0x00000002;
+ operation_ = value;
+ onChanged();
return this;
}
public Builder clearOperation() {
- result.hasOperation = false;
- result.operation_ = getDefaultInstance().getOperation();
+ bitField0_ = (bitField0_ & ~0x00000002);
+ operation_ = getDefaultInstance().getOperation();
+ onChanged();
return this;
}
+ void setOperation(com.google.protobuf.ByteString value) {
+ bitField0_ |= 0x00000002;
+ operation_ = value;
+ onChanged();
+ }
// optional bytes key = 3;
+ private com.google.protobuf.ByteString key_ = com.google.protobuf.ByteString.EMPTY;
public boolean hasKey() {
- return result.hasKey();
+ return ((bitField0_ & 0x00000004) == 0x00000004);
}
public com.google.protobuf.ByteString getKey() {
- return result.getKey();
+ return key_;
}
public Builder setKey(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
- result.hasKey = true;
- result.key_ = value;
+ bitField0_ |= 0x00000004;
+ key_ = value;
+ onChanged();
return this;
}
public Builder clearKey() {
- result.hasKey = false;
- result.key_ = getDefaultInstance().getKey();
+ bitField0_ = (bitField0_ & ~0x00000004);
+ key_ = getDefaultInstance().getKey();
+ onChanged();
return this;
}
// optional bytes value = 4;
+ private com.google.protobuf.ByteString value_ = com.google.protobuf.ByteString.EMPTY;
public boolean hasValue() {
- return result.hasValue();
+ return ((bitField0_ & 0x00000008) == 0x00000008);
}
public com.google.protobuf.ByteString getValue() {
- return result.getValue();
+ return value_;
}
public Builder setValue(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
- result.hasValue = true;
- result.value_ = value;
+ bitField0_ |= 0x00000008;
+ value_ = value;
+ onChanged();
return this;
}
public Builder clearValue() {
- result.hasValue = false;
- result.value_ = getDefaultInstance().getValue();
+ bitField0_ = (bitField0_ & ~0x00000008);
+ value_ = getDefaultInstance().getValue();
+ onChanged();
return this;
}
// optional int32 node_id = 5;
+ private int nodeId_ ;
public boolean hasNodeId() {
- return result.hasNodeId();
+ return ((bitField0_ & 0x00000010) == 0x00000010);
}
public int getNodeId() {
- return result.getNodeId();
+ return nodeId_;
}
public Builder setNodeId(int value) {
- result.hasNodeId = true;
- result.nodeId_ = value;
+ bitField0_ |= 0x00000010;
+ nodeId_ = value;
+ onChanged();
return this;
}
public Builder clearNodeId() {
- result.hasNodeId = false;
- result.nodeId_ = 0;
+ bitField0_ = (bitField0_ & ~0x00000010);
+ nodeId_ = 0;
+ onChanged();
return this;
}
// optional int64 arrived = 6;
+ private long arrived_ ;
public boolean hasArrived() {
- return result.hasArrived();
+ return ((bitField0_ & 0x00000020) == 0x00000020);
}
public long getArrived() {
- return result.getArrived();
+ return arrived_;
}
public Builder setArrived(long value) {
- result.hasArrived = true;
- result.arrived_ = value;
+ bitField0_ |= 0x00000020;
+ arrived_ = value;
+ onChanged();
return this;
}
public Builder clearArrived() {
- result.hasArrived = false;
- result.arrived_ = 0L;
+ bitField0_ = (bitField0_ & ~0x00000020);
+ arrived_ = 0L;
+ onChanged();
return this;
}
@@ -492,7 +705,6 @@ public Builder clearArrived() {
static {
defaultInstance = new Slop(true);
- voldemort.serialization.VSlopProto.internalForceInit();
defaultInstance.initFields();
}
@@ -541,7 +753,5 @@ public Builder clearArrived() {
}, assigner);
}
- public static void internalForceInit() {}
-
// @@protoc_insertion_point(outer_class_scope)
}
View
113 src/java/voldemort/serialization/VoldemortOperation.java
@@ -1,113 +0,0 @@
-/*
- * Copyright 2008-2009 LinkedIn, Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package voldemort.serialization;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-
-import voldemort.common.VoldemortOpCode;
-import voldemort.utils.ByteUtils;
-import voldemort.versioning.VectorClock;
-import voldemort.versioning.Version;
-import voldemort.versioning.Versioned;
-
-public final class VoldemortOperation {
-
- private final byte opCode;
- private final String key;
- private final byte[] value;
- private final VectorClock version;
-
- private VoldemortOperation(byte opCode, String key, byte[] value, VectorClock version) {
- this.opCode = opCode;
- this.key = key;
- this.value = value;
- this.version = version;
- }
-
- public VoldemortOperation(byte[] bytes) {
- if(bytes == null || bytes.length <= 1)
- throw new SerializationException("Not enough bytes to serialize");
- DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(bytes));
- try {
- this.opCode = inputStream.readByte();
- switch(opCode) {
- case VoldemortOpCode.GET_OP_CODE:
- this.version = null;
- this.key = inputStream.readUTF();
- this.value = null;
- break;
- case VoldemortOpCode.PUT_OP_CODE:
- this.version = new VectorClock(bytes, 1);
- this.key = inputStream.readUTF();
- int valueSize = inputStream.readInt();
- this.value = new byte[valueSize];
- ByteUtils.read(inputStream, this.value);
- break;
- case VoldemortOpCode.DELETE_OP_CODE:
- this.version = new VectorClock(bytes, 1);
- this.key = inputStream.readUTF();
- this.value = null;
- break;
- default:
- throw new SerializationException("Unknown opcode: " + bytes[0]);
- }
- } catch(IOException e) {
- throw new SerializationException(e);
- }
- }
-
- public byte[] getBytes() {
- try {
- ByteArrayOutputStream byteOutput = new ByteArrayOutputStream();
- DataOutputStream output = new DataOutputStream(byteOutput);
- output.writeByte(opCode);
- if(opCode != VoldemortOpCode.GET_OP_CODE)
- output.write(version.toBytes());
- output.writeUTF(key);
- if(opCode == VoldemortOpCode.PUT_OP_CODE) {
- output.writeInt(value.length);
- output.write(value);
- }
- return byteOutput.toByteArray();
- } catch(IOException e) {
- throw new SerializationException(e);
- }
- }
-
- public VoldemortOperation makeGetOperation(String key) {
- return new VoldemortOperation(VoldemortOpCode.GET_OP_CODE, key, null, null);
- }
-
- public VoldemortOperation makePutOperation(String key, Versioned<byte[]> versioned) {
- return new VoldemortOperation(VoldemortOpCode.PUT_OP_CODE,
- key,
- versioned.getValue(),
- (VectorClock) versioned.getVersion());
- }
-
- public VoldemortOperation makeDeleteOperation(String key, Version version) {
- return new VoldemortOperation(VoldemortOpCode.DELETE_OP_CODE,
- key,
- null,
- (VectorClock) version);
- }
-
-}
View
56 src/java/voldemort/server/protocol/vold/VoldemortNativeRequestHandler.java
@@ -74,6 +74,9 @@ public StreamRequestHandler handleRequest(DataInputStream inputStream,
case VoldemortOpCode.GET_VERSION_OP_CODE:
handleGetVersion(inputStream, outputStream, store);
break;
+ case VoldemortOpCode.HAS_KEYS_OP_CODE:
+ handleHasKeys(inputStream, outputStream, store);
+ break;
default:
throw new IOException("Unknown op code: " + opCode);
}
@@ -146,7 +149,6 @@ private void handleGetVersion(DataInputStream inputStream,
* This is pretty ugly. We end up mimicking the request logic here, so this
* needs to stay in sync with handleRequest.
*/
-
public boolean isCompleteRequest(final ByteBuffer buffer) {
DataInputStream inputStream = new DataInputStream(new ByteBufferBackedInputStream(buffer));
@@ -177,7 +179,7 @@ public boolean isCompleteRequest(final ByteBuffer buffer) {
// Read the key just to skip the bytes.
readKey(inputStream);
break;
- case VoldemortOpCode.GET_OP_CODE:
+ case VoldemortOpCode.GET_OP_CODE: {
// Read the key just to skip the bytes.
readKey(inputStream);
if(protocolVersion > 2) {
@@ -187,7 +189,8 @@ public boolean isCompleteRequest(final ByteBuffer buffer) {
}
}
break;
- case VoldemortOpCode.GET_ALL_OP_CODE:
+ }
+ case VoldemortOpCode.GET_ALL_OP_CODE: {
int numKeys = inputStream.readInt();
// Read the keys to skip the bytes.
@@ -204,6 +207,15 @@ public boolean isCompleteRequest(final ByteBuffer buffer) {
}
}
break;
+ }
+ case VoldemortOpCode.HAS_KEYS_OP_CODE: {
+ int numKeys = inputStream.readInt();
+
+ // Read the keys to skip the bytes.
+ for(int i = 0; i < numKeys; i++)
+ readKey(inputStream);
+ break;
+ }
case VoldemortOpCode.PUT_OP_CODE: {
readKey(inputStream);
@@ -322,6 +334,44 @@ private void handleGet(DataInputStream inputStream,
}
}
+ private void handleHasKeys(DataInputStream inputStream,
+ DataOutputStream outputStream,
+ Store<ByteArray, byte[], byte[]> store) throws IOException {
+ // read keys
+ int numKeys = inputStream.readInt();
+ List<ByteArray> keys = new ArrayList<ByteArray>(numKeys);
+ for(int i = 0; i < numKeys; i++)
+ keys.add(readKey(inputStream));
+
+ // execute the operation
+ Map<ByteArray, Boolean> results = null;
+ try {
+ results = store.hasKeys(keys);
+ outputStream.writeShort(0);
+ } catch(VoldemortException e) {
+ logger.error(e.getMessage());
+ writeException(outputStream, e);
+ return;
+ }
+
+ // write back the results
+ outputStream.writeInt(results.size());
+
+ if(logger.isDebugEnabled())
+ logger.debug("HASKEYS start");
+
+ for(Map.Entry<ByteArray, Boolean> entry: results.entrySet()) {
+ // write the key
+ outputStream.writeInt(entry.getKey().length());
+ outputStream.write(entry.getKey().get());
+ // write the values
+ outputStream.writeBoolean(entry.getValue());
+ }
+
+ if(logger.isDebugEnabled())
+ logger.debug("HASKEYS end");
+ }
+
private void handleGetAll(DataInputStream inputStream,
DataOutputStream outputStream,
Store<ByteArray, byte[], byte[]> store) throws IOException {
View
5 src/java/voldemort/store/DelegatingStore.java
@@ -85,4 +85,9 @@ public String toString() {
public List<Version> getVersions(K key) {
return innerStore.getVersions(key);
}
+
+ public Map<K, Boolean> hasKeys(Iterable<K> keys) {
+ StoreUtils.assertValidKeys(keys);
+ return innerStore.hasKeys(keys);
+ }
}
View
19 src/java/voldemort/store/Store.java
@@ -53,6 +53,7 @@
* them.
*
* @param keys The keys to check for.
+ * @param transforms Transforms per key
* @return A Map of keys to a list of versioned values.
* @throws VoldemortException
*/
@@ -95,11 +96,25 @@
* layering.
*
* @param capability The capability type to retrieve
- * @return The given capaiblity
- * @throws NoSuchCapabilityException if the capaibility is not present
+ * @return The given capability
+ * @throws NoSuchCapabilityException if the capability is not present
*/
public Object getCapability(StoreCapabilityType capability);
+ /**
+ * Get all the versions for a key
+ *
+ * @param key The key
+ * @return List of versions
+ */
public List<Version> getVersions(K key);
+ /**
+ * Given a set of keys, check if it exists
+ *
+ * @param keys Set of keys to check
+ * @return Map of key to boolean
+ */
+ public Map<K, Boolean> hasKeys(Iterable<K> keys);
+
}
View
10 src/java/voldemort/store/StoreUtils.java
@@ -73,6 +73,16 @@ public static void assertValidKeys(Iterable<?> keys) {
return Collections.emptyList();
}
+ public static <K, V, T> Map<K, Boolean> hasKeys(Store<K, V, T> storageEngine, Iterable<K> keys) {
+ Map<K, List<Versioned<V>>> result = storageEngine.getAll(keys, null);
+ Map<K, Boolean> returnResult = new HashMap<K, Boolean>();
+ for(Map.Entry<K, List<Versioned<V>>> entry: result.entrySet()) {
+ if(entry.getValue() != null && entry.getValue().size() > 0)
+ returnResult.put(entry.getKey(), true);
+ }
+ return returnResult;
+ }
+
/**
* Implements getAll by delegating to get.
*/
View
5 src/java/voldemort/store/bdb/BdbStorageEngine.java
@@ -261,6 +261,11 @@ private Database getBdbDatabase() {
return bdbDatabase;
}
+ public Map<ByteArray, Boolean> hasKeys(Iterable<ByteArray> keys) {
+ StoreUtils.assertValidKeys(keys);
+ return StoreUtils.hasKeys(this, keys);
+ }
+
public Map<ByteArray, List<Versioned<byte[]>>> getAll(Iterable<ByteArray> keys,
Map<ByteArray, byte[]> transforms)
throws VoldemortException {
View
17 src/java/voldemort/store/compress/CompressingStore.java
@@ -59,15 +59,19 @@ public CompressingStore(Store<ByteArray, byte[], byte[]> innerStore,
this.innerStore = Utils.notNull(innerStore);
}
+ private List<ByteArray> deflateKeys(Iterable<ByteArray> keys) {
+ List<ByteArray> deflatedKeys = Lists.newArrayList();
+ for(ByteArray key: keys)
+ deflatedKeys.add(deflateKey(key));
+ return deflatedKeys;
+ }
+
public Map<ByteArray, List<Versioned<byte[]>>> getAll(Iterable<ByteArray> keys,
Map<ByteArray, byte[]> transforms)
throws VoldemortException {
StoreUtils.assertValidKeys(keys);
Iterable<ByteArray> processedKeys = keys;
- List<ByteArray> deflatedKeys = Lists.newArrayList();
- for(ByteArray key: keys)
- deflatedKeys.add(deflateKey(key));
- processedKeys = deflatedKeys;
+ processedKeys = deflateKeys(keys);
Map<ByteArray, byte[]> newTransforms = Maps.newHashMap();
if(transforms != null) {
for(Map.Entry<ByteArray, byte[]> transform: transforms.entrySet()) {
@@ -169,4 +173,9 @@ public boolean delete(ByteArray key, Version version) throws VoldemortException
StoreUtils.assertValidKey(key);
return innerStore.delete(deflateKey(key), version);
}
+
+ public Map<ByteArray, Boolean> hasKeys(Iterable<ByteArray> keys) {
+ StoreUtils.assertValidKeys(keys);
+ return innerStore.hasKeys(deflateKeys(keys));
+ }
}
View
6 src/java/voldemort/store/configuration/ConfigurationStorageEngine.java
@@ -233,7 +233,7 @@ public Object getCapability(StoreCapabilityType capability) {
}
public ClosableIterator<String> keys() {
- throw new VoldemortException("keys iteration not supported.");
+ throw new VoldemortException("Keys iteration not supported.");
}
public void truncate() {
@@ -243,4 +243,8 @@ public void truncate() {
public boolean isPartitionAware() {
return false;
}
+
+ public Map<String, Boolean> hasKeys(Iterable<String> keys) {
+ throw new VoldemortException("Has keys operation not supported in ConfigurationStorageEngine");
+ }
}
View
20 src/java/voldemort/store/http/HttpStore.java
@@ -209,4 +209,24 @@ public Object getCapability(StoreCapabilityType capability) {
IOUtils.closeQuietly(input);
}
}
+
+ public Map<ByteArray, Boolean> hasKeys(Iterable<ByteArray> keys) {
+ StoreUtils.assertValidKey(keys);
+ DataInputStream input = null;
+ try {
+ HttpPost method = new HttpPost(this.storeUrl);
+ ByteArrayOutputStream outputBytes = new ByteArrayOutputStream();
+ requestFormat.writeHasKeysRequest(new DataOutputStream(outputBytes),