Flink プロジェクトは異なるビルドツールを使ってビルドすることができます。素早く始めるために、Flinkは以下のビルドツールのためのプロジェクトテンプレートを提供します:
これらのテンプレートはプロジェクトの構造をセットアップし初期ビルドファイルを生成するのに役立ちます。
以下の2つの方法のどちらかを使って新しいプロジェクトの土台を作ることができます:
プロジェクトをビルドするためには、単純にsbt clean assembly
コマンドを発行する必要があります。これは fat-jar your-project-name-assembly-0.1-SNAPSHOT.jarをtarget/scala_your-major-scala-version/ディレクトリに生成するでしょう。
プロジェクトを実行するには、sbt run
コマンドを実行する必要があります。
デフォルトでは、sbt
が実行しているのと同じJVM内でジョブを実行するでしょう。別個のJVM内でジョブを実行するには、以下の行をbuild.sbt
に追加してください。
Flink ジョブ開発には、IntelliJの使用をお勧めします。開始するには、新しく生成されたプロジェクトをIntelliJにインポートする必要があります。これはFile -> New -> Project from Existing Sources...
からプロジェクトのディレクトリを選択することで行うことができます。IntelliJ は自動的にbuild.sbt
ファイルを検知し全てをセットアップすることができます。
Flinkジョブを実行するためには、Run/Debug ConfigurationのクラスパスとしてmainRunner
モジュールを選択することをお勧めします。これにより、providedに設定されている全ての依存が実行時に利用可能になることを確実にします。Run -> Edit Configurations...
を使ってRun/Debug Configurations を設定し、Use classpath of module ドロップボックスからmainRunner
を選択することができます。
新しく作成されたプロジェクトをEclipseにインポートするには、まずそのためのEclipseプロジェクトを生成する必要があります。これらのプロジェクトファイルはsbteclipse プラグインを使って生成することができます。以下の行を PROJECT_DIR/project/plugins.sbt
ファイルに追加してください:
Eclipseプロジェクトファイルを生成するために、sbt
の中で以下のコマンドを使用します
これで、File -> Import... -> Existing Projects into Workspace
を使ってEclipseにプロジェクトをインポートし、プロジェクトディレクトリを選択することができます。
The only requirements are working Maven 3.0.4 (or higher) and Java 8.x installations.
プロジェクトを作成するために以下のコマンドのうちの一つを使います:
注意: Maven 3.0 以上については、コマンドラインを使ってレポジトリを指定 (-DarchetypeCatalog) することはもうできません。レポジトリのスナップショットを使いたい場合は、settings.xml にレポジトリのエントリを追加する必要があります。この変更についての詳細は、Maven公式ドキュメントを参照してください
作業ディレクトリ内に新しいディレクトリがあるでしょう。curl のやり方を使った場合は、ディレクトリはquickstart
と呼ばれます。そうでなければ、それはartifactId
の名前を持ちます。
The sample project is a Maven project, which contains two classes: StreamingJob and BatchJob are the basic skeleton programs for a DataStream and DataSet program. The main method is the entry point of the program, both for in-IDE testing/execution and for proper deployments.
このプロジェクトをIDEにインポートすることをお勧めします。
IntelliJ IDEA supports Maven out of the box and offers a plugin for Scala development. From our experience, IntelliJ provides the best experience for developing Flink applications.
Eclipseについては、Eclipse Update Sitesからインストールすることができる以下のプラグインが必要です:
If you want to build/package your project, go to your project directory and
run the ‘mvn clean package
’ command.
You will find a JAR file that contains your application, plus connectors and libraries
that you may have added as dependencoes to the application: target/<artifact-id>-<version>.jar
.
Note: If you use a different class than StreamingJob as the application’s main class / entry point,
we recommend you change the mainClass
setting in the pom.xml
file accordingly. That way, the Flink
can run time application from the JAR file without additionally specifying the main class.
アプリケーションを書きます!
If you are writing a streaming application and you are looking for inspiration what to write, take a look at the Stream Processing Application Tutorial
If you are writing a batch processing application and you are looking for inspiration what to write, take a look at the Batch Application Examples
For a complete overview over the APIa, have a look at the DataStream API and DataSet API sections.
If you have any trouble, ask on our Mailing List. 喜んで手伝います。