Groups with More than Two Roles

You can extrapolate fault-tolerant behavior to an application with several distinct operating roles.

For example, consider an application that uses roles for graceful degradation of service. Each role subscribes to a different subset of messages by using different content matchers, and processes matching messages.

  • B1 is an active role: the program processes high priority messages with matcher M1, and ignores the rest. The member with ordinal 1 operates in this role.
  • B2 is an active role: the program processes medium priority messages with matcher M2, and ignores the rest. The member with ordinal 2 operates in this role.
  • B3 is an active role: the program processes low priority messages with matcher M3, and ignores the rest. The member with ordinal 3 operates in this role.
  • B4 is the standby role: the program does not process any messages. Any member with ordinal 4 or greater operates in this role.
    More than Two Roles, Role Behavior
    Ordinal Role Description
    1 B1 Actively process high priority messages
    2 B2 Actively process medium priority messages
    3 B3 Actively process low priority messages
    4 or greater B4 Standby
    More than Two Roles, Timeline
    Processes Running Process P1 Process P2 Process P3 Process P4 Process P5
    1 Ord=1

    Role=B1

           
    2 Ord=1

    Role=B1

    Ord=2

    Role=B2

         
    3 Ord=1

    Role=B1

    Ord=2

    Role=B2

    Ord=3

    Role=B3

       
    4 or more Ord=1

    Role=B1

    Ord=2

    Role=B2

    Ord=3

    Role=B3

    Ord=4

    Role=B4 standby

    Ord=5

    Role=B4 standby

When only one instance of application B is running, it has ordinal 1, role B1, and it processes messages with the highest priority. It does not devote any time to messages with medium or low priority.

When two instances are running, one instance, with ordinal 1, role B1, processes messages with high priority. Meanwhile the other instance, with ordinal 2, role B2, processes messages with medium priority. Neither devotes any time to messages with low priority.

When three instances are running, each instance processes messages with a different priority, and together they cover all the priorities. That is, one instance has ordinal 1, role B1, and processes messages with high priority. Meanwhile, the second instance, with ordinal 2, role B2, processes messages with medium priority. The third instance, with ordinal 3, role B3, processes messages with medium priority.

When four or more instances are running, the instances with ordinal greater than 3 idle in standby role B4, ready to processes messages if an instance in any of the processes in the three active roles were to become unavailable.

Tip: Notice that when the process with ordinal k becomes unavailable, all processes with ordinals greater than k shift their roles. When developing programs, design program logic to make this shift smoothly and rapidly.