Shutting down and managing components

The correlator implements an interface with which it can be asked to shut themselves down, provide its process identifier, and respond to communication checks.

The tool for this is called engine_management, located in the bin directory. For historical reasons this functionality is also available as component_management.

Some of the functions of the engine_management tool can also be performed from within EPL. For more information, see Using the Management interface.

To use the correlator’s management tool, run the following command:

engine_management [ options ]

When you run this command with the –h option, the usage message for this command is shown.

Description of engine_management

Use the engine_management tool to connect to a running component. Once connected, the tool can shut down the component or return information about the component. The engine_management tool can connect to the correlator.

The engine_management tool sends output to stdout.

Options

The engine_management tool takes the following options. These options are also available for the component_management tool. All options are optional.

Option

Description

-V | --version

Displays version information for the engine_management tool.

-h | --help

Display usage information.

-v | --verbose

Displays information in a more verbose manner. For example, when you specify the -v option, the engine_management tool displays status messages that indicate that it is trying to connect to the component, has connected to the component, is disconnecting, is disconnected, and so on. If you are having trouble obtaining the information you want, specify the -v option to help determine where the problem is.

-n host | --hostname host

Name of the host on which the component is running. The default is localhost. Non-ASCII characters are not allowed in host names.

-p port | --port port

Port on which the component you want to connect to is listening. The default is 15903.

-w | --wait

Instructs the engine_management tool to wait for the component to start and be in a state that is ready to receive EPL files. This option is similar to the -W option, except that this option (the -w option) instructs the tool to wait forever. The -W option lets you specify how many seconds to wait. See the information for the -W option for an example.

-W num | --waitFor num

Instructs the engine_management tool to wait num seconds for the component to start and be in a state that is ready to receive EPL files. If the component is not ready to receive EPL files before the specified number of seconds has elapsed, the engine_management tool terminates with an exit code of 1. This option is most useful in scripts, when the component you want to operate on has not yet started. For example, suppose a script specifies the following commands:

correlator.exe options
engine_inject some_EPL_files

It can sometimes take a few seconds for a component to start, and this number of seconds is not always exactly predictable. If the engine_inject tool runs before the correlator is ready to receive EPL files, the engine_inject tool fails. To avoid this for a local correlator that is listening on the default port, insert the following command between these commands:

engine_management -W 10

This lets the engine_management tool wait for up to 10 seconds for the correlator’s management interface to be available. To set an appropriate wait time for your application, monitor your application’s performance and adjust as needed.

-N | --getname

Displays the name of the component. For example, when you start a correlator, you can give it a name with the -N option. This is the name that the engine_management tool returns. If you do not assign a name to a correlator when you start it, the default name is correlator.

-T | --gettype

Displays the type of the component that the engine_management tool connects to, which will be correlator.

-M | --getuptime

Gets the uptime of the component in milliseconds. This can be useful if you wish to track when and for how long a particular component has been running for.

-Vm | --getvmemory

Gets the virtual memory usage of the component in megabytes. This can be useful if you wish to measure the virtual memory usage of a component, for example, to identify possible memory leaks.

-Pm | --getpmemory

Gets the physical memory usage of the component in megabytes. This can be useful if you wish to measure the physical memory usage of a component, for example, to identify possible memory leaks.

-Y | --getphysical

Displays the physical ID of the component. This can be useful if you are looking at log information that identifies components by their physical IDs.

-L | --getlogical

Displays the logical ID of the component. This can be useful if you are looking at log information that identifies components by their logical IDs.

-O | --getloglevel

Displays the log level of the component. The returned value is one of the following: TRACE, DEBUG, INFO, WARN, ERROR, CRIT, FATAL, or OFF.

-C | --getversion

Displays the version of the component. For example, when the tool connects to a correlator, it displays the version of the correlator software that is running.

-R | --getproduct

Displays the product version of the component. For example, when the tool connects to a correlator, it displays the version of the UNIX software that is running.

-B | --getbuild

Displays the build number of the component. This information is helpful if you need technical support. It indicates the exact software contained by the component you connected to.

-F | --getplatform

Displays the build platform of the component. This information is helpful if you need technical support. It indicates the set of libraries required by the component you connected to.

-P | --getpid

Displays the process identifier of the correlator you are connecting to. This can be useful if you are looking at log information that identifies components by their process identifier.

-H | --gethostname

Displays the host name of the component. When debugging connectivity issues, this option is helpful for obtaining the host name of a component that is running behind a proxy or on a multihomed system.

