Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WFLY-4478] Stop running batch jobs when a shutdown is issued for the…
… container. This ensures the container won't wait to shutdown until the batch jobs are fully completed.
- Loading branch information
Showing
29 changed files
with
846 additions
and
199 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
53 changes: 53 additions & 0 deletions
53
...tension-jberet/src/main/java/org/wildfly/extension/batch/jberet/AttributeMarshallers.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,53 @@ | |||
/* | |||
* Copyright 2015 Red Hat, Inc. | |||
* | |||
* 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.wildfly.extension.batch.jberet; | |||
|
|||
import javax.xml.stream.XMLStreamException; | |||
import javax.xml.stream.XMLStreamWriter; | |||
|
|||
import org.jboss.as.controller.AttributeDefinition; | |||
import org.jboss.as.controller.AttributeMarshaller; | |||
import org.jboss.dmr.ModelNode; | |||
|
|||
/** | |||
* @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a> | |||
*/ | |||
class AttributeMarshallers { | |||
public static final AttributeMarshaller NAMED = new AttributeMarshaller() { | |||
|
|||
@Override | |||
public void marshallAsElement(final AttributeDefinition attribute, final ModelNode resourceModel, final boolean marshallDefault, final XMLStreamWriter writer) throws XMLStreamException { | |||
if (resourceModel.hasDefined(attribute.getName())) { | |||
writer.writeStartElement(attribute.getName()); | |||
writer.writeAttribute(Attribute.NAME.getLocalName(), resourceModel.get(attribute.getName()).asString()); | |||
writer.writeEndElement(); | |||
} | |||
} | |||
}; | |||
|
|||
public static final AttributeMarshaller VALUE = new AttributeMarshaller() { | |||
|
|||
@Override | |||
public void marshallAsElement(final AttributeDefinition attribute, final ModelNode resourceModel, final boolean marshallDefault, final XMLStreamWriter writer) throws XMLStreamException { | |||
if (resourceModel.hasDefined(attribute.getName())) { | |||
writer.writeStartElement(attribute.getName()); | |||
writer.writeAttribute(Attribute.VALUE.getLocalName(), resourceModel.get(attribute.getName()).asString()); | |||
writer.writeEndElement(); | |||
} | |||
} | |||
}; | |||
} |
50 changes: 50 additions & 0 deletions
50
...extension-jberet/src/main/java/org/wildfly/extension/batch/jberet/BatchConfiguration.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,50 @@ | |||
/* | |||
* Copyright 2015 Red Hat, Inc. | |||
* | |||
* 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.wildfly.extension.batch.jberet; | |||
|
|||
import org.jberet.repository.JobRepository; | |||
import org.jberet.spi.JobExecutor; | |||
|
|||
/** | |||
* A configuration for the {@link org.jberet.spi.BatchEnvironment} behavior. | |||
* | |||
* @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a> | |||
*/ | |||
public interface BatchConfiguration { | |||
|
|||
/** | |||
* Indicates whether or no batch jobs should be restarted on a resume operation if they were stopped during a | |||
* suspend. | |||
* | |||
* @return {@code true} to restart jobs on resume otherwise {@code false} to leave the jobs in a stopped state | |||
*/ | |||
boolean isRestartOnResume(); | |||
|
|||
/** | |||
* Returns the default job repository to use. | |||
* | |||
* @return the default job repository | |||
*/ | |||
JobRepository getDefaultJobRepository(); | |||
|
|||
/** | |||
* Returns the default job executor to use. | |||
* | |||
* @return the default job executor | |||
*/ | |||
JobExecutor getDefaultJobExecutor(); | |||
} |
77 changes: 77 additions & 0 deletions
77
...on-jberet/src/main/java/org/wildfly/extension/batch/jberet/BatchConfigurationService.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,77 @@ | |||
/* | |||
* Copyright 2015 Red Hat, Inc. | |||
* | |||
* 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.wildfly.extension.batch.jberet; | |||
|
|||
import org.jberet.repository.JobRepository; | |||
import org.jberet.spi.JobExecutor; | |||
import org.jboss.msc.service.Service; | |||
import org.jboss.msc.service.StartContext; | |||
import org.jboss.msc.service.StartException; | |||
import org.jboss.msc.service.StopContext; | |||
import org.jboss.msc.value.InjectedValue; | |||
|
|||
/** | |||
* A default batch configuration service. | |||
* | |||
* @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a> | |||
*/ | |||
class BatchConfigurationService implements BatchConfiguration, Service<BatchConfiguration> { | |||
|
|||
private final InjectedValue<JobRepository> jobRepositoryInjector = new InjectedValue<>(); | |||
private final InjectedValue<JobExecutor> jobExecutorInjector = new InjectedValue<>(); | |||
private volatile boolean restartOnResume; | |||
|
|||
@Override | |||
public boolean isRestartOnResume() { | |||
return restartOnResume; | |||
} | |||
|
|||
protected void setRestartOnResume(final boolean restartOnResume) { | |||
this.restartOnResume = restartOnResume; | |||
} | |||
|
|||
@Override | |||
public JobRepository getDefaultJobRepository() { | |||
return jobRepositoryInjector.getValue(); | |||
} | |||
|
|||
@Override | |||
public JobExecutor getDefaultJobExecutor() { | |||
return jobExecutorInjector.getValue(); | |||
} | |||
|
|||
@Override | |||
public void start(final StartContext context) throws StartException { | |||
} | |||
|
|||
@Override | |||
public void stop(final StopContext context) { | |||
} | |||
|
|||
@Override | |||
public BatchConfiguration getValue() throws IllegalStateException, IllegalArgumentException { | |||
return this; | |||
} | |||
|
|||
protected InjectedValue<JobRepository> getJobRepositoryInjector() { | |||
return jobRepositoryInjector; | |||
} | |||
|
|||
protected InjectedValue<JobExecutor> getJobExecutorInjector() { | |||
return jobExecutorInjector; | |||
} | |||
} |
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
Oops, something went wrong.