congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
Timeout.limit
Code IndexAdd Tabnine to your IDE (free)

How to use
limit
method
in
org.jenkinsci.plugins.workflow.support.concurrent.Timeout

Best Java code snippets using org.jenkinsci.plugins.workflow.support.concurrent.Timeout.limit (Showing top 8 results out of 315)

origin: org.jenkins-ci.plugins.workflow/workflow-durable-task-step

@Override public String getStatus() {
  StringBuilder b = new StringBuilder();
  try (Timeout timeout = Timeout.limit(2, TimeUnit.SECONDS)) { // CpsThreadDump applies a 3s timeout anyway
    FilePath workspace = getWorkspace();
    if (workspace != null) {
      b.append(controller.getDiagnostics(workspace, launcher()));
    } else {
      b.append("waiting to reconnect to ").append(remote).append(" on ").append(node);
    }
  } catch (IOException | InterruptedException x) {
    b.append("failed to look up workspace ").append(remote).append(" on ").append(node).append(": ").append(x);
  }
  b.append("; recurrence period: ").append(recurrencePeriod).append("ms");
  ScheduledFuture<?> t = task;
  if (t != null) {
    b.append("; check task scheduled; cancelled? ").append(t.isCancelled()).append(" done? ").append(t.isDone());
  }
  t = stopTask;
  if (t != null) {
    b.append("; stop task scheduled; cancelled? ").append(t.isCancelled()).append(" done? ").append(t.isDone());
  }
  return b.toString();
}
origin: org.jenkins-ci.plugins.workflow/workflow-durable-task-step

private @CheckForNull FilePath getWorkspace() throws AbortException {
  if (ws == null) {
    ws = FilePathUtils.find(node, remote);
    if (ws == null) {
      LOGGER.log(Level.FINE, "Jenkins is not running, no such node {0}, or it is offline", node);
      return null;
    }
  }
  boolean directory;
  try (Timeout timeout = Timeout.limit(10, TimeUnit.SECONDS)) {
    directory = ws.isDirectory();
  } catch (Exception x) {
    // RequestAbortedException, ChannelClosedException, EOFException, wrappers thereof; InterruptedException if it just takes too long.
    LOGGER.log(Level.FINE, node + " is evidently offline now", x);
    ws = null;
    if (!printedCannotContactMessage) {
      logger().println("Cannot contact " + node + ": " + x);
      printedCannotContactMessage = true;
    }
    return null;
  }
  if (!directory) {
    throw new AbortException("missing workspace " + remote + " on " + node);
  }
  return ws;
}
origin: jenkinsci/workflow-cps-plugin

