jars added and gctrl update
This commit is contained in:
parent
fd3fe273f4
commit
8a1b169298
11 changed files with 166 additions and 88 deletions
|
@ -22,7 +22,15 @@ class Analyze {
|
|||
Main.logger(this.getClass().getSimpleName(), "Start Analyzing");
|
||||
|
||||
while (Main.run) {
|
||||
|
||||
|
||||
////////////////////////////////
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
////////////////////////////////
|
||||
|
||||
String current_symptom = get_symptom();
|
||||
//Main.logger(this.getClass().getSimpleName(), "Received Symptom : " + current_symptom);
|
||||
|
||||
|
|
|
@ -19,12 +19,25 @@ class Execute {
|
|||
private static List<String> workflow_lists;
|
||||
private static final MANOAPI manoapi = new MANOAPI();
|
||||
private static final SDNCtrlAPI sdnctlrapi = new SDNCtrlAPI();
|
||||
static int period = 2000;
|
||||
static int period2 = 2000;
|
||||
|
||||
static int UC2_already_done = 0;
|
||||
static int UC3_already_done = 0;
|
||||
|
||||
void start() throws InterruptedException {
|
||||
Main.logger(this.getClass().getSimpleName(), "Start Execution");
|
||||
workflow_lists = Main.shared_knowledge.get_worklow_lists();
|
||||
|
||||
while (Main.run) {
|
||||
////////////////////////////////
|
||||
try {
|
||||
Thread.sleep(period);
|
||||
//period = 0;
|
||||
} catch (InterruptedException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
////////////////////////////////
|
||||
String current_plan = get_plan();
|
||||
|
||||
// Main.logger(this.getClass().getSimpleName(), "Received Plan : " + current_plan);
|
||||
|
@ -42,39 +55,48 @@ class Execute {
|
|||
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(Main.shared_knowledge.getOlddestip());
|
||||
if (UC2_already_done == 0){
|
||||
UC2_already_done = 1;
|
||||
System.out.println("Now .... "+UC2_already_done);
|
||||
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(Main.shared_knowledge.getOlddestip());
|
||||
}
|
||||
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);
|
||||
String status;
|
||||
if (UC3_already_done == 0){
|
||||
UC3_already_done = 1;
|
||||
Main.logger(this.getClass().getSimpleName(), "Redirecting Traffic");
|
||||
status = sdnctlrapi.redirect_traffic(Main.shared_knowledge.getOlddestip(), Main.shared_knowledge.getNewdestip());
|
||||
Main.logger(this.getClass().getSimpleName(), status);
|
||||
UC3_already_done = 1;
|
||||
period2 = 4000;
|
||||
}
|
||||
break;
|
||||
case "UC4":
|
||||
Main.logger(this.getClass().getSimpleName(), "Deploying LB+GWs");
|
||||
/*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()));
|
||||
Main.shared_knowledge.setNewgwsip(newgwsip.subList(1, newgwsip.size()));*/
|
||||
break;
|
||||
case "UC5":
|
||||
Main.logger(this.getClass().getSimpleName(), "Inserting a loadbalancer");
|
||||
/*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);
|
||||
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);
|
||||
//Plan.i = -1;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
} catch (ClientProtocolException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
Thread.sleep(2000);
|
||||
|
|
|
@ -29,9 +29,10 @@ class Knowledge {
|
|||
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 = 70;
|
||||
static final int horizon = 5;
|
||||
static final String gw = "GWI1";
|
||||
//static final double gw_lat_threshold = 80;
|
||||
static double gw_lat_threshold = 70;
|
||||
|
||||
/*TODO : edit symptom, rfc, workflow_lists, plan*/
|
||||
private static final List<String> symptom = Arrays.asList("N/A", "NOK", "OK");
|
||||
|
@ -41,11 +42,11 @@ class Knowledge {
|
|||
private final Map<String, String> gwinfo = new HashMap<>();
|
||||
private final List<Map<String, String>> gwsinfo = new ArrayList<>();
|
||||
private final String olddestip = "10.2.2.1";
|
||||
private String newdestip;
|
||||
private String newdestip = "10.2.2.2";
|
||||
private String oldgwip;
|
||||
private String lbip;
|
||||
private List<String> newgwsip;
|
||||
private final String importantsrcip = "192.168.0.1";
|
||||
private final String importantsrcip = "10.0.1.100";
|
||||
|
||||
void start() throws Exception {
|
||||
// delete the H2 database named 'test' in the user home directory
|
||||
|
|
|
@ -50,15 +50,11 @@ class MANOAPI {
|
|||
}
|
||||
//TODO ************ (giw2: 10.2.2.2 intern ==> 172.17.0.17 extern)
|
||||
|
||||
for (Entry<String, String> e : vnfinfos.entrySet()) {
|
||||
//for (Entry<String, String> e : vnfinfos.entrySet()) {
|
||||
httpclient = HttpClients.createDefault();
|
||||
httpPut = new HttpPut("http://127.0.0.1:5001/restapi/compute/dc1/"+vnfinfos.get("name"));
|
||||
httpPut.setHeader("Accept", "application/json");
|
||||
httpPut.setHeader("Content-type", "application/json");//vnfinfos.get("image")
|
||||
/*String inputJson = "{\n" +
|
||||
" \"image\": \"+gateway:topo+\",\n" +
|
||||
" \"network\": \"(id=input,ip=10.2.2.2/8)\"\n" +
|
||||
"}";*/
|
||||
inputJson = "{\n" +
|
||||
" \"image\": \""+vnfinfos.get("image")+"\",\n" +
|
||||
" \"network\": \"(id=input,ip="+ip+"/8)\"\n" +
|
||||
|
@ -68,38 +64,15 @@ class MANOAPI {
|
|||
response = httpclient.execute(httpPut);
|
||||
br = new BufferedReader(new InputStreamReader((response.getEntity().getContent())));
|
||||
if (response.getStatusLine().getStatusCode() != 200) {
|
||||
throw new RuntimeException("Failed : HTTP error code : " + response.getStatusLine().getStatusCode());
|
||||
//break;
|
||||
//throw new RuntimeException("Failed : HTTP error code : " + response.getStatusLine().getStatusCode());
|
||||
}
|
||||
result = new StringBuffer();
|
||||
line = "";
|
||||
while ((line = br.readLine()) != null) {
|
||||
System.out.println("Response : \n" + result.append(line));
|
||||
}
|
||||
|
||||
//Fixing script gateway.js registering bug
|
||||
//Manually registering gwf2
|
||||
httpPost = new HttpPost("http://172.17.0.17:8181/gateways/register");
|
||||
httpPost.setHeader("Accept", "application/json");
|
||||
httpPost.setHeader("Content-type", "application/json");
|
||||
inputJson = "{\n" +
|
||||
" \"Name\": \"gwf2\",\n" +
|
||||
" \"PoC\": \"http://10.0.2.100:8282\"\n" +
|
||||
"}";
|
||||
stringEntity = new StringEntity(inputJson);
|
||||
httpPost.setEntity(stringEntity);
|
||||
httpclient.execute(httpPost);
|
||||
//Manually registering gwf3
|
||||
httpPost = new HttpPost("http://172.17.0.17:8181/gateways/register");
|
||||
httpPost.setHeader("Accept", "application/json");
|
||||
httpPost.setHeader("Content-type", "application/json");
|
||||
inputJson = "{\n" +
|
||||
" \"Name\": \"gwf3\",\n" +
|
||||
" \"PoC\": \"http://10.0.3.100:8282\"\n" +
|
||||
"}";
|
||||
stringEntity = new StringEntity(inputJson);
|
||||
httpPost.setEntity(stringEntity);
|
||||
httpclient.execute(httpPost);
|
||||
}
|
||||
//}
|
||||
return ip;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,11 @@ class Main {
|
|||
|
||||
public static void main(String[] args) throws Exception {
|
||||
Logger.getRootLogger().setLevel(Level.ERROR);
|
||||
|
||||
|
||||
if(args.length > 1){
|
||||
//Possibility to define threshold when launching the jar file
|
||||
Knowledge.gw_lat_threshold = Double.parseDouble(args[0]);
|
||||
}
|
||||
|
||||
shared_knowledge.start();
|
||||
Thread.sleep(3000);
|
||||
|
|
|
@ -44,7 +44,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||
class Monitor {
|
||||
private static List<String> symptom = Arrays.asList("N/A", "NOK", "OK");
|
||||
private static final int period = 2000;
|
||||
private static double i = 0;
|
||||
static int period2 = 2000;
|
||||
public static double i = 0;
|
||||
public String gw_current_SYMP = "N/A";
|
||||
|
||||
void start() {
|
||||
|
@ -59,9 +60,8 @@ class Monitor {
|
|||
private void symptom_generator() {
|
||||
while (Main.run)
|
||||
try {
|
||||
Thread.sleep(period * 5);
|
||||
Thread.sleep(period);
|
||||
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++) {
|
||||
|
@ -93,10 +93,10 @@ class Monitor {
|
|||
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());
|
||||
Thread.sleep(period2);
|
||||
Main.shared_knowledge.insert_in_tab(new java.sql.Timestamp(new java.util.Date().getTime()), get_data());
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
//e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -124,8 +124,7 @@ class Monitor {
|
|||
}
|
||||
|
||||
private double get_fake_data() {
|
||||
//return new Random().nextInt();
|
||||
return i += 10;
|
||||
return i += 5;
|
||||
}
|
||||
|
||||
//ARIMA-based Forecasting
|
||||
|
|
|
@ -20,15 +20,21 @@ import java.util.List;
|
|||
|
||||
@SuppressWarnings({"SynchronizeOnNonFinalField"})
|
||||
class Plan {
|
||||
private static int i;
|
||||
public static int i;
|
||||
public String gw_PLAN = "";
|
||||
|
||||
void start() {
|
||||
Main.logger(this.getClass().getSimpleName(), "Start Planning");
|
||||
|
||||
while (Main.run) {
|
||||
////////////////////////////////
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
////////////////////////////////
|
||||
String current_rfc = get_rfc();
|
||||
//Main.logger(this.getClass().getSimpleName(), "Received RFC : " + current_rfc);
|
||||
update_plan(plan_generator(current_rfc));
|
||||
|
||||
}
|
||||
|
|
|
@ -29,30 +29,6 @@ class SDNCtrlAPI {
|
|||
BufferedReader br;
|
||||
StringBuffer result;
|
||||
|
||||
//Fixing script gateway.js registering bug
|
||||
//Manually registering gwf2
|
||||
/*httpPost = new HttpPost("http://172.17.0.17:8181/gateways/register");
|
||||
httpPost.setHeader("Accept", "application/json");
|
||||
httpPost.setHeader("Content-type", "application/json");
|
||||
inputJson = "{\n" +
|
||||
" \"Name\": \"gwf2\",\n" +
|
||||
" \"PoC\": \"http://10.0.2.100:8282\"\n" +
|
||||
"}";
|
||||
stringEntity = new StringEntity(inputJson);
|
||||
httpPost.setEntity(stringEntity);
|
||||
httpclient.execute(httpPost);
|
||||
//Manually registering gwf3
|
||||
httpPost = new HttpPost("http://172.17.0.17:8181/gateways/register");
|
||||
httpPost.setHeader("Accept", "application/json");
|
||||
httpPost.setHeader("Content-type", "application/json");
|
||||
inputJson = "{\n" +
|
||||
" \"Name\": \"gwf3\",\n" +
|
||||
" \"PoC\": \"http://10.0.3.100:8282\"\n" +
|
||||
"}";
|
||||
stringEntity = new StringEntity(inputJson);
|
||||
httpPost.setEntity(stringEntity);
|
||||
httpclient.execute(httpPost);*/
|
||||
|
||||
|
||||
//On s3: Redirect traffic from gwf2 to gwi2 through s4
|
||||
httpPost = new HttpPost("http://127.0.0.1:8080/stats/flowentry/add");
|
||||
|
@ -227,10 +203,73 @@ class SDNCtrlAPI {
|
|||
return status;
|
||||
}
|
||||
|
||||
String remove_less_important_traffic(String importantsrcip) {
|
||||
String remove_less_important_traffic(String importantsrcip) throws ClientProtocolException, IOException{
|
||||
String status = "OK";
|
||||
|
||||
CloseableHttpClient httpclient = HttpClients.createDefault();
|
||||
HttpPost httpPost;
|
||||
String match, actions, inputJson, line;
|
||||
StringEntity stringEntity;
|
||||
HttpResponse response;
|
||||
BufferedReader br;
|
||||
StringBuffer result;
|
||||
|
||||
Main.logger(this.getClass().getSimpleName(), "importantsrcip = " + importantsrcip);
|
||||
//TODO
|
||||
|
||||
httpPost = new HttpPost("http://127.0.0.1:8080/stats/flowentry/add");
|
||||
httpPost.setHeader("Accept", "application/json");
|
||||
httpPost.setHeader("Content-type", "application/json");//vnfinfos.get("image")
|
||||
match = "{\n" +
|
||||
" \"ipv4_dst\": \"10.2.2.1\",\n" +
|
||||
" \"eth_type\": 2048,\n" +
|
||||
" \"ipv4_src\": \""+importantsrcip+"\"\n" +
|
||||
"}";
|
||||
actions = "[\n" +
|
||||
" {\"type\": \"OUTPUT\", \"port\":1} \n" +
|
||||
"]";
|
||||
inputJson = "{\n" +
|
||||
" \"dpid\": 3,\n" +
|
||||
" \"priority\": 3,\n" +
|
||||
" \"match\": "+match+",\n" +
|
||||
" \"actions\": "+actions+"\n" +
|
||||
"}";
|
||||
stringEntity = new StringEntity(inputJson);
|
||||
httpPost.setEntity(stringEntity);
|
||||
response = httpclient.execute(httpPost);
|
||||
br = new BufferedReader(new InputStreamReader((response.getEntity().getContent())));
|
||||
if (response.getStatusLine().getStatusCode() != 200) {
|
||||
throw new RuntimeException("Failed : HTTP error code : " + response.getStatusLine().getStatusCode());
|
||||
}
|
||||
result = new StringBuffer();
|
||||
line = "";
|
||||
while ((line = br.readLine()) != null) {
|
||||
System.out.println("Response : \n" + result.append(line));
|
||||
}
|
||||
|
||||
httpPost = new HttpPost("http://127.0.0.1:8080/stats/flowentry/add");
|
||||
httpPost.setHeader("Accept", "application/json");
|
||||
httpPost.setHeader("Content-type", "application/json");//vnfinfos.get("image")
|
||||
match = "{\n" +
|
||||
" \"ipv4_dst\": \"10.2.2.1\",\n" +
|
||||
" \"eth_type\": 2048\n" +
|
||||
"}";
|
||||
inputJson = "{\n" +
|
||||
" \"dpid\": 3,\n" +
|
||||
" \"priority\": 2,\n" +
|
||||
" \"match\": "+match+"\n" +
|
||||
"}";
|
||||
stringEntity = new StringEntity(inputJson);
|
||||
httpPost.setEntity(stringEntity);
|
||||
response = httpclient.execute(httpPost);
|
||||
br = new BufferedReader(new InputStreamReader((response.getEntity().getContent())));
|
||||
if (response.getStatusLine().getStatusCode() != 200) {
|
||||
throw new RuntimeException("Failed : HTTP error code : " + response.getStatusLine().getStatusCode());
|
||||
}
|
||||
result = new StringBuffer();
|
||||
line = "";
|
||||
while ((line = br.readLine()) != null) {
|
||||
System.out.println("Response : \n" + result.append(line));
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
|
|
@ -27,8 +27,34 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||
|
||||
public class GctrlApplication {
|
||||
|
||||
public static void main(String[] args) throws ClientProtocolException, IOException{
|
||||
static int x = 0;
|
||||
static int y = 0;
|
||||
static int p = 2000;
|
||||
|
||||
public static void main(String[] args) throws ClientProtocolException, IOException, InterruptedException{
|
||||
while(true){
|
||||
String[] workflow = {"UC1","UC2","UC3"};
|
||||
for (String w : workflow) {
|
||||
switch (w) {
|
||||
case "UC1":
|
||||
if(x==0){
|
||||
x=1;
|
||||
System.out.println("Okay1 "+x);}
|
||||
break;
|
||||
case "UC2":
|
||||
if(y==0){
|
||||
y=1;
|
||||
System.out.println("Okay2 "+y);p=5000;}
|
||||
break;
|
||||
case "UC3":
|
||||
System.out.println("Okay3");
|
||||
break;
|
||||
}
|
||||
}
|
||||
Thread.sleep(p);
|
||||
continue;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
BIN
gctrl-spring/jars/gctrl_fake_data.jar
Normal file
BIN
gctrl-spring/jars/gctrl_fake_data.jar
Normal file
Binary file not shown.
BIN
gctrl-spring/jars/gctrl_real_data.jar
Normal file
BIN
gctrl-spring/jars/gctrl_real_data.jar
Normal file
Binary file not shown.
Loading…
Reference in a new issue