-
Notifications
You must be signed in to change notification settings - Fork 276
Quick Start
To get the latest code and build it, do
$ git clone [email protected]:linkedin/ambry.git
$ cd ambry
$ ./gradlew allJar
$ cd target
$ mkdir logs
Ambry uses files that provide information about the cluster to route requests from the frontend to servers and for replication between servers. We will use a simple clustermap that contains a single server with one partition. The partition will use /tmp
as the mount point.
$ nohup java -Dlog4j.configuration=file:../config/log4j.properties -cp ambry.jar com.github.ambry.server.AmbryMain --serverPropsFilePath ../config/server.properties --hardwareLayoutFilePath ../config/HardwareLayout.json --partitionLayoutFilePath ../config/PartitionLayout.json > logs/server.log &
Through this command, we configure the log4j properties, provide the server with configuration options and cluster definitions and redirect output to a log. Note down the process ID returned (serverProcessID
) because it will be needed for shutdown.
The log will be available at logs/server.log
. Alternately, you can change the log4j properties to write the log messages to a file instead of standard output.
$ nohup java -Dlog4j.configuration=file:../config/log4j.properties -cp ambry.jar com.github.ambry.frontend.AmbryFrontendMain --serverPropsFilePath ../config/frontend.properties --hardwareLayoutFilePath ../config/HardwareLayout.json --partitionLayoutFilePath ../config/PartitionLayout.json > logs/frontend.log &
Note down the process ID returned (frontendProcessID
) because it will be needed for shutdown. Make sure that the frontend is ready to receive requests.
$ curl http://localhost:1174/healthCheck
GOOD
The log will be available at logs/frontend.log
. Alternately, you can change the log4j properties to write the log messages to a file instead of standard output.
We are now ready to store and retrieve data from Ambry. Let us start by storing a simple image. For demonstration purposes, we will use an image demo.gif
that has been copied into the target
folder.
$ curl -i -H "x-ambry-service-id : CUrlUpload" -H "x-ambry-owner-id : `whoami`" -H "x-ambry-content-type : image/gif" -H "x-ambry-um-description : Demonstration Image" http://localhost:1174/ --data-binary @demo.gif
HTTP/1.1 201 Created
Location: AmbryID
Content-Length: 0
The CUrl command creates a POST
request that contains the binary data in demo.gif. Along with the file data, we provide headers that act as blob properties. These include the size of the blob, the service ID, the owner ID and the content type.
In addition to these properties, Ambry also has a provision for arbitrary user defined metadata. We provide x-ambry-um-description
as user metadata. Ambry does not interpret this data and it is purely for user annotation.
The Location
header in the response is the blob ID of the blob we just uploaded.
Now that we stored a blob, let us verify some properties of the blob we uploaded.
$ curl -i http://localhost:1174/AmbryID/BlobInfo
HTTP/1.1 200 OK
x-ambry-blob-size: {Blob size}
x-ambry-service-id: CUrlUpload
x-ambry-creation-time: {Creation time}
x-ambry-private: false
x-ambry-content-type: image/gif
x-ambry-owner-id: {username}
x-ambry-um-desc: Demonstration Image
Content-Length: 0
Now that we have verified that Ambry returns properties correctly, let us obtain the actual blob.
$ curl http://localhost:1174/AmbryID > demo-downloaded.gif
$ diff demo.gif demo-downloaded.gif
$
This confirms that the data that was sent in the POST
request matches what we received in the GET
. If you would like to see the image, simply point your browser to http://localhost:1174/AmbryID
and you should see the image that was uploaded !
Ambry is an immutable store and blobs cannot be updated but they can be deleted in order to make them irretrievable. Let us go ahead and delete the blob we just created.
$ curl -i -X DELETE http://localhost:1174/AmbryID
HTTP/1.1 202 Accepted
Content-Length: 0
You will no longer be able to retrieve the blob properties or data.
$ curl -i http://localhost:1174/AmbryID/BlobInfo
HTTP/1.1 410 Gone
Content-Type: text/plain; charset=UTF-8
Content-Length: 17
Connection: close
Failure: 410 Gone
$ kill -15 frontendProcessID
$ kill -15 serverProcessID
You can confirm that the services have been shut down by looking at the logs.
In addition to the simple APIs demonstrated above, Ambry provides support for GET
of only user metadata and HEAD
. In addition to the POST
of binary data that was demonstrated, Ambry also supports POST
of multipart/form-data
via CUrl or web forms.
Other features of interest include:
-
Time To Live (TTL): During
POST
, a TTL in seconds can be provided through the addition of a header namedx-ambry-ttl
. This means that Ambry will stop serving the blob after the TTL has expired. OnGET
, expired blobs behave the same way as deleted blobs. -
Private: During
POST
, providing a header namedx-ambry-private
with the valuetrue
will mark the blob as private. API behavior can be configured based on whether a blob is public or private.
- Getting Started
- API
- Configuration
- Design
- Implementation
- Operations
- FAQ
- Project
- Future Work