Skip to content

Web server workflow-related state refactoring - #1387

Merged
shengquan-ni merged 68 commits into
masterfrom
shengquan-websock-refactor
Feb 10, 2022
Merged

Web server workflow-related state refactoring#1387
shengquan-ni merged 68 commits into
masterfrom
shengquan-websock-refactor

Conversation

@shengquan-ni

@shengquan-ni shengquan-ni commented Jan 4, 2022

Copy link
Copy Markdown
Contributor

Workflow State Store
According to our discussion, we want to separate data and logic for each component class in our webserver. So I used protobuf for the data class and added a SyncableState (any better names?) to wrap the modification. I created a centralized store for all data classes. This centralized store is called WorkflowStateStore and is passed into every service component. The service component can subscribe to any state change and push events to the frontend as a reaction. It can also actively modify any state based on request and this modification will also be observed by other components.

Reason to use protobuf
Although protobuf increases the transmission efficiency but the biggest reason I want to use it is not about that. Protobuf gives us a unified way to define data classes. Since we have the typescript-based frontend, a java/scala/python-based backend, we don't want to write the same data class in different languages. Another reason is that protobuf objects are immutable so we can easily write the onChanged API and enforce developers to follow this API to modify the state. Right now protobuf data classes only stay inside the backend. When we send those data to the frontend, a conversion to TexeraWebsocketEvent needs to be done so that we can hook up with the existing json serialization/deserialization. In the future, we may replace json with protobuf serialization.

Websocket Input
This module provides an observable of frontend requests to workflow internal components inside the web server. So every component has a chance to subscribe to specific events they want to handle.

Lifecycle Manager
This module controls the lifecycle of a workflow state. As I stated before, there is a counter inside each workflow to maintain the current number of active users. Once all users disconnect AND the workflow is not in a running state, the cleanup logic will trigger.

Texera Overall Infrastructure-web server architecture drawio (1)

@zuozhiw zuozhiw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, left a few minor minor comments.

Comment thread core/amber/src/main/scala/edu/uci/ics/texera/web/WebsocketSubscriber.scala Outdated
Comment thread core/amber/src/main/scala/edu/uci/ics/texera/web/StateStore.scala
@shengquan-ni
shengquan-ni merged commit 189cc5b into master Feb 10, 2022
@shengquan-ni
shengquan-ni deleted the shengquan-websock-refactor branch February 10, 2022 18:21
yangzhang75 pushed a commit to yangzhang75/texera that referenced this pull request Jun 22, 2026
**Workflow State Store**
According to our discussion, we want to separate data and logic for each component class in our webserver. So I used protobuf for the data class and added a `SyncableState` (any better names?) to wrap the modification. I created a centralized store for all data classes. This centralized store is called `WorkflowStateStore` and is passed into every service component. The service component can subscribe to any state change and push events to the frontend as a reaction. It can also actively modify any state based on request and this modification will also be observed by other components.

**Reason to use protobuf**
Although protobuf increases the transmission efficiency but the biggest reason I want to use it is not about that. Protobuf gives us a unified way to define data classes. Since we have the typescript-based frontend, a java/scala/python-based backend, we don't want to write the same data class in different languages. Another reason is that protobuf objects are immutable so we can easily write the `onChanged` API and enforce developers to follow this API to modify the state. Right now protobuf data classes only stay inside the backend. When we send those data to the frontend, a conversion to `TexeraWebsocketEvent` needs to be done so that we can hook up with the existing json serialization/deserialization. In the future, we may replace json with protobuf serialization.

**Websocket Input**
This module provides an `observable` of frontend requests to workflow internal components inside the web server. So every component has a chance to subscribe to specific events they want to handle.

**Lifecycle Manager**
This module controls the lifecycle of a workflow state. As I stated before, there is a counter inside each workflow to maintain the current number of active users. Once all users disconnect **AND** the workflow is not in a running state, the cleanup logic will trigger.


![Texera Overall Infrastructure-web server architecture drawio (1)](https://user-images.githubusercontent.com/13672781/153096652-bdf30976-3a1c-485f-aef5-b4ceac8f046c.png)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Refactor the code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants