Kohei Nozaki's blog 

StepContext#persistentUserDataで遊ぶ


Posted on Sunday Feb 16, 2014 at 07:43AM in Technology


StepContext#persistentUserDataにはStepに紐づくデータを保存しておける。ここに入れたデータはJobRepositoryに保存され、後続のStepやジョブの再実行時に参照できる。何かしら使い道があると思われるので若干遊んでみる

環境・前提条件

関連メソッドの仕様を見てみる

[1]から引いてみる

javax.batch.runtime.context.StepContextインタフェース

Stepに関連する操作をする時に使うインタフェース。artifactで@Injectで注入して使える。

    /**
     * The getPersistentUserData method returns a persistent data object 
     * belonging to the current step. The user data type must implement 
     * java.util.Serializable. This data is saved as part of a step's 
     * checkpoint. For a step that does not do checkpoints, it is saved 
     * after the step ends. It is available upon restart. 
     * @return user-specified type
     */
    public Serializable getPersistentUserData();

    /**
     * The setPersistentUserData method stores a persistent data object 
     * into the current step. The user data type must implement 
     * java.util.Serializable. This data is saved as part of a step's 
     * checkpoint. For a step that does not do checkpoints, it is saved 
     * after the step ends. It is available upon restart. 
     * @param data is the user-specified type
     */ 
    public void setPersistentUserData(Serializable data);

javax.batch.runtime.StepExecutionインタフェース

Stepの実行履歴的な情報を含むインタフェース。JobOperatorを使って引っ張って来れたり、Deciderのメソッドの引数で受け取れたりする。

    /**
     * Get user persistent data
     * @return persistent data 
     */
    public Serializable getPersistentUserData();

先行StepでセットしたpersistentUserDataを後続Stepで参照してみる

サンプルの仕様

  • 第一レベルの要素は動作順に以下
    1. set (setPersistentUserDataBatchlet)
    2. get (getPersistentUserDataBatchlet)
  • setでセットしたpersistentUserDataをgetで参照してみる

資源

資源はこのへんにまとめて全部ある

動かしてみる

ログ

08:52:02,642 FINE  [org.nailedtothex.jbatch.example.persistentuserdata.SetPersistentUserDataBatchlet] (batch-batch - 4) set: process()
08:52:02,649 FINE  [org.nailedtothex.jbatch.example.persistentuserdata.GetPersistentUserDataBatchlet] (batch-batch - 4) get: process()
08:52:02,650 FINE  [org.nailedtothex.jbatch.example.persistentuserdata.GetPersistentUserDataBatchlet] (batch-batch - 4) stepExecution: stepName=set, persistentUserData=* my step name is set *
08:52:02,650 FINE  [org.nailedtothex.jbatch.example.persistentuserdata.GetPersistentUserDataBatchlet] (batch-batch - 4) stepExecution: stepName=get, persistentUserData=null

setステップで設定した「 my step name is set 」がgetステップから見えている(3行目)。うむ

Repository

job_execution
jbatch=# select * from job_execution order by jobexecutionid desc limit 1;
 jobexecutionid | jobinstanceid | version |       createtime        |        starttime        |         endtime         |     lastupdatedtime     | batchstatus | exitstatus | jobparameters | restartposition 
----------------+---------------+---------+-------------------------+-------------------------+-------------------------+-------------------------+-------------+------------+---------------+-----------------
            131 |           126 |         | 2014-02-16 08:52:02.637 | 2014-02-16 08:52:02.637 | 2014-02-16 08:52:02.653 | 2014-02-16 08:52:02.653 | COMPLETED   | COMPLETED  |               | 
(1 row)
step_execution
jbatch=# select * from step_execution where jobexecutionid = 131 order by stepexecutionid;
 stepexecutionid | jobexecutionid | version | stepname |        starttime        |         endtime         | batchstatus | exitstatus | executionexception |                       persistentuserdata                       | readcount | writecount | commitcount | rollbackcount | readskipcount | processskipcount | filtercount | writeskipcount | readercheckpointinfo | writercheckpointinfo 
-----------------+----------------+---------+----------+-------------------------+-------------------------+-------------+------------+--------------------+----------------------------------------------------------------+-----------+------------+-------------+---------------+---------------+------------------+-------------+----------------+----------------------+----------------------
             153 |            131 |         | set      | 2014-02-16 08:52:02.639 | 2014-02-16 08:52:02.642 | COMPLETED   | COMPLETED  |                    | \xaced00057400172a206d792073746570206e616d6520697320736574202a |         0 |          0 |           0 |             0 |             0 |                0 |           0 |              0 |                      | 
             154 |            131 |         | get      | 2014-02-16 08:52:02.645 | 2014-02-16 08:52:02.65  | COMPLETED   | COMPLETED  |                    |                                                                |         0 |          0 |           0 |             0 |             0 |                0 |           0 |              0 |                      | 
(2 rows)

persistentuserdataカラムに何かが入っている。うむ

前回実行時のデータを再実行時に参照してみる

サンプルの仕様

  • Stepは1つだけ
  • 何もpersistentUserDataに入ってなかったら
    1. persistentUserDataにデータを入れる
    2. 例外投げて死ぬ
  • 何かpersistentUserDataに入っていたら
    1. 内容を表示して終了
  • 初回実行はpersistentUserDataにデータ入れてFAILEDになる
  • 再実行時はpersistentUserDataのデータを表示してCOMPLETEDになる

資源

資源はこのへんにまとめて全部ある

動かしてみる

ログ

09:15:07,338 FINE  [org.nailedtothex.jbatch.example.persistentuserdata.GetAndSetPersistentUserDataBatchlet] (batch-batch - 3) getAndSet: process()
09:15:07,339 WARN  [org.jberet] (batch-batch - 3) JBERET000001: Failed to run batchlet org.jberet.job.model.RefArtifact@7e76d151: java.lang.RuntimeException: to confirm whether the data is visible or not when restart
    at org.nailedtothex.jbatch.example.persistentuserdata.GetAndSetPersistentUserDataBatchlet.process(GetAndSetPersistentUserDataBatchlet.java:31) [classes:]
    at org.jberet.runtime.runner.BatchletRunner.run(BatchletRunner.java:61) [jberet-core-1.0.1.Beta-SNAPSHOT.jar:1.0.1.Beta-SNAPSHOT]
    at org.jberet.runtime.runner.StepExecutionRunner.runBatchletOrChunk(StepExecutionRunner.java:207) [jberet-core-1.0.1.Beta-SNAPSHOT.jar:1.0.1.Beta-SNAPSHOT]
    at org.jberet.runtime.runner.StepExecutionRunner.run(StepExecutionRunner.java:131) [jberet-core-1.0.1.Beta-SNAPSHOT.jar:1.0.1.Beta-SNAPSHOT]
    at org.jberet.runtime.runner.CompositeExecutionRunner.runStep(CompositeExecutionRunner.java:162) [jberet-core-1.0.1.Beta-SNAPSHOT.jar:1.0.1.Beta-SNAPSHOT]
    at org.jberet.runtime.runner.CompositeExecutionRunner.runFromHeadOrRestartPoint(CompositeExecutionRunner.java:88) [jberet-core-1.0.1.Beta-SNAPSHOT.jar:1.0.1.Beta-SNAPSHOT]
    at org.jberet.runtime.runner.JobExecutionRunner.run(JobExecutionRunner.java:58) [jberet-core-1.0.1.Beta-SNAPSHOT.jar:1.0.1.Beta-SNAPSHOT]
    at org.wildfly.jberet.services.BatchEnvironmentService$WildFlyBatchEnvironment$1.run(BatchEnvironmentService.java:149) [wildfly-jberet-8.0.0.Final.jar:8.0.0.Final]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [rt.jar:1.7.0_51]
    at java.util.concurrent.FutureTask.run(FutureTask.java:262) [rt.jar:1.7.0_51]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_51]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_51]
    at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_51]
    at org.jboss.threads.JBossThread.run(JBossThread.java:122)

09:15:08,351 FINE  [org.nailedtothex.jbatch.example.persistentuserdata.GetAndSetPersistentUserDataBatchlet] (batch-batch - 2) getAndSet: process()
09:15:08,351 FINE  [org.nailedtothex.jbatch.example.persistentuserdata.GetAndSetPersistentUserDataBatchlet] (batch-batch - 2) persistentUserData=* my job execution id is 134 *

初回実行時に入れた「 my job execution id is 134 」が再実行時に見えている。うむ

Repository

job_execution
jbatch=# select * from job_execution where jobexecutionid in (134, 135) order by jobexecutionid;
 jobexecutionid | jobinstanceid | version |       createtime        |        starttime        |         endtime         |     lastupdatedtime     | batchstatus | exitstatus | jobparameters | restartposition 
----------------+---------------+---------+-------------------------+-------------------------+-------------------------+-------------------------+-------------+------------+---------------+-----------------
            134 |           128 |         | 2014-02-16 09:15:07.335 | 2014-02-16 09:15:07.335 | 2014-02-16 09:15:07.343 | 2014-02-16 09:15:07.343 | FAILED      | FAILED     |               | 
            135 |           128 |         | 2014-02-16 09:15:08.347 | 2014-02-16 09:15:08.347 | 2014-02-16 09:15:08.354 | 2014-02-16 09:15:08.354 | COMPLETED   | COMPLETED  |               | 
