查看: 1057| 回复: 2
跳转到指定楼层
上一主题 下一主题
收起左侧

[学Java/C#] 求debug一个Java程序

🔗
匿名用户-7EZNX  2020-10-13 05:34:37 |倒序浏览

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看附件。没有帐号?注册账号

x
刚面完某一线大厂,直接歇菜并且懵了。

下面的程序有问题,请问怎么debug呢?  

ExponentialBackOff是啥有人知道么?

  1. @ProcessElement
  2. public void processElement(DoFn<String, Integer>.ProcessContext context) throws Exception {
  3.   
  4.   String variantId = context.element();
  5.   
  6.   ExponentialBackOff backoff = new ExponentialBackOff.Builder().build();
  7.   
  8.   while (true) {
  9.    
  10.     try {
  11.       
  12.       genomics.variants().delete(variantId).execute();
  13.       
  14.       Metrics.counter(DeleteVariantFn.class, "Number of variants deleted").inc();
  15.       
  16.       context.output(1);
  17.       
  18.       return;
  19.       
  20.     } catch (Exception e) {
  21.       
  22.       if (e.getMessage().startsWith("it is too many requests")) {
  23.         
  24.         LOG.warn("Backing-off per: ", e);
  25.         
  26.         long backOffMillis = backoff.nextBackOffMillis();
  27.         
  28.         if (backOffMillis == BackOff.STOP) {
  29.           throw e;
  30.         }
  31.         
  32.       } else {
  33.         throw e;
  34.       }
  35.       
  36.     }
  37.    
  38.   }
  39. }


复制代码



上一篇:大家见过这道LIS变种题吗
下一篇:需要掌握手写quick sort/quick select吗?
推荐
zli_test 2020-10-20 10:16:34 | 只看该作者
全局:
I guess the problem is here:
  1.                     long backOffMillis = backoff.nextBackOffMillis();

  2.                     if (backOffMillis == BackOff.STOP) {
  3.                         throw e;
  4.                     } else {
  5.                         TimeUnit.MILLISECONDS.sleep(backOffMillis);
  6.                     }
复制代码


Basically, you need to add the code as above.  Otherwise, it doesn't backoff.  Exponential Backoff is how long you need to wait.  The wait time increases exponentially.  For example, first time you wait 1 sec,  2nd time 2 sec, 3rd time 4 sec, and etc.  so the wait time is 2^(n-1) sec n is the number of times it runs.
回复

使用道具 举报

推荐
usr_opta 2020-10-20 08:38:29 | 只看该作者
全局:
ExponentialBackOff是啥有人知道么?

有一种东西叫做搜索引擎。
下面的程序有问题,请问怎么debug呢?  

你要backoff但是代码里没看到backoff的语句。一般是sleep之类的。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

>
快速回复 返回顶部 返回列表