diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml
new file mode 100644
index 00000000..2d05e6df
--- /dev/null
+++ b/.github/workflows/pr-build.yml
@@ -0,0 +1,66 @@
+name: Pull Request
+on:
+ pull_request:
+ types: [ opened, synchronize, reopened ]
+
+jobs:
+ build:
+ name: Build
+ runs-on: ubuntu-latest
+ steps:
+
+ - uses: actions/checkout@v3
+ with:
+ fetch-depth: 0
+
+ - name: Set up JDK 11
+ uses: actions/setup-java@v3
+ with:
+ java-version: 11
+ distribution: 'adopt'
+
+ - name: Cache Maven packages
+ uses: actions/cache@v3
+ with:
+ path: ~/.m2
+ key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
+ restore-keys: ${{ runner.os }}-m2
+
+ - name: Build
+ run: mvn clean verify -DskipTests=true
+
+ test:
+ name: Test
+ needs: build
+ runs-on: ubuntu-latest
+ timeout-minutes: 200
+ services:
+ mongo:
+ image: mongo:4.4
+ ports:
+ - 27017:27017
+ steps:
+
+ - uses: actions/checkout@v3
+ with:
+ fetch-depth: 0
+
+ - name: Set up JDK 11
+ uses: actions/setup-java@v3
+ with:
+ java-version: 11
+ distribution: 'adopt'
+
+ - name: Cache Maven packages
+ uses: actions/cache@v3
+ with:
+ path: ~/.m2
+ key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
+ restore-keys: ${{ runner.os }}-m2
+
+ - name: Build
+ run: mvn clean package install -DskipTests=true
+
+ - name: Build, test
+ timeout-minutes: 180
+ run: mvn -B test
\ No newline at end of file
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
deleted file mode 100644
index 3db59ba1..00000000
--- a/.github/workflows/publish.yml
+++ /dev/null
@@ -1,21 +0,0 @@
-name: Publish Bintray
-on:
- release:
- types: [published]
-
-jobs:
- publish:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v1
- - name: Set up JDK 1.8
- uses: actions/setup-java@v1
- with:
- java-version: 1.8
- - name: Grant Permission to Execute
- run: chmod +x gradlew
- - name: Publish Library
- env:
- BINTRAY_USERNAME: ${{ secrets.BINTRAY_USERNAME }}
- BINTRAY_API_KEY: ${{ secrets.BINTRAY_API_KEY }}
- run: ./gradlew bintrayUpload
\ No newline at end of file
diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml
new file mode 100644
index 00000000..af316a41
--- /dev/null
+++ b/.github/workflows/release-build.yml
@@ -0,0 +1,108 @@
+name: Publish package to GitHub Packages
+on:
+ release:
+ types: [ published ]
+
+jobs:
+ build:
+ name: Build
+ runs-on: ubuntu-latest
+ services:
+ mongo:
+ image: mongo:4.4
+ ports:
+ - 27017:27017
+ steps:
+ - uses: actions/checkout@v3
+ with:
+ fetch-depth: 0
+
+ - name: Set up JDK 11
+ uses: actions/setup-java@v3
+ with:
+ java-version: 11
+ distribution: 'adopt'
+ - uses: cardinalby/git-get-release-action@v1
+ id: getEnvRelease
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Get Project Version from pom.xml
+ uses: entimaniac/read-pom-version-action@1.0.0
+ id: getVersion
+
+ # - name: Check Enviroment release
+ # if: ${{ !((steps.getEnvRelease.outputs.prerelease && contains(steps.getVersion.outputs.version, '-SNAPSHOT')) || (!steps.getEnvRelease.outputs.prerelease && !contains(steps.getVersion.outputs.version, '-SNAPSHOT'))) }}
+ # run: exit 1
+
+ - name: Cache Maven packages
+ uses: actions/cache@v3
+ with:
+ path: ~/.m2
+ key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
+ restore-keys: ${{ runner.os }}-m2
+
+ - name: Build
+ run: mvn clean verify
+
+ publish-OSSRH:
+ runs-on: ubuntu-latest
+ name: Publish to Maven Central
+ needs: test
+ permissions:
+ contents: read
+ packages: write
+ steps:
+ - uses: actions/checkout@v3
+ with:
+ fetch-depth: 0
+
+ - id: install-secret-key
+ name: Install gpg secret key
+ run: |
+ cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import
+ gpg --list-secret-keys --keyid-format LONG
+
+ - name: Set up Maven Central Repository
+ uses: actions/setup-java@v3
+ with:
+ java-version: 11
+ distribution: 'adopt'
+ server-id: ossrh
+ server-username: MAVEN_USERNAME
+ server-password: MAVEN_PASSWORD
+
+ - name: Publish package
+ run: mvn -DskipTests=true --batch-mode -P ossrh-publish -Dgpg.passphrase=${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} deploy
+ env:
+ MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
+ MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
+
+ publish-artifact:
+ name: GitHub Artifacts
+ needs: test
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ packages: write
+ steps:
+ - uses: actions/checkout@v3
+ with:
+ fetch-depth: 0
+
+ - uses: actions/setup-java@v3
+ with:
+ java-version: '11'
+ distribution: 'adopt'
+
+ - name: Cache Maven packages
+ uses: actions/cache@v3
+ with:
+ path: ~/.m2
+ key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
+ restore-keys: ${{ runner.os }}-m2
+
+ - name: Publish artifact on GitHub Packages
+ run: mvn -B -P github-publish clean deploy -DskipTests
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
old mode 100755
new mode 100644
index d8dab78e..3761db16
--- a/.gitignore
+++ b/.gitignore
@@ -1,10 +1,17 @@
-/build
-/.gradle
-/.settings
-/.classpath
-/.project
-/.idea
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### IntelliJ IDEA ###
+.idea/
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
*.iml
+*.ipr
/out
lib/*
*#
@@ -13,3 +20,28 @@ lib/*
src/legacytest/*
checkouts/*
bin
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 62f70d8c..00000000
--- a/.travis.yml
+++ /dev/null
@@ -1,18 +0,0 @@
-dist: bionic
-sudo: false
-
-language: java
-jdk:
- - oraclejdk13
- - openjdk13
-
-services:
- - mongodb
-
-install: ./gradlew assemble
-
-cache:
- directories:
- - $HOME/.gradle
-
-script: ./gradlew check --info --stacktrace
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
deleted file mode 100644
index 623c6c87..00000000
--- a/CONTRIBUTING.md
+++ /dev/null
@@ -1,29 +0,0 @@
-# Contributing
-
-This project uses a very minimalistic approach to contributions:
-
- * Fork it
- * Create a branch
- * Make your changes
- * Commit it with an explanation of [*why* this change is necessary](https://chris.beams.io/posts/git-commit/#why-not-how)
- * Make sure all tests pass
- * Submit a pull request
- * Be patient
-
-## Prerequisites
-
-This project uses Gradle 6.x. A [compatible JDK version](https://docs.gradle.org/current/userguide/compatibility.html#java) is therefore required.
-
-## Running Tests
-
-To start a local MongoDB node before running tests, use
-
-``` shell
-./gradlew startMongoDb
-```
-
-Then run the tests:
-
-``` shell
-./gradlew check
-```
diff --git a/build.gradle b/build.gradle
deleted file mode 100644
index 0f8b763b..00000000
--- a/build.gradle
+++ /dev/null
@@ -1,178 +0,0 @@
-buildscript {
- repositories {
- mavenCentral()
- jcenter()
- }
-}
-
-plugins {
- id 'net.researchgate.release' version '2.8.1'
- id "com.jfrog.bintray" version "1.8.5"
- id 'com.sourcemuse.mongo' version '1.0.7'
-}
-
-allprojects {
- repositories {
- jcenter()
- }
- apply plugin: 'maven-publish'
- apply plugin: 'java'
-}
-
-apply plugin: 'eclipse'
-apply plugin: 'groovy'
-apply plugin: 'idea'
-apply plugin: 'com.sourcemuse.mongo'
-
-archivesBaseName = 'quartz-mongodb'
-
-jar {
- archiveVersion = projectVersion
-}
-
-repositories {
- mavenCentral()
-}
-
-java {
- sourceCompatibility = JavaVersion.VERSION_1_8
- targetCompatibility = JavaVersion.VERSION_1_8
-}
-
-configurations {
- provided
- implementation.extendsFrom provided
-}
-sourceSets {
- main { compileClasspath += configurations.provided }
-}
-
-idea {
- module {
- scopes.PROVIDED.plus += [configurations.provided]
- downloadJavadoc = true
- downloadSources = true
- }
-}
-
-eclipse {
- classpath {
- downloadSources true
- downloadJavadoc true
- }
- jdt {
- sourceCompatibility java.sourceCompatibility
- targetCompatibility java.targetCompatibility
- }
-}
-
-dependencies {
- implementation("org.quartz-scheduler:quartz:2.3.2")
- implementation("org.mongodb:mongodb-driver-sync:4.7.1")
- implementation("commons-codec:commons-codec:1.10")
- implementation("org.apache.commons:commons-lang3:3.8")
- implementation("org.apache.httpcomponents:httpcore:4.4.10")
- implementation("org.slf4j:slf4j-api:1.7.21")
-
- compileOnly("org.clojure:clojure:1.10.0")
-
- testImplementation("org.clojure:clojure:1.10.0")
- testImplementation("joda-time:joda-time:2.8.2")
- testImplementation("org.slf4j:slf4j-simple:1.7.10")
- testImplementation("org.codehaus.groovy:groovy-all:2.5.12")
- testImplementation("org.spockframework:spock-core:1.3-groovy-2.5")
- testRuntimeOnly("cglib:cglib-nodep:3.1")
- testRuntimeOnly("org.objenesis:objenesis:2.1")
-}
-
-release {
- scmAdapters = [net.researchgate.release.GitAdapter]
- git {
- pushToRemote = 'origin'
- }
-
- versionPropertyFile = 'gradle.properties'
-}
-
-task sourceJar(type: Jar) {
- dependsOn classes
- classifier "sources"
- from sourceSets.main.allSource
-}
-
-task javadocJar(type: Jar) {
- classifier 'javadoc'
- from javadoc
-}
-
-tasks.withType(Javadoc) {
- options.addStringOption('Xdoclint:none', '-quiet')
-}
-
-artifacts {
- archives sourceJar
- archives javadocJar
-}
-
-publishing {
- publications {
- quartzMongoDB(MavenPublication) {
- groupId = 'com.novemberain'
- artifactId = archivesBaseName
- version = projectVersion
-
- artifact sourceJar {
- classifier "sources"
- }
-
- from components.java
- }
- }
-}
-
-mongo {
- port 27017
- logging 'console'
- journalingEnabled true
-}
-
-test {
- beforeTest { descriptor ->
- logger.lifecycle("Running test \"${descriptor}\"")
- }
-}
-
-// force test runs even when there are no test changes,
-// such test loops are very useful for testing race conditions
-// and other concurrency hazards
-test.outputs.upToDateWhen { false }
-
-tasks.withType(Test){
- runWithMongoDb = true
- mongo {
- journalingEnabled true
- port 27017
- logging 'console'
- mongoVersion 'PRODUCTION'
- }
-}
-
-bintray {
- user = System.getenv("BINTRAY_USERNAME")
- key = System.getenv("BINTRAY_API_KEY")
- publications = ['quartzMongoDB']
- pkg {
- repo = 'maven'
- name = 'quartz-mongodb'
- labels = ['quartz', 'mongodb']
- userOrg = 'michaelklishin'
- licenses = ['Apache-2.0']
- vcsUrl = 'https://github.com/michaelklishin/quartz-mongodb.git'
-
- version {
- name = projectVersion
- desc = 'MongoDB-backed job store for the Quartz scheduler'
- vcsTag = projectVersion
- }
- }
-}
diff --git a/gradle.properties b/gradle.properties
deleted file mode 100644
index 465b4750..00000000
--- a/gradle.properties
+++ /dev/null
@@ -1,3 +0,0 @@
-projectVersion=2.2.0-SNAPSHOT
-org.gradle.caching = true
-org.gradle.vfs.watch = true
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
deleted file mode 100644
index 62d4c053..00000000
Binary files a/gradle/wrapper/gradle-wrapper.jar and /dev/null differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
deleted file mode 100644
index 766af62f..00000000
--- a/gradle/wrapper/gradle-wrapper.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-#Tue Jul 14 22:34:43 MSK 2020
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-all.zip
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-zipStorePath=wrapper/dists
-zipStoreBase=GRADLE_USER_HOME
diff --git a/gradlew b/gradlew
deleted file mode 100755
index fbd7c515..00000000
--- a/gradlew
+++ /dev/null
@@ -1,185 +0,0 @@
-#!/usr/bin/env sh
-
-#
-# Copyright 2015 the original author or authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-##############################################################################
-##
-## Gradle start up script for UN*X
-##
-##############################################################################
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn () {
- echo "$*"
-}
-
-die () {
- echo
- echo "$*"
- echo
- exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-nonstop=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
- NONSTOP* )
- nonstop=true
- ;;
-esac
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin or MSYS, switch paths to Windows format before running java
-if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
-
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
- fi
- i=`expr $i + 1`
- done
- case $i in
- 0) set -- ;;
- 1) set -- "$args0" ;;
- 2) set -- "$args0" "$args1" ;;
- 3) set -- "$args0" "$args1" "$args2" ;;
- 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
-fi
-
-# Escape application args
-save () {
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
- echo " "
-}
-APP_ARGS=`save "$@"`
-
-# Collect all arguments for the java command, following the shell quoting and substitution rules
-eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-
-exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
deleted file mode 100644
index 5093609d..00000000
--- a/gradlew.bat
+++ /dev/null
@@ -1,104 +0,0 @@
-@rem
-@rem Copyright 2015 the original author or authors.
-@rem
-@rem Licensed under the Apache License, Version 2.0 (the "License");
-@rem you may not use this file except in compliance with the License.
-@rem You may obtain a copy of the License at
-@rem
-@rem https://www.apache.org/licenses/LICENSE-2.0
-@rem
-@rem Unless required by applicable law or agreed to in writing, software
-@rem distributed under the License is distributed on an "AS IS" BASIS,
-@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-@rem See the License for the specific language governing permissions and
-@rem limitations under the License.
-@rem
-
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Resolve any "." and ".." in APP_HOME to make it shorter.
-for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 00000000..382030a3
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,173 @@
+
+
+ 4.0.0
+
+ com.netgrif
+ quartz-mongodb-connector
+ 1.0.0-SNAPSHOT
+
+
+ 11
+ 11
+ UTF-8
+
+
+
+
+ org.quartz-scheduler
+ quartz
+ 2.3.2
+
+
+
+ org.mongodb
+ mongodb-driver-sync
+ 4.7.1
+
+
+
+ commons-codec
+ commons-codec
+ 1.10
+
+
+
+ org.apache.commons
+ commons-lang3
+ 3.8
+
+
+
+ org.apache.httpcomponents
+ httpcore
+ 4.4.10
+
+
+
+ org.slf4j
+ slf4j-api
+ 1.7.21
+
+
+
+ org.clojure
+ clojure
+ 1.10.0
+
+
+
+
+ joda-time
+ joda-time
+ 2.8.2
+ test
+
+
+
+ org.slf4j
+ slf4j-simple
+ 1.7.10
+ test
+
+
+
+ org.codehaus.groovy
+ groovy-all
+ 2.5.11
+ test
+ pom
+
+
+
+ org.spockframework
+ spock-core
+ 1.3-groovy-2.5
+ test
+
+
+
+ cglib
+ cglib-nodep
+ 3.1
+ test
+
+
+
+ org.objenesis
+ objenesis
+ 2.1
+ test
+
+
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ 5.9.2
+ test
+
+
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ 5.9.2
+ test
+
+
+
+
+ org.junit.jupiter
+ junit-jupiter-params
+ 5.9.2
+ test
+
+
+
+ joda-time
+ joda-time
+ 2.12.5
+ test
+
+
+
+
+ org.mockito
+ mockito-core
+ 4.1.0
+ test
+
+
+
+
+ org.mockito
+ mockito-junit-jupiter
+ 4.1.0
+ test
+
+
+
+ org.projectlombok
+ lombok
+ 1.18.28
+ test
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 3.0.0-M5
+
+ false
+
+
+
+
+
+
diff --git a/src/main/java/com/novemberain/quartz/mongodb/Constants.java b/src/main/java/com/netgrif/quartz/mongodb/Constants.java
old mode 100644
new mode 100755
similarity index 93%
rename from src/main/java/com/novemberain/quartz/mongodb/Constants.java
rename to src/main/java/com/netgrif/quartz/mongodb/Constants.java
index 55b32645..13d87d8f
--- a/src/main/java/com/novemberain/quartz/mongodb/Constants.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/Constants.java
@@ -1,4 +1,4 @@
-package com.novemberain.quartz.mongodb;
+package com.netgrif.quartz.mongodb;
public interface Constants {
diff --git a/src/main/java/com/novemberain/quartz/mongodb/DynamicMongoDBJobStore.java b/src/main/java/com/netgrif/quartz/mongodb/DynamicMongoDBJobStore.java
old mode 100644
new mode 100755
similarity index 83%
rename from src/main/java/com/novemberain/quartz/mongodb/DynamicMongoDBJobStore.java
rename to src/main/java/com/netgrif/quartz/mongodb/DynamicMongoDBJobStore.java
index 411470e6..3e392089
--- a/src/main/java/com/novemberain/quartz/mongodb/DynamicMongoDBJobStore.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/DynamicMongoDBJobStore.java
@@ -1,7 +1,7 @@
-package com.novemberain.quartz.mongodb;
+package com.netgrif.quartz.mongodb;
import com.mongodb.client.MongoClient;
-import com.novemberain.quartz.mongodb.clojure.DynamicClassLoadHelper;
+import com.netgrif.quartz.mongodb.clojure.DynamicClassLoadHelper;
import org.quartz.spi.ClassLoadHelper;
public class DynamicMongoDBJobStore extends MongoDBJobStore {
diff --git a/src/main/java/com/novemberain/quartz/mongodb/JobCompleteHandler.java b/src/main/java/com/netgrif/quartz/mongodb/JobCompleteHandler.java
old mode 100644
new mode 100755
similarity index 95%
rename from src/main/java/com/novemberain/quartz/mongodb/JobCompleteHandler.java
rename to src/main/java/com/netgrif/quartz/mongodb/JobCompleteHandler.java
index 9593578f..01bddefb
--- a/src/main/java/com/novemberain/quartz/mongodb/JobCompleteHandler.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/JobCompleteHandler.java
@@ -1,8 +1,8 @@
-package com.novemberain.quartz.mongodb;
+package com.netgrif.quartz.mongodb;
-import com.novemberain.quartz.mongodb.dao.JobDao;
-import com.novemberain.quartz.mongodb.dao.LocksDao;
-import com.novemberain.quartz.mongodb.dao.TriggerDao;
+import com.netgrif.quartz.mongodb.dao.JobDao;
+import com.netgrif.quartz.mongodb.dao.LocksDao;
+import com.netgrif.quartz.mongodb.dao.TriggerDao;
import org.quartz.JobDetail;
import org.quartz.JobPersistenceException;
import org.quartz.Trigger.CompletedExecutionInstruction;
diff --git a/src/main/java/com/novemberain/quartz/mongodb/JobConverter.java b/src/main/java/com/netgrif/quartz/mongodb/JobConverter.java
old mode 100644
new mode 100755
similarity index 96%
rename from src/main/java/com/novemberain/quartz/mongodb/JobConverter.java
rename to src/main/java/com/netgrif/quartz/mongodb/JobConverter.java
index b27fa776..99924999
--- a/src/main/java/com/novemberain/quartz/mongodb/JobConverter.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/JobConverter.java
@@ -1,11 +1,11 @@
-package com.novemberain.quartz.mongodb;
+package com.netgrif.quartz.mongodb;
import org.bson.Document;
import org.quartz.*;
import org.quartz.spi.ClassLoadHelper;
-import static com.novemberain.quartz.mongodb.util.Keys.KEY_GROUP;
-import static com.novemberain.quartz.mongodb.util.Keys.KEY_NAME;
+import static com.netgrif.quartz.mongodb.util.Keys.KEY_GROUP;
+import static com.netgrif.quartz.mongodb.util.Keys.KEY_NAME;
public class JobConverter {
diff --git a/src/main/java/com/novemberain/quartz/mongodb/JobDataConverter.java b/src/main/java/com/netgrif/quartz/mongodb/JobDataConverter.java
old mode 100644
new mode 100755
similarity index 97%
rename from src/main/java/com/novemberain/quartz/mongodb/JobDataConverter.java
rename to src/main/java/com/netgrif/quartz/mongodb/JobDataConverter.java
index 1c56fb65..6437a57e
--- a/src/main/java/com/novemberain/quartz/mongodb/JobDataConverter.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/JobDataConverter.java
@@ -1,6 +1,6 @@
-package com.novemberain.quartz.mongodb;
+package com.netgrif.quartz.mongodb;
-import com.novemberain.quartz.mongodb.util.SerialUtils;
+import com.netgrif.quartz.mongodb.util.SerialUtils;
import org.bson.Document;
import org.quartz.JobDataMap;
import org.quartz.JobPersistenceException;
diff --git a/src/main/java/com/novemberain/quartz/mongodb/LockManager.java b/src/main/java/com/netgrif/quartz/mongodb/LockManager.java
old mode 100644
new mode 100755
similarity index 95%
rename from src/main/java/com/novemberain/quartz/mongodb/LockManager.java
rename to src/main/java/com/netgrif/quartz/mongodb/LockManager.java
index 548aa492..f7855060
--- a/src/main/java/com/novemberain/quartz/mongodb/LockManager.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/LockManager.java
@@ -1,8 +1,8 @@
-package com.novemberain.quartz.mongodb;
+package com.netgrif.quartz.mongodb;
import com.mongodb.MongoWriteException;
-import com.novemberain.quartz.mongodb.dao.LocksDao;
-import com.novemberain.quartz.mongodb.util.ExpiryCalculator;
+import com.netgrif.quartz.mongodb.dao.LocksDao;
+import com.netgrif.quartz.mongodb.util.ExpiryCalculator;
import org.bson.Document;
import org.quartz.JobDetail;
import org.quartz.TriggerKey;
diff --git a/src/main/java/com/novemberain/quartz/mongodb/MongoDBJobStore.java b/src/main/java/com/netgrif/quartz/mongodb/MongoDBJobStore.java
similarity index 93%
rename from src/main/java/com/novemberain/quartz/mongodb/MongoDBJobStore.java
rename to src/main/java/com/netgrif/quartz/mongodb/MongoDBJobStore.java
index 1c353a3d..3b533677 100755
--- a/src/main/java/com/novemberain/quartz/mongodb/MongoDBJobStore.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/MongoDBJobStore.java
@@ -1,34 +1,21 @@
-/*
- * $Id: MongoDBJobStore.java 253170 2014-01-06 02:28:03Z waded $
- * --------------------------------------------------------------------------------------
- * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com
- *
- * The software in this package is published under the terms of the CPAL v1.0
- * license, a copy of which has been included with this distribution in the
- * LICENSE.txt file.
- */
-package com.novemberain.quartz.mongodb;
+package com.netgrif.quartz.mongodb;
import com.mongodb.MongoCommandException;
import com.mongodb.MongoException;
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
-import com.novemberain.quartz.mongodb.db.MongoConnector;
-import com.novemberain.quartz.mongodb.util.Keys;
+import com.netgrif.quartz.mongodb.db.MongoConnector;
+import com.netgrif.quartz.mongodb.util.Keys;
import org.bson.Document;
import org.quartz.*;
-import org.quartz.Calendar;
import org.quartz.Trigger.CompletedExecutionInstruction;
import org.quartz.Trigger.TriggerState;
import org.quartz.impl.matchers.GroupMatcher;
import org.quartz.spi.*;
+import org.quartz.Calendar;
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
+import java.io.*;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.TimeUnit;
@@ -212,23 +199,7 @@ public boolean isJobDataAsBase64() {
return jobDataAsBase64;
}
- /**
- * Configures the way job data is stored. {@link JobDetail}'s
- * or {@link Trigger}'s {@link JobDataMap} can be represented
- * as a {@code Map}.
- *
- * - {@code true} (default) - Serialize map with
- * {@link java.io.ObjectOutputStream ObjectOutputStream}
- * and store as {@code base64} encoded string in field
- * '{@value Constants#JOB_DATA}'. Map may contain any
- * {@link java.io.Serializable Serializable} object
- * internally, but will have some performance impact.
- * - {@code false} - Store map directly in
- * '{@value Constants#JOB_DATA_PLAIN}' field. Use this
- * option is you only store simple types in job data
- * map for better performance.
- *
- */
+
public void setJobDataAsBase64(boolean jobDataAsBase64) {
this.jobDataAsBase64 = jobDataAsBase64;
@@ -335,9 +306,10 @@ public void clearAllSchedulingData() throws JobPersistenceException {
assembler.pausedTriggerGroupsDao.remove();
}
+
@Override
public void storeCalendar(String name, Calendar calendar, boolean replaceExisting, boolean updateTriggers)
- throws JobPersistenceException {
+ throws ObjectAlreadyExistsException, JobPersistenceException {
// TODO implement updating triggers
if (updateTriggers) {
throw new UnsupportedOperationException("Updating triggers is not supported.");
diff --git a/src/main/java/com/novemberain/quartz/mongodb/MongoStoreAssembler.java b/src/main/java/com/netgrif/quartz/mongodb/MongoStoreAssembler.java
old mode 100644
new mode 100755
similarity index 89%
rename from src/main/java/com/novemberain/quartz/mongodb/MongoStoreAssembler.java
rename to src/main/java/com/netgrif/quartz/mongodb/MongoStoreAssembler.java
index 0704c695..facee9d8
--- a/src/main/java/com/novemberain/quartz/mongodb/MongoStoreAssembler.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/MongoStoreAssembler.java
@@ -1,15 +1,15 @@
-package com.novemberain.quartz.mongodb;
+package com.netgrif.quartz.mongodb;
import com.mongodb.client.MongoCollection;
-import com.novemberain.quartz.mongodb.cluster.*;
-import com.novemberain.quartz.mongodb.dao.*;
-import com.novemberain.quartz.mongodb.db.MongoConnector;
-import com.novemberain.quartz.mongodb.db.MongoConnectorBuilder;
-import com.novemberain.quartz.mongodb.trigger.MisfireHandler;
-import com.novemberain.quartz.mongodb.trigger.TriggerConverter;
-import com.novemberain.quartz.mongodb.util.Clock;
-import com.novemberain.quartz.mongodb.util.ExpiryCalculator;
-import com.novemberain.quartz.mongodb.util.QueryHelper;
+import com.netgrif.quartz.mongodb.cluster.*;
+import com.netgrif.quartz.mongodb.db.MongoConnector;
+import com.netgrif.quartz.mongodb.db.MongoConnectorBuilder;
+import com.netgrif.quartz.mongodb.trigger.MisfireHandler;
+import com.netgrif.quartz.mongodb.trigger.TriggerConverter;
+import com.netgrif.quartz.mongodb.util.Clock;
+import com.netgrif.quartz.mongodb.util.ExpiryCalculator;
+import com.netgrif.quartz.mongodb.util.QueryHelper;
+import com.netgrif.quartz.mongodb.dao.*;
import org.bson.Document;
import org.quartz.SchedulerConfigException;
import org.quartz.spi.ClassLoadHelper;
@@ -42,8 +42,8 @@ public class MongoStoreAssembler {
public void build(MongoDBJobStore jobStore, ClassLoadHelper loadHelper,
SchedulerSignaler signaler, Properties quartzProps)
- throws SchedulerConfigException, ClassNotFoundException,
- IllegalAccessException, InstantiationException {
+ throws SchedulerConfigException, ClassNotFoundException,
+ IllegalAccessException, InstantiationException {
mongoConnector = createMongoConnector(jobStore);
JobDataConverter jobDataConverter = new JobDataConverter(jobStore.isJobDataAsBase64());
@@ -83,17 +83,17 @@ public void build(MongoDBJobStore jobStore, ClassLoadHelper loadHelper,
private CheckinExecutor createCheckinExecutor(MongoDBJobStore jobStore, ClassLoadHelper loadHelper,
Properties quartzProps)
- throws ClassNotFoundException, InstantiationException, IllegalAccessException {
+ throws ClassNotFoundException, InstantiationException, IllegalAccessException {
return new CheckinExecutor(createCheckinTask(jobStore, loadHelper),
jobStore.clusterCheckinIntervalMillis, jobStore.instanceId);
}
private Runnable createCheckinTask(MongoDBJobStore jobStore, ClassLoadHelper loadHelper)
- throws ClassNotFoundException, IllegalAccessException, InstantiationException {
+ throws ClassNotFoundException, IllegalAccessException, InstantiationException {
Runnable errorHandler;
Class aClass;
if (jobStore.getCheckInErrorHandler() == null) {
- // current default, see
+ // TODO: Refactor
aClass = KamikazeErrorHandler.class;
} else {
aClass = loadHelper.loadClass(jobStore.getCheckInErrorHandler());
@@ -121,7 +121,7 @@ private LocksDao createLocksDao(MongoDBJobStore jobStore) {
private LockManager createLockManager(MongoDBJobStore jobStore) {
ExpiryCalculator expiryCalculator = new ExpiryCalculator(schedulerDao,
- Clock.SYSTEM_CLOCK, jobStore.jobTimeoutMillis, jobStore.triggerTimeoutMillis,jobStore.isClustered());
+ Clock.SYSTEM_CLOCK, jobStore.jobTimeoutMillis, jobStore.triggerTimeoutMillis, jobStore.isClustered());
return new LockManager(locksDao, expiryCalculator);
}
diff --git a/src/main/java/com/novemberain/quartz/mongodb/TriggerAndJobPersister.java b/src/main/java/com/netgrif/quartz/mongodb/TriggerAndJobPersister.java
old mode 100644
new mode 100755
similarity index 96%
rename from src/main/java/com/novemberain/quartz/mongodb/TriggerAndJobPersister.java
rename to src/main/java/com/netgrif/quartz/mongodb/TriggerAndJobPersister.java
index cf0e674b..8145a7a4
--- a/src/main/java/com/novemberain/quartz/mongodb/TriggerAndJobPersister.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/TriggerAndJobPersister.java
@@ -1,9 +1,9 @@
-package com.novemberain.quartz.mongodb;
+package com.netgrif.quartz.mongodb;
-import com.novemberain.quartz.mongodb.dao.JobDao;
-import com.novemberain.quartz.mongodb.dao.TriggerDao;
-import com.novemberain.quartz.mongodb.trigger.TriggerConverter;
-import com.novemberain.quartz.mongodb.util.Keys;
+import com.netgrif.quartz.mongodb.dao.JobDao;
+import com.netgrif.quartz.mongodb.dao.TriggerDao;
+import com.netgrif.quartz.mongodb.trigger.TriggerConverter;
+import com.netgrif.quartz.mongodb.util.Keys;
import org.bson.Document;
import org.bson.conversions.Bson;
import org.bson.types.ObjectId;
diff --git a/src/main/java/com/novemberain/quartz/mongodb/TriggerRunner.java b/src/main/java/com/netgrif/quartz/mongodb/TriggerRunner.java
old mode 100644
new mode 100755
similarity index 95%
rename from src/main/java/com/novemberain/quartz/mongodb/TriggerRunner.java
rename to src/main/java/com/netgrif/quartz/mongodb/TriggerRunner.java
index b3411115..a63b0201
--- a/src/main/java/com/novemberain/quartz/mongodb/TriggerRunner.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/TriggerRunner.java
@@ -1,14 +1,14 @@
-package com.novemberain.quartz.mongodb;
+package com.netgrif.quartz.mongodb;
import com.mongodb.MongoException;
import com.mongodb.MongoWriteException;
-import com.novemberain.quartz.mongodb.cluster.TriggerRecoverer;
-import com.novemberain.quartz.mongodb.dao.CalendarDao;
-import com.novemberain.quartz.mongodb.dao.JobDao;
-import com.novemberain.quartz.mongodb.dao.LocksDao;
-import com.novemberain.quartz.mongodb.dao.TriggerDao;
-import com.novemberain.quartz.mongodb.trigger.MisfireHandler;
-import com.novemberain.quartz.mongodb.trigger.TriggerConverter;
+import com.netgrif.quartz.mongodb.cluster.TriggerRecoverer;
+import com.netgrif.quartz.mongodb.dao.CalendarDao;
+import com.netgrif.quartz.mongodb.dao.JobDao;
+import com.netgrif.quartz.mongodb.dao.LocksDao;
+import com.netgrif.quartz.mongodb.dao.TriggerDao;
+import com.netgrif.quartz.mongodb.trigger.MisfireHandler;
+import com.netgrif.quartz.mongodb.trigger.TriggerConverter;
import org.bson.Document;
import org.quartz.*;
import org.quartz.Calendar;
diff --git a/src/main/java/com/novemberain/quartz/mongodb/TriggerStateManager.java b/src/main/java/com/netgrif/quartz/mongodb/TriggerStateManager.java
old mode 100644
new mode 100755
similarity index 92%
rename from src/main/java/com/novemberain/quartz/mongodb/TriggerStateManager.java
rename to src/main/java/com/netgrif/quartz/mongodb/TriggerStateManager.java
index b26a811c..2bb66a9d
--- a/src/main/java/com/novemberain/quartz/mongodb/TriggerStateManager.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/TriggerStateManager.java
@@ -1,12 +1,12 @@
-package com.novemberain.quartz.mongodb;
-
-import com.novemberain.quartz.mongodb.dao.JobDao;
-import com.novemberain.quartz.mongodb.dao.PausedJobGroupsDao;
-import com.novemberain.quartz.mongodb.dao.PausedTriggerGroupsDao;
-import com.novemberain.quartz.mongodb.dao.TriggerDao;
-import com.novemberain.quartz.mongodb.util.GroupHelper;
-import com.novemberain.quartz.mongodb.util.QueryHelper;
-import com.novemberain.quartz.mongodb.util.TriggerGroupHelper;
+package com.netgrif.quartz.mongodb;
+
+import com.netgrif.quartz.mongodb.dao.JobDao;
+import com.netgrif.quartz.mongodb.dao.PausedJobGroupsDao;
+import com.netgrif.quartz.mongodb.dao.PausedTriggerGroupsDao;
+import com.netgrif.quartz.mongodb.dao.TriggerDao;
+import com.netgrif.quartz.mongodb.util.GroupHelper;
+import com.netgrif.quartz.mongodb.util.QueryHelper;
+import com.netgrif.quartz.mongodb.util.TriggerGroupHelper;
import org.bson.types.ObjectId;
import org.quartz.JobKey;
import org.quartz.Trigger.TriggerState;
diff --git a/src/main/java/com/novemberain/quartz/mongodb/clojure/DynamicClassLoadHelper.java b/src/main/java/com/netgrif/quartz/mongodb/clojure/DynamicClassLoadHelper.java
old mode 100644
new mode 100755
similarity index 95%
rename from src/main/java/com/novemberain/quartz/mongodb/clojure/DynamicClassLoadHelper.java
rename to src/main/java/com/netgrif/quartz/mongodb/clojure/DynamicClassLoadHelper.java
index 21bc0a4b..a620700a
--- a/src/main/java/com/novemberain/quartz/mongodb/clojure/DynamicClassLoadHelper.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/clojure/DynamicClassLoadHelper.java
@@ -1,4 +1,4 @@
-package com.novemberain.quartz.mongodb.clojure;
+package com.netgrif.quartz.mongodb.clojure;
import clojure.lang.DynamicClassLoader;
import org.quartz.spi.ClassLoadHelper;
diff --git a/src/main/java/com/novemberain/quartz/mongodb/cluster/CheckinExecutor.java b/src/main/java/com/netgrif/quartz/mongodb/cluster/CheckinExecutor.java
old mode 100644
new mode 100755
similarity index 96%
rename from src/main/java/com/novemberain/quartz/mongodb/cluster/CheckinExecutor.java
rename to src/main/java/com/netgrif/quartz/mongodb/cluster/CheckinExecutor.java
index df8e240d..cf72979c
--- a/src/main/java/com/novemberain/quartz/mongodb/cluster/CheckinExecutor.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/cluster/CheckinExecutor.java
@@ -1,4 +1,4 @@
-package com.novemberain.quartz.mongodb.cluster;
+package com.netgrif.quartz.mongodb.cluster;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/src/main/java/com/netgrif/quartz/mongodb/cluster/CheckinTask.java b/src/main/java/com/netgrif/quartz/mongodb/cluster/CheckinTask.java
new file mode 100755
index 00000000..69421750
--- /dev/null
+++ b/src/main/java/com/netgrif/quartz/mongodb/cluster/CheckinTask.java
@@ -0,0 +1,58 @@
+package com.netgrif.quartz.mongodb.cluster;
+
+import com.mongodb.MongoWriteConcernException;
+import com.netgrif.quartz.mongodb.dao.SchedulerDao;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class CheckinTask implements Runnable {
+
+ private static final Logger log = LoggerFactory.getLogger(CheckinTask.class);
+
+ private SchedulerDao schedulerDao;
+ private Runnable errorHandler;
+ private int retryCount = 0;
+ private static final int MAX_RETRIES = 10;
+ private static final long RETRY_DELAY_MS = 1000;
+
+ public CheckinTask(SchedulerDao schedulerDao, Runnable errorHandler) {
+ this.schedulerDao = schedulerDao;
+ this.errorHandler = errorHandler;
+ }
+
+ public void setErrorHandler(Runnable errorHandler) {
+ this.errorHandler = errorHandler;
+ }
+
+ @Override
+ public void run() {
+ try {
+ schedulerDao.checkIn();
+ retryCount = 0;
+ } catch (MongoWriteConcernException e) {
+ handleWriteConcernException(e);
+ } catch (Exception e) {
+ log.error("Unexpected error during check-in: " + e.getMessage(), e);
+ //errorHandler.run(); //TODO: ups..
+ }
+ }
+
+ private void handleWriteConcernException(MongoWriteConcernException e) {
+ if (retryCount < MAX_RETRIES) {
+ log.warn("WriteConcernException occurred, retrying check-in... Attempt: " + (retryCount + 1));
+ try {
+ Thread.sleep(RETRY_DELAY_MS * retryCount);
+ retryCount++;
+ run();
+ } catch (InterruptedException ie) {
+ Thread.currentThread().interrupt();
+ log.error("Thread interrupted during retry delay", ie);
+ } catch (Exception ee) {
+ log.error("Hups..." +ee.getMessage() , ee);
+ }
+ } else {
+ log.error("Maximum number of attempts reached. Unable to complete check-in.", e);
+ errorHandler.run();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/com/novemberain/quartz/mongodb/cluster/KamikazeErrorHandler.java b/src/main/java/com/netgrif/quartz/mongodb/cluster/KamikazeErrorHandler.java
old mode 100644
new mode 100755
similarity index 90%
rename from src/main/java/com/novemberain/quartz/mongodb/cluster/KamikazeErrorHandler.java
rename to src/main/java/com/netgrif/quartz/mongodb/cluster/KamikazeErrorHandler.java
index be33d727..ddfaac71
--- a/src/main/java/com/novemberain/quartz/mongodb/cluster/KamikazeErrorHandler.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/cluster/KamikazeErrorHandler.java
@@ -1,4 +1,4 @@
-package com.novemberain.quartz.mongodb.cluster;
+package com.netgrif.quartz.mongodb.cluster;
/**
* This implementation pauses Quartz to not allow to execute the same JOB by two schedulers.
diff --git a/src/main/java/com/novemberain/quartz/mongodb/cluster/NoOpErrorHandler.java b/src/main/java/com/netgrif/quartz/mongodb/cluster/NoOpErrorHandler.java
old mode 100644
new mode 100755
similarity index 68%
rename from src/main/java/com/novemberain/quartz/mongodb/cluster/NoOpErrorHandler.java
rename to src/main/java/com/netgrif/quartz/mongodb/cluster/NoOpErrorHandler.java
index 9b4481d2..eb8128ed
--- a/src/main/java/com/novemberain/quartz/mongodb/cluster/NoOpErrorHandler.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/cluster/NoOpErrorHandler.java
@@ -1,4 +1,4 @@
-package com.novemberain.quartz.mongodb.cluster;
+package com.netgrif.quartz.mongodb.cluster;
public class NoOpErrorHandler implements Runnable {
@Override
diff --git a/src/main/java/com/novemberain/quartz/mongodb/cluster/RecoveryTriggerFactory.java b/src/main/java/com/netgrif/quartz/mongodb/cluster/RecoveryTriggerFactory.java
old mode 100644
new mode 100755
similarity index 97%
rename from src/main/java/com/novemberain/quartz/mongodb/cluster/RecoveryTriggerFactory.java
rename to src/main/java/com/netgrif/quartz/mongodb/cluster/RecoveryTriggerFactory.java
index 681f7135..25354f92
--- a/src/main/java/com/novemberain/quartz/mongodb/cluster/RecoveryTriggerFactory.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/cluster/RecoveryTriggerFactory.java
@@ -1,13 +1,12 @@
-package com.novemberain.quartz.mongodb.cluster;
+package com.netgrif.quartz.mongodb.cluster;
import org.quartz.JobDataMap;
import org.quartz.JobKey;
-import org.quartz.Scheduler;
import org.quartz.SimpleTrigger;
import org.quartz.TriggerKey;
import org.quartz.impl.triggers.SimpleTriggerImpl;
import org.quartz.spi.OperableTrigger;
-
+import org.quartz.Scheduler;
import java.util.Date;
public class RecoveryTriggerFactory {
diff --git a/src/main/java/com/novemberain/quartz/mongodb/cluster/Scheduler.java b/src/main/java/com/netgrif/quartz/mongodb/cluster/Scheduler.java
old mode 100644
new mode 100755
similarity index 95%
rename from src/main/java/com/novemberain/quartz/mongodb/cluster/Scheduler.java
rename to src/main/java/com/netgrif/quartz/mongodb/cluster/Scheduler.java
index 2f007a8a..072ce715
--- a/src/main/java/com/novemberain/quartz/mongodb/cluster/Scheduler.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/cluster/Scheduler.java
@@ -1,4 +1,4 @@
-package com.novemberain.quartz.mongodb.cluster;
+package com.netgrif.quartz.mongodb.cluster;
public class Scheduler {
diff --git a/src/main/java/com/novemberain/quartz/mongodb/cluster/TriggerRecoverer.java b/src/main/java/com/netgrif/quartz/mongodb/cluster/TriggerRecoverer.java
old mode 100644
new mode 100755
similarity index 91%
rename from src/main/java/com/novemberain/quartz/mongodb/cluster/TriggerRecoverer.java
rename to src/main/java/com/netgrif/quartz/mongodb/cluster/TriggerRecoverer.java
index d73685a4..5ff9fa7b
--- a/src/main/java/com/novemberain/quartz/mongodb/cluster/TriggerRecoverer.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/cluster/TriggerRecoverer.java
@@ -1,11 +1,11 @@
-package com.novemberain.quartz.mongodb.cluster;
+package com.netgrif.quartz.mongodb.cluster;
-import com.novemberain.quartz.mongodb.LockManager;
-import com.novemberain.quartz.mongodb.TriggerAndJobPersister;
-import com.novemberain.quartz.mongodb.dao.JobDao;
-import com.novemberain.quartz.mongodb.dao.LocksDao;
-import com.novemberain.quartz.mongodb.dao.TriggerDao;
-import com.novemberain.quartz.mongodb.trigger.MisfireHandler;
+import com.netgrif.quartz.mongodb.LockManager;
+import com.netgrif.quartz.mongodb.TriggerAndJobPersister;
+import com.netgrif.quartz.mongodb.dao.JobDao;
+import com.netgrif.quartz.mongodb.dao.LocksDao;
+import com.netgrif.quartz.mongodb.dao.TriggerDao;
+import com.netgrif.quartz.mongodb.trigger.MisfireHandler;
import org.quartz.JobPersistenceException;
import org.quartz.TriggerKey;
import org.quartz.spi.OperableTrigger;
diff --git a/src/main/java/com/novemberain/quartz/mongodb/dao/CalendarDao.java b/src/main/java/com/netgrif/quartz/mongodb/dao/CalendarDao.java
old mode 100644
new mode 100755
similarity index 96%
rename from src/main/java/com/novemberain/quartz/mongodb/dao/CalendarDao.java
rename to src/main/java/com/netgrif/quartz/mongodb/dao/CalendarDao.java
index 42043c40..e5e1bcf0
--- a/src/main/java/com/novemberain/quartz/mongodb/dao/CalendarDao.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/dao/CalendarDao.java
@@ -1,17 +1,16 @@
-package com.novemberain.quartz.mongodb.dao;
+package com.netgrif.quartz.mongodb.dao;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.model.Filters;
+import com.mongodb.client.model.IndexOptions;
+import com.mongodb.client.model.Projections;
+import com.netgrif.quartz.mongodb.util.SerialUtils;
import org.bson.Document;
import org.bson.conversions.Bson;
import org.bson.types.Binary;
import org.quartz.Calendar;
import org.quartz.JobPersistenceException;
-import com.mongodb.client.MongoCollection;
-import com.mongodb.client.model.Filters;
-import com.mongodb.client.model.IndexOptions;
-import com.mongodb.client.model.Projections;
-import com.novemberain.quartz.mongodb.util.SerialUtils;
-
import java.util.LinkedList;
import java.util.List;
diff --git a/src/main/java/com/novemberain/quartz/mongodb/dao/JobDao.java b/src/main/java/com/netgrif/quartz/mongodb/dao/JobDao.java
old mode 100644
new mode 100755
similarity index 91%
rename from src/main/java/com/novemberain/quartz/mongodb/dao/JobDao.java
rename to src/main/java/com/netgrif/quartz/mongodb/dao/JobDao.java
index 9771cadb..9ab6b7df
--- a/src/main/java/com/novemberain/quartz/mongodb/dao/JobDao.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/dao/JobDao.java
@@ -1,14 +1,14 @@
-package com.novemberain.quartz.mongodb.dao;
+package com.netgrif.quartz.mongodb.dao;
import com.mongodb.MongoWriteException;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.model.Filters;
import com.mongodb.client.model.IndexOptions;
import com.mongodb.client.result.DeleteResult;
-import com.novemberain.quartz.mongodb.JobConverter;
-import com.novemberain.quartz.mongodb.util.GroupHelper;
-import com.novemberain.quartz.mongodb.util.Keys;
-import com.novemberain.quartz.mongodb.util.QueryHelper;
+import com.netgrif.quartz.mongodb.JobConverter;
+import com.netgrif.quartz.mongodb.util.GroupHelper;
+import com.netgrif.quartz.mongodb.util.Keys;
+import com.netgrif.quartz.mongodb.util.QueryHelper;
import org.bson.Document;
import org.bson.conversions.Bson;
import org.bson.types.ObjectId;
@@ -19,8 +19,8 @@
import java.util.*;
-import static com.novemberain.quartz.mongodb.util.Keys.KEY_GROUP;
-import static com.novemberain.quartz.mongodb.util.Keys.toFilter;
+import static com.netgrif.quartz.mongodb.util.Keys.KEY_GROUP;
+import static com.netgrif.quartz.mongodb.util.Keys.toFilter;
public class JobDao {
diff --git a/src/main/java/com/novemberain/quartz/mongodb/dao/LocksDao.java b/src/main/java/com/netgrif/quartz/mongodb/dao/LocksDao.java
old mode 100644
new mode 100755
similarity index 96%
rename from src/main/java/com/novemberain/quartz/mongodb/dao/LocksDao.java
rename to src/main/java/com/netgrif/quartz/mongodb/dao/LocksDao.java
index 6e2caab0..8ba80188
--- a/src/main/java/com/novemberain/quartz/mongodb/dao/LocksDao.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/dao/LocksDao.java
@@ -1,4 +1,4 @@
-package com.novemberain.quartz.mongodb.dao;
+package com.netgrif.quartz.mongodb.dao;
import com.mongodb.MongoException;
import com.mongodb.client.MongoCollection;
@@ -6,7 +6,7 @@
import com.mongodb.client.model.IndexOptions;
import com.mongodb.client.model.Projections;
import com.mongodb.client.result.UpdateResult;
-import com.novemberain.quartz.mongodb.util.Clock;
+import com.netgrif.quartz.mongodb.util.Clock;
import org.bson.Document;
import org.bson.conversions.Bson;
import org.quartz.JobDetail;
@@ -21,8 +21,8 @@
import java.util.LinkedList;
import java.util.List;
-import static com.novemberain.quartz.mongodb.Constants.LOCK_INSTANCE_ID;
-import static com.novemberain.quartz.mongodb.util.Keys.*;
+import static com.netgrif.quartz.mongodb.Constants.LOCK_INSTANCE_ID;
+import static com.netgrif.quartz.mongodb.util.Keys.*;
public class LocksDao {
@@ -104,6 +104,7 @@ public void lockTrigger(TriggerKey key) {
* @return false when not found or caught an exception
*/
public boolean relock(TriggerKey key, Date lockTime) {
+ key = key;
UpdateResult updateResult;
try {
updateResult = locksCollection.updateOne(
diff --git a/src/main/java/com/novemberain/quartz/mongodb/dao/PausedJobGroupsDao.java b/src/main/java/com/netgrif/quartz/mongodb/dao/PausedJobGroupsDao.java
old mode 100644
new mode 100755
similarity index 91%
rename from src/main/java/com/novemberain/quartz/mongodb/dao/PausedJobGroupsDao.java
rename to src/main/java/com/netgrif/quartz/mongodb/dao/PausedJobGroupsDao.java
index a873bd4a..0da76b68
--- a/src/main/java/com/novemberain/quartz/mongodb/dao/PausedJobGroupsDao.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/dao/PausedJobGroupsDao.java
@@ -1,4 +1,4 @@
-package com.novemberain.quartz.mongodb.dao;
+package com.netgrif.quartz.mongodb.dao;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.model.Filters;
@@ -9,7 +9,7 @@
import java.util.HashSet;
import java.util.List;
-import static com.novemberain.quartz.mongodb.util.Keys.KEY_GROUP;
+import static com.netgrif.quartz.mongodb.util.Keys.KEY_GROUP;
public class PausedJobGroupsDao {
diff --git a/src/main/java/com/novemberain/quartz/mongodb/dao/PausedTriggerGroupsDao.java b/src/main/java/com/netgrif/quartz/mongodb/dao/PausedTriggerGroupsDao.java
old mode 100644
new mode 100755
similarity index 91%
rename from src/main/java/com/novemberain/quartz/mongodb/dao/PausedTriggerGroupsDao.java
rename to src/main/java/com/netgrif/quartz/mongodb/dao/PausedTriggerGroupsDao.java
index 1dde3935..0d29e762
--- a/src/main/java/com/novemberain/quartz/mongodb/dao/PausedTriggerGroupsDao.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/dao/PausedTriggerGroupsDao.java
@@ -1,4 +1,4 @@
-package com.novemberain.quartz.mongodb.dao;
+package com.netgrif.quartz.mongodb.dao;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.model.Filters;
@@ -9,7 +9,7 @@
import java.util.HashSet;
import java.util.List;
-import static com.novemberain.quartz.mongodb.util.Keys.KEY_GROUP;
+import static com.netgrif.quartz.mongodb.util.Keys.KEY_GROUP;
public class PausedTriggerGroupsDao {
diff --git a/src/main/java/com/novemberain/quartz/mongodb/dao/SchedulerDao.java b/src/main/java/com/netgrif/quartz/mongodb/dao/SchedulerDao.java
old mode 100644
new mode 100755
similarity index 93%
rename from src/main/java/com/novemberain/quartz/mongodb/dao/SchedulerDao.java
rename to src/main/java/com/netgrif/quartz/mongodb/dao/SchedulerDao.java
index 2ab3b299..421dff47
--- a/src/main/java/com/novemberain/quartz/mongodb/dao/SchedulerDao.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/dao/SchedulerDao.java
@@ -1,11 +1,14 @@
-package com.novemberain.quartz.mongodb.dao;
+package com.netgrif.quartz.mongodb.dao;
import com.mongodb.client.MongoCollection;
-import com.mongodb.client.model.*;
+import com.mongodb.client.model.Filters;
+import com.mongodb.client.model.IndexOptions;
+import com.mongodb.client.model.Projections;
+import com.mongodb.client.model.UpdateOptions;
import com.mongodb.client.result.DeleteResult;
import com.mongodb.client.result.UpdateResult;
-import com.novemberain.quartz.mongodb.cluster.Scheduler;
-import com.novemberain.quartz.mongodb.util.Clock;
+import com.netgrif.quartz.mongodb.cluster.Scheduler;
+import com.netgrif.quartz.mongodb.util.Clock;
import org.bson.Document;
import org.bson.conversions.Bson;
import org.slf4j.Logger;
@@ -61,7 +64,7 @@ public void createIndex() {
public void checkIn() {
long lastCheckinTime = clock.millis();
- log.debug("Saving node data: name='{}', id='{}', checkin time={}, interval={}",
+ log.debug("Saving node data: name='{}', id='{}', checkin time={}, interval={}",
schedulerName, instanceId, lastCheckinTime, clusterCheckinIntervalMillis);
// If not found Mongo will create a new entry with content from filter and update.
diff --git a/src/main/java/com/novemberain/quartz/mongodb/dao/TriggerDao.java b/src/main/java/com/netgrif/quartz/mongodb/dao/TriggerDao.java
old mode 100644
new mode 100755
similarity index 93%
rename from src/main/java/com/novemberain/quartz/mongodb/dao/TriggerDao.java
rename to src/main/java/com/netgrif/quartz/mongodb/dao/TriggerDao.java
index e20067e9..de5b4dc0
--- a/src/main/java/com/novemberain/quartz/mongodb/dao/TriggerDao.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/dao/TriggerDao.java
@@ -1,4 +1,4 @@
-package com.novemberain.quartz.mongodb.dao;
+package com.netgrif.quartz.mongodb.dao;
import com.mongodb.MongoWriteException;
import com.mongodb.client.FindIterable;
@@ -7,10 +7,10 @@
import com.mongodb.client.model.IndexOptions;
import com.mongodb.client.model.ReplaceOptions;
import com.mongodb.client.model.UpdateOptions;
-import com.novemberain.quartz.mongodb.Constants;
-import com.novemberain.quartz.mongodb.trigger.TriggerConverter;
-import com.novemberain.quartz.mongodb.util.Keys;
-import com.novemberain.quartz.mongodb.util.QueryHelper;
+import com.netgrif.quartz.mongodb.Constants;
+import com.netgrif.quartz.mongodb.trigger.TriggerConverter;
+import com.netgrif.quartz.mongodb.util.Keys;
+import com.netgrif.quartz.mongodb.util.QueryHelper;
import org.bson.Document;
import org.bson.conversions.Bson;
import org.bson.types.ObjectId;
@@ -23,16 +23,11 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
import static com.mongodb.client.model.Sorts.ascending;
-import static com.novemberain.quartz.mongodb.util.Keys.KEY_GROUP;
-import static com.novemberain.quartz.mongodb.util.Keys.toFilter;
+import static com.netgrif.quartz.mongodb.util.Keys.KEY_GROUP;
+import static com.netgrif.quartz.mongodb.util.Keys.toFilter;
public class TriggerDao {
diff --git a/src/main/java/com/novemberain/quartz/mongodb/db/ExternalMongoConnector.java b/src/main/java/com/netgrif/quartz/mongodb/db/ExternalMongoConnector.java
old mode 100644
new mode 100755
similarity index 85%
rename from src/main/java/com/novemberain/quartz/mongodb/db/ExternalMongoConnector.java
rename to src/main/java/com/netgrif/quartz/mongodb/db/ExternalMongoConnector.java
index f37a187d..94c81a3f
--- a/src/main/java/com/novemberain/quartz/mongodb/db/ExternalMongoConnector.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/db/ExternalMongoConnector.java
@@ -1,16 +1,21 @@
-package com.novemberain.quartz.mongodb.db;
+package com.netgrif.quartz.mongodb.db;
import com.mongodb.WriteConcern;
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import org.bson.Document;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* The implementation of {@link MongoConnector} that doesn't own the lifecycle of {@link MongoClient}.
*/
public class ExternalMongoConnector implements MongoConnector {
+
+ private static final Logger log = LoggerFactory.getLogger(ExternalMongoConnector.class);
+
private final WriteConcern writeConcern;
private final MongoDatabase database;
@@ -26,6 +31,10 @@ public ExternalMongoConnector(final WriteConcern writeConcern, final MongoDataba
this.writeConcern = writeConcern;
}
+ public ExternalMongoConnector(MongoClient mongoClient, String dbName) {
+ this(WriteConcern.W1, mongoClient.getDatabase(dbName));
+ }
+
/**
* Constructs an instance of {@link ExternalMongoConnector}.
*
diff --git a/src/main/java/com/novemberain/quartz/mongodb/db/InternalMongoConnector.java b/src/main/java/com/netgrif/quartz/mongodb/db/InternalMongoConnector.java
old mode 100644
new mode 100755
similarity index 99%
rename from src/main/java/com/novemberain/quartz/mongodb/db/InternalMongoConnector.java
rename to src/main/java/com/netgrif/quartz/mongodb/db/InternalMongoConnector.java
index 7c5a9f41..05d121f1
--- a/src/main/java/com/novemberain/quartz/mongodb/db/InternalMongoConnector.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/db/InternalMongoConnector.java
@@ -1,4 +1,4 @@
-package com.novemberain.quartz.mongodb.db;
+package com.netgrif.quartz.mongodb.db;
import com.mongodb.*;
import com.mongodb.client.MongoClient;
diff --git a/src/main/java/com/novemberain/quartz/mongodb/db/MongoConnector.java b/src/main/java/com/netgrif/quartz/mongodb/db/MongoConnector.java
old mode 100644
new mode 100755
similarity index 95%
rename from src/main/java/com/novemberain/quartz/mongodb/db/MongoConnector.java
rename to src/main/java/com/netgrif/quartz/mongodb/db/MongoConnector.java
index a3273f81..4c444ed6
--- a/src/main/java/com/novemberain/quartz/mongodb/db/MongoConnector.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/db/MongoConnector.java
@@ -1,4 +1,4 @@
-package com.novemberain.quartz.mongodb.db;
+package com.netgrif.quartz.mongodb.db;
import com.mongodb.WriteConcern;
import com.mongodb.client.MongoClient;
diff --git a/src/main/java/com/novemberain/quartz/mongodb/db/MongoConnectorBuilder.java b/src/main/java/com/netgrif/quartz/mongodb/db/MongoConnectorBuilder.java
old mode 100644
new mode 100755
similarity index 99%
rename from src/main/java/com/novemberain/quartz/mongodb/db/MongoConnectorBuilder.java
rename to src/main/java/com/netgrif/quartz/mongodb/db/MongoConnectorBuilder.java
index a8550453..6dffd541
--- a/src/main/java/com/novemberain/quartz/mongodb/db/MongoConnectorBuilder.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/db/MongoConnectorBuilder.java
@@ -1,19 +1,18 @@
-package com.novemberain.quartz.mongodb.db;
+package com.netgrif.quartz.mongodb.db;
import com.mongodb.*;
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoDatabase;
import org.quartz.SchedulerConfigException;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLException;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLException;
-
/**
* Builder for {@link MongoConnector}.
*/
@@ -79,7 +78,7 @@ public MongoConnector build() throws SchedulerConfigException {
if (database != null) {
// User passed MongoDatabase instance.
validateForDatabase();
- return new ExternalMongoConnector(writeConcern, database);
+ return new ExternalMongoConnector(writeConcern, database); //TODO: init edit
}
// Options below require database name
diff --git a/src/main/java/com/novemberain/quartz/mongodb/db/SSLContextFactory.java b/src/main/java/com/netgrif/quartz/mongodb/db/SSLContextFactory.java
old mode 100644
new mode 100755
similarity index 98%
rename from src/main/java/com/novemberain/quartz/mongodb/db/SSLContextFactory.java
rename to src/main/java/com/netgrif/quartz/mongodb/db/SSLContextFactory.java
index 4702f70e..5b94a054
--- a/src/main/java/com/novemberain/quartz/mongodb/db/SSLContextFactory.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/db/SSLContextFactory.java
@@ -1,5 +1,11 @@
-package com.novemberain.quartz.mongodb.db;
+package com.netgrif.quartz.mongodb.db;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.http.ssl.SSLContextBuilder;
+import org.apache.http.ssl.SSLContexts;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
@@ -7,13 +13,6 @@
import java.security.GeneralSecurityException;
import java.security.KeyStore;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLException;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.http.ssl.SSLContextBuilder;
-import org.apache.http.ssl.SSLContexts;
-
/**
* Allows to get an {@link SSLContext} from a Java truststore and keystore.
*/
diff --git a/src/main/java/com/novemberain/quartz/mongodb/trigger/MisfireHandler.java b/src/main/java/com/netgrif/quartz/mongodb/trigger/MisfireHandler.java
old mode 100644
new mode 100755
similarity index 96%
rename from src/main/java/com/novemberain/quartz/mongodb/trigger/MisfireHandler.java
rename to src/main/java/com/netgrif/quartz/mongodb/trigger/MisfireHandler.java
index 02480e04..54d516b0
--- a/src/main/java/com/novemberain/quartz/mongodb/trigger/MisfireHandler.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/trigger/MisfireHandler.java
@@ -1,6 +1,6 @@
-package com.novemberain.quartz.mongodb.trigger;
+package com.netgrif.quartz.mongodb.trigger;
-import com.novemberain.quartz.mongodb.dao.CalendarDao;
+import com.netgrif.quartz.mongodb.dao.CalendarDao;
import org.quartz.Calendar;
import org.quartz.JobPersistenceException;
import org.quartz.Trigger;
diff --git a/src/main/java/com/novemberain/quartz/mongodb/trigger/TriggerConverter.java b/src/main/java/com/netgrif/quartz/mongodb/trigger/TriggerConverter.java
old mode 100644
new mode 100755
similarity index 95%
rename from src/main/java/com/novemberain/quartz/mongodb/trigger/TriggerConverter.java
rename to src/main/java/com/netgrif/quartz/mongodb/trigger/TriggerConverter.java
index f60e0254..f6b99cac
--- a/src/main/java/com/novemberain/quartz/mongodb/trigger/TriggerConverter.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/trigger/TriggerConverter.java
@@ -1,9 +1,8 @@
-package com.novemberain.quartz.mongodb.trigger;
+package com.netgrif.quartz.mongodb.trigger;
-import com.novemberain.quartz.mongodb.Constants;
-import com.novemberain.quartz.mongodb.JobDataConverter;
-import com.novemberain.quartz.mongodb.dao.JobDao;
-import com.novemberain.quartz.mongodb.dao.TriggerDao;
+import com.netgrif.quartz.mongodb.Constants;
+import com.netgrif.quartz.mongodb.JobDataConverter;
+import com.netgrif.quartz.mongodb.dao.JobDao;
import org.bson.Document;
import org.bson.types.ObjectId;
import org.quartz.Job;
@@ -14,8 +13,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static com.novemberain.quartz.mongodb.util.Keys.KEY_GROUP;
-import static com.novemberain.quartz.mongodb.util.Keys.KEY_NAME;
+import static com.netgrif.quartz.mongodb.util.Keys.KEY_GROUP;
+import static com.netgrif.quartz.mongodb.util.Keys.KEY_NAME;
public class TriggerConverter {
diff --git a/src/main/java/com/novemberain/quartz/mongodb/trigger/TriggerPropertiesConverter.java b/src/main/java/com/netgrif/quartz/mongodb/trigger/TriggerPropertiesConverter.java
old mode 100644
new mode 100755
similarity index 75%
rename from src/main/java/com/novemberain/quartz/mongodb/trigger/TriggerPropertiesConverter.java
rename to src/main/java/com/netgrif/quartz/mongodb/trigger/TriggerPropertiesConverter.java
index 219f6d10..bec1adab
--- a/src/main/java/com/novemberain/quartz/mongodb/trigger/TriggerPropertiesConverter.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/trigger/TriggerPropertiesConverter.java
@@ -1,9 +1,9 @@
-package com.novemberain.quartz.mongodb.trigger;
+package com.netgrif.quartz.mongodb.trigger;
-import com.novemberain.quartz.mongodb.trigger.properties.CalendarIntervalTriggerPropertiesConverter;
-import com.novemberain.quartz.mongodb.trigger.properties.CronTriggerPropertiesConverter;
-import com.novemberain.quartz.mongodb.trigger.properties.DailyTimeIntervalTriggerPropertiesConverter;
-import com.novemberain.quartz.mongodb.trigger.properties.SimpleTriggerPropertiesConverter;
+import com.netgrif.quartz.mongodb.trigger.properties.CalendarIntervalTriggerPropertiesConverter;
+import com.netgrif.quartz.mongodb.trigger.properties.CronTriggerPropertiesConverter;
+import com.netgrif.quartz.mongodb.trigger.properties.DailyTimeIntervalTriggerPropertiesConverter;
+import com.netgrif.quartz.mongodb.trigger.properties.SimpleTriggerPropertiesConverter;
import org.bson.Document;
import org.quartz.spi.OperableTrigger;
diff --git a/src/main/java/com/novemberain/quartz/mongodb/trigger/properties/CalendarIntervalTriggerPropertiesConverter.java b/src/main/java/com/netgrif/quartz/mongodb/trigger/properties/CalendarIntervalTriggerPropertiesConverter.java
old mode 100644
new mode 100755
similarity index 93%
rename from src/main/java/com/novemberain/quartz/mongodb/trigger/properties/CalendarIntervalTriggerPropertiesConverter.java
rename to src/main/java/com/netgrif/quartz/mongodb/trigger/properties/CalendarIntervalTriggerPropertiesConverter.java
index 6895deb0..7143b6eb
--- a/src/main/java/com/novemberain/quartz/mongodb/trigger/properties/CalendarIntervalTriggerPropertiesConverter.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/trigger/properties/CalendarIntervalTriggerPropertiesConverter.java
@@ -1,6 +1,6 @@
-package com.novemberain.quartz.mongodb.trigger.properties;
+package com.netgrif.quartz.mongodb.trigger.properties;
-import com.novemberain.quartz.mongodb.trigger.TriggerPropertiesConverter;
+import com.netgrif.quartz.mongodb.trigger.TriggerPropertiesConverter;
import org.bson.Document;
import org.quartz.DateBuilder.IntervalUnit;
import org.quartz.impl.triggers.CalendarIntervalTriggerImpl;
diff --git a/src/main/java/com/novemberain/quartz/mongodb/trigger/properties/CronTriggerPropertiesConverter.java b/src/main/java/com/netgrif/quartz/mongodb/trigger/properties/CronTriggerPropertiesConverter.java
old mode 100644
new mode 100755
similarity index 92%
rename from src/main/java/com/novemberain/quartz/mongodb/trigger/properties/CronTriggerPropertiesConverter.java
rename to src/main/java/com/netgrif/quartz/mongodb/trigger/properties/CronTriggerPropertiesConverter.java
index e751499d..c7e846f0
--- a/src/main/java/com/novemberain/quartz/mongodb/trigger/properties/CronTriggerPropertiesConverter.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/trigger/properties/CronTriggerPropertiesConverter.java
@@ -1,6 +1,6 @@
-package com.novemberain.quartz.mongodb.trigger.properties;
+package com.netgrif.quartz.mongodb.trigger.properties;
-import com.novemberain.quartz.mongodb.trigger.TriggerPropertiesConverter;
+import com.netgrif.quartz.mongodb.trigger.TriggerPropertiesConverter;
import org.bson.Document;
import org.quartz.CronExpression;
import org.quartz.CronTrigger;
diff --git a/src/main/java/com/novemberain/quartz/mongodb/trigger/properties/DailyTimeIntervalTriggerPropertiesConverter.java b/src/main/java/com/netgrif/quartz/mongodb/trigger/properties/DailyTimeIntervalTriggerPropertiesConverter.java
old mode 100644
new mode 100755
similarity index 95%
rename from src/main/java/com/novemberain/quartz/mongodb/trigger/properties/DailyTimeIntervalTriggerPropertiesConverter.java
rename to src/main/java/com/netgrif/quartz/mongodb/trigger/properties/DailyTimeIntervalTriggerPropertiesConverter.java
index 965dad08..2014c7be
--- a/src/main/java/com/novemberain/quartz/mongodb/trigger/properties/DailyTimeIntervalTriggerPropertiesConverter.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/trigger/properties/DailyTimeIntervalTriggerPropertiesConverter.java
@@ -1,17 +1,16 @@
-package com.novemberain.quartz.mongodb.trigger.properties;
+package com.netgrif.quartz.mongodb.trigger.properties;
-import com.novemberain.quartz.mongodb.trigger.TriggerPropertiesConverter;
+import com.netgrif.quartz.mongodb.trigger.TriggerPropertiesConverter;
import org.bson.Document;
import org.quartz.DailyTimeIntervalTrigger;
+import org.quartz.DateBuilder;
import org.quartz.TimeOfDay;
import org.quartz.impl.triggers.DailyTimeIntervalTriggerImpl;
import org.quartz.spi.OperableTrigger;
-import org.quartz.DateBuilder;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
-import java.util.Set;
public class DailyTimeIntervalTriggerPropertiesConverter extends TriggerPropertiesConverter {
diff --git a/src/main/java/com/novemberain/quartz/mongodb/trigger/properties/SimpleTriggerPropertiesConverter.java b/src/main/java/com/netgrif/quartz/mongodb/trigger/properties/SimpleTriggerPropertiesConverter.java
old mode 100644
new mode 100755
similarity index 93%
rename from src/main/java/com/novemberain/quartz/mongodb/trigger/properties/SimpleTriggerPropertiesConverter.java
rename to src/main/java/com/netgrif/quartz/mongodb/trigger/properties/SimpleTriggerPropertiesConverter.java
index d973dc29..3fce5e79
--- a/src/main/java/com/novemberain/quartz/mongodb/trigger/properties/SimpleTriggerPropertiesConverter.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/trigger/properties/SimpleTriggerPropertiesConverter.java
@@ -1,6 +1,6 @@
-package com.novemberain.quartz.mongodb.trigger.properties;
+package com.netgrif.quartz.mongodb.trigger.properties;
-import com.novemberain.quartz.mongodb.trigger.TriggerPropertiesConverter;
+import com.netgrif.quartz.mongodb.trigger.TriggerPropertiesConverter;
import org.bson.Document;
import org.quartz.SimpleTrigger;
import org.quartz.impl.triggers.SimpleTriggerImpl;
diff --git a/src/main/java/com/novemberain/quartz/mongodb/util/Clock.java b/src/main/java/com/netgrif/quartz/mongodb/util/Clock.java
old mode 100644
new mode 100755
similarity index 93%
rename from src/main/java/com/novemberain/quartz/mongodb/util/Clock.java
rename to src/main/java/com/netgrif/quartz/mongodb/util/Clock.java
index 990c2de2..e3f7d032
--- a/src/main/java/com/novemberain/quartz/mongodb/util/Clock.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/util/Clock.java
@@ -1,4 +1,4 @@
-package com.novemberain.quartz.mongodb.util;
+package com.netgrif.quartz.mongodb.util;
import java.util.Date;
diff --git a/src/main/java/com/novemberain/quartz/mongodb/util/ExpiryCalculator.java b/src/main/java/com/netgrif/quartz/mongodb/util/ExpiryCalculator.java
old mode 100644
new mode 100755
similarity index 88%
rename from src/main/java/com/novemberain/quartz/mongodb/util/ExpiryCalculator.java
rename to src/main/java/com/netgrif/quartz/mongodb/util/ExpiryCalculator.java
index 9774ddac..4d4a650e
--- a/src/main/java/com/novemberain/quartz/mongodb/util/ExpiryCalculator.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/util/ExpiryCalculator.java
@@ -1,8 +1,8 @@
-package com.novemberain.quartz.mongodb.util;
+package com.netgrif.quartz.mongodb.util;
-import com.novemberain.quartz.mongodb.Constants;
-import com.novemberain.quartz.mongodb.cluster.Scheduler;
-import com.novemberain.quartz.mongodb.dao.SchedulerDao;
+import com.netgrif.quartz.mongodb.Constants;
+import com.netgrif.quartz.mongodb.cluster.Scheduler;
+import com.netgrif.quartz.mongodb.dao.SchedulerDao;
import org.bson.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -25,7 +25,7 @@ public ExpiryCalculator(SchedulerDao schedulerDao, Clock clock,
this.clock = clock;
this.jobTimeoutMillis = jobTimeoutMillis;
this.triggerTimeoutMillis = triggerTimeoutMillis;
- this.isClustered = isClustered;
+ this.isClustered = isClustered; //TODO: tak to je na hovienko...
}
public boolean isJobLockExpired(Document lock) {
diff --git a/src/main/java/com/novemberain/quartz/mongodb/util/GroupHelper.java b/src/main/java/com/netgrif/quartz/mongodb/util/GroupHelper.java
old mode 100644
new mode 100755
similarity index 79%
rename from src/main/java/com/novemberain/quartz/mongodb/util/GroupHelper.java
rename to src/main/java/com/netgrif/quartz/mongodb/util/GroupHelper.java
index f1d69f29..82dfeeeb
--- a/src/main/java/com/novemberain/quartz/mongodb/util/GroupHelper.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/util/GroupHelper.java
@@ -1,4 +1,4 @@
-package com.novemberain.quartz.mongodb.util;
+package com.netgrif.quartz.mongodb.util;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.model.Filters;
@@ -11,7 +11,6 @@
import java.util.List;
import java.util.Set;
-import static com.novemberain.quartz.mongodb.util.Keys.KEY_GROUP;
public class GroupHelper {
protected MongoCollection collection;
@@ -25,20 +24,20 @@ public GroupHelper(MongoCollection collection, QueryHelper queryHelper
public Set groupsThatMatch(GroupMatcher> matcher) {
Bson filter = queryHelper.matchingKeysConditionFor(matcher);
return collection
- .distinct(KEY_GROUP, String.class)
+ .distinct(Keys.KEY_GROUP, String.class)
.filter(filter)
.into(new HashSet());
}
public List inGroupsThatMatch(GroupMatcher> matcher) {
return collection
- .find(Filters.in(KEY_GROUP, groupsThatMatch(matcher)))
+ .find(Filters.in(Keys.KEY_GROUP, groupsThatMatch(matcher)))
.into(new LinkedList());
}
public Set allGroups() {
return collection
- .distinct(KEY_GROUP, String.class)
+ .distinct(Keys.KEY_GROUP, String.class)
.into(new HashSet());
}
}
diff --git a/src/main/java/com/novemberain/quartz/mongodb/util/Keys.java b/src/main/java/com/netgrif/quartz/mongodb/util/Keys.java
old mode 100644
new mode 100755
similarity index 97%
rename from src/main/java/com/novemberain/quartz/mongodb/util/Keys.java
rename to src/main/java/com/netgrif/quartz/mongodb/util/Keys.java
index d79c3d48..18a5c091
--- a/src/main/java/com/novemberain/quartz/mongodb/util/Keys.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/util/Keys.java
@@ -1,8 +1,8 @@
-package com.novemberain.quartz.mongodb.util;
+package com.netgrif.quartz.mongodb.util;
import com.mongodb.client.model.Filters;
import com.mongodb.client.model.Projections;
-import com.novemberain.quartz.mongodb.Constants;
+import com.netgrif.quartz.mongodb.Constants;
import org.bson.Document;
import org.bson.conversions.Bson;
import org.quartz.JobKey;
diff --git a/src/main/java/com/novemberain/quartz/mongodb/util/QueryHelper.java b/src/main/java/com/netgrif/quartz/mongodb/util/QueryHelper.java
old mode 100644
new mode 100755
similarity index 58%
rename from src/main/java/com/novemberain/quartz/mongodb/util/QueryHelper.java
rename to src/main/java/com/netgrif/quartz/mongodb/util/QueryHelper.java
index 149a9153..ffbff63b
--- a/src/main/java/com/novemberain/quartz/mongodb/util/QueryHelper.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/util/QueryHelper.java
@@ -1,4 +1,4 @@
-package com.novemberain.quartz.mongodb.util;
+package com.netgrif.quartz.mongodb.util;
import com.mongodb.client.model.Filters;
import org.bson.BsonDocument;
@@ -7,8 +7,6 @@
import java.util.Collection;
-import static com.novemberain.quartz.mongodb.util.Keys.KEY_GROUP;
-
public class QueryHelper {
public Bson matchingKeysConditionFor(GroupMatcher> matcher) {
@@ -16,19 +14,19 @@ public Bson matchingKeysConditionFor(GroupMatcher> matcher) {
switch (matcher.getCompareWithOperator()) {
case EQUALS:
- return Filters.eq(KEY_GROUP, compareToValue);
+ return Filters.eq(Keys.KEY_GROUP, compareToValue);
case STARTS_WITH:
- return Filters.regex(KEY_GROUP, "^" + compareToValue + ".*");
+ return Filters.regex(Keys.KEY_GROUP, "^" + compareToValue + ".*");
case ENDS_WITH:
- return Filters.regex(KEY_GROUP, ".*" + compareToValue + "$");
+ return Filters.regex(Keys.KEY_GROUP, ".*" + compareToValue + "$");
case CONTAINS:
- return Filters.regex(KEY_GROUP, compareToValue);
+ return Filters.regex(Keys.KEY_GROUP, compareToValue);
}
return new BsonDocument();
}
public Bson inGroups(Collection groups) {
- return Filters.in(KEY_GROUP, groups);
+ return Filters.in(Keys.KEY_GROUP, groups);
}
}
diff --git a/src/main/java/com/novemberain/quartz/mongodb/util/SerialUtils.java b/src/main/java/com/netgrif/quartz/mongodb/util/SerialUtils.java
old mode 100644
new mode 100755
similarity index 98%
rename from src/main/java/com/novemberain/quartz/mongodb/util/SerialUtils.java
rename to src/main/java/com/netgrif/quartz/mongodb/util/SerialUtils.java
index 5cfca439..fef0c2d6
--- a/src/main/java/com/novemberain/quartz/mongodb/util/SerialUtils.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/util/SerialUtils.java
@@ -1,4 +1,4 @@
-package com.novemberain.quartz.mongodb.util;
+package com.netgrif.quartz.mongodb.util;
import org.apache.commons.codec.binary.Base64;
import org.bson.types.Binary;
diff --git a/src/main/java/com/novemberain/quartz/mongodb/util/TriggerGroupHelper.java b/src/main/java/com/netgrif/quartz/mongodb/util/TriggerGroupHelper.java
old mode 100644
new mode 100755
similarity index 88%
rename from src/main/java/com/novemberain/quartz/mongodb/util/TriggerGroupHelper.java
rename to src/main/java/com/netgrif/quartz/mongodb/util/TriggerGroupHelper.java
index 170e0663..97821cab
--- a/src/main/java/com/novemberain/quartz/mongodb/util/TriggerGroupHelper.java
+++ b/src/main/java/com/netgrif/quartz/mongodb/util/TriggerGroupHelper.java
@@ -1,4 +1,4 @@
-package com.novemberain.quartz.mongodb.util;
+package com.netgrif.quartz.mongodb.util;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.model.Filters;
@@ -9,7 +9,7 @@
import java.util.LinkedList;
import java.util.List;
-import static com.novemberain.quartz.mongodb.util.Keys.KEY_GROUP;
+import static com.netgrif.quartz.mongodb.util.Keys.KEY_GROUP;
public class TriggerGroupHelper extends GroupHelper {
public static final String JOB_ID = "jobId";
diff --git a/src/main/java/com/novemberain/quartz/mongodb/cluster/CheckinTask.java b/src/main/java/com/novemberain/quartz/mongodb/cluster/CheckinTask.java
deleted file mode 100644
index 65b98050..00000000
--- a/src/main/java/com/novemberain/quartz/mongodb/cluster/CheckinTask.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package com.novemberain.quartz.mongodb.cluster;
-
-import com.mongodb.MongoException;
-import com.novemberain.quartz.mongodb.dao.SchedulerDao;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * The responsibility of this class is to check-in inside Scheduler Cluster.
- */
-public class CheckinTask implements Runnable {
-
- private static final Logger log = LoggerFactory.getLogger(CheckinTask.class);
-
- private SchedulerDao schedulerDao;
- private Runnable errorhandler;
-
- public CheckinTask(SchedulerDao schedulerDao, Runnable errorHandler) {
- this.schedulerDao = schedulerDao;
- this.errorhandler = errorHandler;
- }
-
- // for tests only
- public void setErrorHandler(Runnable errorHandler) {
- this.errorhandler = errorHandler;
- }
-
- @Override
- public void run() {
- log.debug("Node {}:{} checks-in.", schedulerDao.schedulerName, schedulerDao.instanceId);
- try {
- schedulerDao.checkIn();
- } catch (MongoException e) {
- log.error("Node " + schedulerDao.instanceId + " could not check-in: " + e.getMessage(), e);
- errorhandler.run();
- }
- }
-}
diff --git a/src/test/groovy/com/novemberain/quartz/mongodb/Clocks.groovy b/src/test/groovy/com/netgrif/quartz/mongodb/Clocks.groovy
similarity index 85%
rename from src/test/groovy/com/novemberain/quartz/mongodb/Clocks.groovy
rename to src/test/groovy/com/netgrif/quartz/mongodb/Clocks.groovy
index 2a1ae6ed..bc96ee3d 100644
--- a/src/test/groovy/com/novemberain/quartz/mongodb/Clocks.groovy
+++ b/src/test/groovy/com/netgrif/quartz/mongodb/Clocks.groovy
@@ -1,6 +1,6 @@
-package com.novemberain.quartz.mongodb
+package com.netgrif.quartz.mongodb
-import com.novemberain.quartz.mongodb.util.Clock
+import com.netgrif.quartz.mongodb.util.Clock
import java.util.concurrent.atomic.AtomicInteger
diff --git a/src/test/groovy/com/novemberain/quartz/mongodb/FailoverTest.groovy b/src/test/groovy/com/netgrif/quartz/mongodb/FailoverTest.groovy
similarity index 99%
rename from src/test/groovy/com/novemberain/quartz/mongodb/FailoverTest.groovy
rename to src/test/groovy/com/netgrif/quartz/mongodb/FailoverTest.groovy
index 56ba52bc..9860717c 100644
--- a/src/test/groovy/com/novemberain/quartz/mongodb/FailoverTest.groovy
+++ b/src/test/groovy/com/netgrif/quartz/mongodb/FailoverTest.groovy
@@ -1,6 +1,6 @@
-package com.novemberain.quartz.mongodb
+package com.netgrif.quartz.mongodb
-import com.novemberain.quartz.mongodb.util.Keys
+import com.netgrif.quartz.mongodb.util.Keys
import org.bson.types.ObjectId
import org.quartz.Job
import org.quartz.JobExecutionContext
diff --git a/src/test/groovy/com/novemberain/quartz/mongodb/JobDataConverterTest.groovy b/src/test/groovy/com/netgrif/quartz/mongodb/JobDataConverterTest.groovy
similarity index 99%
rename from src/test/groovy/com/novemberain/quartz/mongodb/JobDataConverterTest.groovy
rename to src/test/groovy/com/netgrif/quartz/mongodb/JobDataConverterTest.groovy
index ccdb3d40..ed3b0ae6 100644
--- a/src/test/groovy/com/novemberain/quartz/mongodb/JobDataConverterTest.groovy
+++ b/src/test/groovy/com/netgrif/quartz/mongodb/JobDataConverterTest.groovy
@@ -1,4 +1,4 @@
-package com.novemberain.quartz.mongodb
+package com.netgrif.quartz.mongodb
import groovy.transform.EqualsAndHashCode
import groovy.transform.ToString
diff --git a/src/test/groovy/com/novemberain/quartz/mongodb/LoadBalancingTest.groovy b/src/test/groovy/com/netgrif/quartz/mongodb/LoadBalancingTest.groovy
similarity index 97%
rename from src/test/groovy/com/novemberain/quartz/mongodb/LoadBalancingTest.groovy
rename to src/test/groovy/com/netgrif/quartz/mongodb/LoadBalancingTest.groovy
index 8eb07346..27df965f 100644
--- a/src/test/groovy/com/novemberain/quartz/mongodb/LoadBalancingTest.groovy
+++ b/src/test/groovy/com/netgrif/quartz/mongodb/LoadBalancingTest.groovy
@@ -1,4 +1,4 @@
-package com.novemberain.quartz.mongodb
+package com.netgrif.quartz.mongodb
import org.quartz.Job
import org.quartz.JobBuilder
diff --git a/src/test/groovy/com/novemberain/quartz/mongodb/LockManagerTest.groovy b/src/test/groovy/com/netgrif/quartz/mongodb/LockManagerTest.groovy
similarity index 93%
rename from src/test/groovy/com/novemberain/quartz/mongodb/LockManagerTest.groovy
rename to src/test/groovy/com/netgrif/quartz/mongodb/LockManagerTest.groovy
index cdc5a3e8..2d010e8d 100644
--- a/src/test/groovy/com/novemberain/quartz/mongodb/LockManagerTest.groovy
+++ b/src/test/groovy/com/netgrif/quartz/mongodb/LockManagerTest.groovy
@@ -1,10 +1,10 @@
-package com.novemberain.quartz.mongodb
+package com.netgrif.quartz.mongodb
import com.mongodb.MongoWriteException
import com.mongodb.ServerAddress
import com.mongodb.WriteError
-import com.novemberain.quartz.mongodb.dao.LocksDao
-import com.novemberain.quartz.mongodb.util.ExpiryCalculator
+import com.netgrif.quartz.mongodb.dao.LocksDao
+import com.netgrif.quartz.mongodb.util.ExpiryCalculator
import org.bson.BsonDocument
import org.bson.Document
import org.quartz.TriggerKey
diff --git a/src/test/groovy/com/novemberain/quartz/mongodb/MongoHelper.groovy b/src/test/groovy/com/netgrif/quartz/mongodb/MongoHelper.groovy
similarity index 98%
rename from src/test/groovy/com/novemberain/quartz/mongodb/MongoHelper.groovy
rename to src/test/groovy/com/netgrif/quartz/mongodb/MongoHelper.groovy
index 61f80a63..aee1cb30 100644
--- a/src/test/groovy/com/novemberain/quartz/mongodb/MongoHelper.groovy
+++ b/src/test/groovy/com/netgrif/quartz/mongodb/MongoHelper.groovy
@@ -1,4 +1,4 @@
-package com.novemberain.quartz.mongodb
+package com.netgrif.quartz.mongodb
import com.mongodb.MongoClientSettings
import com.mongodb.ServerAddress
diff --git a/src/test/groovy/com/novemberain/quartz/mongodb/QuartzHelper.groovy b/src/test/groovy/com/netgrif/quartz/mongodb/QuartzHelper.groovy
similarity index 98%
rename from src/test/groovy/com/novemberain/quartz/mongodb/QuartzHelper.groovy
rename to src/test/groovy/com/netgrif/quartz/mongodb/QuartzHelper.groovy
index 3b523948..5256300d 100644
--- a/src/test/groovy/com/novemberain/quartz/mongodb/QuartzHelper.groovy
+++ b/src/test/groovy/com/netgrif/quartz/mongodb/QuartzHelper.groovy
@@ -1,4 +1,4 @@
-package com.novemberain.quartz.mongodb
+package com.netgrif.quartz.mongodb
import org.joda.time.DateTime
import org.quartz.Scheduler
diff --git a/src/test/groovy/com/novemberain/quartz/mongodb/TriggerStateManagerTest.groovy b/src/test/groovy/com/netgrif/quartz/mongodb/TriggerStateManagerTest.groovy
similarity index 83%
rename from src/test/groovy/com/novemberain/quartz/mongodb/TriggerStateManagerTest.groovy
rename to src/test/groovy/com/netgrif/quartz/mongodb/TriggerStateManagerTest.groovy
index 3255f9d0..17117f78 100644
--- a/src/test/groovy/com/novemberain/quartz/mongodb/TriggerStateManagerTest.groovy
+++ b/src/test/groovy/com/netgrif/quartz/mongodb/TriggerStateManagerTest.groovy
@@ -1,10 +1,10 @@
-package com.novemberain.quartz.mongodb
+package com.netgrif.quartz.mongodb
-import com.novemberain.quartz.mongodb.dao.JobDao
-import com.novemberain.quartz.mongodb.dao.PausedJobGroupsDao
-import com.novemberain.quartz.mongodb.dao.PausedTriggerGroupsDao
-import com.novemberain.quartz.mongodb.dao.TriggerDao
-import com.novemberain.quartz.mongodb.util.QueryHelper
+import com.netgrif.quartz.mongodb.dao.JobDao
+import com.netgrif.quartz.mongodb.dao.PausedJobGroupsDao
+import com.netgrif.quartz.mongodb.dao.PausedTriggerGroupsDao
+import com.netgrif.quartz.mongodb.dao.TriggerDao
+import com.netgrif.quartz.mongodb.util.QueryHelper
import org.quartz.TriggerKey
import spock.lang.Shared
import spock.lang.Specification
diff --git a/src/test/groovy/com/novemberain/quartz/mongodb/cluster/CheckinTaskTest.groovy b/src/test/groovy/com/netgrif/quartz/mongodb/cluster/CheckinTaskTest.groovy
similarity index 88%
rename from src/test/groovy/com/novemberain/quartz/mongodb/cluster/CheckinTaskTest.groovy
rename to src/test/groovy/com/netgrif/quartz/mongodb/cluster/CheckinTaskTest.groovy
index 9671cfce..cc6306d6 100644
--- a/src/test/groovy/com/novemberain/quartz/mongodb/cluster/CheckinTaskTest.groovy
+++ b/src/test/groovy/com/netgrif/quartz/mongodb/cluster/CheckinTaskTest.groovy
@@ -1,7 +1,7 @@
-package com.novemberain.quartz.mongodb.cluster
+package com.netgrif.quartz.mongodb.cluster
import com.mongodb.MongoException
-import com.novemberain.quartz.mongodb.dao.SchedulerDao
+import com.netgrif.quartz.mongodb.dao.SchedulerDao
import spock.lang.Specification
class CheckinTaskTest extends Specification {
diff --git a/src/test/groovy/com/novemberain/quartz/mongodb/cluster/SchedulerTest.groovy b/src/test/groovy/com/netgrif/quartz/mongodb/cluster/SchedulerTest.groovy
similarity index 95%
rename from src/test/groovy/com/novemberain/quartz/mongodb/cluster/SchedulerTest.groovy
rename to src/test/groovy/com/netgrif/quartz/mongodb/cluster/SchedulerTest.groovy
index b0057118..3d65e849 100644
--- a/src/test/groovy/com/novemberain/quartz/mongodb/cluster/SchedulerTest.groovy
+++ b/src/test/groovy/com/netgrif/quartz/mongodb/cluster/SchedulerTest.groovy
@@ -1,4 +1,4 @@
-package com.novemberain.quartz.mongodb.cluster
+package com.netgrif.quartz.mongodb.cluster
import spock.lang.Specification
diff --git a/src/test/groovy/com/novemberain/quartz/mongodb/dao/CalendarDaoTest.groovy b/src/test/groovy/com/netgrif/quartz/mongodb/dao/CalendarDaoTest.groovy
similarity index 87%
rename from src/test/groovy/com/novemberain/quartz/mongodb/dao/CalendarDaoTest.groovy
rename to src/test/groovy/com/netgrif/quartz/mongodb/dao/CalendarDaoTest.groovy
index 730df1c3..592c9e2c 100644
--- a/src/test/groovy/com/novemberain/quartz/mongodb/dao/CalendarDaoTest.groovy
+++ b/src/test/groovy/com/netgrif/quartz/mongodb/dao/CalendarDaoTest.groovy
@@ -1,11 +1,11 @@
-package com.novemberain.quartz.mongodb.dao
+package com.netgrif.quartz.mongodb.dao
-import com.novemberain.quartz.mongodb.MongoHelper
+import com.netgrif.quartz.mongodb.MongoHelper
import org.quartz.impl.calendar.DailyCalendar
import spock.lang.Specification
-import static com.novemberain.quartz.mongodb.dao.CalendarDao.CALENDAR_NAME
-import static com.novemberain.quartz.mongodb.dao.CalendarDao.CALENDAR_SERIALIZED_OBJECT
+import static com.netgrif.quartz.mongodb.dao.CalendarDao.CALENDAR_NAME
+import static com.netgrif.quartz.mongodb.dao.CalendarDao.CALENDAR_SERIALIZED_OBJECT
class CalendarDaoTest extends Specification {
diff --git a/src/test/groovy/com/novemberain/quartz/mongodb/dao/LocksDaoTest.groovy b/src/test/groovy/com/netgrif/quartz/mongodb/dao/LocksDaoTest.groovy
similarity index 94%
rename from src/test/groovy/com/novemberain/quartz/mongodb/dao/LocksDaoTest.groovy
rename to src/test/groovy/com/netgrif/quartz/mongodb/dao/LocksDaoTest.groovy
index d6651ea7..41e61be5 100644
--- a/src/test/groovy/com/novemberain/quartz/mongodb/dao/LocksDaoTest.groovy
+++ b/src/test/groovy/com/netgrif/quartz/mongodb/dao/LocksDaoTest.groovy
@@ -1,10 +1,10 @@
-package com.novemberain.quartz.mongodb.dao
+package com.netgrif.quartz.mongodb.dao
import com.mongodb.MongoWriteException
-import com.novemberain.quartz.mongodb.Clocks
-import com.novemberain.quartz.mongodb.MongoHelper
-import com.novemberain.quartz.mongodb.util.Clock
-import com.novemberain.quartz.mongodb.util.Keys
+import com.netgrif.quartz.mongodb.Clocks
+import com.netgrif.quartz.mongodb.MongoHelper
+import com.netgrif.quartz.mongodb.util.Clock
+import com.netgrif.quartz.mongodb.util.Keys
import org.quartz.TriggerKey
import spock.lang.Shared
import spock.lang.Specification
diff --git a/src/test/groovy/com/novemberain/quartz/mongodb/dao/SchedulerDaoTest.groovy b/src/test/groovy/com/netgrif/quartz/mongodb/dao/SchedulerDaoTest.groovy
similarity index 96%
rename from src/test/groovy/com/novemberain/quartz/mongodb/dao/SchedulerDaoTest.groovy
rename to src/test/groovy/com/netgrif/quartz/mongodb/dao/SchedulerDaoTest.groovy
index af462170..1f6cd00a 100644
--- a/src/test/groovy/com/novemberain/quartz/mongodb/dao/SchedulerDaoTest.groovy
+++ b/src/test/groovy/com/netgrif/quartz/mongodb/dao/SchedulerDaoTest.groovy
@@ -1,8 +1,8 @@
-package com.novemberain.quartz.mongodb.dao
+package com.netgrif.quartz.mongodb.dao
-import com.novemberain.quartz.mongodb.Clocks
-import com.novemberain.quartz.mongodb.MongoHelper
-import com.novemberain.quartz.mongodb.util.Clock
+import com.netgrif.quartz.mongodb.Clocks
+import com.netgrif.quartz.mongodb.MongoHelper
+import com.netgrif.quartz.mongodb.util.Clock
import spock.lang.Shared
import spock.lang.Specification
diff --git a/src/test/groovy/com/novemberain/quartz/mongodb/dao/TriggerDaoTest.groovy b/src/test/groovy/com/netgrif/quartz/mongodb/dao/TriggerDaoTest.groovy
similarity index 83%
rename from src/test/groovy/com/novemberain/quartz/mongodb/dao/TriggerDaoTest.groovy
rename to src/test/groovy/com/netgrif/quartz/mongodb/dao/TriggerDaoTest.groovy
index 188896ee..1386ace5 100644
--- a/src/test/groovy/com/novemberain/quartz/mongodb/dao/TriggerDaoTest.groovy
+++ b/src/test/groovy/com/netgrif/quartz/mongodb/dao/TriggerDaoTest.groovy
@@ -1,18 +1,18 @@
-package com.novemberain.quartz.mongodb.dao
+package com.netgrif.quartz.mongodb.dao
-import com.novemberain.quartz.mongodb.MongoHelper
-import com.novemberain.quartz.mongodb.trigger.TriggerConverter
-import com.novemberain.quartz.mongodb.util.Keys
-import com.novemberain.quartz.mongodb.util.QueryHelper
+import com.netgrif.quartz.mongodb.MongoHelper
+import com.netgrif.quartz.mongodb.trigger.TriggerConverter
+import com.netgrif.quartz.mongodb.util.Keys
+import com.netgrif.quartz.mongodb.util.QueryHelper
import org.bson.Document
import org.quartz.TriggerKey
import org.quartz.impl.triggers.SimpleTriggerImpl
import spock.lang.Shared
import spock.lang.Specification
-import static com.novemberain.quartz.mongodb.Constants.STATE_ERROR
-import static com.novemberain.quartz.mongodb.Constants.STATE_PAUSED
-import static com.novemberain.quartz.mongodb.Constants.STATE_WAITING
+import static com.netgrif.quartz.mongodb.Constants.STATE_ERROR
+import static com.netgrif.quartz.mongodb.Constants.STATE_PAUSED
+import static com.netgrif.quartz.mongodb.Constants.STATE_WAITING
class TriggerDaoTest extends Specification {
diff --git a/src/test/groovy/com/novemberain/quartz/mongodb/trigger/TriggerConverterTest.groovy b/src/test/groovy/com/netgrif/quartz/mongodb/trigger/TriggerConverterTest.groovy
similarity index 90%
rename from src/test/groovy/com/novemberain/quartz/mongodb/trigger/TriggerConverterTest.groovy
rename to src/test/groovy/com/netgrif/quartz/mongodb/trigger/TriggerConverterTest.groovy
index be607862..dc02a155 100644
--- a/src/test/groovy/com/novemberain/quartz/mongodb/trigger/TriggerConverterTest.groovy
+++ b/src/test/groovy/com/netgrif/quartz/mongodb/trigger/TriggerConverterTest.groovy
@@ -1,12 +1,11 @@
-package com.novemberain.quartz.mongodb.trigger
+package com.netgrif.quartz.mongodb.trigger
-import com.novemberain.quartz.mongodb.Constants
-import com.novemberain.quartz.mongodb.JobDataConverter
-import com.novemberain.quartz.mongodb.dao.JobDao
-import com.novemberain.quartz.mongodb.dao.TriggerDao
-import com.novemberain.quartz.mongodb.util.Keys
+
+import com.netgrif.quartz.mongodb.JobDataConverter
+import com.netgrif.quartz.mongodb.dao.JobDao
+import com.netgrif.quartz.mongodb.dao.TriggerDao
+import com.netgrif.quartz.mongodb.util.Keys
import org.bson.Document
-import org.quartz.TriggerKey
import org.quartz.impl.triggers.SimpleTriggerImpl
import spock.lang.Shared
import spock.lang.Specification
diff --git a/src/test/groovy/com/novemberain/quartz/mongodb/util/ExpiryCalculatorTest.groovy b/src/test/groovy/com/netgrif/quartz/mongodb/util/ExpiryCalculatorTest.groovy
similarity index 92%
rename from src/test/groovy/com/novemberain/quartz/mongodb/util/ExpiryCalculatorTest.groovy
rename to src/test/groovy/com/netgrif/quartz/mongodb/util/ExpiryCalculatorTest.groovy
index 5d6b1c96..26287ab8 100644
--- a/src/test/groovy/com/novemberain/quartz/mongodb/util/ExpiryCalculatorTest.groovy
+++ b/src/test/groovy/com/netgrif/quartz/mongodb/util/ExpiryCalculatorTest.groovy
@@ -1,9 +1,9 @@
-package com.novemberain.quartz.mongodb.util
+package com.netgrif.quartz.mongodb.util
-import com.novemberain.quartz.mongodb.Clocks
-import com.novemberain.quartz.mongodb.Constants
-import com.novemberain.quartz.mongodb.cluster.Scheduler
-import com.novemberain.quartz.mongodb.dao.SchedulerDao
+import com.netgrif.quartz.mongodb.Clocks
+import com.netgrif.quartz.mongodb.Constants
+import com.netgrif.quartz.mongodb.cluster.Scheduler
+import com.netgrif.quartz.mongodb.dao.SchedulerDao
import org.bson.Document
import spock.lang.Shared
import spock.lang.Specification
diff --git a/src/test/groovy/it/MongoDBJobStoreTest.groovy b/src/test/groovy/it/MongoDBJobStoreTest.groovy
index 04131b17..788fbc75 100644
--- a/src/test/groovy/it/MongoDBJobStoreTest.groovy
+++ b/src/test/groovy/it/MongoDBJobStoreTest.groovy
@@ -1,8 +1,8 @@
package it
import com.mongodb.client.model.Updates
-import com.novemberain.quartz.mongodb.MongoDBJobStore
-import com.novemberain.quartz.mongodb.MongoHelper
+import com.netgrif.quartz.mongodb.MongoDBJobStore
+import com.netgrif.quartz.mongodb.MongoHelper
import org.bson.Document
import org.bson.types.ObjectId
import org.quartz.CalendarIntervalScheduleBuilder
@@ -24,11 +24,10 @@ import org.quartz.spi.OperableTrigger
import spock.lang.Specification
import spock.lang.Subject
-import static com.novemberain.quartz.mongodb.QuartzHelper.in2Months
-import static com.novemberain.quartz.mongodb.QuartzHelper.inSeconds
+import static com.netgrif.quartz.mongodb.QuartzHelper.in2Months
+import static com.netgrif.quartz.mongodb.QuartzHelper.inSeconds
import static org.quartz.DateBuilder.IntervalUnit.*
import static org.quartz.Trigger.TriggerState.*
-import static org.quartz.Trigger.TriggerState.PAUSED
class MongoDBJobStoreTest extends Specification {
diff --git a/src/test/groovy/it/QuartzWithMongoDbStoreTest.groovy b/src/test/groovy/it/QuartzWithMongoDbStoreTest.groovy
index 7d191fae..acb45e79 100644
--- a/src/test/groovy/it/QuartzWithMongoDbStoreTest.groovy
+++ b/src/test/groovy/it/QuartzWithMongoDbStoreTest.groovy
@@ -1,7 +1,7 @@
package it
-import com.novemberain.quartz.mongodb.MongoHelper
-import com.novemberain.quartz.mongodb.QuartzHelper
+import com.netgrif.quartz.mongodb.MongoHelper
+import com.netgrif.quartz.mongodb.QuartzHelper
import org.quartz.CalendarIntervalScheduleBuilder
import org.quartz.Job
import org.quartz.JobBuilder
@@ -22,7 +22,7 @@ import spock.lang.Specification
import java.util.concurrent.CountDownLatch
import java.util.concurrent.atomic.AtomicInteger
-import static com.novemberain.quartz.mongodb.QuartzHelper.inSeconds
+import static com.netgrif.quartz.mongodb.QuartzHelper.inSeconds
import static org.quartz.impl.matchers.GroupMatcher.groupEquals
/**
diff --git a/src/test/java/com/netgrif/mongo/quartz/DeadJob.java b/src/test/java/com/netgrif/mongo/quartz/DeadJob.java
new file mode 100644
index 00000000..08a9d21e
--- /dev/null
+++ b/src/test/java/com/netgrif/mongo/quartz/DeadJob.java
@@ -0,0 +1,61 @@
+package com.netgrif.mongo.quartz;
+
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+
+import java.util.concurrent.CountDownLatch;
+
+
+public class DeadJob {
+
+ public static final CountDownLatch job2RunSignaler = new CountDownLatch(1);
+ public static final CountDownLatch job3RunSignaler = new CountDownLatch(1);
+ public static final CountDownLatch job4RunSignaler = new CountDownLatch(3);
+
+
+ public static class DeadJob1 implements Job {
+
+ @Override
+ public void execute(JobExecutionContext context) throws JobExecutionException {
+ System.out.println("Executing DeadJob1");
+ throw new IllegalStateException("Should not be executed!");
+ }
+ }
+
+
+ public static class DeadJob2 implements Job {
+ @Override
+ public void execute(JobExecutionContext ctx) throws JobExecutionException {
+ System.out.println("Executing DeadJob2");
+ if (ctx.isRecovering()) {
+ throw new IllegalStateException("Should not be in recovering state!");
+ }
+ job2RunSignaler.countDown();
+ }
+ }
+
+
+ public static class DeadJob3 implements Job {
+ @Override
+ public void execute(JobExecutionContext ctx) throws JobExecutionException {
+ System.out.println("Executing DeadJob3");
+ if (!ctx.isRecovering()) {
+ throw new IllegalStateException("Should not be in recovering state!");
+ }
+ job3RunSignaler.countDown();
+ }
+ }
+
+
+ public static class DeadJob4 implements Job {
+ @Override
+ public void execute(JobExecutionContext ctx) throws JobExecutionException {
+ System.out.println("Executing DeadJob4");
+ if (!ctx.isRecovering()) {
+ throw new IllegalStateException("Should not be in recovering state!");
+ }
+ job4RunSignaler.countDown();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/com/netgrif/mongo/quartz/FailoverTest.java b/src/test/java/com/netgrif/mongo/quartz/FailoverTest.java
new file mode 100644
index 00000000..a699bd4e
--- /dev/null
+++ b/src/test/java/com/netgrif/mongo/quartz/FailoverTest.java
@@ -0,0 +1,209 @@
+package com.netgrif.mongo.quartz;
+
+import com.netgrif.quartz.mongodb.Constants;
+import com.netgrif.quartz.mongodb.util.Keys;
+import org.bson.types.ObjectId;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.quartz.Scheduler;
+import org.quartz.SchedulerException;
+import org.quartz.impl.triggers.SimpleTriggerImpl;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class FailoverTest {
+
+ private static final long QUARTZ_FINISH_WAITTIME_SECS = 2L;
+
+
+ @BeforeEach
+ public void setup() throws SchedulerException {
+ MongoHelper.purgeCollections();
+ }
+
+
+ public void insertSimpleTrigger(Date fireTime, long repeatInterval, int repeatCount) {
+ insertSimpleTrigger(fireTime, null, repeatInterval, repeatCount);
+ }
+
+ public void insertSimpleTriggerLong(Date fireTime, long finalFireTime, long repeatInterval, int repeatCount) {
+ Map data = new HashMap<>();
+ data.putAll(commonTriggerData());
+ data.put("class", SimpleTriggerImpl.class.getName());
+ data.put("startTime", fireTime);
+ data.put("previousFireTime", fireTime);
+ data.put("nextFireTime", null);
+ data.put("finalFireTime", finalFireTime);
+ data.put("repeatCount", repeatCount);
+ data.put("repeatInterval", repeatInterval);
+
+ MongoHelper.addTrigger(data);
+
+ }
+
+ public void insertSimpleTrigger(Date fireTime, Date finalFireTime, long repeatInterval, int repeatCount) {
+ Map data = new HashMap<>();
+ data.putAll(commonTriggerData());
+ data.put("class", SimpleTriggerImpl.class.getName());
+ data.put("startTime", fireTime);
+ data.put("previousFireTime", fireTime);
+ data.put("nextFireTime", null);
+ data.put("finalFireTime", finalFireTime);
+ data.put("repeatCount", repeatCount);
+ data.put("repeatInterval", repeatInterval);
+
+ MongoHelper.addTrigger(data);
+ }
+
+ public void insertOneshotTrigger(Date fireTime) {
+ insertSimpleTrigger(fireTime, 0, 0);
+ }
+
+ public void insertTriggerLock(String instanceId) {
+ Map lockData = new HashMap<>();
+ lockData.put(Keys.LOCK_TYPE, Keys.LockType.t.name());
+ lockData.put(Keys.KEY_GROUP, "g1");
+ lockData.put(Keys.KEY_NAME, "t1");
+ lockData.put(Constants.LOCK_INSTANCE_ID, instanceId);
+ lockData.put(Constants.LOCK_TIME, new Date(1462820481910L));
+
+ MongoHelper.addLock(lockData);
+ }
+
+
+ @Test
+ public void shouldExecuteOneShotTriggerOnlyOnce() throws InterruptedException, SchedulerException {
+ // Set up
+ insertScheduler("single-node");
+ insertJob("DeadJob1", false);
+ insertOneshotTrigger(new Date(1462820481910L));
+ insertTriggerLock("single-node");
+
+ List cluster = QuartzHelper.createCluster("single-node");
+
+ TimeUnit.SECONDS.sleep(QUARTZ_FINISH_WAITTIME_SECS);
+
+ assertEquals(0, MongoHelper.getCount("triggers"));
+ assertEquals(0, MongoHelper.getCount("locks"));
+
+ QuartzHelper.shutdown(cluster);
+ }
+
+ @Test
+ public void shouldReexecuteOtherTriggerFromFailedExecution() throws Exception {
+ insertScheduler("dead-node");
+ insertJob("DeadJob2", false);
+ insertTrigger();
+ insertTriggerLock("dead-node");
+
+ List cluster = QuartzHelper.createCluster("single-node");
+ DeadJob.job2RunSignaler.await(2, TimeUnit.SECONDS);
+
+ assertEquals(0, DeadJob.job2RunSignaler.getCount());
+ TimeUnit.SECONDS.sleep(QUARTZ_FINISH_WAITTIME_SECS);
+ QuartzHelper.shutdown(cluster);
+ }
+
+ @Test
+ public void shouldRecoverOwnOneShotTrigger() throws Exception {
+ insertScheduler("single-node");
+ insertJob("DeadJob3", true);
+ insertOneshotTrigger(new Date(1462820481910L));
+ insertTriggerLock("single-node");
+
+ List cluster = QuartzHelper.createCluster("single-node");
+ DeadJob.job3RunSignaler.await(2, TimeUnit.SECONDS);
+
+ assertEquals(0, DeadJob.job3RunSignaler.getCount());
+ TimeUnit.SECONDS.sleep(QUARTZ_FINISH_WAITTIME_SECS);
+ assertEquals(0, MongoHelper.getCount("triggers"));
+ assertEquals(0, MongoHelper.getCount("jobs"));
+ assertEquals(0, MongoHelper.getCount("locks"));
+ QuartzHelper.shutdown(cluster);
+ }
+
+ @Test
+ @Disabled("TODO")
+ public void shouldRecoverOwnRepeatingTrigger() throws Exception {
+ insertScheduler("single-node");
+ insertJob("DeadJob4", true);
+ insertTriggerLock("single-node");
+ long repeatInterval = 1000L;
+ int repeatCount = 2;
+ Date fireTime = new Date();
+ long finalFireTime = fireTime.getTime() + (repeatInterval * (repeatCount + 1));
+ insertSimpleTriggerLong(fireTime, finalFireTime, repeatInterval, repeatCount);
+
+ List cluster = QuartzHelper.createCluster("single-node");
+ DeadJob.job4RunSignaler.await(5, TimeUnit.SECONDS);
+
+ assertEquals(0, DeadJob.job4RunSignaler.getCount());
+ TimeUnit.SECONDS.sleep(QUARTZ_FINISH_WAITTIME_SECS);
+ assertEquals(0, MongoHelper.getCount("triggers"));
+ assertEquals(0, MongoHelper.getCount("jobs"));
+ assertEquals(0, MongoHelper.getCount("locks"));
+ QuartzHelper.shutdown(cluster);
+ }
+
+
+
+ private void insertScheduler(String id) {
+ MongoHelper.addScheduler(new HashMap<>() {{
+ put("instanceId", id);
+ put("schedulerName", "test cluster");
+ put("lastCheckinTime", 1462806352702L);
+ put("checkinInterval", 7500L);
+ }});
+ }
+
+ private void insertJob(String jobName, boolean recover) {
+ MongoHelper.addJob(new HashMap<>() {{
+ put("_id", new ObjectId("00000000ee78252adaba4534"));
+ put("keyName", "job");
+ put("keyGroup", "g1");
+ put("jobDescription", null);
+ put("jobClass", "com.netgrif.mongo.quartz.DeadJob$" + jobName);
+ put("durability", false);
+ put("requestsRecovery", recover);
+ }});
+ }
+
+ private Map commonTriggerData() {
+ return new HashMap<>() {{
+ put("state", "waiting");
+ put("calendarName", null);
+ put("description", null);
+ put("endTime", null);
+ put("fireInstanceId", null);
+ put("jobId", new ObjectId("00000000ee78252adaba4534"));
+ put("keyName", "t1");
+ put("keyGroup", "g1");
+ put("misfireInstruction", 0);
+ put("nextFireTime", null);
+ put("priority", 5);
+ put("timesTriggered", 1);
+ }};
+ }
+
+ private void insertTrigger() {
+ Map data = commonTriggerData();
+ data.putAll(new HashMap<>() {{
+ put("class", "org.quartz.impl.triggers.CalendarIntervalTriggerImpl");
+ put("startTime", new Date(1462820481910L));
+ put("previousFireTime", new Date(1462820481910L));
+ put("nextFireTime", new Date(1462820483910L));
+ put("finalFireTime", null);
+ put("repeatIntervalUnit", "SECOND");
+ put("repeatInterval", 2);
+ }});
+ MongoHelper.addTrigger(data);
+ }
+
+}
diff --git a/src/test/java/com/netgrif/mongo/quartz/JobDataConverterTest.java b/src/test/java/com/netgrif/mongo/quartz/JobDataConverterTest.java
new file mode 100644
index 00000000..de736e4b
--- /dev/null
+++ b/src/test/java/com/netgrif/mongo/quartz/JobDataConverterTest.java
@@ -0,0 +1,210 @@
+package com.netgrif.mongo.quartz;
+
+
+import com.netgrif.quartz.mongodb.Constants;
+import com.netgrif.quartz.mongodb.JobDataConverter;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import org.bson.Document;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.quartz.JobDataMap;
+import org.quartz.JobPersistenceException;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+public class JobDataConverterTest {
+
+ private JobDataConverter converterBase64;
+ private JobDataConverter converterPlain;
+ private String base64 = "rO0ABXNyABFqYXZhLnV0aWwuSGFzaE1hcAUH2sHDFmDRAwACRgAKbG9hZEZhY3RvckkACXRocmVzaG9sZHhwP0AAAAAAAAx3CAAAABAAAAACdAADc3RydAADMTIzdAADZm9vc3IAMWNvbS5uZXRncmlmLm1vbmdvLnF1YXJ0ei5Kb2JEYXRhQ29udmVydGVyVGVzdCRGb29jnxlZgcJi3AIAAkwAA2JhcnQAM0xjb20vbmV0Z3JpZi9tb25nby9xdWFydHovSm9iRGF0YUNvbnZlcnRlclRlc3QkQmFyO0wAA3N0cnQAEkxqYXZhL2xhbmcvU3RyaW5nO3hwc3IAMWNvbS5uZXRncmlmLm1vbmdvLnF1YXJ0ei5Kb2JEYXRhQ29udmVydGVyVGVzdCRCYXIeonWPEVlgfwIAAUwAA3N0cnEAfgAHeHB0AANhYmN0AANkZWZ4";
+
+ @BeforeEach
+ public void setUp() {
+ converterBase64 = new JobDataConverter(true);
+ converterPlain = new JobDataConverter(false);
+ }
+
+ @Test
+ public void emptyJobDataDoesNotModifyTheDocument() throws JobPersistenceException {
+ JobDataMap emptyJobDataMap = new JobDataMap();
+ Document doc = new Document();
+
+ converterBase64.toDocument(emptyJobDataMap, doc);
+ assertEquals(0, doc.size());
+
+ converterPlain.toDocument(emptyJobDataMap, doc);
+ assertEquals(0, doc.size());
+ }
+
+ @Test
+ public void documentWithoutJobDataDoesNotModifyJobDataMap() throws JobPersistenceException {
+ Document doc = new Document();
+ doc.put("foo", "bar");
+ doc.put("num", 123);
+ JobDataMap jobDataMap = new JobDataMap();
+
+ assertFalse(converterBase64.toJobData(doc, jobDataMap));
+ assertEquals(0, jobDataMap.size());
+
+ assertFalse(converterPlain.toJobData(doc, jobDataMap));
+ assertEquals(0, jobDataMap.size());
+ }
+
+ @Test
+ public void testBase64EncodeWorks() throws JobPersistenceException {
+ JobDataMap jobDataMap = createJobDataWithSerializableContent();
+ Document doc = new Document();
+
+ converterBase64.toDocument(jobDataMap, doc);
+ assertEquals(1, doc.size());
+ assertEquals(base64, doc.get(Constants.JOB_DATA));
+ }
+
+ @Test
+ public void testBase64DecodeWorks() throws JobPersistenceException {
+ Document doc = new Document();
+ doc.put(Constants.JOB_DATA, base64);
+ JobDataMap jobDataMap = new JobDataMap();
+
+ assertTrue(converterBase64.toJobData(doc, jobDataMap));
+ assertEquals(2, jobDataMap.getWrappedMap().size());
+ assertMapEquals(createJobDataWithSerializableContent().getWrappedMap(), jobDataMap.getWrappedMap());
+ }
+
+ @Test
+ public void testBase64DecodeFails() {
+ Document doc = new Document();
+ doc.put(Constants.JOB_DATA, 'a' + base64);
+ JobDataMap jobDataMap = new JobDataMap();
+
+ assertThrows(JobPersistenceException.class, () -> {
+ converterBase64.toJobData(doc, jobDataMap);
+ });
+ }
+
+ @Test
+ public void testPlainEncodeWorks() throws JobPersistenceException {
+ JobDataMap jobDataMap = createJobDataWithSimpleContent();
+ Document doc = new Document();
+
+ converterPlain.toDocument(jobDataMap, doc);
+ assertEquals(1, doc.size());
+ assertMapEquals(createJobDataWithSimpleContent().getWrappedMap(), (Map)doc.get(Constants.JOB_DATA_PLAIN));
+ }
+
+ @Test
+ public void testPlainDecodeWorks() throws JobPersistenceException {
+ Document doc = new Document();
+ doc.put(Constants.JOB_DATA_PLAIN, createJobDataWithSimpleContent().getWrappedMap());
+ JobDataMap jobDataMap = new JobDataMap();
+
+ assertTrue(converterPlain.toJobData(doc, jobDataMap));
+ assertEquals(2, jobDataMap.getWrappedMap().size());
+
+ Map expectedMap = createJobDataWithSimpleContent().getWrappedMap();
+ Map actualMap = jobDataMap.getWrappedMap();
+
+ for (String key : expectedMap.keySet()) {
+ Object expectedValue = expectedMap.get(key);
+ Object actualValue = actualMap.get(key);
+
+ if (expectedValue instanceof Map) {
+ assertMapEquals((Map, ?>) expectedValue, (Map, ?>) actualValue);
+ } else if (expectedValue instanceof List) {
+ assertListsEqual((List>) expectedValue, (List>) actualValue);
+ } else {
+ assertEquals(expectedValue, actualValue);
+ }
+ }
+ }
+
+
+
+ @Test
+ public void testPlainDecodeFallsBackToBase64() throws JobPersistenceException {
+ Document doc = new Document();
+ doc.put(Constants.JOB_DATA, base64);
+ JobDataMap jobDataMap = new JobDataMap();
+
+ assertTrue(converterPlain.toJobData(doc, jobDataMap));
+ assertEquals(2, jobDataMap.getWrappedMap().size());
+ assertMapEquals(createJobDataWithSerializableContent().getWrappedMap(), jobDataMap.getWrappedMap());
+ }
+
+ private JobDataMap createJobDataWithSerializableContent() {
+ Foo foo = new Foo(new Bar("abc"), "def");
+ Map map = new HashMap<>();
+ map.put("foo", foo);
+ map.put("str", "123");
+ return new JobDataMap(map);
+ }
+
+ private JobDataMap createJobDataWithSimpleContent() {
+ Map map = new HashMap<>();
+ map.put("foo", "foo");
+ Map barMap = new HashMap<>();
+ barMap.put("one", 1);
+ barMap.put("two", 2.0);
+ barMap.put("list", new String[]{"a", "b", "c"});
+ map.put("bar", barMap);
+ return new JobDataMap(map);
+ }
+
+ @ToString
+ @EqualsAndHashCode
+ static class Foo implements Serializable {
+ Bar bar;
+ String str;
+
+ public Foo(Bar bar, String str) {
+ this.bar = bar;
+ this.str = str;
+ }
+ }
+
+ @ToString
+ @EqualsAndHashCode
+ static class Bar implements Serializable {
+ String str;
+
+ public Bar(String str) {
+ this.str = str;
+ }
+ }
+
+ private void assertMapEquals(Map, ?> expectedMap, Map, ?> actualMap) {
+ assertEquals(expectedMap.size(), actualMap.size());
+ for (Object key : expectedMap.keySet()) {
+ assertTrue(actualMap.containsKey(key));
+ Object expectedValue = expectedMap.get(key);
+ Object actualValue = actualMap.get(key);
+
+ if (expectedValue instanceof Object[] && actualValue instanceof Object[]) {
+ assertArrayEquals((Object[]) expectedValue, (Object[]) actualValue);
+ } else {
+ areEqualKeyValues(expectedMap, actualMap);
+ }
+ }
+ }
+
+ private Map, Boolean> areEqualKeyValues(Map, ?> first, Map, ?> second) {
+ return first.entrySet().stream()
+ .collect(Collectors.toMap(e -> e.getKey(),
+ e -> e.getValue().equals(second.get(e.getKey()))));
+ }
+
+
+ private void assertListsEqual(List> expectedList, List> actualList) {
+ assertEquals(expectedList.size(), actualList.size());
+ for (int i = 0; i < expectedList.size(); i++) {
+ assertEquals(expectedList.get(i), actualList.get(i));
+ }
+ }
+}
diff --git a/src/test/java/com/netgrif/mongo/quartz/LoadBalancingTest.java b/src/test/java/com/netgrif/mongo/quartz/LoadBalancingTest.java
new file mode 100644
index 00000000..26ec8462
--- /dev/null
+++ b/src/test/java/com/netgrif/mongo/quartz/LoadBalancingTest.java
@@ -0,0 +1,66 @@
+package com.netgrif.mongo.quartz;
+
+import lombok.extern.slf4j.Slf4j;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.quartz.*;
+
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+@Slf4j
+public class LoadBalancingTest {
+
+ private static List counter = new CopyOnWriteArrayList<>();
+ private List cluster;
+
+ @BeforeEach
+ public void setup() throws SchedulerException {
+ MongoHelper.purgeCollections();
+ this.cluster = QuartzHelper.createCluster("BaWiX", "Test");
+ }
+
+
+ @AfterEach
+ public void cleanup() throws SchedulerException {
+ QuartzHelper.shutdown(this.cluster);
+ }
+
+ @Test
+ public void shouldExecuteTheJobOnlyOnce() throws InterruptedException, SchedulerException {
+ counter.clear();
+ JobDetail job = JobBuilder.newJob(SharedJob.class)
+ .withIdentity("job1", "g1")
+ .build();
+ Trigger trigger = TriggerBuilder.newTrigger()
+ .startAt(new Date(System.currentTimeMillis() + 1000L))
+ .withIdentity("t1", "g1")
+ .build();
+
+ this.cluster.get(0).scheduleJob(job, trigger);
+ Thread.sleep(7000);
+
+ assertEquals(1, counter.size());
+ }
+
+ public static class SharedJob implements Job {
+ @Override
+ public void execute(JobExecutionContext context) throws JobExecutionException {
+ try {
+ String id = context.getScheduler().getSchedulerInstanceId();
+ System.out.println("Shared Job executed by: " + id);
+ counter.add(id);
+ Thread.sleep(2000);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ throw new JobExecutionException(e);
+ } catch (SchedulerException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+}
diff --git a/src/test/java/com/netgrif/mongo/quartz/LockManagerTest.java b/src/test/java/com/netgrif/mongo/quartz/LockManagerTest.java
new file mode 100644
index 00000000..852bc484
--- /dev/null
+++ b/src/test/java/com/netgrif/mongo/quartz/LockManagerTest.java
@@ -0,0 +1,92 @@
+package com.netgrif.mongo.quartz;
+
+import com.mongodb.MongoWriteException;
+import com.mongodb.ServerAddress;
+import com.mongodb.WriteError;
+import com.netgrif.quartz.mongodb.Constants;
+import com.netgrif.quartz.mongodb.LockManager;
+import com.netgrif.quartz.mongodb.dao.LocksDao;
+import com.netgrif.quartz.mongodb.util.ExpiryCalculator;
+import org.bson.BsonDocument;
+import org.bson.Document;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.quartz.TriggerKey;
+
+import java.util.Date;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.mockito.Mockito.*;
+
+@ExtendWith(MockitoExtension.class)
+public class LockManagerTest {
+
+ @Mock
+ private LocksDao locksDao;
+
+ @Mock
+ private ExpiryCalculator expiryCalc;
+
+ @InjectMocks
+ private LockManager manager;
+
+ private TriggerKey tkey;
+
+ @BeforeEach
+ public void setup() {
+ tkey = new TriggerKey("n1", "g1");
+ }
+
+ private MongoWriteException newWriteException() {
+ return new MongoWriteException(
+ new WriteError(1, "Rly!", BsonDocument.parse("{}")),
+ new ServerAddress());
+ }
+
+ @Test
+ public void tryLockShouldLockTriggerWhenHaveNoLocks() {
+ manager.tryLock(tkey);
+ verify(locksDao).lockTrigger(tkey);
+ }
+
+ @Test
+ public void tryLockCannotGetExistingLockForExpirationCheck() {
+ doThrow(newWriteException()).when(locksDao).lockTrigger(tkey);
+
+ assertFalse(manager.tryLock(tkey));
+ }
+
+ @Test
+ public void shouldNotRelockWhenLockIsNotFound() {
+ when(locksDao.findTriggerLock(tkey)).thenReturn(null);
+
+ assertFalse(manager.relockExpired(tkey));
+ }
+
+ @Test
+ public void shouldNotRelockValidLock() {
+ Document existingLock = new Document();
+ when(locksDao.findTriggerLock(tkey)).thenReturn(existingLock);
+ when(expiryCalc.isTriggerLockExpired(existingLock)).thenReturn(false);
+
+ assertFalse(manager.relockExpired(tkey));
+ }
+
+ @Test
+ @Disabled("Dorobit...")
+ public void shouldRelockExpiredLock() {
+ Date lockTime = new Date(123);
+ Document existingLock = new Document(Constants.LOCK_TIME, lockTime);
+ boolean relocked = manager.relockExpired(tkey);
+
+ assert manager.relockExpired(tkey);
+ }
+
+
+}
diff --git a/src/test/java/com/netgrif/mongo/quartz/MongoHelper.java b/src/test/java/com/netgrif/mongo/quartz/MongoHelper.java
new file mode 100644
index 00000000..10888575
--- /dev/null
+++ b/src/test/java/com/netgrif/mongo/quartz/MongoHelper.java
@@ -0,0 +1,107 @@
+package com.netgrif.mongo.quartz;
+
+import com.mongodb.MongoClientSettings;
+import com.mongodb.ServerAddress;
+import com.mongodb.WriteConcern;
+import com.mongodb.client.MongoClient;
+import com.mongodb.client.MongoClients;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoDatabase;
+import org.bson.Document;
+
+import java.util.*;
+
+public class MongoHelper {
+
+ public static final String testDatabaseName = "quartz_mongodb_test";
+
+ public static final int DEFAULT_MONGO_PORT = 27017;
+
+ private static final MongoClient client = MongoClients.create(
+ MongoClientSettings.builder()
+ .writeConcern(WriteConcern.JOURNALED)
+ .applyToClusterSettings(builder ->
+ builder.hosts(Collections.singletonList(new ServerAddress("localhost", DEFAULT_MONGO_PORT)))
+ )
+ .build());
+
+ private static final MongoDatabase testDatabase = client.getDatabase(testDatabaseName);
+
+ private static final Map> collections = new HashMap<>();
+
+ static {
+ collections.put("calendars", testDatabase.getCollection("quartz_calendars"));
+ collections.put("locks", testDatabase.getCollection("quartz_locks"));
+ collections.put("jobs", testDatabase.getCollection("quartz_jobs"));
+ collections.put("jobGroups", testDatabase.getCollection("quartz_paused_job_groups"));
+ collections.put("schedulers", testDatabase.getCollection("quartz_schedulers"));
+ collections.put("triggers", testDatabase.getCollection("quartz_triggers"));
+ collections.put("triggerGroups", testDatabase.getCollection("quartz_paused_trigger_groups"));
+ }
+
+ public static void dropTestDB() {
+ testDatabase.drop();
+ }
+
+ public static void clearColl(String colKey) {
+ collections.get(colKey).deleteMany(new Document());
+ }
+
+ public static void purgeCollections() {
+ clearColl("triggers");
+ clearColl("jobs");
+ clearColl("locks");
+ clearColl("calendars");
+ clearColl("schedulers");
+ clearColl("triggerGroups");
+ clearColl("jobGroups");
+ }
+
+ public static void addScheduler(Map dataMap) {
+ collections.get("schedulers").insertOne(new Document(dataMap));
+ }
+
+ public static void addJob(Map dataMap) {
+ collections.get("jobs").insertOne(new Document(dataMap));
+ }
+
+ public static void addLock(Map dataMap) {
+ collections.get("locks").insertOne(new Document(dataMap));
+ }
+
+ public static void addTrigger(Map dataMap) {
+ collections.get("triggers").insertOne(new Document(dataMap));
+ }
+
+ public static long getCount(String col) {
+ return collections.get(col).countDocuments();
+ }
+
+ public static MongoCollection getCalendarsColl() {
+ return collections.get("calendars");
+ }
+
+ public static MongoCollection getLocksColl() {
+ return collections.get("locks");
+ }
+
+ public static MongoCollection getSchedulersColl() {
+ return collections.get("schedulers");
+ }
+
+ public static MongoCollection getTriggersColl() {
+ return collections.get("triggers");
+ }
+
+ public static Document getFirst(String col) {
+ return getFirst(col, new HashMap<>());
+ }
+
+ public static Document getFirst(String col, Map amap) {
+ return collections.get(col).find(new Document(amap)).first();
+ }
+
+ public static Collection findAll(String col) {
+ return collections.get(col).find().into(new ArrayList<>());
+ }
+}
diff --git a/src/test/java/com/netgrif/mongo/quartz/QuartzHelper.java b/src/test/java/com/netgrif/mongo/quartz/QuartzHelper.java
new file mode 100755
index 00000000..c88fc79c
--- /dev/null
+++ b/src/test/java/com/netgrif/mongo/quartz/QuartzHelper.java
@@ -0,0 +1,95 @@
+package com.netgrif.mongo.quartz;
+
+import org.joda.time.DateTime;
+import org.quartz.Scheduler;
+import org.quartz.SchedulerException;
+import org.quartz.impl.StdSchedulerFactory;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Properties;
+
+public class QuartzHelper {
+
+ /**
+ * Creates standard properties with MongoDBJobStore.
+ */
+ public static Properties createProps() {
+ Properties props = new Properties();
+ props.setProperty("org.quartz.jobStore.class", "com.netgrif.quartz.mongodb.DynamicMongoDBJobStore");
+ props.setProperty("org.quartz.jobStore.mongoUri", "mongodb://localhost:" + MongoHelper.DEFAULT_MONGO_PORT);
+ props.setProperty("org.quartz.scheduler.idleWaitTime", "1000");
+ props.setProperty("org.quartz.jobStore.dbName", "quartz_mongodb_test");
+ props.setProperty("org.quartz.threadPool.threadCount", "1");
+ props.setProperty("org.quartz.scheduler.skipUpdateCheck", "true");
+ props.setProperty("org.quartz.plugin.triggHistory.class", "org.quartz.plugins.history.LoggingTriggerHistoryPlugin");
+ props.setProperty("org.quartz.plugin.jobHistory.class", "org.quartz.plugins.history.LoggingJobHistoryPlugin");
+ return props;
+ }
+
+ /**
+ * Creates properties for clustered scheduler.
+ */
+ public static Properties createClusteredProps(String instanceName) {
+ Properties props = createProps();
+ props.setProperty("org.quartz.jobStore.isClustered", "true");
+ props.setProperty("org.quartz.scheduler.instanceId", instanceName);
+ props.setProperty("org.quartz.scheduler.instanceName", "test cluster");
+ return props;
+ }
+
+ /**
+ * Create a new Scheduler with the following properties.
+ */
+ public static Scheduler createScheduler(Properties properties) throws SchedulerException {
+ StdSchedulerFactory factory = new StdSchedulerFactory();
+ factory.initialize(properties);
+ Scheduler scheduler = factory.getScheduler();
+ scheduler.start();
+ return scheduler;
+ }
+
+ /**
+ * Create and start the default scheduler.
+ */
+ public static Scheduler startDefaultScheduler() throws SchedulerException {
+ return createScheduler(createProps());
+ }
+
+ public static Scheduler createClusteredScheduler(String instanceName) throws SchedulerException {
+ return createScheduler(createClusteredProps(instanceName));
+ }
+
+ /**
+ * Creates a cluster of schedulers with given names.
+ */
+ public static List createCluster(String... names) throws SchedulerException {
+ List schedulers = new ArrayList<>();
+ for (String name : names) {
+ schedulers.add(createClusteredScheduler(name));
+ }
+ return schedulers;
+ }
+
+ /**
+ * Shutdown all schedulers in given cluster.
+ */
+ public static void shutdown(List cluster) {
+ for (Scheduler scheduler : cluster) {
+ try {
+ scheduler.shutdown();
+ } catch (SchedulerException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public static Date inSeconds(int n) {
+ return DateTime.now().plusSeconds(n).toDate();
+ }
+
+ public static Date in2Months() {
+ return DateTime.now().plusMonths(2).toDate();
+ }
+}
diff --git a/src/test/java/com/netgrif/mongo/quartz/TriggerStateManagerTest.java b/src/test/java/com/netgrif/mongo/quartz/TriggerStateManagerTest.java
new file mode 100644
index 00000000..124e5825
--- /dev/null
+++ b/src/test/java/com/netgrif/mongo/quartz/TriggerStateManagerTest.java
@@ -0,0 +1,87 @@
+package com.netgrif.mongo.quartz;
+
+
+import com.netgrif.quartz.mongodb.Constants;
+import com.netgrif.quartz.mongodb.TriggerStateManager;
+import com.netgrif.quartz.mongodb.dao.JobDao;
+import com.netgrif.quartz.mongodb.dao.PausedJobGroupsDao;
+import com.netgrif.quartz.mongodb.dao.PausedTriggerGroupsDao;
+import com.netgrif.quartz.mongodb.dao.TriggerDao;
+import com.netgrif.quartz.mongodb.util.QueryHelper;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.quartz.TriggerKey;
+
+import java.util.*;
+
+import static org.mockito.Mockito.*;
+
+@ExtendWith(MockitoExtension.class)
+class TriggerStateManagerTest {
+
+ @Mock
+ private TriggerDao triggerDao;
+
+ @Mock
+ private JobDao jobDao;
+
+ @Mock
+ private PausedJobGroupsDao pausedJobGroupsDao;
+
+ @Mock
+ private PausedTriggerGroupsDao pausedTriggerGroupsDao;
+
+ @Mock
+ private QueryHelper queryHelper;
+
+ @InjectMocks
+ private TriggerStateManager stateManager;
+
+ private static final TriggerKey triggerKey = new TriggerKey("t-name", "t-group");
+
+ @BeforeEach
+ void setUp() {
+ stateManager = new TriggerStateManager(triggerDao, jobDao, pausedJobGroupsDao, pausedTriggerGroupsDao, queryHelper);
+ }
+
+ @Test
+ void resetTriggerFromErrorStateShouldDoNothingWhenTriggerIsNotInErrorState() {
+ when(triggerDao.getState(triggerKey)).thenReturn(Constants.STATE_WAITING);
+
+ stateManager.resetTriggerFromErrorState(triggerKey);
+
+ verifyNoInteractions(pausedTriggerGroupsDao);
+ verifyNoMoreInteractions(triggerDao);
+ }
+
+ @Test
+ void resetTriggerFromErrorStateShouldSetWaitingStateWhenTriggerIsInErrorState() {
+ when(triggerDao.getState(triggerKey)).thenReturn(Constants.STATE_ERROR);
+ HashSet pausedGroups = new HashSet<>();
+ pausedGroups.add("g1");
+ doReturn(pausedGroups).when(pausedTriggerGroupsDao).getPausedGroups();
+
+ stateManager.resetTriggerFromErrorState(triggerKey);
+
+ verify(pausedTriggerGroupsDao).getPausedGroups();
+ verify(triggerDao).transferState(triggerKey, Constants.STATE_ERROR, Constants.STATE_WAITING);
+ }
+
+ @Test
+ void resetTriggerFromErrorStateShouldSetPausedStateWhenTriggerIsInPausedGroup() {
+ when(triggerDao.getState(triggerKey)).thenReturn(Constants.STATE_ERROR);
+ HashSet pausedGroups = new HashSet<>();
+ pausedGroups.add("g1");
+ pausedGroups.add(triggerKey.getGroup());
+ doReturn(pausedGroups).when(pausedTriggerGroupsDao).getPausedGroups();
+
+ stateManager.resetTriggerFromErrorState(triggerKey);
+
+ verify(pausedTriggerGroupsDao).getPausedGroups();
+ verify(triggerDao).transferState(triggerKey, Constants.STATE_ERROR, Constants.STATE_PAUSED);
+ }
+}
diff --git a/src/test/java/com/netgrif/mongo/quartz/cluster/CheckinTaskTest.java b/src/test/java/com/netgrif/mongo/quartz/cluster/CheckinTaskTest.java
new file mode 100644
index 00000000..d48d1fc7
--- /dev/null
+++ b/src/test/java/com/netgrif/mongo/quartz/cluster/CheckinTaskTest.java
@@ -0,0 +1,5 @@
+package com.netgrif.mongo.quartz.cluster;
+
+public class CheckinTaskTest {
+ //TODO: plz create new test :)
+}
diff --git a/src/test/java/com/netgrif/mongo/quartz/cluster/SchedulerTest.java b/src/test/java/com/netgrif/mongo/quartz/cluster/SchedulerTest.java
new file mode 100644
index 00000000..a258e5e4
--- /dev/null
+++ b/src/test/java/com/netgrif/mongo/quartz/cluster/SchedulerTest.java
@@ -0,0 +1,4 @@
+package com.netgrif.mongo.quartz.cluster;
+
+public class SchedulerTest {
+}