<activationByGroupingKey> エレメントには、<groupingKey> エレメントで定義されているルール・インスタンスをアクティブ化および非アクティブ化できるイベントを指定するエレメントが含まれます。<groupingKey> エレメントは、フィルターおよびタイマー・ルールに対しては無効であるため、<activationByGroupingKey> エレメントはこれらのルールに適用されません。
<activationByGroupingKey> エレメントで提供される関数は、グループ化キーを定義するルールで使用できます。これを使用すると、グループ化キーに基づいてルール・インスタンスのアクティブ化および非アクティブ化を制御できます。<activationByGroupingKey> エレメントをコーディングすると、<activationByGroupingKey> 内の <activateOnEvent> の条件および <deactivateOnEvent> の条件に基づいて、各ルール・インスタンスを別個にアクティブ化または非アクティブ化できるようになります。
以下の例は、計算ルールにおける <activationByGroupingKey> エレメントの使用方法を示しています。
<computationRule name="StockReporter"> <variable dataType="java.lang.Integer" name="totalSharesTraded"> <varInitializer expressionLanguage="java"> return new Integer(0); </varInitializer> </variable> <activationInterval> <activationTime> <start> <inactiveWhenLoaded/> </start> </activationTime> <activationByGroupingKey> <activateOnEvent> <eventType type="StartReporting"/> </activateOnEvent> </activationByGroupingKey> </activationInterval> <eventSelector> <eventType type="StockSharesTraded"/> </eventSelector> <groupingKey> <attributeName>stockSymbol</attributeName> </groupingKey> <computeFunction assignTo="totalSharesTraded" expressionLanguage="java"> return new Integer(act_lib.getIntVariable("totalSharesTraded") + act_event.getIntAttribute("sharesTraded")); </computeFunction> <timeWindow> <timeInterval unit="ISO-8601" duration="PT10M"/> </timeWindow> <onTimeWindowComplete> <action expressionLanguage="java"> StockReport.createReport(act_eventList.get(0).getStringAttribute("stockSymbol"), act_lib.getIntVariable("totalSharesTraded")); </action> </onTimeWindowComplete> </computationRule>
<activationByGroupingKey> には属性がありません。
<activationByGroupingKey> には以下のエレメントが含まれます。
以下のエレメントは、表示されている順序でコーディングする必要があります。エレメントがオプションである場合、コーディングする必要はありませんが、コーディングするエレメントはすべて正しい順序になっている必要があります。
エレメント | 必須/オプション |
---|---|
<activateOnEvent> | オプション。指定できるのは 0 回または 1 回です。 |
<deactivateOnEvent> | オプション。指定できるのは 0 回または 1 回です。 |
ルールの振る舞いは、現行のルール・アクティビティーと、<activationInterval> エレメントおよび <activationByGroupingKey> エレメントに含まれる <activateOnEvent> と <deactivateOnEvent> の定義間の相互作用に応じて異なる場合があります。以下の例は、これらの定義がどのように相互作用することがあるか示します。
この例では、保守モードのシステムのイベントを抑制し、保守期間の終了時点で、抑制されたイベント数のサマリー・レポートが提供されるよう重複ルールを定義しています。
デフォルトでは、グループ化キーを定義するルールは、すべてのグループ化キー値の処理を許可します。したがって、イベントがルールのイベント選択基準を満たすと、すべてのルール・インスタンスがアクティブになり、グループ化キーの任意の値に従ってこれらのイベントを受け入れられるようになります。ルールのアクティブ化間隔は、ルールにグループ化キーが含まれない場合と同じです。これは、ルールのイベント選択基準を満たすイベントは、基本的にすべて処理されるためです。
<duplicateRule name="Maintenance_Supression"> <activationInterval> <activationTime> <start> <inactiveWhenLoaded/> </start> <stop> <after duration="PT2H" unit="ISO-8601"/> </stop> </activationTime> <activateOnEvent> <eventType type="StartMaintenanceModeAllHosts"/> </activateOnEvent> <deactivateOnEvent> <eventType type="StopMaintenanceModeAllHosts"/> </deactivateOnEvent> </activationInterval> <groupingKey missingAttributeHandling="ignoreEvent"> <attributeName>hostname</attributeName> </groupingKey> <timeWindow> <runUntilDeactivated/> </timeWindow> <onDetection> <action expressionLanguage="java" name="DropEvent"> <![CDATA[act_lib.exitRuleSet();]]> </action> </onDetection> <onTimeWindowComplete> <action expressionLanguage="java" name="CreateSummaryOfSupressedEvents"> <![CDATA[Helper.createSummaryEvent("MaintenanceSummary", act_eventList, act_lib);]]> </action> </onTimeWindowComplete> </duplicateRule>
場合により、どのルール・インスタンスをいつアクティブにするか、制御する必要があるかもしれません。そのような場合は、<activationByGroupingKey> エレメントをコーディングします。
<activationByGroupingKey> <activateOnEvent> <eventType type="StartMaintenanceMode"/> <stopAfter duration="PT2H" unit="ISO-8601"/> </activateOnEvent> <deactivateOnEvent> <eventType type="StopMaintenanceMode"/> </deactivateOnEvent> </activationByGroupingKey>
開始時のルール状態 | 場合によりルール状態が影響を受ける対象 | 終了時のルール状態 |
---|---|---|
非アクティブ | <activationInterval> <activationTime> <start> で定義された時間 |
|
activate() メソッド | ||
<activationInterval> <activateOnEvent> で定義されたイベント A | ||
<activationByGroupingKey> <activateOnEvent> で <stopAfter> を使用せずに 定義されたイベント A[1] |
|
|
<activateOnEvent> で <stopAfter> を使用して 定義されたイベント A[2] |
|
|
|
<activationInterval> <activationTime> <start> で定義された時間 | ルールの状態は変化しません。開始時のルール状態と同じです。 |
activate() メソッド | ||
<activationInterval> <activateOnEvent> で定義されたイベント A | ||
<activationByGroupingKey> <activateOnEvent> で <stopAfter> を使用せずに 定義されたイベント A[1] | ||
<activateOnEvent> で <stopAfter> を使用して 定義されたイベント A[2] | ||
|
<activationInterval> <activationTime> <start> で定義された時間 | ルールの状態は変化しません。開始時のルール状態と同じです。 |
activate() メソッド | ||
<activationInterval> <activateOnEvent> で定義されたイベント A | すべてのグループ化キー値が許可されます。 | |
<activationByGroupingKey> <activateOnEvent> で <stopAfter> を使用せずに 定義されたイベント A[1] |
|
|
<activateOnEvent> で <stopAfter> を使用して 定義されたイベント A[2] |
|
|
|
<activationInterval> <activationTime> <start> で定義された時間 | ルールの状態は変化しません。開始時のルール状態と同じです。 |
activate() メソッド | ||
<activationInterval> <activateOnEvent> で定義されたイベント A | すべてのグループ化キー値が許可されます。 | |
<activationByGroupingKey> <activateOnEvent> で <stopAfter> を使用せずに 定義されたイベント A[1] | 前に許可されていたグループ化キー値に加え、グループ化キー値 1 が許可されるようになります。 | |
<activateOnEvent> で <stopAfter> を使用して 定義されたイベント A[2] | 前に許可されていたグループ化キー値に加え、グループ化キー値 2 が許可されるようになります。 |
開始時のルール状態 | 場合によりルール状態が影響を受ける対象 | 終了時のルール状態 |
---|---|---|
非アクティブ | <activationInterval> <activationTime> <stop> で定義された時間 | ルールの状態は変化しません。開始時のルール状態と同じです。 |
deactivate() メソッド | ||
<activationInterval> <deactivateOnEvent> で定義されたイベント D | ||
<activationByGroupingKey> <deactivateOnEvent> で定義されたイベント D[1] | ||
イベント A[2] について、<activationByGroupingKey> <activateOnEvent> <stopAfter> で定義された継続時間が終了します。 | ||
|
<activationInterval> <activationTime> <stop> で定義された時間 |
|
deactivate() メソッド | ||
<activationInterval> <deactivateOnEvent> で定義されたイベント D | ||
<activationByGroupingKey> <deactivateOnEvent> で定義されたイベント D[1] |
|
|
イベント A[2] について、<activationByGroupingKey> <activateOnEvent> <stopAfter> で定義された継続時間が終了します。 | グループ化キー値 2 を持つルール・インスタンスが非アクティブ化されます。 | |
|
<activationInterval> <activationTime> <stop> で定義された時間 |
|
deactivate() メソッド | ||
<activationInterval> <deactivateOnEvent> で定義されたイベント D | ||
<activationByGroupingKey> <deactivateOnEvent> で定義されたイベント D[1] |
|
|
イベント A[2] について、<activationByGroupingKey> <activateOnEvent> <stopAfter> で定義された継続時間が終了します。 |
|
|
|
<activationInterval> <activationTime> <stop> で定義された時間 |
|
deactivate() メソッド | ||
<activationInterval> <deactivateOnEvent> で定義されたイベント D | ||
<activationByGroupingKey> <deactivateOnEvent> で定義されたイベント D[1] |
|
|
イベント A[2] について、<activationByGroupingKey> <activateOnEvent> <stopAfter> で定義された継続時間が終了します。 | グループ化キー値 2 を持つルール・インスタンスが非アクティブ化されます。 |