Skip to content

Commit 14eba9c

Browse files
authored
Merge pull request #9 from dizitart/master
Milestone 1.0.1 changes
2 parents fd57139 + 198ee2f commit 14eba9c

30 files changed

+337
-61
lines changed

.ci/release.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,18 @@
33
if [[ -z "${TRAVIS_TAG}" ]]; then
44
echo "Not a tagged release"
55
else
6-
echo "Creating DataGate zip distribution"
6+
echo "Copying artifacts"
77
cp nitrite-datagate/build/libs/nitrite-datagate-$NITRITE_VERSION.jar nitrite-datagate/src/main/dist/lib/nitrite-datagate.jar
88
cp nitrite-datagate/build/libs/nitrite-datagate-$NITRITE_VERSION.jar nitrite-datagate/src/main/docker/nitrite-datagate.jar
99
rm nitrite-datagate/src/main/dist/lib/.gitkeep
10+
echo "Creating DataGate zip distribution"
1011
cd nitrite-datagate/src/main/dist/
1112
zip -r nitrite-datagate-$NITRITE_VERSION.zip bin conf lib
1213
cd -
1314
echo $(pwd)
1415
echo "Creating docker image"
1516
cd nitrite-datagate/src/main/docker
17+
chmod +x datagate.sh
1618
docker build -t dizitart/nitrite-datagate:$NITRITE_VERSION .
1719
docker tag dizitart/nitrite-datagate:$NITRITE_VERSION dizitart/nitrite-datagate:latest
1820
docker login -u $DOCKER_USER -p $DOCKER_PASS

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,5 @@ deploy:
4242

4343
env:
4444
global:
45-
- NITRITE_VERSION=1.0
45+
- NITRITE_VERSION=1.0.1
4646
- PGP_KEY_FILE=~/secring.gpg

README.adoc

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ image:https://codecov.io/gh/dizitart/nitrite-database/branch/master/graph/badge.
55
image:https://javadoc.io/badge/org.dizitart/nitrite.svg["Javadocs", link=https://javadoc.io/doc/org.dizitart/nitrite]
66
image:https://badges.gitter.im/dizitart/nitrite-database.svg["Gitter", link="https://gitter.im/dizitart/nitrite-database?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=body_badge"]
77

8+
9+
image:http://www.dizitart.org/nitrite-database/doc/1.0/images/nitrite-logo.svg[Logo 200, 200]
10+
811
**NO**sql **O**bject (*NO~2~* a.k.a Nitrite) database is an open source nosql embedded
912
document store written in Java. It has MongoDB like API. It supports both
1013
in-memory and single file based persistent store powered by
@@ -71,6 +74,31 @@ ObjectRepository<Employee> repository = db.getRepository(Employee.class);
7174

7275
--
7376

77+
*Annotations for POJO*
78+
[source,java]
79+
--
80+
// provides index information for ObjectRepository
81+
@Indices({
82+
@Index(field = "joinDate", type = IndexType.NonUnique),
83+
@Index(field = "name", type = IndexType.Unique)
84+
})
85+
public class Employee implements Serializable {
86+
// provides id field to uniquely identify an object inside an ObjectRepository
87+
@Id
88+
private long empId;
89+
90+
private Date joinDate;
91+
92+
private String name;
93+
94+
private String address;
95+
96+
// ... public getters and setters
97+
}
98+
99+
--
100+
101+
74102
*CRUD Operations*
75103
[source,java]
76104
--
@@ -111,7 +139,7 @@ repository.insert(emp);
111139
collection.createIndex("firstName", indexOptions(IndexType.NonUnique));
112140
collection.createIndex("note", indexOptions(IndexType.Fulltext));
113141

114-
// create object index
142+
// create object index. It can also be provided via annotation
115143
repository.createIndex("firstName", indexOptions(IndexType.NonUnique));
116144
--
117145

@@ -198,7 +226,7 @@ Release notes are available https://github.com/dizitart/nitrite-database/release
198226
|===
199227
|Reference |API
200228

201-
|[Document]
229+
|http://www.dizitart.org/nitrite-database[Document]
202230
|https://javadoc.io/doc/org.dizitart/nitrite[JavaDoc]
203231
|===
204232

@@ -236,4 +264,4 @@ before you file an issue please check if it is already existing or not.
236264

237265
== Maintainers
238266

239-
* Anindya Chatterjee
267+
* Anindya Chatterjee

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ buildscript {
2626
classpath "io.franzbecker:gradle-lombok:$lombokPluginVersion"
2727
classpath "org.asciidoctor:asciidoctor-gradle-plugin:$asciidoctorPluginVersion"
2828
classpath "net.ltgt.gradle:gradle-errorprone-plugin:$errorPronePluginVersion"
29-
classpath "com.github.jengelman.gradle.plugins:shadow:$shadowPluginVersion"
29+
classpath "com.github.jengelman.gradle.plugins:shadow:$shadowPluginVersion"
3030
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:$nexusStagingPlugin"
3131
}
3232
}

gradle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
org.gradle.jvmargs=-Xmx1024m
2323

2424
# artifact version
25-
nitriteVersion=1.0
25+
nitriteVersion=1.0.1
2626

2727
# nitrite dependency
2828
asciidoctorVersion=1.5.4
@@ -44,6 +44,7 @@ log4j2Version=2.6.2
4444
lombokVersion=1.16.10
4545
lombokPluginVersion=1.7
4646
luceneVersion=4.9.0
47+
meanbeanVersion=2.0.3
4748
mongoDriverVersion=3.4.2
4849
nexusStagingPlugin=0.8.0
4950
objenesisVersion=2.4

nitrite-datagate/README.adoc

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
= Nitrite DataGate
2+
3+
If you are using Nitrite Database in your applications and want to synchronize the data in
4+
real-time across the devices, you need DataGate.
5+
6+
Nitrite DataGate is the replication server for Nitrite database. It comes as a separate product.
7+
It is available as a binary distribution or as a docker image.
8+
9+
To get the latest binary distribution please visit the
10+
https://github.com/dizitart/nitrite-database/releases[Release] page of Github.
11+
The docker image is available at docker hub
12+
13+
[source,bash]
14+
--
15+
docker pull dizitart/nitrite-datagate
16+
--
17+
18+
*Configuration*
19+
20+
DataGate server needs a MongoDb instance to run. To configure Mongo details, edit the file
21+
*datagate.properties* inside the *conf* directory of the binary distribution and set the below
22+
properties
23+
24+
[source,properties]
25+
--
26+
# Mongo Config
27+
datagate.mongo.host=
28+
datagate.mongo.port=
29+
datagate.mongo.user=
30+
datagate.mongo.password=
31+
datagate.mongo.database=
32+
--
33+
34+
And run the server, execute the below command from bin folder
35+
36+
[source,bash]
37+
--
38+
./datagate.sh
39+
--
40+
41+
To configure and run the docker image, some details like MongoDb connection
42+
needs to be provided. Create some docker file like below and build it for
43+
the desired result.
44+
45+
[source,docker]
46+
--
47+
FROM dizitart/nitrite-datagate
48+
49+
COPY keystore.jks /
50+
51+
## Connection details (Replace with your own values)
52+
ENV DATAGATE_HOST "0.0.0.0"
53+
ENV DATAGATE_HTTP_PORT "8080"
54+
ENV DATAGATE_HTTPS_PORT "8443"
55+
ENV DATAGATE_MONITOR_PORT "9090"
56+
ENV DATAGATE_KEY_STORE "keystore.jks"
57+
ENV DATAGATE_KEY_PASSWORD "s3cret"
58+
59+
## Mongo connection details (Replace with your own values)
60+
ENV DATAGATE_MONGO_HOST "192.168.0.100"
61+
ENV DATAGATE_MONGO_PORT "2706"
62+
ENV DATAGATE_MONGO_USER "demo"
63+
ENV DATAGATE_MONGO_PASSWORD "demoPass"
64+
ENV DATAGATE_MONGO_DATABASE "demo"
65+
66+
## Starts the server
67+
RUN ["chmod", "+x", "./datagate.sh"]
68+
ENTRYPOINT [ "./datagate.sh" ]
69+
--
70+
71+
Once the server is up and running, access the admin portal using the url
72+
--
73+
http(s)://<ip>:<port>/datagate
74+
--

