-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added a logger via error callback to all HBase operations
- Loading branch information
1 parent
2ef8ee6
commit f330b74
Showing
2 changed files
with
45 additions
and
12 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
src/main/java/org/elasticsearch/river/hbase/HBaseCallbackLogger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.elasticsearch.river.hbase; | ||
|
||
import org.elasticsearch.common.logging.ESLogger; | ||
|
||
import com.stumbleupon.async.Callback; | ||
|
||
/** | ||
* A small helper class that will log any responses from HBase, in case there are any. | ||
* | ||
* @author Ravi Gairola | ||
*/ | ||
public class HBaseCallbackLogger implements Callback<Object, Object> { | ||
private final ESLogger logger; | ||
private final String realm; | ||
|
||
public HBaseCallbackLogger(final ESLogger logger, final String realm) { | ||
this.logger = logger; | ||
this.realm = realm; | ||
} | ||
|
||
@Override | ||
public Object call(final Object arg) throws Exception { | ||
if (arg instanceof Throwable) { | ||
this.logger.error("An async error has been caught within {}:", (Throwable) arg, this.realm); | ||
} | ||
else { | ||
this.logger.trace("Got response from HBase in realm {}: {}", this.realm, arg); | ||
} | ||
return arg; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters