TIBCO Data Virtualization で Azure Data Lake Storage のデータ にリアルタイムアクセスする方法

CData TIBCO DV Adapter for Azure Data Lake Storage を使って、TIBCO Data Virtualization Studio でAzure Data Lake Storage のデータソースを作成し、TDV Server からAzure Data Lake Storage のデータにリアルタイムでアクセスする方法を解説します。

TIBCO Data Virtualization(TDV)は、複数の多様なデータソースへのアクセスを一元管理するエンタープライズデータ仮想化ソリューションです。CData TIBCO DV Adapter for Azure Data Lake Storage と組み合わせることで、TIBCO Data Virtualization 内からAzure Data Lake Storage のデータに直接フェデレーテッドアクセスが可能になります。この記事では、アダプターのデプロイと Azure Data Lake Storage に基づく新しいデータソースの作成手順を解説します。

CData TIBCO DV Adapter は、最適化されたデータ処理機能が組み込まれており、Azure Data Lake Storage のデータ とのインタラクションにおいて比類のないパフォーマンスを発揮します。Azure Data Lake Storage に対して複雑な SQL クエリを発行すると、アダプターはフィルタや集計などサポートされている SQL 操作を直接 Azure Data Lake Storage にプッシュします。組み込みの動的メタデータクエリにより、ネイティブのデータ型を使用してAzure Data Lake Storage のデータを操作・分析できます。

Azure Data Lake Storage TIBCO DV Adapter のデプロイ

  1. コンソールで、TDV Server のインストールディレクトリ内の bin フォルダに移動します。現在のバージョンのアダプターがインストールされている場合は、先にアンデプロイする必要があります。

    .\server_util.bat -server localhost -user admin -password ******** -undeploy -version 1 -name ADLS
    
  2. CData TIBCO DV Adapter をローカルフォルダに解凍し、解凍した場所から JAR ファイル(tdv.adls.jar)をサーバーにデプロイします。

    .\server_util.bat -server localhost -user admin -password ******** -deploy -package /PATH/TO/tdv.adls.jar
    

新しい JAR ファイルが正しくロードされるように、サーバーの再起動が必要な場合があります。再起動は、C:\Program Files\TIBCO\TDV Server <version>\bin にある composite.bat スクリプトを実行して行えます。サーバーを再起動した後は、TDV Studio への再認証が必要です。

再起動コマンドの例

.\composite.bat monitor restart

OAuth を使用して Azure Data Lake Storage で認証する

Azure Data Lake Storage は OAuth プロトコルを使用して認証を行いますが、TDV Studio は内部でブラウザベースの認証をサポートしていないため、OAuth トークンを取得するための簡単な Java アプリケーションを作成して実行する必要があります。取得したトークンは、アダプターから直接 Azure Data Lake Storage に接続するために使用されます。

