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

make sure tasks are in ZK #735

Merged
merged 1 commit into from
Oct 28, 2015
Merged
Show file tree
Hide file tree
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 @@ -233,10 +233,10 @@ protected SingularityCreateResult set(String path, Optional<byte[]> data) {
}
}

protected <T> Optional<T> getData(String path, Optional<Stat> stat, Transcoder<T> transcoder, Optional<ZkCache<T>> zkCache) {
private <T> Optional<T> getData(String path, Optional<Stat> stat, Transcoder<T> transcoder, Optional<ZkCache<T>> zkCache, Optional<Boolean> shouldCheckExists) {
if (!stat.isPresent() && zkCache.isPresent()) {
Optional<T> cachedValue = zkCache.get().get(path);
if (cachedValue.isPresent()) {
if (cachedValue.isPresent() && (!shouldCheckExists.isPresent() || (shouldCheckExists.get().booleanValue() && checkExists(path).isPresent()))) {
return cachedValue;
}
}
Expand Down Expand Up @@ -277,15 +277,15 @@ protected <T> Optional<T> getData(String path, Optional<Stat> stat, Transcoder<T
}

protected <T> Optional<T> getData(String path, Transcoder<T> transcoder) {
return getData(path, Optional.<Stat> absent(), transcoder, Optional.<ZkCache<T>> absent());
return getData(path, Optional.<Stat> absent(), transcoder, Optional.<ZkCache<T>> absent(), Optional.<Boolean> absent());
}

protected <T> Optional<T> getData(String path, Transcoder<T> transcoder, Optional<ZkCache<T>> zkCache) {
return getData(path, Optional.<Stat> absent(), transcoder, zkCache);
protected <T> Optional<T> getData(String path, Transcoder<T> transcoder, ZkCache<T> zkCache, boolean shouldCheckExists) {
return getData(path, Optional.<Stat> absent(), transcoder, Optional.of(zkCache), Optional.of(shouldCheckExists));
}

protected Optional<String> getStringData(String path) {
return getData(path, StringTranscoder.INSTANCE, Optional.<ZkCache<String>> absent());
return getData(path, Optional.<Stat> absent(), StringTranscoder.INSTANCE, Optional.<ZkCache<String>> absent(), Optional.<Boolean> absent());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ public List<SingularityTaskId> getInactiveTaskIdsForDeploy(String requestId, fin
}

public Optional<SingularityTaskHistory> getTaskHistory(SingularityTaskId taskId) {
final Optional<SingularityTask> task = getTask(taskId);
final Optional<SingularityTask> task = getTaskCheckCache(taskId, true);

if (!task.isPresent()) {
return Optional.absent();
Expand Down Expand Up @@ -471,11 +471,15 @@ public Optional<SingularityPendingTask> getPendingTask(SingularityPendingTaskId
return getData(getPendingPath(pendingTaskId), pendingTaskTranscoder);
}

@Timed
public Optional<SingularityTask> getTask(SingularityTaskId taskId) {
private Optional<SingularityTask> getTaskCheckCache(SingularityTaskId taskId, boolean shouldCheckExists) {
final String path = getTaskPath(taskId);

return getData(path, taskTranscoder, Optional.of(taskCache));
return getData(path, taskTranscoder, taskCache, shouldCheckExists);
}

@Timed
public Optional<SingularityTask> getTask(SingularityTaskId taskId) {
return getTaskCheckCache(taskId, false);
}

public List<SingularityPendingTaskId> getPendingTaskIds() {
Expand Down