Lifecycle Callback Annotations Lifecycle

20-2 Oracle Complex Event Processing Developers Guide Figure 20–1 Oracle CEP High Availability: Primary and Secondary Servers This section describes: ■ Section 20.1.1, High Availability Lifecycle and Failover ■ Section 20.1.2, Deployment Group and Notification Group ■ Section 20.1.3, High Availability Components ■ Section 20.1.4, High Availability and Scalability ■ Section 20.1.5, High Availability and Oracle Coherence

20.1.1 High Availability Lifecycle and Failover

Figure 20–2 shows a state diagram for the Oracle CEP high availability lifecycle. In this diagram, the state names SECONDARY, BECOMING_PRIMARY, and PRIMARY correspond to the Oracle CEP high availability adapter RuntimeMBean method getState return values. These states are specific to Oracle CEP. Figure 20–2 Oracle CEP High Availability Lifecycle State Diagram It is not possible to specify the server that will be the initial primary. Initially, the first server in the multi-server domain to start up becomes the primary so by starting servers in a particular order, you can influence primary selection. There is no way to force a particular, running server to become the primary. If a primary fails, and then comes back up, it will not automatically become the primary again unless the current primary fails causing a failover. This section describes the Oracle CEP high availability lifecycle in more detail, including: ■ Section 20.1.1.1, Secondary Failure Understanding High Availability 20-3 ■ Section 20.1.1.2, Primary Failure and Failover ■ Section 20.1.1.3, Rejoining the High Availability Multi-Server Domain

20.1.1.1 Secondary Failure

In general, when a secondary server fails, there is no effect on Oracle CEP application operation as Figure 20–3 shows. Regardless of the quality of service you choose, there are no missed or duplicate events. Figure 20–3 Secondary Failure

20.1.1.2 Primary Failure and Failover

However, when a primary server fails, as Figure 20–4 shows, Oracle CEP performs a failover that may cause missed or duplicate events, depending on the quality of service you choose. Figure 20–4 Primary Failure and Failover During failover, Oracle CEP automatically selects a new primary and the new primary transitions from the SECONDARY state to the BECOMING_PRIMARY state. Depending on the quality of service you choose, the new primary will not transition to PRIMARY state until a configurable readiness threshold is met. For details, see the specific quality of service option in Section 20.2, Choosing a Quality of Service .

20.1.1.3 Rejoining the High Availability Multi-Server Domain

When a new Oracle CEP server is added to an Oracle CEP high availability multi-server domain or an existing failed server restarts, the server will not have fully joined the Oracle CEP high availability deployment and notification groups until all applications deployed to it have fully joined. The type of application determines when it can be said to have fully joined. 20-4 Oracle Complex Event Processing Developers Guide If the application must generate exactly the same sequence of output events as existing secondaries a Type 1 application, then it must be able to rebuild its internal state by processing input streams for some finite period of time the warm-up-window period. This warm-up-window time determines the minimum time it will take for the application to fully join the Oracle CEP high availability deployment and notification groups. If the application does not need to generate exactly the same sequence of output events as existing secondaries a Type 2 application, then it does not require a warm-up-window time and will fully join the Oracle CEP high availability deployment and notification groups as soon as it is deployed. For more information, see Section 20.3.2.5, Choose an Adequate warm-up-window Time .

20.1.2 Deployment Group and Notification Group

All the servers in the multi-server domain belong to the same deployment group: this is the group to which you deploy an application. For the purposes of Oracle CEP high availability, you must deploy the same application to all the servers in this group. By default, all the servers in the multi-server domain also belong to the same notification group. The servers listen to the notification group for membership notifications that indicate when a server has failed and exited the group or resumed operation and rejoined the group, as well as for synchronization notifications from the primary. If you need to scale your Oracle CEP high availability application, you can use the ActiveActiveGroupBean to define a notification group that allows two or more servers to function as a primary server unit while retaining the convenience of a single deployment group that spans all servers primaries and secondaries. You must use Oracle Coherence-based clustering to create the multi-server domain deployment group. You may use either default groups or custom groups. For more information, see: ■ Section 20.1.4, High Availability and Scalability ■ Section 20.1.5, High Availability and Oracle Coherence ■ How to Create an Oracle CEP Multi-Server Domain With Default Groups Using Oracle Coherence in the Oracle Complex Event Processing Administrators Guide. ■ How to Create an Oracle CEP Multi-Server Domain With Custom Groups Using Oracle Coherence in the Oracle Complex Event Processing Administrators Guide.

