Skip to content
Snippets Groups Projects
Commit da675420 authored by Christian Wulf's avatar Christian Wulf
Browse files

formatting;

added runNow for testing purposes
parent 0ddb7c2d
No related branches found
No related tags found
No related merge requests found
...@@ -40,7 +40,9 @@ abstract class AbstractRunnableStage implements Runnable { ...@@ -40,7 +40,9 @@ abstract class AbstractRunnableStage implements Runnable {
@Override @Override
public final void run() { public final void run() {
final Stage stage = this.stage; // should prevent the stage to be reloaded after a volatile read final Stage stage = this.stage; // should prevent the stage to be reloaded after a volatile read
this.logger.debug("Executing runnable stage..."); final Logger logger = this.logger; // should prevent the logger to be reloaded after a volatile read
logger.debug("Executing runnable stage...");
try { try {
try { try {
...@@ -53,17 +55,17 @@ abstract class AbstractRunnableStage implements Runnable { ...@@ -53,17 +55,17 @@ abstract class AbstractRunnableStage implements Runnable {
executeStage(); executeStage();
} }
} catch (TerminateException e) { } catch (TerminateException e) {
this.stage.abort(); stage.abort();
stage.getOwningContext().abortConfigurationRun(); stage.getOwningContext().abortConfigurationRun();
} finally { } finally {
afterStageExecution(); afterStageExecution();
} }
} catch (RuntimeException e) { } catch (RuntimeException e) {
this.logger.error(TERMINATING_THREAD_DUE_TO_THE_FOLLOWING_EXCEPTION, e); logger.error(TERMINATING_THREAD_DUE_TO_THE_FOLLOWING_EXCEPTION, e);
throw e; throw e;
} catch (InterruptedException e) { } catch (InterruptedException e) {
this.logger.error(TERMINATING_THREAD_DUE_TO_THE_FOLLOWING_EXCEPTION, e); logger.error(TERMINATING_THREAD_DUE_TO_THE_FOLLOWING_EXCEPTION, e);
} }
} finally { } finally {
if (stage.getTerminationStrategy() != TerminationStrategy.BY_INTERRUPT) { if (stage.getTerminationStrategy() != TerminationStrategy.BY_INTERRUPT) {
...@@ -71,8 +73,9 @@ abstract class AbstractRunnableStage implements Runnable { ...@@ -71,8 +73,9 @@ abstract class AbstractRunnableStage implements Runnable {
} }
} }
logger.debug("Finished runnable stage. (" + stage.getId() + ")"); if (logger.isDebugEnabled()) {
logger.debug("Finished runnable stage. (" + stage.getId() + ")");
}
} }
protected abstract void beforeStageExecution() throws InterruptedException; protected abstract void beforeStageExecution() throws InterruptedException;
......
...@@ -53,4 +53,9 @@ public class RunnableProducerStage extends AbstractRunnableStage { ...@@ -53,4 +53,9 @@ public class RunnableProducerStage extends AbstractRunnableStage {
logger.trace("waitForStartingSignal"); logger.trace("waitForStartingSignal");
startSemaphore.acquire(); startSemaphore.acquire();
} }
void runNow() {
triggerStartingSignal();
super.run();
}
} }
/**
* Copyright (C) 2015 Christian Wulf, Nelson Tavares de Sousa (http://christianwulf.github.io/teetime)
*
* 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 teetime.util.framework.concurrent.queue.takestrategy; package teetime.util.framework.concurrent.queue.takestrategy;
import java.util.Queue; import java.util.Queue;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment