Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static String varPath(String executionId) {

private boolean debug = false;

private boolean locking = true;
private boolean skipped = false;

private final Inputs inputs;

Expand Down Expand Up @@ -143,12 +143,12 @@ public void setDebug(boolean debug) {
this.debug = debug;
}

public boolean isLocking() {
return locking;
public boolean isSkipped() {
return skipped;
}

public void setLocking(boolean locking) {
this.locking = locking;
public void setSkipped(boolean skipped) {
this.skipped = skipped;
}

public Inputs getInputs() {
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/dev/vml/es/acm/core/code/ExecutionId.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

public final class ExecutionId {

public static final String HEALTH_CHECK = "health-check";

private ExecutionId() {
// intentionally empty
}
Expand Down
12 changes: 9 additions & 3 deletions core/src/main/java/dev/vml/es/acm/core/code/Executor.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ public Execution execute(ExecutionContext context) throws AcmException {
private ContextualExecution executeInternal(ExecutionContext context) {
ContextualExecution.Builder execution = new ContextualExecution.Builder(context).start();

boolean healthChecking = ExecutionId.HEALTH_CHECK.equals(context.getId());
if ((!healthChecking && context.isSkipped())) {
return execution.end(ExecutionStatus.SKIPPED);
}

try {
statuses.put(context.getId(), ExecutionStatus.PARSING);

Expand All @@ -204,13 +209,14 @@ private ContextualExecution executeInternal(ExecutionContext context) {
return execution.end(ExecutionStatus.SUCCEEDED);
}

boolean locking = !healthChecking;
String lockName = executableLockName(context);
if (context.isLocking() && queryLocker(resolverFactory, l -> l.isLocked(lockName))) {
if (locking && queryLocker(resolverFactory, l -> l.isLocked(lockName))) {
return execution.end(ExecutionStatus.SKIPPED);
}

try {
if (context.isLocking()) {
if (locking) {
useLocker(resolverFactory, l -> l.lock(lockName));
}
statuses.put(context.getId(), ExecutionStatus.RUNNING);
Expand All @@ -222,7 +228,7 @@ private ContextualExecution executeInternal(ExecutionContext context) {
contentScript.run();
return execution.end(ExecutionStatus.SUCCEEDED);
} finally {
if (context.isLocking()) {
if (locking) {
useLocker(resolverFactory, l -> l.unlock(lockName));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,15 +243,14 @@ private void checkComponents(List<HealthIssue> issues) {

private void checkCodeExecutor(List<HealthIssue> issues, ResourceResolver resourceResolver) {
try (ExecutionContext context = executor.createContext(
ExecutionId.generate(),
ExecutionId.HEALTH_CHECK,
resourceResolver.getUserID(),
ExecutionMode.RUN,
Code.consoleMinimal(),
new InputValues(),
resourceResolver,
new CodeOutputMemory())) {
context.setHistory(false);
context.setLocking(false);

Execution execution = executor.execute(context);
if (execution.getStatus() != ExecutionStatus.SUCCEEDED) {
Expand Down