Updated Master Server API (markdown)

Chris Lu 2017-01-25 09:29:10 -08:00
parent 7691a2543c
commit c44d4fa0af

@ -168,253 +168,3 @@ curl "http://localhost:9333/dir/status?pretty=y"
"Version": "0.47"
}
```
## Volume Server
### Upload File
```bash
curl -F file=@/home/chris/myphoto.jpg http://127.0.0.1:8080/3,01637037d6
{"size": 43234}
```
The size returned is the size stored on SeaweedFS, sometimes the file is automatically gzipped based on the mime type.
### Upload File Directly
```bash
curl -F file=@/home/chris/myphoto.jpg http://localhost:9333/submit
{"fid":"3,01fbe0dc6f1f38","fileName":"myphoto.jpg","fileUrl":"localhost:8080/3,01fbe0dc6f1f38","size":68231}
```
This API is just for convenience. The master server would get an file id and store the file to the right volume server.
It is a convenient API and does not support different parameters when assigning file id. (or you can add the support and send a push request.)
### Delete File
```bash
curl -X DELETE http://127.0.0.1:8080/3,01637037d6
```
### Create а specific volume on a specific volume server
```bash
curl "http://localhost:8080/admin/assign_volume?replication=000&volume=3"
```
This generates volume 3 on this volume server.
If you use other replicationType, e.g. 001, you would need to do the same on other volume servers to create the mirroring volumes.
### Delete а volume
This API should be protected just in case someone delete your volumes!
It deletes the volume physically.
```bash
curl "http://localhost:8080/admin/volume/delete?volume=volumeId"
```
### Unmount/mount а volume
This API should be protected!
This deactivates a given volume. This is useful to process a volume stopping the volume server. Possible use cases are compaction, index recreation or moving the volume to another server. As soon as a volume is unmounted it won't be accessed by the volume any more and can be safely changed or moved away.
```bash
curl "http://localhost:8080/admin/volume/unmount?volume=volumeId"
```
The counterpart is to mount a volume. This adds a volume file to a volume server without the need to restart the volume server. A use case is to mount a previously unmounted volume again or to add a volume, that has been moved to another server to the new server.
```bash
curl "http://localhost:8080/admin/volume/mount?volume=volumeId"
```
### Delete а specific collection on a specific volume server
This API should be protected just in case someone delete your volumes!
```bash
curl "http://localhost:8080/admin/delete_collection?collection=some_collection_name."
```
### Check Volume Server Status
```bash
curl "http://localhost:8080/status?pretty=y"
{
"Version": "0.34",
"Volumes": [
{
"Id": 1,
"Size": 1319688,
"RepType": "000",
"Version": 2,
"FileCount": 276,
"DeleteCount": 0,
"DeletedByteCount": 0,
"ReadOnly": false
},
{
"Id": 2,
"Size": 1040962,
"RepType": "000",
"Version": 2,
"FileCount": 291,
"DeleteCount": 0,
"DeletedByteCount": 0,
"ReadOnly": false
},
{
"Id": 3,
"Size": 1486334,
"RepType": "000",
"Version": 2,
"FileCount": 301,
"DeleteCount": 2,
"DeletedByteCount": 0,
"ReadOnly": false
},
{
"Id": 4,
"Size": 8953592,
"RepType": "000",
"Version": 2,
"FileCount": 320,
"DeleteCount": 2,
"DeletedByteCount": 0,
"ReadOnly": false
},
{
"Id": 5,
"Size": 70815851,
"RepType": "000",
"Version": 2,
"FileCount": 309,
"DeleteCount": 1,
"DeletedByteCount": 0,
"ReadOnly": false
},
{
"Id": 6,
"Size": 1483131,
"RepType": "000",
"Version": 2,
"FileCount": 301,
"DeleteCount": 1,
"DeletedByteCount": 0,
"ReadOnly": false
},
{
"Id": 7,
"Size": 46797832,
"RepType": "000",
"Version": 2,
"FileCount": 292,
"DeleteCount": 0,
"DeletedByteCount": 0,
"ReadOnly": false
}
]
}
```
## Filer server
### POST/PUT/Get files
```bash
# Basic Usage:
//create or overwrite the file, the directories /path/to will be automatically created
POST /path/to/file
//get the file content
GET /path/to/file
//create or overwrite the file, the filename in the multipart request will be used
POST /path/to/
//return a json format subdirectory and files listing
GET /path/to/
```
Examples:
```bash
# Basic Usage:
> curl -F file=@report.js "http://localhost:8888/javascript/"
{"name":"report.js","size":866,"fid":"7,0254f1f3fd","url":"http://localhost:8081/7,0254f1f3fd"}
> curl "http://localhost:8888/javascript/report.js" # get the file content
...
> curl -F file=@report.js "http://localhost:8888/javascript/new_name.js" # upload the file with a different name
{"name":"report.js","size":866,"fid":"3,034389657e","url":"http://localhost:8081/3,034389657e"}
> curl "http://localhost:8888/javascript/?pretty=y" # list all files under /javascript/
{
"Directory": "/javascript/",
"Files": [
{
"name": "new_name.js",
"fid": "3,034389657e"
},
{
"name": "report.js",
"fid": "7,0254f1f3fd"
}
],
"Subdirectories": null
}
```
### List files under a directory
This is for embedded filer only.
Some folder can be very large. To efficiently list files, we use a non-traditional way to iterate files. Every pagination you provide a "lastFileName", and a "limit=x". The filer locate the "lastFileName" in O(log(n)) time, and retrieve the next x files.
```bash
curl "http://localhost:8888/javascript/?pretty=y&lastFileName=new_name.js&limit=2"
{
"Directory": "/javascript/",
"Files": [
{
"name": "report.js",
"fid": "7,0254f1f3fd"
}
]
}
```
### Move a directory
This is for embedded filer only.
Rename a folder is an O(1) operation, even for folders with lots of files.
```bash
# Change folder name from /javascript to /assets
> curl "http://localhost:8888/admin/mv?from=/javascript&to=/assets"
# no files under /javascript now
> curl "http://localhost:8888/javascript/?pretty=y"
{
"Directory": "/javascript/",
"Files": null,
"Subdirectories": null
}
# files are moved to /assets folder
> curl "http://localhost:8888/assets/?pretty=y"
{
"Directory": "/assets/",
"Files": [
{
"name": "new_name.js",
"fid": "3,034389657e"
},
{
"name": "report.js",
"fid": "7,0254f1f3fd"
}
],
"Subdirectories": null
}
```
# Delete a file
```bash
> curl -X DELETE "http://localhost:8888/assets/report.js"
```