(2 rows)
step_execution
jbatch=# select * from step_execution where jobexecutionid in (134, 135) order by jobexecutionid, stepexecutionid;
 stepexecutionid | jobexecutionid | version | stepname  |        starttime        |         endtime         | batchstatus | exitstatus |                                                                   executionexception                                                                   |                              persistentuserdata                              | readcount | writecount | commitcount | rollbackcount | readskipcount | processskipcount | filtercount | writeskipcount | readercheckpointinfo | writercheckpointinfo 
-----------------+----------------+---------+-----------+-------------------------+-------------------------+-------------+------------+--------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------+-----------+------------+-------------+---------------+---------------+------------------+-------------+----------------+----------------------+----------------------
             157 |            134 |         | getAndSet | 2014-02-16 09:15:07.336 | 2014-02-16 09:15:07.34  | FAILED      | FAILED     | java.lang.RuntimeException: to confirm whether the data is visible or not when restart                                                                +| \xaced000574001e2a206d79206a6f6220657865637574696f6e20696420697320313334202a |         0 |          0 |           0 |             0 |             0 |                0 |           0 |              0 |                      | 
                 |                |         |           |                         |                         |             |            |         at org.nailedtothex.jbatch.example.persistentuserdata.GetAndSetPersistentUserDataBatchlet.process(GetAndSetPersistentUserDataBatchlet.java:31)+|                                                                              |           |            |             |               |               |                  |             |                |                      | 
                 |                |         |           |                         |                         |             |            |         at org.jberet.runtime.runner.BatchletRunner.run(BatchletRunner.java:61)                                                                       +|                                                                              |           |            |             |               |               |                  |             |                |                      | 
                 |                |         |           |                         |                         |             |            |         at org.jberet.runtime.runner.StepExecutionRunner.runBatchletOrChunk(StepExecutionRunner.java:207)                                             +|                                                                              |           |            |             |               |               |                  |             |                |                      | 
                 |                |         |           |                         |                         |             |            |         at org.jberet.runtime.runner.StepExecutionRunner.run(StepExecutionRunner.java:131)                                                            +|                                                                              |           |            |             |               |               |                  |             |                |                      | 
                 |                |         |           |                         |                         |             |            |         at org.jberet.runtime.runner.CompositeExecutionRunner.runStep(CompositeExecutionRunner.java:162)                                              +|                                                                              |           |            |             |               |               |                  |             |                |                      | 
                 |                |         |           |                         |                         |             |            |         at org.jberet.runtime.runner.CompositeExecutionRunner.runFromHeadOrRestartPoint(CompositeExecutionRunner.java:88)                             +|                                                                              |           |            |             |               |               |                  |             |                |                      | 
                 |                |         |           |                         |                         |             |            |         at org.jberet.runtime.runner.JobExecutionRunner.run(JobExecutionRunner.java:58)                                                               +|                                                                              |           |            |             |               |               |                  |             |                |                      | 
                 |                |         |           |                         |                         |             |            |         at org.wildfly.jberet.services.BatchEnvironmentService$WildFlyBatchEnvironment$1.run(BatchEnvironmentService.java:149)                        +|                                                                              |           |            |             |               |               |                  |             |                |                      | 
                 |                |         |           |                         |                         |             |            |         at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)                                                                    +|                                                                              |           |            |             |               |               |                  |             |                |                      | 
                 |                |         |           |                         |                         |             |            |         at java.util.concurrent.FutureTask.run(FutureTask.java:262)                                                                                   +|                                                                              |           |            |             |               |               |                  |             |                |                      | 
                 |                |         |           |                         |                         |             |            |         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)                                                            +|                                                                              |           |            |             |               |               |                  |             |                |                      | 
                 |                |         |           |                         |                         |             |            |         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)                                                            +|                                                                              |           |            |             |               |               |                  |             |                |                      | 
                 |                |         |           |                         |                         |             |            |         at java.lang.Thread.run(Thread.java:744)                                                                                                      +|                                                                              |           |            |             |               |               |                  |             |                |                      | 
                 |                |         |           |                         |                         |             |            |         at org.jboss.threads.JBossThread.run(JBossThread.java:122)                                                                                    +|                                                                              |           |            |             |               |               |                  |             |                |                      | 
                 |                |         |           |                         |                         |             |            |                                                                                                                                                        |                                                                              |           |            |             |               |               |                  |             |                |                      | 
             158 |            135 |         | getAndSet | 2014-02-16 09:15:08.349 | 2014-02-16 09:15:08.352 | COMPLETED   | COMPLETED  |                                                                                                                                                        | \xaced000574001e2a206d79206a6f6220657865637574696f6e20696420697320313334202a |         0 |          0 |           0 |             0 |             0 |                0 |           0 |              0 |                      | 
(2 rows)

備考

  • 再実行時にはpersistentUserDataがコピーされるようなので、データ量がでかい場合は気をつけた方がいいのかも

参考文献

  1. JSR-000352 Batch Applications for the Java Platform - Final Release


How to define a JavaMail session using CLI


Posted on Sunday Feb 16, 2014 at 07:30AM in Technology


  • Defining a JavaMail session for gmail.

Environment

  • WildFly8.0.0.Final
  • Oracle JDK7u51

Defining with jboss-cli

Define a outbound-socket-binding named “MyMailSMTP”

  • SMTP server hostname
  • SMTP server port
/socket-binding-group=standard-sockets/remote-destination-outbound-socket-binding=MyMailSMTP:add( \
host=smtp.gmail.com, \
port=465)

Define a JavaMail session named “MyMail”

  • JNDI name of JavaMail session
  • Email address of the sender
  • Debug flag
/subsystem=mail/mail-session=MyMail:add(jndi-name="java:/mail/myMail", from="jane.doe@gmail.example.com", debug=true)

Add a reference from “MyMail” to “MyMailSMTP”

  • SMTP server username
  • SMTP server password
  • TLS flag
  • SSL flag
/subsystem=mail/mail-session=MyMail/server=smtp:add( \
outbound-socket-binding-ref=MyMailSMTP, \
ssl=true, \
username=jane.doe@gmail.example.com, \
password=***)

Example Servlet sends a mail

@WebServlet("/")
public class MailServlet extends HttpServlet {
    @Resource(lookup = "java:/mail/myMail")
    Session session;

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        MimeMessage message = new MimeMessage(session);
        try {

            InternetAddress[] address = { new InternetAddress("jane.doe@icloud.example.com") };
            message.setRecipients(Message.RecipientType.TO, address);
            message.setSubject("test");
            message.setSentDate(new Date());
            message.setText("testbody");
            Transport.send(message);
        } catch (MessagingException ex) {
            throw new ServletException(ex);
        }
    }
}

Mail which sent from WildFly

Debug Log

