public static final class TaskScheduler.Builder
extends java.lang.Object
TaskScheduler
object with particular characteristics. Chain
its methods and then call build()
to create a TaskScheduler
.Constructor and Description |
---|
Builder() |
Modifier and Type | Method and Description |
---|---|
TaskScheduler |
build()
Creates a
TaskScheduler based on the various builder methods you have chained. |
TaskScheduler.Builder |
disableShortfallEvaluation()
Disable resource shortfall evaluation.
|
TaskScheduler.Builder |
withAutoScaleByAttributeName(java.lang.String name)
Call this method to indicate which host attribute you want your task scheduler to use in order to
distinguish which hosts are in which autoscaling groups.
|
TaskScheduler.Builder |
withAutoScaleDownBalancedByAttributeName(java.lang.String name)
Call this method to tell the autoscaler to try to maintain a balance of host varieties when it scales
down a cluster.
|
TaskScheduler.Builder |
withAutoScalerCallback(Action1<AutoScaleAction> callback) |
TaskScheduler.Builder |
withAutoScalerMapHostnameAttributeName(java.lang.String name)
Use the given host attribute name to determine the alternate hostname of virtual machine to use as an
argument for an autoscaling action.
|
TaskScheduler.Builder |
withAutoScaleRule(AutoScaleRule rule)
Adds an autoscaling rule that governs the behavior by which this scheduler will autoscale hosts of a
certain type.
|
TaskScheduler.Builder |
withDelayAutoscaleDownBySecs(long delayAutoscaleDownBySecs)
Delay the autoscale down actions to reduce unnecessary actions due to short periods of breach of scale down
policy rules.
|
TaskScheduler.Builder |
withDelayAutoscaleUpBySecs(long delayAutoscaleUpBySecs)
Delay the autoscale up actions to reduce unnecessary actions due to short periods of breach of scale up
policy rules.
|
TaskScheduler.Builder |
withFitnessCalculator(VMTaskFitnessCalculator fitnessCalculator)
Call this method to add a fitness calculator that your scheduler will use to compute the suitability
of a particular host for a particular task.
|
TaskScheduler.Builder |
withFitnessGoodEnoughFunction(Func1<java.lang.Double,java.lang.Boolean> f)
Use the given function to determine if the fitness of a host for a task is good enough that the task
scheduler should stop looking for a more fit host.
|
TaskScheduler.Builder |
withInitialResAllocs(java.util.Map<java.lang.String,ResAllocs> resAllocs)
Call this method to set the initial limitations on how many resources will be available to each task
group.
|
TaskScheduler.Builder |
withLeaseOfferExpirySecs(long leaseOfferExpirySecs)
Call this method to set the expiration time for resource offers.
|
TaskScheduler.Builder |
withLeaseRejectAction(Action1<VirtualMachineLease> leaseRejectAction)
(Required) Call this method to establish a method that your task scheduler will call to notify you
that it has rejected a resource offer.
|
TaskScheduler.Builder |
withMaxOffersToReject(int maxOffersToReject)
Call this method to set the maximum number of offers to reject within a time period equal to lease expiry
seconds, set with
leaseOfferExpirySecs() . |
TaskScheduler.Builder |
withRejectAllExpiredOffers()
Indicate that all offers older than the set expiry time must be rejected.
|
TaskScheduler.Builder |
withSingleOfferPerVM(boolean b)
Indicate that the cluster receives resource offers only once per VM (host).
|
public TaskScheduler.Builder withLeaseRejectAction(Action1<VirtualMachineLease> leaseRejectAction)
leaseRejectAction
- the action to trigger when the task scheduler rejects a VM lease, with the
lease being rejected as the only argumentBuilder
, suitable for further chaining or to build the TaskScheduler
public TaskScheduler.Builder withLeaseOfferExpirySecs(long leaseOfferExpirySecs)
leaseOfferExpirySecs
- the amount of time the scheduler will keep an unused lease available for
a later-scheduled task before it considers the lease to have expired, in
secondsBuilder
, suitable for further chaining or to build the TaskScheduler
public TaskScheduler.Builder withMaxOffersToReject(int maxOffersToReject)
leaseOfferExpirySecs()
. Default is 4.maxOffersToReject
- Maximum number of offers to reject.Builder
, suitable for further chaining or to build the TaskScheduler
public TaskScheduler.Builder withRejectAllExpiredOffers()
withMaxOffersToReject(int)
per each
time period spanning the expiry time, set by withLeaseOfferExpirySecs(long)
.Builder
, suitable for further chaining or to build the TaskScheduler
public TaskScheduler.Builder withFitnessCalculator(VMTaskFitnessCalculator fitnessCalculator)
fitnessCalculator
- the fitness calculator you want this scheduler to use in its evaluationsBuilder
, suitable for further chaining or to build the TaskScheduler
public TaskScheduler.Builder withAutoScaleByAttributeName(java.lang.String name)
withAutoScaleRule(AutoScaleRule)
.name
- the name of the host attribute that defines which autoscaling group it is inBuilder
, suitable for further chaining or to build the TaskScheduler
public TaskScheduler.Builder withAutoScalerMapHostnameAttributeName(java.lang.String name)
In some circumstances (for instance with Amazon Web Services), the host name is not the correct identifier for the host in the context of an autoscaling action (for instance, in AWS, you need the EC2 instance identifier). If this is the case for your system, you need to implement a function that maps the host name to the identifier for the host in an autoscaling context so that Fenzo can perform autoscaling properly. You provide this function to the task manager by means of this builder method.
name
- the attribute name to use as the alternate host identifier in an autoscaling contextBuilder
, suitable for further chaining or to build the TaskScheduler
public TaskScheduler.Builder withAutoScaleDownBalancedByAttributeName(java.lang.String name)
name
- the name of the attributeBuilder
, suitable for further chaining or to build the TaskScheduler
public TaskScheduler.Builder withFitnessGoodEnoughFunction(Func1<java.lang.Double,java.lang.Boolean> f)
By default, if you do not build your task scheduler by passing a function into this method, the task scheduler will always search all of the available hosts for the best possible fit for every task.
f
- a single-argument function that accepts a double parameter, representing the fitness, and
returns a Boolean
indicating whether the fitness is good enough to constitute a
successful match between the host and taskBuilder
, suitable for further chaining or to build the TaskScheduler
public TaskScheduler.Builder disableShortfallEvaluation()
This evaluation can be computaionally expensive and/or may scale up aggressively, initially, to more resources than needed. The initial aggressive scale up is corrected later by scale down, which is triggered by scale down evaluation after a cool down period transpires.
Builder
, suitable for further chaining or to build the TaskScheduler
public TaskScheduler.Builder withInitialResAllocs(java.util.Map<java.lang.String,ResAllocs> resAllocs)
resAllocs
- a Map with the task group name as keys and resource allocation limits as valuesBuilder
, suitable for further chaining or to build the TaskScheduler
public TaskScheduler.Builder withAutoScaleRule(AutoScaleRule rule)
Before you call this method you must first call
withAutoScaleByAttributeName()
to indicate which host
attribute you are using to identify which hosts are in which autoscaling groups.
rule
- the autoscaling rule to addBuilder
, suitable for further chaining or to build the TaskScheduler
java.lang.IllegalArgumentException
- if you have not properly initialized autoscaling or if your rule is
poorly formedpublic TaskScheduler.Builder withAutoScalerCallback(Action1<AutoScaleAction> callback)
public TaskScheduler.Builder withDelayAutoscaleUpBySecs(long delayAutoscaleUpBySecs)
The autoscaler takes the scale up action based on the latest scale up request value after the delay.
The default is 0 secs. Ideally, you should set this to be at least two times the larger of the two values:
TaskScheduler.scheduleOnce(List, List)
.delayAutoscaleUpBySecs
- Delay autoscale up actions by this many seconds.Builder
, suitable for further chaining or to build the TaskScheduler
java.lang.IllegalArgumentException
- if you give negative number for delayAutoscalerbySecs
.public TaskScheduler.Builder withDelayAutoscaleDownBySecs(long delayAutoscaleDownBySecs)
The autoscaler takes the scale down action based on the latest scale down request value after the delay.
The default is 0 secs. Ideally, you should set this to be at least two times the delay before terminated tasks are replaced successfully.
delayAutoscaleDownBySecs
- Delay autoscale down actions by this many seconds.Builder
, suitable for further chaining or to build the TaskScheduler
java.lang.IllegalArgumentException
- if you give negative number for delayAutoscalerbySecs
.public TaskScheduler.Builder withSingleOfferPerVM(boolean b)
b
- True if only one resource offer is expected per host, false by default.Builder
, suitable for further chaining or to build the TaskScheduler
public TaskScheduler build()
TaskScheduler
based on the various builder methods you have chained.TaskScheduler
built according to the specifications you indicated