@Restricted(DoNotUse.class)
@Terminator public static void suspendAll() {
  CpsFlowExecution exec = null;
  try (Timeout t = Timeout.limit(3, TimeUnit.MINUTES)) { // TODO some complicated sequence of calls to Futures could allow all of them to run in parallel
    LOGGER.fine("starting to suspend all executions");
    for (FlowExecution execution : FlowExecutionList.get()) {
origin: jenkinsci/throttle-concurrent-builds-plugin

@Nonnull
private List<String> categoriesForPipeline(Task task) {
  if (task instanceof PlaceholderTask) {
    PlaceholderTask placeholderTask = (PlaceholderTask)task;
    Run<?, ?> r = placeholderTask.run();
    if (r != null) {
      Map<String, List<String>> categoriesByFlowNode = ThrottleJobProperty.getCategoriesForRunByFlowNode(r);
      if (!categoriesByFlowNode.isEmpty()) {
        try (Timeout t = Timeout.limit(100, TimeUnit.MILLISECONDS)) {
          FlowNode firstThrottle = firstThrottleStartNode(placeholderTask.getNode());
          if (firstThrottle != null) {
            List<String> categories = categoriesByFlowNode.get(firstThrottle.getId());
            if (categories != null) {
              return categories;
            }
          }
        } catch (IOException | InterruptedException e) {
          LOGGER.log(Level.WARNING, "Error getting categories for pipeline {0}: {1}",
              new Object[] {task.getDisplayName(), e});
          return new ArrayList<>();
        }
      }
    }
  }
  return new ArrayList<>();
}
origin: org.jenkins-ci.plugins.workflow/workflow-durable-task-step

@Restricted(NoExternalUse.class) // for Jelly
public @CheckForNull String getEnclosingLabel() {
  if (!context.isReady()) {
    return null;
  }
  FlowNode executorStepNode;
  try (Timeout t = Timeout.limit(100, TimeUnit.MILLISECONDS)) {
    executorStepNode = context.get(FlowNode.class);
  } catch (Exception x) {
    LOGGER.log(Level.FINE, null, x);
    return null;
  }
  if (executorStepNode == null) {
    return null;
  }
  List<FlowNode> heads = executorStepNode.getExecution().getCurrentHeads();
  int headsHash = heads.hashCode(); // deterministic based on IDs of those heads
  if (headsHash == lastCheckedHashCode) {
    return lastEnclosingLabel;
  } else {
    lastCheckedHashCode = headsHash;
    return lastEnclosingLabel = computeEnclosingLabel(executorStepNode, heads);
  }
}
private String computeEnclosingLabel(FlowNode executorStepNode, List<FlowNode> heads) {
origin: jenkinsci/workflow-cps-plugin

CURRENT.set(this);
try (Timeout timeout = Timeout.limit(5, TimeUnit.MINUTES)) {
  LOGGER.log(FINE, "runNextChunk on {0}", resumeValue);
  final Outcome o = resumeValue;
origin: jenkinsci/workflow-cps-plugin

/**
 * Stops the execution of this thread. If it's paused to wait for the completion of {@link StepExecution},
 * call {@link StepExecution#stop(Throwable)} to give it a chance to clean up.
 *
 * <p>
 * If the execution is not inside a step (meaning it's paused in a safe point), then have the CPS thread
 * throw a given {@link Throwable} to break asap.
 */
@CpsVmThreadOnly
public void stop(Throwable t) {
  StepExecution s = getStep();  // this is the part that should run in CpsVmThread
  if (s == null) {
    // if it's not running inside a StepExecution, we need to set an interrupt flag
    // and interrupt at an earliest convenience
    Outcome o = new Outcome(null, t);
    if (resumeValue==null) {
      resume(o);
    } else {
      // this thread was already resumed, so just overwrite the value with a Throwable
      resumeValue = o;
    }
    return;
  }
  try (Timeout timeout = Timeout.limit(30, TimeUnit.SECONDS)) {
    s.stop(t);
  } catch (Exception e) {
    t.addSuppressed(e);
    s.getContext().onFailure(t);
  }
}
origin: org.jenkins-ci.plugins.workflow/workflow-durable-task-step

  return; // slave not yet ready, wait for another day
try (Timeout timeout = Timeout.limit(10, TimeUnit.SECONDS)) {
      if (controller.writeLog(workspace, logger())) {
        getContext().saveState();
org.jenkinsci.plugins.workflow.support.concurrentTimeoutlimit

Popular methods of Timeout

    Popular in Java

    • Creating JSON documents from java classes using gson
    • getExternalFilesDir (Context)
    • getSystemService (Context)
    • onRequestPermissionsResult (Fragment)
    • PrintWriter (java.io)
      Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
    • Selector (java.nio.channels)
      A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
    • Enumeration (java.util)
      A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
    • Scanner (java.util)
      A parser that parses a text string of primitive types and strings with the help of regular expressio
    • SortedMap (java.util)
      A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
    • Table (org.hibernate.mapping)
      A relational table
    • Top 25 Plugins for Webstorm
    Tabnine Logo
    • Products

      Search for Java codeSearch for JavaScript code
    • IDE Plugins

      IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
    • Company

      About UsContact UsCareers
    • Resources

      FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
    Get Tabnine for your IDE now