15:37:26,305 INFO  [stdout] (default task-1) DEBUG: JavaMail version 1.5.1
15:37:26,306 INFO  [stdout] (default task-1) DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
15:37:26,307 INFO  [stdout] (default task-1) DEBUG: Tables of loaded providers
15:37:26,307 INFO  [stdout] (default task-1) DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Oracle], com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Oracle], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Oracle], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Oracle], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Oracle]}
15:37:26,307 INFO  [stdout] (default task-1) DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Oracle], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Oracle], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Oracle], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Oracle], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Oracle], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle]}
15:37:26,307 INFO  [stdout] (default task-1) DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
15:37:26,309 INFO  [stdout] (default task-1) DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Oracle]
15:37:26,309 INFO  [stdout] (default task-1) DEBUG SMTP: need username and password for authentication
15:37:26,309 INFO  [stdout] (default task-1) DEBUG SMTP: useEhlo true, useAuth true
15:37:26,309 INFO  [stdout] (default task-1) DEBUG SMTP: trying to connect to host "smtp.gmail.com", port 465, isSSL true
15:37:26,889 INFO  [stdout] (default task-1) 220 mx.google.com ESMTP *** - gsmtp
15:37:26,889 INFO  [stdout] (default task-1) DEBUG SMTP: connected to host "smtp.gmail.com", port: 465
15:37:26,889 INFO  [stdout] (default task-1) 
15:37:26,893 INFO  [stdout] (default task-1) EHLO ***
15:37:27,006 INFO  [stdout] (default task-1) 250-mx.google.com at your service, [27.114.70.39]
15:37:27,006 INFO  [stdout] (default task-1) 250-SIZE 35882577
15:37:27,006 INFO  [stdout] (default task-1) 250-8BITMIME
15:37:27,006 INFO  [stdout] (default task-1) 250-AUTH LOGIN PLAIN XOAUTH XOAUTH2 PLAIN-CLIENTTOKEN
15:37:27,007 INFO  [stdout] (default task-1) 250-ENHANCEDSTATUSCODES
15:37:27,007 INFO  [stdout] (default task-1) 250 CHUNKING
15:37:27,007 INFO  [stdout] (default task-1) DEBUG SMTP: Found extension "SIZE", arg "35882577"
15:37:27,007 INFO  [stdout] (default task-1) DEBUG SMTP: Found extension "8BITMIME", arg ""
15:37:27,007 INFO  [stdout] (default task-1) DEBUG SMTP: Found extension "AUTH", arg "LOGIN PLAIN XOAUTH XOAUTH2 PLAIN-CLIENTTOKEN"
15:37:27,008 INFO  [stdout] (default task-1) DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
15:37:27,008 INFO  [stdout] (default task-1) DEBUG SMTP: Found extension "CHUNKING", arg ""
15:37:27,008 INFO  [stdout] (default task-1) DEBUG SMTP: Attempt to authenticate using mechanisms: LOGIN PLAIN DIGEST-MD5 NTLM 
15:37:27,008 INFO  [stdout] (default task-1) DEBUG SMTP: AUTH LOGIN command trace suppressed
15:37:27,959 INFO  [stdout] (default task-1) DEBUG SMTP: AUTH LOGIN succeeded
15:37:27,960 INFO  [stdout] (default task-1) DEBUG SMTP: use8bit false
15:37:27,960 INFO  [stdout] (default task-1) MAIL FROM:<jane.doe@gmail.example.com>
15:37:28,074 INFO  [stdout] (default task-1) 250 2.1.0 OK *** - gsmtp
15:37:28,074 INFO  [stdout] (default task-1) RCPT TO:<jane.doe@icloud.example.com>
15:37:28,194 INFO  [stdout] (default task-1) 250 2.1.5 OK *** - gsmtp
15:37:28,195 INFO  [stdout] (default task-1) DEBUG SMTP: Verified Addresses
15:37:28,195 INFO  [stdout] (default task-1) DEBUG SMTP:   jane.doe@icloud.example.com
15:37:28,195 INFO  [stdout] (default task-1) DATA
15:37:28,881 INFO  [stdout] (default task-1) 354  Go ahead *** - gsmtp
15:37:28,881 INFO  [stdout] (default task-1) Date: Thu, 6 Mar 2014 15:37:26 +0900 (JST)
15:37:28,881 INFO  [stdout] (default task-1) To: jane.doe@icloud.example.com
15:37:28,881 INFO  [stdout] (default task-1) Message-ID: <56980149.1.1394087846308.JavaMail.jane.doe@gmail.example.com>
15:37:28,882 INFO  [stdout] (default task-1) Subject: test
15:37:28,882 INFO  [stdout] (default task-1) MIME-Version: 1.0
15:37:28,882 INFO  [stdout] (default task-1) Content-Type: text/plain; charset=us-ascii
15:37:28,882 INFO  [stdout] (default task-1) Content-Transfer-Encoding: 7bit
15:37:28,882 INFO  [stdout] (default task-1) 
15:37:28,882 INFO  [stdout] (default task-1) testbody
15:37:28,883 INFO  [stdout] (default task-1) .
15:37:29,802 INFO  [stdout] (default task-1) 250 2.0.0 OK 1394087849 *** - gsmtp
15:37:29,803 INFO  [stdout] (default task-1) QUIT
15:37:29,916 INFO  [stdout] (default task-1) 221 2.0.0 closing connection *** - gsmtp
  • Debug logging can be turned off like this:
/subsystem=mail/mail-session=MyMail:write-attribute(name=debug, value=false)
/:reload

References

  1. How to configure a Mail Session in Wildfly? | Community
  2. JBoss AS 7.2.0 Email Session configurtion - Eng… | Community
  3. jboss7.x - Please help configure JBoss 7 “mail-session” via jboss-cli - Stack Overflow
  4. Configuring and Using mail service in JBoss AS7 « JBoss
  5. JBoss 7 JavaMail | Community


Decisionでフロー制御してみる


Posted on Saturday Feb 15, 2014 at 08:20PM in Technology


フロー制御は、ExitStatusでフロー制御してみるでやったようにBatchletだけでもできるけど、Chunk要素などの後続処理のフロー制御はDecision要素を使うと楽にできそうなので、試してみる

例えば先行のChunk処理でスキップが多すぎる時に、一応ジョブは正常終了しつつも警告メール的なものを送っておくとか、そういうことをやりたい時にはDecisionを使うとよいかもしれない。引数でStepExecution[]が渡ってくるので、先行処理のMetricsを取り出して調べたりすることが楽にできる。

環境・前提条件

仕様を確認する

  • [2]から引いてみる

public interface Decider

A Decider receives control as part of a decision element in a job. It is used to direct execution flow during job processing. It returns an exit status that updates the current job execution's exit status. This exit status value also directs the execution transition based on next, end, stop, fail child elements configured on the same decision element as the decider.

String decide(StepExecution[] executions) throws Exception

The decide method sets a new exit status for a job. It receives an array of StepExecution objects as input. These StepExecution objects represent the execution element that transitions to this decider as follows:

Step

When the transition is from a step, the decide method receives the StepExecution corresponding to the step as input.

Split

When the transition is from a split, the decide method receives a StepExecution from each flow defined to the split as input.

Flow

When the transition is from a flow, the decide method receives a StepExecution corresponding to the last execution element that completed in the flow. This will be a single StepExecution if the last element was a step and multiple StepExecutions if the last element was a split.

Parameters:

executions - specifies the StepExecution(s) of the preceding element.

Returns:

updated job exit status

  • とりあえず上に書かれた3パターンで試してみる

Stepからの遷移の場合

資源はこのへんにまとめて全部ある

資源

仕様

  • 第一レベルの要素は以下
    1. step1 (batchlet step)
    2. step2 (chunk oriented step)
    3. step2decision (decision)
    4. step3_NO_SKIP_FOUND (batchlet step)
    5. step4_SKIP_FOUND (batchlet step)
  • step2でスキップがなかった場合はstep3_NO_SKIP_FOUNDに遷移する
  • step2でスキップがあった場合はstep4_SKIP_FOUNDに遷移する

スキップが無い場合のテストを動かしてみる

ログ

13:53:59,614 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): executions=1
13:53:59,614 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): stepName=step2, stepExecutionId=248
13:53:59,614 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): metric: WRITE_SKIP_COUNT=0
13:53:59,615 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): metric: PROCESS_SKIP_COUNT=0
13:53:59,615 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): metric: WRITE_COUNT=10
13:53:59,615 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): metric: COMMIT_COUNT=4
13:53:59,615 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): metric: READ_SKIP_COUNT=0
13:53:59,615 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): metric: ROLLBACK_COUNT=0
13:53:59,615 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): metric: FILTER_COUNT=0
13:53:59,615 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): metric: READ_COUNT=10
13:53:59,615 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): exitStatus=SKIP_NOT_FOUND
13:53:59,617 FINE  [org.nailedtothex.jbatch.example.decision.NopBatchlet] (batch-batch - 10) step3_NO_SKIP_FOUND

Repository

job_execution
jbatch=# select * from job_execution order by jobexecutionid desc limit 1;
 jobexecutionid | jobinstanceid | version |       createtime       |       starttime        |         endtime         |     lastupdatedtime     | batchstatus |   exitstatus   |     jobparameters     | restartposition 
----------------+---------------+---------+------------------------+------------------------+-------------------------+-------------------------+-------------+----------------+-----------------------+-----------------
            188 |           176 |         | 2014-02-16 13:53:59.41 | 2014-02-16 13:53:59.41 | 2014-02-16 13:53:59.619 | 2014-02-16 13:53:59.619 | COMPLETED   | SKIP_NOT_FOUND | itemReaderFailAt = -1+| 
                |               |         |                        |                        |                         |                         |             |                | divide = 2           +| 
                |               |         |                        |                        |                         |                         |             |                |                       | 
(1 row)
step_execution
jbatch=# select * from step_execution where jobexecutionid in (188) order by jobexecutionid, stepexecutionid;
 stepexecutionid | jobexecutionid | version |      stepname       |        starttime        |         endtime         | batchstatus | exitstatus | executionexception | persistentuserdata | readcount | writecount | commitcount | rollbackcount | readskipcount | processskipcount | filtercount | writeskipcount |                                                                         readercheckpointinfo                                                                         |                                                                         writercheckpointinfo                                                                         
-----------------+----------------+---------+---------------------+-------------------------+-------------------------+-------------+------------+--------------------+--------------------+-----------+------------+-------------+---------------+---------------+------------------+-------------+----------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------
             247 |            188 |         | step1               | 2014-02-16 13:53:59.412 | 2014-02-16 13:53:59.453 | COMPLETED   | COMPLETED  |                    |                    |         0 |          0 |           0 |             0 |             0 |                0 |           0 |              0 |                                                                                                                                                                      | 
             248 |            188 |         | step2               | 2014-02-16 13:53:59.46  | 2014-02-16 13:53:59.61  | COMPLETED   | COMPLETED  |                    |                    |        10 |         10 |           4 |             0 |             0 |                0 |           0 |              0 | \xaced0005737200116a6176612e6c616e672e496e746567657212e2a0a4f781873802000149000576616c7565787200106a6176612e6c616e672e4e756d62657286ac951d0b94e08b02000078700000000a | \xaced0005737200116a6176612e6c616e672e496e746567657212e2a0a4f781873802000149000576616c7565787200106a6176612e6c616e672e4e756d62657286ac951d0b94e08b020000787000000004
             249 |            188 |         | step3_NO_SKIP_FOUND | 2014-02-16 13:53:59.615 | 2014-02-16 13:53:59.617 | COMPLETED   | COMPLETED  |                    |                    |         0 |          0 |           0 |             0 |             0 |                0 |           0 |              0 |                                                                                                                                                                      | 
