Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed #10 - constant versions of various hank exception responses

  • Loading branch information...
commit 7f4a11738a991b2a953c22982a6905a39df54f0e 1 parent 77f8f61
bryanduxbury authored
View
4 src/java/com/rapleaf/hank/client/HankSmartClient.java
@@ -48,6 +48,8 @@
* pool and detecting PartDaemon failures.
*/
public class HankSmartClient implements Iface, RingGroupChangeListener, RingStateChangeListener {
+ private static final HankResponse NO_SUCH_DOMAIN = HankResponse.xception(HankExceptions.no_such_domain(true));
+
private static final Logger LOG = Logger.getLogger(HankSmartClient.class);
private final DomainGroupConfig domainGroup;
@@ -134,7 +136,7 @@ public HankResponse get(String domain_name, ByteBuffer key) throws TException {
DomainConfig domainConfig = domainGroup.getDomainConfig(domainId);
partition = domainConfig.getPartitioner().partition(key) % domainConfig.getNumParts();
} catch (DataNotFoundException e) {
- return HankResponse.xception(HankExceptions.no_such_domain(true));
+ return NO_SUCH_DOMAIN;
}
Map<Integer, PartDaemonConnectionSet> domainMap = domainPartToHost.get(domainId);
View
12 src/java/com/rapleaf/hank/part_daemon/Handler.java
@@ -41,6 +41,12 @@
* Implements the actual data serving logic of the PartDaemon
*/
class Handler implements Iface {
+ private static final HankResponse WRONG_HOST = HankResponse.xception(HankExceptions.wrong_host(true));
+
+ private static final HankResponse NOT_FOUND = HankResponse.not_found(true);
+
+ private static final HankResponse NO_SUCH_DOMAIN = HankResponse.xception(HankExceptions.no_such_domain(true));
+
private final static Logger LOG = Logger.getLogger(Handler.class);
private final Domain[] domains;
@@ -93,7 +99,7 @@ public HankResponse get(int domainId, ByteBuffer key) throws TException {
Domain domain = getDomain(domainId & 0xff);
if (domain == null) {
- return HankResponse.xception(HankExceptions.no_such_domain(true));
+ return NO_SUCH_DOMAIN;
}
try {
@@ -101,10 +107,10 @@ public HankResponse get(int domainId, ByteBuffer key) throws TException {
if (result.isFound()) {
return HankResponse.value(result.getBuffer());
} else {
- return HankResponse.not_found(true);
+ return NOT_FOUND;
}
} else {
- return HankResponse.xception(HankExceptions.wrong_host(true));
+ return WRONG_HOST;
}
} catch (IOException e) {
String errMsg = String.format("Exception during get! Domain: %d (%s) Key: %s",
Please sign in to comment.
Something went wrong with that request. Please try again.