m n i B a s e • SmalltalkͷΦϒδΣΫτࢦσʔλʔϕʔε • GORISEK Ltd.ͷͰDolphin SmalltalkͰ։ൃ • VisualWorks, SqueakʹҠ২͞Ε͍ͯΔ • 2014ʹGitHubʹιʔε͕Ҡߦʁ • MITϥΠηϯεʹͳͬͨ https://github.com/sebastianconcept/OmniBase
e m S t o n e • GemStone/S Smalltalkͷྺ࢙͋ΔOODB • SmalltalkͱDBػೳ͕ҰମԽ͞Ε͍ͨ͢͝Smalltalk • ༻ར༻ͰҰ෦ϑϦʔͰ͑ΔOODB • GLASSͱ͍͏WebಛԽͷ͋Δ https://github.com/GsDevKit/gsDevKitHome
m a z o n D y n a m o D B • ΩʔɾόϦϡʔܕͷNoSQLσʔλϕʔεαʔϏε • ཧෆཁͰ৴པੑ͕ߴ͍σʔλϕʔε • σʔληϯλʔؒͷࣗಈಉظϨϓϦέʔγϣϯ • ߴͳΞΫηε͕Մೳ • SSDΛར༻͍ͯ͠Δ • ετϨʔδ༰ྔ੍ݶ͕ͳ͍ • ϓϩϏδϣϯεϧʔϓοτ͚ͩΛࢦఆ͢Δ͚ͩ • APIʢSDKʣܦ༝Ͱར༻Ͱ͖Δ
W S S i g n a t u re Ve r s i o n 4 • ଟ͘ͷAWSαʔϏεͱΓऔΓ͢Δͱ͖ඞཁ • Signature version 4 signing process http://docs.aws.amazon.com/general/latest/gr/signature-version-4.html
y n a m o D B H T T P A P I • SSLଓ • URLશͯ/ɻURLͰॲཧ༰Λࢦఆ͠ͳ͍ • ϔομʔͷx-amz-targetͰॲཧ༰Λࢦఆ͢Δ • ΤϯυϙΠϯτσʔλʔηϯλʔͷॴΛࢦఆ • JSONܗࣜͰૹ৴ɺJSONܗࣜͰड৴ • ϔομʔʹx-amz-dateͱ͍͏ISO 8601ܗࣜʢྫ: 20130315T092054Zʣ ͷΛೖΕͳ͚ΕͳΒͳ͍ http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/MakingHTTPRequests.html
W S S D K f o r S m a l l t a l k D y n a m o D B AWS SDK for Smalltalk DynamoDBͰରԠ͢Δσʔλʔܕ * εΧϥʔσʔλܕ - จࣈྻɺ * ଟܕ - จࣈྻηοτɺηοτɻ Amazon DynamoDB for Smalltalk supports the following data types: * Scalar types – Number, String. * Multi-valued types – String Set, Number Set. ͦͷଞ࣮த
o w t o i n s t a l l S t e p 2 Get started in minutes using Metacello and FileTree. | pathToPackageDirectory | "edit to match the path to your chosen package directory" pathToPackageDirectory := ‘/YOUR-GIT-DIRECTORY-PATH/aws-sdk-smalltalk/pharo- repository/‘. Metacello new baseline: 'AWS'; repository: 'filetree://', pathToPackageDirectory; load.
e t u p awsConfig := AWSDynamoDBConfig default. awsConfig accessKeyId:'YOURACCESSKEY'. awsConfig secretKey:'YOURSECRETKEY'. dy := DynamoDBRawClient new. dy awsConfig accessKeyId:'YOURACCESSKEY'. dy awsConfig secretKey:'YOURSECRETKEY'. or
re a t e Ta b l e DynamoDB DynamoDB Table C o l u m n Ty p e K e y S c h e m a i d S t r i n g H A S H { "AttributeDefinitions": [ { "AttributeName": "id", "AttributeType": "S"} ], "TableName": "dmodeltest1", "KeySchema": [ { "AttributeName": "id", "KeyType": "HASH"}], "ProvisionedThroughput": { "ReadCapacityUnits": 10, "WriteCapacityUnits": 10} } dmodeltest1
re a t e Ta b l e dy := DynamoDBRawClient new. operationName := #CreateTable. requestBody := '{ "AttributeDefinitions": [ { "AttributeName": "id", "AttributeType": "S"} ], "TableName": "dmodeltest1", "KeySchema": [ { "AttributeName": "id", "KeyType": "HASH"}], "ProvisionedThroughput": { "ReadCapacityUnits": 10, "WriteCapacityUnits": 10} }'. resp := dy operationName: operationName entityContents: requestBody.
i s t Ta b l e s dy := DynamoDBRawClient new. operationName := #ListTables. requestBody := '{}'. resp := dy operationName: operationName entityContents: requestBody. Json readFrom: (resp contents) readStream.
u t I t e m DynamoDB Item C o l u m n Ty p e K e y S c h e m a i d S t r i n g H A S H {"TableName":"dmodeltest1", "Item": {"id": {"S":"af2d4b16147f45fea3753cc9c0a3f739"} } } DynamoDB Table UUID new primMakeUUID hex.
u t I t e m ( J a v a ) client = new AmazonDynamoDBClient(credentials); String tableName = "dmodeltest1"; Map<String, AttributeValue> item = new HashMap<String, AttributeValue>(); item.put("id", new AttributeValue().withS("babe2d60c42a45fca9120d1c111d8844")); PutItemRequest putItemRequest = new PutItemRequest() .withTableName(tableName) .withItem(item); PutItemResult result = client.putItem(putItemRequest);
u t I t e m dy := DynamoDBRawClient new. operationName := 'PutItem'. requestBody := '{"TableName":"dmodeltest1","Item":{"id": {"S":"af2d4b16147f45fea3753cc9c0a3f739"}}}' resp := dy operationName: operationName entityContents: requestBody.
e t I t e m DynamoDB Item C o l u m n Ty p e K e y S c h e m a i d S t r i n g H A S H {"TableName":"dmodeltest1", "Key": {"id": {"S":"af2d4b16147f45fea3753cc9c0a3f739"} } } DynamoDB Table
e t I t e m operationName := 'GetItem'. json := JsonObject new at:'TableName' put:'dmodeltest1';yourself. d:= DModelTest1 new. d at: ‘id’ put:‘af2d4b16147f45fea3753cc9c0a3f739’. mapper := DynamoDBMapper new. c := (mapper convertItem:d). json at:'Key' put: c . requestBody := json asJsonString . resp := dy operationName: operationName entityContents: requestBody. result := Json readFrom: (resp contents) readStream. mapper loadItem: (result at:'Item') .
e l e t e I t e m operationName := 'DeleteItem'. json := JsonObject new at:'TableName' put:'dmodeltest1';yourself. d:= DModelTest1 new. d id:uuid. mapper := DynamoDBMapper new. c := (mapper convertItem:d). json at:'Key' put: c . requestBody := json asJsonString. resp := dy operationName: operationName entityContents: requestBody. result := Json readFrom: (resp contents) readStream.
e l e t e Ta b l e operationName := #DeleteTable. requestBody := JsonObject new at:'TableName' put:'dmodeltest1'; asJsonString . resp := dy operationName: operationName entityContents: requestBody. Json readFrom: (resp contents) readStream.
y n a m o D B L o c a l ࣮ ߦ ํ ๏ $ java -jar DynamoDBLocal.jar –Djava.library.path=. AWSDynamoDBConfig initialize. AWSDynamoDBConfig developmentDynamoDBSetting. Set up