Upgrade to Pro — share decks privately, control downloads, hide ads and more …

AWS SDK for Smalltalk

AWS SDK for Smalltalk

newapplesho

December 27, 2014
Tweet

More Decks by newapplesho

Other Decks in Programming

Transcript

  1. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. A

    W S S D K f o r S m a l l t a l k 2 0 1 4 M E R RY C H R I S T M A S @newapplesho
  2. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. S

    m a l l t a l k Ͱ ͷ R D B Ҏ ֎ ͷ ީ ิ • OmniBase • Magma • GemStone • MongoDB • Neo4j
  3. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. O

    m n i B a s e • SmalltalkͷΦϒδΣΫτࢦ޲σʔλʔϕʔε • GORISEK Ltd.ͷ੡඼ͰDolphin SmalltalkͰ։ൃ • VisualWorks, Squeakʹ΋Ҡ২͞Ε͍ͯΔ • 2014೥ʹGitHubʹιʔε͕Ҡߦʁ • MITϥΠηϯεʹͳͬͨ https://github.com/sebastianconcept/OmniBase
  4. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. M

    a g m a • SmalltalkͷΦϒδΣΫτࢦ޲σʔλʔϕʔε • SqueakͰ΋ͱ΋ͱ։ൃ͞Ε͍ͨ • Pharo, VisualWorksͰಈ͔͘ෆ໌ʁ http://wiki.squeak.org/squeak/2665
  5. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. G

    e m S t o n e • GemStone/S Smalltalkͷྺ࢙͋ΔOODB • SmalltalkͱDBػೳ͕ҰମԽ͞Ε͍ͨ͢͝Smalltalk • ঎༻ར༻Ͱ΋Ұ෦ϑϦʔͰ࢖͑ΔOODB • GLASSͱ͍͏WebಛԽͷ੡඼΋͋Δ https://github.com/GsDevKit/gsDevKitHome
  6. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. M

    o n g o D B • υΩϡϝϯτࢦ޲σʔλϕʔε • ඇৗʹ༗໊ͳNoSQL • Smalltalk༻υϥΠόʔ͸Kent Beck͞Μ͕࡞ͬͨ http://smalltalkhub.com/#!/~francois/MongoTalk
  7. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. N

    e o 4 j • άϥϑࢦ޲σʔλʔϕʔε • ෳࡶͳσʔλΛѻ͏ͷʹ࠷ద • Smalltalk͔Β͸Neo4reStΛ࢖ͬͯར༻Մೳ http://smalltalkhub.com/#!/~MasashiUmezawa/Neo4reSt
  8. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. ͲΕ΋ૉఢ͚ͩͲ

    Ϋϥ΢υαʔϏεΛ࡞Ζ͏ͱߟ͑Δͱɾɾɾ Mikata https://mikatacloud.com
  9. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. Ϗ

    δ ω ε Ͱ ݎ ࿚ ͳ N o S Q L Λ ӡ ༻ ͢ Δ ʹ ͸ • ҰਓͩͱେมͩͬͨΓ͢Δ • όοΫΞοϓ͕೉͍͠OODB • ελʔτΞοϓʹ͸ߴ͍঎༻ϥΠηϯε • Replica SetsΛߏ੒͢Δʹ͸࠷௿֤DCκʔϯʹ̍୆ͣ ͭɺArbiter̍୆ɺܭ̏୆Ϛγϯ͕ඞཁͩͬͨΓ • ϝϞϦ΍σΟεΫI/Oʹࠨӈ͞ΕͨΓ͢Δ
  10. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. ΋

    ͏ ߟ ͑Δ ͷ ͕ ݏ ʹ ͳ Δ ઒ʹඈͼࠐΉ͔͠ͳ͍
  11. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. 2

    0 1 4 ೥ 0 4 ݄ ͖͋ΒΊͣߟ͑·ͨ͠
  12. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. A

    m a z o n D y n a m o D B • ΩʔɾόϦϡʔܕͷNoSQLσʔλϕʔεαʔϏε • ؅ཧෆཁͰ৴པੑ͕ߴ͍σʔλϕʔε • σʔληϯλʔؒͷࣗಈಉظϨϓϦέʔγϣϯ • ߴ଎ͳΞΫηε͕Մೳ • SSDΛར༻͍ͯ͠Δ • ετϨʔδ༰ྔ੍ݶ͕ͳ͍ • ϓϩϏδϣϯεϧʔϓοτ͚ͩΛࢦఆ͢Δ͚ͩ • APIʢSDKʣܦ༝Ͱར༻Ͱ͖Δ
  13. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. S

    m a l l t a l k e r ͕ A W S Λ ࢖ ͏ ࡍ ͷ ໰ ୊ nodeJS iOS iOS Java Javascript Net nodeJS Android PHP Python Ruby Ruby SDK͕ͳ͍
  14. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. A

    W S S D K f o r S m a l l t a l k ࡞ Γ · ͠ ͨ https://github.com/newapplesho/aws-sdk-smalltalk
  15. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. ࠓ

    ճ ެ ։ ͢ Δ ΋ ͷ • Signature V4 • DynamoDBͷ઀ଓΫϥΠΞϯτʢ௿Ϩϕϧ APIɺΤ ϥʔॲཧ͸ະ࣮૷ʣ • DynamoDBͷ؆қΞΫηε൛ʢະ׬੒ʣ ͍ͣΕ͸͢΂ͯͷSDKΛެ։͢Δ༧ఆ DynamoDB
  16. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. A

    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
  17. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. D

    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
  18. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. A

    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. ͦͷଞ΋࣮૷த
  19. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. ͩ

    ͬͯ ଞ ʹ΍ Ε Δ ͜ ͱ ͕ ͳ ͍ ͔ Β Ͷ ͱ͍͏͜ͱͰ DynamoDB࢖͏͔͠ͳ͍ʂ
  20. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. H

    o w t o i n s t a l l S t e p 1 Get started in minutes using Metacello and FileTree. $ git clone https://github.com/newapplesho/aws-sdk-smalltalk
  21. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. H

    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.
  22. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. S

    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
  23. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. C

    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
  24. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. C

    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.
  25. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. L

    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.
  26. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. P

    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.
  27. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. P

    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);
  28. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. P

    u t I t e m dy := DynamoDBRawClient new. operationName := 'PutItem'. requestBody := '{"TableName":"dmodeltest1","Item":{"id": {"S":"af2d4b16147f45fea3753cc9c0a3f739"}}}' resp := dy operationName: operationName entityContents: requestBody.
  29. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. P

    u t I t e m DynamoDBModelΛܧঝͨ͠ModelΛ࡞੒ DynamoDBModelͷDictionaryͷΠϯελϯεม਺dataʹ ΞΫηεͯ͠ModelΛ࡞੒͢Δ͚ͩ
  30. P u t I t e m dy := DynamoDBRawClient

    new. operationName := 'PutItem'. 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:'Item' put: c . requestBody := json asJsonString . resp := dy operationName: operationName entityContents: requestBody. Json is generated in Smalltalk.
  31. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. G

    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
  32. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. G

    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') .
  33. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. Q

    u e r y operationName := 'Query'. json := JsonObject new at:'TableName' put:'dmodeltest1';yourself. d:= DModelTest1 new. d data at:#id put:uuid. mapper := DynamoDBMapper new. c := (mapper convertItem:d). c := JsonObject new at: (c keys first) put: ((JsonObject new at:'AttributeValueList' put: (Array with: c anyOne); yourself ) at:'ComparisonOperator' put:'EQ'; yourself); yourself. json at:'KeyConditions' put: c . json at:'Select' put: 'ALL_ATTRIBUTES'. requestBody := json asJsonString . resp := dy operationName: operationName entityContents: requestBody. result := Json readFrom: (resp contents) readStream. (result at:'Count') > 0 ifTrue:[ ^ (result at:'Items') collect:[:v | mapper loadItem:v ]. ] .
  34. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. D

    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.
  35. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. D

    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.
  36. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. P

    u t I t e m uuid := UUID new primMakeUUID hex. d:= DModelTest1 new. d id: uuid. d save. DynamoDBModelΛܧঝͨ͠ModelΛ࡞੒
  37. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. G

    e t I t e m "ݕࡧΩʔΛ࡞੒" keyData := DModelTest1 new. keyData id: uuid. result := d getItem: keyData.
  38. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. ͦ

    ͷ ଞ • AWSDynamoDBConfigͷendpoint:Ͱ઀ଓ͢ΔRegion ΛมߋՄೳ • DynamoDB Localʹ΋ରԠ • ӳޠ͕ۤखͳͷͰυΩϡϝϯτͷ຋༁ͯ͘͠ΕΔํื ू
  39. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. Τ

    ϯ υ ϙΠ ϯ τ ͷ ม ߋ http://docs.aws.amazon.com/general/latest/gr/rande.html Default AWSDynamoDBConfig initialize. AWSDynamoDBConfig default endpoint. 'dynamodb.ap-northeast-1.amazonaws.com' change endpoint AWSDynamoDBConfig initialize. AWSDynamoDBConfig default regionName:'us-west-2'. AWSDynamoDBConfig default endpoint. 'dynamodb.us-west-2.amazonaws.com' Regions and Endpoints Asia Pacific (Tokyo)
  40. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. D

    y n a m o D B L o c a l http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Tools.DynamoDBLocal.html ͱΓ͋͑ͣࢼ͍ͨ͠ਓ͸DynamoDB Local
  41. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. D

    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
  42. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. ࠓ

    ޙ ର Ԡ ͷ S m a l l t a l k • Squeak • VisualWorks • GemStone
  43. Copyright © 2014 SORABITO Co., Ltd. All Rights Reserved. ࠓ

    ޙ • DynamoDBվྑ൛ • S3 • EC2 • Elastic Transcoder 2015೥ެ։༧ఆ ͨͩ͠ࢲͷϙέοτϚωʔͱ ૬ஊͩͬͨΓ͢Δ Amazon EC2 DynamoDB Amazon Elastic Transcoder S3 Bucket