Asked in
To Kill a Mockingbird

What is a mock site?

Answer

User Avatar
Wiki User
July 05, 2012 1:48AM

Requires Version: 3.4.3Note: This document describes how to run the example with Unix. For Windows instructions, see Mock site example for windows.

The Mock Site Example shows the basics of using an object of the Site type, which allows you to dispatch commands to all Service resources organized within the Site.

This example defines two Service objects and groups them beneath one Site object. Commands executed on the Site object are automatically dispatched down to the Services in accordance to their ranking. The ranking is determined by the startuprank property, which is simply a number which orders the Services relative to each other, and is used by the Site commands to determine the order in which the resources should be used. By default for most dispatched commands, ranks are sorted in ascending order except for the Stop command which sorts startup rank values in descending order.

The Service lifecycle commands (see the Service Concepts document for more information) are: Start,Stop, and Status. Each of these commands is also defined in the Site type as a Dispatch command. When you call one of these commands on a Site object, it iterates over each of its Service child dependencies and sends the same command to each Service, in the order determined by the startuprank. This makes it easy to control an entire set of Services using a single command sent to the Site.

The Site Type also has a command named dispatchCmd. You can use this command to send any subcommand to the entire set of Services within the Site. You may have Service resources which have other special-purpose commands that the Site doesn't know about, and you can relay those using the dispatchCmd command in the same way that the Start,Stop, and Status lifecycle commands work automatically.

This Example shows you how to do the following things:

  1. Use the Start,Stop, and Status lifecycle commands from a Site, where the commands will be dispatched to the Services
  2. Use the dispatchCmd command to dynamically dispatch any named command to the Services for the Site.
  3. Use the project.xml resource model format to define a Site object and its related Services

The Example does not define any actual implementation for the lifecycle command scripts. It merely demonstrates how to use the Site to dispatch commands to the Site's Service resources. (For an example on how to implement the lifecycle commands for a Service, see the Mock Unix Service Example or the Windows service example.)

The diagram below describes two Services (mock1 and mock2) grouped within one Site (mock). Notice also each Service resource has its own startuprank value. mock1 has a startuprank of 1, and mock2 has a startuprank of 2:

Site commands normally execute commands in ascending startup rank order. Below you can see "mock1" is first to run "Start" and after that completes, "mock2" runs Start:

The Stop command executes commands in descending startup rank order:

This time "mock2" runs Stop first and once it completes, "mock1" runs Stop.