How Smalltalker Works

Post on 16-Jul-2015

1357 Views

Category:

Engineering

2 Downloads

Preview:

Click to see full reader

Transcript

H o w S m a l l t a l k e r W o r k s

S m a l l t a l k三昧だった一年

@newapplesho

今日は忘年会。

今年1年を振り返ります。

S今年を1文字で表すとしたら

2 0 1 4年 5月

h t t p : / / w w w. s o r a b i t o . c o m

SORABITOの立ち上げ

開発言語

5%5%

14%

5%

29%

43%

Smalltalk Ruby Java PHP Perl FileMaker

2 0 1 4年 7月試験運用

2 0 1 4年 9月正式公開

h t t p s : / / m i k a t a c l o u d . c o m

Serviceの立ち上げ

L O V E I T O R L E AV E I T. I L O V E S M A L LTA L K .

Smalltalkを最も活用した年

最も勉強会の情報を最も活用している人かも

おそらく・・・

http://www.smalltalk-users.jp

サービス紹介で全国めぐり

Smalltalkのおかげで色々ありました

ステキなところで発表しました。

I L O V E S M A L LTA L K

Smalltalkのおかげで色々ありました

川に投げられたりしました

Smalltalkのおかげで色々ありました

パイをなげられたりしました

Smalltalkのおかげで色々ありました

そんな

S m a l l t a l kに

還元したいいちご以外で

詳しくは第42回Smalltalk勉強会

S m a l l t a l k A d v e n t C a l e n d a r 2 0 1 4に挑戦

• 10日分担当しました

• 正直大変でした

• 投稿遅れてすみません

http://qiita.com/advent-calendar/2014/smalltalk

A W S S D K f o r S m a l l t a l kM E R R Y C H R I S T M A S

公開することに

しました

開発経緯

Mikata(http://mikatacloud.com)を作るため

今回公開するもの

仕事を作成したものはサービスに特化させて作ってしまっため、業務外の時間を使って切り出して一般公開できるものを準備しました(いずれはSDK全てを公開します)。

https://mikatacloud.com/AWS SDK

for Smalltalk

A W S S D K f o r S m a l l t a l kM E R R Y C H R I S T M A S

DynamoDB

N o S Q Lって素敵だけど・・・

• 少数メンバーで運用するのは大変だったりする

• 例えばMongo Replica Setsを構成するには最低各DC

ゾーンに1台ずつ、Arbiter1台、計3台マシンが必要

• メモリやディスクI/Oに左右されたりする

A m a z o n D y n a m o D B

• キー・バリュー型のNoSQLデータベースサービス

• 管理不要で信頼性が高いデータベース

• データセンター間の自動同期レプリケーション

• 高速なアクセスが可能

• SSDを利用している

• ストレージ容量制限がない

• プロビジョンスループットだけを指定するだけ

• API(SDK)経由で利用できる

今回公開するもの

• AWSのほとんどのサービスにアクセスするためのSignature V4

• DynamoDBの接続クライアント(低レベル API、エラー処理は未実装)

• DynamoDBの簡易アクセス版(未完成)

サポートするデータ型 ( S U P P O R T S D ATA T Y P E S )

AWS SDK for Smalltalkで対応するデーター型は以下

* スカラーデータ型 - 文字列、数値 * 多値型 - 文字列セット、数値セット。

Amazon DynamoDB for Smalltalk supports the following data types:

* Scalar types – Number, String. * Multi-valued types – String Set, Number Set.

その他も実装中

だって他にやれることがないからね

ということで

DynamoDB使うしかない!

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

H o w t o i n s t a l l

The AWS SDK for Pharo Smalltalk enables Smalltalk developers to easily work with Amazon Web Services with Amazon DynamoDB. You can get started in minutes using Metacello and FileTree.

ごめんなさい。間に合いませんでした。後ほど

別途別の資料を用意します

R A W A P I編

C r e a t e Ta b l e s

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.

Used DynamoDB Local Sample

L i s t Ta b l e s

dy := DynamoDBRawClient new. dy awsConfig accessKeyId:'YOURACCESSKEY'. dy awsConfig secretKey:'YOURSECRETKEY'. dy awsConfig useSSL: false.

operationName := #ListTables. requestBody := '{}'. resp := dy operationName: operationName entityContents: requestBody. Json readFrom: (resp contents) readStream.

Used DynamoDB Local Sample

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);

P u t I t e m

dy := DynamoDBRawClient new. uuid := UUID new primMakeUUID hex. operationName := 'PutItem'. json := JsonObject new at:'TableName' put:'dmodeltest1';yourself. d:= DModelTest1 new. d id:uuid. mapper := DynamoDBMapper new. c := (mapper convertItem:d). json at:'Item' put: c . requestBody := json asJsonString . resp := dy operationName: operationName entityContents: requestBody.

Used DynamoDB Local Sample

G e t I t e m

operationName := 'GetItem'. 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. mapper loadItem: (result at:'Item') .

Used DynamoDB Local Sample

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 ]. ] .

Used DynamoDB Local Sample

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.

Used DynamoDB Local Sample

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.

Used DynamoDB Local Sample

簡易アクセス版

P u t I t e m

uuid := UUID new primMakeUUID hex. d:= DModelTest1 new. d id: uuid. d save.

Used DynamoDB Local Sample

DynamoDBModelを継承したModelを作成DynamoDBModelのDictionaryのインスタンス変数dataにアクセスしてModelを作成するだけ

G e t I t e m

"検索キーを作成"

keyData := DModelTest1 new. keyData id: uuid. result := d getItem: keyData.

Used DynamoDB Local Sample

その他

その他

• AWSDynamoDBConfigのendpoint:で接続するRegionを変更可能

• DynamoDB Localにも対応

• 英語が苦手なのでドキュメントの翻訳してくれる方募集

今後

• DynamoDB改良版

• S3

• EC2

• Elastic Transcoder

2015年公開予定

ただし私のポケットマネーと相談だったりする

Amazon EC2

DynamoDB

Amazon Elastic Transcoder

S3 Bucket

来年の開発言語

20%

15%

5%15%

45%

Smalltalk Ruby Java PHP Perl FileMaker

Scala

来年も

S

top related