Package akka.routing
Class DefaultResizer
- java.lang.Object
-
- akka.routing.DefaultResizer
-
- All Implemented Interfaces:
Resizer,java.io.Serializable,scala.Equals,scala.Product
public class DefaultResizer extends java.lang.Object implements Resizer, scala.Product, java.io.Serializable
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DefaultResizer(int lower, int upper)Java API constructor for default values except bounds.DefaultResizer(int lowerBound, int upperBound, int pressureThreshold, double rampupRate, double backoffThreshold, double backoffRate, int messagesPerResize)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static int$lessinit$greater$default$1()static int$lessinit$greater$default$2()static int$lessinit$greater$default$3()static double$lessinit$greater$default$4()static double$lessinit$greater$default$5()static double$lessinit$greater$default$6()static int$lessinit$greater$default$7()static DefaultResizerapply(int lowerBound, int upperBound, int pressureThreshold, double rampupRate, double backoffThreshold, double backoffRate, int messagesPerResize)static DefaultResizerapply(com.typesafe.config.Config resizerConfig)static intapply$default$1()static intapply$default$2()static intapply$default$3()static doubleapply$default$4()static doubleapply$default$5()static doubleapply$default$6()static intapply$default$7()intbackoff(int pressure, int capacity)Computes a proposed negative (or zero) capacity delta using the configuredbackoffThresholdandbackoffRatedoublebackoffRate()doublebackoffThreshold()booleancanEqual(java.lang.Object x$1)intcapacity(scala.collection.immutable.IndexedSeq<Routee> routees)Returns the overall desired change in resizer capacity.DefaultResizercopy(int lowerBound, int upperBound, int pressureThreshold, double rampupRate, double backoffThreshold, double backoffRate, int messagesPerResize)intcopy$default$1()intcopy$default$2()intcopy$default$3()doublecopy$default$4()doublecopy$default$5()doublecopy$default$6()intcopy$default$7()booleanequals(java.lang.Object x$1)intfilter(int pressure, int capacity)This method can be used to smooth the capacity delta by considering the current pressure and current capacity.static scala.Option<DefaultResizer>fromConfig(com.typesafe.config.Config resizerConfig)inthashCode()booleanisTimeForResize(long messageCounter)Is it time for resizing.intlowerBound()intmessagesPerResize()intpressure(scala.collection.immutable.IndexedSeq<Routee> routees)Number of routees considered busy, or above 'pressure level'.intpressureThreshold()intproductArity()java.lang.ObjectproductElement(int x$1)java.lang.StringproductElementName(int x$1)static scala.collection.Iterator<java.lang.String>productElementNames()scala.collection.Iterator<java.lang.Object>productIterator()java.lang.StringproductPrefix()intrampup(int pressure, int capacity)Computes a proposed positive (or zero) capacity delta using the configuredrampupRate.doublerampupRate()intresize(scala.collection.immutable.IndexedSeq<Routee> currentRoutees)Decide if the capacity of the router need to be changed.java.lang.StringtoString()static scala.Option<scala.Tuple7<java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object>>unapply(DefaultResizer x$0)intupperBound()
-
-
-
Constructor Detail
-
DefaultResizer
public DefaultResizer(int lowerBound, int upperBound, int pressureThreshold, double rampupRate, double backoffThreshold, double backoffRate, int messagesPerResize)
-
DefaultResizer
public DefaultResizer(int lower, int upper)Java API constructor for default values except bounds.
-
-
Method Detail
-
$lessinit$greater$default$1
public static int $lessinit$greater$default$1()
- Parameters:
lowerBound- The fewest number of routees the router should ever have.upperBound- The most number of routees the router should ever have. Must be greater than or equal tolowerBound.pressureThreshold- Threshold to evaluate if routee is considered to be busy (under pressure). Implementation depends on this value (default is 1).- 0: number of routees currently processing a message.
- 1: number of routees currently processing a message has some messages in mailbox.
- > 1: number of routees with at least the configured
pressureThresholdmessages in their mailbox. Note that estimating mailbox size of default UnboundedMailbox is O(N) operation.
rampupRate- Percentage to increase capacity whenever all routees are busy. For example, 0.2 would increase 20% (rounded up), i.e. if current capacity is 6 it will request an increase of 2 more routees.backoffThreshold- Minimum fraction of busy routees before backing off. For example, if this is 0.3, then we'll remove some routees only when less than 30% of routees are busy, i.e. if current capacity is 10 and 3 are busy then the capacity is unchanged, but if 2 or less are busy the capacity is decreased. Use 0.0 or negative to avoid removal of routees.backoffRate- Fraction of routees to be removed when the resizer reaches the backoffThreshold. For example, 0.1 would decrease 10% (rounded up), i.e. if current capacity is 9 it will request an decrease of 1 routee.messagesPerResize- Number of messages between resize operation. Use 1 to resize before each message.
-
$lessinit$greater$default$2
public static int $lessinit$greater$default$2()
-
$lessinit$greater$default$3
public static int $lessinit$greater$default$3()
-
$lessinit$greater$default$4
public static double $lessinit$greater$default$4()
-
$lessinit$greater$default$5
public static double $lessinit$greater$default$5()
-
$lessinit$greater$default$6
public static double $lessinit$greater$default$6()
-
$lessinit$greater$default$7
public static int $lessinit$greater$default$7()
-
apply
public static DefaultResizer apply(com.typesafe.config.Config resizerConfig)
-
apply$default$1
public static int apply$default$1()
- Parameters:
lowerBound- The fewest number of routees the router should ever have.upperBound- The most number of routees the router should ever have. Must be greater than or equal tolowerBound.pressureThreshold- Threshold to evaluate if routee is considered to be busy (under pressure). Implementation depends on this value (default is 1).- 0: number of routees currently processing a message.
- 1: number of routees currently processing a message has some messages in mailbox.
- > 1: number of routees with at least the configured
pressureThresholdmessages in their mailbox. Note that estimating mailbox size of default UnboundedMailbox is O(N) operation.
rampupRate- Percentage to increase capacity whenever all routees are busy. For example, 0.2 would increase 20% (rounded up), i.e. if current capacity is 6 it will request an increase of 2 more routees.backoffThreshold- Minimum fraction of busy routees before backing off. For example, if this is 0.3, then we'll remove some routees only when less than 30% of routees are busy, i.e. if current capacity is 10 and 3 are busy then the capacity is unchanged, but if 2 or less are busy the capacity is decreased. Use 0.0 or negative to avoid removal of routees.backoffRate- Fraction of routees to be removed when the resizer reaches the backoffThreshold. For example, 0.1 would decrease 10% (rounded up), i.e. if current capacity is 9 it will request an decrease of 1 routee.messagesPerResize- Number of messages between resize operation. Use 1 to resize before each message.
-
apply$default$2
public static int apply$default$2()
-
apply$default$3
public static int apply$default$3()
-
apply$default$4
public static double apply$default$4()
-
apply$default$5
public static double apply$default$5()
-
apply$default$6
public static double apply$default$6()
-
apply$default$7
public static int apply$default$7()
-
fromConfig
public static scala.Option<DefaultResizer> fromConfig(com.typesafe.config.Config resizerConfig)
-
apply
public static DefaultResizer apply(int lowerBound, int upperBound, int pressureThreshold, double rampupRate, double backoffThreshold, double backoffRate, int messagesPerResize)
- Parameters:
lowerBound- The fewest number of routees the router should ever have.upperBound- The most number of routees the router should ever have. Must be greater than or equal tolowerBound.pressureThreshold- Threshold to evaluate if routee is considered to be busy (under pressure). Implementation depends on this value (default is 1).- 0: number of routees currently processing a message.
- 1: number of routees currently processing a message has some messages in mailbox.
- > 1: number of routees with at least the configured
pressureThresholdmessages in their mailbox. Note that estimating mailbox size of default UnboundedMailbox is O(N) operation.
rampupRate- Percentage to increase capacity whenever all routees are busy. For example, 0.2 would increase 20% (rounded up), i.e. if current capacity is 6 it will request an increase of 2 more routees.backoffThreshold- Minimum fraction of busy routees before backing off. For example, if this is 0.3, then we'll remove some routees only when less than 30% of routees are busy, i.e. if current capacity is 10 and 3 are busy then the capacity is unchanged, but if 2 or less are busy the capacity is decreased. Use 0.0 or negative to avoid removal of routees.backoffRate- Fraction of routees to be removed when the resizer reaches the backoffThreshold. For example, 0.1 would decrease 10% (rounded up), i.e. if current capacity is 9 it will request an decrease of 1 routee.messagesPerResize- Number of messages between resize operation. Use 1 to resize before each message.
-
unapply
public static scala.Option<scala.Tuple7<java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object,java.lang.Object>> unapply(DefaultResizer x$0)
-
productElementNames
public static scala.collection.Iterator<java.lang.String> productElementNames()
-
lowerBound
public int lowerBound()
-
upperBound
public int upperBound()
-
pressureThreshold
public int pressureThreshold()
-
rampupRate
public double rampupRate()
-
backoffThreshold
public double backoffThreshold()
-
backoffRate
public double backoffRate()
-
messagesPerResize
public int messagesPerResize()
-
isTimeForResize
public boolean isTimeForResize(long messageCounter)
Description copied from interface:ResizerIs it time for resizing. Typically implemented with modulo of nth message, but could be based on elapsed time or something else. The messageCounter starts with 0 for the initial resize and continues with 1 for the first message. Make sure to perform initial resize before first message (messageCounter == 0), because there is no guarantee that resize will be done when concurrent messages are in play.CAUTION: this method is invoked from the thread which tries to send a message to the pool, i.e. the ActorRef.!() method, hence it may be called concurrently.
- Specified by:
isTimeForResizein interfaceResizer
-
resize
public int resize(scala.collection.immutable.IndexedSeq<Routee> currentRoutees)
Description copied from interface:ResizerDecide if the capacity of the router need to be changed. Will be invoked whenisTimeForResizereturns true and no other resize is in progress.Return the number of routees to add or remove. Negative value will remove that number of routees. Positive value will add that number of routees. 0 will not change the routees.
This method is invoked only in the context of the Router actor.
-
capacity
public int capacity(scala.collection.immutable.IndexedSeq<Routee> routees)
Returns the overall desired change in resizer capacity. Positive value will add routees to the resizer. Negative value will remove routees from the resizer.- Parameters:
routees- The current actor in the resizer- Returns:
- the number of routees by which the resizer should be adjusted (positive, negative or zero)
-
pressure
public int pressure(scala.collection.immutable.IndexedSeq<Routee> routees)
Number of routees considered busy, or above 'pressure level'.Implementation depends on the value of
pressureThreshold(default is 1).- 0: number of routees currently processing a message.
- 1: number of routees currently processing a message has some messages in mailbox.
- > 1: number of routees with at least the configured
pressureThresholdmessages in their mailbox. Note that estimating mailbox size of default UnboundedMailbox is O(N) operation.
- Parameters:
routees- the current resizer of routees- Returns:
- number of busy routees, between 0 and routees.size
-
filter
public int filter(int pressure, int capacity)This method can be used to smooth the capacity delta by considering the current pressure and current capacity.- Parameters:
pressure- current number of busy routeescapacity- current number of routees- Returns:
- proposed change in the capacity
-
rampup
public int rampup(int pressure, int capacity)Computes a proposed positive (or zero) capacity delta using the configuredrampupRate.- Parameters:
pressure- the current number of busy routeescapacity- the current number of total routees- Returns:
- proposed increase in capacity
-
backoff
public int backoff(int pressure, int capacity)Computes a proposed negative (or zero) capacity delta using the configuredbackoffThresholdandbackoffRate- Parameters:
pressure- the current number of busy routeescapacity- the current number of total routees- Returns:
- proposed decrease in capacity (as a negative number)
-
copy
public DefaultResizer copy(int lowerBound, int upperBound, int pressureThreshold, double rampupRate, double backoffThreshold, double backoffRate, int messagesPerResize)
-
copy$default$1
public int copy$default$1()
-
copy$default$2
public int copy$default$2()
-
copy$default$3
public int copy$default$3()
-
copy$default$4
public double copy$default$4()
-
copy$default$5
public double copy$default$5()
-
copy$default$6
public double copy$default$6()
-
copy$default$7
public int copy$default$7()
-
productPrefix
public java.lang.String productPrefix()
- Specified by:
productPrefixin interfacescala.Product
-
productArity
public int productArity()
- Specified by:
productArityin interfacescala.Product
-
productElement
public java.lang.Object productElement(int x$1)
- Specified by:
productElementin interfacescala.Product
-
productIterator
public scala.collection.Iterator<java.lang.Object> productIterator()
- Specified by:
productIteratorin interfacescala.Product
-
canEqual
public boolean canEqual(java.lang.Object x$1)
- Specified by:
canEqualin interfacescala.Equals
-
productElementName
public java.lang.String productElementName(int x$1)
- Specified by:
productElementNamein interfacescala.Product
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object x$1)
- Specified by:
equalsin interfacescala.Equals- Overrides:
equalsin classjava.lang.Object
-
-