4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ログから見る CData Driver の動き

Last updated at Posted at 2016-12-01

CData Software は、世界中で知られた標準規格のデータドライバーを提供しています。いわゆるエレベータートークで30秒で CData Software の製品を説明すると、いろいろな反応や質問をいただきます。「Selesforce にはデータベースなんてないから、取ってこられないでしょ?」「まさかクラウドサービスのDBをハッキングして変な方法で取りに行っているのでは?」「なんでSQLでAPI にアクセスできるの?」「通信のセキュリティは大丈夫なの?」などなど。

そこで、この記事では、CData のログを解析して、CData がどうやってSaaSデータソースのデータと通信しているかを見てみましょう。ログを見ることで、ユーザーが正しい方法でデータソースに接続してくることが分かります。ログによって、開発者が接続の問題が発生したときに、トラブルの原因を探ることも用意です。システムインテグレータの方は ログを一度見ておくことで、エンドユーザーからのさまざまな質問に答えることができます。

  • データソースからドライバー側に送られてきている実際のデータはなに?
  • パフォーマンスに関連する接続プロパティ、たとえば、ページサイズやタイムアウト設定、最適なものに設定されているか?
  • アプリケーションン側からなんのSQL が投げられているのか?
  • 一定の時間にどれだけの数の接続を開いたのか?
  • データソースとの接続にはどれだけの時間がかかったのか? データ処理にはどれくらいの時間がかかったのか?

#ログの設定
使いたいドライバーをインストールします(こちらから30日の無償評価版が利用できます)。
データソース毎に必要な接続設定を行います。詳細はドキュメントの接続設定項を参照してください。
接続文字列や接続URL において、ログファイルのプロパティにファイルパス(例: C:\Users\public\SalesforceLog.txt)を設定します、次にVerbosity (ログの粒度)を1~5で設定します。

#ログの説明
実際にログからどアプリケーション(今回はExcel)、ドライバー、データソース(今回はSalesforce)との間で起こっていることを読み解きましょう。
下には、CData Software のSalesforce Driver のログが示されています。いくつかの項目ではセキュリティの関係上 データを省略・削除しています。

  1. Salesforce との接続がオープンします。
  2. 次にドライバー側から指定されたアカウントへの接続文字列が送られます。そこにはUser, Password, Security Token などが渡されています。
  3. コネクションが確立され、取引先(Account)テーブルからデータを取得するSQLが実行されています。
  4. 74項目のSQLが4msで発行されたと記録されています。
  5. SalesforceへのRequestはSOAP通信にてPOSTメソッドで発行されていることが確認できます。
  6. その際にSSL証明書が受け入れられたことも確認できます。
  7. Responseとして正常な[HTTP/1.1 200 OK]を受け取っています。
  8. その後にRequest時とResponse時のHTTP Headerの情報が記録されています。
  9. 最終的には接続がクローズされたことが確認できます。
2016-11-29T15:43:53.559+09:00	5	[Connection: 26]	_persist_oauthaccesstoken: [], _persist_oauthaccesstokensecret: [*****], _persist_token_timestamp: [], _persist_oauthexpiresin: [], _persist_oauthrefreshtoken: []
2016-11-29T15:43:53.560+09:00	1	[Connection: 26]	Opened Salesforce connection. Version: [15.0.6039.0]. Edition: [ Excel Add-In ].
2016-11-29T15:43:53.560+09:00	1	[Connection: 26]	Connection String: _userconnection="26";allornone="False";autocache="False";cachelocation="***";cachemetadata="False";callbackurl="http://localhost:33333";catalog="CData";firewalltype="NONE";initiateoauth="getandrefresh";logfile="***";loginurl="https://login.salesforce.com/services/Soap/c/33.0";oauthsessionexpiresin="900";offline="False";password="*****";proxyautodetect="True";readonly="False";schema="Salesforce";securitytoken="***";sessiontimeout="10";sslclientcertsubject="*";timeout="60";user="***";usesandbox="False";verbosity="1".
2016-11-29T15:43:53.560+09:00	2	[Connection: 26]	Executed query: [ SELECT  *  FROM [Account] LIMIT 10 ].
2016-11-29T15:43:53.561+09:00	5	[Connection: 26]	Retrieved 74 cached columns of the table Account.
2016-11-29T15:43:53.564+09:00	4	[Connection: 26]	Executed column schema query: [Account].Success: 74 results (4 ms)
2016-11-29T15:43:53.565+09:00	5	[Connection: 26]	Retrieved 74 cached columns of the table Account.
2016-11-29T15:43:53.594+09:00	5	[Connection: 26]	_persist_oauthaccesstoken: [], _persist_oauthaccesstokensecret: [*****], _persist_token_timestamp: [], _persist_oauthexpiresin: [], _persist_oauthrefreshtoken: []
2016-11-29T15:43:53.595+09:00	2	[Request] POST https://login.salesforce.com/services/Soap/c/33.0
2016-11-29T15:43:53.702+09:00	4	User Authorized SSL Cert: [TRUSTED] Server Cert: [LS0t...] Accepted: True
2016-11-29T15:43:53.901+09:00	2	[Response] HTTP/1.1 200 OK, 807 Bytes Transferred
2016-11-29T15:43:53.905+09:00	3	[Request]
[HTTP Headers]
HTTP Auth Scheme: 0
...

2016-11-29T15:43:53.905+09:00	3	[Response]
[HTTP Headers]
HTTP/1.1 200 OK
...

2016-11-29T15:43:53.965+09:00	5	[Connection: 26]	_persist_oauthaccesstoken: [], _persist_oauthaccesstokensecret: [*****], _persist_token_timestamp: [], _persist_oauthexpiresin: [], _persist_oauthrefreshtoken: []
2016-11-29T15:43:53.965+09:00	5	[Connection: 26]	Retrieved 74 cached columns of the table Account.
2016-11-29T15:43:53.967+09:00	2	[Request] POST https://ap.salesforce.com/services/Soap/c/33.0/00D10000000aTHc
2016-11-29T15:43:54.064+09:00	4	User Authorized SSL Cert: [] Server Cert: [LS0t...] Accepted: True
2016-11-29T15:43:54.185+09:00	2	[Response] HTTP/1.1 200 OK, 2565 Bytes Transferred
2016-11-29T15:43:54.185+09:00	3	[Request]
[HTTP Headers]
HTTP Auth Scheme: 0
...

2016-11-29T15:43:54.185+09:00	3	[Response]
[HTTP Headers]
HTTP/1.1 200 OK
...

2016-11-29T15:43:54.185+09:00	1	[Connection: 26]	Executed query: [ SELECT  *  FROM [Account] LIMIT 10 ]. Success: 10 results ( 625 ) ms
2016-11-29T15:43:54.914+09:00	4	[Connection: 26]	Executed sys_disconnect: Success: (2 ms)
2016-11-29T15:43:54.914+09:00	1	[Connection: 26]	Closed Salesforce connection.

このように、CData Driverでは SaaS に対して正規のAPIを発行して、データのやり取りを行っていることを確認できました。

4
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?