Permalink
Browse files
JAVA-334: too much exception logging from updater thread when a serve…
…r is down JAVA-347: in case all servers are down do not retry reads
Showing
with
29 additions
and 15 deletions.
15
src/main/com/mongodb/DBTCPConnector.java
29
src/main/com/mongodb/ReplicaSetStatus.java
| @@ -118,6 +118,16 @@ ServerAddress getASecondary(){ | ||
| return best._addr; | ||
| } | ||
| + boolean hasServerUp() { | ||
| + for (int i = 0; i < _all.size(); i++) { | ||
| + Node n = _all.get(i); | ||
| + if (n._ok) { | ||
| + return true; | ||
| + } | ||
| + } | ||
| + return false; | ||
| + } | ||
| + | ||
| class Node { | ||
| Node( ServerAddress addr ){ | ||
| @@ -151,10 +161,12 @@ synchronized void update(Set<Node> seenNodes){ | ||
| _pingTime = _lastCheck - start; | ||
| if ( res == null ){ | ||
| - _ok = false; | ||
| - return; | ||
| + throw new MongoInternalException("Invalid null value returned from isMaster"); | ||
| } | ||
| + if (!_ok) { | ||
| + _logger.log( Level.WARNING , "Server seen up: " + _addr ); | ||
| + } | ||
| _ok = true; | ||
| _isMaster = res.getBoolean( "ismaster" , false ); | ||
| _isSecondary = res.getBoolean( "secondary" , false ); | ||
| @@ -199,15 +211,12 @@ else if ( !_setName.equals( setName ) ){ | ||
| } | ||
| } | ||
| - catch ( MongoException e ){ | ||
| - Throwable root = e; | ||
| - if ( e.getCause() != null ) | ||
| - root = e.getCause(); | ||
| - _logger.log( Level.FINE , "node down: " + _addr + " " + root ); | ||
| - _ok = false; | ||
| - } | ||
| catch ( Exception e ){ | ||
| - _logger.log( Level.SEVERE , "can't update node: " + _addr , e ); | ||
| + if (_ok == true) { | ||
| + _logger.log( Level.WARNING , "Server seen down: " + _addr, e ); | ||
| + } else if (Math.random() < 0.1) { | ||
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
|
||
| + _logger.log( Level.WARNING , "Server seen down: " + _addr ); | ||
| + } | ||
| _ok = false; | ||
| } | ||
May be just decrease the Level to INFO?