Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .ci/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@
if [[ -z "${TRAVIS_TAG}" ]]; then
echo "Not a tagged release"
else
echo "Creating DataGate zip distribution"
echo "Copying artifacts"
cp nitrite-datagate/build/libs/nitrite-datagate-$NITRITE_VERSION.jar nitrite-datagate/src/main/dist/lib/nitrite-datagate.jar
cp nitrite-datagate/build/libs/nitrite-datagate-$NITRITE_VERSION.jar nitrite-datagate/src/main/docker/nitrite-datagate.jar
rm nitrite-datagate/src/main/dist/lib/.gitkeep
echo "Creating DataGate zip distribution"
cd nitrite-datagate/src/main/dist/
zip -r nitrite-datagate-$NITRITE_VERSION.zip bin conf lib
cd -
echo $(pwd)
echo "Creating docker image"
cd nitrite-datagate/src/main/docker
chmod +x datagate.sh
docker build -t dizitart/nitrite-datagate:$NITRITE_VERSION .
docker tag dizitart/nitrite-datagate:$NITRITE_VERSION dizitart/nitrite-datagate:latest
docker login -u $DOCKER_USER -p $DOCKER_PASS
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ deploy:

env:
global:
- NITRITE_VERSION=1.0
- NITRITE_VERSION=1.0.1
- PGP_KEY_FILE=~/secring.gpg
34 changes: 31 additions & 3 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ image:https://codecov.io/gh/dizitart/nitrite-database/branch/master/graph/badge.
image:https://javadoc.io/badge/org.dizitart/nitrite.svg["Javadocs", link=https://javadoc.io/doc/org.dizitart/nitrite]
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"]


image:http://www.dizitart.org/nitrite-database/doc/1.0/images/nitrite-logo.svg[Logo 200, 200]

**NO**sql **O**bject (*NO~2~* a.k.a Nitrite) database is an open source nosql embedded
document store written in Java. It has MongoDB like API. It supports both
in-memory and single file based persistent store powered by
Expand Down Expand Up @@ -71,6 +74,31 @@ ObjectRepository<Employee> repository = db.getRepository(Employee.class);

--

*Annotations for POJO*
[source,java]
--
// provides index information for ObjectRepository
@Indices({
@Index(field = "joinDate", type = IndexType.NonUnique),
@Index(field = "name", type = IndexType.Unique)
})
public class Employee implements Serializable {
// provides id field to uniquely identify an object inside an ObjectRepository
@Id
private long empId;

private Date joinDate;

private String name;

private String address;

// ... public getters and setters
}

--


*CRUD Operations*
[source,java]
--
Expand Down Expand Up @@ -111,7 +139,7 @@ repository.insert(emp);
collection.createIndex("firstName", indexOptions(IndexType.NonUnique));
collection.createIndex("note", indexOptions(IndexType.Fulltext));

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

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

|[Document]
|http://www.dizitart.org/nitrite-database[Document]
|https://javadoc.io/doc/org.dizitart/nitrite[JavaDoc]
|===

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

== Maintainers

* Anindya Chatterjee
* Anindya Chatterjee
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ buildscript {
classpath "io.franzbecker:gradle-lombok:$lombokPluginVersion"
classpath "org.asciidoctor:asciidoctor-gradle-plugin:$asciidoctorPluginVersion"
classpath "net.ltgt.gradle:gradle-errorprone-plugin:$errorPronePluginVersion"
classpath "com.github.jengelman.gradle.plugins:shadow:$shadowPluginVersion"
classpath "com.github.jengelman.gradle.plugins:shadow:$shadowPluginVersion"
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:$nexusStagingPlugin"
}
}
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
org.gradle.jvmargs=-Xmx1024m

# artifact version
nitriteVersion=1.0
nitriteVersion=1.0.1

# nitrite dependency
asciidoctorVersion=1.5.4
Expand All @@ -44,6 +44,7 @@ log4j2Version=2.6.2
lombokVersion=1.16.10
lombokPluginVersion=1.7
luceneVersion=4.9.0
meanbeanVersion=2.0.3
mongoDriverVersion=3.4.2
nexusStagingPlugin=0.8.0
objenesisVersion=2.4
Expand Down
74 changes: 74 additions & 0 deletions nitrite-datagate/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
= Nitrite DataGate

