Class DefaultHighRepJobPolicy
java.lang.Object
com.google.appengine.api.datastore.dev.DefaultHighRepJobPolicy
- All Implemented Interfaces:
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
FieldsModifier and TypeFieldDescriptionstatic final StringA long that will be used as the seed for theRandomthat determines whether or not a job application attempt fails.static final StringA float >= 0 and invalid input: '<'= 100 representing the percentage of job application attempts that will fail. -
Constructor Summary
ConstructorsConstructorDescriptionDefaultHighRepJobPolicy(long unappliedJobSeed, float unappliedJobPercentage) Constructs aDefaultHighRepJobPolicy. -
Method Summary
Modifier and TypeMethodDescriptionbooleanshouldApplyNewJob(com.google.appengine.api.datastore.Key entityGroup) Returnstrueif the new job should apply according to the policy,falseotherwise.booleanshouldRollForwardExistingJob(com.google.appengine.api.datastore.Key entityGroup) Returnstrueif the existing job should roll forward according to the policy,falseotherwise.
-
Field Details
-
RANDOM_SEED_PROPERTY
A long that will be used as the seed for theRandomthat determines whether or not a job application attempt fails. Must be parsable viaLong.parseLong(String). If not provided we use the current time (in millis) as the seed.- See Also:
-
UNAPPLIED_JOB_PERCENTAGE_PROPERTY
A float >= 0 and invalid input: '<'= 100 representing the percentage of job application attempts that will fail. Must be parsable viaFloat.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 aDefaultHighRepJobPolicy.- 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:HighRepJobPolicyReturnstrueif the new job should apply according to the policy,falseotherwise.- Specified by:
shouldApplyNewJobin interfaceHighRepJobPolicy- Parameters:
entityGroup- A unique identifier for the entity group.
-
shouldRollForwardExistingJob
public boolean shouldRollForwardExistingJob(com.google.appengine.api.datastore.Key entityGroup) Description copied from interface:HighRepJobPolicyReturnstrueif the existing job should roll forward according to the policy,falseotherwise.- Specified by:
shouldRollForwardExistingJobin interfaceHighRepJobPolicy- Parameters:
entityGroup- A unique identifier for the entity group.
-