6 Calendar-Based Scaling

This chapter describes calendar-based scaling in WebLogic Server 12.2.1 and provides an example of how to scale a cluster up and down based on a calendar schedule.

This chapter includes the following sections:

Overview of Calendar-Based Scaling

WLDF now supports actions for policies to be triggered according to a calendar schedule at a specific time, after a duration of time, or at timed intervals. Calendar-based scaling executes a scaling action based on a defined schedule.

Calendar-based rule schedules are only supported for Harvester rules that utilize the Java Expression Language (EL) as the expression language. The following policy types support calendar-based rule schedules:

  • Calendar –based

  • Smart rule-based

  • Collected metrics

Configuring Calendar-Based Scaling

To configure calendar-based scaling, you create a policy and define the policy's schedule, then create and assign a scaling action to that policy. Policy schedules can be set to set to execute based on the following:

  • Every N seconds

  • Every N minutes

  • Every N hours

  • Specific days of the week (at a specific time)

  • Specific days of the month (at a specific time)

Policy schedules are based on the WLDFScheduleBean. Table 6-1 lists the attributes used for setting policy schedules.

Table 6-1 WLDFScheduleBean Attributes

Attribute Default Value Allowable Values

dayOfMonth

* (every day)

  • last, which specifies the last day of the month

  • 1st to 31st

  • 1 to 31

  • Sun, Mon, Tues, Weds, Thurs, Fri, Sat

  • -x where x is the number of days before the last day of the month (for example, -7 would be seven days before the last day of the month)

daysOfWeek

* (every day)

  • 0 to 7 (0 and 7 both represent Sunday)

  • Sun, Mon, Tues, Weds, Thurs, Fri, Sat

hour

* (every hour)

  • 0 to 23

minute

*/5 (every five minutes)

  • 0 to 59

month

* (every month)

  • 1 to 12

  • Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec

second

0

  • 0 to 59

timezone

n/a

  • Defaults to the local VM time zone

year

* (every year)

  • A four-digit calendar year, for example: 2015

These attributes can be specified in several ways using the following syntax . This syntax is supported by the EJB ScheduleExpression class. See the ScheduleExpression documentation for full details about this syntax.

  1. As a single value. For example:

    second = "10"
    month = "Oct"
    
  2. Using a wild card (*), which represents all of the attribute's allowable values. For example, to specify every day of the week:

    dayOfWeek = "*"
    
  3. As a range, which constrains the attribute to an inclusive range of values. You specify the two ends of the range, separated by a dash (-). For example:

    second = "1-10"
    dayOfWeek = "Mon-Fri"
    
  4. As an increment, which constrains the attribute based on a starting point and an interval, using a slash (/) to separate the two values. The use of increments is supported only for specifying second, minute, and hour attributes. For example:

    • minute = "*/5" specifies every five minutes. This syntax is equivalent to minute = "0,5,10,15,20,25,30,35,40,45,50,55"

    • second = "30/10" specifies every 10 seconds within the minute starting at second 30. This syntax is equivalent to second = "30,40,50"

    Note:

    When the maximum value for an attribute is reached, the incrementing stops. That is, it will not exceed the maximum allowable value.

  5. As a list, which constrains the attribute to two or more allowable values, or range of values, using a comma-separated list. Each list item must be a value or range; list items cannot be wild cards, lists, or increments. For example:

    second = "10,20,30"
    dayOfWeek = "Mon,Wed,Fri"
    minute = "0-10,30,40"
    

You can configure calendar based scaling using the WebLogic Server Administration Console, Fusion Middleware Control, or WLST, as described in the following sections:

Note:

  • Before you configure calendar-based scaling in your domain, make sure that you have created a dynamic cluster and completed the prerequisite tasks that are described in Requirements for Configuring Elasticity.

  • Calendar-based scaling policies must be configured in a domain-wide diagnostic system module that is targeted to the Administration Server.

Configuring Calendar-Based Scaling Using the WebLogic Server Administration Console

To configure calendar-based scaling using the WebLogic Server Administration Console:

  1. Create and enable a policy that supports calendar-based rules. See the following topics in the Oracle WebLogic Server Administration Console Online Help:

    Note:

    When creating a calendar-based policy using the WebLogic Server Administration Console, you can specify the schedule for the policy, and also create a scaling action and assign it to the policy. If you choose not to specify the policy schedule and scaling action at the time you're creating the policy itself, you can use the following steps to complete the configuration at a later time.

  2. Set or update the schedule for your policy:

    1. In the left pane of the Administration Console, expand Diagnostics and select Diagnostic Modules.

    2. Select the diagnostic module containing the policy you want to configure.

    3. Select Configuration > Policies and Actions > Policies and click the name of the policy you want to configure.

    4. Select the Schedule page and define the desired schedule settings for your policy.

    5. Click Save.

  3. Create and enable a scaling action. See the following topics in the Oracle WebLogic Server Administration Console Online Help:

  4. Assign a scaling action to your policy:

    Note:

    You can assign only one scaling action to a given policy.

    1. In the left pane of the Administration Console, expand Diagnostics and select Diagnostic Modules.

    2. Select the diagnostic system module containing the policy you want to configure.

    3. Select Configuration > Policies and Actions > Policies and click the name of the policy you want to configure.

    4. Select the Actions page.

    5. In the Scaling Actions section, select either Scale Up Action or Scale Down Action and choose the scale up or scale down action you want to assign to this policy. Alternatively, you can click New Scale Up Action or New Scale Down Action to create a new scaling action for this policy.

    6. Click Save.

Configuring Calendar-Based Scaling Using Fusion Middleware Control

To configure calendar-based scaling using Fusion Middleware Control:

  1. Create and enable a policy that supports calendar-based rules. See "Create a new policy" in Administering Oracle WebLogic Server with Fusion Middleware Control.

    Note:

    While creating a policy in Fusion Middleware Control, you can specify the schedule for the policy and also create and assign a scaling action to the policy. If you choose not to specify the schedule and scaling action for a policy during creation, you can use the following steps to complete the necessary configuration.

  2. Set or update the schedule for your policy:

    1. From the WebLogic Domain dropdown menu, select Diagnostics, then select Diagnostic Modules.

    2. In the Diagnostic Modules table, select the diagnostic system module containing the policy you want to configure.

    3. Select Configuration > Policies and Actions > Policies and click the name of the policy you want to configure.

    4. Select the Schedule page and define the desired schedule settings for your policy.

    5. Click Apply.

  3. Create and enable a scaling action. See "Create a scale up or scale down action" in Administering Oracle WebLogic Server with Fusion Middleware Control.

  4. Assign a scaling action to your policy:

    Note:

    You can assign only one scaling action to a given policy.

    1. From the WebLogic Domain dropdown menu, select Diagnostics, then select Diagnostic Modules.

    2. In the Diagnostic Modules table, select the diagnostic system module containing the policy you want to configure.

    3. Select Configuration > Policies and Actions > Policies and click the name of the policy you want to configure.

    4. Select the Actions page.

    5. In the Scaling Actions section, select either Scale Up Action or Scale Down Action and choose the desired scaling action from the list. Optionally, click Create Scale Up Action or Create Scale Down Action to create a new scaling action for this policy.

    6. Click Apply.

Configuring Calendar-Based Scaling Using WLST

The following examples show how to use WLST to create and configure calendar-based policies that scale a dynamic cluster at a certain time on a certain date.Example 6-1shows the commands to configure a calendar-based policy that executes a scale up action at 3:00 a.m. on December 26. Example 6-2 shows the commands to configure a calendar-based policy that executes a scale down action at midnight on January 15.

Example 6-1 Calendar-Based Policy With a Scale Up Action

calendarScaleUp=wn.createWatch('ChristmasReturnsScaleUpWatch')
  calendarScaleUp.setExpressionLanguage('EL')
  calendarScaleUp.getSchedule().setHour('3')
  calendarScaleUp.getSchedule().setMinute('0')
  calendarScaleUp.getSchedule().setSecond('0')
  calendarScaleUp.getSchedule().setDayOfMonth('26')
  calendarScaleUp.getSchedule().setMonth('Dec')
  calendarScaleUp.setEnabled(false)
  calendarScaleUp.addNotification(scaleUp)

Example 6-2 Calendar-Based Policy With a Scale Down Action

calendarScaleDown=wn.createWatch('PostChristmasReturnsScaleDownWatch')
  calendarScaleDown.setExpressionLanguage('EL')
  calendarScaleDown.getSchedule().setHour('0')
  calendarScaleDown.getSchedule().setMinute('0')
  calendarScaleDown.getSchedule().setSecond('0')
  calendarScaleDown.getSchedule().setDayOfMonth('15')
  calendarScaleDown.getSchedule().setMonth('Jan')
  calendarScaleDown.setEnabled(false)
  calendarScaleDown.addNotification(scaleDown)