-
Notifications
You must be signed in to change notification settings - Fork 339
Add LogRecord table update callbacks #2159
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
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,6 +86,7 @@ | |
| import java.util.Arrays; | ||
| import java.util.HashMap; | ||
| import java.util.List; | ||
| import java.util.concurrent.atomic.AtomicBoolean; | ||
| import java.util.concurrent.atomic.AtomicReference; | ||
| import java.util.function.Consumer; | ||
|
|
||
|
|
@@ -208,10 +209,6 @@ public GanttProject(boolean isOnlyViewer) { | |
| getWebSocket().register(null); | ||
| getWebSocket().onCommitResponseReceived(this::fireXlogReceived); | ||
| getWebSocket().onBaseTxnIdReceived(this::onBaseTxnIdReceived); | ||
| var taskListenerAdapter = new TaskListenerAdapter(); | ||
| // TODO: add listeners sensibly. | ||
| taskListenerAdapter.setTaskAddedHandler(event -> this.sendProjectStateLogs()); | ||
| getTaskManager().addTaskListener(taskListenerAdapter); | ||
| } | ||
|
|
||
| area = new GanttGraphicArea(this, getTaskManager(), getZoomManager(), getUndoManager(), | ||
|
|
@@ -956,7 +953,8 @@ public void refresh() { | |
| super.repaint(); | ||
| } | ||
|
|
||
| // TODO: Accumulate changes instead of sending it every time. | ||
| private final AtomicBoolean isSendingInProgress = new AtomicBoolean(); | ||
|
|
||
| private Unit sendProjectStateLogs() { | ||
| gpLogger.debug("Sending project state logs"); | ||
| try { | ||
|
|
@@ -969,20 +967,34 @@ private Unit sendProjectStateLogs() { | |
| "refid", | ||
| txns | ||
| )); | ||
| isSendingInProgress.set(true); | ||
| } | ||
| } catch (ProjectDatabaseException e) { | ||
| gpLogger.error("Failed to send logs", new Object[]{}, ImmutableMap.of(), e); | ||
|
dbarashev marked this conversation as resolved.
|
||
| isSendingInProgress.set(false); | ||
| } | ||
| return Unit.INSTANCE; | ||
| } | ||
|
|
||
| @Override | ||
| protected Unit onProjectLogUpdate() { | ||
| if (isColloboqueLocalTest()) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't like that we have more and more these checks. I thought that we would have just a few differences between the "local test" and "prod" modes (url, authentication), but now it seems that we will just not do anything in prod.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove this check? And maybe the super call too?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, in this case we shall check "if we are working with an online document, in any sense", not "is it a local online document setup". We probably need to modify the local dev server so that it could respond to project read and write operations, just like a regular GP Cloud server. In this case the check may look like |
||
| super.onProjectLogUpdate(); | ||
| if (!isSendingInProgress.get()) sendProjectStateLogs(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The call is guarded with the flag check here, but not guarded a few lines below. I suggest moving the check of
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was designed this weird because |
||
| } | ||
| return Unit.INSTANCE; | ||
| } | ||
|
|
||
| private Unit fireXlogReceived(ServerCommitResponse response) { | ||
| myBaseTxnCommitInfo.update(response.getBaseTxnId(), response.getNewBaseTxnId(), 1); | ||
| isSendingInProgress.set(false); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest replacing this boolean flag and long-living success response listener with a short-living listener, working as follows:
Pros:
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you so much for the idea! I hated this AtomicBoolean but I couldn't come up with something better |
||
| sendProjectStateLogs(); | ||
| return Unit.INSTANCE; | ||
| } | ||
|
|
||
| private Unit onBaseTxnIdReceived(String baseTxnId) { | ||
| myBaseTxnCommitInfo.update("", baseTxnId, 0); | ||
| sendProjectStateLogs(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It appears that the comment above (previous messages are discarded) and these two lines (sendCompleted, sendLogs) are kinda controversial. We obviously need to make sure that the state which we have locally matches the server state which corresponds to this
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! |
||
| return Unit.INSTANCE; | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.