aboutsummaryrefslogtreecommitdiffstats
path: root/restconf-client/provider/src
diff options
context:
space:
mode:
authorSmokowski, Kevin (ks6305) <kevin.smokowski@att.com>2019-05-17 21:09:28 +0000
committerKevin Smokowski <kevin.smokowski@att.com>2019-05-29 15:43:52 +0000
commita7430938d2b83b6fe9b03360ff54206fd1259885 (patch)
tree82c935174fb03088f4a096ea215568833682aa2a /restconf-client/provider/src
parentb9ee871047eadd4c151adeeba97265431c8da616 (diff)
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) <kevin.smokowski@att.com>
Diffstat (limited to 'restconf-client/provider/src')
-rw-r--r--restconf-client/provider/src/main/java/org/onap/ccsdk/sli/plugins/restconfapicall/RestconfApiCallNode.java57
1 files changed, 1 insertions, 56 deletions
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<String, String> 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<String, String> 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) {
@@ -403,31 +373,6 @@ public class RestconfApiCallNode implements SvcLogicJavaPlugin {
}
/**
- * 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<String, String> 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.
*