Created
October 22, 2012 04:32
-
-
Save jmakeig/3929646 to your computer and use it in GitHub Desktop.
HDFS Storage Technology Preview - REST bootstrapping
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# Bootstraps a REST interface for a database | |
# Customize database, host, port and authentication to fit your environment | |
DB="test-hdfs" | |
HOST="localhost" | |
PORT="8010" | |
AUTH="admin:admin" | |
echo "Setting up a REST interface for database $DB on port $PORT." | |
curl -s -S \ | |
-X POST \ | |
--data-binary "{\"rest-api\" : {\"name\":\"$DB-rest\",\"database\":\"$DB\",\"port\":$PORT}}" \ | |
-H "Content-type: application/json" \ | |
--anyauth --user $AUTH \ | |
"http://$HOST:8002/v1/rest-apis" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# Inserts 500 documents into a database, does a key-value search, | |
# and retrieves a document. | |
# Customize host, port and authentication to fit your environment | |
HOST="localhost" | |
PORT="8010" | |
AUTH="admin:admin" | |
echo "Inserting 500 documents of the form, {\"data\": 99}" | |
for i in {1..500} | |
do | |
curl -s -S \ | |
-X PUT \ | |
-H "Content-type: application/json" \ | |
--data-binary "{\"data\": $i}" \ | |
--anyauth --user $AUTH \ | |
"http://$HOST:$PORT/v1/documents?uri=/$i.json" | |
done | |
echo | |
echo "Found the document whose data element is equal to 434" | |
curl -s -S \ | |
-X GET \ | |
-H "Accept: application/json" \ | |
--anyauth --user $AUTH \ | |
"http://$HOST:$PORT/v1/keyvalue?key=data&value=434" | |
echo | |
echo | |
echo "Retrieved a document by unique name" | |
curl -s -S \ | |
-X GET \ | |
--anyauth --user $AUTH \ | |
"http://$HOST:$PORT/v1/documents?uri=/434.json" | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment