Example: Using scripting to create and configure schedulers

The following Jacl example script can be invoked using the wsadmin scripting tool, which creates a SchedulerConfiguration resource using the DefaultWorkManager at the server scope.

# Example JACL Script to create a SchedulerConfiguration 
# at the server scope

# Change the cell, node and server to match your environment
set cellName   MyCell
set nodeName   MyNode
set serverName server1


# We can just grab the first provider, since there is only one at the
# server scope level.
set schedProv [$AdminConfig getid /Cell:$cellName/Node:$nodeName/Server:$serverName/SchedulerProvider:SchedulerProvider]
if {$schedProv == ""} {
    puts "Unable to find SchedulerProvider for server: $serverName.  Aborting."
    exit
}
puts "Found a SchedulerProvider"

# Find our WorkManagerInfo object.
# If we don't have a DefaultWorkManager at the server scope,
# copy the one from the Node scope.
set wrkMgrProv [$AdminConfig getid /Cell:$cellName/Node:$nodeName/Server:$serverName/WorkManagerProvider:WorkManagerProvider/]
if {$wrkMgrProv == ""} {
    puts "Unable to find the WorkManagerProvider for server: $serverName.  Aborting."
    exit
}

set wrkMgrInfo [$AdminConfig getid /Cell:$cellName/Node:$nodeName/Server:$serverName/WorkManagerProvider:WorkManagerProvider/WorkManagerInfo:DefaultWorkManager/]
if {$wrkMgrInfo == ""} {
    puts "Unable to find the DefaultWorkManager for server: $serverName.  Creating one."
    set wrkMgrInfo [$AdminConfig getid /Cell:$cellName/Node:$nodeName/WorkManagerProvider:WorkManagerProvider/WorkManagerInfo:DefaultWorkManager/]
    if {$wrkMgrInfo == ""} {
       puts "Unable to find the DefaultWorkManager for node: $nodeName.  Aborting."
       exit
    }
    # Setup our DefaultWorkManager attributes
    set createAttrs [subst { \
        {category "[$AdminConfig showAttribute $wrkMgrInfo category]"} \
        {description "[$AdminConfig showAttribute $wrkMgrInfo description]"} \
        {isGrowable [$AdminConfig showAttribute $wrkMgrInfo isGrowable]} \
        {jndiName [$AdminConfig showAttribute $wrkMgrInfo jndiName]} \
        {maxThreads [$AdminConfig showAttribute $wrkMgrInfo maxThreads]} \
        {minThreads [$AdminConfig showAttribute $wrkMgrInfo minThreads]} \
        {name "[$AdminConfig showAttribute $wrkMgrInfo name]"} \
        {numAlarmThreads [$AdminConfig showAttribute $wrkMgrInfo numAlarmThreads]} \
        {serviceNames "[$AdminConfig showAttribute $wrkMgrInfo serviceNames]"} \
        {threadPriority [$AdminConfig showAttribute $wrkMgrInfo threadPriority]} }]
    set wrkMgrInfo [$AdminConfig create WorkManagerInfo $wrkMgrProv $createAttrs]

    puts "Created a DefaultWorkManager"

}
puts "Found a WorkManagerInfo"

# Setup our SchedulerConfiguration attributes
set schedulerName          MyScheduler
set schedulerJNDIName      sched/MyScheduler
set datasourceJNDIName     jdbc/MySchedulerDatasource
set datasourceAlias        MySchedulerAlias
set pollInterval           30
set tablePrefix            MSCD
set useAdminRoles          true

set createAttrs [subst { \
  {name $schedulerName} \
  {datasourceJNDIName $datasourceJNDIName} \
  {datasourceAlias $datasourceAlias} \
  {jndiName $schedulerJNDIName} \
  {pollInterval $pollInterval} \
  {tablePrefix $tablePrefix} \
  {useAdminRoles true} \
  {workManagerInfo $wrkMgrInfo}}]

# Create the Scheduler
$AdminConfig create SchedulerConfiguration $schedProv $createAttrs
puts "Scheduler created"

# Save the configuration
$AdminConfig save

# Reload the configuration
set dshelper [$AdminControl queryNames type=DataSourceCfgHelper,process=$serverName,*]
$AdminControl invoke $dshelper reload



 

Related Tasks


Configuring schedulers using Java Management Extensions
Using scripting (wsadmin)