Catch "connection refused"

瀏覽次數:95 次
跳到第一則未讀訊息

jday@sbi

未讀,
2012年5月16日 下午1:03:032012/5/16
收件者:mongodb-user
I am building an application as a service and I am engineering it to
handle if the database backend closes or becomes unavailable for any
particular reason.

One of the scenarios I have is if the mongodb service is shut down
unexpectedly. At present I can catch most throwable errors, except
for:

May 08, 2012 5:13:42 PM com.mongodb.DBTCPConnector
fetchMaxBsonObjectSize
WARNING: Exception determining maxBSON size using0
java.io.IOException: couldn't connect to [/127.0.0.1:27017]
bc:java.net.ConnectException: Connection refused
at com.mongodb.DBPort._open(DBPort.java:228)
at com.mongodb.DBPort.go(DBPort.java:112)
at com.mongodb.DBPort.go(DBPort.java:93)
at com.mongodb.DBPort.findOne(DBPort.java:146)
at com.mongodb.DBPort.runCommand(DBPort.java:157)
at
com.mongodb.DBTCPConnector.fetchMaxBsonObjectSize(DBTCPConnector.java:
457)
at com.mongodb.DBTCPConnector.checkMaster(DBTCPConnector.java:
444)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:209)
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:
305)
at com.mongodb.DB.command(DB.java:160)
at com.mongodb.DB.command(DB.java:183)
at com.mongodb.DB.command(DB.java:144)
at com.mongodb.DB._doauth(DB.java:541)
at com.mongodb.DB.authenticate(DB.java:478)
at
com.smartbombinteractive.dataRunners.MongoRawRunner.connect(MongoRawRunner.java:
135)
...

If I include java.io.IOException and attempt to catch (IOException e)
the error still goes through to output and pummels my logs. I have an
(Exception e) catchall at the end of the catches that is being skipped
too.

How do I correctly catch this exception? Or... what setting do I use
to quiet these output entries.
訊息已遭刪除

Eliot Horowitz

未讀,
2012年5月16日 晚上9:08:262012/5/16
收件者:mongod...@googlegroups.com
The message is being logged from inside the driver.
The logger is "com.mongodb.tcp", so you can increase the log level to
ERROR so you won't see those warnings.
> --
> You received this message because you are subscribed to the Google
> Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com
> To unsubscribe from this group, send email to
> mongodb-user...@googlegroups.com
> See also the IRC channel -- freenode.net#mongodb
回覆所有人
回覆作者
轉寄
0 則新訊息