(3 rows)

jbatch=# 

スキップが有る場合のテストを動かしてみる

ログ

13:55:00,761 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 5) decide(): executions=1
13:55:00,761 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 5) decide(): stepName=step2, stepExecutionId=251
13:55:00,761 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 5) decide(): metric: WRITE_SKIP_COUNT=0
13:55:00,761 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 5) decide(): metric: PROCESS_SKIP_COUNT=0
13:55:00,761 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 5) decide(): metric: WRITE_COUNT=9
13:55:00,761 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 5) decide(): metric: COMMIT_COUNT=4
13:55:00,762 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 5) decide(): metric: READ_SKIP_COUNT=1
13:55:00,762 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 5) decide(): metric: ROLLBACK_COUNT=0
13:55:00,762 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 5) decide(): metric: FILTER_COUNT=0
13:55:00,762 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 5) decide(): metric: READ_COUNT=9
13:55:00,762 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 5) decide(): exitStatus=SKIP_FOUND
13:55:00,763 FINE  [org.nailedtothex.jbatch.example.decision.NopBatchlet] (batch-batch - 5) step4_SKIP_FOUND

Repository

job_execution
jbatch=# select * from job_execution order by jobexecutionid desc limit 1;
 jobexecutionid | jobinstanceid | version |       createtime        |        starttime        |         endtime         |     lastupdatedtime     | batchstatus | exitstatus |    jobparameters     | restartposition 
----------------+---------------+---------+-------------------------+-------------------------+-------------------------+-------------------------+-------------+------------+----------------------+-----------------
            189 |           177 |         | 2014-02-16 13:55:00.639 | 2014-02-16 13:55:00.639 | 2014-02-16 13:55:00.765 | 2014-02-16 13:55:00.765 | COMPLETED   | SKIP_FOUND | itemReaderFailAt = 5+| 
                |               |         |                         |                         |                         |                         |             |            | divide = 2          +| 
                |               |         |                         |                         |                         |                         |             |            |                      | 
(1 row)
step_execution
jbatch=# select * from step_execution where jobexecutionid in (189) order by jobexecutionid, stepexecutionid;
 stepexecutionid | jobexecutionid | version |     stepname     |        starttime        |         endtime         | batchstatus | exitstatus | executionexception | persistentuserdata | readcount | writecount | commitcount | rollbackcount | readskipcount | processskipcount | filtercount | writeskipcount |                                                                         readercheckpointinfo                                                                         |                                                                         writercheckpointinfo                                                                         
-----------------+----------------+---------+------------------+-------------------------+-------------------------+-------------+------------+--------------------+--------------------+-----------+------------+-------------+---------------+---------------+------------------+-------------+----------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------
             250 |            189 |         | step1            | 2014-02-16 13:55:00.641 | 2014-02-16 13:55:00.642 | COMPLETED   | COMPLETED  |                    |                    |         0 |          0 |           0 |             0 |             0 |                0 |           0 |              0 |                                                                                                                                                                      | 
             251 |            189 |         | step2            | 2014-02-16 13:55:00.644 | 2014-02-16 13:55:00.758 | COMPLETED   | COMPLETED  |                    |                    |         9 |          9 |           4 |             0 |             1 |                0 |           0 |              0 | \xaced0005737200116a6176612e6c616e672e496e746567657212e2a0a4f781873802000149000576616c7565787200106a6176612e6c616e672e4e756d62657286ac951d0b94e08b02000078700000000a | \xaced0005737200116a6176612e6c616e672e496e746567657212e2a0a4f781873802000149000576616c7565787200106a6176612e6c616e672e4e756d62657286ac951d0b94e08b020000787000000003
             252 |            189 |         | step4_SKIP_FOUND | 2014-02-16 13:55:00.762 | 2014-02-16 13:55:00.763 | COMPLETED   | COMPLETED  |                    |                    |         0 |          0 |           0 |             0 |             0 |                0 |           0 |              0 |                                                                                                                                                                      | 
(3 rows)

jbatch=# 
  • Decider#decide()に渡されるStepExecutionは、基本的に遷移元Stepのものだけのようだ

Splitからの遷移の場合

資源

仕様

  • 第一レベルの要素は以下
    1. split1 (split)
    2. split1decision (decision)
  • split1の下には同じようなflowが3つある
    • flowの下にはstep (batchlet) が2つ
  • decisionの後の分岐とスキップはもう試したので省略

テストを動かしてみる

ログ

13:42:04,217 FINE  [org.nailedtothex.jbatch.example.decision.NopBatchlet] (batch-batch - 3) flow3-step1
13:42:04,217 FINE  [org.nailedtothex.jbatch.example.decision.NopBatchlet] (batch-batch - 6) flow1-step1
13:42:04,217 FINE  [org.nailedtothex.jbatch.example.decision.NopBatchlet] (batch-batch - 2) flow2-step1
13:42:04,221 FINE  [org.nailedtothex.jbatch.example.split.SleepBatchlet] (batch-batch - 2) entering process(): stepName=flow2-step2, sleepInMills=2,000
13:42:04,221 FINE  [org.nailedtothex.jbatch.example.split.SleepBatchlet] (batch-batch - 3) entering process(): stepName=flow3-step2, sleepInMills=3,000
13:42:04,221 FINE  [org.nailedtothex.jbatch.example.split.SleepBatchlet] (batch-batch - 6) entering process(): stepName=flow1-step2, sleepInMills=1,000
13:42:05,222 FINE  [org.nailedtothex.jbatch.example.split.SleepBatchlet] (batch-batch - 6)  exiting process(): stepName=flow1-step2, sleepInMills=1,000
13:42:06,222 FINE  [org.nailedtothex.jbatch.example.split.SleepBatchlet] (batch-batch - 2)  exiting process(): stepName=flow2-step2, sleepInMills=2,000
13:42:07,222 FINE  [org.nailedtothex.jbatch.example.split.SleepBatchlet] (batch-batch - 3)  exiting process(): stepName=flow3-step2, sleepInMills=3,000
13:42:07,225 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): executions=3
13:42:07,226 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): stepName=flow1-step2, stepExecutionId=243
13:42:07,226 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): metric: WRITE_SKIP_COUNT=0
13:42:07,226 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): metric: PROCESS_SKIP_COUNT=0
13:42:07,226 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): metric: WRITE_COUNT=0
13:42:07,226 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): metric: COMMIT_COUNT=0
13:42:07,226 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): metric: READ_SKIP_COUNT=0
13:42:07,226 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): metric: ROLLBACK_COUNT=0
13:42:07,226 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): metric: FILTER_COUNT=0
13:42:07,227 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): metric: READ_COUNT=0
13:42:07,227 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): stepName=flow2-step2, stepExecutionId=242
13:42:07,227 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): metric: WRITE_SKIP_COUNT=0
13:42:07,227 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): metric: PROCESS_SKIP_COUNT=0
13:42:07,227 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): metric: WRITE_COUNT=0
13:42:07,227 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): metric: COMMIT_COUNT=0
13:42:07,227 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): metric: READ_SKIP_COUNT=0
13:42:07,227 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): metric: ROLLBACK_COUNT=0
13:42:07,227 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): metric: FILTER_COUNT=0
13:42:07,227 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): metric: READ_COUNT=0
13:42:07,227 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): stepName=flow3-step2, stepExecutionId=244
13:42:07,228 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): metric: WRITE_SKIP_COUNT=0
13:42:07,228 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): metric: PROCESS_SKIP_COUNT=0
13:42:07,228 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): metric: WRITE_COUNT=0
13:42:07,228 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): metric: COMMIT_COUNT=0
13:42:07,228 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): metric: READ_SKIP_COUNT=0
13:42:07,228 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): metric: ROLLBACK_COUNT=0
13:42:07,228 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): metric: FILTER_COUNT=0
13:42:07,228 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): metric: READ_COUNT=0
13:42:07,228 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 10) decide(): exitStatus=SKIP_NOT_FOUND
  • 遷移元がSplitの場合、Splitの子Flowの数だけStepExecutionが渡される(Flowの最後の要素のStepExecution)。だから配列なのか。なるほどね

Repository

job_execution
jbatch=# select * from job_execution order by jobexecutionid desc limit 1;
 jobexecutionid | jobinstanceid | version |       createtime        |        starttime        |         endtime         |     lastupdatedtime     | batchstatus |   exitstatus   | jobparameters | restartposition 
----------------+---------------+---------+-------------------------+-------------------------+-------------------------+-------------------------+-------------+----------------+---------------+-----------------
            186 |           174 |         | 2014-02-16 13:42:04.198 | 2014-02-16 13:42:04.198 | 2014-02-16 13:42:07.229 | 2014-02-16 13:42:07.229 | COMPLETED   | SKIP_NOT_FOUND |               | 
(1 row)

jbatch=# 
step_execution
jbatch=# select * from step_execution where jobexecutionid in (186) order by jobexecutionid, stepexecutionid;
 stepexecutionid | jobexecutionid | version |  stepname   |        starttime        |         endtime         | batchstatus | exitstatus | executionexception | persistentuserdata | readcount | writecount | commitcount | rollbackcount | readskipcount | processskipcount | filtercount | writeskipcount | readercheckpointinfo | writercheckpointinfo 