If you are using Nitrite Database in your applications and want to synchronize the data in
real-time across the devices, you need DataGate.

Nitrite DataGate is the replication server for Nitrite database. It comes as a separate product.
It is available as a binary distribution or as a docker image.

To get the latest binary distribution please visit the
https://github.com/dizitart/nitrite-database/releases[Release] page of Github.
The docker image is available at docker hub

[source,bash]
--
docker pull dizitart/nitrite-datagate
--

*Configuration*

DataGate server needs a MongoDb instance to run. To configure Mongo details, edit the file
*datagate.properties* inside the *conf* directory of the binary distribution and set the below
properties

[source,properties]
--
# Mongo Config
datagate.mongo.host=
datagate.mongo.port=
datagate.mongo.user=
datagate.mongo.password=
datagate.mongo.database=
--

And run the server, execute the below command from bin folder

[source,bash]
--
./datagate.sh
--

To configure and run the docker image, some details like MongoDb connection
needs to be provided. Create some docker file like below and build it for
the desired result.

[source,docker]
--
FROM dizitart/nitrite-datagate

COPY keystore.jks /

## Connection details (Replace with your own values)
ENV DATAGATE_HOST "0.0.0.0"
ENV DATAGATE_HTTP_PORT "8080"
ENV DATAGATE_HTTPS_PORT "8443"
ENV DATAGATE_MONITOR_PORT "9090"
ENV DATAGATE_KEY_STORE "keystore.jks"
ENV DATAGATE_KEY_PASSWORD "s3cret"

## Mongo connection details (Replace with your own values)
ENV DATAGATE_MONGO_HOST "192.168.0.100"
ENV DATAGATE_MONGO_PORT "2706"
ENV DATAGATE_MONGO_USER "demo"
ENV DATAGATE_MONGO_PASSWORD "demoPass"
ENV DATAGATE_MONGO_DATABASE "demo"

## Starts the server
RUN ["chmod", "+x", "./datagate.sh"]
ENTRYPOINT [ "./datagate.sh" ]
--

Once the server is up and running, access the admin portal using the url
--
http(s)://<ip>:<port>/datagate
--
4 changes: 3 additions & 1 deletion nitrite-datagate/src/main/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ ENV JAVA_OPTS "$JAVA_OPTS -Drun.mode=docker -Djava.security.egd=file:/dev/./uran
# log settings
ENV DATAGATE_LOG_FILE "/logs/datagate.log"

ENV DATAGATE_SYNC_LOG_CLEANUP_DELAY "30" #days
# default 30 days cleanup policy
ENV DATAGATE_SYNC_LOG_CLEANUP_DELAY "30"

## Configure below environment variables
#ENV DATAGATE_HOST ""
Expand All @@ -26,4 +27,5 @@ ENV DATAGATE_SYNC_LOG_CLEANUP_DELAY "30" #days
#ENV DATAGATE_MONGO_PASSWORD ""
#ENV DATAGATE_MONGO_DATABASE ""

