Skip to content

Commit

Permalink
Set initial wait before listing jobs via FTP [JENKINS-31757].
Browse files Browse the repository at this point in the history
  • Loading branch information
candiduslynx committed Nov 26, 2015
1 parent 1fb8ebf commit 60c9700
Showing 1 changed file with 20 additions and 18 deletions.
Expand Up @@ -317,12 +317,23 @@ private boolean waitForCompletion(OutputStream outputStream)
{
// Initialize current time and estimated time.
long curr = System.currentTimeMillis();
long jobEndTime = System.currentTimeMillis() + this.waitTime;
long jobEndTime = curr + this.waitTime;
boolean eternal = (waitTime == 0);

// Perform wait
while (eternal || (curr <= jobEndTime))
do
{
// Wait
try
{
Thread.sleep(waitInterval);
curr = System.currentTimeMillis();
} catch (InterruptedException e) {
logger.severe(logPrefix + "Interrupted.");
this.jobCC = "WAIT_INTERRUPTED";
return false;
}

// check job state
if (!this.checkJobAvailability())
return false;
Expand All @@ -331,17 +342,8 @@ private boolean waitForCompletion(OutputStream outputStream)
if (this.fetchJobLog(outputStream))
return true;

// Wait
try
{
Thread.sleep(waitInterval);
curr = System.currentTimeMillis();
} catch (InterruptedException e) {
logger.severe(logPrefix + "Interrupted.");
this.jobCC = "WAIT_INTERRUPTED";
return false;
}
}

} while (eternal || (curr <= jobEndTime)) ;

// Exit with wait error.
this.jobCC = "WAIT_ERROR";
Expand All @@ -367,11 +369,11 @@ private boolean checkJobAvailability ()
try
{
for (String name : this.FTPClient.listNames("*"))
if(this.jobID.equals(name)) {
// Found our jobId
return true;
}
logger.severe("Job [" + this.jobID + "] cannot be found in JES");
if (this.jobID.equals(name)) {
// Found our jobId
return true;
}
logger.severe(this.logPrefix + "Job [" + this.jobID + "] cannot be found in JES");
this.jobCC = "JOB_NOT_FOUND_IN_JES";
return false;
}
Expand Down

0 comments on commit 60c9700

Please sign in to comment.