-----------------+----------------+---------+-------------+-------------------------+-------------------------+-------------+------------+--------------------+--------------------+-----------+------------+-------------+---------------+---------------+------------------+-------------+----------------+----------------------+----------------------
             239 |            186 |         | flow1-step1 | 2014-02-16 13:42:04.211 | 2014-02-16 13:42:04.217 | COMPLETED   | COMPLETED  |                    |                    |         0 |          0 |           0 |             0 |             0 |                0 |           0 |              0 |                      | 
             240 |            186 |         | flow3-step1 | 2014-02-16 13:42:04.211 | 2014-02-16 13:42:04.217 | COMPLETED   | COMPLETED  |                    |                    |         0 |          0 |           0 |             0 |             0 |                0 |           0 |              0 |                      | 
             241 |            186 |         | flow2-step1 | 2014-02-16 13:42:04.211 | 2014-02-16 13:42:04.217 | COMPLETED   | COMPLETED  |                    |                    |         0 |          0 |           0 |             0 |             0 |                0 |           0 |              0 |                      | 
             242 |            186 |         | flow2-step2 | 2014-02-16 13:42:04.22  | 2014-02-16 13:42:06.223 | COMPLETED   | SUCCESS    |                    |                    |         0 |          0 |           0 |             0 |             0 |                0 |           0 |              0 |                      | 
             243 |            186 |         | flow1-step2 | 2014-02-16 13:42:04.22  | 2014-02-16 13:42:05.223 | COMPLETED   | SUCCESS    |                    |                    |         0 |          0 |           0 |             0 |             0 |                0 |           0 |              0 |                      | 
             244 |            186 |         | flow3-step2 | 2014-02-16 13:42:04.22  | 2014-02-16 13:42:07.222 | COMPLETED   | SUCCESS    |                    |                    |         0 |          0 |           0 |             0 |             0 |                0 |           0 |              0 |                      | 
(6 rows)

Flowからの遷移の場合

資源

仕様

  • 第一レベルの要素は以下
    1. flow1 (flow)
    2. flowdecision (decision)
  • flow1の下にはstep (batchlet) が2つ

テストを動かしてみる

ログ

13:47:01,234 FINE  [org.nailedtothex.jbatch.example.decision.NopBatchlet] (batch-batch - 6) flow1-step1
13:47:01,237 FINE  [org.nailedtothex.jbatch.example.decision.NopBatchlet] (batch-batch - 6) flow1-step2
13:47:01,239 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 6) decide(): executions=1
13:47:01,239 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 6) decide(): stepName=flow1-step2, stepExecutionId=246
13:47:01,239 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 6) decide(): metric: WRITE_SKIP_COUNT=0
13:47:01,239 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 6) decide(): metric: PROCESS_SKIP_COUNT=0
13:47:01,239 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 6) decide(): metric: WRITE_COUNT=0
13:47:01,240 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 6) decide(): metric: COMMIT_COUNT=0
13:47:01,240 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 6) decide(): metric: READ_SKIP_COUNT=0
13:47:01,240 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 6) decide(): metric: ROLLBACK_COUNT=0
13:47:01,240 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 6) decide(): metric: FILTER_COUNT=0
13:47:01,240 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 6) decide(): metric: READ_COUNT=0
13:47:01,240 FINE  [org.nailedtothex.jbatch.example.decision.MyDecider] (batch-batch - 6) decide(): exitStatus=SKIP_NOT_FOUND

Repository

job_execution
jbatch=# select * from job_execution order by jobexecutionid desc limit 1;
 jobexecutionid | jobinstanceid | version |       createtime        |        starttime        |        endtime         |    lastupdatedtime     | batchstatus |   exitstatus   | jobparameters | restartposition 
----------------+---------------+---------+-------------------------+-------------------------+------------------------+------------------------+-------------+----------------+---------------+-----------------
            187 |           175 |         | 2014-02-16 13:47:01.231 | 2014-02-16 13:47:01.231 | 2014-02-16 13:47:01.24 | 2014-02-16 13:47:01.24 | COMPLETED   | SKIP_NOT_FOUND |               | 
(1 row)
step_execution
jbatch=# select * from step_execution where jobexecutionid in (187) order by jobexecutionid, stepexecutionid;
 stepexecutionid | jobexecutionid | version |  stepname   |        starttime        |         endtime         | batchstatus | exitstatus | executionexception | persistentuserdata | readcount | writecount | commitcount | rollbackcount | readskipcount | processskipcount | filtercount | writeskipcount | readercheckpointinfo | writercheckpointinfo 
-----------------+----------------+---------+-------------+-------------------------+-------------------------+-------------+------------+--------------------+--------------------+-----------+------------+-------------+---------------+---------------+------------------+-------------+----------------+----------------------+----------------------
             245 |            187 |         | flow1-step1 | 2014-02-16 13:47:01.232 | 2014-02-16 13:47:01.234 | COMPLETED   | COMPLETED  |                    |                    |         0 |          0 |           0 |             0 |             0 |                0 |           0 |              0 |                      | 
             246 |            187 |         | flow1-step2 | 2014-02-16 13:47:01.236 | 2014-02-16 13:47:01.237 | COMPLETED   | COMPLETED  |                    |                    |         0 |          0 |           0 |             0 |             0 |                0 |           0 |              0 |                      | 
(2 rows)

jbatch=# 
  • 遷移元がFlowの場合はFlowの一番最後のStepのStepExecutionだけが渡される

備考

  • Decider#decide()に渡されるStepExecutionは以下のようになる
    • 遷移元がStepの場合: 遷移元StepのStepExecution (配列の要素数は1個)
    • 遷移元がSplitの場合: 遷移元Splitの各子Flowの最後のStepのStepExecution (配列の要素数は複数個)
    • 遷移元がFlowの場合: 遷移元Flowの最後のStepのStepExecution (配列の要素数は1個)

参考文献

  1. JSR-000352 Batch Applications for the Java Platform - Final Release
  2. Decider (Java™ EE 7 Specification APIs)


Splitで並列処理してみる


Posted on Saturday Feb 15, 2014 at 08:19PM in Technology


「Partitioned Chunk Processingで遊ぶ」で使ったPartitionは一つの処理を手分けしてやる仕組みだが、splitは異なる処理を並列で行う仕組み。簡単なバッチを作って遊んでみる。

環境・前提条件

バッチを作ってみる

仕様

  • 一番高レベルの要素は2つ。順番に動く
    1. split0 (Split)
    2. nextOfSplit (Step)
  • split0にはflowが3つある
    • 全てのflowは1つのstepを持つ
    • 使っているartifactは全て同じ。単純なBatchletで、パラメータで与えられたミリ秒数だけThread.sleep()する
    • それぞれ1, 2, 3秒スリープする
  • nextOfSplitは特に何もしない。ちゃんとsplit0内のflowが全部終わってから遷移するか確かめるために置いた

資源

資源はこのへんにまとめて全部ある

動かしてみる

ログ

21:38:24,423 FINE  [org.nailedtothex.jbatch.example.split.SleepBatchlet] (batch-batch - 5) entering process(): stepName=1sec, sleepInMills=1,000
21:38:24,423 FINE  [org.nailedtothex.jbatch.example.split.SleepBatchlet] (batch-batch - 8) entering process(): stepName=3sec, sleepInMills=3,000
21:38:24,422 FINE  [org.nailedtothex.jbatch.example.split.SleepBatchlet] (batch-batch - 7) entering process(): stepName=2sec, sleepInMills=2,000
21:38:25,424 FINE  [org.nailedtothex.jbatch.example.split.SleepBatchlet] (batch-batch - 5)  exiting process(): stepName=1sec, sleepInMills=1,000
21:38:26,423 FINE  [org.nailedtothex.jbatch.example.split.SleepBatchlet] (batch-batch - 7)  exiting process(): stepName=2sec, sleepInMills=2,000
21:38:27,424 FINE  [org.nailedtothex.jbatch.example.split.SleepBatchlet] (batch-batch - 8)  exiting process(): stepName=3sec, sleepInMills=3,000
21:38:27,430 FINE  [org.nailedtothex.jbatch.example.split.SleepBatchlet] (batch-batch - 4) entering process(): stepName=nextOfSplit, sleepInMills=null
21:38:27,430 FINE  [org.nailedtothex.jbatch.example.split.SleepBatchlet] (batch-batch - 4)  exiting process(): stepName=nextOfSplit, sleepInMills=null

Repository

job_execution

jbatch=# select * from job_execution order by jobexecutionid desc limit 1;
 jobexecutionid | jobinstanceid | version |       createtime        |        starttime        |         endtime         |     lastupdatedtime     | batchstatus | exitstatus | jobparameters | restartposition 
----------------+---------------+---------+-------------------------+-------------------------+-------------------------+-------------------------+-------------+------------+---------------+-----------------
            129 |           124 |         | 2014-02-15 21:38:24.415 | 2014-02-15 21:38:24.415 | 2014-02-15 21:38:27.433 | 2014-02-15 21:38:27.433 | COMPLETED   | COMPLETED  |               | 
(1 row)

