Skip to content
Permalink
Browse files

Set initial wait before listing jobs via FTP [JENKINS-31757].

  • Loading branch information
candiduslynx committed Nov 26, 2015
1 parent 1fb8ebf commit 60c9700d059c40902b820e20d81cbfcb32b8bbad
Showing with 20 additions and 18 deletions.
  1. +20 −18 src/main/java/org/jenkinsci/plugins/IBM_zOS_Connector/zFTPConnector.java
@@ -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;
@@ -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";
@@ -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;
}

0 comments on commit 60c9700

Please sign in to comment.
You can’t perform that action at this time.