-U | --getusername

Displays the user name of the component. On a multiuser machine, this is useful for determining who owns a component.

-D | --getdirectory

Displays the working (current) directory of the component. This can be helpful if a plug-in writes a file in a component’s working directory.

-E | --getport

Displays the port of the component.

-c | --getconnections

This option is for use by technical support. It displays all the connections to the component.

-a | --getall

Displays all information for the component.

-xs id:id  reason | --disconnectsender id:id  reason

Disconnects the sender that has the physical ID you specify. If you specify a reason, the engine_management tool sends the reason to the correlator. The correlator then logs the message, sends the reason to the sender, and disconnects the sender. You can specify the component ID as physical_ID/logical_ID.

-xr id:id  reason | --disconnectreceiver id:id  reason

Disconnects the receiver that has the physical ID you specify. If you specify a reason, the engine_management tool sends the reason to the correlator. The correlator then logs the message, sends the reason to the receiver, and disconnects the receiver. You can specify the component ID as physical_ID/logical_ID.

-I category | --getinfo category

This option is for use by technical support. It displays component-specific information for the specified category.

-d | --deepping

Ping the component. This confirms that the component process is running and acknowledging communications.

-l level | --setloglevel level

Sets the amount of information that the component logs in the component-specific log file. In order of decreasing verbosity, you can specify TRACE, DEBUG, INFO, WARN, ERROR, FATAL, CRIT, or OFF.

Note:

Setting the log level of the main correlator log file to anything other than INFO is discouraged. See the description of the -v (or --loglevel) option in Starting the correlator for more details.

If --setloglevel and --setApplicationLogFile both use the same log file, then the log file defined with --setApplicationLogFile is not changed.

-r type  arg* | --dorequest type  arg*

This option sends a component-specific request. For example: engine_management -r cpuProfile frequency. This returns the profiling frequency in Hertz. The following request types are available and apply to the correlator only:

  • applicationEventLogging — Sends detailed application information to the correlator log file. See Viewing garbage collection and application events information.
  • codeCoverage — Lets you check which lines in an EPL file have been executed. See Recording code coverage information.
  • cpuProfile — Lets you profile Apama EPL applications. See Using the CPU profiler.
  • eplMemoryProfileOverview — Returns information on all the monitors in the correlator. See Using the EPL memory profiler.
  • eplMemoryProfileMonitorInstanceDetail — Returns monitor instance details. See Using the EPL memory profiler.
  • eplMemoryProfileMonitorDetail — Returns aggregated monitor instance details. See Using the EPL memory profiler.
  • flushAllQueues — Sends a request into the correlator that waits until every event/injection sent or enqueued to a context before the flushAllQueues request started has been processed, and every event emitted as a result of those events has been acknowledged. This may block if a slow receiver is connected to the correlator. Events enqueued to a context after the request has started may or may not be processed. Thus, if you want to see the results of one context enqueueing to a second, which enqueues to a third, you should execute engine_management -r flushAllQueues three times, to ensure it has been processed by each context. This does not change the behavior of the correlator (the correlator will always flush all queues as soon as it is able to), it just waits for events currently on input queues to complete. In addition, flushAllQueues also waits for any queued MemoryStore operations to complete, such as the preparation of a new store.
  • flushChannelCache — Notifies all dynamicChainManagers again about all channels which contexts are subscribed to or have sent to. This allows the manager to change its decision about whether it needs to subscribe to the channel (for example, when a channel has been created on a message bus after the correlator was started). See also Requirements of a transport chain manager plug-in class.
  • setOOB — Enables out of band notifications for a correlator. See Out of band connection notifications.
  • startInternalClock — Starts the internal clocking of a correlator which was started with the -Xclock option (see Determining whether to disable the correlator’s internal clock for more information on the -Xclock option). startInternalClock first advances the time of all contexts to the current wall-clock time and then continues sending clock ticks at the configured frequency. It will do nothing if the internal clock is already running.
  • toStringQueues — Outputs the current contents of all input and output queues within the running correlator. This can be helpful for identifying slow senders/receivers and potential causes (such as very large events or excessive flow).
  • verbosegc — Enables logging of garbage collection events. See Viewing garbage collection and application events information.

Certain other requests for the -r option are available for use by Apama technical support.

See Management requests for additional options.

-s why | --shutdown why