step_execution

jbatch=# select * from step_execution where jobexecutionid =129 order by stepexecutionid;
 stepexecutionid | jobexecutionid | version |  stepname   |        starttime        |         endtime         | batchstatus | exitstatus | executionexception | persistentuserdata | readcount | writecount | commitcount | rollbackcount | readskipcount | processskipcount | filtercount | writeskipcount | readercheckpointinfo | writercheckpointinfo 
-----------------+----------------+---------+-------------+-------------------------+-------------------------+-------------+------------+--------------------+--------------------+-----------+------------+-------------+---------------+---------------+------------------+-------------+----------------+----------------------+----------------------
             147 |            129 |         | 1sec        | 2014-02-15 21:38:24.42  | 2014-02-15 21:38:25.424 | COMPLETED   | SUCCESS    |                    |                    |         0 |          0 |           0 |             0 |             0 |                0 |           0 |              0 |                      | 
             148 |            129 |         | 2sec        | 2014-02-15 21:38:24.42  | 2014-02-15 21:38:26.424 | COMPLETED   | SUCCESS    |                    |                    |         0 |          0 |           0 |             0 |             0 |                0 |           0 |              0 |                      | 
             149 |            129 |         | 3sec        | 2014-02-15 21:38:24.42  | 2014-02-15 21:38:27.424 | COMPLETED   | SUCCESS    |                    |                    |         0 |          0 |           0 |             0 |             0 |                0 |           0 |              0 |                      | 
             150 |            129 |         | nextOfSplit | 2014-02-15 21:38:27.428 | 2014-02-15 21:38:27.431 | COMPLETED   | SUCCESS    |                    |                    |         0 |          0 |           0 |             0 |             0 |                0 |           0 |              0 |                      | 
(4 rows)

備考

  • ちゃんとパラで走っているみたい
  • [1]によると、いずれかのFlowが死ぬと、親のSplitも死ぬ
  • Flowは複数のStepを1つにまとめる場合に使う。うまく使うとStep間の遷移をすっきり表現できる気がする。Splitの子要素として以外でも使えるようだ

参考文献

  1. JSR-000352 Batch Applications for the Java Platform - Final Release


GitHubから取ってきたJavaの資源をビルドしてみる


Posted on Saturday Feb 15, 2014 at 01:22PM in Technology


jBeret (JSR352の実装) をGitHubから取ってきてjarファイルを作り、WildFlyに配置する手順のメモ

環境

  • Maven 3.1.1
  • Oracle JDK7u51
  • OS X 10.9.1

GitHubから取ってくる

kyle-no-MacBook:src kyle$ git clone git@github.com:jberet/jsr352.git
Cloning into 'jsr352'...
remote: Reusing existing pack: 7898, done.
remote: Counting objects: 179, done.
remote: Compressing objects: 100% (122/122), done.
remote: Total 8077 (delta 47), reused 0 (delta 0)
Receiving objects: 100% (8077/8077), 1.80 MiB | 118.00 KiB/s, done.
Resolving deltas: 100% (2712/2712), done.
Checking connectivity... done
kyle-no-MacBook:src kyle$ ls -ld jsr352
drwxr-xr-x+ 13 kyle  staff  442  2 15 08:58 jsr352
kyle-no-MacBook:src kyle$ ls -l jsr352
total 40
-rw-r--r--+  1 kyle  staff     83  2 15 08:58 README.md
drwxr-xr-x+  5 kyle  staff    170  2 15 09:03 jberet-core
drwxr-xr-x+  4 kyle  staff    136  2 15 08:58 jberet-distribution
drwxr-xr-x+  4 kyle  staff    136  2 15 08:58 jberet-jpa-repository
drwxr-xr-x+  4 kyle  staff    136  2 15 08:58 jberet-se
drwxr-xr-x+  4 kyle  staff    136  2 15 08:58 jberet-support
-rw-r--r--+  1 kyle  staff  12560  2 15 08:58 pom.xml
drwxr-xr-x+  5 kyle  staff    170  2 15 08:58 tck-porting-impl
drwxr-xr-x+ 13 kyle  staff    442  2 15 08:58 test-apps
kyle-no-MacBook:src kyle$ 

ビルド

