Open lpellegr opened 9 years ago
Instead of TreeMap, we may consider as well HashTreePMap from pCollection lib as it provides immutability and better performance together with clean code. http://pcollections.googlecode.com/svn/trunk/docs/org/pcollections/HashTreePMap.html
Interesting. ImmutableSortedMap from Guava should be also considered if it is possible to use an immutable map. This would avoid importing yet another library.
If ImmutableSortedMap refers to an immutable map, it would not be well suited to the tasks maps as tasks are added dynamically during iterations/replications. Unless I missed something.
@fviale yes, that's why I said if it is possible to use an immutable map. It was a suggestion related to what Marco proposed.
We should as well consider LinkedHashMap, which preserves insertion order. As TaskIds are always incrementing, insertion order should match TaskIds order.
InternalJob implementation is really weird.
Several changes should be made to improve readability and performance:
InternalJob#prepareTasks
). Besides, it makes some assumptions about how HashMap is implemented (open addressing vs separate chaining)prepareTasks
method is still required once TreeMap is usedSchedulerDBManager#newJobSubmitted
)getHMTasks
,getITasks
,getIHMTasks
,getTasks
, etc.). Ideally, a shallow copy should always be returned. If not possible, at least a better naming should be used.getHMTasks
(which returns a shallow copy) is not called inside a for loop multiple times when it is not required (like it was the case inSchedulerDBManager#newJobSubmitted
).