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

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

本文整理了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

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

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

  1. private List<ExtensionComponent<T>> ensureLoaded() {
  2. if(extensions!=null)
  3. return extensions; // already loaded
  4. if (jenkins.getInitLevel().compareTo(InitMilestone.PLUGINS_PREPARED)<0)
  5. return legacyInstances; // can't perform the auto discovery until all plugins are loaded, so just make the legacy instances visible
  6. synchronized (getLoadLock()) {
  7. if(extensions==null) {
  8. List<ExtensionComponent<T>> r = load();
  9. r.addAll(legacyInstances);
  10. extensions = sort(r);
  11. }
  12. return extensions;
  13. }
  14. }

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

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

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

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

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

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

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

  1. /**
  2. * Gets the effective singleton instance.
  3. *
  4. * @return the effective singleton instance.
  5. * @throws AssertionError if the singleton is missing, i.e. not running on a Jenkins master.
  6. */
  7. @Nonnull
  8. public static TriggerStore getInstance() {
  9. Jenkins instance = Jenkins.getInstance();
  10. TriggerStore d;
  11. if (instance == null) {
  12. d = null;
  13. } else if (instance.getInitLevel().compareTo(InitMilestone.JOB_LOADED) < 0) {
  14. throw new AssertionError(TriggerStore.class.getName() + " is not available until after all jobs are loaded");
  15. } else {
  16. d = instance.getDescriptorByType(TriggerStore.class);
  17. }
  18. if (d == null) {
  19. throw new AssertionError(TriggerStore.class.getName() + " is missing");
  20. }
  21. return d;
  22. }

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

  1. private List<ExtensionComponent<T>> ensureLoaded() {
  2. if(extensions!=null)
  3. return extensions; // already loaded
  4. if (jenkins.getInitLevel().compareTo(InitMilestone.PLUGINS_PREPARED)<0)
  5. return legacyInstances; // can't perform the auto discovery until all plugins are loaded, so just make the legacy instances visible
  6. synchronized (getLoadLock()) {
  7. if(extensions==null) {
  8. List<ExtensionComponent<T>> r = load();
  9. r.addAll(legacyInstances);
  10. extensions = sort(r);
  11. }
  12. return extensions;
  13. }
  14. }

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

  1. /**
  2. * Return the helper, making sure its anonymous while Jenkins is still
  3. * initializing.
  4. *
  5. * @return helper
  6. */
  7. HistoryDao getHistoryDao(JobConfigHistory plugin) {
  8. Jenkins jenkins = Jenkins.getInstance();
  9. if(jenkins == null)
  10. return null;
  11. return (COMPLETED == jenkins.getInitLevel())
  12. ? PluginUtils.getHistoryDao(plugin)
  13. : PluginUtils.getAnonymousHistoryDao(plugin);
  14. }
  15. }

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

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

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

  1. if (jenkins.getInitLevel() != InitMilestone.COMPLETED) {
  2. throw new Exception("Jenkins initialization has not reached the COMPLETED initialization stage. Current state is " + jenkins.getInitLevel() +
  3. ". 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

  1. if (jenkins.getInitLevel() != InitMilestone.COMPLETED) {
  2. throw new Exception("Jenkins initialization has not reached the COMPLETED initialization stage. Current state is " + jenkins.getInitLevel() +
  3. ". 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

  1. /**
  2. * Called when a new {@link EC2Computer} object is introduced (such as when Hudson started, or when
  3. * a new agent is added.)
  4. *
  5. * When Jenkins has just started, we don't want to spin up all the instances, so we only start if
  6. * the EC2 instance is already running
  7. */
  8. @Override
  9. public void start(EC2Computer c) {
  10. //Jenkins is in the process of starting up
  11. if (Jenkins.getInstance().getInitLevel() != InitMilestone.COMPLETED) {
  12. InstanceState state = null;
  13. try {
  14. state = c.getState();
  15. } catch (AmazonClientException | InterruptedException | NullPointerException e) {
  16. LOGGER.log(Level.FINE, "Error getting EC2 instance state for " + c.getName(), e);
  17. }
  18. if (!(InstanceState.PENDING.equals(state) || InstanceState.RUNNING.equals(state))) {
  19. LOGGER.info("Ignoring start request for " + c.getName()
  20. + " during Jenkins startup due to EC2 instance state of " + state);
  21. return;
  22. }
  23. }
  24. LOGGER.info("Start requested for " + c.getName());
  25. c.connect(false);
  26. }

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

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

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

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

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

  1. if (jenkins.getInitLevel() != InitMilestone.COMPLETED) {
  2. throw new Exception("Jenkins initialization has not reached the COMPLETED initialization stage. Current state is " + jenkins.getInitLevel() +
  3. ". 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类方法