Skip to content

Commit 1f9721b

Browse files
author
Sahil Lone
committed
Add README
1 parent e877a84 commit 1f9721b

File tree

13 files changed

+63
-77
lines changed

13 files changed

+63
-77
lines changed

README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Memory Mapped Queue
2+
3+
[![](https://jitpack.io/v/sahlone/MemoryMappedQueue.svg?label=Release)](https://jitpack.io/#sahlone/kson)
4+
5+
Memory mapped queue is a high performance queue based on the concept of [Memory Mapped Files](https://en.wikipedia.org/wiki/Memory-mapped_file).
6+
7+
The Queue is a circular queue which can in theory give unlimited no of operation provided there is space left under cetain conditions.
8+
The queue can store the data across system restrts as it is based on concept of file per queue.
9+
The application can be started as targeting only one queue at a time, so if we need to have multiple queues we need to have multiple application instances running.
10+
11+
Application takes a set of configuration as a strtup environment varibales that can help to tweak the application.
12+
The application also comes with predeined set of default values so that the application can be started right away.
13+
14+
```
15+
QUEUE_BASE_DIR [default: queue/data] -> Directory within host application where queue data can be written
16+
QUEUE_SIZE_BYTES -> [default:20KB] Maximum size of queue in bytes( limited by the operating system and handware for 32bit vs 64 bit)
17+
QUEUE_NAME ->[default: memory-mapped-queue] name of the queue
18+
```
19+
*Note* Once the Queue have been create the size cannot be changed within application but requires some maintainence work
20+
21+
### Commands
22+
```
23+
PUT text
24+
Inserts a text line into the FIFO Queue. text is a single line of an arbitrary
25+
number of case sensitive alphanumeric words ([A-Z]+[a-z]+[0-9]) separated by
26+
space characters.
27+
GET n
28+
Return n lines from the head of the queue and remove them from the queue.
29+
SHUTDOWN
30+
Shutdown the application/server.
31+
```
32+
### Installation
33+
The application can be used as a standalone library that can be grabbed from [Jitpack](https://jitpack.io/#sahlone/kson)
34+
The library can be obtained from [Jitpack](https://jitpack.io/#sahlone/kson).
35+
```Gradle
36+
repositories {
37+
maven { url 'https://jitpack.io' }
38+
}
39+
dependencies {
40+
implementation 'com.github.sahlone:MemoryMappedQueue:$version'
41+
}
42+
```
43+
### Running the Application
44+
The application can also be run directly as an application
45+
Build the application to produce runnable jar
46+
```
47+
$ ./gradlew clean installShadowDist
48+
```
49+
The above command will create executable jar file in builds folder that can be used to run the application
50+
Remember to have environment variables if you need to change the application properties
51+
```
52+
$ java -jar -Dlogback.configurationFile=logback.xml build/libs/MemoryMappedQueue-1.0.1-all.jar
53+
```
54+
### Work in progress
55+
1. Implement Compare and Swap on head and tail for better concurrecy control
56+
2. Implement a Application server for multiple client connections
57+

build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ buildscript {
1111
plugins {
1212
id 'org.jetbrains.kotlin.jvm' version "1.4.10"
1313
id 'idea'
14-
id 'java-library'
1514
id "io.gitlab.arturbosch.detekt" version '1.8.0'
1615
id "maven"
16+
id "com.github.johnrengelman.shadow" version "6.1.0"
17+
id 'application'
1718
}
1819

1920
group = 'com.github.sahlone'
@@ -107,3 +108,4 @@ install {
107108
}
108109
}
109110
}
111+
mainClassName = 'com.sahlone.mmq.Application'

docker/Dockerfile

Lines changed: 0 additions & 15 deletions
This file was deleted.

docker/docker-compose-env.yaml

Lines changed: 0 additions & 28 deletions
This file was deleted.

docker/docker-compose.yaml

Lines changed: 0 additions & 12 deletions
This file was deleted.

docker/postgres/Dockerfile

Lines changed: 0 additions & 5 deletions
This file was deleted.

docker/postgres/init-db.sh

Lines changed: 0 additions & 8 deletions
This file was deleted.

docker/start-app.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

gradle/dependencies.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ ext {
66
sl4j = '1.7.25'
77
logstashLogbackEncoder = '5.0'
88
logback = '1.2.2'
9-
komprehensions = '1.3.2'
109
config4k = '0.4.1'
1110

1211
libraries = [

queue/data/memory-mapped-queue.data

19.5 KB
Binary file not shown.

queue/data/memory-mapped-queue.meta

8 Bytes
Binary file not shown.

src/main/resources/application.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
memoryMappedQueue {
2+
baseQueueDir = "queue/data"
3+
maxQueueSizeBytes = 20000
4+
queueName = "memory-mapped-queue"
25
baseQueueDir = ${?QUEUE_BASE_DIR}
36
maxQueueSizeBytes = ${?QUEUE_SIZE_BYTES}
47
queueName = ${?QUEUE_NAME}

src/main/resources/logback-levels.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,4 @@
44
xsi:schemaLocation="http://ch.qos.logback/xml/ns/logback https://raw.githubusercontent.com/logback-XSD/master/src/main/xsd/logback.xsd">
55
<logger name="org.apache.kafka" level="warn"/>
66
<logger name="org.reflections" level="warn"/>
7-
<logger name="com.zaxxer.hikari" level="warn"/>
8-
<logger name="org.jooq" level="warn"/>
97
</included>

0 commit comments

Comments
 (0)