quick look at batch applications for the java platform · 2 copyright © 2012, oracle and/or its...

16
Quick look at Batch Applications for the Java Platform Anissa Lam (梁鈺儀) Principal Member of Technical Staff

Upload: others

Post on 25-Sep-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Quick look at Batch Applications for the Java Platform · 2 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. The following is intended to outline our general

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 1

Quick look at Batch Applications for the Java Platform Anissa Lam (梁鈺儀) Principal Member of Technical Staff

Page 2: Quick look at Batch Applications for the Java Platform · 2 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. The following is intended to outline our general

Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 2

The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.

Page 3: Quick look at Batch Applications for the Java Platform · 2 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. The following is intended to outline our general

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 3

Batch Applications for the Java Platform

§ New for Java EE 7, can be used in Java SE § Standardizes batch processing for Java

–  Non-interactive, bulk-oriented, long-running –  Data or computationally intensive –  Sequentially or in parallel –  Ad-hoc, scheduled or on-demand execution

§ Led by IBM

Overview

Page 4: Quick look at Batch Applications for the Java Platform · 2 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. The following is intended to outline our general

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 4

Basic Components of Batch Processing

Page 5: Quick look at Batch Applications for the Java Platform · 2 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. The following is intended to outline our general

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 5

Batch Domain Language

Page 6: Quick look at Batch Applications for the Java Platform · 2 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. The following is intended to outline our general

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 6

Batch Domain Language

Page 7: Quick look at Batch Applications for the Java Platform · 2 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. The following is intended to outline our general

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 7

Chunked Processing

Page 8: Quick look at Batch Applications for the Java Platform · 2 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. The following is intended to outline our general

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 8

Job Specification Language (JSL)

§ Specifies the Steps in the order for execution to accomplish the Job. § Powerful

§  Conditional execution of steps §  Each step can have different properties, listeners etc. §  Exception Handling

§  Each application can have more than one JSL (job XMLfile) § Job XML filename must be unique § Placed in META-INF/batch-jobs directory

Page 9: Quick look at Batch Applications for the Java Platform · 2 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. The following is intended to outline our general

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 9

<step id=”process”> <chunk item-count=“2”

<reader ref=”simpleItemReader” /> <processor ref=“simpleItemProcessor”/> <writer ref=”simpleItemWriter” /> <chunk/> </step>

Batch Applications for the Java Platform Step Example using Job Specification Language (JSL)

@Named Public class simpleItemReader extends AbstractItemReader { @Inject private JobContext jobcontext; … }

Page 10: Quick look at Batch Applications for the Java Platform · 2 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. The following is intended to outline our general

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 10

Chunked Processing: Reader, Processor, Writer public interface ItemReader<T> { public void open(Externalizable checkpoint); public T readItem(); public Externalizable checkpointInfo(); public void close(); } public interface ItemProcessor<T, R> { public R processItem(T item); } public interface ItemWriter<T> { public void open(Externalizable checkpoint); public void writeItems(List<T> items); public Externalizable checkpointInfo(); public void close(); }

Page 11: Quick look at Batch Applications for the Java Platform · 2 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. The following is intended to outline our general

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 11

Checkpointing § For data intensive tasks, long periods of time

–  Checkpoint/restart is a common design requirement § Basically saves Reader, Writer positions

–  Naturally fits into Chunk oriented steps –  reader.checkpointInfo() and writer.checkpointInfo() are

called –  The resulting Externalizable data is persisted –  When the Chunk restarts, the reader and writer are initialized with the

respective Externalizable data

Page 12: Quick look at Batch Applications for the Java Platform · 2 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. The following is intended to outline our general

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 12

Chunked Processing: Checkpoint public interface ItemReader<T> { public void open(Externalizable checkpoint); public T readItem(); public Externalizable checkpointInfo(); public void close(); } public interface ItemProcessor<T, R> { public R processItem(T item); } public interface ItemWriter<T> { public void open(Externalizable checkpoint); public void writeItems(List<T> items); public Externalizable checkpointInfo(); public void close(); }

Page 13: Quick look at Batch Applications for the Java Platform · 2 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. The following is intended to outline our general

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 13

Handling Exceptions <job id=...> ... <chunk skip-limit=”5” retry-limit=”5”> <skippable-exception-classes> <include class="java.lang.Exception"/> <exclude class="java.io.FileNotFoundException"/> </skippable-exception-classes> <retryable-exception-classes> ... </retryable-exception-classes> <no-rollback-exception-classes> ... </no-rollback-exception-classes> </chunk> ... </job>

Page 14: Quick look at Batch Applications for the Java Platform · 2 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. The following is intended to outline our general

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 14

Advanced Topics § Partitioned Steps § Advanced Partitioning Scenarios

§  Partition Mapper, Reducer, Collector, Analyzer § Flow & Split § Batchlet § Batch Runtime Specification

Page 15: Quick look at Batch Applications for the Java Platform · 2 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. The following is intended to outline our general

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 15

Example: Simple Payroll Processing Application

§ Simple payroll processing application. § Demonstrates some of the key features of JSR 352 § SimplePayrollJob

§  Reading input data for payroll processing from CVS file §  Each line contains employee ID and base salary §  Calculates tax, bonus, and net salary §  Finally write out the processed records into Database.

Page 16: Quick look at Batch Applications for the Java Platform · 2 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. The following is intended to outline our general

Copyright © 2013, Oracle and/or its affiliates. All rights reserved. 16

Resources

§ Final Specification at : http://java.net/projects/jbatch/ § Questions and comments : [email protected]