Gradleによるステップの作成とFlowへの追加

開始する前に

以下が必要です。

このタスクについて

Flowには少なくとも1つのステップが必要です。GradleによるFlowを作成する場合、結果のFlow定義ファイルには、事前定義された各タイプのステップ(読み込み、マッピング、マスタリング)のサンプルコードが含まれます。

Flowを作成した後、GradleタスクhubCreateStepDefinitionを使用して、カスタマイズ可能なステップ定義を初期化できます。次に、ステップ定義ファイルからJSONをコピーしてFlow定義ファイルに貼り付ける必要があります。

手順

  1. Gradleによる、ステップの定義を作成します。
    1. コマンドラインウィンドウを開き、プロジェクトのルートディレクトリに移動します。
    2. プロジェクトルートで、GradleタスクhubCreateStepDefinitionを実行します。この場合、ingestionとしてstepTypeを設定します。mappingとしてstepTypeを設定します。masteringとしてstepTypeを設定します。customとしてstepTypeを設定します。
      ./gradlew hubCreateStepDefinition -PstepDefName=your-ingestion-step-name -PstepDefType=ingestiongradlew.bat hubCreateStepDefinition -PstepDefName=your-ingestion-step-name -PstepDefType=ingestion
      ./gradlew hubCreateStepDefinition -PstepDefName=your-mapping-step-name -PstepDefType=mappinggradlew.bat hubCreateStepDefinition -PstepDefName=your-mapping-step-name -PstepDefType=mapping
      ./gradlew hubCreateStepDefinition -PstepDefName=your-mastering-step-name -PstepDefType=masteringgradlew.bat hubCreateStepDefinition -PstepDefName=your-mastering-step-name -PstepDefType=mastering
      ./gradlew hubCreateStepDefinition -PstepDefName=your-custom-step-name -PstepDefType=customgradlew.bat hubCreateStepDefinition -PstepDefName=your-custom-step-name -PstepDefType=custom
      注:デフォルトのstepTypecustomです。

      ステップ定義ファイルが作成されます。

      your-project-root/step-definitions/ingestion/your-ingestion-step-name/your-ingestion-step-name.step.json
      your-project-root/step-definitions/mapping/your-mapping-step-name/your-mapping-step-name.step.json
      your-project-root/step-definitions/mastering/your-mastering-step-name/your-mastering-step-name.step.json
      your-project-root/step-definitions/custom/your-custom-step-name/your-custom-step-name.step.json
    3. ステップ定義ファイルで、modulePathの値をこのステップのカスタムモジュールへの正しいパスに置き換えます。
      { "name" : "your-step-name", "type" : "the-step-type", "version" : 1, "options" : { "collections" : [ "your-step-name" ], "outputFormat" : "json" }, "customHook" : { }, "language" : "zxx", "modulePath" : "/path/to/your/step/module/main.sjs", "identifier" : null }
  2. ステップをFlowに手動で追加します。
    1. テキストエディタで、ステップ定義ファイルを開きます。
      デフォルトの読み込みステップ定義ファイルには、以下が含まれています。
      { "language" : "zxx", "name" : "your-ingestion-step-def-name", "description" : null, "type" : "INGESTION", "version" : 1, "options" : { "collections" : [ "your-ingestion-step-def-name" ], "outputFormat" : "json", "targetDatabase" : "data-hub-STAGING" }, "customHook" : { }, "modulePath" : "/custom-modules/ingestion/your-ingestion-step-def-name/main.sjs", "retryLimit" : 0, "batchSize" : 100, "threadCount" : 4, "fileLocations" : { "inputFilePath" : "", "outputURIReplacement" : "", "inputFileType" : "" } }
    2. 同様に、Flow定義ファイルを開きます。

      Flow定義ファイルは、your-project-root/flowsにあります。

      ステップのないデフォルトのFlow定義ファイルには、以下が含まれています。

      { "name" : "your-flow-name", "description" : "flow description", "identifier" : "", "steps" : {} }
    3. stepsノードでは、ステップをキー/バリューペアとして追加します。
      • キーには、シーケンスのステップの順序を表す数字を含む文字列を入力します。
        注:Flowのstepsノード内でキーが一意である限り、ステップは任意の順序でリストに含めることができます。キーが重複すると、想定しない結果が生じる場合があります。キー番号は0より大きくする必要があります。
      • バリューには、ステップ定義ファイルのコンテンツ全体をコピーして貼り付けます。
    4. Flow定義ファイルでステップを編集します。
      • nameの設定をstepDefinitionNameに変更します。
      • typeの設定をstepDefinitionTypeに変更します。
      • 新しいnameの設定を作成し、ステップの名前を割り当てます。
      • (オプション)次の設定を削除します。
        • language
        • version
        • modulePath

        これらの設定の値は、ステップ定義から取得されます。

    最初のステップ(「1」)としてデフォルトの読み込みステップをデフォルトのFlowに追加すると、Flow定義ファイルは次のようになります。

    { "name": "your-flow-name", "description": "", "batchSize": 100, "threadCount": 4, "options": { "sourceQuery": null }, "steps": { "1": { "name" : "your-step-name", "stepDefinitionName" : "your-ingestion-step-def-name", "description" : null, "stepDefinitionType" : "INGESTION", "options" : { "collections" : [ "your-ingestion-step-name" ], "outputFormat" : "json", "targetDatabase" : "data-hub-STAGING" }, "customHook" : { }, "retryLimit" : 0, "batchSize" : 100, "threadCount" : 4, "fileLocations" : { "inputFilePath" : "", "outputURIReplacement" : "", "inputFileType" : "" } } } }