From a7430938d2b83b6fe9b03360ff54206fd1259885 Mon Sep 17 00:00:00 2001 From: "Smokowski, Kevin (ks6305)" Date: Fri, 17 May 2019 21:09:28 +0000 Subject: implement generic retry and partners in restapicallnode implement generic retry and partners in restapicallnode Change-Id: I436622dda5a5a83b029c935b929f43e05d37a2a0 Issue-ID: CCSDK-1343 Signed-off-by: Smokowski, Kevin (ks6305) --- .../restconfapicall/RestconfApiCallNode.java | 57 +--------------------- 1 file changed, 1 insertion(+), 56 deletions(-) (limited to 'restconf-client') diff --git a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java index ac0897e8..620df282 100644 --- a/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java +++ b/restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java @@ -46,8 +46,6 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin; import org.onap.ccsdk.sli.plugins.restapicall.Format; import org.onap.ccsdk.sli.plugins.restapicall.HttpResponse; import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode; -import org.onap.ccsdk.sli.plugins.restapicall.RetryException; -import org.onap.ccsdk.sli.plugins.restapicall.RetryPolicy; import org.onap.ccsdk.sli.plugins.restapicall.XmlParser; import org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatSerializer; import org.onap.ccsdk.sli.plugins.yangserializers.dfserializer.DataFormatSerializerContext; @@ -165,14 +163,9 @@ public class RestconfApiCallNode implements SvcLogicJavaPlugin { public void sendRequest(Map paramMap, SvcLogicContext ctx, Integer retryCount) throws SvcLogicException { RestapiCallNode rest = getRestapiCallNode(); - RetryPolicy retryPolicy = null; HttpResponse r = new HttpResponse(); try { YangParameters p = getYangParameters(paramMap); - if (p.partner != null) { - retryPolicy = rest.getRetryPolicyStore() - .getRetryPolicy(p.partner); - } String pp = p.responsePrefix != null ? p.responsePrefix + '.' : ""; Map props = new HashMap<>((Map)ctx.toProperties()); @@ -215,30 +208,7 @@ public class RestconfApiCallNode implements SvcLogicJavaPlugin { log.error(REQ_ERR + e.getMessage(), e); String prefix = parseParam(paramMap, RES_PRE, false, null); - if (retryPolicy == null || !shouldRetry) { - setFailureResponseStatus(ctx, prefix, e.getMessage()); - } else { - if (retryCount == null) { - retryCount = 0; - } - log.debug(format(ATTEMPTS_MSG, retryCount, - retryPolicy.getMaximumRetries())); - try { - retryCount = retryCount + 1; - if (retryCount < retryPolicy.getMaximumRetries() + 1) { - setRetryUri(paramMap, retryPolicy); - log.debug(format(RETRY_COUNT, retryCount, retryPolicy - .getMaximumRetries())); - sendRequest(paramMap, ctx, retryCount); - } else { - log.debug(MAX_RETRY_ERR); - setFailureResponseStatus(ctx, prefix, e.getMessage()); - } - } catch (Exception ex) { - log.error(NO_MORE_RETRY, ex); - setFailureResponseStatus(ctx, prefix, RETRY_FAIL); - } - } + setFailureResponseStatus(ctx, prefix, e.getMessage()); } if (r != null && r.code >= 300) { @@ -402,31 +372,6 @@ public class RestconfApiCallNode implements SvcLogicJavaPlugin { ctx.setAttribute(prefix + RES_MSG, res.message); } - /** - * Sets the retry URI to the param map from the retry policies different - * host. - * - * @param paramMap parameter map - * @param retryPolicy retry policy - * @throws URISyntaxException when new URI creation fails - * @throws RetryException when retry policy cannot give another host - */ - private void setRetryUri(Map paramMap, - RetryPolicy retryPolicy) - throws URISyntaxException, RetryException { - URI uri = new URI(paramMap.get(REST_API_URL)); - String hostName = uri.getHost(); - String retryString = retryPolicy.getNextHostName(uri.toString()); - - URI uriTwo = new URI(retryString); - URI retryUri = UriBuilder.fromUri(uri).host(uriTwo.getHost()).port( - uriTwo.getPort()).scheme(uriTwo.getScheme()).build(); - - paramMap.put(REST_API_URL, retryUri.toString()); - log.debug(UPDATED_URL + retryUri.toString()); - log.debug(format(COMM_FAIL, hostName, retryString)); - } - /** * Updates request message for JSON and XML data format, when the HTTP * method points it as PUT or PATCH. -- cgit 1.2.3-korg