#RUN ["chmod", "+x", "./datagate.sh"]
#ENTRYPOINT [ "./datagate.sh" ]
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
Expand Down Expand Up @@ -56,7 +58,7 @@
@EnableSwagger2
@EnableScheduling
@SpringBootApplication
@EnableAutoConfiguration
@EnableAutoConfiguration(exclude = { MongoAutoConfiguration.class, MongoDataAutoConfiguration.class })
public class NitriteDataGate extends WebMvcConfigurerAdapter {

@Value("${datagate.mongo.host}")
Expand Down
1 change: 1 addition & 0 deletions nitrite/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ dependencies {
testCompile "org.awaitility:awaitility:$awaitilityVersion"
testCompile "joda-time:joda-time:$jodaTimeVersion"
testCompile "com.squareup.okhttp3:mockwebserver:$okhttpVersion"
testCompile "org.meanbean:meanbean:$meanbeanVersion"
}

gradle.buildFinished { BuildResult result ->
Expand Down
30 changes: 30 additions & 0 deletions nitrite/src/docs/asciidoc/collections/annotations.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Nitrite provides a set of annotations for entity objects while using it in ObjectRepository. The
annotations are to let Nitrite knows about various information about the ObjectRepository while
constructing it. It also helps to reduce some boilerplate code.

.Example
[source,java]
--
// Employee class
@Indices({
@Index(field = "joinDate", type = IndexType.NonUnique),
@Index(field = "name", type = IndexType.Unique)
})
public class Employee implements Serializable {
@Id
private long empId;

private Date joinDate;

private String name;

private String address;

// ... public getters and setters
}

--

`Index` annotation is to let Nitrite knows about the field which will be indexed. `Id` annotation
is to mark a field as id field. This id field is used to uniquely identify an object inside an
ObjectRepository. More on these annotations will be discussed later.
4 changes: 4 additions & 0 deletions nitrite/src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ include::nitrite-collection.adoc[]

include::object-repository.adoc[]

==== Annotations

include::collections/annotations.adoc[]

==== NitriteMapper

include::collections/nitrite-mapper.adoc[]
Expand Down
15 changes: 11 additions & 4 deletions nitrite/src/docs/asciidoc/tools/datagate.adoc
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
Nitrite DataGate is the replication server for Nitrite database. It comes as a separate product.
It is available as a binary distribution or as a docker image.

To get the latest binary distribution please visit the Release page of Github. The docker image
To get the latest binary distribution please visit the
https://github.com/dizitart/nitrite-database/releases[Release] page of Github. The docker image
is available at docker hub

[source,bash]
--
docker pull dizitart/nitrite-datagate:1.0
docker pull dizitart/nitrite-datagate
--

*Configuration*
Expand Down Expand Up @@ -38,7 +39,7 @@ the desired result.

[source,docker]
--
FROM dizitart/nitrite-datagate:1.0
FROM dizitart/nitrite-datagate

COPY keystore.jks /

Expand All @@ -58,5 +59,11 @@ ENV DATAGATE_MONGO_PASSWORD "demoPass"
ENV DATAGATE_MONGO_DATABASE "demo"

## Starts the server
RUN ["chmod", "+x", "./datagate.sh"]
ENTRYPOINT [ "./datagate.sh" ]
--
--

Once the server is up and running, access the admin portal using the url
--
http(s)://<ip>:<port>/datagate
--
6 changes: 3 additions & 3 deletions nitrite/src/main/java/org/dizitart/no2/Cursor.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
* [source,java]
* . Example of {@link Cursor}
* --
* // createId/open a database
* // create/open a database
* Nitrite db = Nitrite.builder()
* .openOrCreate("user", "password");
*
* // createId a collection named - test
* // create a collection named - test
* NitriteCollection collection = db.getCollection("test");
*
* // returns all ids un-filtered
Expand All @@ -43,7 +43,7 @@
* --
*
* [icon="{@docRoot}/note.png"]
* NOTE: To createId an iterator over the documents instead of the ids,
* NOTE: To create an iterator over the documents instead of the ids,
* call on the {@link Cursor}.
*
* @author Anindya Chatterjee
Expand Down
6 changes: 3 additions & 3 deletions nitrite/src/main/java/org/dizitart/no2/IndexOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
public class IndexOptions {

/**
* Specifies the type of an index to createId.
* Specifies the type of an index to create.
*
* @param indexType type of an index.
* @returns type of an index to createId.
* @returns type of an index to create.
* */
@Getter @Setter
private IndexType indexType;
Expand All @@ -42,7 +42,7 @@ public class IndexOptions {
* way.
*
* @param async if set to `true` then the index will be created asynchronously;
* otherwise createId index operation will wait until all existing
* otherwise create index operation will wait until all existing
* documents are indexed.
* @returns `true` if index is to be created asynchronously; otherwise `false`.
* @see NitriteCollection#createIndex(String, IndexOptions)
Expand Down
4 changes: 2 additions & 2 deletions nitrite/src/main/java/org/dizitart/no2/Nitrite.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
* [NOTE]
* ====
* - It does not support ACID transactions.
* - Use {@link NitriteBuilder} to createId a db instance.
* - Use {@link NitriteBuilder} to create a db instance.
* ====
*
* @author Anindya Chatterjee
Expand All @@ -78,7 +78,7 @@ public class Nitrite implements Closeable {
}

/**
* Provides a builder utility to createId a {@link Nitrite} database
* Provides a builder utility to create a {@link Nitrite} database
* instance.
*
* @return a {@link NitriteBuilder} instance.
Expand Down
Loading