Table of Contents:


Introduction

In this tutorial, a moving node wants to send an “Offload” message to a node. It inquires other nodes about their compute capabilities (CPU speed, no. of cores), and if the other node has at least 4 CPU cores, it will use it as the message target.

There are 5 nodes, divided into 3 groups:

Tutorial 5 Nodes

Hardware configuration in the settings file for Group3, for example, looks like this:

Group3.application1 = processEngineAppY

processEngineAppY.noOfCpus = 4
processEngineAppY.cpuSpeed = 31500

There are 2 process definitions:

  1. Process 1 - run by M0, which sends a message named “Get hardware description” to every node it connects to, and then checks the answer. It waits for the response and then checks if the response indicates that the node had at least 4 CPU cores. If yes, it proceeds to trigger work offloading using a message.

  2. Process 2 is deployed on the static nodes (X1,X2,Y3,Y4). This process is started by the “Get hardware description” message. It uses a custom Java implementation Task to obtain the hardware specification and then sends a message with the hardware description to the node who started the process (M0 in this scenario).

##

Modelling “Process 2”

Let’s first model Process 2. Make the process start event a “Start message event” which expects a message named “Get hardware description” (See Tutorial 2 how to create such start events).

Getting Hardware specs in Java

Then, add a Simulate Processing Work task from the palette.

Following the example of Tutorial 2, create a subclass of ee.mass.epm.sim.task.SimulatedTask Java class. You can place the file for example in:

step-one/step-one-main/src/main/java/ee/mass/epm/samples/CheckHardwareTask.java

Override & implement the execute(DelegateExecution execution) method as follows:

    @Override
    public void execute(DelegateExecution execution) {
        super.execute(execution);

        SimulatedProcessEngineConfiguration engine = 
                (SimulatedProcessEngineConfiguration) Context.getProcessEngineConfiguration();

        int hostAddress = engine.getHostAddress();
        DTNHost self = SimScenario.getInstance().getHosts().get(hostAddress);

        CpuConf cpuConf = BpmEngineApplication.ofHost(self).getCpuConf();
        execution.setVariable("noOfCpus", cpuConf.getNoOfCpus() );
        execution.setVariable("cpuSpeed", cpuConf.getCpuSpeed() );

    }

With the Java implementation in place, don’t forget to update Simulate Processing Work “Class” property to point to your implementation.

Sending the HW description message

To complete the process, add a Send BP Message task which attaches noOfCpus and cpuSpeed process variables to the message. The Message name should be “Hardware Description”,

Modelling “Process 1”

If you have followed the previous tutorials, you should be able to put together the first 3 tasks of Process 1. Below, we quickly summarize them.

  1. “Device Connected” is a an Intermediate Signal Catching Event, configured to refer to a “New Connection” Signal
  2. “Ask hardware description” is a “Send Start Process Message” task, sending a message with name “Get hardware description” to the the address stored in process variable lastConnectAddress (set by the connection signal event)
  3. “Hardware Description Received” is an intermediate Message catching event for a message named “Hardware Description” (Sent from Process 2).

XOR-gateway

Now that we have received the hardware description message, we want to make a decision based on it. For this we use an XOR-gateway.

Add the XOR gateway to the process and create 2 outgoing flows:

  1. First one advancing the flow (it will be later connected to a send message task)
  2. Second one going back to “Device Connected”

The below video demonstrates how to set up these flow conditions.

Completing the process

Finally, add a Send BP Message task, as a kind of a placeholder for now invoking some services (offloading work) on the node we have identified to have the required number of CPUs.

This message task should be after the XOR gateway outgoing flow with the flow condition. The actual message handling we are not covering here, it has been done in previous tutorials.

Running the scenario

Recall the different CPU configurations of X1, X2, Y3, Y4.

If you run the simulation, you should see the hardware description message exchanges with X1 and X2, but no “Offload work” message, because the XOR gateway flow which checks the noOfCpus variable value does not yield a true value. With Y3 however, the XOR gateway flow proceeds to the Offload message task.


Back to Home