[JAVA-211] need to be able to determine if there is an error or exception Created: 04/Nov/10 Updated: 04/Dec/13 Resolved: 07/Mar/12 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Cluster Management, Connection Management |
| Affects Version/s: | 2.3 |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Joseph Wang | Assignee: | Eliot Horowitz (Inactive) |
| Resolution: | Incomplete | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
Have the following codes: try { if (enable_limit) { cur = coll.find(query).limit(20).addOption( Bytes.QUERYOPTION_SLAVEOK); } else { cur = coll.find(query).addOption(Bytes.QUERYOPTION_SLAVEOK); }size = enable_limit ? cur.itcount() : cur.size(); } catch (Exception ex) { System.out.println("count: get exception " + ex); ex.printStackTrace(); db = mongo.getDb("lp"); coll = db.getCollection("lp.mrtest"); if (enable_limit) { cur = coll.find(query).limit(20).addOption( Bytes.QUERYOPTION_SLAVEOK); } else { cur = coll.find(query).addOption(Bytes.QUERYOPTION_SLAVEOK); }size = enable_limit ? cur.itcount() : cur.size(); System.out.println("count: get " + size); } catch (Throwable t) { System.out.println("count: get thowable " + t); t.printStackTrace(); db = mongo.getDb("lp"); coll = db.getCollection("lp.mrtest"); if (enable_limit) { cur = coll.find(query).limit(20).addOption( Bytes.QUERYOPTION_SLAVEOK); } else { cur = coll.find(query).addOption(Bytes.QUERYOPTION_SLAVEOK); } size = enable_limit ? cur.itcount() : cur.size(); Testing failover by issuing kill -9 on the primary node. Cannot seem to be able to catch exception s.t. I java.io.IOException: couldn't connect to [ip-10-166-59-166/10.166.59.166:20000] bc:java.net.ConnectException: Connection refused |
| Comments |
| Comment by Jeffrey Yemin [ 07/Mar/12 ] |
|
Please re-open if you have more information that you can share. |
| Comment by Scott Hernandez (Inactive) [ 26/Aug/11 ] |
|
Joseph, Can you test with the latest driver? If not I'm going to close this as a lot of this code has changed already. |
| Comment by Eliot Horowitz (Inactive) [ 22/Nov/10 ] |
|
You should have gotten a MongoException.Network error |
| Comment by Joseph Wang [ 04/Nov/10 ] |
|
Tried db.getLastError(). Doesn't seem to work. DBObject dbObject = db.getLastError(); } java.net.SocketException: Connection reset |