Class DefaultHighRepJobPolicy

java.lang.Object
com.google.appengine.api.datastore.dev.DefaultHighRepJobPolicy
All Implemented Interfaces:
HighRepJobPolicy

public class DefaultHighRepJobPolicy extends Object implements HighRepJobPolicy
An implementation of HighRepJobPolicy in which a user-defined percentage of jobs do not apply. The percentage applies to both new (initial write) and existing (roll forward) jobs. The user can also provide a random seed, which can be used to make the behavior of this class deterministic in tests.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    A long that will be used as the seed for the Random that determines whether or not a job application attempt fails.
    static final String
    A float >= 0 and invalid input: '<'= 100 representing the percentage of job application attempts that will fail.
  • Constructor Summary

    Constructors
    Constructor
    Description
    DefaultHighRepJobPolicy(long unappliedJobSeed, float unappliedJobPercentage)
    Constructs a DefaultHighRepJobPolicy.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    shouldApplyNewJob(com.google.appengine.api.datastore.Key entityGroup)
    Returns true if the new job should apply according to the policy, false otherwise.
    boolean
    shouldRollForwardExistingJob(com.google.appengine.api.datastore.Key entityGroup)
    Returns true if the existing job should roll forward according to the policy, false otherwise.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • RANDOM_SEED_PROPERTY

      public static final String RANDOM_SEED_PROPERTY
      A long that will be used as the seed for the Random that determines whether or not a job application attempt fails. Must be parsable via Long.parseLong(String). If not provided we use the current time (in millis) as the seed.
      See Also:
    • UNAPPLIED_JOB_PERCENTAGE_PROPERTY

      public static final String UNAPPLIED_JOB_PERCENTAGE_PROPERTY
      A float >= 0 and invalid input: '<'= 100 representing the percentage of job application attempts that will fail. Must be parsable via Float.parseFloat(String). Any portion of the value beyond two decimal places will be truncated. If not provided we set the percentage to 0.
      See Also:
  • Constructor Details

    • DefaultHighRepJobPolicy

      public DefaultHighRepJobPolicy(long unappliedJobSeed, float unappliedJobPercentage)
      Constructs a DefaultHighRepJobPolicy.
      Parameters:
      unappliedJobSeed - The seed to use for random number generation.
      unappliedJobPercentage - The percentage of jobs that should fail to apply. This percentage applies to both new jobs and attempts to roll forward existing unapplied jobs.
  • Method Details

    • shouldApplyNewJob

      public boolean shouldApplyNewJob(com.google.appengine.api.datastore.Key entityGroup)
      Description copied from interface: HighRepJobPolicy
      Returns true if the new job should apply according to the policy, false otherwise.
      Specified by:
      shouldApplyNewJob in interface HighRepJobPolicy
      Parameters:
      entityGroup - A unique identifier for the entity group.
    • shouldRollForwardExistingJob

      public boolean shouldRollForwardExistingJob(com.google.appengine.api.datastore.Key entityGroup)
      Description copied from interface: HighRepJobPolicy
      Returns true if the existing job should roll forward according to the policy, false otherwise.
      Specified by:
      shouldRollForwardExistingJob in interface HighRepJobPolicy
      Parameters:
      entityGroup - A unique identifier for the entity group.