Skip to content

Commit da030c8

Browse files
Initial Commit
1 parent 2288971 commit da030c8

21 files changed

+425
-0
lines changed

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Realtime Mysql Framework
2+
This is a java framework which provides you to handle the changes in your database at realtime.
3+
4+
## How it works
5+
The framework has a server that listens to the changes in the general log file of the mysql and fires the listener associated with the updated.
6+
7+
The framework provides an interface with functions such as onUpdate, onSelect etc... You can override these functions to handle the changes and register the implemented interface with the framework. The framework will automatically call the function associated with the update.
8+
9+
## Usage
10+
- Initialize the Mysql data directory
11+
```console
12+
foo@bar:~$ mysqld --initialize --data-dir="datadirectory"
13+
```
14+
- Start the mysql daemon(mysql server)
15+
```console
16+
foo@bar:~$ filename="your log file name for mysql"
17+
foo@bar:~$ datadir="your mysql data directory"
18+
foo@bar:~$ mysqld --datadir="$datadir" --general-log --general-log-file="$filename"
19+
```
20+
- Start the Realtime Server provided and pass the general log file location as the parameter. Example: `java Server general_log_file_name`
21+
```console
22+
foo@bar:~$ cd ./generated
23+
foo@bar:~$ file="$datadir/$filename"
24+
foo@bar:~$ java Server "$file" || kill -term `pidof mysqld`
25+
```
26+
- Import the ServerConnect java file in your program and implement the interface DatabaseEventListener. `See Demo.java`
27+
```java
28+
import com.pranay.realtimedatabase.DatabaseEventListener;
29+
import com.pranay.realtimedatabase.ServerConnect;
30+
.
31+
.
32+
.
33+
ServerConnect conn = new ServerConnect();
34+
conn.setDatabaseChangeEventListener(new DatabaseEventListener() {...} );
35+
conn.startDatabaseChangeListenerService();
36+
```
37+
## QuickStart
38+
I have provided some quickstart bash scripts to start the realtime server as well as mysql server with general logging enabled.
39+
- Launch the `quickstart.sh` and follow the steps
40+
41+
### Other Scripts
42+
- *compile.sh* Compile all the java files
43+
- *runserver.sh* Start the realtime server

compile.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/bash
2+
javac sources/com/pranay/realtimedatabase/*.java -cp . -d ./generated/
3+
if [ $? -ne 0 ]
4+
then
5+
echo -e "\e[031mCompilation failed\e[0m"
6+
exit
7+
fi
8+
javac sources/*.java -cp sources/ -d ./generated/
9+
if [ $? -ne 0 ]
10+
then
11+
echo -e "\e[031mCompilation failed\e[0m"
12+
exit
13+
fi

generated/ClientThread.class

2.11 KB
Binary file not shown.

generated/Demo$1.class

1.24 KB
Binary file not shown.

generated/Demo.class

633 Bytes
Binary file not shown.

generated/Server.class

3.4 KB
Binary file not shown.
2.14 KB
Binary file not shown.
250 Bytes
Binary file not shown.
Binary file not shown.
2.49 KB
Binary file not shown.

0 commit comments

Comments
 (0)