Skip to content
Draft
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
@@ -0,0 +1,59 @@
package com.chikli.hudson.plugin.naginator;

import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.Extension;
import hudson.model.AbstractBuild;
import org.kohsuke.stapler.DataBoundConstructor;
import static java.lang.Math.min;

/**
* Need to make a fork.
* Expontential delay
* @author <a href="mailto:[email protected]">Daniel Alfonsetti</a>
*/
public class ExponentialDelay extends ScheduleDelay {

private int backoffBase;
private int max;

@DataBoundConstructor
public ExponentialDelay(int backoff_base, int max) {
this.backoffBase = backoff_base;
this.max = max;
}

public int getBackoffBase() {
return backoffBase;
}

public int getMax() {
return max;
}

// number of seconds.
@Override
public int computeScheduleDelay(AbstractBuild failedBuild) {
// int n = getRetryCount(failedBuild);
// // int delay = (int) Math.pow(this.backoffBase, n);
// int delay = 50+n;
// return max <= 0 ? delay : min(delay, max);
return 1;
}

private int getRetryCount(AbstractBuild<?, ?> failedBuild) {
NaginatorAction action = failedBuild.getAction(NaginatorAction.class);
if (action == null) {
return 0;
}
return action.getRetryCount();
}

@Extension
public static class DescriptorImpl extends ScheduleDelayDescriptor {
@NonNull
@Override
public String getDisplayName() {
return "Exponential";
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form">
<f:entry title="backoff_base" field="backoff_base">
<f:textbox />
</f:entry>
<f:entry title="max" field="max">
<f:textbox />
</f:entry>
</j:jelly>
Loading