Beispiel #1
0
 static MongoException parse(final BSONObject o) {
   final String s = ServerError.getMsg(o, null);
   if (s == null) {
     return null;
   }
   return new MongoException(ServerError.getCode(o), s);
 }
  public Response call(DB db, DBCollection coll, OutMessage m, int retries) throws MongoException {

    final MyPort mp = _threadPort.get();
    final DBPort port = mp.get(false);

    port.checkAuth(db);

    Response res = null;
    try {
      res = port.call(m, coll);
      mp.done(port);
    } catch (IOException ioe) {
      mp.error(ioe);
      if (_error(ioe) && retries > 0) {
        return call(db, coll, m, retries - 1);
      }
      throw new MongoException.Network("can't call something", ioe);
    } catch (RuntimeException re) {
      mp.error(re);
      throw re;
    }

    ServerError err = res.getError();

    if (err != null && err.isNotMasterError()) {
      _pickCurrent();
      if (retries <= 0) {
        throw new MongoException("not talking to master and retries used up");
      }
      return call(db, coll, m, retries - 1);
    }

    return res;
  }
Beispiel #3
0
 public MongoException(final BSONObject o) {
   this(ServerError.getCode(o), ServerError.getMsg(o, "UNKNOWN"));
 }