kyle-no-MacBook:jberet-core kyle$ mvn clean compile jar:jar
Picked up _JAVA_OPTIONS: -Dfile.encoding=UTF-8
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building jberet-core 1.0.1.Beta-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ jberet-core ---
[INFO] 
[INFO] --- maven-enforcer-plugin:1.2:enforce (enforce-java-version) @ jberet-core ---
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/doxia/doxia-sink-api/1.0-alpha-10/doxia-sink-api-1.0-alpha-10.jar
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/reporting/maven-reporting-api/2.0.9/maven-reporting-api-2.0.9.jar
[WARNING] Checksum validation failed, no checksums available from the repository for http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/reporting/maven-reporting-api/2.0.9/maven-reporting-api-2.0.9.jar
Downloaded: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/reporting/maven-reporting-api/2.0.9/maven-reporting-api-2.0.9.jar (10 KB at 5.1 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/doxia/doxia-sink-api/1.0-alpha-10/doxia-sink-api-1.0-alpha-10.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/doxia/doxia-sink-api/1.0-alpha-10/doxia-sink-api-1.0-alpha-10.jar (10 KB at 11.7 KB/sec)
[INFO] 
[INFO] --- maven-enforcer-plugin:1.2:enforce (enforce-maven-version) @ jberet-core ---
[INFO] 
[INFO] --- buildnumber-maven-plugin:1.2:create-timestamp (get-build-timestamp) @ jberet-core ---
Downloading: http://repository.jboss.org/nexus/content/groups/public/junit/junit/4.10/junit-4.10.pom
[WARNING] Checksum validation failed, no checksums available from the repository for http://repository.jboss.org/nexus/content/groups/public/junit/junit/4.10/junit-4.10.pom
Downloaded: http://repository.jboss.org/nexus/content/groups/public/junit/junit/4.10/junit-4.10.pom (3 KB at 2.1 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.pom
[WARNING] Checksum validation failed, no checksums available from the repository for http://repository.jboss.org/nexus/content/groups/public/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.pom
Downloaded: http://repository.jboss.org/nexus/content/groups/public/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.pom (481 B at 0.4 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/maven-plugin-api/2.0.1/maven-plugin-api-2.0.1.pom
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-api/2.0.1/maven-plugin-api-2.0.1.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-api/2.0.1/maven-plugin-api-2.0.1.pom (643 B at 2.3 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/maven/2.0.1/maven-2.0.1.pom
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/maven/2.0.1/maven-2.0.1.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/maven/2.0.1/maven-2.0.1.pom (12 KB at 38.9 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm-api/1.8/maven-scm-api-1.8.pom
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-api/1.8/maven-scm-api-1.8.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-api/1.8/maven-scm-api-1.8.pom (2 KB at 5.5 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm/1.8/maven-scm-1.8.pom
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm/1.8/maven-scm-1.8.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm/1.8/maven-scm-1.8.pom (21 KB at 54.2 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/codehaus/plexus/plexus-utils/3.0.3/plexus-utils-3.0.3.pom
Downloaded: http://repository.jboss.org/nexus/content/groups/public/org/codehaus/plexus/plexus-utils/3.0.3/plexus-utils-3.0.3.pom (3 KB at 3.6 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm-manager-plexus/1.8/maven-scm-manager-plexus-1.8.pom
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-manager-plexus/1.8/maven-scm-manager-plexus-1.8.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-manager-plexus/1.8/maven-scm-manager-plexus-1.8.pom (3 KB at 8.3 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm-managers/1.8/maven-scm-managers-1.8.pom
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-managers/1.8/maven-scm-managers-1.8.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-managers/1.8/maven-scm-managers-1.8.pom (2 KB at 5.8 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm-provider-bazaar/1.8/maven-scm-provider-bazaar-1.8.pom
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-bazaar/1.8/maven-scm-provider-bazaar-1.8.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-bazaar/1.8/maven-scm-provider-bazaar-1.8.pom (3 KB at 8.0 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm-providers/1.8/maven-scm-providers-1.8.pom
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-providers/1.8/maven-scm-providers-1.8.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-providers/1.8/maven-scm-providers-1.8.pom (4 KB at 14.4 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/regexp/regexp/1.3/regexp-1.3.pom
[WARNING] Checksum validation failed, no checksums available from the repository for http://repository.jboss.org/nexus/content/groups/public/regexp/regexp/1.3/regexp-1.3.pom
Downloaded: http://repository.jboss.org/nexus/content/groups/public/regexp/regexp/1.3/regexp-1.3.pom (145 B at 0.1 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm-provider-svnexe/1.8/maven-scm-provider-svnexe-1.8.pom
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-svnexe/1.8/maven-scm-provider-svnexe-1.8.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-svnexe/1.8/maven-scm-provider-svnexe-1.8.pom (3 KB at 9.4 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm-providers-svn/1.8/maven-scm-providers-svn-1.8.pom
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-providers-svn/1.8/maven-scm-providers-svn-1.8.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-providers-svn/1.8/maven-scm-providers-svn-1.8.pom (3 KB at 6.9 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm-provider-svn-commons/1.8/maven-scm-provider-svn-commons-1.8.pom
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-svn-commons/1.8/maven-scm-provider-svn-commons-1.8.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-svn-commons/1.8/maven-scm-provider-svn-commons-1.8.pom (3 KB at 10.3 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm-provider-gitexe/1.8/maven-scm-provider-gitexe-1.8.pom
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-gitexe/1.8/maven-scm-provider-gitexe-1.8.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-gitexe/1.8/maven-scm-provider-gitexe-1.8.pom (3 KB at 8.7 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm-providers-git/1.8/maven-scm-providers-git-1.8.pom
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-providers-git/1.8/maven-scm-providers-git-1.8.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-providers-git/1.8/maven-scm-providers-git-1.8.pom (3 KB at 8.5 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm-provider-git-commons/1.8/maven-scm-provider-git-commons-1.8.pom
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-git-commons/1.8/maven-scm-provider-git-commons-1.8.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-git-commons/1.8/maven-scm-provider-git-commons-1.8.pom (3 KB at 7.3 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm-provider-cvsexe/1.8/maven-scm-provider-cvsexe-1.8.pom
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-cvsexe/1.8/maven-scm-provider-cvsexe-1.8.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-cvsexe/1.8/maven-scm-provider-cvsexe-1.8.pom (3 KB at 8.3 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm-providers-cvs/1.8/maven-scm-providers-cvs-1.8.pom
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-providers-cvs/1.8/maven-scm-providers-cvs-1.8.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-providers-cvs/1.8/maven-scm-providers-cvs-1.8.pom (2 KB at 6.6 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm-provider-cvs-commons/1.8/maven-scm-provider-cvs-commons-1.8.pom
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-cvs-commons/1.8/maven-scm-provider-cvs-commons-1.8.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-cvs-commons/1.8/maven-scm-provider-cvs-commons-1.8.pom (3 KB at 8.2 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm-provider-starteam/1.8/maven-scm-provider-starteam-1.8.pom
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-starteam/1.8/maven-scm-provider-starteam-1.8.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-starteam/1.8/maven-scm-provider-starteam-1.8.pom (3 KB at 8.5 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm-provider-clearcase/1.8/maven-scm-provider-clearcase-1.8.pom
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-clearcase/1.8/maven-scm-provider-clearcase-1.8.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-clearcase/1.8/maven-scm-provider-clearcase-1.8.pom (3 KB at 9.6 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm-provider-perforce/1.8/maven-scm-provider-perforce-1.8.pom
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-perforce/1.8/maven-scm-provider-perforce-1.8.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-perforce/1.8/maven-scm-provider-perforce-1.8.pom (3 KB at 9.6 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm-provider-hg/1.8/maven-scm-provider-hg-1.8.pom
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-hg/1.8/maven-scm-provider-hg-1.8.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-hg/1.8/maven-scm-provider-hg-1.8.pom (3 KB at 8.6 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/com/google/code/maven-scm-provider-svnjava/maven-scm-provider-svnjava/1.13/maven-scm-provider-svnjava-1.13.pom
Downloading: http://repo.maven.apache.org/maven2/com/google/code/maven-scm-provider-svnjava/maven-scm-provider-svnjava/1.13/maven-scm-provider-svnjava-1.13.pom
Downloaded: http://repo.maven.apache.org/maven2/com/google/code/maven-scm-provider-svnjava/maven-scm-provider-svnjava/1.13/maven-scm-provider-svnjava-1.13.pom (10 KB at 31.4 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/sonatype/oss/oss-parent/5/oss-parent-5.pom
Downloaded: http://repository.jboss.org/nexus/content/groups/public/org/sonatype/oss/oss-parent/5/oss-parent-5.pom (4 KB at 4.6 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm-provider-svn-commons/1.5/maven-scm-provider-svn-commons-1.5.pom
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-svn-commons/1.5/maven-scm-provider-svn-commons-1.5.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-svn-commons/1.5/maven-scm-provider-svn-commons-1.5.pom (3 KB at 7.9 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm-providers-svn/1.5/maven-scm-providers-svn-1.5.pom
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-providers-svn/1.5/maven-scm-providers-svn-1.5.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-providers-svn/1.5/maven-scm-providers-svn-1.5.pom (3 KB at 8.0 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm-providers/1.5/maven-scm-providers-1.5.pom
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-providers/1.5/maven-scm-providers-1.5.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-providers/1.5/maven-scm-providers-1.5.pom (4 KB at 13.9 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm/1.5/maven-scm-1.5.pom
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm/1.5/maven-scm-1.5.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm/1.5/maven-scm-1.5.pom (15 KB at 56.5 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm-api/1.5/maven-scm-api-1.5.pom
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-api/1.5/maven-scm-api-1.5.pom
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-api/1.5/maven-scm-api-1.5.pom (2 KB at 5.4 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/net/java/dev/jna/jna/3.2.2/jna-3.2.2.pom
Downloading: http://repo.maven.apache.org/maven2/net/java/dev/jna/jna/3.2.2/jna-3.2.2.pom
Downloaded: http://repo.maven.apache.org/maven2/net/java/dev/jna/jna/3.2.2/jna-3.2.2.pom (2 KB at 5.7 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/tmatesoft/svnkit/svnkit/1.3.5/svnkit-1.3.5.pom
Downloading: http://repo.maven.apache.org/maven2/org/tmatesoft/svnkit/svnkit/1.3.5/svnkit-1.3.5.pom
Downloaded: http://repo.maven.apache.org/maven2/org/tmatesoft/svnkit/svnkit/1.3.5/svnkit-1.3.5.pom (2 KB at 4.2 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/tmatesoft/svnkit/trilead-ssh2/build213-svnkit-1.3-patch/trilead-ssh2-build213-svnkit-1.3-patch.pom
Downloading: http://repo.maven.apache.org/maven2/org/tmatesoft/svnkit/trilead-ssh2/build213-svnkit-1.3-patch/trilead-ssh2-build213-svnkit-1.3-patch.pom
Downloaded: http://repo.maven.apache.org/maven2/org/tmatesoft/svnkit/trilead-ssh2/build213-svnkit-1.3-patch/trilead-ssh2-build213-svnkit-1.3-patch.pom (725 B at 2.5 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/tmatesoft/sqljet/sqljet/1.0.4/sqljet-1.0.4.pom
Downloading: http://repo.maven.apache.org/maven2/org/tmatesoft/sqljet/sqljet/1.0.4/sqljet-1.0.4.pom
Downloaded: http://repo.maven.apache.org/maven2/org/tmatesoft/sqljet/sqljet/1.0.4/sqljet-1.0.4.pom (771 B at 2.5 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/antlr/antlr-runtime/3.1.3/antlr-runtime-3.1.3.pom
Downloading: http://repo.maven.apache.org/maven2/org/antlr/antlr-runtime/3.1.3/antlr-runtime-3.1.3.pom
Downloaded: http://repo.maven.apache.org/maven2/org/antlr/antlr-runtime/3.1.3/antlr-runtime-3.1.3.pom (4 KB at 13.4 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/antlr/antlr-master/3.1.3/antlr-master-3.1.3.pom
Downloading: http://repo.maven.apache.org/maven2/org/antlr/antlr-master/3.1.3/antlr-master-3.1.3.pom
Downloaded: http://repo.maven.apache.org/maven2/org/antlr/antlr-master/3.1.3/antlr-master-3.1.3.pom (9 KB at 32.4 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/antlr/stringtemplate/3.2/stringtemplate-3.2.pom
Downloading: http://repo.maven.apache.org/maven2/org/antlr/stringtemplate/3.2/stringtemplate-3.2.pom
Downloaded: http://repo.maven.apache.org/maven2/org/antlr/stringtemplate/3.2/stringtemplate-3.2.pom (2 KB at 7.0 KB/sec)
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm-api/1.8/maven-scm-api-1.8.jar
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm-manager-plexus/1.8/maven-scm-manager-plexus-1.8.jar
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm-provider-bazaar/1.8/maven-scm-provider-bazaar-1.8.jar
Downloading: http://repository.jboss.org/nexus/content/groups/public/regexp/regexp/1.3/regexp-1.3.jar
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm-provider-svnexe/1.8/maven-scm-provider-svnexe-1.8.jar
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm-provider-gitexe/1.8/maven-scm-provider-gitexe-1.8.jar
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm-provider-git-commons/1.8/maven-scm-provider-git-commons-1.8.jar
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm-provider-svn-commons/1.8/maven-scm-provider-svn-commons-1.8.jar
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm-provider-cvsexe/1.8/maven-scm-provider-cvsexe-1.8.jar
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm-provider-cvs-commons/1.8/maven-scm-provider-cvs-commons-1.8.jar
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm-provider-starteam/1.8/maven-scm-provider-starteam-1.8.jar
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm-provider-clearcase/1.8/maven-scm-provider-clearcase-1.8.jar
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm-provider-perforce/1.8/maven-scm-provider-perforce-1.8.jar
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/apache/maven/scm/maven-scm-provider-hg/1.8/maven-scm-provider-hg-1.8.jar
Downloading: http://repository.jboss.org/nexus/content/groups/public/com/google/code/maven-scm-provider-svnjava/maven-scm-provider-svnjava/1.13/maven-scm-provider-svnjava-1.13.jar
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/tmatesoft/svnkit/svnkit/1.3.5/svnkit-1.3.5.jar
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/tmatesoft/svnkit/trilead-ssh2/build213-svnkit-1.3-patch/trilead-ssh2-build213-svnkit-1.3-patch.jar
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/tmatesoft/sqljet/sqljet/1.0.4/sqljet-1.0.4.jar
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/antlr/antlr-runtime/3.1.3/antlr-runtime-3.1.3.jar
Downloading: http://repository.jboss.org/nexus/content/groups/public/org/antlr/stringtemplate/3.2/stringtemplate-3.2.jar
Downloading: http://repository.jboss.org/nexus/content/groups/public/net/java/dev/jna/jna/3.2.2/jna-3.2.2.jar
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-api/1.8/maven-scm-api-1.8.jar
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-manager-plexus/1.8/maven-scm-manager-plexus-1.8.jar
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-bazaar/1.8/maven-scm-provider-bazaar-1.8.jar
Downloading: http://repo.maven.apache.org/maven2/regexp/regexp/1.3/regexp-1.3.jar
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-svnexe/1.8/maven-scm-provider-svnexe-1.8.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-api/1.8/maven-scm-api-1.8.jar (103 KB at 151.7 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-gitexe/1.8/maven-scm-provider-gitexe-1.8.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-manager-plexus/1.8/maven-scm-manager-plexus-1.8.jar (11 KB at 12.2 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-git-commons/1.8/maven-scm-provider-git-commons-1.8.jar
Downloaded: http://repo.maven.apache.org/maven2/regexp/regexp/1.3/regexp-1.3.jar (25 KB at 25.1 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-svn-commons/1.8/maven-scm-provider-svn-commons-1.8.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-gitexe/1.8/maven-scm-provider-gitexe-1.8.jar (62 KB at 149.8 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-cvsexe/1.8/maven-scm-provider-cvsexe-1.8.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-svnexe/1.8/maven-scm-provider-svnexe-1.8.jar (75 KB at 61.6 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-cvs-commons/1.8/maven-scm-provider-cvs-commons-1.8.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-bazaar/1.8/maven-scm-provider-bazaar-1.8.jar (54 KB at 42.2 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-starteam/1.8/maven-scm-provider-starteam-1.8.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-cvsexe/1.8/maven-scm-provider-cvsexe-1.8.jar (30 KB at 99.1 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-clearcase/1.8/maven-scm-provider-clearcase-1.8.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-git-commons/1.8/maven-scm-provider-git-commons-1.8.jar (37 KB at 61.4 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-svn-commons/1.8/maven-scm-provider-svn-commons-1.8.jar (40 KB at 86.1 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-perforce/1.8/maven-scm-provider-perforce-1.8.jar
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-hg/1.8/maven-scm-provider-hg-1.8.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-cvs-commons/1.8/maven-scm-provider-cvs-commons-1.8.jar (79 KB at 141.8 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/com/google/code/maven-scm-provider-svnjava/maven-scm-provider-svnjava/1.13/maven-scm-provider-svnjava-1.13.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-clearcase/1.8/maven-scm-provider-clearcase-1.8.jar (70 KB at 163.0 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/tmatesoft/svnkit/svnkit/1.3.5/svnkit-1.3.5.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-starteam/1.8/maven-scm-provider-starteam-1.8.jar (73 KB at 122.2 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/tmatesoft/svnkit/trilead-ssh2/build213-svnkit-1.3-patch/trilead-ssh2-build213-svnkit-1.3-patch.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-perforce/1.8/maven-scm-provider-perforce-1.8.jar (80 KB at 120.8 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/tmatesoft/sqljet/sqljet/1.0.4/sqljet-1.0.4.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/maven/scm/maven-scm-provider-hg/1.8/maven-scm-provider-hg-1.8.jar (65 KB at 97.7 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/antlr/antlr-runtime/3.1.3/antlr-runtime-3.1.3.jar
Downloaded: http://repo.maven.apache.org/maven2/com/google/code/maven-scm-provider-svnjava/maven-scm-provider-svnjava/1.13/maven-scm-provider-svnjava-1.13.jar (51 KB at 114.0 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/org/antlr/stringtemplate/3.2/stringtemplate-3.2.jar
Downloaded: http://repo.maven.apache.org/maven2/org/tmatesoft/svnkit/trilead-ssh2/build213-svnkit-1.3-patch/trilead-ssh2-build213-svnkit-1.3-patch.jar (246 KB at 262.5 KB/sec)
Downloading: http://repo.maven.apache.org/maven2/net/java/dev/jna/jna/3.2.2/jna-3.2.2.jar
Downloaded: http://repo.maven.apache.org/maven2/org/antlr/antlr-runtime/3.1.3/antlr-runtime-3.1.3.jar (148 KB at 191.0 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/org/antlr/stringtemplate/3.2/stringtemplate-3.2.jar (168 KB at 236.3 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/net/java/dev/jna/jna/3.2.2/jna-3.2.2.jar (839 KB at 450.2 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/org/tmatesoft/svnkit/svnkit/1.3.5/svnkit-1.3.5.jar (1845 KB at 414.9 KB/sec)
Downloaded: http://repo.maven.apache.org/maven2/org/tmatesoft/sqljet/sqljet/1.0.4/sqljet-1.0.4.jar (727 KB at 166.2 KB/sec)
[INFO] 
[INFO] --- buildnumber-maven-plugin:1.2:create (get-scm-revision) @ jberet-core ---
[INFO] Checking for local modifications: skipped.
[INFO] Updating project files from SCM: skipped.
[INFO] Executing: /bin/sh -c cd /Users/kyle/src/jsr352/jberet-core && git rev-parse --verify HEAD
[INFO] Working directory: /Users/kyle/src/jsr352/jberet-core
[INFO] Storing buildNumber: 70bfa6de5c01f000de0ca1772f7639f956289c76 at timestamp: 1392422639073
[INFO] Executing: /bin/sh -c cd /Users/kyle/src/jsr352/jberet-core && git rev-parse --verify HEAD
[INFO] Working directory: /Users/kyle/src/jsr352/jberet-core
[INFO] Storing buildScmBranch: UNKNOWN
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ jberet-core ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 14 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.0:compile (default-compile) @ jberet-core ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 61 source files to /Users/kyle/src/jsr352/jberet-core/target/classes
[WARNING] ブートストラップ・クラスパスが-source 1.6と一緒に設定されていません
[WARNING] 次のオプションはどのプロセッサでも認識されませんでした: '[org.jboss.logging.tools.level]'
[WARNING] /Users/kyle/src/jsr352/jberet-core/src/main/java/org/jberet/runtime/runner/JobExecutionRunner.java:[74,38] 最終パラメータの不正確な引数型を持った可変引数メソッドの非可変引数呼出し。
  可変引数呼出しに関してはjava.lang.Objectにキャストします。
  非可変引数呼出しに関してはjava.lang.Object[]にキャストしてこの警告を出さないようにします
[WARNING] /Users/kyle/src/jsr352/jberet-core/src/main/java/org/jberet/runtime/context/JobContextImpl.java: 入力ファイルの操作のうち、未チェックまたは安全ではないものがあります。
[WARNING] /Users/kyle/src/jsr352/jberet-core/src/main/java/org/jberet/runtime/context/JobContextImpl.java: 詳細は、-Xlint:uncheckedオプションを指定して再コンパイルしてください。
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-cli) @ jberet-core ---
[INFO] Building jar: /Users/kyle/src/jsr352/jberet-core/target/jberet-core-1.0.1.Beta-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 54.764s
[INFO] Finished at: Sat Feb 15 09:04:02 JST 2014
[INFO] Final Memory: 19M/310M
[INFO] ------------------------------------------------------------------------
kyle-no-MacBook:main kyle$ ls -l  /Users/kyle/src/jsr352/jberet-core/target/jberet-core-1.0.1.Beta-SNAPSHOT.jar
-rw-r--r--+ 1 kyle  staff  185155  2 15 09:04 /Users/kyle/src/jsr352/jberet-core/target/jberet-core-1.0.1.Beta-SNAPSHOT.jar
kyle-no-MacBook:main kyle$ 

よくわからないけどMavenが自動的に依存関係のあるライブラリを集めてきてくれて、ビルドが走りめでたくjarファイルができました

然るべき場所に配置

  1. $WILDFLY_HOME/modules/system/layers/base/org/jberet/jberet-core/mainにjarファイルを配置
  2. 同じディレクトリにあるmodule.xmlを書き換える。こんな感じ。書き換えたら再起動
<module xmlns="urn:jboss:module:1.1" name="org.jberet.jberet-core">
    <properties>
        <property name="jboss.api" value="private"/>
    </properties>

    <resources>
        <resource-root path="jberet-core-1.0.1.Beta-SNAPSHOT.jar"/>
        <!-- Insert resources here -->
    </resources>

    <dependencies>
        <module name="javax.api"/>
        <module name="javaee.api"/>
        <module name="javax.transaction.api"/>
        <module name="org.jboss.jts"/>
        <module name="org.jboss.marshalling"/>
        <module name="org.jboss.logging"/>
        <module name="com.h2database.h2" optional="true"/>
        <module name="com.google.guava"/>
    </dependencies>
</module>