Asakusa Frameworkのasakusa runのメモ。
Asakusa CLIのrunサブコマンドは、Asakusaバッチを実行する。
従来、バッチの実行はYAESSで行っていた。
単純に実行するだけなら、今後はasakusa runコマンドの方が良さそう?
ただし、YAESSにはyaess-ssh等の高度な機能があり、そういったものはasakusa runには無い。
asakusa run バッチID [-A 引数=値 …]
$ asakusa run m3bp.example.summarizeSales -A date=2011-04-01
runサブコマンドを試している最中に遭遇したエラー。
実行環境にHadoopがインストールされていないと以下のようなエラーが発生する。
$ asakusa run m3bp.example.summarizeSales -A date=2011-04-01 which: no hadoop in (/usr/java/default/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/home/asakusa/.local/bin:/home/asakusa/bin:/home/asakusa/.local/bin:/home/asakusa/bin:/home/asakusa/asakusa/bin) $HADOOP_CMD is not defined [ERROR] error occurred while executing command com.asakusafw.utils.jcommander.CommandExecutionException: executing batch "m3bp.example.summarizeSales" was failed at com.asakusafw.workflow.cli.run.RunCommand.run(RunCommand.java:85) at java.util.Optional.ifPresent(Optional.java:159) at com.asakusafw.operation.tools.portal.AsakusaPortal.exec(AsakusaPortal.java:90) at com.asakusafw.operation.tools.portal.AsakusaPortal.main(AsakusaPortal.java:63) Caused by: java.io.IOException: failed to execute task: command=/home/asakusa/asakusa/m3bp/bin/execute, arguments=[m3bp.example.summarizeSales, byCategory, f76b5cd0-1bbf-43bc-9391-89ee07b13b34, date=2011-04-01, com.asakusafw.m3bp.generated.Application], exit=1 at com.asakusafw.workflow.executor.basic.BasicCommandTaskExecutor.execute(BasicCommandTaskExecutor.java:154) at com.asakusafw.workflow.executor.basic.BasicCommandTaskExecutor.execute(BasicCommandTaskExecutor.java:87) at com.asakusafw.workflow.executor.basic.BasicJobflowExecutor.executePhase(BasicJobflowExecutor.java:124) at com.asakusafw.workflow.executor.basic.BasicJobflowExecutor.execute(BasicJobflowExecutor.java:72) at com.asakusafw.workflow.executor.basic.BasicBatchExecutor.executeJobflow(BasicBatchExecutor.java:180) at com.asakusafw.workflow.executor.basic.BasicBatchExecutor.execute(BasicBatchExecutor.java:117) at com.asakusafw.workflow.cli.run.RunCommand.run(RunCommand.java:78) ... 3 more
> asakusa run vanilla.example.summarizeSales -A date=2011-04-01 Exception in thread "main" java.lang.IllegalStateException: classpath entry must exist: D:\cygwin\home\hishidama\asakusa\hadoop\lib at com.asakusafw.vanilla.bootstrap.Classpath.addEntries(Classpath.java:76) at com.asakusafw.vanilla.bootstrap.VanillaBootstrap.buildClasspath(VanillaBootstrap.java:79) at com.asakusafw.vanilla.bootstrap.VanillaBootstrap.exec(VanillaBootstrap.java:61) at com.asakusafw.vanilla.bootstrap.VanillaBootstrap.main(VanillaBootstrap.java:53) [ERROR] error occurred while executing command com.asakusafw.utils.jcommander.CommandExecutionException: executing batch "vanilla.example.summarizeSales" was failed at com.asakusafw.workflow.cli.run.RunCommand.run(RunCommand.java:85) at java.base/java.util.Optional.ifPresent(Unknown Source) at com.asakusafw.operation.tools.portal.AsakusaPortal.exec(AsakusaPortal.java:90) at com.asakusafw.operation.tools.portal.AsakusaPortal.main(AsakusaPortal.java:63) Caused by: java.io.IOException: failed to execute task: command=D:\cygwin\home\hishidama\asakusa\vanilla\bin\execute.CMD, arguments=[vanilla.example.summarizeSales, byCategory, dbf8bd32-22f0-458b-a150-59bb8ad1ca75, date=2011-04-01, com.asakusafw.vanilla.generated.Application], exit=1 at com.asakusafw.workflow.executor.basic.BasicCommandTaskExecutor.execute(BasicCommandTaskExecutor.java:154) at com.asakusafw.workflow.executor.basic.BasicCommandTaskExecutor.execute(BasicCommandTaskExecutor.java:87) at com.asakusafw.workflow.executor.basic.BasicJobflowExecutor.executePhase(BasicJobflowExecutor.java:124) at com.asakusafw.workflow.executor.basic.BasicJobflowExecutor.execute(BasicJobflowExecutor.java:72) at com.asakusafw.workflow.executor.basic.BasicBatchExecutor.executeJobflow(BasicBatchExecutor.java:180) at com.asakusafw.workflow.executor.basic.BasicBatchExecutor.execute(BasicBatchExecutor.java:117) at com.asakusafw.workflow.cli.run.RunCommand.run(RunCommand.java:78) ... 3 more
実行環境にHadoopをインストールしない場合、AsakusaFWが用意するHadoopライブラリーを使用する方法がある。
build.gradleに設定を追加する。
〜 asakusafwOrganizer { profiles.prod { hadoop.embed true } profiles.dev { hadoop.embed true } 〜 }
profiles.prod
は本番環境用の設定、profiles.dev
は開発環境用の設定。(profiles.dev
はShafuの「Asakusa
Frameworkのインストール」で使用される)
「hadoop.embed true
」を記述してデプロイメントアーカイブを作成すると、アーカイブの中にHadoopが入れられ、それが使われるようになる。
(ちなみに、AsakusaFW 0.10.0より前は「hadoop.embed
」ではない別の設定方法だった)
Java9で実行すると以下のようなエラーが発生する。
Exception in thread "main" java.lang.ExceptionInInitializerError at org.apache.hadoop.util.StringUtils.(StringUtils.java:80) at org.apache.hadoop.fs.FileSystem$Cache$Key. (FileSystem.java:2823) at org.apache.hadoop.fs.FileSystem$Cache$Key. (FileSystem.java:2818) at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:2684) at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:373) at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:172) at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:357) at org.apache.hadoop.fs.Path.getFileSystem(Path.java:295) at com.asakusafw.runtime.directio.hadoop.HadoopDataSourceProfile.convert(HadoopDataSourceProfile.java:462) 〜 Caused by: java.lang.StringIndexOutOfBoundsException: begin 0, end 3, length 1 at java.base/java.lang.String.checkBoundsBeginEnd(Unknown Source) at java.base/java.lang.String.substring(Unknown Source) at org.apache.hadoop.util.Shell. (Shell.java:52) ... 31 more
たぶん、2017年12月時点でHadoopがJava9に対応していない。