20.1.3 High Availability Components

To implement Oracle CEP high availability options, you configure your Event Processing Network EPN with a high availability input adapter after each input adapter and a high availability output adapter before each output adapter. Figure 20–5 shows a typical EPN with all possible high availability adapters in place. Understanding High Availability 20-5 Figure 20–5 High Availability Adapters in the EPN The optional high availability input adapter in the primary communicates with the corresponding high availability input adapters in each secondary to normalize event timestamps. Oracle CEP high availability provides one type of high availability input adapter. See Section 20.1.3.1, High Availability Input Adapter . The high availability output adapter in the primary is responsible for outputting events to the output streams that connect the Oracle CEP application to its downsteam client. The high availability output adapter in the primary also communicates with the corresponding high availability output adapters in each secondary, and, depending on the high availability quality of service you choose, may instruct the secondary output adapters to trim their in-memory queues of output events. Oracle CEP high availability provides the following high availability output adapters: ■ Section 20.1.3.2, Buffering Output Adapter ■ Section 20.1.3.3, Broadcast Output Adapter ■ Section 20.1.3.4, Correlating Output Adapter Oracle CEP high availability also provides a notification groups Spring bean to increase scalability in JMS applications. See Section 20.1.3.5, ActiveActiveGroupBean . Which adapter you choose is determined by the high availability quality of service you choose. See Section 20.2, Choosing a Quality of Service . Note: For simplicity, Figure 20–5 does not show channels and shows only one processor. However, the EPN may be arbitrarily complex with multiple input streams and output streams, channels, multiple processors, event beans, and so on. The only restriction is that each input adapter must be followed by a high availability input adapter and each output adapter must be preceded by a high availability output adapter. Similarly, for simplicity, a multi-server domain of only two Oracle CEP servers is shown but you may have an arbitrary number of secondary servers. 20-6 Oracle Complex Event Processing Developers Guide

20.1.3.1 High Availability Input Adapter

The optional Oracle CEP high availability input adapter on the primary Oracle CEP server assigns a time in nanoseconds to events as they arrive at the adapter and forwards the time values assigned to events to all secondary servers. This ensures that all servers running the application use a consistent time value and generate the same results and avoids the need for distributed clock synchronization. Since a time value is assigned to each event before the event reaches any downstream channels in the EPN, downstream channels should be configured to use application time so that they do not assign a new time value to events as they arrive at the channel. Input events must have a key that uniquely identifies each event in order to use this adapter. You can configure the Oracle CEP high availability input adapter to send heartbeat events. The Oracle CEP high availability input adapter is applicable to all high availability quality of service options. However, because the high availability input adapter increases performance overhead, it is not appropriate for some high availability quality of service options such as Section 20.2.1, Simple Failover and Section 20.2.2, Simple Failover with Buffering . For these options, you should instead consider using application time with some incoming event property. For more information, see: ■ Section 20.2.3, Light-Weight Queue Trimming ■ Section 20.2.4, Precise Recovery with JMS ■ Section 21.2.1, How to Configure the High Availability Input Adapter .

20.1.3.2 Buffering Output Adapter

The Oracle CEP high availability buffering output adapter implements a buffered queue trimming strategy. The buffer is a sliding window of output events from the stream. The size of the window is measured in milliseconds. The Oracle CEP high availability buffering output adapter is applicable to simple failover and simple failover with buffering high availability quality of service options. For more information, see: ■ Section 20.2.1, Simple Failover ■ Section 20.2.2, Simple Failover with Buffering ■ Section 21.2.2, How to Configure the Buffering Output Adapter .

20.1.3.3 Broadcast Output Adapter

The Oracle CEP high availability broadcast output adapter implements a distributed queue trimming strategy. The active primary instance broadcasts messages to the active secondary instances in the notification group telling them when to trim their local representation of the queue. The Oracle CEP high availability broadcast output adapter is applicable to the light-weight queue trimming high availability quality of service option. For more information, see: ■ Section 20.2.3, Light-Weight Queue Trimming