哪个更好:setDefaultHighRepJobPolicyUnappliedJobPercentage(100)与CustomHighRepJobPolicy [英] Which is better: setDefaultHighRepJobPolicyUnappliedJobPercentage(100) vs. CustomHighRepJobPolicy

查看:135
本文介绍了哪个更好:setDefaultHighRepJobPolicyUnappliedJobPercentage(100)与CustomHighRepJobPolicy的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在最差的一致性条件下测试我的应用程序。似乎有两种方法可以使用:

方式A1:setDefaultHighRepJobPolicyUnappliedJobPercentage(100)

  private final LocalServiceTestHelper helper = 
new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig()
.setDefaultHighRepJobPolicyUnappliedJobPercentage(100));

来源: https://cloud.google.com/appengine/docs/java/tools/localunittesting#Writing_HRD_Datastore_Tests



方法A2:CustomHighRepJobPolicy

  private static final class CustomHighRepJobPolicy implements HighRepJobPolicy {
@Override
public boolean shouldApplyNewJob(Key arg0){
return false;
}
@Override
public boolean shouldRollForwardExistingJob(Key arg0){
return false;


private final LocalServiceTestHelper helper = $ b $ new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig()
.setAlternateHighRepJobPolicyClass(CustomHighRepJobPolicy.class));

来源: https://groups.google.com/forum/#!topic/google-appengine-java/JLu29LTZPV4 (来自Broc Seib的评论)



问题A



这两种方法似乎都产生了从不更新的索引,以便没有祖先的查询永远不会返回结果。但是,在这两种方法中应该知道的有什么不同?

问题B



当测试相反的结果(没有最终的一致性,以至于索引立即更新)时,似乎有三种方法......应该有什么区别?

方法B1:setDefaultHighRepJobPolicyUnappliedJobPercentage(0)

  private final LocalServiceTestHelper helper = 
new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig()
.setDefaultHighRepJobPolicyUnappliedJobPercentage(0));

来源: https://cloud.google.com/appengine/docs/java/tools/localunittesting#Writing_HRD_Datastore_Tests



方法B2:CustomHighRepJobPolicy

  private static final class CustomHighRepJobPolicy implements HighRepJobPolicy {
@Override
public boolean shouldApplyNewJob(Key arg0){
return true;
}
@Override
public boolean shouldRollForwardExistingJob(Key arg0){
return true;


private final LocalServiceTestHelper helper = $ b $ new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig()
.setAlternateHighRepJobPolicyClass(CustomHighRepJobPolicy.class));

来源: https://groups.google.com/forum/#!topic/google-appengine-java/JLu29LTZPV4 (来自Broc Seib的评论)



方法B3:setApplyAllHighRepJobPolicy

 私人final LocalServiceTestHelper helper = 
new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig()
.setApplyAllHighRepJobPolicy());

来源: https://cloud.google.com/appengine/docs/java/tools/localunittesting#Writing_HRD_Datastore_Tests

测量每个选项。这将回答你的合理怀疑,比我们任何人都可以通过琢磨! 你没有衡量,你无法管理和数据roolz!

我不知道这些方法之间有任何实质性区别 - 并不意味着不是任何(可惜,Java不是我最强的领域,所以可能有我不知道的Java特定细节!)...

相反,这意味着我将在你的鞋子中做的事情就是我在这里推荐的 - 将一些重负载测试工作负载集中在一起,并通过相同的一组单元测试运行它们,只有政策,看看测试结果和运行时间会发生什么。



我希望观察到相同的测试结果和大致相同的运行时间,任何差异都会显示我需要深入挖掘的地方! - )

I'm trying to test my app under the worst conditions for eventual consistency. It seems like there are two approaches I can use:

Approach A1: setDefaultHighRepJobPolicyUnappliedJobPercentage(100)

private final LocalServiceTestHelper helper =
        new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig()
            .setDefaultHighRepJobPolicyUnappliedJobPercentage(100));    

source: https://cloud.google.com/appengine/docs/java/tools/localunittesting#Writing_HRD_Datastore_Tests

Approach A2: CustomHighRepJobPolicy

private static final class CustomHighRepJobPolicy implements HighRepJobPolicy {
    @Override
    public boolean shouldApplyNewJob(Key arg0) {
        return false;
    }
    @Override
    public boolean shouldRollForwardExistingJob(Key arg0) {
        return false;
    }   
}
private final LocalServiceTestHelper helper =
        new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig()
        .setAlternateHighRepJobPolicyClass(CustomHighRepJobPolicy.class));

source: https://groups.google.com/forum/#!topic/google-appengine-java/JLu29LTZPV4 (comment from Broc Seib)

Question A

Both approaches seem to produce the desired effect of never updating any of the indices so that queries without an ancestor never return results. But are there any differences in these two approaches one should be aware of?

Question B

When testing the opposite (no eventual consistency such that indices are updated immediately), there seems to be three approaches...are there any differences one should be are of?

Approach B1: setDefaultHighRepJobPolicyUnappliedJobPercentage(0)

private final LocalServiceTestHelper helper =
        new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig()
            .setDefaultHighRepJobPolicyUnappliedJobPercentage(0));  

source: https://cloud.google.com/appengine/docs/java/tools/localunittesting#Writing_HRD_Datastore_Tests

Approach B2: CustomHighRepJobPolicy

private static final class CustomHighRepJobPolicy implements HighRepJobPolicy {
    @Override
    public boolean shouldApplyNewJob(Key arg0) {
        return true;
    }
    @Override
    public boolean shouldRollForwardExistingJob(Key arg0) {
        return true;
    }   
}
private final LocalServiceTestHelper helper =
        new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig()
        .setAlternateHighRepJobPolicyClass(CustomHighRepJobPolicy.class));

source: https://groups.google.com/forum/#!topic/google-appengine-java/JLu29LTZPV4 (comment from Broc Seib)

Approach B3: setApplyAllHighRepJobPolicy

private final LocalServiceTestHelper helper =
        new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig()
            .setApplyAllHighRepJobPolicy());    

source: https://cloud.google.com/appengine/docs/java/tools/localunittesting#Writing_HRD_Datastore_Tests

解决方案

My recommended approach is to measure each choice under a realistic/pessimistic load-testing simulated workload. That will answer your reasonable doubts much better than any of us might by just pondering on it! "What you don't measure, you can't manage", and "data roolz"!

I am not aware of any substantial difference between these approaches -- that doesn't mean there aren't any (alas, Java's not my strongest area, so there may be Java specific subtleties I'm not aware of!)...

Rather, it means that what I would do in your shoes would be exactly what I recommend here -- hack together some heavy load-testing workloads, and run them through the same bunch of unit tests, varying only the policy, and see what happens in terms of test results and running times.

I'd expect to observe the same test results, and roughly equal running times, and any discrepancy would show me where I need to dig in deeper!-)

这篇关于哪个更好:setDefaultHighRepJobPolicyUnappliedJobPercentage(100)与CustomHighRepJobPolicy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