Create the Java Application

  1. Create a new Java file with preferred name for example GenOAuthSettings.java. This Java file leverages the ADLSOAuth class contained within the TDV Adapter JAR to initiate a test connection and perform the required OAuth authentication flow
  2. Copy and insert the following code into the .java file:
  3. 
    public class GenOAuthSettings {
        public static void main(String[] args) {
            try {
        	    if (args.length != 2) {
        			throw new Exception("Input must have two arguments: 'data source', 'connection string'");
        		}
        
        		String source = args[0].replace(" ", "").toLowerCase();
        		String connectionString = args[1];
        		String prefix;
        
        		if (source.equals("adls")) {
        			prefix = "jdbc:adls:";
        
        			com.cdata.cis.adls.ADLSOAuth oauth = new com.cdata.cis.adls.ADLSOAuth();
        
        			if (!connectionString.startsWith(prefix)) connectionString = prefix + connectionString;
        			oauth.generateOAuthSettingsFile(connectionString);
        		}
        		// More sources can be added below using the same format.  You must add the import statement and ensure the jar file resides in the classpath
    			//            else if (source.equals("googlebigquery") || source.equals("bigquery")) {
    			//                prefix = "jdbc:googlebigquery:";
    			//
    			//                com.cdata.cis.googlebigquery.GoogleBigQueryOAuth oauth = new com.cdata.cis.googlebigquery.GoogleBigQueryOAuth();
    			//
    			//                if (!connectionString.startsWith(prefix)) connectionString = prefix + connectionString;
    			//                oauth.generateOAuthSettingsFile(connectionString);
    			//            }
        		else {
    				throw new Exception("Data Source not supported.  Available Data Sources: Azure Data Lake Storage");
    			}
    			
    			System.out.println("Test Connection Successful!");
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    	}
    }
    
  4. Place the .java file in the same directory as the tdv.adls.jar file. This is required to prevent classpath resolution errors during compilation and execution

Build and run the Java Application

  1. Open Console and navigate to the directory containing the .java file and adapter jar
  2. Compile the Java file using the following command:
  3. javac -cp .;tdv.adls.jar GenOAuthSettings.java
    
  4. Execute the application using one of the following commands:
  5. java -cp .;tdv.adls.jar GenOAuthSettings "ADLS" "connection string"
    

This command initiates the OAuth authentication flow and generates the OAuth settings file at the location specified in the OAuthSettingsLocation parameter. Once you deploy the adapter and authenticate, you can create a new data source for Azure Data Lake Storage in TDV Studio.

TDV Studio で Azure Data Lake Storage データソースを作成する

CData TIBCO DV Adapter for Azure Data Lake Storage を使用すると、Azure Data Lake Storage 用のデータソースを簡単に作成し、データソースをイントロスペクトしてリソースを TDV に追加できます。

データソースの作成

  1. データソースを追加するフォルダを右クリックし、New -> New Data Source を選択します。
  2. アダプター(例:Azure Data Lake Storage)が表示されるまでスクロールし、Next をクリックします。
  3. データソースに名前を付けます(例:CData Azure Data Lake Storage Source)。
  4. 必要な接続プロパティを入力します。

    Azure Data Lake Storage 接続プロパティの取得・設定方法

    Azure Data Lake Storage Gen2 への接続

    それでは、Gen2 Data Lake Storage アカウントに接続していきましょう。接続するには、以下のプロパティを設定します。

    • Account:ストレージアカウントの名前
    • FileSystem:このアカウントに使用されるファイルシステム名。例えば、Azure Blob コンテナの名前
    • Directory(オプション):レプリケートされたファイルが保存される場所へのパス。パスが指定されない場合、ファイルはルートディレクトリに保存されます

    Azure Data Lake Storage Gen2への認証

    続いて、認証方法を設定しましょう。CData 製品では、5つの認証方法をサポートしています:アクセスキー(AccessKey)の使用、共有アクセス署名(SAS)の使用、Azure Active Directory OAuth(AzureAD)経由、Azure サービスプリンシパル(AzureServicePrincipal またはAzureServicePrincipalCert)経由、およびManaged Service Identity(AzureMSI)経由です。

    アクセスキー

    アクセスキーを使用して接続するには、まずADLS Gen2ストレージアカウントで利用可能なアクセスキーを取得する必要があります。

    Azure ポータルでの手順は以下のとおりです:

    1. ADLS Gen2ストレージアカウントにアクセスします
    2. 設定でアクセスキーを選択します
    3. 利用可能なアクセスキーの1つの値をAccessKey 接続プロパティにコピーします

    接続の準備ができたら、以下のプロパティを設定してください。

    • AuthSchemeAccessKey
    • AccessKey:先ほどAzure ポータルで取得したアクセスキーの値

    共有アクセス署名(SAS)

    共有アクセス署名を使用して接続するには、まずAzure Storage Explorer ツールを使用して署名を生成する必要があります。

    接続の準備ができたら、以下のプロパティを設定してください。

    • AuthSchemeSAS
    • SharedAccessSignature:先ほど生成した共有アクセス署名の値

    その他の認証方法については、 href="/kb/help/" target="_blank">ヘルプドキュメントの「Azure Data Lake Storage Gen2への認証」セクションをご確認ください。

    NOTE:DV Adapter の OAuthSettingsLocation プロパティには、OAuth 認証(上記参照)を実行したときと同じ値を設定してください。

  5. Create & Close をクリックします。

データソースのイントロスペクト

データソースを作成したら、右クリックして Open を選択することでデータソースをイントロスペクトできます。ダッシュボードで Add/Remove Resources をクリックし、データソースの一部として含めるテーブル、ビュー、ストアドプロシージャを選択します。Next をクリックし、Finish をクリックして、選択した Azure Data Lake Storage のテーブル、ビュー、ストアドプロシージャをリソースとして追加します。

After creating and introspecting the data source, you are ready to work with Azure Data Lake Storage のデータ in TIBCO Data Virtualization just like you would any other relational data source. You can create views, query using SQL, publish the data source, and more.

データソースを作成してイントロスペクトしたら、他のリレーショナルデータソースと同様に TIBCO Data Virtualization でAzure Data Lake Storage のデータを操作できるようになります。ビューの作成、SQL によるクエリ、データソースの公開など、さまざまな操作が可能です。

はじめる準備はできましたか?

詳細:

TIBCO DV アダプタ