Skip to content

Commit

Permalink
Extract method HttpRemoteTask#triggerUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
raunaqmorarka authored and sopel39 committed Jul 9, 2021
1 parent 641aaac commit 613bd2f
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,7 @@ public synchronized void addSplits(Multimap<PlanNodeId, Split> splitsBySource)
updateSplitQueueSpace();

if (needsUpdate) {
this.needsUpdate.set(true);
scheduleUpdate();
triggerUpdate();
}
}

Expand All @@ -372,16 +371,14 @@ public synchronized void noMoreSplits(PlanNodeId sourceId)
}

noMoreSplits.put(sourceId, true);
needsUpdate.set(true);
scheduleUpdate();
triggerUpdate();
}

@Override
public synchronized void noMoreSplits(PlanNodeId sourceId, Lifespan lifespan)
{
if (pendingNoMoreSplitsForLifespan.put(sourceId, lifespan)) {
needsUpdate.set(true);
scheduleUpdate();
triggerUpdate();
}
}

Expand All @@ -394,8 +391,7 @@ public synchronized void setOutputBuffers(OutputBuffers newOutputBuffers)

if (newOutputBuffers.getVersion() > outputBuffers.get().getVersion()) {
outputBuffers.set(newOutputBuffers);
needsUpdate.set(true);
scheduleUpdate();
triggerUpdate();
}
}

Expand Down Expand Up @@ -511,6 +507,13 @@ private void scheduleUpdate()
executor.execute(this::sendUpdate);
}

private synchronized void triggerUpdate()
{
// synchronized so that needsUpdate is not cleared in sendUpdate before actual request is sent
needsUpdate.set(true);
sendUpdate();
}

private synchronized void sendUpdate()
{
TaskStatus taskStatus = getTaskStatus();
Expand Down

0 comments on commit 613bd2f

Please sign in to comment.