Fix priorities of our rules higher than ARP.
Add exception handling to REST calls. Change-Id: I1ed17eaf9b87bc9b54a32bc08c7afb17027dfaa4
Showing
2 changed files
with
20 additions
and
9 deletions
... | @@ -70,7 +70,7 @@ public class CordFabricManager implements FabricService { | ... | @@ -70,7 +70,7 @@ public class CordFabricManager implements FabricService { |
70 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 70 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
71 | protected FlowObjectiveService flowObjectiveService; | 71 | protected FlowObjectiveService flowObjectiveService; |
72 | 72 | ||
73 | - private static final int PRIORITY = 1000; | 73 | + private static final int PRIORITY = 50000; |
74 | 74 | ||
75 | private short openflowPort = 6633; | 75 | private short openflowPort = 6633; |
76 | 76 | ... | ... |
... | @@ -18,6 +18,7 @@ package org.onosproject.xosintegration; | ... | @@ -18,6 +18,7 @@ package org.onosproject.xosintegration; |
18 | import com.eclipsesource.json.JsonArray; | 18 | import com.eclipsesource.json.JsonArray; |
19 | import com.eclipsesource.json.JsonObject; | 19 | import com.eclipsesource.json.JsonObject; |
20 | import com.sun.jersey.api.client.Client; | 20 | import com.sun.jersey.api.client.Client; |
21 | +import com.sun.jersey.api.client.ClientHandlerException; | ||
21 | import com.sun.jersey.api.client.ClientResponse; | 22 | import com.sun.jersey.api.client.ClientResponse; |
22 | import com.sun.jersey.api.client.WebResource; | 23 | import com.sun.jersey.api.client.WebResource; |
23 | import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter; | 24 | import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter; |
... | @@ -78,6 +79,7 @@ public class OnosXOSIntegrationManager implements VoltTenantService { | ... | @@ -78,6 +79,7 @@ public class OnosXOSIntegrationManager implements VoltTenantService { |
78 | private static final String XOS_TENANT_BASE_URI = "/xoslib/volttenant/"; | 79 | private static final String XOS_TENANT_BASE_URI = "/xoslib/volttenant/"; |
79 | private static final int TEST_XOS_PROVIDER_SERVICE = 1; | 80 | private static final int TEST_XOS_PROVIDER_SERVICE = 1; |
80 | 81 | ||
82 | + private static final int PRIORITY = 50000; | ||
81 | private static final DeviceId FABRIC_DEVICE_ID = DeviceId.deviceId("of:5e3e486e73000187"); | 83 | private static final DeviceId FABRIC_DEVICE_ID = DeviceId.deviceId("of:5e3e486e73000187"); |
82 | private static final PortNumber FABRIC_OLT_CONNECT_POINT = PortNumber.portNumber(2); | 84 | private static final PortNumber FABRIC_OLT_CONNECT_POINT = PortNumber.portNumber(2); |
83 | private static final PortNumber FABRIC_VCPE_CONNECT_POINT = PortNumber.portNumber(3); | 85 | private static final PortNumber FABRIC_VCPE_CONNECT_POINT = PortNumber.portNumber(3); |
... | @@ -232,7 +234,14 @@ public class OnosXOSIntegrationManager implements VoltTenantService { | ... | @@ -232,7 +234,14 @@ public class OnosXOSIntegrationManager implements VoltTenantService { |
232 | */ | 234 | */ |
233 | private void postRest(String json) { | 235 | private void postRest(String json) { |
234 | WebResource.Builder builder = getClientBuilder(); | 236 | WebResource.Builder builder = getClientBuilder(); |
235 | - ClientResponse response = builder.post(ClientResponse.class, json); | 237 | + ClientResponse response; |
238 | + | ||
239 | + try { | ||
240 | + response = builder.post(ClientResponse.class, json); | ||
241 | + } catch (ClientHandlerException e) { | ||
242 | + log.warn("Unable to contact REST server: {}", e.getMessage()); | ||
243 | + return; | ||
244 | + } | ||
236 | 245 | ||
237 | if (response.getStatus() != HTTP_CREATED) { | 246 | if (response.getStatus() != HTTP_CREATED) { |
238 | log.info("REST POST request returned error code {}", | 247 | log.info("REST POST request returned error code {}", |
... | @@ -340,7 +349,7 @@ public class OnosXOSIntegrationManager implements VoltTenantService { | ... | @@ -340,7 +349,7 @@ public class OnosXOSIntegrationManager implements VoltTenantService { |
340 | 349 | ||
341 | ForwardingObjective forwardToFabric = DefaultForwardingObjective.builder() | 350 | ForwardingObjective forwardToFabric = DefaultForwardingObjective.builder() |
342 | .withFlag(ForwardingObjective.Flag.VERSATILE) | 351 | .withFlag(ForwardingObjective.Flag.VERSATILE) |
343 | - .withPriority(1000) | 352 | + .withPriority(PRIORITY) |
344 | .makePermanent() | 353 | .makePermanent() |
345 | .fromApp(appId) | 354 | .fromApp(appId) |
346 | .withSelector(fromGateway) | 355 | .withSelector(fromGateway) |
... | @@ -349,7 +358,7 @@ public class OnosXOSIntegrationManager implements VoltTenantService { | ... | @@ -349,7 +358,7 @@ public class OnosXOSIntegrationManager implements VoltTenantService { |
349 | 358 | ||
350 | ForwardingObjective forwardToGateway = DefaultForwardingObjective.builder() | 359 | ForwardingObjective forwardToGateway = DefaultForwardingObjective.builder() |
351 | .withFlag(ForwardingObjective.Flag.VERSATILE) | 360 | .withFlag(ForwardingObjective.Flag.VERSATILE) |
352 | - .withPriority(1000) | 361 | + .withPriority(PRIORITY) |
353 | .makePermanent() | 362 | .makePermanent() |
354 | .fromApp(appId) | 363 | .fromApp(appId) |
355 | .withSelector(fromFabric) | 364 | .withSelector(fromFabric) |
... | @@ -371,14 +380,16 @@ public class OnosXOSIntegrationManager implements VoltTenantService { | ... | @@ -371,14 +380,16 @@ public class OnosXOSIntegrationManager implements VoltTenantService { |
371 | String baseUrl = "http://" + FABRIC_CONTROLLER_ADDRESS + ":" | 380 | String baseUrl = "http://" + FABRIC_CONTROLLER_ADDRESS + ":" |
372 | + Integer.toString(FABRIC_SERVER_PORT); | 381 | + Integer.toString(FABRIC_SERVER_PORT); |
373 | Client client = Client.create(); | 382 | Client client = Client.create(); |
374 | - client.addFilter(new HTTPBasicAuthFilter("padmin@vicci.org", "letmein")); | 383 | + WebResource resource = client.resource(baseUrl + FABRIC_BASE_URI); |
375 | - WebResource resource = client.resource(baseUrl | ||
376 | - + FABRIC_BASE_URI); | ||
377 | WebResource.Builder builder = resource.accept(JSON_UTF_8.toString()) | 384 | WebResource.Builder builder = resource.accept(JSON_UTF_8.toString()) |
378 | .type(JSON_UTF_8.toString()); | 385 | .type(JSON_UTF_8.toString()); |
379 | 386 | ||
380 | - ClientResponse response = builder.post(ClientResponse.class, json); | 387 | + try { |
381 | - | 388 | + builder.post(ClientResponse.class, json); |
389 | + } catch (ClientHandlerException e) { | ||
390 | + log.warn("Unable to contact fabric REST server:", e.getMessage()); | ||
391 | + return; | ||
392 | + } | ||
382 | } | 393 | } |
383 | 394 | ||
384 | /** | 395 | /** | ... | ... |
-
Please register or login to post a comment