Skip to content

Commit

Permalink
Added a bunch of javadoc
Browse files Browse the repository at this point in the history
Signed-off-by: coduz <alberto.codutti@eurotech.com>
  • Loading branch information
Coduz committed Mar 21, 2020
1 parent 8bb31e8 commit 5a165de
Show file tree
Hide file tree
Showing 16 changed files with 117 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.ibm.jbatch.container.persistence.CheckpointDataKey;
import com.ibm.jbatch.container.services.IJobExecution;
import com.ibm.jbatch.container.services.IPersistenceManagerService;
import com.ibm.jbatch.container.services.impl.JDBCPersistenceManagerImpl;
import com.ibm.jbatch.container.status.JobStatus;
import com.ibm.jbatch.container.status.StepStatus;
import com.ibm.jbatch.spi.services.IBatchConfig;
Expand Down Expand Up @@ -57,6 +58,27 @@
import java.util.stream.Collectors;

/**
* This is a custom implementation of the {@link IPersistenceManagerService} for jBatch which replace the default {@link JDBCPersistenceManagerImpl}.
* <p>
* This implementation is much more performant for many reasons, starting from using a DB connection pool and query that are precompiled by JPA using the {@link javax.persistence.NamedQueries}.
* Entity have been optimized and code now skips some checks that {@link JDBCPersistenceManagerImpl} performs since those checks are not required by our usage of jBatch.
* This makes this implementation not compatible with the regular behaviour of the {@link JDBCPersistenceManagerImpl} but makes it fit our needing.
* <p>
* As a general overview if the jBatch tables they follow the schema below
*
* <pre>
* JobInstanceData (aka: JobInstace)
* |
* |-- as one --- JobStatus
* |-- as many -- ExecutionInstanceData (aka: JobExecution)
* |
* |-- as many -- StepExecutionInstanceData (aka: JobStepExecution)
* | |
* | |-- as one --- StepStatus
* |
* |-- as many -- CheckpointData
* </pre>
*
* @since 1.2.0
*/
public class JPAPersistenceManagerImpl extends AbstractKapuaService implements IPersistenceManagerService {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 Eurotech and/or its affiliates and others
* Copyright (c) 2020 Eurotech and/or its affiliates and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -19,7 +19,7 @@
import java.util.Map;

/**
* {@link EntityManagerFactory} for the jbatch module.
* {@link EntityManagerFactory} for the jBatch module.
*
* @since 1.2.0
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 Eurotech and/or its affiliates and others
* Copyright (c) 2020 Eurotech and/or its affiliates and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -19,6 +19,14 @@
import java.io.Serializable;

/**
* Base class for JPA counterpart of jBatch entities.
* <p>
* It offers {@link #readObject(byte[])} and {@link #writeObject(Serializable)} as utility method since most of the jBatch entities on the default {@link com.ibm.jbatch.container.services.impl.JDBCPersistenceManagerImpl}
* contains binary objects. This is odd but current deployment have that format and, for backward compatibility we need to keep this format.
* <p>
* Further improvement could be use the Apache Lang 3 {@link org.apache.commons.lang3.SerializationUtils#serialize(Serializable)} and {@link org.apache.commons.lang3.SerializationUtils#deserialize(byte[])},
* but compatibility needs to be checked.
*
* @since 1.2.0
*/
public abstract class AbstractJpaJbatchEntity implements Serializable {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 Eurotech and/or its affiliates and others
* Copyright (c) 2020 Eurotech and/or its affiliates and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -19,6 +19,11 @@
import javax.persistence.Lob;
import javax.persistence.Table;

/**
* JPA counterpart of the {@link CheckpointData} object.
*
* @since 1.2.0
*/
@Entity(name = "CheckpointData")
@Table(name = "jbtc_checkpoint_data")
public class JpaCheckpointData extends AbstractJpaJbatchEntity {
Expand All @@ -35,6 +40,7 @@ public class JpaCheckpointData extends AbstractJpaJbatchEntity {
private byte[] obj;

public JpaCheckpointData() {
// Required by JPA
}

public long getJobInstanceId() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 Eurotech and/or its affiliates and others
* Copyright (c) 2020 Eurotech and/or its affiliates and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -15,6 +15,11 @@
import com.ibm.jbatch.container.persistence.CheckpointDataKey;
import org.eclipse.kapua.commons.jpa.EntityManager;

/**
* Service DAO for {@link JpaCheckpointData}
*
* @since 1.2.0
*/
public class JpaCheckpointDataDAO {

private JpaCheckpointDataDAO() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 Eurotech and/or its affiliates and others
* Copyright (c) 2020 Eurotech and/or its affiliates and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down Expand Up @@ -31,6 +31,11 @@
import java.util.Date;
import java.util.Properties;

/**
* JPA counterpart of the {@link JobOperatorJobExecution} object.
*
* @since 1.2.0
*/
@Entity(name = "ExecutionInstanceData")
@Table(name = "jbtc_execution_instance_data")
@NamedQueries({
Expand Down Expand Up @@ -77,6 +82,7 @@ public class JpaExecutionInstanceData extends AbstractJpaJbatchEntity {
private String exitStatus;

public JpaExecutionInstanceData() {
// Required by JPA
}

public long getId() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 Eurotech and/or its affiliates and others
* Copyright (c) 2020 Eurotech and/or its affiliates and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -22,6 +22,11 @@
import java.util.Properties;
import java.util.Set;

/**
* Service DAO for {@link JpaExecutionInstanceData}.
*
* @since 1.2.0
*/
public class JpaExecutionInstanceDataDAO {

private JpaExecutionInstanceDataDAO() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 Eurotech and/or its affiliates and others
* Copyright (c) 2020 Eurotech and/or its affiliates and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -11,6 +11,11 @@
*******************************************************************************/
package org.eclipse.kapua.job.engine.jbatch.persistence.jpa;

/**
* Enumeration of {@link JpaExecutionInstanceDataFields}.
*
* @since 1.2.0
*/
public enum JpaExecutionInstanceDataFields {
JOB_EXEC_ID,
JOB_INSTANCE_ID,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 Eurotech and/or its affiliates and others
* Copyright (c) 2020 Eurotech and/or its affiliates and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -25,6 +25,11 @@
import javax.persistence.Transient;
import java.io.Serializable;

/**
* JPA counterpart of {@link JobInstance}
*
* @since 1.2.0
*/
@Entity(name = "JobInstanceData")
@Table(name = "jbtc_job_instance_data")
@NamedQueries({
Expand Down Expand Up @@ -58,6 +63,7 @@ public class JpaJobInstanceData implements Serializable {
private String jobXml;

public JpaJobInstanceData() {
// Required by JPA
}

public long getId() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 Eurotech and/or its affiliates and others
* Copyright (c) 2020 Eurotech and/or its affiliates and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -19,6 +19,11 @@
import java.util.Map;
import java.util.stream.Collectors;

/**
* Service DAO for {@link JpaJobInstanceData}.
*
* @since 1.2.0
*/
public class JpaJobInstanceDataDAO {

private JpaJobInstanceDataDAO() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 Eurotech and/or its affiliates and others
* Copyright (c) 2020 Eurotech and/or its affiliates and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -19,6 +19,11 @@
import javax.persistence.Lob;
import javax.persistence.Table;

/**
* JPA counterpart for {@link JobStatus} object.
*
* @sicne 1.2.0
*/
@Entity(name = "JobStatus")
@Table(name = "jbtc_job_status")
public class JpaJobStatus extends AbstractJpaJbatchEntity {
Expand All @@ -32,6 +37,7 @@ public class JpaJobStatus extends AbstractJpaJbatchEntity {
private byte[] obj;

public JpaJobStatus() {
// Required by JPA
}

public long getJobInstanceId() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 Eurotech and/or its affiliates and others
* Copyright (c) 2020 Eurotech and/or its affiliates and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -14,6 +14,11 @@
import com.ibm.jbatch.container.status.JobStatus;
import org.eclipse.kapua.commons.jpa.EntityManager;

/**
* Service DAO for {@link JpaJobStatus}
*
* @since 1.2.0
*/
public class JpaJobStatusDAO {

private JpaJobStatusDAO() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 Eurotech and/or its affiliates and others
* Copyright (c) 2020 Eurotech and/or its affiliates and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand Down Expand Up @@ -33,6 +33,11 @@
import java.sql.Timestamp;
import java.util.Date;

/**
* JPA counterpart of {@link javax.batch.runtime.StepExecution}
*
* @since 1.2.0
*/
@Entity(name = "StepExecutionInstanceData")
@Table(name = "jbtc_step_execution_instance_data")
@NamedQueries({
Expand Down Expand Up @@ -98,6 +103,7 @@ public class JpaStepExecutionInstanceData extends AbstractJpaJbatchEntity {
private byte[] persistentData;

public JpaStepExecutionInstanceData() {
// Required by JPA
}

public long getId() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 Eurotech and/or its affiliates and others
* Copyright (c) 2020 Eurotech and/or its affiliates and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -20,6 +20,11 @@
import java.util.Map;
import java.util.stream.Collectors;

/**
* Service DAO for {@link JpaStepExecutionInstanceData}
*
* @since 1.2.0
*/
public class JpaStepExecutionInstanceDataDAO {

private JpaStepExecutionInstanceDataDAO() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 Eurotech and/or its affiliates and others
* Copyright (c) 2020 Eurotech and/or its affiliates and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -21,6 +21,11 @@
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
* JPA counterpart of {@link StepStatus}.
*
* @since 1.2.0
*/
@Entity(name = "StepStatus")
@Table(name = "jbtc_step_status")
@NamedQueries({
Expand All @@ -46,6 +51,7 @@ public class JpaStepStatus extends AbstractJpaJbatchEntity {
private byte[] obj;

public JpaStepStatus() {
// Required by JPA
}

public long getStepExecutionId() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019 Eurotech and/or its affiliates and others
* Copyright (c) 2020 Eurotech and/or its affiliates and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -17,6 +17,11 @@
import javax.persistence.TypedQuery;
import java.util.List;

/**
* Service DAO for {@link JpaStepStatus}.
*
* @since 1.2.0
*/
public class JpaStepStatusDAO {

private JpaStepStatusDAO() {
Expand Down

0 comments on commit 5a165de

Please sign in to comment.