jenkins.model.Jenkins.getInitLevel()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(9.6k)|赞(0)|评价(0)|浏览(111)

本文整理了Java中jenkins.model.Jenkins.getInitLevel()方法的一些代码示例,展示了Jenkins.getInitLevel()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jenkins.getInitLevel()方法的具体详情如下:
包路径:jenkins.model.Jenkins
类名称:Jenkins
方法名:getInitLevel

Jenkins.getInitLevel介绍

[英]Gets the initialization milestone that we've already reached.
[中]获取我们已经达到的初始化里程碑。

代码示例

代码示例来源:origin: jenkinsci/jenkins

@Override
  public boolean isActivated() {
    final Jenkins instance = Jenkins.getInstance();
    // Safe to check in such way, because monitors are being checked in UI only.
    // So Jenkins class construction and initialization must be always finished by the call of this extension.
    return instance.getInitLevel() != InitMilestone.COMPLETED;
  }
}

代码示例来源:origin: jenkinsci/jenkins

private List<ExtensionComponent<T>> ensureLoaded() {
  if(extensions!=null)
    return extensions; // already loaded
  if (jenkins.getInitLevel().compareTo(InitMilestone.PLUGINS_PREPARED)<0)
    return legacyInstances; // can't perform the auto discovery until all plugins are loaded, so just make the legacy instances visible
  synchronized (getLoadLock()) {
    if(extensions==null) {
      List<ExtensionComponent<T>> r = load();
      r.addAll(legacyInstances);
      extensions = sort(r);
    }
    return extensions;
  }
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * During Jenkins start-up, before {@link InitMilestone#PLUGINS_STARTED} the extensions lists will be empty
 * and they are not guaranteed to be fully populated until after {@link InitMilestone#EXTENSIONS_AUGMENTED},
 * similarly, during termination after {@link Jenkins#isTerminating()} is set, it is no longer safe to access
 * the extensions lists.
 * If you attempt to access the extensions list from a UI thread while the extensions are being loaded you will
 * hit a big honking great monitor lock that will block until the effective extension list has been determined
 * (as if a plugin fails to start, all of the failed plugin's extensions and any dependent plugins' extensions
 * will have to be evicted from the list of extensions. In practical terms this only affects the
 * "Jenkins is loading" screen, but as that screen uses the generic layouts we provide this utility method
 * so that the generic layouts can avoid iterating extension lists while Jenkins is starting up.
 * If you attempt to access the extensions list from a UI thread while Jenkins is being shut down, the extensions
 * themselves may no longer be in a valid state and could attempt to revive themselves and block termination.
 * In actual terms the termination only affects those views required to render {@link HudsonIsRestarting}'s
 * {@code index.jelly} which is the same set as the {@link HudsonIsLoading} pages so it makes sense to
 * use both checks here.
 *
 * @return {@code true} if the extensions lists have been populated.
 * @since 1.607
 */
public static boolean isExtensionsAvailable() {
  final Jenkins jenkins = Jenkins.getInstanceOrNull();
  return jenkins != null && jenkins.getInitLevel().compareTo(InitMilestone.EXTENSIONS_AUGMENTED) >= 0
      && !jenkins.isTerminating();
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

@Override
  public boolean isActivated() {
    final Jenkins instance = Jenkins.getInstance();
    // Safe to check in such way, because monitors are being checked in UI only.
    // So Jenkins class construction and initialization must be always finished by the call of this extension.
    return instance.getInitLevel() != InitMilestone.COMPLETED;
  }
}

代码示例来源:origin: org.jenkins-ci.plugins/github-branch-source

@Override
public void close() throws IOException {
  if (fullScanRequested && iterationCompleted) {
    // we needed a full scan and the scan was completed, so trim the cache entries
    pullRequestMetadataCache.keySet().retainAll(pullRequestMetadataKeys);
    pullRequestContributorCache.keySet().retainAll(pullRequestMetadataKeys);
    if (Jenkins.getActiveInstance().getInitLevel().compareTo(InitMilestone.JOB_LOADED) > 0) {
      // synchronization should be cheap as only writers would be looking for this just to
      // write null
      synchronized (pullRequestSourceMapLock) {
        pullRequestSourceMap = null; // all data has to have been migrated
      }
    }
  }
}

代码示例来源:origin: jenkinsci/dockerhub-notification-plugin

/**
 * Gets the effective singleton instance.
 *
 * @return the effective singleton instance.
 * @throws AssertionError if the singleton is missing, i.e. not running on a Jenkins master.
 */
@Nonnull
public static TriggerStore getInstance() {
  Jenkins instance = Jenkins.getInstance();
  TriggerStore d;
  if (instance == null) {
    d = null;
  } else if (instance.getInitLevel().compareTo(InitMilestone.JOB_LOADED) < 0) {
    throw new AssertionError(TriggerStore.class.getName() + " is not available until after all jobs are loaded");
  } else {
    d = instance.getDescriptorByType(TriggerStore.class);
  }
  if (d == null) {
    throw new AssertionError(TriggerStore.class.getName() + " is missing");
  }
  return d;
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

private List<ExtensionComponent<T>> ensureLoaded() {
  if(extensions!=null)
    return extensions; // already loaded
  if (jenkins.getInitLevel().compareTo(InitMilestone.PLUGINS_PREPARED)<0)
    return legacyInstances; // can't perform the auto discovery until all plugins are loaded, so just make the legacy instances visible
  synchronized (getLoadLock()) {
    if(extensions==null) {
      List<ExtensionComponent<T>> r = load();
      r.addAll(legacyInstances);
      extensions = sort(r);
    }
    return extensions;
  }
}

代码示例来源:origin: jenkinsci/jobConfigHistory-plugin

/**
   * Return the helper, making sure its anonymous while Jenkins is still
   * initializing.
   * 
   * @return helper
   */
  HistoryDao getHistoryDao(JobConfigHistory plugin) {
    Jenkins jenkins = Jenkins.getInstance();
    if(jenkins == null)
      return null;
    return (COMPLETED == jenkins.getInitLevel())
        ? PluginUtils.getHistoryDao(plugin)
        : PluginUtils.getAnonymousHistoryDao(plugin);
  }
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

/**
 * During Jenkins start-up, before {@link InitMilestone#PLUGINS_STARTED} the extensions lists will be empty
 * and they are not guaranteed to be fully populated until after {@link InitMilestone#EXTENSIONS_AUGMENTED},
 * similarly, during termination after {@link Jenkins#isTerminating()} is set, it is no longer safe to access
 * the extensions lists.
 * If you attempt to access the extensions list from a UI thread while the extensions are being loaded you will
 * hit a big honking great monitor lock that will block until the effective extension list has been determined
 * (as if a plugin fails to start, all of the failed plugin's extensions and any dependent plugins' extensions
 * will have to be evicted from the list of extensions. In practical terms this only affects the
 * "Jenkins is loading" screen, but as that screen uses the generic layouts we provide this utility method
 * so that the generic layouts can avoid iterating extension lists while Jenkins is starting up.
 * If you attempt to access the extensions list from a UI thread while Jenkins is being shut down, the extensions
 * themselves may no longer be in a valid state and could attempt to revive themselves and block termination.
 * In actual terms the termination only affects those views required to render {@link HudsonIsRestarting}'s
 * {@code index.jelly} which is the same set as the {@link HudsonIsLoading} pages so it makes sense to
 * use both checks here.
 *
 * @return {@code true} if the extensions lists have been populated.
 * @since 1.607
 */
public static boolean isExtensionsAvailable() {
  final Jenkins jenkins = Jenkins.getInstanceOrNull();
  return jenkins != null && jenkins.getInitLevel().compareTo(InitMilestone.EXTENSIONS_AUGMENTED) >= 0
      && !jenkins.isTerminating();
}

代码示例来源:origin: io.jenkins.jenkinsfile-runner/setup

if (jenkins.getInitLevel() != InitMilestone.COMPLETED) {
  throw new Exception("Jenkins initialization has not reached the COMPLETED initialization stage. Current state is " + jenkins.getInitLevel() +
      ". Likely there is an issue with the Initialization task graph (e.g. usage of @Initializer(after = InitMilestone.COMPLETED)). See JENKINS-37759 for more info");

代码示例来源:origin: jenkinsci/jenkinsfile-runner

if (jenkins.getInitLevel() != InitMilestone.COMPLETED) {
  throw new Exception("Jenkins initialization has not reached the COMPLETED initialization stage. Current state is " + jenkins.getInitLevel() +
      ". Likely there is an issue with the Initialization task graph (e.g. usage of @Initializer(after = InitMilestone.COMPLETED)). See JENKINS-37759 for more info");

代码示例来源:origin: jenkinsci/ec2-plugin

/**
 * Called when a new {@link EC2Computer} object is introduced (such as when Hudson started, or when
 * a new agent is added.)
 *
 * When Jenkins has just started, we don't want to spin up all the instances, so we only start if
 * the EC2 instance is already running
 */
@Override
public void start(EC2Computer c) {
  //Jenkins is in the process of starting up
  if (Jenkins.getInstance().getInitLevel() != InitMilestone.COMPLETED) {
    InstanceState state = null;
    try {
      state = c.getState();
    } catch (AmazonClientException | InterruptedException | NullPointerException e) {
      LOGGER.log(Level.FINE, "Error getting EC2 instance state for " + c.getName(), e);
    }
    if (!(InstanceState.PENDING.equals(state) || InstanceState.RUNNING.equals(state))) {
      LOGGER.info("Ignoring start request for " + c.getName()
          + " during Jenkins startup due to EC2 instance state of " + state);
      return;
      }
  }
  LOGGER.info("Start requested for " + c.getName());
  c.connect(false);
}

代码示例来源:origin: org.jenkins-ci.plugins/credentials

SecurityContext ctx = ACL.impersonate(ACL.SYSTEM);
try {
  if (jenkins.getInitLevel().compareTo(InitMilestone.JOB_LOADED) < 0) {
    LOGGER.log(Level.INFO, "Forced save credentials stores: Initialization has not completed");
    while (jenkins.getInitLevel().compareTo(InitMilestone.JOB_LOADED) < 0) {
      LOGGER.log(Level.INFO, "Forced save credentials stores: Sleeping for 1 second");
      try {

代码示例来源:origin: jenkinsci/credentials-plugin

SecurityContext ctx = ACL.impersonate(ACL.SYSTEM);
try {
  if (jenkins.getInitLevel().compareTo(InitMilestone.JOB_LOADED) < 0) {
    LOGGER.log(Level.INFO, "Forced save credentials stores: Initialization has not completed");
    while (jenkins.getInitLevel().compareTo(InitMilestone.JOB_LOADED) < 0) {
      LOGGER.log(Level.INFO, "Forced save credentials stores: Sleeping for 1 second");
      try {

代码示例来源:origin: jenkinsci/jenkins-test-harness

if (jenkins.getInitLevel() != InitMilestone.COMPLETED) {
  throw new Exception("Jenkins initialization has not reached the COMPLETED initialization stage. Current state is " + jenkins.getInitLevel() +
      ". Likely there is an issue with the Initialization task graph (e.g. usage of @Initializer(after = InitMilestone.COMPLETED)). See JENKINS-37759 for more info");

相关文章

微信公众号

最新文章

更多

Jenkins类方法