Instructs the component to shut down and specifies a message that indicates the reason for termination. The component inserts the string you specify in its log file with a CRIT flag, and then shuts down.

Management requests

The options in the tables below replicate -r (or --dorequest) request types of the same name.

The following options are specific to the correlator:

Option

Description

--rotateLogs

Rotates all the log files. See Rotating all correlator log files.

--setApplicationLogFile [node=]path

Sets the log file for EPL log messages (global or per-package). For more information on how to set, get and unset the log file, see Setting EPL log files and log levels dynamically.

--setApplicationLogLevel [node=]level

Sets the log level for EPL log messages (global or per-package). For more information on how to set, get and unset the log level, see Setting EPL log files and log levels dynamically.

--getApplicationLogFile node

Displays the EPL log file for this node.

--getApplicationLogLevel node

Displays the EPL log level for this node.

--getRootApplicationLogFile

Displays the root EPL log file.

--getRootApplicationLogLevel

Displays the root EPL log level.

--unsetApplicationLogFile node

Unsets the EPL log file for this node.

--unsetApplicationLogLevel node

Unsets the EPL log level for this node.

--unsetRootApplicationLogFile

Unsets the root EPL log file.

--unsetRootApplicationLogLevel

Unsets the root EPL log level.

Option Description
--setLogFile path Instructs the component to close the component-specific log file it is using and to open a new log file with the name you specify. This has no effect on EPL logging which uses a separate log file. See Rotating specified log files.

Exit values

The engine_management tool returns the following exit values:

Value

Description

0

All status requests were processed successfully.

1

Indicates one of the following: - No connection to the specified component was possible.

  • The connection failed.
  • You specified the waitFor option and the specified time elapsed without the component starting.

2

One or more errors occurred while requesting/processing status.

3

Deep ping failed.

Viewing garbage collection and application events information

The information in this topic applies to the correlator only.

You can enable logging of verbose garbage collection and application events in different ways and at different times, as described below.

Using the engine_management tool to enable garbage collection and application event logging for a running correlator

A handy way to view garbage collection (GC) information for a running correlator is to execute the following command:

engine_management -r verbosegc on

This command enables logging of garbage collection events, and is particularly useful in production environments. The additional garbage collection information goes to the correlator log, where the garbage collection messages are logged at DEBUG level and are signposted by a prefix, <apama.verboseGC.MonitorName>, where MonitorName indicates the monitor where garbage collection occurred.

To disable logging of garbage collection information, execute the following command:

engine_management -r verbosegc off

The above commands provide an alternative to the following command, which provides a great deal of detailed output (such as context-state changes, event triggering, spawning, routing, etc.) in addition to garbage collection information:

engine_management -r applicationEventLogging on

Again, this output goes to the correlator log, with the messages being logged at DEBUG level. Any additional log messages to the garbage collection messages are signposted by the prefix <apama.applicationEvents>.

To turn this off, execute the following command:

engine_management -r applicationEventLogging off

See Shutting down and managing components for more information on the -r (or --dorequest) option of the engine_management tool.

Enabling garbage collection and application event logging at correlator startup

You can also enable garbage collection logging at correlator startup. To do so, execute the following command:

correlator --loglevel apama.verboseGC=DEBUG

This enables verbose garbage collection logging for all monitors.

If you only wish to enable garbage collection logging for a particular monitor, append the name of the monitor (for example, “MyMonitor”) to apama.verboseGC as follows:

correlator --loglevel apama.verboseGC.MyMonitor=DEBUG

This enables verbose garbage collection logging only for the monitor which has the name “MyMonitor”.

Similarly, you can also enable application event logging at start time by starting a correlator with the following command:

correlator --loglevel apama.applicationEvents=DEBUG

Note:

If you enable application event logging at start time in this fashion, this will not enable verbose garbage collection logging (as is the case when enabling it using the engine_management request). Furthermore, it is not possible to enable application event logging on a per-monitor basis, as it is for garbage collection logging.

See Starting the correlator for more information on the --loglevel (or -v) option of the correlator command.

Using a YAML configuration file to enable garbage collection and application event logging at correlator startup

Another way to enable garbage collection logging or application event logging at start time is through a YAML configuration file. For more information, see the descriptions of the following categories in Setting correlator and plug-in log files and log levels in a YAML configuration file:

  • apama.verboseGC
  • apama.verboseGC.MonitorName
  • apama.applicationEvents

Setting EPL log files and log levels dynamically

