You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@batchee.apache.org by rm...@apache.org on 2013/11/05 08:39:28 UTC
[51/62] importing batchee from github - a fork from the IBm RI
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/JSR352.Runtime/src/com/ibm/jbatch/container/jobinstance/JobExecutionHelper.java
----------------------------------------------------------------------
diff --git a/JSR352.Runtime/src/com/ibm/jbatch/container/jobinstance/JobExecutionHelper.java b/JSR352.Runtime/src/com/ibm/jbatch/container/jobinstance/JobExecutionHelper.java
deleted file mode 100755
index 8a66c70..0000000
--- a/JSR352.Runtime/src/com/ibm/jbatch/container/jobinstance/JobExecutionHelper.java
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * Copyright 2012 International Business Machines Corp.
- *
- * See the NOTICE file distributed with this work for additional information
- * regarding copyright ownership. Licensed under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.ibm.jbatch.container.jobinstance;
-
-import java.util.Properties;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.batch.operations.JobExecutionAlreadyCompleteException;
-import javax.batch.operations.JobExecutionNotMostRecentException;
-import javax.batch.operations.JobRestartException;
-import javax.batch.operations.JobStartException;
-import javax.batch.operations.NoSuchJobExecutionException;
-import javax.batch.runtime.BatchStatus;
-import javax.batch.runtime.JobInstance;
-
-import com.ibm.jbatch.container.context.impl.JobContextImpl;
-import com.ibm.jbatch.container.jsl.ModelResolverFactory;
-import com.ibm.jbatch.container.modelresolver.PropertyResolver;
-import com.ibm.jbatch.container.modelresolver.PropertyResolverFactory;
-import com.ibm.jbatch.container.navigator.ModelNavigator;
-import com.ibm.jbatch.container.navigator.NavigatorFactory;
-import com.ibm.jbatch.container.services.IBatchKernelService;
-import com.ibm.jbatch.container.services.IJobExecution;
-import com.ibm.jbatch.container.services.IJobStatusManagerService;
-import com.ibm.jbatch.container.services.IPersistenceManagerService;
-import com.ibm.jbatch.container.servicesmanager.ServicesManager;
-import com.ibm.jbatch.container.servicesmanager.ServicesManagerImpl;
-import com.ibm.jbatch.container.status.JobStatus;
-import com.ibm.jbatch.jsl.model.JSLJob;
-import com.ibm.jbatch.jsl.model.JSLProperties;
-
-public class JobExecutionHelper {
-
- private final static String CLASSNAME = JobExecutionHelper.class.getName();
- private final static Logger logger = Logger.getLogger(CLASSNAME);
-
- private static ServicesManager servicesManager = ServicesManagerImpl.getInstance();
-
- private static IJobStatusManagerService _jobStatusManagerService =
- servicesManager.getJobStatusManagerService();
-
- private static IPersistenceManagerService _persistenceManagementService =
- servicesManager.getPersistenceManagerService();
- private static IBatchKernelService _batchKernelService = servicesManager.getBatchKernelService();
-
-
- private static ModelNavigator<JSLJob> getResolvedJobNavigator(String jobXml, Properties jobParameters, boolean parallelExecution) {
-
- JSLJob jobModel = ModelResolverFactory.createJobResolver().resolveModel(jobXml);
- PropertyResolver<JSLJob> propResolver = PropertyResolverFactory.createJobPropertyResolver(parallelExecution);
- propResolver.substituteProperties(jobModel, jobParameters);
-
- return NavigatorFactory.createJobNavigator(jobModel);
- }
-
- private static ModelNavigator<JSLJob> getResolvedJobNavigator(JSLJob jobModel, Properties jobParameters, boolean parallelExecution) {
-
- PropertyResolver<JSLJob> propResolver = PropertyResolverFactory.createJobPropertyResolver(parallelExecution);
- propResolver.substituteProperties(jobModel, jobParameters);
-
- return NavigatorFactory.createJobNavigator(jobModel);
- }
-
- private static JobContextImpl getJobContext(ModelNavigator<JSLJob> jobNavigator) {
- JSLProperties jslProperties = new JSLProperties();
- if(jobNavigator.getRootModelElement() != null) {
- jslProperties = jobNavigator.getRootModelElement().getProperties();
- }
- return new JobContextImpl(jobNavigator, jslProperties);
- }
-
- private static JobInstance getNewJobInstance(String name, String jobXml) {
- String apptag = _batchKernelService.getBatchSecurityHelper().getCurrentTag();
- return _persistenceManagementService.createJobInstance(name, apptag, jobXml);
- }
-
- private static JobInstance getNewSubJobInstance(String name) {
- String apptag = _batchKernelService.getBatchSecurityHelper().getCurrentTag();
- return _persistenceManagementService.createSubJobInstance(name, apptag);
- }
-
- private static JobStatus createNewJobStatus(JobInstance jobInstance) {
- long instanceId = jobInstance.getInstanceId();
- JobStatus jobStatus = _jobStatusManagerService.createJobStatus(instanceId);
- jobStatus.setJobInstance(jobInstance);
- return jobStatus;
- }
-
- private static void validateRestartableFalseJobsDoNotRestart(JSLJob jobModel)
- throws JobRestartException {
- if (jobModel.getRestartable() != null && jobModel.getRestartable().equalsIgnoreCase("false")) {
- throw new JobRestartException("Job Restartable attribute is false, Job cannot be restarted.");
- }
- }
-
- public static RuntimeJobExecution startJob(String jobXML, Properties jobParameters) throws JobStartException {
- logger.entering(CLASSNAME, "startJob", new Object[]{jobXML, jobParameters==null ? "<null>" : jobParameters});
-
- JSLJob jobModel = ModelResolverFactory.createJobResolver().resolveModel(jobXML);
-
- ModelNavigator<JSLJob> jobNavigator = getResolvedJobNavigator(jobModel, jobParameters, false);
-
- JobContextImpl jobContext = getJobContext(jobNavigator);
-
- JobInstance jobInstance = getNewJobInstance(jobNavigator.getRootModelElement().getId(), jobXML);
-
- RuntimeJobExecution executionHelper =
- _persistenceManagementService.createJobExecution(jobInstance, jobParameters, jobContext.getBatchStatus());
-
- executionHelper.prepareForExecution(jobContext);
-
- JobStatus jobStatus = createNewJobStatus(jobInstance);
- _jobStatusManagerService.updateJobStatus(jobStatus);
-
- logger.exiting(CLASSNAME, "startJob", executionHelper);
-
- return executionHelper;
- }
-
- public static RuntimeFlowInSplitExecution startFlowInSplit(JSLJob jobModel) throws JobStartException{
- logger.entering(CLASSNAME, "startFlowInSplit", jobModel);
-
- ModelNavigator<JSLJob> jobNavigator = getResolvedJobNavigator(jobModel, null, true);
- JobContextImpl jobContext = getJobContext(jobNavigator);
-
- JobInstance jobInstance = getNewSubJobInstance(jobNavigator.getRootModelElement().getId());
-
- RuntimeFlowInSplitExecution executionHelper =
- _persistenceManagementService.createFlowInSplitExecution(jobInstance, jobContext.getBatchStatus());
-
- executionHelper.prepareForExecution(jobContext);
-
- JobStatus jobStatus = createNewJobStatus(jobInstance);
- _jobStatusManagerService.updateJobStatus(jobStatus);
-
- logger.exiting(CLASSNAME, "startFlowInSplit", executionHelper);
- return executionHelper;
- }
-
- public static RuntimeJobExecution startPartition(JSLJob jobModel, Properties jobParameters) throws JobStartException{
- logger.entering(CLASSNAME, "startPartition", new Object[]{jobModel, jobParameters ==null ? "<null>" :jobParameters});
-
- ModelNavigator<JSLJob> jobNavigator = getResolvedJobNavigator(jobModel, jobParameters, true);
- JobContextImpl jobContext = getJobContext(jobNavigator);
-
- JobInstance jobInstance = getNewSubJobInstance(jobNavigator.getRootModelElement().getId());
-
- RuntimeJobExecution executionHelper =
- _persistenceManagementService.createJobExecution(jobInstance, jobParameters, jobContext.getBatchStatus());
-
- executionHelper.prepareForExecution(jobContext);
-
- JobStatus jobStatus = createNewJobStatus(jobInstance);
- _jobStatusManagerService.updateJobStatus(jobStatus);
-
- logger.exiting(CLASSNAME, "startPartition", executionHelper);
- return executionHelper;
- }
-
- public static RuntimeJobExecution restartJob(long executionId, JSLJob gennedJobModel) throws JobRestartException, JobExecutionAlreadyCompleteException, JobExecutionNotMostRecentException, NoSuchJobExecutionException {
- return restartExecution(executionId, null, null, false, false);
- }
-
- private static void validateJobInstanceNotCompleteOrAbandonded(JobStatus jobStatus) throws JobRestartException, JobExecutionAlreadyCompleteException {
- if (jobStatus.getBatchStatus() == null) {
- String msg = "On restart, we didn't find an earlier batch status.";
- logger.warning(msg);
- throw new IllegalStateException(msg);
- }
-
- if (jobStatus.getBatchStatus().equals(BatchStatus.COMPLETED)) {
- String msg = "Already completed job instance = " + jobStatus.getJobInstanceId();
- logger.fine(msg);
- throw new JobExecutionAlreadyCompleteException(msg);
- } else if (jobStatus.getBatchStatus().equals(BatchStatus.ABANDONED)) {
- String msg = "Abandoned job instance = " + jobStatus.getJobInstanceId();
- logger.warning(msg);
- throw new JobRestartException(msg);
- }
- }
-
- private static void validateJobExecutionIsMostRecent(long jobInstanceId, long executionId) throws JobExecutionNotMostRecentException {
-
- long mostRecentExecutionId = _persistenceManagementService.getMostRecentExecutionId(jobInstanceId);
-
- if ( mostRecentExecutionId != executionId ) {
- String message = "ExecutionId: " + executionId + " is not the most recent execution.";
- logger.warning(message);
- throw new JobExecutionNotMostRecentException(message);
- }
- }
-
- public static RuntimeJobExecution restartPartition(long execId, JSLJob gennedJobModel, Properties partitionProps) throws JobRestartException,
- JobExecutionAlreadyCompleteException, JobExecutionNotMostRecentException, NoSuchJobExecutionException {
- return restartExecution(execId, gennedJobModel, partitionProps, true, false);
- }
-
- public static RuntimeFlowInSplitExecution restartFlowInSplit(long execId, JSLJob gennedJobModel) throws JobRestartException,
- JobExecutionAlreadyCompleteException, JobExecutionNotMostRecentException, NoSuchJobExecutionException {
- return (RuntimeFlowInSplitExecution)restartExecution(execId, gennedJobModel, null, true, true);
- }
-
- public static RuntimeJobExecution restartJob(long executionId, Properties restartJobParameters) throws JobRestartException,
- JobExecutionAlreadyCompleteException, JobExecutionNotMostRecentException, NoSuchJobExecutionException {
- return restartExecution(executionId, null, restartJobParameters, false, false);
- }
-
- private static RuntimeJobExecution restartExecution(long executionId, JSLJob gennedJobModel, Properties restartJobParameters, boolean parallelExecution, boolean flowInSplit) throws JobRestartException,
- JobExecutionAlreadyCompleteException, JobExecutionNotMostRecentException, NoSuchJobExecutionException {
-
- long jobInstanceId = _persistenceManagementService.getJobInstanceIdByExecutionId(executionId);
-
- JobStatus jobStatus = _jobStatusManagerService.getJobStatus(jobInstanceId);
-
- if (logger.isLoggable(Level.FINE)) {
- logger.fine("On restartJob with jobInstance Id = " + jobInstanceId + " , found JobStatus: " + jobStatus +
- ", batchStatus = " + jobStatus.getBatchStatus().name() );
- }
-
- validateJobExecutionIsMostRecent(jobInstanceId, executionId);
-
- validateJobInstanceNotCompleteOrAbandonded(jobStatus);
-
- JobInstanceImpl jobInstance = jobStatus.getJobInstance();
-
- ModelNavigator<JSLJob> jobNavigator = null;
-
- // If we are in a parallel job that is genned use the regenned JSL.
- if (gennedJobModel == null) {
- jobNavigator = getResolvedJobNavigator(jobInstance.getJobXML(), restartJobParameters, parallelExecution);
- } else {
- jobNavigator = getResolvedJobNavigator(gennedJobModel, restartJobParameters, parallelExecution);
- }
- // JSLJob jobModel = ModelResolverFactory.createJobResolver().resolveModel(jobInstance.getJobXML());
- validateRestartableFalseJobsDoNotRestart(jobNavigator.getRootModelElement());
-
- JobContextImpl jobContext = getJobContext(jobNavigator);
-
- RuntimeJobExecution executionHelper;
- if (flowInSplit) {
- executionHelper = _persistenceManagementService.createFlowInSplitExecution(jobInstance, jobContext.getBatchStatus());
- } else {
- executionHelper = _persistenceManagementService.createJobExecution(jobInstance, restartJobParameters, jobContext.getBatchStatus());
- }
- executionHelper.prepareForExecution(jobContext, jobStatus.getRestartOn());
- _jobStatusManagerService.updateJobStatusWithNewExecution(jobInstance.getInstanceId(), executionHelper.getExecutionId());
-
- return executionHelper;
- }
-
- public static IJobExecution getPersistedJobOperatorJobExecution(long jobExecutionId) throws NoSuchJobExecutionException {
- return _persistenceManagementService.jobOperatorGetJobExecution(jobExecutionId);
- }
-
-
- public static JobInstance getJobInstance(long executionId){
- JobStatus jobStatus = _jobStatusManagerService.getJobStatusFromExecutionId(executionId);
- JobInstanceImpl jobInstance = jobStatus.getJobInstance();
- return jobInstance;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/JSR352.Runtime/src/com/ibm/jbatch/container/jobinstance/JobInstanceImpl.java
----------------------------------------------------------------------
diff --git a/JSR352.Runtime/src/com/ibm/jbatch/container/jobinstance/JobInstanceImpl.java b/JSR352.Runtime/src/com/ibm/jbatch/container/jobinstance/JobInstanceImpl.java
deleted file mode 100755
index b8e11eb..0000000
--- a/JSR352.Runtime/src/com/ibm/jbatch/container/jobinstance/JobInstanceImpl.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright 2012 International Business Machines Corp.
- *
- * See the NOTICE file distributed with this work for additional information
- * regarding copyright ownership. Licensed under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-package com.ibm.jbatch.container.jobinstance;
-
-import java.io.Serializable;
-
-import javax.batch.runtime.JobInstance;
-
-public class JobInstanceImpl implements JobInstance, Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- private long jobInstanceId = 0L;
- private String jobName = null;
- private String jobXML = null;
-
- private JobInstanceImpl() {
- }
-
- public JobInstanceImpl(long instanceId) {
- this.jobInstanceId = instanceId;
- }
-
- public JobInstanceImpl(long instanceId, String jobXML) {
- this.jobXML = jobXML;
- this.jobInstanceId = instanceId;
- }
-
- @Override
- public long getInstanceId() {
- return jobInstanceId;
- }
-
- public void setJobName(String jobName) {
- this.jobName = jobName;
- }
-
- public String getJobName() {
- return jobName;
- }
-
- public String getJobXML() {
- return jobXML;
- }
-
-
- @Override
- public String toString() {
-
- StringBuffer buf = new StringBuffer();
- buf.append(" jobName: " + jobName);
- buf.append(" jobInstance id: " + jobInstanceId);
- if (jobXML != null) {
- int concatLen = jobXML.length() > 300 ? 300 : jobXML.length();
- buf.append(" jobXML: " + jobXML.subSequence(0, concatLen) + "...truncated ...\n");
- } else {
- buf.append(" jobXML = null");
- }
- return buf.toString();
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/JSR352.Runtime/src/com/ibm/jbatch/container/jobinstance/JobOperatorJobExecution.java
----------------------------------------------------------------------
diff --git a/JSR352.Runtime/src/com/ibm/jbatch/container/jobinstance/JobOperatorJobExecution.java b/JSR352.Runtime/src/com/ibm/jbatch/container/jobinstance/JobOperatorJobExecution.java
deleted file mode 100755
index a37c0aa..0000000
--- a/JSR352.Runtime/src/com/ibm/jbatch/container/jobinstance/JobOperatorJobExecution.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/**
- * Copyright 2012 International Business Machines Corp.
- *
- * See the NOTICE file distributed with this work for additional information
- * regarding copyright ownership. Licensed under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.ibm.jbatch.container.jobinstance;
-
-import java.sql.Timestamp;
-import java.util.Date;
-import java.util.Properties;
-import java.util.logging.Logger;
-
-import javax.batch.runtime.BatchStatus;
-
-import com.ibm.jbatch.container.context.impl.JobContextImpl;
-import com.ibm.jbatch.container.services.IJobExecution;
-import com.ibm.jbatch.container.services.IPersistenceManagerService;
-import com.ibm.jbatch.container.services.IPersistenceManagerService.TimestampType;
-import com.ibm.jbatch.container.servicesmanager.ServicesManager;
-import com.ibm.jbatch.container.servicesmanager.ServicesManagerImpl;
-import com.ibm.jbatch.spi.TaggedJobExecution;
-
-public class JobOperatorJobExecution implements IJobExecution, TaggedJobExecution {
-
- private final static String sourceClass = JobOperatorJobExecution.class.getName();
- private final static Logger logger = Logger.getLogger(sourceClass);
-
- private static ServicesManager servicesManager = ServicesManagerImpl.getInstance();
- private static IPersistenceManagerService _persistenceManagementService = servicesManager.getPersistenceManagerService();
-
- private long executionID = 0L;
- private long instanceID = 0L;
-
- Timestamp createTime;
- Timestamp startTime;
- Timestamp endTime;
- Timestamp updateTime;
- Properties parameters;
- String batchStatus;
- String exitStatus;
- Properties jobProperties = null;
- String jobName = null;
- private JobContextImpl jobContext = null;
-
- public void setJobName(String jobName) {
- this.jobName = jobName;
- }
-
- public void setJobContext(JobContextImpl jobContext) {
- this.jobContext = jobContext;
- }
-
- public JobOperatorJobExecution(long executionId, long instanceId) {
- this.executionID = executionId;
- this.instanceID = instanceId;
- }
-
- @Override
- public BatchStatus getBatchStatus() {
-
- BatchStatus batchStatus = null;
-
- if (this.jobContext != null){
- batchStatus = this.jobContext.getBatchStatus();
- logger.finest("Returning batch status of: " + batchStatus + " from JobContext.");
- }
- else {
- // old job, retrieve from the backend
- batchStatus = BatchStatus.valueOf(_persistenceManagementService.jobOperatorQueryJobExecutionBatchStatus(executionID));
- logger.finest("Returning batch status of: " + batchStatus + " from JobContext.");
- }
- return batchStatus;
- }
-
- @Override
- public Date getCreateTime() {
-
- if (this.jobContext == null) {
- createTime = _persistenceManagementService.jobOperatorQueryJobExecutionTimestamp(executionID, TimestampType.CREATE);
- }
-
- if (createTime != null){
- return new Date(createTime.getTime());
- }
- else return createTime;
- }
-
- @Override
- public Date getEndTime() {
-
-
- if (this.jobContext == null) {
- endTime = _persistenceManagementService.jobOperatorQueryJobExecutionTimestamp(executionID, TimestampType.END);
- }
-
- if (endTime != null){
- return new Date(endTime.getTime());
- }
- else return endTime;
- }
-
- @Override
- public long getExecutionId() {
- return executionID;
- }
-
- @Override
- public String getExitStatus() {
-
- if (this.jobContext != null){
- return this.jobContext.getExitStatus();
- }
- else {
- exitStatus = _persistenceManagementService.jobOperatorQueryJobExecutionExitStatus(executionID);
- return exitStatus;
- }
-
- }
-
- @Override
- public Date getLastUpdatedTime() {
-
- if (this.jobContext == null) {
- this.updateTime = _persistenceManagementService.jobOperatorQueryJobExecutionTimestamp(executionID, TimestampType.LAST_UPDATED);
- }
-
- if (updateTime != null) {
- return new Date(this.updateTime.getTime());
- }
- else return updateTime;
- }
-
- @Override
- public Date getStartTime() {
-
- if (this.jobContext == null) {
- startTime = _persistenceManagementService.jobOperatorQueryJobExecutionTimestamp(executionID, TimestampType.STARTED);
- }
-
- if (startTime != null){
- return new Date(startTime.getTime());
- }
- else return startTime;
- }
-
- @Override
- public Properties getJobParameters() {
- // TODO Auto-generated method stub
- return jobProperties;
- }
-
- // IMPL specific setters
-
- public void setBatchStatus(String status) {
- batchStatus = status;
- }
-
- public void setCreateTime(Timestamp ts) {
- createTime = ts;
- }
-
- public void setEndTime(Timestamp ts) {
- endTime = ts;
- }
-
- public void setExecutionId(long id) {
- executionID = id;
- }
-
- public void setJobInstanceId(long jobInstanceID){
- instanceID = jobInstanceID;
- }
-
- public void setExitStatus(String status) {
- exitStatus = status;
-
- }
-
- public void setInstanceId(long id) {
- instanceID = id;
- }
-
- public void setLastUpdateTime(Timestamp ts) {
- updateTime = ts;
- }
-
- public void setStartTime(Timestamp ts) {
- startTime = ts;
- }
-
- public void setJobParameters(Properties jProps){
- jobProperties = jProps;
- }
-
- @Override
- public String getJobName() {
- return jobName;
- }
-
- @Override
- public String getTagName() {
- return _persistenceManagementService.getTagName(executionID);
- }
-
- @Override
- public long getInstanceId() {
- return instanceID;
- }
-
- @Override
- public String toString() {
- StringBuffer buf = new StringBuffer();
- buf.append("createTime=" + createTime);
- buf.append(",batchStatus=" + batchStatus);
- buf.append(",exitStatus=" + exitStatus);
- buf.append(",jobName=" + jobName);
- buf.append(",instanceId=" + instanceID);
- buf.append(",executionId=" + executionID);
- return buf.toString();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/JSR352.Runtime/src/com/ibm/jbatch/container/jobinstance/RuntimeFlowInSplitExecution.java
----------------------------------------------------------------------
diff --git a/JSR352.Runtime/src/com/ibm/jbatch/container/jobinstance/RuntimeFlowInSplitExecution.java b/JSR352.Runtime/src/com/ibm/jbatch/container/jobinstance/RuntimeFlowInSplitExecution.java
deleted file mode 100755
index d5c5c8a..0000000
--- a/JSR352.Runtime/src/com/ibm/jbatch/container/jobinstance/RuntimeFlowInSplitExecution.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * Copyright 2012 International Business Machines Corp.
- *
- * See the NOTICE file distributed with this work for additional information
- * regarding copyright ownership. Licensed under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.ibm.jbatch.container.jobinstance;
-
-import javax.batch.runtime.JobInstance;
-
-import com.ibm.jbatch.container.status.ExecutionStatus;
-
-public class RuntimeFlowInSplitExecution extends RuntimeJobExecution {
-
- public RuntimeFlowInSplitExecution(JobInstance jobInstance, long executionId) {
- super(jobInstance, executionId);
- }
-
- private ExecutionStatus flowStatus;
-
- public ExecutionStatus getFlowStatus() {
- return flowStatus;
- }
-
- public void setFlowStatus(ExecutionStatus flowStatus) {
- this.flowStatus = flowStatus;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/JSR352.Runtime/src/com/ibm/jbatch/container/jobinstance/RuntimeJobExecution.java
----------------------------------------------------------------------
diff --git a/JSR352.Runtime/src/com/ibm/jbatch/container/jobinstance/RuntimeJobExecution.java b/JSR352.Runtime/src/com/ibm/jbatch/container/jobinstance/RuntimeJobExecution.java
deleted file mode 100755
index 3699ae9..0000000
--- a/JSR352.Runtime/src/com/ibm/jbatch/container/jobinstance/RuntimeJobExecution.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Copyright 2012 International Business Machines Corp.
- *
- * See the NOTICE file distributed with this work for additional information
- * regarding copyright ownership. Licensed under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.ibm.jbatch.container.jobinstance;
-
-import java.sql.Timestamp;
-import java.util.Date;
-import java.util.Properties;
-
-import javax.batch.runtime.BatchStatus;
-import javax.batch.runtime.JobInstance;
-
-import com.ibm.jbatch.container.artifact.proxy.ListenerFactory;
-import com.ibm.jbatch.container.context.impl.JobContextImpl;
-import com.ibm.jbatch.container.navigator.ModelNavigator;
-import com.ibm.jbatch.container.services.IJobExecution;
-import com.ibm.jbatch.jsl.model.JSLJob;
-
-public class RuntimeJobExecution {
-
- private ModelNavigator<JSLJob> jobNavigator = null;
- private JobInstance jobInstance;
- private long executionId;
- private String restartOn;
- private JobContextImpl jobContext = null;
- private ListenerFactory listenerFactory;
- private IJobExecution operatorJobExecution = null;
- private Integer partitionInstance = null;
-
- public RuntimeJobExecution(JobInstance jobInstance, long executionId) {
- this.jobInstance = jobInstance;
- this.executionId = executionId;
- this.operatorJobExecution = new JobOperatorJobExecution(executionId, jobInstance.getInstanceId());
- }
-
-
- /*
- * Non-spec'd methods (not on the interface, but maybe we should
- * put on a second interface).
- */
-
- public void prepareForExecution(JobContextImpl jobContext, String restartOn) {
- this.jobContext = jobContext;
- this.jobNavigator = jobContext.getNavigator();
- jobContext.setExecutionId(executionId);
- jobContext.setInstanceId(jobInstance.getInstanceId());
- this.restartOn = restartOn;
- operatorJobExecution.setJobContext(jobContext);
- }
-
- public void prepareForExecution(JobContextImpl jobContext) {
- prepareForExecution(jobContext, null);
- }
-
- public void setRestartOn(String restartOn) {
- this.restartOn = restartOn;
- }
- public long getExecutionId() {
- return executionId;
- }
-
- public long getInstanceId() {
- return jobInstance.getInstanceId();
- }
-
- public JobInstance getJobInstance() {
- return jobInstance;
- }
-
- public ModelNavigator<JSLJob> getJobNavigator() {
- return jobNavigator;
- }
-
- public JobContextImpl getJobContext() {
- return jobContext;
- }
-
- public String getRestartOn() {
- return restartOn;
- }
-
- public ListenerFactory getListenerFactory() {
- return listenerFactory;
- }
-
- public void setListenerFactory(ListenerFactory listenerFactory) {
- this.listenerFactory = listenerFactory;
- }
-
- public IJobExecution getJobOperatorJobExecution() {
- return operatorJobExecution;
- }
-
- public BatchStatus getBatchStatus() {
- return this.jobContext.getBatchStatus();
- }
-
- public String getExitStatus() {
- return this.jobContext.getExitStatus();
- }
-
- public void setBatchStatus(String status) {
- operatorJobExecution.setBatchStatus(status);
- }
-
- public void setCreateTime(Timestamp ts) {
- operatorJobExecution.setCreateTime(ts);
- }
-
- public void setEndTime(Timestamp ts) {
- operatorJobExecution.setEndTime(ts);
- }
-
- public void setExitStatus(String status) {
- //exitStatus = status;
- operatorJobExecution.setExitStatus(status);
-
- }
-
- public void setLastUpdateTime(Timestamp ts) {
- operatorJobExecution.setLastUpdateTime(ts);
- }
-
- public void setStartTime(Timestamp ts) {
- operatorJobExecution.setStartTime(ts);
- }
-
- public void setJobParameters(Properties jProps){
- operatorJobExecution.setJobParameters(jProps);
- }
-
- public Properties getJobParameters(){
- return operatorJobExecution.getJobParameters();
- }
-
- public Date getStartTime(){
- return operatorJobExecution.getStartTime();
- }
-
- public Date getEndTime(){
- return operatorJobExecution.getEndTime();
- }
-
- public Date getLastUpdatedTime(){
- return operatorJobExecution.getLastUpdatedTime();
- }
-
- public Date getCreateTime(){
- return operatorJobExecution.getCreateTime();
- }
-
- @Override
- public String toString() {
- StringBuffer buf = new StringBuffer();
- buf.append(" executionId: " + executionId);
- buf.append(" restartOn: " + restartOn);
- buf.append("\n-----------------------\n");
- buf.append("jobInstance: \n " + jobInstance);
- return buf.toString();
- }
-
- public Integer getPartitionInstance() {
- return partitionInstance;
- }
-
- public void setPartitionInstance(Integer partitionInstance) {
- this.partitionInstance = partitionInstance;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/JSR352.Runtime/src/com/ibm/jbatch/container/jobinstance/StepExecutionImpl.java
----------------------------------------------------------------------
diff --git a/JSR352.Runtime/src/com/ibm/jbatch/container/jobinstance/StepExecutionImpl.java b/JSR352.Runtime/src/com/ibm/jbatch/container/jobinstance/StepExecutionImpl.java
deleted file mode 100755
index f004ec7..0000000
--- a/JSR352.Runtime/src/com/ibm/jbatch/container/jobinstance/StepExecutionImpl.java
+++ /dev/null
@@ -1,276 +0,0 @@
-/*
- * Copyright 2012 International Business Machines Corp.
- *
- * See the NOTICE file distributed with this work for additional information
- * regarding copyright ownership. Licensed under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-package com.ibm.jbatch.container.jobinstance;
-
-import java.io.Serializable;
-import java.sql.Timestamp;
-import java.util.Date;
-
-import javax.batch.api.partition.PartitionPlan;
-import javax.batch.runtime.BatchStatus;
-import javax.batch.runtime.Metric;
-import javax.batch.runtime.StepExecution;
-
-import com.ibm.jbatch.container.context.impl.MetricImpl;
-import com.ibm.jbatch.container.context.impl.StepContextImpl;
-
-public class StepExecutionImpl implements StepExecution, Serializable {
-
- private long commitCount = 0;
- private Timestamp endTime = null;
- private String exitStatus = null;
- private BatchStatus batchStatus = null;
-
- private long filterCount = 0;
- private long jobExecutionId = 0;
- private Timestamp lastUpdateTime = null;
- private long processSkipCount = 0;
- private long readCount = 0;
- private long readSkipCount = 0;
- private long rollbackCount = 0;
- private Timestamp startTime = null;
- private long stepExecutionId = 0;
- private String stepName = null;
-
- private long writeCount = 0;
- private long writeSkipCount = 0;
-
- private PartitionPlan plan = null;
-
- private Serializable persistentUserData = null;
-
- private StepContextImpl stepContext = null;
-
- public StepExecutionImpl(long jobExecutionId, long stepExecutionId) {
- this.jobExecutionId = jobExecutionId;
- this.stepExecutionId = stepExecutionId;
- }
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- @Override
- public long getStepExecutionId() {
- return this.stepExecutionId;
- }
-
- @Override
- public Date getEndTime() {
- if (stepContext != null){
- return this.stepContext.getEndTimeTS();
- }
- else {
- if (endTime != null) {
- return new Date(endTime.getTime());
- } else {
- return null;
- }
- }
- }
-
- // Not a spec API but for internal use.
- public long getJobExecutionId(){
- return this.jobExecutionId;
- }
-
- @Override
- public String getExitStatus() {
- if (stepContext != null){
- return this.stepContext.getExitStatus();
- }
- else {
- return exitStatus;
- }
- }
-
- @Override
- public Date getStartTime() {
- if (stepContext != null){
- return this.stepContext.getStartTimeTS();
- }
- else {
- if (startTime != null) {
- return new Date(startTime.getTime());
- } else {
- return null;
- }
- }
- }
-
- @Override
- public String toString() {
- StringBuffer buf = new StringBuffer();
- buf.append("---------------------------------------------------------------------------------");
- buf.append("getStepName(): " + this.getStepName() + "\n");
- buf.append("getStepExecutionId(): " + this.stepExecutionId + "\n");
- buf.append("getJobExecutionId(): " + this.jobExecutionId + "\n");
- //buf.append("getCommitCount(): " + this.getCommitCount() + "\n");
- //buf.append("getFilterCount(): " + this.getFilterCount() + "\n");
- //buf.append("getProcessSkipCount(): " + this.getProcessSkipCount() + "\n");
- //buf.append("getReadCount(): " + this.getReadCount() + "\n");
- //buf.append("getReadSkipCount(): " + this.getReadSkipCount() + "\n");
- //buf.append("getRollbackCount(): " + this.getRollbackCount() + "\n");
- //buf.append("getWriteCount(): " + this.getWriteCount() + "\n");
- //buf.append("getWriteSkipCount(): " + this.getWriteSkipCount() + "\n");
- buf.append("getStartTime(): " + this.getStartTime() + "\n");
- buf.append("getEndTime(): " + this.getEndTime() + "\n");
- //buf.append("getLastUpdateTime(): " + this.getLastUpdateTime() + "\n");
- buf.append("getBatchStatus(): " + this.getBatchStatus().name() + "\n");
- buf.append("getExitStatus(): " + this.getExitStatus());
- buf.append("---------------------------------------------------------------------------------");
- return buf.toString();
- }
-
- @Override
- public Metric[] getMetrics() {
-
-
- if (stepContext != null){
- return stepContext.getMetrics();
- }
- else {
- Metric[] metrics = new MetricImpl[8];
- metrics[0] = new MetricImpl(MetricImpl.MetricType.READ_COUNT, readCount);
- metrics[1] = new MetricImpl(MetricImpl.MetricType.WRITE_COUNT, writeCount);
- metrics[2] = new MetricImpl(MetricImpl.MetricType.COMMIT_COUNT, commitCount);
- metrics[3] = new MetricImpl(MetricImpl.MetricType.ROLLBACK_COUNT, rollbackCount);
- metrics[4] = new MetricImpl(MetricImpl.MetricType.READ_SKIP_COUNT, readSkipCount);
- metrics[5] = new MetricImpl(MetricImpl.MetricType.PROCESS_SKIP_COUNT, processSkipCount);
- metrics[6] = new MetricImpl(MetricImpl.MetricType.FILTER_COUNT, filterCount);
- metrics[7] = new MetricImpl(MetricImpl.MetricType.WRITE_SKIP_COUNT, writeSkipCount);
-
- return metrics;
- }
- }
-
- @Override
- public BatchStatus getBatchStatus() {
-
- if (stepContext != null){
- return this.stepContext.getBatchStatus();
- }
- else {
- return batchStatus;
- }
- }
-
- @Override
- public Serializable getPersistentUserData() {
- if (stepContext != null){
- return this.stepContext.getPersistentUserData();
- }
- else {
- return this.persistentUserData;
- }
- }
-
-
- // impl specific setters
- public void setFilterCount(long filterCnt) {
- this.filterCount = filterCnt;
- }
-
- public void setLastUpdateTime(Timestamp lastUpdateTime) {
- this.lastUpdateTime = lastUpdateTime;
- }
-
- public void setProcessSkipCount(long processSkipCnt) {
- this.processSkipCount = processSkipCnt;
- }
-
- public void setReadCount(long readCnt) {
- this.readCount = readCnt;
- }
-
- public void setReadSkipCount(long readSkipCnt) {
- this.readSkipCount = readSkipCnt;
- }
-
- public void setRollbackCount(long rollbackCnt) {
- this.rollbackCount = rollbackCnt;
- }
-
- public void setJobExecutionId(long jobexecID){
- this.jobExecutionId = jobexecID;
- }
-
- public void setStepExecutionId(long stepexecID){
- this.stepExecutionId = stepexecID;
- }
-
-
- public void setStepName(String stepName) {
- this.stepName = stepName;
- }
-
- public void setWriteCount(long writeCnt) {
- this.writeCount = writeCnt;
- }
-
- public void setWriteSkipCount(long writeSkipCnt) {
- this.writeSkipCount = writeSkipCnt;
- }
-
- public void setStepContext(StepContextImpl stepContext) {
- this.stepContext = stepContext;
- }
-
- public void setCommitCount(long commitCnt) {
- this.commitCount = commitCnt;
- }
-
- public void setBatchStatus(BatchStatus batchstatus){
- this.batchStatus = batchstatus;
- }
-
- public void setExitStatus(String exitstatus){
- this.exitStatus = exitstatus;
- }
-
- public void setStartTime(Timestamp startts){
- this.startTime = startts;
- }
-
- public void setEndTime(Timestamp endts){
- this.endTime = endts;
- }
-
- public void setPersistentUserData(Serializable data){
- this.persistentUserData = data;
- }
-
- @Override
- public String getStepName() {
- if (stepContext != null){
- return this.stepContext.getStepName();
- }
- else {
- return stepName;
- }
- }
-
- public void setPlan(PartitionPlan plan) {
- this.plan = plan;
- }
-
- public PartitionPlan getPlan() {
- return plan;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/JSR352.Runtime/src/com/ibm/jbatch/container/navigator/AbstractNavigatorImpl.java
----------------------------------------------------------------------
diff --git a/JSR352.Runtime/src/com/ibm/jbatch/container/navigator/AbstractNavigatorImpl.java b/JSR352.Runtime/src/com/ibm/jbatch/container/navigator/AbstractNavigatorImpl.java
deleted file mode 100755
index ec3d76e..0000000
--- a/JSR352.Runtime/src/com/ibm/jbatch/container/navigator/AbstractNavigatorImpl.java
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * Copyright 2012 International Business Machines Corp.
- *
- * See the NOTICE file distributed with this work for additional information
- * regarding copyright ownership. Licensed under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.ibm.jbatch.container.navigator;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import com.ibm.jbatch.container.jsl.ExecutionElement;
-import com.ibm.jbatch.container.jsl.IllegalTransitionException;
-import com.ibm.jbatch.container.jsl.Transition;
-import com.ibm.jbatch.container.jsl.TransitionElement;
-import com.ibm.jbatch.container.jsl.impl.GlobPatternMatcherImpl;
-import com.ibm.jbatch.container.jsl.impl.TransitionImpl;
-import com.ibm.jbatch.container.status.ExecutionStatus;
-import com.ibm.jbatch.container.status.ExtendedBatchStatus;
-import com.ibm.jbatch.jsl.model.*;
-
-public abstract class AbstractNavigatorImpl<T> implements ModelNavigator<T> {
-
- private final static Logger logger = Logger.getLogger(AbstractNavigatorImpl.class.getName());
-
- private Map<String, ExecutionElement> alreadyExecutedElements = new HashMap<String, ExecutionElement>();
-
- public ExecutionElement getFirstExecutionElement(List<ExecutionElement> peerExecutionElements, String restartOn) throws IllegalTransitionException {
- final String method = "getFirstExecutionElement";
-
- logger.fine(method + " , restartOn = " + restartOn);
-
- ExecutionElement startElement = null;
-
- if (restartOn != null) {
- startElement = getExecutionElementFromId(peerExecutionElements, restartOn);
- if (startElement == null) {
- throw new IllegalStateException("Didn't find an execution element maching restart-on designated element: " + restartOn);
- }
- } else {
- if (peerExecutionElements.size() > 0) {
- startElement = peerExecutionElements.get(0);
- } else {
- logger.fine(method + " , Container appears to contain no execution elements. Returning.");
- return null;
- }
- }
-
- if (logger.isLoggable(Level.FINE)) {
- logger.fine(method + " , Found start element: " + startElement);
- }
-
- // We allow repeating a decision
- if (!(startElement instanceof Decision)) {
- alreadyExecutedElements.put(startElement.getId(), startElement);
- }
-
- validateElementType(startElement);
-
- return startElement;
- }
-
-
-
- /**
- * Precedence is: look at elements, then look at attribute, then return quietly
- *
- * @param currentElem
- * @param peerExecutionElements
- * @param currentExitStatus
- * @return
- * @throws IllegalTransitionException
- */
- public Transition getNextTransition(ExecutionElement currentElem, List<ExecutionElement> peerExecutionElements, ExecutionStatus currentStatus)
- throws IllegalTransitionException {
- final String method = "getNextTransition";
-
- if (logger.isLoggable(Level.FINE)) {
- logger.fine(method + " ,currentStatus=" + currentStatus);
- }
-
- Transition returnTransition = new TransitionImpl();
-
- ExecutionElement nextExecutionElement = null;
-
- List<TransitionElement> transitionElements = currentElem.getTransitionElements();
-
- // Check the transition elements first.
- if (!transitionElements.isEmpty()) {
- for (TransitionElement t : transitionElements) {
- logger.fine(method + " Trying to match next transition element: " + t);
-
- boolean isMatched = matchExitStatusAgainstOnAttribute(currentStatus.getExitStatus(), t);
- if (isMatched) {
- if (t instanceof Next) {
- Next next = (Next)t;
- nextExecutionElement = getExecutionElementFromId(peerExecutionElements, next.getTo());
- returnTransition.setNextExecutionElement(nextExecutionElement);
- break;
- } else {
- returnTransition.setTransitionElement(t);
- }
- return returnTransition;
- }
- }
- }
-
- // We've returned already if we matched a Stop, End or Fail
- if (nextExecutionElement == null) {
- if (currentStatus.getExtendedBatchStatus().equals(ExtendedBatchStatus.EXCEPTION_THROWN)) {
- logger.fine("Didn't match transition element, after exception thrown. Need to fail job");
- returnTransition.setNoTransitionElementMatchAfterException();
- return returnTransition;
- } else {
- logger.fine("Didn't match transition element, check @next attribute now.");
- nextExecutionElement = getNextExecutionElemFromAttribute(peerExecutionElements, currentElem);
- returnTransition.setNextExecutionElement(nextExecutionElement);
- }
- }
-
- if (nextExecutionElement != null) {
- if (alreadyExecutedElements.containsKey(nextExecutionElement.getId())) {
- String errorMsg = "Execution loop detected !!! Trying to re-execute execution element: " + nextExecutionElement.getId();
- logger.severe(errorMsg);
- throw new IllegalTransitionException(errorMsg);
- }
-
- // We allow repeating a decision
- if (!(nextExecutionElement instanceof Decision)) {
- alreadyExecutedElements.put(nextExecutionElement.getId(), nextExecutionElement);
- }
- logger.fine(method + " Transitioning to next element id = " + nextExecutionElement.getId());
- } else {
- logger.fine(method + " There is no next execution element. Mark transition to show we're finished.");
- returnTransition.setFinishedTransitioning();
- }
- return returnTransition;
- }
-
-
- private ExecutionElement getExecutionElementFromId(List<ExecutionElement> executionElements, String id)
- throws IllegalTransitionException {
- if (id != null) {
- logger.finer("attribute value is " + id);
- for (ExecutionElement elem : executionElements) {
- if (elem.getId().equals(id)) {
- validateElementType(elem);
- return elem;
- }
- }
- logger.warning("No execution element found with id = " + id);
- throw new IllegalTransitionException("No execution element found with id = " + id);
- } else {
- logger.finer("attribute value is <null>, so simply exiting...");
- return null;
- }
- }
-
- private static boolean matchSpecifiedExitStatus(String currentStepExitStatus, String exitStatusPattern) {
-
- logger.finer("matchSpecifiedExitStatus, matching current exitStatus " + currentStepExitStatus + " against pattern: " + exitStatusPattern);
-
- GlobPatternMatcherImpl matcher = new GlobPatternMatcherImpl();
- boolean match = matcher.matchWithoutBackslashEscape(currentStepExitStatus, exitStatusPattern);
-
- if (match) {
- logger.finer("matchSpecifiedExitStatus, match=YES");
- return true;
- }
- else {
- logger.finer("matchSpecifiedExitStatus, match=NO");
- return false;
- }
- }
-
- private boolean matchExitStatusAgainstOnAttribute(String exitStatus, TransitionElement elem) {
- logger.fine("Trying to match exitStatus = " + exitStatus + " , against transition element: " + elem);
- String exitStatusToMatch = null;
-
- if (elem instanceof End) {
- exitStatusToMatch = ((End) elem).getOn();
- } else if (elem instanceof Fail) {
- exitStatusToMatch = ((Fail) elem).getOn();
- return matchSpecifiedExitStatus(exitStatus, exitStatusToMatch);
- } else if (elem instanceof Stop) {
- exitStatusToMatch = ((Stop) elem).getOn();
- } else if (elem instanceof Next) {
- exitStatusToMatch = ((Next) elem).getOn();
- } else {
- throw new IllegalStateException("Shouldn't be possible to get here. Unknown transition element, " + elem.toString());
- }
-
- boolean match = matchSpecifiedExitStatus(exitStatus, exitStatusToMatch);
- String logMsg = match ? "Matched" : "Didn't match";
- logger.fine(logMsg);
- return match;
- }
-
- private ExecutionElement getNextExecutionElemFromAttribute(List<ExecutionElement> peerExecutionElements, ExecutionElement currentElem) throws IllegalTransitionException {
- ExecutionElement nextExecutionElement = null;
- String nextAttrId = null;
- if (currentElem instanceof Step) {
- nextAttrId = ((Step) currentElem).getNextFromAttribute();
- nextExecutionElement = getExecutionElementFromId(peerExecutionElements, nextAttrId);
- } else if (currentElem instanceof Split) {
- nextAttrId = ((Split) currentElem).getNextFromAttribute();
- nextExecutionElement = getExecutionElementFromId(peerExecutionElements, nextAttrId);
- } else if (currentElem instanceof Flow) {
- nextAttrId = ((Flow) currentElem).getNextFromAttribute();
- nextExecutionElement = getExecutionElementFromId(peerExecutionElements, nextAttrId);
- } else if (currentElem instanceof Decision) {
- // Nothing special to do in this case.
- }
-
- validateElementType(nextExecutionElement);
-
- logger.fine("From currentElem = " + currentElem + " , return @next attribute execution element: " + nextExecutionElement);
- return nextExecutionElement;
- }
-
- @Override
- public ExecutionElement getFirstExecutionElement()
- throws IllegalTransitionException {
- return getFirstExecutionElement(null);
- }
-
- private void validateElementType(ExecutionElement elem) {
- if (elem != null) {
- if (!((elem instanceof Decision) || (elem instanceof Flow) || (elem instanceof Split) || (elem instanceof Step))) {
- throw new IllegalArgumentException("Unknown execution element found, elem = " + elem + ", found with type: " + elem.getClass().getCanonicalName() +
- " , which is not an instance of Decision, Flow, Split, or Step.");
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/JSR352.Runtime/src/com/ibm/jbatch/container/navigator/FlowNavigatorImpl.java
----------------------------------------------------------------------
diff --git a/JSR352.Runtime/src/com/ibm/jbatch/container/navigator/FlowNavigatorImpl.java b/JSR352.Runtime/src/com/ibm/jbatch/container/navigator/FlowNavigatorImpl.java
deleted file mode 100755
index 6542743..0000000
--- a/JSR352.Runtime/src/com/ibm/jbatch/container/navigator/FlowNavigatorImpl.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright 2012 International Business Machines Corp.
- *
- * See the NOTICE file distributed with this work for additional information
- * regarding copyright ownership. Licensed under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.ibm.jbatch.container.navigator;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import com.ibm.jbatch.container.jsl.ExecutionElement;
-import com.ibm.jbatch.container.jsl.IllegalTransitionException;
-import com.ibm.jbatch.container.jsl.Transition;
-import com.ibm.jbatch.container.status.ExecutionStatus;
-import com.ibm.jbatch.jsl.model.Flow;
-
-public class FlowNavigatorImpl extends AbstractNavigatorImpl<Flow> implements ModelNavigator<Flow> {
-
- private final static Logger logger = Logger.getLogger(FlowNavigatorImpl.class.getName());
- private Flow flow = null;
-
- public FlowNavigatorImpl(Flow flow) {
- this.flow = flow;
- }
-
- public String toString() {
- return "FlowNavigatorImpl for flow id = " + flow.getId();
- }
-
- @Override
- public ExecutionElement getFirstExecutionElement(String restartOn)
- throws IllegalTransitionException {
- logger.fine("Getting first execution element in flow, restartOn = " + restartOn);
- ExecutionElement firstElem = getFirstExecutionElement(flow.getExecutionElements(), restartOn);
- logger.fine("Got first execution element in flow = " + firstElem.getId());
- return firstElem;
- }
-
-
-
- @Override
- public Transition getNextTransition(ExecutionElement currentExecutionElem, ExecutionStatus currentStatus)
- throws IllegalTransitionException {
- if (logger.isLoggable(Level.FINE)) {
- logger.fine("Getting next transition in flow, currentExecutionElem = " + currentExecutionElem);
- }
- Transition nextTransition = getNextTransition(currentExecutionElem, flow.getExecutionElements(), currentStatus);
- logger.fine("Got next transition in flow = " + nextTransition);
- return nextTransition;
- }
-
- @Override
- public Flow getRootModelElement() {
- return flow;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/JSR352.Runtime/src/com/ibm/jbatch/container/navigator/JobNavigatorImpl.java
----------------------------------------------------------------------
diff --git a/JSR352.Runtime/src/com/ibm/jbatch/container/navigator/JobNavigatorImpl.java b/JSR352.Runtime/src/com/ibm/jbatch/container/navigator/JobNavigatorImpl.java
deleted file mode 100755
index 49fd17f..0000000
--- a/JSR352.Runtime/src/com/ibm/jbatch/container/navigator/JobNavigatorImpl.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2012 International Business Machines Corp.
- *
- * See the NOTICE file distributed with this work for additional information
- * regarding copyright ownership. Licensed under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.ibm.jbatch.container.navigator;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-
-import com.ibm.jbatch.container.jsl.IllegalTransitionException;
-import com.ibm.jbatch.container.jsl.ExecutionElement;
-import com.ibm.jbatch.container.jsl.Transition;
-import com.ibm.jbatch.container.status.ExecutionStatus;
-import com.ibm.jbatch.jsl.model.JSLJob;
-
-public class JobNavigatorImpl extends AbstractNavigatorImpl<JSLJob> implements ModelNavigator<JSLJob> {
-
- private final static Logger logger = Logger.getLogger(JobNavigatorImpl.class.getName());
- private JSLJob job = null;
-
- public JobNavigatorImpl(JSLJob job) {
- this.job = job;
- }
-
- public String toString() {
- return "JobNavigatorImpl for job id = " + job.getId();
- }
-
- @Override
- public ExecutionElement getFirstExecutionElement(String restartOn)
- throws IllegalTransitionException {
- logger.fine("Getting first execution element in job, restartOn = " + restartOn);
- ExecutionElement firstElem = getFirstExecutionElement(job.getExecutionElements(), restartOn);
- logger.fine("Got first execution element in job = " + firstElem.getId());
- return firstElem;
- }
-
- @Override
- public ExecutionElement getFirstExecutionElement()
- throws IllegalTransitionException {
- return getFirstExecutionElement(null);
- }
-
- @Override
- public Transition getNextTransition(ExecutionElement currentExecutionElem, ExecutionStatus currentStatus)
- throws IllegalTransitionException {
- if (logger.isLoggable(Level.FINE)) {
- logger.fine("Getting next transition in job, currentExecutionElem = " + currentExecutionElem);
- }
- Transition nextTransition = getNextTransition(currentExecutionElem, job.getExecutionElements(), currentStatus);
- logger.fine("Got next transition in job = " + nextTransition);
- return nextTransition;
- }
-
- @Override
- public JSLJob getRootModelElement() {
- return job;
- }
-}
-
-
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/JSR352.Runtime/src/com/ibm/jbatch/container/navigator/ModelNavigator.java
----------------------------------------------------------------------
diff --git a/JSR352.Runtime/src/com/ibm/jbatch/container/navigator/ModelNavigator.java b/JSR352.Runtime/src/com/ibm/jbatch/container/navigator/ModelNavigator.java
deleted file mode 100755
index 0dd28a0..0000000
--- a/JSR352.Runtime/src/com/ibm/jbatch/container/navigator/ModelNavigator.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2012 International Business Machines Corp.
- *
- * See the NOTICE file distributed with this work for additional information
- * regarding copyright ownership. Licensed under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-package com.ibm.jbatch.container.navigator;
-
-import com.ibm.jbatch.container.jsl.ExecutionElement;
-import com.ibm.jbatch.container.jsl.IllegalTransitionException;
-import com.ibm.jbatch.container.jsl.Transition;
-import com.ibm.jbatch.container.status.ExecutionStatus;
-
-public interface ModelNavigator<T> {
-
- /**
- *
- * @param restartOn
- * @return
- * @throws IllegalTransitionException
- */
- public ExecutionElement getFirstExecutionElement(String restartOn) throws IllegalTransitionException;
-
- /**
- *
- * @return
- * @throws IllegalTransitionException
- */
- public ExecutionElement getFirstExecutionElement() throws IllegalTransitionException;
-
- /**
- * Enforces "can't revisit already visited steps rule".
- */
- public Transition getNextTransition(ExecutionElement currentExecutionElem, ExecutionStatus currentExecutionStatus)
- throws IllegalTransitionException;
-
- /**
- * E.g. the JSLJob for a job, the Flow for a flow, etc.
- * @return
- */
- public T getRootModelElement();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/JSR352.Runtime/src/com/ibm/jbatch/container/navigator/NavigatorFactory.java
----------------------------------------------------------------------
diff --git a/JSR352.Runtime/src/com/ibm/jbatch/container/navigator/NavigatorFactory.java b/JSR352.Runtime/src/com/ibm/jbatch/container/navigator/NavigatorFactory.java
deleted file mode 100755
index 10014a1..0000000
--- a/JSR352.Runtime/src/com/ibm/jbatch/container/navigator/NavigatorFactory.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright 2012 International Business Machines Corp.
- *
- * See the NOTICE file distributed with this work for additional information
- * regarding copyright ownership. Licensed under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-package com.ibm.jbatch.container.navigator;
-
-import com.ibm.jbatch.jsl.model.Flow;
-import com.ibm.jbatch.jsl.model.JSLJob;
-
-public class NavigatorFactory {
- public static JobNavigatorImpl createJobNavigator(JSLJob job) {
- return new JobNavigatorImpl(job);
- }
- public static FlowNavigatorImpl createFlowNavigator(Flow flow) {
- return new FlowNavigatorImpl(flow);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/JSR352.Runtime/src/com/ibm/jbatch/container/persistence/CheckpointAlgorithmFactory.java
----------------------------------------------------------------------
diff --git a/JSR352.Runtime/src/com/ibm/jbatch/container/persistence/CheckpointAlgorithmFactory.java b/JSR352.Runtime/src/com/ibm/jbatch/container/persistence/CheckpointAlgorithmFactory.java
deleted file mode 100755
index d4cf8fa..0000000
--- a/JSR352.Runtime/src/com/ibm/jbatch/container/persistence/CheckpointAlgorithmFactory.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2012 International Business Machines Corp.
- *
- * See the NOTICE file distributed with this work for additional information
- * regarding copyright ownership. Licensed under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-package com.ibm.jbatch.container.persistence;
-
-
-import com.ibm.jbatch.container.artifact.proxy.CheckpointAlgorithmProxy;
-import com.ibm.jbatch.container.artifact.proxy.InjectionReferences;
-import com.ibm.jbatch.container.artifact.proxy.ProxyFactory;
-import com.ibm.jbatch.container.context.impl.StepContextImpl;
-import com.ibm.jbatch.container.validation.ArtifactValidationException;
-import com.ibm.jbatch.jsl.model.Chunk;
-import com.ibm.jbatch.jsl.model.Step;
-
-public class CheckpointAlgorithmFactory {
-
- public static CheckpointAlgorithmProxy getCheckpointAlgorithmProxy (Step step, InjectionReferences injectionReferences, StepContextImpl stepContext) throws ArtifactValidationException{
- Chunk chunk = step.getChunk();
- CheckpointAlgorithmProxy proxy = null;
- String checkpointType = chunk.getCheckpointPolicy();
-
-
- if (checkpointType.equals("item")) {
-
- proxy = new CheckpointAlgorithmProxy( new ItemCheckpointAlgorithm());
-
- }else if (checkpointType.equalsIgnoreCase("custom")) {
-
- proxy = ProxyFactory.createCheckpointAlgorithmProxy(chunk
- .getCheckpointAlgorithm().getRef(), injectionReferences, stepContext);
-
- }
- return proxy;
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/JSR352.Runtime/src/com/ibm/jbatch/container/persistence/CheckpointData.java
----------------------------------------------------------------------
diff --git a/JSR352.Runtime/src/com/ibm/jbatch/container/persistence/CheckpointData.java b/JSR352.Runtime/src/com/ibm/jbatch/container/persistence/CheckpointData.java
deleted file mode 100755
index ff00344..0000000
--- a/JSR352.Runtime/src/com/ibm/jbatch/container/persistence/CheckpointData.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright 2012 International Business Machines Corp.
- *
- * See the NOTICE file distributed with this work for additional information
- * regarding copyright ownership. Licensed under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-package com.ibm.jbatch.container.persistence;
-import java.io.Serializable;
-import java.io.UnsupportedEncodingException;
-/**
- *
- */
-public class CheckpointData implements Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private long _jobInstanceId;
- private String _batchDataStreamName;
- private String _stepName;
- private byte[] _restartToken;
-
- public CheckpointData (
- long jobInstanceId,
- String stepname,
- String batchDataStreamName) {
- if(stepname != null && batchDataStreamName != null) {
- _jobInstanceId = jobInstanceId;
- _batchDataStreamName = batchDataStreamName;
- _stepName = stepname;
- try {
- _restartToken = new String("NOTSET").getBytes("UTF8");
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException("Doesn't support UTF-8", e);
- }
- } else {
- throw new RuntimeException("Invalid parameters to CheckpointData jobInstanceId: " + _jobInstanceId +
- " BDS: " + batchDataStreamName + " stepName: " + stepname);
- }
- }
-
- public long getjobInstanceId() {
- return _jobInstanceId;
- }
-
- public void setjobInstanceId(long id) {
- _jobInstanceId = id;
- }
-
- public String getBatchDataStreamName() {
- return _batchDataStreamName;
- }
-
- public void setBatchDataStreamName(String dataStreamName) {
- _batchDataStreamName = dataStreamName;
- }
-
- public String getStepName() {
- return _stepName;
- }
-
- public void setStepName(String name) {
- _stepName = name;
- }
-
- public byte[] getRestartToken() {
- return _restartToken;
- }
-
- public void setRestartToken(byte[] token) {
- _restartToken = token;
- }
-
- public String toString() {
- String restartString = null;
- try {
- restartString = new String(this._restartToken, "UTF8");
- } catch (UnsupportedEncodingException e) {
- restartString = "<bytes not UTF-8>";
- }
- return " jobInstanceId: " + _jobInstanceId + " stepId: " + this._stepName + " bdsName: " + this._batchDataStreamName +
- " restartToken: [UTF8-bytes: " + restartString;
-
- }
-
-
-
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/JSR352.Runtime/src/com/ibm/jbatch/container/persistence/CheckpointDataKey.java
----------------------------------------------------------------------
diff --git a/JSR352.Runtime/src/com/ibm/jbatch/container/persistence/CheckpointDataKey.java b/JSR352.Runtime/src/com/ibm/jbatch/container/persistence/CheckpointDataKey.java
deleted file mode 100755
index f92ff9a..0000000
--- a/JSR352.Runtime/src/com/ibm/jbatch/container/persistence/CheckpointDataKey.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2012 International Business Machines Corp.
- *
- * See the NOTICE file distributed with this work for additional information
- * regarding copyright ownership. Licensed under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-package com.ibm.jbatch.container.persistence;
-
-public class CheckpointDataKey {
-
- private long _jobInstanceId;
-
- // OK, this comes from IBM terminology, but I can't come up with a better name so we're leaving it.
- // "readerOrWriterName" ?
- private String _batchDataStreamName;
- private String _stepName;
-
- public CheckpointDataKey(long jobId, String stepName, String bdsName) {
- this._jobInstanceId = jobId;
- this._stepName = stepName;
- this._batchDataStreamName = bdsName;
- }
-
- public long getJobInstanceId() {
- return _jobInstanceId;
- }
-
- public String getBatchDataStreamName() {
- return _batchDataStreamName;
- }
-
- public String getStepName() {
- return _stepName;
- }
-
- public String getCommaSeparatedKey() {
- return stringify();
- }
-
- public String toString() {
- return stringify();
- }
-
- private String stringify() {
- return _jobInstanceId + "," + _stepName + "," + _batchDataStreamName;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/JSR352.Runtime/src/com/ibm/jbatch/container/persistence/CheckpointManager.java
----------------------------------------------------------------------
diff --git a/JSR352.Runtime/src/com/ibm/jbatch/container/persistence/CheckpointManager.java b/JSR352.Runtime/src/com/ibm/jbatch/container/persistence/CheckpointManager.java
deleted file mode 100755
index 90e678c..0000000
--- a/JSR352.Runtime/src/com/ibm/jbatch/container/persistence/CheckpointManager.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright 2012 International Business Machines Corp.
- *
- * See the NOTICE file distributed with this work for additional information
- * regarding copyright ownership. Licensed under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-package com.ibm.jbatch.container.persistence;
-
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectOutputStream;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.batch.api.chunk.CheckpointAlgorithm;
-
-import com.ibm.jbatch.container.artifact.proxy.ItemReaderProxy;
-import com.ibm.jbatch.container.artifact.proxy.ItemWriterProxy;
-import com.ibm.jbatch.container.exception.BatchContainerRuntimeException;
-import com.ibm.jbatch.container.exception.BatchContainerServiceException;
-import com.ibm.jbatch.container.services.IPersistenceManagerService;
-import com.ibm.jbatch.container.servicesmanager.ServicesManager;
-import com.ibm.jbatch.container.servicesmanager.ServicesManagerImpl;
-
-public class CheckpointManager {
- private final static String sourceClass = CheckpointManager.class.getName();
- private final static Logger logger = Logger.getLogger(sourceClass);
-
- private ServicesManager servicesManager = ServicesManagerImpl.getInstance();
- private IPersistenceManagerService _persistenceManagerService = null;
-
- private ItemReaderProxy readerProxy = null;
- private ItemWriterProxy writerProxy = null;
- int commitInterval = 0;
- private CheckpointAlgorithm checkpointAlgorithm;
- private boolean ckptStarted;
- private long executionId = 0;
- private String stepId = null;
- private long jobInstanceID = 0;
-
-
- public CheckpointManager(ItemReaderProxy reader, ItemWriterProxy writer,CheckpointAlgorithm chkptAlg,
- long executionId, long jobInstanceID, String stepId) {
- this.readerProxy = reader;
- this.writerProxy = writer;
- this.checkpointAlgorithm = chkptAlg;
- this.executionId = executionId;
- this.stepId = stepId;
- this.jobInstanceID = jobInstanceID;
-
- _persistenceManagerService = servicesManager.getPersistenceManagerService();
- }
-
- public void beginCheckpoint(int timeoutVal)
- {
- String method = "startCheckpoint";
- if(logger.isLoggable(Level.FINER)) { logger.entering(sourceClass, method);}
-
- ckptStarted = true;
-
- }
-
- public void beginCheckpoint()
- {
- String method = "beginCheckpoint";
- if(logger.isLoggable(Level.FINER)) { logger.entering(sourceClass, method);}
- if(logger.isLoggable(Level.FINE)) { logger.fine("executionId=" + executionId );}
- ckptStarted = true;
-
-
- }
-
-
- public boolean ApplyCheckPointPolicy(/*boolean forceCheckpoint*/)
- {
- String method = "ApplyCheckPointPolicy";
- if(logger.isLoggable(Level.FINER)) { logger.entering(sourceClass, method); }
-
- boolean checkpoint = false;
-
- try {
- checkpoint = checkpointAlgorithm.isReadyToCheckpoint();
- } catch (Exception e) {
- throw new BatchContainerRuntimeException("Checkpoint algorithm failed", e);
- }
-
- if (logger.isLoggable(Level.FINE) && checkpoint)
- logger.fine("ApplyCheckPointPolicy - " + checkpoint);
-
- if(logger.isLoggable(Level.FINER)) { logger.exiting(sourceClass, method);}
-
- return checkpoint;
- }
-
- public boolean isStarted()
- {
- return ckptStarted;
- }
-
-
- public void checkpoint()
- {
- String method = "checkpoint";
- if(logger.isLoggable(Level.FINER)) { logger.entering(sourceClass, method, " [executionId " + executionId + "] "); }
-
-
-
- ByteArrayOutputStream readerChkptBA = new ByteArrayOutputStream();
- ByteArrayOutputStream writerChkptBA = new ByteArrayOutputStream();
-
- ObjectOutputStream readerOOS = null, writerOOS = null;
- CheckpointDataKey readerChkptDK = null, writerChkptDK = null;
-
- try{
-
- readerOOS = new ObjectOutputStream(readerChkptBA);
- readerOOS.writeObject(readerProxy.checkpointInfo());
- readerOOS.close();
- CheckpointData readerChkptData = new CheckpointData(jobInstanceID, stepId, "READER");
- readerChkptData.setRestartToken(readerChkptBA.toByteArray());
- readerChkptDK = new CheckpointDataKey(jobInstanceID, stepId, "READER");
-
- _persistenceManagerService.updateCheckpointData(readerChkptDK, readerChkptData);
-
- writerOOS = new ObjectOutputStream(writerChkptBA);
- writerOOS.writeObject(writerProxy.checkpointInfo());
- writerOOS.close();
- CheckpointData writerChkptData = new CheckpointData(jobInstanceID, stepId, "WRITER");
- writerChkptData.setRestartToken(writerChkptBA.toByteArray());
- writerChkptDK = new CheckpointDataKey(jobInstanceID, stepId, "WRITER");
-
- _persistenceManagerService.updateCheckpointData(writerChkptDK, writerChkptData);
-
- }
- catch (Exception ex){
- // is this what I should be throwing here?
- throw new BatchContainerServiceException("Cannot persist the checkpoint data for [" + stepId + "]", ex);
- }
-
- if(logger.isLoggable(Level.FINER)) { logger.exiting(sourceClass, method, " [executionId " + executionId + "] ");}
-
- }
-
- public int checkpointTimeout() {
-
- int returnTimeout = 0;
-
- try {
- returnTimeout = this.checkpointAlgorithm.checkpointTimeout();
- } catch (Exception e) {
- throw new BatchContainerRuntimeException("Checkpoint algorithm checkpointTimeout() failed", e);
- }
-
- return returnTimeout;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/JSR352.Runtime/src/com/ibm/jbatch/container/persistence/ItemCheckpointAlgorithm.java
----------------------------------------------------------------------
diff --git a/JSR352.Runtime/src/com/ibm/jbatch/container/persistence/ItemCheckpointAlgorithm.java b/JSR352.Runtime/src/com/ibm/jbatch/container/persistence/ItemCheckpointAlgorithm.java
deleted file mode 100755
index 407fbcc..0000000
--- a/JSR352.Runtime/src/com/ibm/jbatch/container/persistence/ItemCheckpointAlgorithm.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * Copyright 2012 International Business Machines Corp.
- *
- * See the NOTICE file distributed with this work for additional information
- * regarding copyright ownership. Licensed under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-package com.ibm.jbatch.container.persistence;
-
-import java.util.Date;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.batch.api.chunk.CheckpointAlgorithm;
-
-public final class ItemCheckpointAlgorithm implements CheckpointAlgorithm {
-
- private static final String className = ItemCheckpointAlgorithm.class.getName();
- private static Logger logger = Logger.getLogger(ItemCheckpointAlgorithm.class.getPackage().getName());;
-
- CheckpointAlgorithm ichkp = null;
- boolean inCheckpoint = false;
- private static final int defaultRecordValue = 10;
- private static final int defaultTimeValue = 10;
- private static final int defaultTimeoutValue = 60;
- int threshold = defaultRecordValue;
- long requests = 0;
- int timeout = defaultTimeoutValue;
-
- java.util.Date date = null;
- long checkpointBeginTime = 0;
- int interval = 10; // 10 sec interval?
- long numTimes = 0;
-
- int time;
- int item;
-
- public ItemCheckpointAlgorithm(){
- date = new java.util.Date();
- checkpointBeginTime = date.getTime();
- logger.finer("ITEMTIME: in ctor, ts = " + checkpointBeginTime);
-
- }
-
- public void endCheckpoint() throws Exception {
- inCheckpoint = false;
- }
-
- public int getCheckpointTimeOut(int timeOut) throws Exception {
- return timeout;
- }
-
- public boolean isReadyToCheckpointItem() throws Exception {
- String method = "isReadyToCheckpoint";
- if(logger.isLoggable(Level.FINER)) { logger.entering(className, method); }
-
- requests++;
-
- boolean itemready = (requests >= item);
-
- if ( itemready) {
- logger.finer("ITEMTIMECHKPT: item checkpoint hit");
- long millis = Long.valueOf( (new Date().getTime()) - checkpointBeginTime );
- if ( millis>0 ) {
- String rate = Integer.valueOf ( Long.valueOf( (requests*1000/millis) ).intValue()).toString();
- if(logger.isLoggable(Level.FINE)) { logger.fine(" - true [requests/second " + rate + "]"); }
-
- } else {
- if(logger.isLoggable(Level.FINE)) { logger.fine(" - true [requests " + requests + "]"); }
-
- }
- }
-
- if ( itemready ) requests = 0;
-
- return itemready;
- }
-
- public boolean isReadyToCheckpointTime() throws Exception {
- String method = "isReadyToCheckpoint";
- if(logger.isLoggable(Level.FINER)) { logger.entering(className, method); }
-
- boolean timeready = false;
- numTimes++;
- java.util.Date curDate = new java.util.Date();
- long curts = curDate.getTime();
- long curdiff = curts - checkpointBeginTime;
- int diff = (int)curdiff / 1000;
-
- if (diff >= time) {
- logger.finer("ITEMTIMECHKPT: time checkpoint hit");
- timeready = true;
- if(logger.isLoggable(Level.FINER)) { logger.fine("Num of requests="+numTimes+" at a rate="+numTimes/diff+" req/sec");}
-
- numTimes = 0;
-
- date = new java.util.Date();
- checkpointBeginTime = date.getTime();
-
- }
-
-
- if(logger.isLoggable(Level.FINER)) { logger.exiting(className, method, timeready); }
-
- return timeready;
- }
-
- public void setThreshold(int INthreshHold){
- threshold = INthreshHold;
- }
-
- public boolean isReadyToCheckpoint() throws Exception {
-
- boolean ready = false;
-
- if (time == 0){ // no time limit, just check if item count has been reached
- if (isReadyToCheckpointItem()){
- ready = true;
- }
- } else if (isReadyToCheckpointItem() || isReadyToCheckpointTime()) {
- ready = true;
- }
-
- return ready;
- }
-
- public void setThresholds(int itemthreshold, int timethreshold) {
-
- item = itemthreshold;
- time = timethreshold;
-
- }
-
- @Override
- public void beginCheckpoint() throws Exception {
- checkpointBeginTime = date.getTime();
- }
-
- @Override
- public int checkpointTimeout() throws Exception {
- // TODO Auto-generated method stub
- return 0;
- }
-
-
-
- // Old Item only chkpt code
- /*
- private static final String className = ItemCheckpointAlgorithm.class.getName();
- private static Logger logger = Logger.getLogger(ItemCheckpointAlgorithm.class.getPackage().getName());;
-
- CheckpointAlgorithm ichkp = null;
- boolean inCheckpoint = false;
- private static final int defaultRecordValue = 10;
- private static final int defaultTimeoutValue = 60;
- int itemthreshold = defaultRecordValue;
- int timethreshold = 0; // default time threshold is 0
- long timeStarted = 0;
- long requests = 0;
- int timeout = defaultTimeoutValue;
-
- //@BeginCheckpoint
- public void beginCheckpoint() throws Exception {
- inCheckpoint = true;
- timeStarted = new Date().getTime();
- }
-
- //@EndCheckpoint
- public void endCheckpoint() throws Exception {
- inCheckpoint = false;
- }
-
- //@GetCheckpointTimeout
- public int getCheckpointTimeOut(int timeOut) throws Exception {
- return timeout;
- }
-
- //@IsReadyToCheckpoint
- public boolean isReadyToCheckpoint() throws Exception {
- String method = "ShouldCheckpointBeExecuted";
- if(logger.isLoggable(Level.FINER)) { logger.entering(className, method); }
-
- requests++;
-
- boolean ready = (requests >= itemthreshold);
-
- if ( ready) {
- long millis = Long.valueOf( (new Date().getTime()) - timeStarted );
- if ( millis>0 ) {
- String rate = Integer.valueOf ( Long.valueOf( (requests*1000/millis) ).intValue()).toString();
- if(logger.isLoggable(Level.FINE)) { logger.fine(" - true [requests/second " + rate + "]"); }
-
- } else {
- if(logger.isLoggable(Level.FINE)) { logger.fine(" - true [requests " + requests + "]"); }
-
- }
- }
-
- if ( ready ) requests = 0;
-
- return ready;
- }
-
- public void setThreshold(int INthreshHold){
- itemthreshold = INthreshHold;
- }
-
- //@Override
- public void setThresholds(int itemthreshold, int timethreshold) {
- this.itemthreshold = itemthreshold;
- }
-
- @Override
- public int checkpointTimeout(int timeout) throws Exception {
- this.timeout = timeout;
- return this.timeout;
- }
-*/
-}
http://git-wip-us.apache.org/repos/asf/incubator-batchee/blob/efa64877/JSR352.Runtime/src/com/ibm/jbatch/container/persistence/PersistentDataWrapper.java
----------------------------------------------------------------------
diff --git a/JSR352.Runtime/src/com/ibm/jbatch/container/persistence/PersistentDataWrapper.java b/JSR352.Runtime/src/com/ibm/jbatch/container/persistence/PersistentDataWrapper.java
deleted file mode 100755
index 493a1c3..0000000
--- a/JSR352.Runtime/src/com/ibm/jbatch/container/persistence/PersistentDataWrapper.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2012 International Business Machines Corp.
- *
- * See the NOTICE file distributed with this work for additional information
- * regarding copyright ownership. Licensed under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.ibm.jbatch.container.persistence;
-
-import java.io.Serializable;
-
-/**
- *
- */
-public class PersistentDataWrapper implements Serializable {
-
- private static final long serialVersionUID = 1L;
- private byte[] persistentDataBytes;
-
- public PersistentDataWrapper(byte[] persistentData) {
- this.persistentDataBytes = persistentData;
- }
-
- public byte[] getPersistentDataBytes() {
- return persistentDataBytes;
- }
-
-
-}