Running Servicia on multiple virtual machines

Defining a Servicia runtime

A Servicia runtime defines a set of services intended to run together, i.e., should be able to reference each other, a port number the runtime will be available at.

  • assign a unique id to each runtime instance (-id parameter for the launcher)
  • select a unique port (configure dialog)
  • select the services to be contained in the runtime instance (configure dialog)

Starting a single runtime instance

Let's assume runtime 'one' comprises the services S1 and S2 and runs on port 10000.

   Launcher -id one 

will start the runtime 'one'. The Launcher creates a primary runtime instance per default. That is, some core Servicia components like the service registry will also hosted by this instance. There can only be one primary. For details about using thee launche see LauncherCommandlineArguments.

Type ID Port Services
VM1 primary one 10000 S1, S2

The service S1 and S2 will be started and initialized. If the services implement the LifeCycle interface the init(ServiceContext) method will be invoked.

The services S1 and S2 are able to reference each other using the accessApiForClass or the publishTo methods.

Starting multiple runtime instances at the same time

Now, let's assume we'd like to start a third service S3 depending on S1 and S2. This service should be restarted or exchanged from time to time without shutting down the other two services. Thus, service S3 will be started in a separate runtime instance:

The runtime 'two' consists out of the services S1, S2 and S3. It runs on port 10001.

   Launcher -secondary -id two

will create a secondary runtime instance. This instance expects a primary already running.

Type ID Port Local services Distant services
VM1 primary one 10000 S1, S2
VM2 secondary two 10001 S3 S1, S2

Local and distant

On the startup phase the launcher detects that both references services S1 and S2 are already running on the primary. Since a service is not allowed to run twice S1 and S2 are not initialized again. Instead Servicia marks the services as 'running distantly' and calls from S3 to S1 or S2 are automatically turned into distant XML-RPC calls.

S3 will be started normally according to the service life-cycle model.

Detect already running primary instance

Sometimes it is handy to have an automatic detection whether a primary is already running and to start the instance according to it. For example runtime instance 'two' can be started as follows:

   Launcher -autodetect -id two

when a running primary is detected the instance will be run as a secondary. If no running primary is detected the instance will be a primary.

Without a running primary this launch command will lead to the following configuration:

Type ID Port Local services Distant services
VM1 primary two 10001 S1, S2, S3
Last modified 10 years ago Last modified on 05/26/08 15:02:25