This topic describes how to configure logging for individual EPL packages. It applies to the correlator only. For information about configuring the log level of the whole correlator and plug-ins running inside it, see Setting correlator and plug-in log files and log levels in a YAML configuration file.

You can configure per-package logging in several ways:

In EPL code, you can specify log statements as a development or debug tool. By default, log statements that you specify in EPL send information to the correlator log file. If a log file was not specified when the correlator was started, and you have not executed the engine_management tool to associate a log file with the correlator, log statements send output to stdout.

In place of this default behavior, you can specify different log files for individual packages, monitors and events. This can be helpful during development. For example, you can specify a separate log file for a package or monitor you are implementing, and direct log output from only your development code to that file.

Also, you can specify a particular log level for a package, monitor, or event. The settings of log files and log levels are independent of each other. That is, you can set only a log level for a particular package, monitor or event, or you can set only a log level for a particular element. The topics below provide information for managing individual log files and log levels.

See also Rotating correlator log files.

Note:

Regularly rotating log files and storing the old ones in a secure location may be important as part of your personal data protection policy. For more information, see Recommendations for logging by Apama application code.

Tree structure of packages, monitors, and events

Packages, monitors and events form a tree as illustrated in the figure below. For each node in the tree, you can specify a log file and/or a log level. Nodes for which you do not specify log settings inherit log settings from their parent node.

Illustration of the tree structure

The root of the tree is the default package, which contains code that does not explicitly specify a package with the package statement. Specified packages are intermediate nodes. Packages can nest inside each other. Monitors and events in specified packages are leaf nodes. If you specify an event type in a monitor, that event is a leaf node and its containing monitor is an intermediate node.

For example, suppose you specify packageA.log as the log file for packageA. The packageA.log file receives output from log statements in MonitorE and MonitorK. If EventF contains any action members that specify log statements, output would go to the packageA.log file.

Now suppose that you set ERROR as the log level for the default package and you set INFO as the log level for PackageB. For log statements in MonitorG, PackageH, and MonitorL, the correlator compares the log statement’s log level with INFO. For log statements in the rest of the tree, the correlator compares the log statement’s log level with ERROR. For details, see the table in Managing EPL log levels.

Managing EPL log levels

To set the log level for a package, monitor or event, invoke the engine_management tool as follows:

engine_management --setApplicationLogLevel [node=]logLevel
Option Description
node Optionally, specify the name of a package, monitor or event. If you do not specify a node name, the tool sets the log level for the default package.
logLevel Specify OFF, CRIT, FATAL, ERROR, WARN, INFO, DEBUG, or TRACE.

To obtain the log level for a particular node, invoke the tool as follows:

engine_management --getApplicationLogLevel [node]

If you do not specify a node, the tool returns the log level for the default package. To remove the log level for a node, so that it takes on the log level of its parent node, invoke the tool as follows. Again, if you do not specify a node, you remove the log level for the default package. The default package then takes on the log level in effect for the correlator. The default correlator log level is INFO.

engine_management --unsetApplicationLogLevel [node]

To manage the log level for an event that you define in a monitor, see Managing event logging attributes.

After the correlator identifies the applicable log level, the log level itself determines whether the correlator sends the log statement output to the appropriate log file. The following table indicates which log level identifiers cause the correlator to send the log statement to the appropriate log file.

Log level in effect Log statements with these identifiers go to the appropriate log file Log statements with these identifiers are ignored
OFF None CRIT, FATAL,``ERROR, WARN, INFO, DEBUG, TRACE
CRIT CRIT FATAL, ERROR, WARN, INFO, DEBUG, TRACE
FATAL CRIT, FATAL ERROR, WARN, INFO, DEBUG, TRACE
ERROR CRIT, FATAL,``ERROR WARN, INFO, DEBUG, TRACE
WARN CRIT, FATAL, ERROR, WARN INFO, DEBUG, TRACE
INFO CRIT, FATAL, ERROR, WARN, INFO DEBUG, TRACE
DEBUG CRIT, FATAL, ERROR, WARN, INFO, DEBUG TRACE
TRACE CRIT, FATAL, ERROR, WARN, INFO, DEBUG, TRACE None

See also Log levels determine results of log statements.

Managing EPL log files

To specify a log file for a package, monitor or event, invoke the engine_management tool as follows:

