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

Apache Cassandra Implementation for Chat Service #296

Closed

Conversation

parhamrahmani
Copy link
Contributor

@parhamrahmani parhamrahmani commented Jan 16, 2025

Apache Cassandra Implementation for Chat Service

Closes #293

This pull request implements a polyglot persistence within REMSFAL and replaces the MySQL database solution for the chat service with Apache Cassandra.

Changes

  • Keyspace and Replication:

    • The REMSFAL keyspace uses the NetworkTopologyStrategy with replication set to 2 nodes in datacenter1, ensuring high availability and fault tolerance. You can add new containers to datacenter1 in docker compose file to also redistribute data and horizontally scale.
    • Warning: In order to reduce container to only 1, the NetworkTopologyStrategy with replication of 2 won't work anymore and should be set to SimpleStrategy without replication (which wouldn't align with the thesis issue._
  • Data Models:

    • chat_messages Table: Stores chat messages, partitioned by chat_session_id and clustered by message_id for efficient retrieval. The table will be partitioned and grouped by each chat session and distributed across nodes to avoid chat_messages table getting too big on a node/server.
    • chat_sessions Table: Manages session metadata, partitioned by project_id and clustered by task_id and session_id to support queries of sessions on a project/task on a single partition.
  • CassandraExecutor:

    • Automates the initialization of the Cassandra database, ensuring the keyspace and schema are correctly configured.
    • Processes changelogs sequentially from cassandra-changelogs.xml for schema updates.
    • To use this, Place CQL changelog files in src/main/resources/cassandra/changelogs/cql-scripts/. Then define changelog entries in cassandra-changelogs.xml, specifying the file names of the CQL scripts to execute.
  • Controller and Repository Updates:

    • Refactored to align with Cassandra's schema and query patterns, including the permanent deletion of messages in "CLOSED" sessions. The status "ARCHIVED" is not used anymore for the sake of simplicity.
  • Docker Integration:

    • Added two Cassandra containers for local testing, simulating a multi-node setup for data replication and distribution.

@parhamrahmani
Copy link
Contributor Author

parhamrahmani commented Jan 16, 2025

@astanik Can you please review this pull request? This will be hopefully the final implementation regarding the chat service database solution. T

I am getting connection refused on port 9042 which is needed for Cassandra. Is this a misconfiguration on my part? since i didn't have this on my personal environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement Chat Service Database Solution - Chat Logs and Messages
1 participant