jars added and gctrl update
This commit is contained in:
parent
fd3fe273f4
commit
8a1b169298
11 changed files with 166 additions and 88 deletions
|
@ -23,6 +23,14 @@ class Analyze {
|
||||||
|
|
||||||
while (Main.run) {
|
while (Main.run) {
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
try {
|
||||||
|
Thread.sleep(2000);
|
||||||
|
} catch (InterruptedException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
String current_symptom = get_symptom();
|
String current_symptom = get_symptom();
|
||||||
//Main.logger(this.getClass().getSimpleName(), "Received Symptom : " + current_symptom);
|
//Main.logger(this.getClass().getSimpleName(), "Received Symptom : " + current_symptom);
|
||||||
|
|
||||||
|
|
|
@ -19,12 +19,25 @@ class Execute {
|
||||||
private static List<String> workflow_lists;
|
private static List<String> workflow_lists;
|
||||||
private static final MANOAPI manoapi = new MANOAPI();
|
private static final MANOAPI manoapi = new MANOAPI();
|
||||||
private static final SDNCtrlAPI sdnctlrapi = new SDNCtrlAPI();
|
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 {
|
void start() throws InterruptedException {
|
||||||
Main.logger(this.getClass().getSimpleName(), "Start Execution");
|
Main.logger(this.getClass().getSimpleName(), "Start Execution");
|
||||||
workflow_lists = Main.shared_knowledge.get_worklow_lists();
|
workflow_lists = Main.shared_knowledge.get_worklow_lists();
|
||||||
|
|
||||||
while (Main.run) {
|
while (Main.run) {
|
||||||
|
////////////////////////////////
|
||||||
|
try {
|
||||||
|
Thread.sleep(period);
|
||||||
|
//period = 0;
|
||||||
|
} catch (InterruptedException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
////////////////////////////////
|
||||||
String current_plan = get_plan();
|
String current_plan = get_plan();
|
||||||
|
|
||||||
// Main.logger(this.getClass().getSimpleName(), "Received Plan : " + current_plan);
|
// Main.logger(this.getClass().getSimpleName(), "Received Plan : " + current_plan);
|
||||||
|
@ -42,39 +55,48 @@ class Execute {
|
||||||
Main.logger(this.getClass().getSimpleName(), "Nothing to do");
|
Main.logger(this.getClass().getSimpleName(), "Nothing to do");
|
||||||
break;
|
break;
|
||||||
case "UC2"://////
|
case "UC2"://////
|
||||||
Main.logger(this.getClass().getSimpleName(), "Deploying GW");
|
if (UC2_already_done == 0){
|
||||||
String newdestip = manoapi.deploy_gw(Main.shared_knowledge.getGwinfo());
|
UC2_already_done = 1;
|
||||||
Main.shared_knowledge.setNewdestip(newdestip);
|
System.out.println("Now .... "+UC2_already_done);
|
||||||
Main.shared_knowledge.setOldgwip(Main.shared_knowledge.getOlddestip());
|
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;
|
break;
|
||||||
case "UC3"://///
|
case "UC3"://///
|
||||||
Main.logger(this.getClass().getSimpleName(), "Redirecting Traffic");
|
String status;
|
||||||
String status = sdnctlrapi.redirect_traffic(Main.shared_knowledge.getOlddestip(), Main.shared_knowledge.getNewdestip());
|
if (UC3_already_done == 0){
|
||||||
Main.logger(this.getClass().getSimpleName(), status);
|
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;
|
break;
|
||||||
case "UC4":
|
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());
|
List<String> newgwsip = manoapi.deploy_multi_gws_and_lb(Main.shared_knowledge.getGwsinfo());
|
||||||
Main.shared_knowledge.setLbip(newgwsip.get(0));
|
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;
|
break;
|
||||||
case "UC5":
|
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());
|
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;
|
break;
|
||||||
case "UC6":
|
case "UC6":
|
||||||
Main.logger(this.getClass().getSimpleName(), "Removing less important traffic");
|
Main.logger(this.getClass().getSimpleName(), "Removing less important traffic");
|
||||||
status = sdnctlrapi.remove_less_important_traffic(Main.shared_knowledge.getImportantsrcip());
|
status = sdnctlrapi.remove_less_important_traffic(Main.shared_knowledge.getImportantsrcip());
|
||||||
Main.logger(this.getClass().getSimpleName(), status);
|
Main.logger(this.getClass().getSimpleName(), status);
|
||||||
|
//Plan.i = -1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
} catch (ClientProtocolException e) {
|
} catch (ClientProtocolException e) {
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
Thread.sleep(2000);
|
Thread.sleep(2000);
|
||||||
|
|
|
@ -29,9 +29,10 @@ class Knowledge {
|
||||||
private static final String DB_PASSWORD = "";
|
private static final String DB_PASSWORD = "";
|
||||||
|
|
||||||
static final int moving_wind = 10;
|
static final int moving_wind = 10;
|
||||||
static final int horizon = 3;
|
static final int horizon = 5;
|
||||||
static final String gw = "GW_I";
|
static final String gw = "GWI1";
|
||||||
static final double gw_lat_threshold = 70;
|
//static final double gw_lat_threshold = 80;
|
||||||
|
static double gw_lat_threshold = 70;
|
||||||
|
|
||||||
/*TODO : edit symptom, rfc, workflow_lists, plan*/
|
/*TODO : edit symptom, rfc, workflow_lists, plan*/
|
||||||
private static final List<String> symptom = Arrays.asList("N/A", "NOK", "OK");
|
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 Map<String, String> gwinfo = new HashMap<>();
|
||||||
private final List<Map<String, String>> gwsinfo = new ArrayList<>();
|
private final List<Map<String, String>> gwsinfo = new ArrayList<>();
|
||||||
private final String olddestip = "10.2.2.1";
|
private final String olddestip = "10.2.2.1";
|
||||||
private String newdestip;
|
private String newdestip = "10.2.2.2";
|
||||||
private String oldgwip;
|
private String oldgwip;
|
||||||
private String lbip;
|
private String lbip;
|
||||||
private List<String> newgwsip;
|
private List<String> newgwsip;
|
||||||
private final String importantsrcip = "192.168.0.1";
|
private final String importantsrcip = "10.0.1.100";
|
||||||
|
|
||||||
void start() throws Exception {
|
void start() throws Exception {
|
||||||
// delete the H2 database named 'test' in the user home directory
|
// 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)
|
//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();
|
httpclient = HttpClients.createDefault();
|
||||||
httpPut = new HttpPut("http://127.0.0.1:5001/restapi/compute/dc1/"+vnfinfos.get("name"));
|
httpPut = new HttpPut("http://127.0.0.1:5001/restapi/compute/dc1/"+vnfinfos.get("name"));
|
||||||
httpPut.setHeader("Accept", "application/json");
|
httpPut.setHeader("Accept", "application/json");
|
||||||
httpPut.setHeader("Content-type", "application/json");//vnfinfos.get("image")
|
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" +
|
inputJson = "{\n" +
|
||||||
" \"image\": \""+vnfinfos.get("image")+"\",\n" +
|
" \"image\": \""+vnfinfos.get("image")+"\",\n" +
|
||||||
" \"network\": \"(id=input,ip="+ip+"/8)\"\n" +
|
" \"network\": \"(id=input,ip="+ip+"/8)\"\n" +
|
||||||
|
@ -68,38 +64,15 @@ class MANOAPI {
|
||||||
response = httpclient.execute(httpPut);
|
response = httpclient.execute(httpPut);
|
||||||
br = new BufferedReader(new InputStreamReader((response.getEntity().getContent())));
|
br = new BufferedReader(new InputStreamReader((response.getEntity().getContent())));
|
||||||
if (response.getStatusLine().getStatusCode() != 200) {
|
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();
|
result = new StringBuffer();
|
||||||
line = "";
|
line = "";
|
||||||
while ((line = br.readLine()) != null) {
|
while ((line = br.readLine()) != null) {
|
||||||
System.out.println("Response : \n" + result.append(line));
|
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;
|
return ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,10 @@ class Main {
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
Logger.getRootLogger().setLevel(Level.ERROR);
|
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();
|
shared_knowledge.start();
|
||||||
Thread.sleep(3000);
|
Thread.sleep(3000);
|
||||||
|
|
|
@ -44,7 +44,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
class Monitor {
|
class Monitor {
|
||||||
private static List<String> symptom = Arrays.asList("N/A", "NOK", "OK");
|
private static List<String> symptom = Arrays.asList("N/A", "NOK", "OK");
|
||||||
private static final int period = 2000;
|
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";
|
public String gw_current_SYMP = "N/A";
|
||||||
|
|
||||||
void start() {
|
void start() {
|
||||||
|
@ -59,9 +60,8 @@ class Monitor {
|
||||||
private void symptom_generator() {
|
private void symptom_generator() {
|
||||||
while (Main.run)
|
while (Main.run)
|
||||||
try {
|
try {
|
||||||
Thread.sleep(period * 5);
|
Thread.sleep(period);
|
||||||
ResultSet rs = Main.shared_knowledge.select_from_tab();
|
ResultSet rs = Main.shared_knowledge.select_from_tab();
|
||||||
//print_nice_rs(rs);
|
|
||||||
double[] prediction = predict_next_lat(rs);
|
double[] prediction = predict_next_lat(rs);
|
||||||
boolean isOk = true;
|
boolean isOk = true;
|
||||||
for (int j = 0; j < Knowledge.horizon; j++) {
|
for (int j = 0; j < Knowledge.horizon; j++) {
|
||||||
|
@ -93,10 +93,10 @@ class Monitor {
|
||||||
while (Main.run)
|
while (Main.run)
|
||||||
try {
|
try {
|
||||||
//TODO: Remove this
|
//TODO: Remove this
|
||||||
Thread.sleep(period);
|
Thread.sleep(period2);
|
||||||
Main.shared_knowledge.insert_in_tab(new java.sql.Timestamp(new java.util.Date().getTime()), get_fake_data());
|
Main.shared_knowledge.insert_in_tab(new java.sql.Timestamp(new java.util.Date().getTime()), get_data());
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
//e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -124,8 +124,7 @@ class Monitor {
|
||||||
}
|
}
|
||||||
|
|
||||||
private double get_fake_data() {
|
private double get_fake_data() {
|
||||||
//return new Random().nextInt();
|
return i += 5;
|
||||||
return i += 10;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//ARIMA-based Forecasting
|
//ARIMA-based Forecasting
|
||||||
|
|
|
@ -20,15 +20,21 @@ import java.util.List;
|
||||||
|
|
||||||
@SuppressWarnings({"SynchronizeOnNonFinalField"})
|
@SuppressWarnings({"SynchronizeOnNonFinalField"})
|
||||||
class Plan {
|
class Plan {
|
||||||
private static int i;
|
public static int i;
|
||||||
public String gw_PLAN = "";
|
public String gw_PLAN = "";
|
||||||
|
|
||||||
void start() {
|
void start() {
|
||||||
Main.logger(this.getClass().getSimpleName(), "Start Planning");
|
Main.logger(this.getClass().getSimpleName(), "Start Planning");
|
||||||
|
|
||||||
while (Main.run) {
|
while (Main.run) {
|
||||||
|
////////////////////////////////
|
||||||
|
try {
|
||||||
|
Thread.sleep(2000);
|
||||||
|
} catch (InterruptedException e1) {
|
||||||
|
e1.printStackTrace();
|
||||||
|
}
|
||||||
|
////////////////////////////////
|
||||||
String current_rfc = get_rfc();
|
String current_rfc = get_rfc();
|
||||||
//Main.logger(this.getClass().getSimpleName(), "Received RFC : " + current_rfc);
|
|
||||||
update_plan(plan_generator(current_rfc));
|
update_plan(plan_generator(current_rfc));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,30 +29,6 @@ class SDNCtrlAPI {
|
||||||
BufferedReader br;
|
BufferedReader br;
|
||||||
StringBuffer result;
|
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
|
//On s3: Redirect traffic from gwf2 to gwi2 through s4
|
||||||
httpPost = new HttpPost("http://127.0.0.1:8080/stats/flowentry/add");
|
httpPost = new HttpPost("http://127.0.0.1:8080/stats/flowentry/add");
|
||||||
|
@ -227,10 +203,73 @@ class SDNCtrlAPI {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
String remove_less_important_traffic(String importantsrcip) {
|
String remove_less_important_traffic(String importantsrcip) throws ClientProtocolException, IOException{
|
||||||
String status = "OK";
|
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);
|
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;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,34 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
public class GctrlApplication {
|
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