engine_management --setApplicationLogFile  [node=]logFile
Option Description
node Optionally, specify the name of a package, monitor or event. If you do not specify a node name, the tool associates the log file with the default package.
logFile Specify the path of the log file. You specify the name of an EPL log file in the same way that you specify the name of a main correlator log file or input log file. See Specifying log filenames.

To obtain the path of the log file for a particular node, invoke the tool as follows:

engine_management --getApplicationLogFile [node]

If you do not specify a node, the tool returns the log file for the default package. To disassociate a log file from its node, so that the node uses the log file of its parent node, invoke the tool as follows. Again, if you do not specify a node, you disassociate the log file from the default package. The correlator log file is then in effect for the default package. If a log file has not been specified for the correlator, the default is stdout.

engine_management --unsetApplicationLogFile [node]

Managing event logging attributes

If you specify an event type in a monitor, that event does not inherit the logging configuration from the enclosing monitor. It is expected that this will change in a future release. To explicitly set logging attributes for an event type defined in a monitor, invoke the engine_management tool and specify an unqualified event type name. Do not specify an enclosing scope, such as com.apamax.myMonitor.NestedEventType. For example:

engine_management --setApplicationLogFile NestedEventType=foo.log
engine_management --setApplicationLogLevel NestedEventType=DEBUG

Rotating correlator log files

Rotating a correlator log file refers to closing a log file being used by a running correlator and opening a new log file to be used instead from that point onwards. This lets you archive log files and avoid log files that are too large to easily view.

Each site should decide on and implement its own correlator log rotation policy. You should consider the following:

  • How often to rotate log files.
  • How large a correlator log file can be.
  • What correlator log file naming conventions to use to organize log files.

There is a lot of useful header information in the main log file being used when the correlator starts. If you need to provide log files to Apama technical support, you should be able to provide the log file that was in use when the correlator started, as well as any other log files that were in use before and when a problem occurred.

Note:

Regularly rotating log files and storing the old ones in a secure location may be important as part of your personal data protection policy. For more information, see Protecting and erasing data from Apama log files.

To rotate the correlator log file and also rotate any other log file the correlator is using (input log file, EPL log files), see Rotating all correlator log files.

To rotate only the main correlator log file, see Rotating specified log files.

Note:

Some people use the term “log rolling” instead of “log rotation”.

Rotating all correlator log files

The information in this topic applies to the correlator only.

To invoke rotation of all log files that the correlator is using, you can do the following:

  • Invoke the engine_management tool and specify --rotateLogs.

    This rotates the main correlator log file, the correlator input log file if it is being generated, and any EPL log files that are being generated. When you invoke this management request then the correlator closes each log file it was using.

    If the log filename specification declared ${START_TIME}, ${ROTATION_TIME} and/or ${ID}, then the correlator starts new log files with updated names according to the log filename specification; for example, if ${ID} was specified, then the ID portion of a log filename would be incremented by 1.

  • In EPL, create a monitor that uses the Management interface EPL plug-in to trigger log rotation on a schedule. See Using the Management interface.

  • On UNIX only, you can write a cron job that periodically sends a SIGHUP signal to Apama processes.

    The standard UNIX SIGHUP mechanism causes Apama processes to re-open their log files. If the log file names were specified with ${ROTATION_TIME} and/or ${ID}, then the re-opened files have names that contain the rotation time and/or the incremented ID.

If you want a log filename to always be the same and so did not declare ${START_TIME}, ${ROTATION_TIME} or ${ID} in the log filename specification, then the correlator starts new log files that have the same names as the log files it closed. Log files are appended to if the names are the same.

Rotating specified log files

Run one of the following utilities to rotate a particular log file. Write a cron job that periodically runs the utilities.

  • The following command instructs the correlator to close its component-specific log file and start using a new log file that has the name you specify. If the name of the file contains blanks, be sure enclose it in quotation marks.

    engine_management --setLogFile log-filename
    
  • The following command instructs the correlator to use the specified file as the log file for the specified node, which can be a package, monitor, or event. See also Setting EPL log files and log levels dynamically.

    engine_management --setApplicationLogFile [node=]log-filename
    

    If you use separate log files for particular packages, monitors, or events you might want to rotate those log files at the same time that you rotate the main correlator log file. This keeps your Apama log files in sync with each other. See Rotating all correlator log files.

A log file is never overwritten. If you rotate a log file and specify the same name, then Apama appends messages to the content already there.

Apama does not support automatic log file rotation based on log file size.

The only way to rotate the correlator input log is to rotate all correlator log files. See Rotating all correlator log files.