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

Use queue for resync requests. #12043

Merged
merged 1 commit into from
Jul 30, 2020
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 @@ -47,6 +47,7 @@ public class MessageSender {

private ApplicationConnection connection;
private boolean hasActiveRequest = false;
private boolean resynchronizeRequested = false;

/**
* Counter for the messages send to the server. First sent message has id 0.
Expand Down Expand Up @@ -98,7 +99,7 @@ public void sendInvocationsToServer() {
private void doSendInvocationsToServer() {

ServerRpcQueue serverRpcQueue = getServerRpcQueue();
if (serverRpcQueue.isEmpty()) {
if (serverRpcQueue.isEmpty() && !resynchronizeRequested) {
return;
}

Expand All @@ -110,7 +111,7 @@ private void doSendInvocationsToServer() {
JsonArray reqJson = serverRpcQueue.toJson();
serverRpcQueue.clear();

if (reqJson.length() == 0) {
if (reqJson.length() == 0 && !resynchronizeRequested) {
// Nothing to send, all invocations were filtered out (for
// non-existing connectors)
getLogger().warning(
Expand All @@ -124,6 +125,11 @@ private void doSendInvocationsToServer() {
Version.getFullVersion());
connection.getConfiguration().setWidgetsetVersionSent();
}
if (resynchronizeRequested) {
getLogger().info("Resynchronizing from server");
extraJson.put(ApplicationConstants.RESYNCHRONIZE_ID, true);
resynchronizeRequested = false;
}
if (showLoadingIndicator) {
connection.getLoadingIndicator().trigger();
}
Expand Down Expand Up @@ -239,7 +245,8 @@ public void endRequest() {
hasActiveRequest = false;

if (connection.isApplicationRunning()) {
if (getServerRpcQueue().isFlushPending()) {
if (getServerRpcQueue().isFlushPending()
|| resynchronizeRequested) {
sendInvocationsToServer();
}
runPostRequestHooks(connection.getConfiguration().getRootPanelId());
Expand Down Expand Up @@ -350,10 +357,9 @@ private VLoadingIndicator getLoadingIndicator() {
*/
public void resynchronize() {
getMessageHandler().onResynchronize();
getLogger().info("Resynchronizing from server");
JsonObject resyncParam = Json.createObject();
resyncParam.put(ApplicationConstants.RESYNCHRONIZE_ID, true);
send(Json.createArray(), resyncParam);
getLogger().info("Resynchronize from server requested");
resynchronizeRequested = true;
sendInvocationsToServer();
}

/**
Expand Down