Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BATCHEE-112 persistence service doesnt support multiple execution for…
… getRunningExecution case of JobOperator when set to memory (default)
- Loading branch information
1 parent
a69bd38
commit a0ca7ae
Showing
6 changed files
with
112 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
jbatch/src/test/java/org/apache/batchee/component/SimpleBatchlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* 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 org.apache.batchee.component; | ||
|
||
import javax.batch.api.AbstractBatchlet; | ||
import javax.batch.api.BatchProperty; | ||
import javax.inject.Inject; | ||
|
||
import static java.lang.Thread.sleep; | ||
|
||
public class SimpleBatchlet extends AbstractBatchlet { | ||
@Inject | ||
@BatchProperty | ||
private Long duration; | ||
|
||
@Override | ||
public String process() throws Exception { | ||
if (duration != null && duration > 0) { | ||
sleep(duration); | ||
} | ||
return "ok"; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
jbatch/src/test/java/org/apache/batchee/container/impl/JobOperatorImplTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* 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 org.apache.batchee.container.impl; | ||
|
||
import org.apache.batchee.container.services.ServicesManager; | ||
import org.apache.batchee.container.services.persistence.MemoryPersistenceManagerService; | ||
import org.apache.batchee.spi.PersistenceManagerService; | ||
import org.junit.Test; | ||
|
||
import javax.batch.operations.JobOperator; | ||
import java.util.List; | ||
import java.util.Properties; | ||
|
||
import static java.util.Collections.singletonList; | ||
import static org.apache.batchee.util.Batches.waitForEnd; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
public class JobOperatorImplTest { | ||
@Test | ||
public void runningExecutionMemory_BATCHEE112() { | ||
final JobOperator operator = new JobOperatorImpl(new ServicesManager() {{ | ||
init(new Properties() {{ | ||
setProperty(PersistenceManagerService.class.getSimpleName(), MemoryPersistenceManagerService.class.getName()); | ||
}}); | ||
}}); | ||
for (int i = 0; i < 10; i++) { | ||
final long id = operator.start("simple", new Properties() {{ | ||
setProperty("duration", "3000"); | ||
}}); | ||
final List<Long> running = operator.getRunningExecutions("simple"); | ||
assertEquals("Iteration: " + i, singletonList(id), running); | ||
waitForEnd(operator, id); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- 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. --> | ||
<job id="simple" version="1.0" xmlns="http://xmlns.jcp.org/xml/ns/javaee"> | ||
<step id="exec"> | ||
<batchlet ref="org.apache.batchee.component.SimpleBatchlet" /> | ||
</step> | ||
</job> |