ajout gctrl
This commit is contained in:
parent
992980e12b
commit
1eb69ec7bf
19 changed files with 1079 additions and 0 deletions
2
gctrl/README.md
Normal file
2
gctrl/README.md
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
# General Controller
|
||||||
|

|
49
gctrl/pom.xml
Normal file
49
gctrl/pom.xml
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>fr.laas.sara.sdci</groupId>
|
||||||
|
<artifactId>fr.laas.sara.sdci.gctrl</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<source>9</source>
|
||||||
|
<target>9</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.h2database</groupId>
|
||||||
|
<artifactId>h2</artifactId>
|
||||||
|
<version>1.4.200</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>de.vandermeer</groupId>
|
||||||
|
<artifactId>asciitable</artifactId>
|
||||||
|
<version>0.3.2</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.signaflo</groupId>
|
||||||
|
<artifactId>timeseries</artifactId>
|
||||||
|
<version>0.4</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-api</artifactId>
|
||||||
|
<version>1.7.5</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
<artifactId>slf4j-log4j12</artifactId>
|
||||||
|
<version>1.7.5</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
78
gctrl/src/main/java/Analyze.java
Normal file
78
gctrl/src/main/java/Analyze.java
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
//* @author couedrao on 25/11/2019.
|
||||||
|
|
||||||
|
//* @project gctrl
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
//
|
||||||
|
//* 1)Perform complex data analysis and reasoning on the symptoms provided by the monitor function.
|
||||||
|
//* 2)Influenced by stored knowledge data.
|
||||||
|
//* 3)If changes are required, a change request is logically passed to the plan function.
|
||||||
|
//*
|
||||||
|
@SuppressWarnings({"SameParameterValue", "SynchronizeOnNonFinalField"})
|
||||||
|
class Analyze {
|
||||||
|
public String gw_current_RFC = "";
|
||||||
|
private static int i;
|
||||||
|
|
||||||
|
void start() {
|
||||||
|
Main.logger(this.getClass().getSimpleName(), "Start Analyzing");
|
||||||
|
|
||||||
|
while (Main.run) {
|
||||||
|
|
||||||
|
String current_symptom = get_symptom();
|
||||||
|
//Main.logger(this.getClass().getSimpleName(), "Received Symptom : " + current_symptom);
|
||||||
|
|
||||||
|
update_rfc(rfc_generator(current_symptom));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Symptom Receiver
|
||||||
|
private String get_symptom() {
|
||||||
|
synchronized (Main.monitor.gw_current_SYMP) {
|
||||||
|
try {
|
||||||
|
Main.monitor.gw_current_SYMP.wait();
|
||||||
|
} catch (InterruptedException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Main.monitor.gw_current_SYMP;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Rule-based RFC Generator
|
||||||
|
private String rfc_generator(String symptom) {
|
||||||
|
List<String> symptoms = Main.shared_knowledge.get_symptoms();
|
||||||
|
List<String> rfcs = Main.shared_knowledge.get_rfc();
|
||||||
|
|
||||||
|
if (symptom.contentEquals(symptoms.get(0)) || symptom.contentEquals(symptoms.get(2))) {
|
||||||
|
Main.logger(this.getClass().getSimpleName(), "RFC --> To plan : " + rfcs.get(0));
|
||||||
|
i = 0;
|
||||||
|
return rfcs.get(0);
|
||||||
|
} else if (symptom.contentEquals(symptoms.get(1))) {
|
||||||
|
i++;
|
||||||
|
if (i < 3) {
|
||||||
|
Main.logger(this.getClass().getSimpleName(), "RFC --> To plan : " + rfcs.get(1));
|
||||||
|
return rfcs.get(1);
|
||||||
|
} else {
|
||||||
|
Main.logger(this.getClass().getSimpleName(), "RFC --> To plan : " + "YourPlansDoNotWork");
|
||||||
|
return "YourPlansDoNotWork";
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void update_rfc(String rfc) {
|
||||||
|
|
||||||
|
synchronized (gw_current_RFC) {
|
||||||
|
gw_current_RFC.notify();
|
||||||
|
gw_current_RFC = rfc;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
102
gctrl/src/main/java/Execute.java
Normal file
102
gctrl/src/main/java/Execute.java
Normal file
|
@ -0,0 +1,102 @@
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
//* @author couedrao on 25/11/2019.
|
||||||
|
|
||||||
|
//* @project gctrl
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
//
|
||||||
|
//* Changes the behavior of the managed resource using effectors Changes the behavior of the managed resource using effectors, based on the actions recommended by the plan function.
|
||||||
|
//*
|
||||||
|
@SuppressWarnings({"SameParameterValue", "SynchronizeOnNonFinalField"})
|
||||||
|
class Execute {
|
||||||
|
private static List<String> workflow_lists;
|
||||||
|
private static final MANOAPI manoapi = new MANOAPI();
|
||||||
|
private static final SDNCtrlAPI sdnctlrapi = new SDNCtrlAPI();
|
||||||
|
|
||||||
|
void start() throws InterruptedException {
|
||||||
|
Main.logger(this.getClass().getSimpleName(), "Start Execution");
|
||||||
|
workflow_lists = Main.shared_knowledge.get_worklow_lists();
|
||||||
|
|
||||||
|
while (Main.run) {
|
||||||
|
String current_plan = get_plan();
|
||||||
|
|
||||||
|
// Main.logger(this.getClass().getSimpleName(), "Received Plan : " + current_plan);
|
||||||
|
String[] workflow = workflow_generator(current_plan);
|
||||||
|
for (int i = 0; i < workflow.length; i++) {
|
||||||
|
Main.logger(this.getClass().getSimpleName(), "workflow [" + i + "] : " + workflow[i]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String w : workflow) {
|
||||||
|
Main.logger(this.getClass().getSimpleName(), "UC : " + w);
|
||||||
|
switch (w) {
|
||||||
|
case "UC1":
|
||||||
|
Main.logger(this.getClass().getSimpleName(), "Nothing to do");
|
||||||
|
break;
|
||||||
|
case "UC2":
|
||||||
|
Main.logger(this.getClass().getSimpleName(), "Deploying GW");
|
||||||
|
String newdestip = manoapi.deploy_gw(Main.shared_knowledge.getGwinfo());
|
||||||
|
Main.shared_knowledge.setNewdestip(newdestip);
|
||||||
|
Main.shared_knowledge.setOldgwip(newdestip);
|
||||||
|
break;
|
||||||
|
case "UC3":
|
||||||
|
Main.logger(this.getClass().getSimpleName(), "Redirecting Traffic");
|
||||||
|
String status = sdnctlrapi.redirect_traffic(Main.shared_knowledge.getOlddestip(), Main.shared_knowledge.getNewdestip());
|
||||||
|
Main.logger(this.getClass().getSimpleName(), status);
|
||||||
|
break;
|
||||||
|
case "UC4":
|
||||||
|
Main.logger(this.getClass().getSimpleName(), "Deploying LB+GWs");
|
||||||
|
List<String> newgwsip = manoapi.deploy_multi_gws_and_lb(Main.shared_knowledge.getGwsinfo());
|
||||||
|
Main.shared_knowledge.setLbip(newgwsip.get(0));
|
||||||
|
Main.shared_knowledge.setNewgwsip(newgwsip.subList(1, newgwsip.size()));
|
||||||
|
break;
|
||||||
|
case "UC5":
|
||||||
|
Main.logger(this.getClass().getSimpleName(), "Inserting a loadbalancer");
|
||||||
|
status = sdnctlrapi.insert_a_loadbalancer(Main.shared_knowledge.getOldgwip(), Main.shared_knowledge.getLbip(), Main.shared_knowledge.getNewgwsip());
|
||||||
|
Main.logger(this.getClass().getSimpleName(), status);
|
||||||
|
break;
|
||||||
|
case "UC6":
|
||||||
|
Main.logger(this.getClass().getSimpleName(), "Removing less important traffic");
|
||||||
|
status = sdnctlrapi.remove_less_important_traffic(Main.shared_knowledge.getImportantsrcip());
|
||||||
|
Main.logger(this.getClass().getSimpleName(), status);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
Thread.sleep(2000);
|
||||||
|
continue;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Plan Receiver
|
||||||
|
private String get_plan() {
|
||||||
|
synchronized (Main.plan.gw_PLAN) {
|
||||||
|
try {
|
||||||
|
Main.plan.gw_PLAN.wait();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Main.plan.gw_PLAN;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Rule-based Workflow Generator
|
||||||
|
private String[] workflow_generator(String plan) {
|
||||||
|
List<String> plans = Main.shared_knowledge.get_plans();
|
||||||
|
if (plan.contentEquals(plans.get(0))) {
|
||||||
|
return workflow_lists.get(0).split("/");
|
||||||
|
} else if (plan.contentEquals(plans.get(1))) {
|
||||||
|
return workflow_lists.get(1).split("/");
|
||||||
|
} else if (plan.contentEquals(plans.get(2))) {
|
||||||
|
return workflow_lists.get(2).split("/");
|
||||||
|
} else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
404
gctrl/src/main/java/Knowledge.java
Normal file
404
gctrl/src/main/java/Knowledge.java
Normal file
|
@ -0,0 +1,404 @@
|
||||||
|
import org.h2.tools.DeleteDbFiles;
|
||||||
|
|
||||||
|
import java.sql.*;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
//* @author couedrao on 25/11/2019.
|
||||||
|
|
||||||
|
//* @project gctrl
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
//* 1)Standard data shared among the monitor analyze plan and Standard data shared among the monitor, analyze, plan and execute functions
|
||||||
|
|
||||||
|
//* 2)The shared knowledge includes data such as topology information, historical logs, metrics, symptoms and policies
|
||||||
|
|
||||||
|
//* 3)Created by the monitor part while execute part might update the knowledge
|
||||||
|
|
||||||
|
//*
|
||||||
|
|
||||||
|
class Knowledge {
|
||||||
|
|
||||||
|
private static final String DB_DRIVER = "org.h2.Driver";
|
||||||
|
private static final String DB_CONNECTION = "jdbc:h2:~/test";
|
||||||
|
private static final String DB_USER = "";
|
||||||
|
private static final String DB_PASSWORD = "";
|
||||||
|
|
||||||
|
static final int moving_wind = 10;
|
||||||
|
static final int horizon = 3;
|
||||||
|
static final String gw = "GW_I";
|
||||||
|
static final double gw_lat_threshold = 20;
|
||||||
|
|
||||||
|
/*TODO : edit symptom, rfc, workflow_lists, plan*/
|
||||||
|
private static final List<String> symptom = Arrays.asList("N/A", "NOK", "OK");
|
||||||
|
private static final List<String> rfc = Arrays.asList("DoNotDoAnything", "DecreaseLatencyIn" + gw);
|
||||||
|
private static final List<String> workflow_lists = Arrays.asList("UC1", "UC2/UC3", "UC4/UC5/UC6");
|
||||||
|
private static final List<String> plan = Arrays.asList("A", "B", "C");
|
||||||
|
private final Map<String, String> gwinfo = new HashMap<>();
|
||||||
|
private final List<Map<String, String>> gwsinfo = new ArrayList<>();
|
||||||
|
private final String olddestip = "192.168.0.2";
|
||||||
|
private String newdestip;
|
||||||
|
private String oldgwip;
|
||||||
|
private String lbip;
|
||||||
|
private List<String> newgwsip;
|
||||||
|
private final String importantsrcip = "192.168.0.1";
|
||||||
|
|
||||||
|
void start() throws Exception {
|
||||||
|
// delete the H2 database named 'test' in the user home directory
|
||||||
|
DeleteDbFiles.execute("~", "test", true);
|
||||||
|
Main.logger(this.getClass().getSimpleName(), "old database 'test' deleted");
|
||||||
|
//Initialization of the Knowledge
|
||||||
|
store_symptoms();
|
||||||
|
store_rfcs();
|
||||||
|
store_plans();
|
||||||
|
store_execution_workflow();
|
||||||
|
//TODO : update gwinfo
|
||||||
|
gwinfo.put("name", "gw");
|
||||||
|
gwinfo.put("image", "alpine:latest");
|
||||||
|
gwinfo.put("net", "new_network");
|
||||||
|
|
||||||
|
gwsinfo.add(0, gwinfo);
|
||||||
|
gwsinfo.add(1, gwinfo);
|
||||||
|
gwsinfo.add(2, gwinfo);
|
||||||
|
|
||||||
|
Main.logger(this.getClass().getSimpleName(), "Knowledge Starting");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void insert_in_tab(Timestamp timestamp, double lat) {
|
||||||
|
try (Connection conn = getDBConnection()) {
|
||||||
|
PreparedStatement insert;
|
||||||
|
String InsertQuery = "INSERT INTO " + Knowledge.gw + "_LAT" + " (id, latency) values" + "(?,?)";
|
||||||
|
conn.setAutoCommit(false);
|
||||||
|
insert = conn.prepareStatement(InsertQuery);
|
||||||
|
insert.setTimestamp(1, timestamp);
|
||||||
|
insert.setDouble(2, lat);
|
||||||
|
insert.executeUpdate();
|
||||||
|
insert.close();
|
||||||
|
conn.commit();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
System.out.println("Exception Message " + e.getLocalizedMessage());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> get_symptoms() {
|
||||||
|
String gw_symp = gw + "_SYMP";
|
||||||
|
|
||||||
|
Connection conn = getDBConnection();
|
||||||
|
String SelectQuery = "select * from " + gw_symp;
|
||||||
|
PreparedStatement select;
|
||||||
|
List<String> r = null;
|
||||||
|
try {
|
||||||
|
select = conn.prepareStatement(SelectQuery);
|
||||||
|
ResultSet rs = select.executeQuery();
|
||||||
|
r = new ArrayList<>();
|
||||||
|
while (rs.next()) {
|
||||||
|
r.add(rs.getString("symptom"));
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
System.out.println("Exception Message " + e.getLocalizedMessage());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> get_rfc() {
|
||||||
|
String gw_rfc = gw + "_RFC";
|
||||||
|
|
||||||
|
Connection conn = getDBConnection();
|
||||||
|
String SelectQuery = "select * from " + gw_rfc;
|
||||||
|
PreparedStatement select;
|
||||||
|
List<String> r = null;
|
||||||
|
try {
|
||||||
|
select = conn.prepareStatement(SelectQuery);
|
||||||
|
ResultSet rs = select.executeQuery();
|
||||||
|
r = new ArrayList<>();
|
||||||
|
while (rs.next()) {
|
||||||
|
r.add(rs.getString("rfc"));
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
System.out.println("Exception Message " + e.getLocalizedMessage());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return r;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> get_plans() {
|
||||||
|
String gw_plan = gw + "_PLAN";
|
||||||
|
|
||||||
|
Connection conn = getDBConnection();
|
||||||
|
String SelectQuery = "select * from " + gw_plan;
|
||||||
|
PreparedStatement select;
|
||||||
|
List<String> r = null;
|
||||||
|
try {
|
||||||
|
select = conn.prepareStatement(SelectQuery);
|
||||||
|
ResultSet rs = select.executeQuery();
|
||||||
|
r = new ArrayList<>();
|
||||||
|
while (rs.next()) {
|
||||||
|
r.add(rs.getString("plan"));
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
System.out.println("Exception Message " + e.getLocalizedMessage());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return r;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> get_worklow_lists() {
|
||||||
|
String gw_execw = gw + "_EXECW";
|
||||||
|
|
||||||
|
Connection conn = getDBConnection();
|
||||||
|
String SelectQuery = "select * from " + gw_execw;
|
||||||
|
PreparedStatement select;
|
||||||
|
List<String> r = null;
|
||||||
|
try {
|
||||||
|
select = conn.prepareStatement(SelectQuery);
|
||||||
|
ResultSet rs = select.executeQuery();
|
||||||
|
r = new ArrayList<>();
|
||||||
|
while (rs.next()) {
|
||||||
|
r.add(rs.getString("workflow"));
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
System.out.println("Exception Message " + e.getLocalizedMessage());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return r;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ResultSet select_from_tab() {
|
||||||
|
//Main.logger("Select the last " + n + " latencies");
|
||||||
|
Connection conn = getDBConnection();
|
||||||
|
String SelectQuery = "select TOP " + moving_wind + " * from " + Knowledge.gw + "_LAT" + " ORDER BY id DESC";
|
||||||
|
//PreparedStatement select;
|
||||||
|
ResultSet rs = null;
|
||||||
|
try {
|
||||||
|
Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
|
||||||
|
// select = conn.prepareStatement(SelectQuery);
|
||||||
|
rs = stmt.executeQuery(SelectQuery);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
System.out.println("Exception Message " + e.getLocalizedMessage());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return rs;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void create_lat_tab() {
|
||||||
|
try (Connection conn = getDBConnection()) {
|
||||||
|
Statement create;
|
||||||
|
conn.setAutoCommit(false);
|
||||||
|
create = conn.createStatement();
|
||||||
|
create.execute("CREATE TABLE " + Knowledge.gw + "_LAT" + " (id timestamp primary key, latency double )");
|
||||||
|
create.close();
|
||||||
|
conn.commit();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
System.out.println("Exception Message " + e.getLocalizedMessage());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
Main.logger(this.getClass().getSimpleName(), "... Database Created");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void store_plans() throws SQLException {
|
||||||
|
String gw_plan = gw + "_PLAN";
|
||||||
|
Connection conn = getDBConnection();
|
||||||
|
Statement create;
|
||||||
|
conn.setAutoCommit(false);
|
||||||
|
create = conn.createStatement();
|
||||||
|
create.execute("CREATE TABLE " + gw_plan + " (id int primary key, plan varchar(20) )");
|
||||||
|
create.close();
|
||||||
|
|
||||||
|
for (int i = 0; i < plan.size(); i++) {
|
||||||
|
conn = getDBConnection();
|
||||||
|
PreparedStatement insert;
|
||||||
|
try {
|
||||||
|
insert = conn.prepareStatement("INSERT INTO " + gw_plan + " (id, plan) values" + "(?,?)");
|
||||||
|
insert.setInt(1, i + 1);
|
||||||
|
insert.setString(2, plan.get(i));
|
||||||
|
insert.executeUpdate();
|
||||||
|
insert.close();
|
||||||
|
conn.commit();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
System.out.println("Exception Message " + e.getLocalizedMessage());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
conn.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void store_rfcs() throws SQLException {
|
||||||
|
String gw_rfc = gw + "_RFC";
|
||||||
|
Connection conn = getDBConnection();
|
||||||
|
Statement create;
|
||||||
|
conn.setAutoCommit(false);
|
||||||
|
create = conn.createStatement();
|
||||||
|
create.execute("CREATE TABLE " + gw_rfc + " (id int primary key, rfc varchar(40) )");
|
||||||
|
create.close();
|
||||||
|
|
||||||
|
for (int i = 0; i < rfc.size(); i++) {
|
||||||
|
conn = getDBConnection();
|
||||||
|
PreparedStatement insert;
|
||||||
|
try {
|
||||||
|
insert = conn.prepareStatement("INSERT INTO " + gw_rfc + " (id, rfc) values" + "(?,?)");
|
||||||
|
insert.setInt(1, i + 1);
|
||||||
|
insert.setString(2, rfc.get(i));
|
||||||
|
insert.executeUpdate();
|
||||||
|
insert.close();
|
||||||
|
conn.commit();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
System.out.println("Exception Message " + e.getLocalizedMessage());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
conn.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void store_execution_workflow() throws SQLException {
|
||||||
|
String gw_execw = gw + "_EXECW";
|
||||||
|
Connection conn = getDBConnection();
|
||||||
|
Statement create;
|
||||||
|
conn.setAutoCommit(false);
|
||||||
|
create = conn.createStatement();
|
||||||
|
create.execute("CREATE TABLE " + gw_execw + " (id int primary key, workflow varchar(50) )");
|
||||||
|
create.close();
|
||||||
|
|
||||||
|
for (int i = 0; i < workflow_lists.size(); i++) {
|
||||||
|
conn = getDBConnection();
|
||||||
|
PreparedStatement insert;
|
||||||
|
try {
|
||||||
|
insert = conn.prepareStatement("INSERT INTO " + gw_execw + " (id, workflow) values" + "(?,?)");
|
||||||
|
insert.setInt(1, i + 1);
|
||||||
|
insert.setString(2, workflow_lists.get(i));
|
||||||
|
insert.executeUpdate();
|
||||||
|
insert.close();
|
||||||
|
conn.commit();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
System.out.println("Exception Message " + e.getLocalizedMessage());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
conn.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void store_symptoms() throws SQLException {
|
||||||
|
String gw_symp = gw + "_SYMP";
|
||||||
|
Connection conn = getDBConnection();
|
||||||
|
Statement create;
|
||||||
|
conn.setAutoCommit(false);
|
||||||
|
create = conn.createStatement();
|
||||||
|
create.execute("CREATE TABLE " + gw_symp + " (id int primary key, symptom varchar(5) )");
|
||||||
|
create.close();
|
||||||
|
|
||||||
|
for (int i = 0; i < symptom.size(); i++) {
|
||||||
|
conn = getDBConnection();
|
||||||
|
PreparedStatement insert;
|
||||||
|
|
||||||
|
try {
|
||||||
|
insert = conn.prepareStatement("INSERT INTO " + gw_symp + " (id, symptom) values" + "(?,?)");
|
||||||
|
insert.setInt(1, i + 1);
|
||||||
|
insert.setString(2, symptom.get(i));
|
||||||
|
insert.executeUpdate();
|
||||||
|
insert.close();
|
||||||
|
conn.commit();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
System.out.println("Exception Message " + e.getLocalizedMessage());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
conn.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Connection getDBConnection() {
|
||||||
|
// Main.logger("Connecting the database ...");
|
||||||
|
try {
|
||||||
|
Class.forName(DB_DRIVER);
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return DriverManager.getConnection(DB_CONNECTION, DB_USER, DB_PASSWORD);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, String> getGwinfo() {
|
||||||
|
return gwinfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Map<String, String>> getGwsinfo() {
|
||||||
|
return gwsinfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOlddestip() {
|
||||||
|
return olddestip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNewdestip() {
|
||||||
|
return newdestip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNewdestip(String newdestip) {
|
||||||
|
this.newdestip = newdestip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOldgwip() {
|
||||||
|
return oldgwip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOldgwip(String oldgwip) {
|
||||||
|
this.oldgwip = oldgwip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLbip() {
|
||||||
|
return lbip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLbip(String lbip) {
|
||||||
|
this.lbip = lbip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getNewgwsip() {
|
||||||
|
return newgwsip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNewgwsip(List<String> newgwsip) {
|
||||||
|
this.newgwsip = newgwsip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getImportantsrcip() {
|
||||||
|
return importantsrcip;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
36
gctrl/src/main/java/MANOAPI.java
Normal file
36
gctrl/src/main/java/MANOAPI.java
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author couedrao on 27/11/2019.
|
||||||
|
* @project gctrl
|
||||||
|
*/
|
||||||
|
class MANOAPI {
|
||||||
|
|
||||||
|
String deploy_gw(Map<String, String> vnfinfos) {
|
||||||
|
String ip = "192.168.0." + (new Random().nextInt(253) + 1);
|
||||||
|
Main.logger(this.getClass().getSimpleName(), "Deploying VNF ...");
|
||||||
|
|
||||||
|
//printing
|
||||||
|
for (Entry<String, String> e : vnfinfos.entrySet()) {
|
||||||
|
Main.logger(this.getClass().getSimpleName(), "\t" + e.getKey() + " : " + e.getValue());
|
||||||
|
}
|
||||||
|
//TODO
|
||||||
|
|
||||||
|
return ip;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> deploy_multi_gws_and_lb(List<Map<String, String>> vnfsinfos) {
|
||||||
|
List<String> ips = new ArrayList<>();
|
||||||
|
//TODO
|
||||||
|
|
||||||
|
for (Map<String, String> vnfsinfo : vnfsinfos) {
|
||||||
|
ips.add(deploy_gw(vnfsinfo));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ips;
|
||||||
|
}
|
||||||
|
}
|
92
gctrl/src/main/java/Main.java
Normal file
92
gctrl/src/main/java/Main.java
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
import org.apache.log4j.Level;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
//* @author couedrao on 25/11/2019.
|
||||||
|
|
||||||
|
//* @project gctrl
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
class Main {
|
||||||
|
static boolean run = true;
|
||||||
|
static final Monitor monitor = new Monitor();
|
||||||
|
static final Analyze analyze = new Analyze();
|
||||||
|
static final Plan plan = new Plan();
|
||||||
|
private static final Execute execute = new Execute();
|
||||||
|
static final Knowledge shared_knowledge = new Knowledge();
|
||||||
|
private static final boolean log = true;
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
Logger.getRootLogger().setLevel(Level.ERROR);
|
||||||
|
|
||||||
|
|
||||||
|
shared_knowledge.start();
|
||||||
|
Thread.sleep(3000);
|
||||||
|
|
||||||
|
Thread thread_m = new Thread(() -> {
|
||||||
|
try {
|
||||||
|
monitor.start();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Thread thread_a = new Thread(() -> {
|
||||||
|
try {
|
||||||
|
analyze.start();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Thread thread_p = new Thread(() -> {
|
||||||
|
try {
|
||||||
|
plan.start();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Thread thread_e = new Thread(() -> {
|
||||||
|
try {
|
||||||
|
execute.start();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
thread_m.start();
|
||||||
|
thread_a.start();
|
||||||
|
thread_p.start();
|
||||||
|
thread_e.start();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void logger(String from, String msg) {
|
||||||
|
if (log) {
|
||||||
|
switch (from) {
|
||||||
|
case "Knowledge":
|
||||||
|
System.out.println("\u001B[1;31m" + "\t[" + from + "] : \t\t" + msg + "\u001B[0m");
|
||||||
|
break;
|
||||||
|
case "Monitor":
|
||||||
|
System.out.println("\u001B[1;32m" + "\t[" + from + "] : \t\t" + msg + "\u001B[0m");
|
||||||
|
break;
|
||||||
|
case "Analyze":
|
||||||
|
System.out.println("\u001B[1;34m" + "\t[" + from + "] : \t\t" + msg + "\u001B[0m");
|
||||||
|
break;
|
||||||
|
case "Plan":
|
||||||
|
System.out.println("\u001B[1;35m" + "\t[" + from + "] : \t\t\t" + msg + "\u001B[0m");
|
||||||
|
break;
|
||||||
|
case "Execute":
|
||||||
|
System.out.println("\u001B[1;36m" + "\t[" + from + "] : \t\t" + msg + "\u001B[0m");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
System.out.println("\t[" + from + "] : \t\t" + msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
159
gctrl/src/main/java/Monitor.java
Normal file
159
gctrl/src/main/java/Monitor.java
Normal file
|
@ -0,0 +1,159 @@
|
||||||
|
import com.github.signaflo.math.operations.DoubleFunctions;
|
||||||
|
import com.github.signaflo.timeseries.TimeSeries;
|
||||||
|
import com.github.signaflo.timeseries.forecast.Forecast;
|
||||||
|
import com.github.signaflo.timeseries.model.arima.Arima;
|
||||||
|
import com.github.signaflo.timeseries.model.arima.ArimaOrder;
|
||||||
|
import de.vandermeer.asciitable.AsciiTable;
|
||||||
|
import de.vandermeer.asciitable.CWC_LongestWord;
|
||||||
|
import de.vandermeer.asciithemes.a7.A7_Grids;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
//
|
||||||
|
|
||||||
|
//* @author couedrao on 25/11/2019.
|
||||||
|
|
||||||
|
//* @project gctrl
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
//* 1)Collects the details from the managed resources e g topology Collects the details from the managed resources e.g. topology information, metrics (e.g. offered capacity and throughput), configuration property settings and so on.
|
||||||
|
|
||||||
|
|
||||||
|
//* 2)The monitor function aggregates,correlates and filters these details until it determines a symptom that needs to be analyzed.
|
||||||
|
|
||||||
|
|
||||||
|
//*
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings({"SynchronizeOnNonFinalField"})
|
||||||
|
class Monitor {
|
||||||
|
private static List<String> symptom;
|
||||||
|
private static final int period = 2000;
|
||||||
|
private static double i = 0;
|
||||||
|
public String gw_current_SYMP = "N/A";
|
||||||
|
|
||||||
|
void start() {
|
||||||
|
Main.logger(this.getClass().getSimpleName(), "Start monitoring of " + Knowledge.gw);
|
||||||
|
symptom = Main.shared_knowledge.get_symptoms();
|
||||||
|
Main.shared_knowledge.create_lat_tab();
|
||||||
|
data_collector(); //in bg
|
||||||
|
symptom_generator();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Symptom Generator (can be modified)
|
||||||
|
private void symptom_generator() {
|
||||||
|
while (Main.run)
|
||||||
|
try {
|
||||||
|
Thread.sleep(period * 5);
|
||||||
|
ResultSet rs = Main.shared_knowledge.select_from_tab();
|
||||||
|
//print_nice_rs(rs);
|
||||||
|
double[] prediction = predict_next_lat(rs);
|
||||||
|
boolean isOk = true;
|
||||||
|
for (int j = 0; j < Knowledge.horizon; j++) {
|
||||||
|
if (prediction[j] > Knowledge.gw_lat_threshold) {
|
||||||
|
Main.logger(this.getClass().getSimpleName(), "Symptom --> To Analyse : " + symptom.get(1));
|
||||||
|
update_symptom(symptom.get(1));
|
||||||
|
isOk = false;
|
||||||
|
break;
|
||||||
|
} else if (prediction[j] < .0) {
|
||||||
|
Main.logger(this.getClass().getSimpleName(), " Symptom --> To Analyse : " + symptom.get(0));
|
||||||
|
update_symptom(symptom.get(0));
|
||||||
|
isOk = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isOk) {
|
||||||
|
Main.logger(this.getClass().getSimpleName(), "Symptom --> To Analyse : " + symptom.get(2));
|
||||||
|
update_symptom(symptom.get(2));
|
||||||
|
}
|
||||||
|
} catch (SQLException | InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Data Collector TODO : modify
|
||||||
|
private void data_collector() {
|
||||||
|
new Thread(() -> {
|
||||||
|
Main.logger(this.getClass().getSimpleName(), "Filling db with latencies");
|
||||||
|
while (Main.run)
|
||||||
|
try {
|
||||||
|
//TODO: Remove this
|
||||||
|
Thread.sleep(period);
|
||||||
|
Main.shared_knowledge.insert_in_tab(new java.sql.Timestamp(new java.util.Date().getTime()), get_fake_data());
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private int get_data() {
|
||||||
|
//Call Sensors
|
||||||
|
/*TODO*/
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private double get_fake_data() {
|
||||||
|
//return new Random().nextInt();
|
||||||
|
return i += 2.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
//ARIMA-based Forecasting
|
||||||
|
private double[] predict_next_lat(ResultSet rs) throws SQLException {
|
||||||
|
rs.first();
|
||||||
|
double[] history = new double[Knowledge.moving_wind];
|
||||||
|
double[] p = new double[Knowledge.horizon];
|
||||||
|
int j = Knowledge.moving_wind - 1;
|
||||||
|
while (rs.next()) {
|
||||||
|
history[j] = Double.parseDouble(rs.getString("latency"));
|
||||||
|
j--;
|
||||||
|
}
|
||||||
|
TimeSeries timeSeries = TimeSeries.from(DoubleFunctions.arrayFrom(history));
|
||||||
|
ArimaOrder modelOrder = ArimaOrder.order(0, 1, 1, 0, 1, 1);
|
||||||
|
//ArimaOrder modelOrder = ArimaOrder.order(0, 0, 0, 1, 1, 1);
|
||||||
|
Arima model = Arima.model(timeSeries, modelOrder);
|
||||||
|
Forecast forecast = model.forecast(Knowledge.moving_wind);
|
||||||
|
System.out.print("Point Estimates : ");
|
||||||
|
for (int k = 0; k < Knowledge.horizon; k++) {
|
||||||
|
p[k] = forecast.pointEstimates().at(k);
|
||||||
|
System.out.print(p[k] + "; ");
|
||||||
|
}
|
||||||
|
System.out.println();
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void print_nice_rs(ResultSet rs) throws SQLException {
|
||||||
|
rs.first();
|
||||||
|
AsciiTable at = new AsciiTable();
|
||||||
|
at.addRule();
|
||||||
|
at.addRow("Timestamp", "Latency_in_" + Knowledge.gw);
|
||||||
|
at.addRule();
|
||||||
|
while (rs.next()) {
|
||||||
|
at.addRow(rs.getTimestamp("id").getTime(), rs.getString("latency"));
|
||||||
|
at.addRule();
|
||||||
|
}
|
||||||
|
at.getContext().setGrid(A7_Grids.minusBarPlusEquals());
|
||||||
|
at.getRenderer().setCWC(new CWC_LongestWord());
|
||||||
|
System.out.println(this.getClass().getSimpleName() + " : ");
|
||||||
|
System.out.println(at.render());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void update_symptom(String symptom) {
|
||||||
|
|
||||||
|
synchronized (gw_current_SYMP) {
|
||||||
|
gw_current_SYMP.notify();
|
||||||
|
gw_current_SYMP = symptom;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
87
gctrl/src/main/java/Plan.java
Normal file
87
gctrl/src/main/java/Plan.java
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
// @author couedrao on 25/11/2019.
|
||||||
|
|
||||||
|
//* @project gctrl
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
//* 1)Structures the actions needed to achieve goals and objectives Structures the actions needed to achieve goals and objectives.
|
||||||
|
|
||||||
|
//* 2)The plan function creates or selects a procedure to enact a desired alteration in the managed resource.
|
||||||
|
|
||||||
|
//* 3)The plan function can take on many forms, ranging from a single command to a complex workflow.
|
||||||
|
|
||||||
|
//*
|
||||||
|
|
||||||
|
@SuppressWarnings({"SynchronizeOnNonFinalField"})
|
||||||
|
class Plan {
|
||||||
|
private static int i;
|
||||||
|
public String gw_PLAN = "";
|
||||||
|
|
||||||
|
void start() {
|
||||||
|
Main.logger(this.getClass().getSimpleName(), "Start Planning");
|
||||||
|
|
||||||
|
while (Main.run) {
|
||||||
|
String current_rfc = get_rfc();
|
||||||
|
//Main.logger(this.getClass().getSimpleName(), "Received RFC : " + current_rfc);
|
||||||
|
update_plan(plan_generator(current_rfc));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//RFC Receiver
|
||||||
|
private String get_rfc() {
|
||||||
|
synchronized (Main.analyze.gw_current_RFC) {
|
||||||
|
try {
|
||||||
|
Main.analyze.gw_current_RFC.wait();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Main.analyze.gw_current_RFC;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Rule-based Plan Generator
|
||||||
|
private String plan_generator(String rfc) {
|
||||||
|
List<String> rfcs = Main.shared_knowledge.get_rfc();
|
||||||
|
List<String> plans = Main.shared_knowledge.get_plans();
|
||||||
|
|
||||||
|
if ("YourPlansDoNotWork".contentEquals(rfc)) {
|
||||||
|
// Thread.sleep(2000);
|
||||||
|
Main.run = false;
|
||||||
|
Main.logger(this.getClass().getSimpleName(), "All the Plans were executed without success. \n \t\t The loop will stop!");
|
||||||
|
// Terminate JVM
|
||||||
|
System.exit(0);
|
||||||
|
} else if (rfc.contentEquals(rfcs.get(0))) {
|
||||||
|
Main.logger(this.getClass().getSimpleName(), "Plan --> To Execute : " + plans.get(0));
|
||||||
|
i = 0;
|
||||||
|
return plans.get(0);
|
||||||
|
} else if (rfc.contentEquals(rfcs.get(1))) {
|
||||||
|
if (i == 0) {
|
||||||
|
Main.logger(this.getClass().getSimpleName(), "Plan --> To Execute : " + plans.get(1));
|
||||||
|
i++;
|
||||||
|
return plans.get(1);
|
||||||
|
} else if (i == 1) {
|
||||||
|
Main.logger(this.getClass().getSimpleName(), "Plan --> To Execute : " + plans.get(2));
|
||||||
|
i++;
|
||||||
|
return plans.get(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void update_plan(String plan) {
|
||||||
|
synchronized (gw_PLAN) {
|
||||||
|
gw_PLAN.notify();
|
||||||
|
gw_PLAN = plan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
34
gctrl/src/main/java/SDNCtrlAPI.java
Normal file
34
gctrl/src/main/java/SDNCtrlAPI.java
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author couedrao on 27/11/2019.
|
||||||
|
* @project gctrl
|
||||||
|
*/
|
||||||
|
class SDNCtrlAPI {
|
||||||
|
|
||||||
|
String redirect_traffic(String olddestip, String newdestip) {
|
||||||
|
String status = "OK";
|
||||||
|
Main.logger(this.getClass().getSimpleName(), "olddestip = " + olddestip + "; newdestip = " + newdestip);
|
||||||
|
//TODO
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
String insert_a_loadbalancer(String oldgwip, String lbip, List<String> newgwsip) {
|
||||||
|
String status = "OK";
|
||||||
|
Main.logger(this.getClass().getSimpleName(), "oldgwip = " + oldgwip + "; lbip = " + lbip + "; newgwsip = " + newgwsip);
|
||||||
|
//TODO
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
String remove_less_important_traffic(String importantsrcip) {
|
||||||
|
String status = "OK";
|
||||||
|
Main.logger(this.getClass().getSimpleName(), "importantsrcip = " + importantsrcip);
|
||||||
|
//TODO
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
1
gctrl/src/misc/5sdbd_gc.draft.svg
Normal file
1
gctrl/src/misc/5sdbd_gc.draft.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 330 KiB |
35
gctrl/src/test/java/Tester.java
Normal file
35
gctrl/src/test/java/Tester.java
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
//
|
||||||
|
//* @author couedrao on 25/11/2019.
|
||||||
|
//* @project gctrl
|
||||||
|
//
|
||||||
|
class Tester {
|
||||||
|
|
||||||
|
private static final Knowledge k = new Knowledge();
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
k.start();
|
||||||
|
List<String> workflow_lists = k.get_worklow_lists();
|
||||||
|
while (Main.run) {
|
||||||
|
logger("You are in test mode! The following actions can be performed : ");
|
||||||
|
for (int i = 0; i < workflow_lists.size(); i++) {
|
||||||
|
logger("[" + i + "] :" + workflow_lists.get(i));
|
||||||
|
}
|
||||||
|
logger("Select any number in [0-" + (workflow_lists.size() - 1) + "] to continue");
|
||||||
|
int input = new Scanner(System.in).nextInt();
|
||||||
|
if (input < workflow_lists.size() )
|
||||||
|
logger("Execution of Action : [" + workflow_lists.get(input) + "]");
|
||||||
|
else logger("(-_-)");
|
||||||
|
|
||||||
|
//Call Effectors
|
||||||
|
/*TODO : */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void logger(String msg) {
|
||||||
|
if (true)
|
||||||
|
System.out.println(msg);
|
||||||
|
}
|
||||||
|
}
|
BIN
gctrl/target/classes/Analyze.class
Normal file
BIN
gctrl/target/classes/Analyze.class
Normal file
Binary file not shown.
BIN
gctrl/target/classes/Execute.class
Normal file
BIN
gctrl/target/classes/Execute.class
Normal file
Binary file not shown.
BIN
gctrl/target/classes/Knowledge.class
Normal file
BIN
gctrl/target/classes/Knowledge.class
Normal file
Binary file not shown.
BIN
gctrl/target/classes/Main.class
Normal file
BIN
gctrl/target/classes/Main.class
Normal file
Binary file not shown.
BIN
gctrl/target/classes/Monitor.class
Normal file
BIN
gctrl/target/classes/Monitor.class
Normal file
Binary file not shown.
BIN
gctrl/target/classes/Plan.class
Normal file
BIN
gctrl/target/classes/Plan.class
Normal file
Binary file not shown.
BIN
gctrl/target/test-classes/Tester.class
Normal file
BIN
gctrl/target/test-classes/Tester.class
Normal file
Binary file not shown.
Loading…
Reference in a new issue