nitrite-datagate/src/main/docker/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ ENV JAVA_OPTS "$JAVA_OPTS -Drun.mode=docker -Djava.security.egd=file:/dev/./uran
99
# log settings
1010
ENV DATAGATE_LOG_FILE "/logs/datagate.log"
1111

12-
ENV DATAGATE_SYNC_LOG_CLEANUP_DELAY "30" #days
12+
# default 30 days cleanup policy
13+
ENV DATAGATE_SYNC_LOG_CLEANUP_DELAY "30"
1314

1415
## Configure below environment variables
1516
#ENV DATAGATE_HOST ""
@@ -26,4 +27,5 @@ ENV DATAGATE_SYNC_LOG_CLEANUP_DELAY "30" #days
2627
#ENV DATAGATE_MONGO_PASSWORD ""
2728
#ENV DATAGATE_MONGO_DATABASE ""
2829

30+
#RUN ["chmod", "+x", "./datagate.sh"]
2931
#ENTRYPOINT [ "./datagate.sh" ]

nitrite-datagate/src/main/java/org/dizitart/no2/datagate/NitriteDataGate.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import org.springframework.boot.SpringApplication;
2828
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
2929
import org.springframework.boot.autoconfigure.SpringBootApplication;
30+
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
31+
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
3032
import org.springframework.context.annotation.Bean;
3133
import org.springframework.context.annotation.ComponentScan;
3234
import org.springframework.context.annotation.Configuration;
@@ -56,7 +58,7 @@
5658
@EnableSwagger2
5759
@EnableScheduling
5860
@SpringBootApplication
59-
@EnableAutoConfiguration
61+
@EnableAutoConfiguration(exclude = { MongoAutoConfiguration.class, MongoDataAutoConfiguration.class })
6062
public class NitriteDataGate extends WebMvcConfigurerAdapter {
6163

6264
@Value("${datagate.mongo.host}")

nitrite/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ dependencies {
4848
testCompile "org.awaitility:awaitility:$awaitilityVersion"
4949
testCompile "joda-time:joda-time:$jodaTimeVersion"
5050
testCompile "com.squareup.okhttp3:mockwebserver:$okhttpVersion"
51+
testCompile "org.meanbean:meanbean:$meanbeanVersion"
5152
}
5253

5354
gradle.buildFinished { BuildResult result ->
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Nitrite provides a set of annotations for entity objects while using it in ObjectRepository. The
2+
annotations are to let Nitrite knows about various information about the ObjectRepository while
3+
constructing it. It also helps to reduce some boilerplate code.
4+
5+
.Example
6+
[source,java]
7+
--
8+
// Employee class
9+
@Indices({
10+
@Index(field = "joinDate", type = IndexType.NonUnique),
11+
@Index(field = "name", type = IndexType.Unique)
12+
})
13+
public class Employee implements Serializable {
14+
@Id
15+
private long empId;
16+
17+
private Date joinDate;
18+
19+
private String name;
20+
21+
private String address;
22+
23+
// ... public getters and setters
24+
}
25+
26+
--
27+
28+
`Index` annotation is to let Nitrite knows about the field which will be indexed. `Id` annotation
29+
is to mark a field as id field. This id field is used to uniquely identify an object inside an
30+
ObjectRepository. More on these annotations will be discussed later.

0 commit comments

Comments
 (0)