Master server

You can append to any HTTP API with &pretty=y to see a formatted json output.

Assign a file key

This operation is very cheap. Just increase a number in master server's memory.

  1. # Basic Usage:
  2. curl http://localhost:9333/dir/assign
  3. {"count":1,"fid":"3,01637037d6","url":"127.0.0.1:8080",
  4. "publicUrl":"localhost:8080"}
  5. # To assign with a specific replication type:
  6. curl "http://localhost:9333/dir/assign?replication=001"
  7. # To specify how many file ids to reserve
  8. curl "http://localhost:9333/dir/assign?count=5"
  9. # To assign a specific data center
  10. curl "http://localhost:9333/dir/assign?dataCenter=dc1"

Lookup volume

We would need to find out whether the volumes have moved.

  1. curl "http://localhost:9333/dir/lookup?volumeId=3&pretty=y"
  2. {
  3. "locations": [
  4. {
  5. "publicUrl": "localhost:8080",
  6. "url": "localhost:8080"
  7. }
  8. ]
  9. }
  10. # Other usages:
  11. # You can actually use the file id to lookup, if you are lazy to parse the file id.
  12. curl "http://localhost:9333/dir/lookup?volumeId=3,01637037d6"
  13. # If you know the collection, specify it since it will be a little faster
  14. curl "http://localhost:9333/dir/lookup?volumeId=3&collection=turbo"

Force garbage collection

If your system has many deletions, the deleted file's disk space will not be synchronously re-claimed. There is a background job to check volume disk usage. If empty space is more than the threshold, default to 0.3, the vacuum job will make the volume readonly, create a new volume with only existing files, and switch on the new volume. If you are impatient or doing some testing, vacuum the unused spaces this way.

  1. curl "http://localhost:9333/vol/vacuum"
  2. curl "http://localhost:9333/vol/vacuum?garbageThreshold=0.4"

The garbageThreshold=0.4 is optional, and will not change the default threshold. You can start volume master with a different default garbageThreshold.

This operation is not trivial. It will try to make a copy of the .dat and .idx files, skipping deleted files, and switch to the new files, removing the old files.

Pre-Allocate Volumes

One volume serves one write a time. If you need to increase concurrency, you can pre-allocate lots of volumes. Here are examples. You can combine all the different options also.

  1. # specify a specific replication
  2. curl "http://localhost:9333/vol/grow?replication=000&count=4"
  3. {"count":4}
  4. # specify a collection
  5. curl "http://localhost:9333/vol/grow?collection=turbo&count=4"
  6. # specify data center
  7. curl "http://localhost:9333/vol/grow?dataCenter=dc1&count=4"
  8. # specify ttl
  9. curl "http://localhost:9333/vol/grow?ttl=5d&count=4"

This generates 4 empty volumes.

Delete Collection

  1. # delete a collection
  2. curl "http://localhost:9333/col/delete?collection=benchmark&pretty=y"

Check System Status

  1. curl "http://10.0.2.15:9333/cluster/status?pretty=y"
  2. {
  3. "IsLeader": true,
  4. "Leader": "10.0.2.15:9333",
  5. "Peers": [
  6. "10.0.2.15:9334",
  7. "10.0.2.15:9335"
  8. ]
  9. }
  10. curl "http://localhost:9333/dir/status?pretty=y"
  11. {
  12. "Topology": {
  13. "DataCenters": [
  14. {
  15. "Free": 3,
  16. "Id": "dc1",
  17. "Max": 7,
  18. "Racks": [
  19. {
  20. "DataNodes": [
  21. {
  22. "Free": 3,
  23. "Max": 7,
  24. "PublicUrl": "localhost:8080",
  25. "Url": "localhost:8080",
  26. "Volumes": 4
  27. }
  28. ],
  29. "Free": 3,
  30. "Id": "DefaultRack",
  31. "Max": 7
  32. }
  33. ]
  34. },
  35. {
  36. "Free": 21,
  37. "Id": "dc3",
  38. "Max": 21,
  39. "Racks": [
  40. {
  41. "DataNodes": [
  42. {
  43. "Free": 7,
  44. "Max": 7,
  45. "PublicUrl": "localhost:8081",
  46. "Url": "localhost:8081",
  47. "Volumes": 0
  48. }
  49. ],
  50. "Free": 7,
  51. "Id": "rack1",
  52. "Max": 7
  53. },
  54. {
  55. "DataNodes": [
  56. {
  57. "Free": 7,
  58. "Max": 7,
  59. "PublicUrl": "localhost:8082",
  60. "Url": "localhost:8082",
  61. "Volumes": 0
  62. },
  63. {
  64. "Free": 7,
  65. "Max": 7,
  66. "PublicUrl": "localhost:8083",
  67. "Url": "localhost:8083",
  68. "Volumes": 0
  69. }
  70. ],
  71. "Free": 14,
  72. "Id": "DefaultRack",
  73. "Max": 14
  74. }
  75. ]
  76. }
  77. ],
  78. "Free": 24,
  79. "Max": 28,
  80. "layouts": [
  81. {
  82. "collection": "",
  83. "replication": "000",
  84. "writables": [
  85. 1,
  86. 2,
  87. 3,
  88. 4
  89. ]
  90. }
  91. ]
  92. },
  93. "Version": "0.47"
  94. }