public class DefaultHighRepJobPolicy extends java.lang.Object implements HighRepJobPolicy
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.Modifier and Type | Field and Description |
---|---|
static java.lang.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. |
static java.lang.String |
UNAPPLIED_JOB_PERCENTAGE_PROPERTY
A float >= 0 and <= 100 representing the percentage of job application attempts that will fail.
|
Constructor and Description |
---|
DefaultHighRepJobPolicy(long unappliedJobSeed,
float unappliedJobPercentage)
Constructs a
DefaultHighRepJobPolicy . |
Modifier and Type | Method and Description |
---|---|
boolean |
shouldApplyNewJob(com.google.appengine.api.datastore.Key entityGroup) |
boolean |
shouldRollForwardExistingJob(com.google.appengine.api.datastore.Key entityGroup) |
public static final java.lang.String RANDOM_SEED_PROPERTY
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.public static final java.lang.String UNAPPLIED_JOB_PERCENTAGE_PROPERTY
Float.parseFloat(String)
. Any portion of the value beyond two
decimal places will be truncated. If not provided we set the percentage to 0, which yields the
master/slave consistency model.public DefaultHighRepJobPolicy(long unappliedJobSeed, float unappliedJobPercentage)
DefaultHighRepJobPolicy
.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.public boolean shouldApplyNewJob(com.google.appengine.api.datastore.Key entityGroup)
shouldApplyNewJob
in interface HighRepJobPolicy
entityGroup
- A unique identifier for the entity group.true
if the new job should apply according to the policy, false
otherwise.public boolean shouldRollForwardExistingJob(com.google.appengine.api.datastore.Key entityGroup)
shouldRollForwardExistingJob
in interface HighRepJobPolicy
entityGroup
- A unique identifier for the entity group.true
if the existing job should roll forward according to the policy, false
otherwise.