java backoff_Java BackOff类代码示例
import org.apache.beam.sdk.util.BackOff; //导入依赖的package包/类
/**
* Writes a batch of mutations to Cloud Datastore.
*
*
If a commit fails, it will be retried up to {@link #MAX_RETRIES} times. All
* mutations in the batch will be committed again, even if the commit was partially
* successful. If the retry limit is exceeded, the last exception from Cloud Datastore will be
* thrown.
*
* @throws DatastoreException if the commit fails or IOException or InterruptedException if
* backing off between retries fails.
*/
private void flushBatch() throws DatastoreException, IOException, InterruptedException {
LOG.debug("Writing batch of {} mutations", mutations.size());
Sleeper sleeper = Sleeper.DEFAULT;
BackOff backoff = BUNDLE_WRITE_BACKOFF.backoff();
while (true) {
// Batch upsert entities.
CommitRequest.Builder commitRequest = CommitRequest.newBuilder();
commitRequest.addAllMutations(mutations);
commitRequest.setMode(CommitRequest.Mode.NON_TRANSACTIONAL);
long startTime = System.currentTimeMillis(), endTime;
if (throttler.throttleRequest(startTime)) {
LOG.info("Delaying request due to previous failures");
throttledSeconds.inc(WriteBatcherImpl.DATASTORE_BATCH_TARGET_LATENCY_MS / 1000);
sleeper.sleep(WriteBatcherImpl.DATASTORE_BATCH_TARGET_LATENCY_MS);
continue;
}
try {
datastore.commit(commitRequest.build());
endTime = System.currentTimeMillis();
writeBatcher.addRequestLatency(endTime, endTime - startTime, mutations.size());
throttler.successfulRequest(startTime);
rpcSuccesses.inc();
// Break if the commit threw no exception.
break;
} catch (DatastoreException exception) {
if (exception.getCode() == Code.DEADLINE_EXCEEDED) {
/* Most errors are not related to request size, and should not change our expectation of
* the latency of successful requests. DEADLINE_EXCEEDED can be taken into
* consideration, though. */
endTime = System.currentTimeMillis();
writeBatcher.addRequestLatency(endTime, endTime - startTime, mutations.size());
}
// Only log the code and message for potentially-transient errors. The entire exception
// will be propagated upon the last retry.
LOG.error("Error writing batch of {} mutations to Datastore ({}): {}", mutations.size(),
exception.getCode(), exception.getMessage());
rpcErrors.inc();
if (NON_RETRYABLE_ERRORS.contains(exception.getCode())) {
throw exception;
}
if (!BackOffUtils.next(sleeper, backoff)) {
LOG.error("Aborting after {} retries.", MAX_RETRIES);
throw exception;
}
}
}
LOG.debug("Successfully wrote {} mutations", mutations.size());
mutations.clear();
mutationsSize = 0;
}
java backoff_Java BackOff类代码示例相关推荐
- java dataconvert_Java DateConverter类代码示例
import org.apache.commons.beanutils.converters.DateConverter; //导入依赖的package包/类 /** * Register array ...
- java parseexception_Java ParseException类代码示例
import com.sun.org.apache.xerces.internal.impl.xpath.regex.ParseException; //导入依赖的package包/类 @Overri ...
- java link_Java Link类代码示例
import org.nodes.Link; //导入依赖的package包/类 public static double sizeBetaCopying(DGraph graph, DGraph s ...
- java bar_Java Bar类代码示例
import com.db.chart.model.Bar; //导入依赖的package包/类 @Override protected void onCreate(Bundle savedInsta ...
- java widget_Java FavoritesWidget类代码示例
import com.google.gwt.sample.dynatablerf.client.widgets.FavoritesWidget; //导入依赖的package包/类 /** * Thi ...
- java direction_Java Direction类代码示例
import android.support.test.uiautomator.Direction; //导入依赖的package包/类 /** * Navigates through the foc ...
- java plugin_Java Plugin类代码示例
import org.apache.logging.log4j.core.config.plugins.Plugin; //导入依赖的package包/类 /** * @since 2.1 */ pu ...
- java jsonresult_Java JsonResult类代码示例
import eu.socialsensor.framework.client.search.visual.JsonResultSet.JsonResult; //导入依赖的package包/类 @O ...
- postgresql java demo_Java PostgreSQL9Dialect类代码示例
import org.hibernate.dialect.PostgreSQL9Dialect; //导入依赖的package包/类 private void addDialects(Strategy ...
最新文章
- Linux 使用者身份與群組記錄的檔案
- ICRA 2021 | VINS 研讨会概要(附完整视频)
- 人为什么要睡觉?科学家给出进一步答案
- 两对光纤收发器用网线连接_光纤那么快,路由器和电脑之间为何不用光纤连接,反而用普通网线...
- java string blob_java String类型转换为Blob类型
- openglshader实现虚拟场景_云桌面,实现办公终端的统一管理与运维
- ubuntu14.04 64bit主机下面安装android的NDK开发环境
- spring cloud gateway 网关_微服务网关Spring Cloud Gateway全搞定
- 安装deepin_deepin使用笔记,安装steam客户端
- [转]一千行MySQL学习笔记
- 教你成为全栈工程师(Full Stack Developer) 一-各显神通总结八大类编程语言的区别...
- RocketMQ安装使用
- wi ndows防火墙,WinXP自带防火墙设置详细讲解
- 电机控制方法以及区别
- 数独游戏技巧从入门到精通_免费教学视频数独阶梯训练让孩子从入门到精通,数学思维直线上升!...
- VirtualBox中不能正常使用OpneGL的问题
- matlab专业代做hslogic,matlab代做hslogic
- uni-app实现文件管理器(Android)
- c语言莫莫加等于莫莫什么意思,莫莫Momo
- 爬取广东工业大学新闻通知网最新通知并发送至 QQ 邮箱
热门文章
- [cogs2482][二分答案]Franky的胡子
- unity 彩带粒子_超级技术贴:Unity粒子遇上着色器,引爆视觉特效
- 惠普HP LaserJet M5035 打印机驱动
- HxD - Freeware Hex Editor and Disk Editor
- 《第十三届服创大赛A23项目-基于区块链的艺术品数字资产确权流通系统》的未完成版
- Redis-6.2.* 版本配置文件redis.conf详解
- Python识别二维码获取电子发票基本信息
- LinkIQ 福禄克全新的以太网电缆,网络和PoE测试仪LIQ-100 LIQ-KIT
- c word to html 走样,打印机打印效果走样解决办法.pptx
- Mina中的Kimchi SNARK