import java.util.Arrays;
import java.util.EnumMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Optional;
import java.util.Set;
@Override
public final boolean updateJobProgress(WsJob job) throws IOException
{
- Optional<RemoteFile> logFile = client.getJobResults(job.getJobId()).stream()
- .filter(f -> f.getLabel() == "log").findFirst();
+ List<RemoteFile> files = client.getJobResults(job.getJobId());
+ Optional<RemoteFile> logFile = files.stream()
+ .filter(f -> f.getLabel().equals("log")).findFirst();
+ boolean newContent = false;
if (logFile.isPresent())
{
InputStream stream = logFile.get().getContent();
long nextChunk = stream.skip(job.getNextChunk());
- job.setnextChunk(nextChunk + appendJobStatus(job, stream));
+ int len = appendJobStatus(job, stream);
+ job.setnextChunk(nextChunk + len);
+ newContent |= len > 0;
}
if (failedStates.contains(job.getJobState()))
{
- Optional<RemoteFile> errLogFile = client.getJobResults(job.getJobId()).stream()
- .filter(f -> f.getLabel() == "error-log").findFirst();
+ Optional<RemoteFile> errLogFile = files.stream()
+ .filter(f -> f.getLabel().equals("error-log")).findFirst();
if (errLogFile.isPresent())
{
- appendJobStatus(job, errLogFile.get().getContent());
+ newContent |= appendJobStatus(job, errLogFile.get().getContent()) > 0;
}
}
- return false;
+ return newContent;
}
private int appendJobStatus(WsJob job, InputStream stream) throws IOException