Skip to content

Commit 6899a69

Browse files
author
Ryan
committed
fixed layout - removed whitespaces.
1 parent c6ed1ed commit 6899a69

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

src/main/com/mongodb/DBTCPConnector.java

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public DBTCPConnector( Mongo m , List<ServerAddress> all )
6262

6363
_createLogger.info( all + " -> " + getAddress() );
6464
}
65-
65+
6666
public void start() {
6767
if (_rsStatus != null)
6868
_rsStatus.start();
@@ -127,7 +127,7 @@ WriteResult _checkWriteError( DB db , MyPort mp , DBPort port , WriteConcern con
127127

128128
if ( ! e.hasErr() )
129129
return new WriteResult( e , concern );
130-
130+
131131
e.throwOnError();
132132
return null;
133133
}
@@ -137,7 +137,7 @@ public WriteResult say( DB db , OutMessage m , WriteConcern concern )
137137
throws MongoException {
138138
return say( db , m , concern , null );
139139
}
140-
140+
141141
@Override
142142
public WriteResult say( DB db , OutMessage m , WriteConcern concern , ServerAddress hostNeeded )
143143
throws MongoException {
@@ -164,7 +164,7 @@ public WriteResult say( DB db , OutMessage m , WriteConcern concern , ServerAddr
164164

165165
if ( concern.raiseNetworkErrors() )
166166
throw new MongoException.Network( "can't say something" , ioe );
167-
167+
168168
CommandResult res = new CommandResult(port.serverAddress());
169169
res.put( "ok" , false );
170170
res.put( "$err" , "NETWORK ERROR" );
@@ -182,7 +182,7 @@ public WriteResult say( DB db , OutMessage m , WriteConcern concern , ServerAddr
182182
m.doneWithMessage();
183183
}
184184
}
185-
185+
186186
@Override
187187
public Response call( DB db , DBCollection coll , OutMessage m, ServerAddress hostNeeded, DBDecoder decoder )
188188
throws MongoException {
@@ -195,20 +195,22 @@ public Response call( DB db , DBCollection coll , OutMessage m , ServerAddress h
195195
}
196196

197197
@Override
198-
public Response call( DB db, DBCollection coll, OutMessage m, ServerAddress hostNeeded, int retries, ReadPreference readPref, DBDecoder decoder ) throws MongoException{
198+
public Response call( DB db, DBCollection coll, OutMessage m, ServerAddress hostNeeded, int retries, ReadPreference readPref, DBDecoder decoder ) throws MongoException{
199+
199200
if (readPref == null)
200201
readPref = ReadPreference.PRIMARY;
202+
201203
if (readPref == ReadPreference.PRIMARY && m.hasOption( Bytes.QUERYOPTION_SLAVEOK ))
202204
readPref = ReadPreference.SECONDARY;
203205

204206
boolean secondaryOk = !(readPref == ReadPreference.PRIMARY);
205207

206208
_checkClosed();
207209
checkMaster( false, !secondaryOk );
208-
210+
209211
final MyPort mp = _myPort.get();
210212
final DBPort port = mp.get( false , readPref, hostNeeded );
211-
213+
212214
Response res = null;
213215
boolean retry = false;
214216
try {
@@ -222,8 +224,8 @@ public Response call( DB db, DBCollection coll, OutMessage m, ServerAddress host
222224
retry = retries > 0 && !coll._name.equals( "$cmd" )
223225
&& !(ioe instanceof SocketTimeoutException) && _error( ioe, secondaryOk );
224226
if ( !retry ){
225-
throw new MongoException.Network( "can't call something : " + port.host() + "/" + db,
226-
ioe );
227+
throw new MongoException.Network( "can't call something : " + port.host() + "/" + db,
228+
ioe );
227229
}
228230
}
229231
catch ( RuntimeException re ){
@@ -237,15 +239,15 @@ public Response call( DB db, DBCollection coll, OutMessage m, ServerAddress host
237239
return call( db , coll , m , hostNeeded , retries - 1 , readPref, decoder );
238240

239241
ServerError err = res.getError();
240-
242+
241243
if ( err != null && err.isNotMasterError() ){
242244
checkMaster( true , true );
243245
if ( retries <= 0 ){
244246
throw new MongoException( "not talking to master and retries used up" );
245247
}
246248
return call( db , coll , m , hostNeeded , retries -1, readPref, decoder );
247249
}
248-
250+
249251
m.doneWithMessage();
250252
return res;
251253
}
@@ -272,7 +274,7 @@ public List<ServerAddress> getServerAddressList() {
272274
if (_rsStatus != null) {
273275
return _rsStatus.getServerAddressList();
274276
}
275-
277+
276278
ServerAddress master = getAddress();
277279
if (master != null) {
278280
// single server
@@ -319,7 +321,7 @@ boolean _error( Throwable t, boolean secondaryOk )
319321
class MyPort {
320322

321323
DBPort get( boolean keep , ReadPreference readPref, ServerAddress hostNeeded ){
322-
324+
323325
if ( hostNeeded != null ){
324326
// asked for a specific host
325327
return _portHolder.get( hostNeeded ).get();
@@ -338,7 +340,7 @@ DBPort get( boolean keep , ReadPreference readPref, ServerAddress hostNeeded ){
338340
_requestPort.getPool().done(_requestPort);
339341
_requestPort = null;
340342
}
341-
343+
342344
if ( !(readPref == ReadPreference.PRIMARY) && _rsStatus != null ){
343345
// if not a primary read set, try to use a secondary
344346
// Do they want a Secondary, or a specific tag set?
@@ -373,7 +375,7 @@ DBPort get( boolean keep , ReadPreference readPref, ServerAddress hostNeeded ){
373375

374376
return p;
375377
}
376-
378+
377379
void done( DBPort p ){
378380
// keep request port
379381
if ( p != _requestPort ){
@@ -394,14 +396,14 @@ void error( DBPort p , Exception e ){
394396
// depending on type of error, may need to close other connections in pool
395397
p.getPool().gotError(e);
396398
}
397-
399+
398400
void requestEnsureConnection(){
399401
if ( ! _inRequest )
400402
return;
401403

402404
if ( _requestPort != null )
403405
return;
404-
406+
405407
_requestPort = _masterPortPool.get();
406408
}
407409

@@ -420,10 +422,10 @@ void requestDone(){
420422
// DBPortPool _requestPool;
421423
boolean _inRequest;
422424
}
423-
425+
424426
void checkMaster( boolean force , boolean failIfNoMaster )
425427
throws MongoException {
426-
428+
427429
if ( _rsStatus != null ){
428430
if ( _masterPortPool == null || force ){
429431
ReplicaSetStatus.Node n = _rsStatus.ensureMaster();
@@ -470,7 +472,7 @@ int fetchMaxBsonObjectSize() {
470472

471473
void testMaster()
472474
throws MongoException {
473-
475+
474476
DBPort p = null;
475477
try {
476478
p = _masterPortPool.get();
@@ -504,7 +506,7 @@ public String debugString(){
504506

505507
return buf.toString();
506508
}
507-
509+
508510
public void close(){
509511
_closed = true;
510512
if ( _portHolder != null ) {

0 commit comments

Comments
 (0)