Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mitigate the concurrency error in scheduling #26

Merged
merged 1 commit into from
Aug 17, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -77,8 +78,7 @@ public Object get(DataFetchingEnvironment environment) {

@Override
protected Stream<Job> dataMapping(Stream<JobData> dataStream) {
return dataStream.parallel()
.map(jobData -> Job.builder()
return dataStream.map(jobData -> Job.builder()
.dataManagement(DataManagement.builder()
.globalSpaceUrl(jobData.getGlobalSpace())
.inputSpaceUrl(jobData.getInputSpace())
Expand Down Expand Up @@ -109,15 +109,26 @@ protected Stream<Job> dataMapping(Stream<JobData> dataStream) {
.startTime(jobData.getStartTime())
.submittedTime(jobData.getSubmittedTime())
.totalNumberOfTasks(jobData.getTotalNumberOfTasks())
// TODO Currently map the JobVariable object to a simple string (its value). Need to map the whole object later
.variables(jobData.getVariables() == null ? ImmutableMap.of()
: jobData.getVariables()
.entrySet()
.stream()
.collect(Collectors.toMap(e -> e.getKey(),
e -> e.getValue()
.getValue())))
// TODO Currently map the JobVariable object to a simple string (its value).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will you do that in another PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment was there before my PR, I have no idea what was planned with it 😄

// Need to map the whole object later
.variables(getVariables(jobData))
.build());
}

/**
* Transform Variables from a JobData into a simple Map.
* @param jobData The jobData to retrieve the variables from
* @return the Map of all variables in the form key -> value
*/
protected Map<String, String> getVariables(JobData jobData) {
if (jobData.getVariables() == null || jobData.getVariables().size() == 0) {
return ImmutableMap.of();
} else {
return jobData.getVariables()
.entrySet()
.stream()
.collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue().getValue()));
}
}

}