Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Demo Marker Detection Application

Theodore Lu edited this page Apr 29, 2021 · 3 revisions

We've included a sample demo application where we deploy an Aruco Marker Detection Application to AdvantEdge.

Setup AdvantEdge environment with multiple Client and Server instances.

  1. Make sure AdvantEDGE can be ran on your Virtual Machine. To deploy AdvantEDGE in your machine (or any other) follow the instructions here.
  2. Dockerize the sample Client and Server application
    • Download and copy the project source files to your Virtual Machine
    • Move the Dockerfile of the application you're building from src/main/resources/<application_name> to src/main/
    • Run docker build --tag meep-docker-registry:30001/<application_name> . and docker push meep-docker-registry:30001/<application_name>
  3. Run AdvantEDGE create a new Scenario and import marker-detection-test.yaml
  4. Create new Sandbox and run the previously created Scenario in the newly created sandbox
  5. In another terminal, use ´docker attach´ to check if both applications were working correctly, it is expected that they would return ´404´ error for their heartbeat since we haven't started the Master yet
  6. Terminate and delete Sandbox and scenarios for subsequent experiments

Run Matchmaking Experiment

Deploying the Master

  1. Download or clone the code repository to your target machine
  2. Build a FatJar, such as with ShadowJar plugin for Gradle
  3. Move the FatJar to the application root
  4. Run with java -jar <fat-jar-name>.jar, if it's working you should see an input prompt in the console

Running the Experiment

For this experiment we will use the sample runOpenCVDemo.json scenario that you can find in src/main/resources/scenarios

  1. Start the Master using java -jar <fat-jar-name>.jar
  2. Run the scenario by inputting load_scenario src/main/resources/scenarios/runOpenCVDemo.json then run_scenario in the Master console
  3. Run docker attach to Client in another terminal to check if everything's working
  4. Use the command assign_client <client_id> in Master console or run curl -X POST <master_ip>/client/assign/<client_id>
  5. Check in the attached terminal if everything is working properly
  6. Don't forget to terminate and delete Sandbox and scenarios for subsequent experiments

Resource Limitation

In the real world, applications in Client and Node might not be able to use all resources available to its respective machines, nor would the network condition be stable, to simulate such conditions in this demo, we would be using AdvantEdge and CGroup

Limiting bandwith with AdvantEdge

You can use AdvantEdge to simulate real world bandwith limitations, to do so you can:

  • Update the opencvdemo.yaml in src/main/resources/AdvantEdge before running the Master scenario
  • Run ae_update_nw_char <sandbox_name> <element_name> <element_type> <throughput_dl> <throughput_ul> <latency> <latency_variation> <packet_loss> in the Master console

To observe the change, attach a terminal to the Client container

Limiting Node Resource using CGroup

We can also simulate real CPU usage by limiting resources for particular process using CGroup, to do so:

  1. Update the application execution script in src/main/bash/<application_name> and add a tag to the end of the execution part of the execution script Example: java Application.MarkerDetection.OpenCVServer.OpenCVServer <tag>
  2. Rebuild the application and push it to its meep-registry
  3. Run the included limit script that you can find in src/main/bash/NodeLimit with the Master ip as parameter Example: sudo bash limit.sh -v -a localhost:4567/node/limit
  4. Run limit_node <tag> <provided_bandwith> in the Master console
  5. To observe the change, attach a terminal to the Client container

Modifying the Demo

Deploying Your Own Application

When deploying your own application, make sure to pay attention to these:

  • The Dockerfile must be for building only, as execution would be done by AdvantEDGE

Modifying The AdvantEdge Deployment

When deploying multiple instances of the Client and Servers, there are some changes that must be done to the deployed application in AdvantEDGE. The following changes can be made from AdvantEDGE's Configure page or by modifying the opencv-demo.yaml

Setup in AdvantEDGE:

Value Description Example
image The complete image name for your application, including the meep-docker-registry 'meep-docker-registry:30001/<application_name>'
command The main command, most of the time it is /bin/bash /bin/bash
arguments The command that would be run as an argument to the commands, this includes your main application -c, export; ./<run_script>.sh;

For the Edge Application, there are some extra parameters that you need to change:

Value Description Example
port The port exposed by the Edge Application node 10300
protocol The protocol allowed on the exposed port TCP

Running the sample Client application

The run script for Client is client_exe.shand it has the following parameters:

Parameter Argument Description Example
Client ID -i The identification name that would be registered to the Master client13
MasterURL -m URL of the Master https://localhost:4567
Register Command -r REST End Point for the Client registry in the Master /client/register
Heartbeat Command -b REST End Point for sending the Client Heartbeat to the Master /client/beat
Get Server Command -s REST End Point for getting the Server from Master /client/get_node
Latency Report Command -l REST End Point for sending the latency report to the Master /client/report
Heartbeat Interval -v (Optional) Interval value in ms for sending the Heartbeat to the Master, default value is 1000ms 2000
Required Network -n Required Network Resource value for matchmaking 250
Required Resouce -e Required Computing Resouce value for matchmaking 200
Location -o Location value resource value for matchmaking 50

Running the sample Server application

The run script for Server is server_exe.shand it has the following parameters:

Parameter Argument Description Example
Server ID -i The identification name that would be registered to the Master server13
Server IP -a Address for that would be given to the Client by Master to establish TCP Connection edge-app
Port -p Port that would be given to the Client by Master to establish TCP Connection, this must correspond to the port exposed in Setup in AdvantEDGE 10300
MasterURL -m URL of the Master https://localhost:4567
Register Command -r REST End Point for the Server registry in the Master /client/register
Heartbeat Command -b REST End Point for sending the Server Heartbeat to the Master /node/register
Connected -c (Deprecated) connected value of the Server true
Heartbeat Interval -v (Optional) Interval value in ms for sending the Heartbeat to the Master, default value is 1000ms 2000
Total Network -n Network resource value that the server can provide for matchmaking 250
Total Resouce -e Computing Resouce value that the server can provide for matchmaking 200
Location -o Location value resource value for matchmaking 50

Heartbeat Debugging

You can check if the Master received Heartbeat request from its members by adding the following connection to the Configurations.json

{
    "in" : "rest_in",
    "out" : "console_out",
    "commands" : {
        "register_client $client_as_json_string" : "console registered $client_as_json_string_registered",
        "register_node $node_as_json_string" : "console registered $node_as_json_string_registered"
    }
}
Clone this wiki locally