forked from sxiangag/Trilobita
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
840eb60
commit 685f13b
Showing
7 changed files
with
206 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,66 @@ | ||
# Commons | ||
Commons module contains all utility functions that can be used throughout this project, such as math calculation related methods. | ||
# Commons Module | ||
|
||
The `commons` module provides basic utilities and foundational components essential for the smooth functioning of the project. It encapsulates common functionalities that can be reused across different modules. | ||
|
||
## Table of Contents | ||
|
||
- Features | ||
- Usage | ||
- Dependencies | ||
- Contribution | ||
|
||
## Features | ||
|
||
1. **Common Classes**: | ||
- `Computable`: An interface defining computable entities. (add, minus, multiply, divide) | ||
- `Mail`: Represents a mail entity with related attributes and behaviors. | ||
- `Message`: Represents a message entity. | ||
2. **Serialization and Deserialization**: | ||
- `MailSerializer`: Provides functionalities to serialize mail objects during communication in `kafka.properties`. | ||
- `MailDeserializer`: Offers functionalities to deserialize mail objects during communication in `kafka.properties`. | ||
3. **Custom Exception**: | ||
- `TrilobitaException`: A custom exception class for handling project-specific exceptions. | ||
|
||
## Usage | ||
|
||
|
||
```java | ||
// Example of using Mail class | ||
Mail newMail = new Mail(toVertexId, null, Mail.MailType.NORMAL); | ||
``` | ||
|
||
#### MailSerializer | ||
|
||
```java | ||
// Serialization of Mail object in `kafka.properties` | ||
// Deserialization of Mail object in `kafka.properties` | ||
key.serializer=org.apache.kafka.common.serialization.StringSerializer | ||
value.serializer=com.trilobita.serializer.MailSerializer | ||
key.deserializer=org.apache.kafka.common.serialization.StringDeserializer | ||
value.deserializer=com.trilobita.deserializer.MailDeserializer | ||
``` | ||
|
||
#### MailDeSerializer | ||
|
||
```java | ||
// Example of using TrilobitaException class | ||
public abstract void start() throws TrilobitaException, InterruptedException, ExecutionException; | ||
``` | ||
|
||
## Dependencies | ||
|
||
- Ensure you have imported the `commons` module in your Maven dependencies if you wish to use it in other modules. | ||
|
||
```xml | ||
<dependency> | ||
<groupId>com.trilobita</groupId> | ||
<artifactId>commons</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
</dependency> | ||
``` | ||
|
||
## Contribution | ||
|
||
If you'd like to contribute to the `commons` module, please follow the standard pull request process. Make sure to write unit tests for any new feature or fix and document your changes thoroughly. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# Core | ||
|
||
The `core` module is the backbone of the project, providing the primary functionalities and foundational components necessary for the operation and interaction of various components within the system. | ||
|
||
Server module depends on this module. | ||
|
||
## Table of Contents | ||
|
||
- Features | ||
- Usage | ||
- Dependencies | ||
- Contribution | ||
|
||
## Features | ||
|
||
1. **Common Utilities**: | ||
- `Util`: A utility class offering various general-purpose methods. | ||
2. **Graph Components**: | ||
- `Graph`: Represents the core graph structure. | ||
- `Vertex`: Basic unit of the graph representing a node. | ||
- `Edge`: Represents connections between vertices. | ||
- `VertexGroup`: Encapsulates a group of vertices for bulk operations. | ||
3. **Messaging System**: | ||
- `MessageAdmin` is a singleton class that offers functionalities related to Kafka topics. It allows you to: | ||
- Retrieve all existing topics. | ||
- Create new topics if they don't exist. | ||
- `MessageConsumer` consumes messages from a specified Kafka topic. It provides the ability to: | ||
- Start listening to a topic in a separate thread. | ||
- Stop the consumer thread. | ||
- Change the topic and restart the consumer. | ||
- Handle consumed messages using a custom `MessageHandler` interface. | ||
- `MessageProducer` enables the production of messages to a specified Kafka topic. It takes care of: | ||
- Creating the topic if it does not exist. | ||
- Sending messages to the desired topic. | ||
|
||
## Usage | ||
|
||
```java | ||
// Example of using Vertex class | ||
List<PageRankVertex> vertices = new ArrayList<>(); | ||
PageRankVertex vertex1 = new PageRankVertex(1); | ||
vertex1.setStatus(Vertex.VertexStatus.ACTIVE); | ||
vertices.add(vertex1); | ||
|
||
PageRankVertex vertex2 = new PageRankVertex(2); | ||
vertex2.setStatus(Vertex.VertexStatus.ACTIVE); | ||
vertices.add(vertex2); | ||
|
||
vertex1.addEdge(vertex2); | ||
|
||
Graph graph = new Graph(vertices); | ||
|
||
// Using the Messaging system | ||
// Initialize MessageAdmin | ||
private final MessageAdmin messageAdmin = MessageAdmin.getInstance(); | ||
|
||
//Produce a Message: | ||
UUID key = UUID.randomUUID(); | ||
Mail mail = new Mail("Hello, Kafka!"); | ||
String targetTopic = "sample_topic"; | ||
MessageProducer.produce(key, mail, targetTopic); | ||
|
||
//Consume Messages: | ||
//Implement the MessageHandler interface: | ||
MessageConsumer.MessageHandler handler = new MessageConsumer.MessageHandler() { | ||
@Override | ||
public void handleMessage(UUID key, Mail value, int partition, long offset) { | ||
System.out.println("Received message: " + value.getContent()); | ||
} | ||
}; | ||
|
||
MessageConsumer consumer = new MessageConsumer("sample_topic", 1, handler); | ||
consumer.start(); | ||
``` | ||
|
||
## Dependencies | ||
|
||
- Ensure the `core` module is included in your Maven dependencies if you intend to use its functionalities in other modules. | ||
|
||
```xml | ||
<dependency> | ||
<groupId>com.trilobita</groupId> | ||
<artifactId>core</artifactId> | ||
<version>1.0.0</version> | ||
</dependency> | ||
``` | ||
|
||
## Contribution | ||
|
||
Contributions to the `core` module are always welcome. Please adhere to the standard pull request process, and ensure that you write unit tests for any new features or fixes. Thoroughly document your changes. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,50 @@ | ||
# Server | ||
Server module provides the implementation of the master and worker. It relies on the core module. | ||
# Engine Module | ||
|
||
The `engine` module is designed to execute core processing tasks, manage computational operations, and provide performance optimizations for the entire application. It houses the central logic and algorithms necessary for the project's main functionalities. | ||
|
||
## Table of Contents | ||
|
||
- Features | ||
- Usage | ||
- Dependencies | ||
- Contribution | ||
|
||
## Features | ||
|
||
1. server/functionable: | ||
- examples | ||
- SumAggregator | ||
- SumCombiner | ||
- Functionable : | ||
- Aggregator : | ||
- Combiner : | ||
2. server/masterserver: | ||
- partitioner | ||
- MasterServer | ||
3. server/workerserver: | ||
- execution | ||
- ExecutionManager | ||
- WorkerServer | ||
4. server/AbstractServer | ||
5. server/Context | ||
6. util/Util | ||
|
||
## Usage | ||
|
||
|
||
|
||
## Dependencies | ||
|
||
- This module depends on the `commons` module for shared utilities and components. | ||
|
||
```xml | ||
<dependency> | ||
<groupId>com.trilobita</groupId> | ||
<artifactId>engine</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
</dependency> | ||
``` | ||
|
||
## Contribution | ||
|
||
Contributions to the `engine` module are welcome. Please adhere to the project's code style guidelines and include comprehensive tests for all new features or changes. Submit a pull request with a clear description of your modifications for review. |
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.