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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 124 additions & 0 deletions .idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@

language: java

script: 'ant test'
script: 'mvn test'

services:
- mongodb

jdk:
- oraclejdk7
- openjdk6
- openjdk7
- oraclejdk8

env:
- DB=mongodb
39 changes: 0 additions & 39 deletions conf/maven-mongo-java-distributed-lock.xml

This file was deleted.

Binary file removed lib/junit-4.8.2.jar
Binary file not shown.
Binary file removed lib/mongo-2.7.3.jar
Binary file not shown.
85 changes: 85 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<project>

<modelVersion>4.0.0</modelVersion>
<groupId>com.deftlabs</groupId>
<artifactId>mongo-java-distributed-lock</artifactId>
<packaging>jar</packaging>
<name>Mongo Java Distributed Lock</name>
<version>0.1.7</version>
<description>A distributed lock backed by MongoDB</description>
<url>https://deftlabs.com</url>

<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>

<scm>
<url>https://github.com/deftlabs</url>
</scm>

<dependencies>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>[3.2.0,)</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.4.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<ignoreMissingFile>true</ignoreMissingFile>
<file>src/main/java/com/deftlabs/lock/mongo/DistributedLockSvcOptions.java</file>
<outputFile>src/main/java/com/deftlabs/lock/mongo/DistributedLockSvcOptions.java</outputFile>
<regex>false</regex>
<token>@LIB_VERSION@</token>
<value>${project.version}</value>
</configuration>
</plugin>
</plugins>
</build>

<developers>
<developer>
<name>Ryan Nitz</name>
<organization>Deft Labs</organization>
</developer>
</developers>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package com.deftlabs.lock.mongo;

// Java
import com.mongodb.MongoClient;

import java.net.InetAddress;
import java.net.UnknownHostException;

Expand All @@ -35,15 +37,17 @@ public class DistributedLockSvcOptions {
*
*/
public DistributedLockSvcOptions(final String pMongoUri)
{ this(pMongoUri, "mongo-distributed-lock", "locks", null); }
{ this(pMongoUri, "mongo-distributed-lock", "locks", null);
}

/**
* Constructor that allows the user to specify database and colleciton name.
*/
public DistributedLockSvcOptions( final String pMongoUri,
final String pDbName,
final String pCollectionName)
{ this(pMongoUri, pDbName, pCollectionName, null); }
{ this(pMongoUri, pDbName, pCollectionName, null);
}

/**
* Constructor that allows the user to specify database, colleciton and app name.
Expand All @@ -65,8 +69,54 @@ public DistributedLockSvcOptions( final String pMongoUri,

try { _hostname = InetAddress.getLocalHost().getHostName();
} catch (final UnknownHostException e) { _hostname = null; }
_mongoClient = null;
}

/**
* The basic constructor. This uses the following:<br />
* <ul>
* <li>database name: mongo-distributed-lock
* <li>collection name: locks
* </ul>
*
*/
public DistributedLockSvcOptions(final MongoClient pMongoClient)
{ this(pMongoClient, "mongo-distributed-lock", "locks", null);
}

/**
* Constructor that allows the user to specify database and colleciton name.
*/
public DistributedLockSvcOptions( final MongoClient pMongoClient,
final String pDbName,
final String pCollectionName)
{ this(pMongoClient, pDbName, pCollectionName, null);
}

/**
* Constructor that allows the user to specify database, colleciton and app name.
* The app name should definetly be used if the db/collection names are shared by multiple
* apps/systems (e.g., SomeCoolDataProcessor).
*/
public DistributedLockSvcOptions( final MongoClient pMongoClient,
final String pDbName,
final String pCollectionName,
final String pAppName)
{
_mongoClient = pMongoClient;
_dbName = pDbName;
_collectionName = pCollectionName;
_appName = pAppName;

try { _hostAddress = InetAddress.getLocalHost().getHostAddress();
} catch (final UnknownHostException e) { _hostAddress = null; }

try { _hostname = InetAddress.getLocalHost().getHostName();
} catch (final UnknownHostException e) { _hostname = null; }
_mongoUri = null;
}

public MongoClient getMongoClient() { return _mongoClient; }
public String getMongoUri() { return _mongoUri; }
public String getDbName() { return _dbName; }
public String getCollectionName() { return _collectionName; }
Expand Down Expand Up @@ -131,6 +181,7 @@ public void setLockUnlockedFrequency(final long pLockUnlockedFrequency) {
public void setHistoryCollectionName(final String pV) { _historyCollectionName = pV; }
public String getHistoryCollectionName() { return _historyCollectionName; }

private final MongoClient _mongoClient;
private final String _mongoUri;
private final String _dbName;
private final String _collectionName;
Expand Down
Loading