hudson.util
Class DoubleLaunchChecker

java.lang.Object
  extended by hudson.util.DoubleLaunchChecker

public class DoubleLaunchChecker
extends Object

Makes sure that no other Hudson uses our JENKINS_HOME directory, to forestall the problem of running multiple instances of Hudson that point to the same data directory.

This set up error occasionally happens especialy when the user is trying to reassign the context path of the app, and it results in a hard-to-diagnose error, so we actively check this.

The mechanism is simple. This class occasionally updates a known file inside the hudson home directory, and whenever it does so, it monitors the timestamp of the file to make sure no one else is updating this file. In this way, while we cannot detect the problem right away, within a reasonable time frame we can detect the collision.

More traditional way of doing this is to use a lock file with PID in it, but unfortunately in Java, there's no reliabe way to obtain PID.

Since:
1.178
Author:
Kohsuke Kawaguchi

Field Summary
 File home
           
 
Constructor Summary
DoubleLaunchChecker()
           
 
Method Summary
 void doDynamic(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
          Serve all URLs with the index view.
 void doIgnore(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp)
          Ignore the problem and go back to using Hudson.
protected  void execute()
           
 String getCollidingId()
           
 String getId()
          Figures out a string that identifies this instance of Hudson.
 void schedule()
          Schedules the next execution.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

home

public final File home
Constructor Detail

DoubleLaunchChecker

public DoubleLaunchChecker()
Method Detail

execute

protected void execute()

getId

public String getId()
Figures out a string that identifies this instance of Hudson.


getCollidingId

public String getCollidingId()

schedule

public void schedule()
Schedules the next execution.


doDynamic

public void doDynamic(org.kohsuke.stapler.StaplerRequest req,
                      org.kohsuke.stapler.StaplerResponse rsp)
               throws IOException,
                      javax.servlet.ServletException
Serve all URLs with the index view.

Throws:
IOException
javax.servlet.ServletException

doIgnore

public void doIgnore(org.kohsuke.stapler.StaplerRequest req,
                     org.kohsuke.stapler.StaplerResponse rsp)
              throws IOException
Ignore the problem and go back to using Hudson.

Throws:
IOException


Copyright © 2004-2013. All Rights Reserved.