-
Notifications
You must be signed in to change notification settings - Fork 2
Demo Marker Detection Application
We've included a sample demo application where we deploy an Aruco Marker Detection Application to AdvantEdge.
- Make sure AdvantEDGE can be ran on your Virtual Machine. To deploy AdvantEDGE in your machine (or any other) follow the instructions here.
- 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>
tosrc/main/
- Run
docker build --tag meep-docker-registry:30001/<application_name> .
anddocker push meep-docker-registry:30001/<application_name>
- Run AdvantEDGE create a new Scenario and import
marker-detection-test.yaml
- Create new Sandbox and run the previously created Scenario in the newly created sandbox
- 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 - Terminate and delete Sandbox and scenarios for subsequent experiments
- Download or clone the code repository to your target machine
- Build a FatJar, such as with ShadowJar plugin for Gradle
- Move the FatJar to the application root
- Run with
java -jar <fat-jar-name>.jar
, if it's working you should see an input prompt in the console
For this experiment we will use the sample runOpenCVDemo.json
scenario that you can find in src/main/resources/scenarios
- Start the
Master
usingjava -jar <fat-jar-name>.jar
- Run the scenario by inputting
load_scenario src/main/resources/scenarios/runOpenCVDemo.json
thenrun_scenario
in theMaster
console - Run
docker attach
toClient
in another terminal to check if everything's working - Use the command
assign_client <client_id>
inMaster
console or runcurl -X POST <master_ip>/client/assign/<client_id>
- Check in the attached terminal if everything is working properly
- Don't forget to terminate and delete Sandbox and scenarios for subsequent experiments
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
You can use AdvantEdge to simulate real world bandwith limitations, to do so you can:
- Update the
opencvdemo.yaml
insrc/main/resources/AdvantEdge
before running theMaster
scenario - Run
ae_update_nw_char <sandbox_name> <element_name> <element_type> <throughput_dl> <throughput_ul> <latency> <latency_variation> <packet_loss>
in theMaster
console
To observe the change, attach a terminal to the Client
container
We can also simulate real CPU usage by limiting resources for particular process using CGroup, to do so:
- Update the application execution script in
src/main/bash/<application_name>
and add atag
to the end of the execution part of the execution script Example:java Application.MarkerDetection.OpenCVServer.OpenCVServer <tag>
- Rebuild the application and push it to its
meep-registry
- Run the included limit script that you can find in
src/main/bash/NodeLimit
with theMaster
ip as parameter Example:sudo bash limit.sh -v -a localhost:4567/node/limit
- Run
limit_node <tag> <provided_bandwith>
in theMaster
console - To observe the change, attach a terminal to the
Client
container
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
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
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 |
The run script for Client is client_exe.sh
and 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 |
The run script for Server is server_exe.sh
and 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 |
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"
}
}