Skip to content

Commit 7cfad4c

Browse files
authored
Merge pull request #13 from kbase/develop
Develop->master
2 parents b73f5d0 + a52b13d commit 7cfad4c

File tree

8 files changed

+548
-680
lines changed

8 files changed

+548
-680
lines changed

RELEASE_NOTES.txt

+15
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,21 @@ OVERVIEW
44
-----------------------------------------
55
Repo for code shared between Java services.
66

7+
VERSION: 0.0.16 (Released 6/13/2016)
8+
--------------------------------------
9+
10+
NEW FEATURES:
11+
- The JsonServerSyslog class now logs SLF4J messages.
12+
13+
UPDATED FEATURES / MAJOR BUG FIXES:
14+
- Fixed a bug where the server would stop logging after a syslog daemon
15+
restart.
16+
- removed the UTCDateFormat class (use joda library classes instead).
17+
- removed UTF8Utils, unused.
18+
19+
ANTICIPATED FUTURE DEVELOPMENTS:
20+
- None
21+
722
VERSION: 0.0.15 (Released 1/24/2015)
823
--------------------------------------
924

build.xml

+6-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<fileset dir="${jardir}" id="lib">
3535
<include name="apache_commons/commons-lang3-3.1.jar"/>
3636
<include name="junit/junit-4.9.jar"/>
37-
<include name="mongo/mongo-java-driver-2.11.2.jar"/>
37+
<include name="mongo/mongo-java-driver-2.13.3.jar"/>
3838
<include name="jackson/jackson-core-2.2.3.jar"/>
3939
<include name="jackson/jackson-databind-2.2.3.jar"/>
4040
<include name="jackson/jackson-annotations-2.2.3.jar"/>
@@ -52,9 +52,12 @@
5252
<include name="apache_commons/http/httpmime-4.3.1.jar"/>
5353
<include name="apache_commons/commons-logging-1.1.1.jar"/>
5454
<include name="slf4j/slf4j-api-1.7.7.jar"/>
55+
<include name="logback/logback-core-1.1.2.jar"/>
56+
<include name="logback/logback-classic-1.1.2.jar"/>
5557
<include name="apache_commons/velocity-1.7.jar"/>
5658
<include name="apache_commons/commons-io-2.4.jar"/>
5759
<include name="javassist/javassist-3.18.2.jar"/>
60+
<include name="joda/joda-time-2.2.jar"/>
5861
</fileset>
5962

6063
<path id="compile.classpath">
@@ -75,7 +78,7 @@
7578

7679
<target name="compile" depends="init, definejarfile" description="compile the source">
7780
<!-- Compile class files-->
78-
<javac destdir="${classes}" includeantruntime="false" target="1.6" source="1.6"
81+
<javac destdir="${classes}" includeantruntime="false"
7982
debug="true" classpathref="compile.classpath">
8083
<src path="${src}"/>
8184
<exclude name="us/kbase/common/performance/**"/>
@@ -118,7 +121,7 @@
118121

119122
<target name="test" depends="compile, preparejunitreportdir" description="run tests">
120123
<echo message="starting ${package} tests"/>
121-
<junit failureproperty="test.failed" printsummary="yes">
124+
<junit failureproperty="test.failed" printsummary="yes" fork="yes">
122125
<classpath path="${jarfile}.jar"/>
123126
<classpath refid="compile.classpath"/>
124127
<formatter type="plain" usefile="false"/>

src/us/kbase/common/mongo/GetMongoDB.java

+15-6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.mongodb.MongoClient;
1414
import com.mongodb.MongoClientOptions;
1515
import com.mongodb.MongoException;
16+
import com.mongodb.MongoTimeoutException;
1617

1718
import org.slf4j.Logger;
1819
import org.slf4j.LoggerFactory;
@@ -35,6 +36,8 @@
3536
*/
3637
public class GetMongoDB {
3738

39+
//TODO needs rewrite. 1) Add tests, 2) deprecated methods, 2) replace NFE, 3) auth in constructor, 4) multiple hosts option, 5) logger on/off option 6) retry rewrite for mongo timeouts.
40+
3841
private static Logger getLogger() {
3942
return LoggerFactory.getLogger(GetMongoDB.class);
4043
}
@@ -96,7 +99,7 @@ public static DB getDB(final String host, final String database)
9699
* @param host the MongoDB host address.
97100
* @param database the database to get.
98101
* @param retryCount - the number of times to retry the MongoDB
99-
* connection, 1 retry / sec.
102+
* connection, 1 retry / sec, not including the time retrying takes.
100103
* @param logIntervalCount - how often to log the retries. Logs occur when
101104
* retries % logIntervalCount = 0.
102105
* @return the MongoDB database instance.
@@ -120,9 +123,12 @@ public static DB getDB(final String host, final String database,
120123
try {
121124
db.getCollectionNames();
122125
break;
123-
} catch (MongoException.Network men) {
126+
} catch (MongoException.Network | MongoTimeoutException e ) {
124127
if (retries >= retryCount) {
125-
throw (IOException) men.getCause();
128+
if (e instanceof MongoException.Network) {
129+
throw (IOException) e.getCause();
130+
}
131+
throw e;
126132
}
127133
if (retries % logIntervalCount == 0) {
128134
getLogger().info(
@@ -165,7 +171,7 @@ public static DB getDB(final String host, final String database,
165171
* @param user the MongoDB user with access to the database.
166172
* @param pwd the MongoDB user's password.
167173
* @param retryCount - the number of times to retry the MongoDB
168-
* connection, 1 retry / sec.
174+
* connection, 1 retry / sec, not including the time retrying takes.
169175
* @param logIntervalCount - how often to log the retries. Logs occur when
170176
* retries % logIntervalCount = 0.
171177
* @return the MongoDB database instance.
@@ -191,9 +197,12 @@ public static DB getDB(final String host, final String database,
191197
try {
192198
db.authenticate(user, pwd.toCharArray());
193199
break;
194-
} catch (MongoException.Network men) {
200+
} catch (MongoException.Network | MongoTimeoutException e) {
195201
if (retries >= retryCount) {
196-
throw (IOException) men.getCause();
202+
if (e instanceof MongoException.Network) {
203+
throw (IOException) e.getCause();
204+
}
205+
throw e;
197206
}
198207
if (retries % logIntervalCount == 0) {
199208
getLogger().info(

0 commit comments

Comments
 (0)