Gradleによるステップの作成とFlowへの追加
開始する前に
以下が必要です。
- Java SE JDK 8以降
- MarkLogic 9.0-7以降
- Gradle 4.6以降
このタスクについて
Flowには少なくとも1つのステップが必要です。GradleによるFlowを作成する場合、結果のFlow定義ファイルには、事前定義された各タイプのステップ(読み込み、マッピング、マスタリング)のサンプルコードが含まれます。
Flowを作成した後、GradleタスクhubCreateStepDefinitionを使用して、カスタマイズ可能なステップ定義を初期化できます。次に、ステップ定義ファイルからJSONをコピーしてFlow定義ファイルに貼り付ける必要があります。
手順
これらの命令をカスタマイズするには、作成するステップのタイプを選択します。
- Gradleによる、ステップの定義を作成します。
- コマンドラインウィンドウを開き、プロジェクトのルートディレクトリに移動します。
- プロジェクトルートで、GradleタスクhubCreateStepDefinitionを実行します。この場合、
ingestion
としてstepTypeを設定します。mapping
としてstepTypeを設定します。mastering
としてstepTypeを設定します。custom
としてstepTypeを設定します。./gradlew hubCreateStepDefinition -PstepDefName=your-ingestion-step-name -PstepDefType=ingestion gradlew.bat hubCreateStepDefinition -PstepDefName=your-ingestion-step-name -PstepDefType=ingestion ./gradlew hubCreateStepDefinition -PstepDefName=your-mapping-step-name -PstepDefType=mapping gradlew.bat hubCreateStepDefinition -PstepDefName=your-mapping-step-name -PstepDefType=mapping ./gradlew hubCreateStepDefinition -PstepDefName=your-mastering-step-name -PstepDefType=mastering gradlew.bat hubCreateStepDefinition -PstepDefName=your-mastering-step-name -PstepDefType=mastering ./gradlew hubCreateStepDefinition -PstepDefName=your-custom-step-name -PstepDefType=custom gradlew.bat hubCreateStepDefinition -PstepDefName=your-custom-step-name -PstepDefType=custom 注:デフォルトのstepTypeはcustom
です。ステップ定義ファイルが作成されます。
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
- ステップ定義ファイルで、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 }
- ステップをFlowに手動で追加します。
- テキストエディタで、ステップ定義ファイルを開きます。デフォルトの読み込みステップ定義ファイルには、以下が含まれています。
{ "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" : "" } }
- 同様に、Flow定義ファイルを開きます。
Flow定義ファイルは、
your-project-root/flows
にあります。ステップのないデフォルトのFlow定義ファイルには、以下が含まれています。
{ "name" : "your-flow-name", "description" : "flow description", "identifier" : "", "steps" : {} }
steps
ノードでは、ステップをキー/バリューペアとして追加します。- キーには、シーケンスのステップの順序を表す数字を含む文字列を入力します。注:Flowの
steps
ノード内でキーが一意である限り、ステップは任意の順序でリストに含めることができます。キーが重複すると、想定しない結果が生じる場合があります。キー番号は0より大きくする必要があります。 - バリューには、ステップ定義ファイルのコンテンツ全体をコピーして貼り付けます。
- キーには、シーケンスのステップの順序を表す数字を含む文字列を入力します。
- 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" : "" } } } }
- テキストエディタで、ステップ定義ファイルを開きます。