本文整理汇总了Java中com.stumbleupon.async.Deferred.addErrback方法的典型用法代码示例。如果您正苦于以下问题:Java Deferred.addErrback方法的具体用法?Java Deferred.addErrback怎么用?Java Deferred.addErrback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.stumbleupon.async.Deferred
的用法示例。
在下文中一共展示了Deferred.addErrback方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeDataPoints
import com.stumbleupon.async.Deferred; //导入方法依赖的package包/类
/**
* Main entry method for adding points
*
* @param data points list
*/
private void writeDataPoints(List<EventData> data) throws Exception {
if (data.size() < 1)
return;
final WritableDataPoints dataPoints = tsdb.newDataPoints();
final EventData first = data.get(0);
dataPoints.setSeries(first.metric, first.tags);
dataPoints.setBatchImport(false); // we need data to be persisted
long prevTs = 0;
Set<String> failures = new HashSet<String>();
for (EventData eventData : data) {
try {
if (eventData.timestamp == prevTs)
continue;
sinkCounter.incrementEventDrainAttemptCount();
prevTs = eventData.timestamp;
final Deferred<Object> d =
eventData.makeDeferred(dataPoints, this);
d.addCallback(new Callback<Object, Object>() {
@Override
public Object call(Object o) throws Exception {
pointsCounter.mark();
inFlight.decrementAndGet();
signal.release();
return null;
}
});
d.addErrback(this);
if (throttle)
throttle(d);
inFlight.incrementAndGet();
sinkCounter.incrementEventDrainSuccessCount();
} catch (IllegalArgumentException ie) {
failures.add(ie.getMessage());
}
}
if (failures.size() > 0) {
logger.error("Points imported with " + failures.toString() + " IllegalArgumentExceptions");
}
}