From 193317fa8b2da0439ad6e71b765cbd4b98097854 Mon Sep 17 00:00:00 2001 From: Viraj Salaka Date: Wed, 11 Oct 2023 22:42:31 +0530 Subject: [PATCH 1/7] Log each and every xds request and response to/from enforcer --- .../discovery/xds/enforcercallbacks/enforcer_callbacks.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/adapter/internal/discovery/xds/enforcercallbacks/enforcer_callbacks.go b/adapter/internal/discovery/xds/enforcercallbacks/enforcer_callbacks.go index e28fa54548..15b305a83b 100644 --- a/adapter/internal/discovery/xds/enforcercallbacks/enforcer_callbacks.go +++ b/adapter/internal/discovery/xds/enforcercallbacks/enforcer_callbacks.go @@ -53,11 +53,7 @@ func (cb *Callbacks) OnStreamClosed(id int64, node *core.Node) { // OnStreamRequest prints debug logs func (cb *Callbacks) OnStreamRequest(id int64, request *discovery.DiscoveryRequest) error { nodeIdentifier := common.GetNodeIdentifier(request) - if nodeQueueInstance.IsNewNode(nodeIdentifier) { - logger.LoggerEnforcerXdsCallbacks.Infof("stream request on stream id: %d, from node: %s, version: %s", - id, nodeIdentifier, request.VersionInfo) - } - logger.LoggerEnforcerXdsCallbacks.Debugf("stream request on stream id: %d, from node: %s, version: %s, for type: %s", + logger.LoggerEnforcerXdsCallbacks.Infof("stream request on stream id: %d, from node: %s, version: %s, for type: %s", id, nodeIdentifier, request.GetVersionInfo(), request.GetTypeUrl()) if request.ErrorDetail != nil { logger.LoggerEnforcerXdsCallbacks.Errorf("Stream request for type %s on stream id: %d Error: %s", request.GetTypeUrl(), @@ -82,7 +78,7 @@ func (cb *Callbacks) OnStreamRequest(id int64, request *discovery.DiscoveryReque func (cb *Callbacks) OnStreamResponse(context context.Context, id int64, request *discovery.DiscoveryRequest, response *discovery.DiscoveryResponse) { nodeIdentifier := common.GetNodeIdentifier(request) - logger.LoggerEnforcerXdsCallbacks.Debugf("stream response on stream id: %d node: %s for type: %s version: %s", + logger.LoggerEnforcerXdsCallbacks.Infof("stream response on stream id: %d node: %s for type: %s version: %s", id, nodeIdentifier, request.GetTypeUrl(), response.GetVersionInfo()) } From 3de50c4f95022bdc3f4c4c1bd7e00feb5feb7f17 Mon Sep 17 00:00:00 2001 From: Viraj Salaka Date: Wed, 11 Oct 2023 22:47:56 +0530 Subject: [PATCH 2/7] Setup XDS max message size for each xds client stub --- .../connect/enforcer/discovery/ApiListDiscoveryClient.java | 3 ++- .../connect/enforcer/discovery/ApplicationDiscoveryClient.java | 3 ++- .../discovery/ApplicationKeyMappingDiscoveryClient.java | 3 ++- .../enforcer/discovery/ApplicationPolicyDiscoveryClient.java | 3 ++- .../enforcer/discovery/SubscriptionDiscoveryClient.java | 3 ++- .../enforcer/discovery/SubscriptionPolicyDiscoveryClient.java | 3 ++- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApiListDiscoveryClient.java b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApiListDiscoveryClient.java index 8f98d0e9f7..78cec4491a 100644 --- a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApiListDiscoveryClient.java +++ b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApiListDiscoveryClient.java @@ -122,7 +122,8 @@ public void run() { public void watchApiList() { // TODO: (Praminda) implement a deadline with retries - reqObserver = stub.streamApiList(new StreamObserver() { + int maxSize = Integer.parseInt(ConfigHolder.getInstance().getEnvVarConfig().getXdsMaxMsgSize()); + reqObserver = stub.withMaxInboundMessageSize(maxSize).streamApiList(new StreamObserver() { @Override public void onNext(DiscoveryResponse response) { logger.info("API list event received with version : " + response.getVersionInfo()); diff --git a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationDiscoveryClient.java b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationDiscoveryClient.java index 94ae990c0f..2d8fc402c0 100644 --- a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationDiscoveryClient.java +++ b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationDiscoveryClient.java @@ -123,7 +123,8 @@ public void run() { public void watchApplications() { // TODO: (Praminda) implement a deadline with retries - reqObserver = stub.streamApplications(new StreamObserver() { + int maxSize = Integer.parseInt(ConfigHolder.getInstance().getEnvVarConfig().getXdsMaxMsgSize()); + reqObserver = stub.withMaxInboundMessageSize(maxSize).streamApplications(new StreamObserver() { @Override public void onNext(DiscoveryResponse response) { logger.info("Application creation event received with version : " + response.getVersionInfo()); diff --git a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationKeyMappingDiscoveryClient.java b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationKeyMappingDiscoveryClient.java index 5a5963b906..41a62a499b 100644 --- a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationKeyMappingDiscoveryClient.java +++ b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationKeyMappingDiscoveryClient.java @@ -123,7 +123,8 @@ public void run() { public void watchApplicationKeyMappings() { // TODO: (Praminda) implement a deadline with retries - reqObserver = stub.streamApplicationKeyMappings(new StreamObserver() { + int maxSize = Integer.parseInt(ConfigHolder.getInstance().getEnvVarConfig().getXdsMaxMsgSize()); + reqObserver = stub.withMaxInboundMessageSize(maxSize).streamApplicationKeyMappings(new StreamObserver() { @Override public void onNext(DiscoveryResponse response) { logger.info("Application key generation event received with version : " + response.getVersionInfo()); diff --git a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationPolicyDiscoveryClient.java b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationPolicyDiscoveryClient.java index 8b81049639..803f44e6cd 100644 --- a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationPolicyDiscoveryClient.java +++ b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationPolicyDiscoveryClient.java @@ -123,7 +123,8 @@ public void run() { public void watchApplicationPolicies() { // TODO: (Praminda) implement a deadline with retries - reqObserver = stub.streamApplicationPolicies(new StreamObserver() { + int maxSize = Integer.parseInt(ConfigHolder.getInstance().getEnvVarConfig().getXdsMaxMsgSize()); + reqObserver = stub.withMaxInboundMessageSize(maxSize).streamApplicationPolicies(new StreamObserver() { @Override public void onNext(DiscoveryResponse response) { logger.info("Application policy event received with version : " + response.getVersionInfo()); diff --git a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/SubscriptionDiscoveryClient.java b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/SubscriptionDiscoveryClient.java index 8afb180678..435c792a81 100644 --- a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/SubscriptionDiscoveryClient.java +++ b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/SubscriptionDiscoveryClient.java @@ -122,7 +122,8 @@ public void run() { public void watchSubscriptions() { // TODO: (Praminda) implement a deadline with retries - reqObserver = stub.streamSubscriptions(new StreamObserver() { + int maxSize = Integer.parseInt(ConfigHolder.getInstance().getEnvVarConfig().getXdsMaxMsgSize()); + reqObserver = stub.withMaxInboundMessageSize(maxSize).streamSubscriptions(new StreamObserver() { @Override public void onNext(DiscoveryResponse response) { logger.info("Subscription event received with version : " + response.getVersionInfo()); diff --git a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/SubscriptionPolicyDiscoveryClient.java b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/SubscriptionPolicyDiscoveryClient.java index 660e906c20..eebb4d27e9 100644 --- a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/SubscriptionPolicyDiscoveryClient.java +++ b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/SubscriptionPolicyDiscoveryClient.java @@ -122,7 +122,8 @@ public void run() { public void watchSubscriptionPolicies() { // TODO: (Praminda) implement a deadline with retries - reqObserver = stub.streamSubscriptionPolicies(new StreamObserver<>() { + int maxSize = Integer.parseInt(ConfigHolder.getInstance().getEnvVarConfig().getXdsMaxMsgSize()); + reqObserver = stub.withMaxInboundMessageSize(maxSize).streamSubscriptionPolicies(new StreamObserver<>() { @Override public void onNext(DiscoveryResponse response) { logger.info("Subscription policy event received with version : " + response.getVersionInfo()); From 54ff5cd01080c18f810533ac98e1fb1f97ece9c8 Mon Sep 17 00:00:00 2001 From: Viraj Salaka Date: Wed, 11 Oct 2023 22:50:51 +0530 Subject: [PATCH 3/7] Disable apiListDiscoveryClient as it is not set as per current adapter implementation. Purpose is to reduce the watches on unnecessary xds resources --- .../enforcer/subscription/SubscriptionDataStoreImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/subscription/SubscriptionDataStoreImpl.java b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/subscription/SubscriptionDataStoreImpl.java index 272e512f49..23e378d142 100644 --- a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/subscription/SubscriptionDataStoreImpl.java +++ b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/subscription/SubscriptionDataStoreImpl.java @@ -151,7 +151,8 @@ public ApiPolicy getApiPolicyByName(String policyName) { private void initializeLoadingTasks() { SubscriptionDiscoveryClient.getInstance().watchSubscriptions(); ApplicationDiscoveryClient.getInstance().watchApplications(); - ApiListDiscoveryClient.getInstance().watchApiList(); + // Disabled API List discovery as it is not set as per current adapter implementation. +// ApiListDiscoveryClient.getInstance().watchApiList(); ApplicationPolicyDiscoveryClient.getInstance().watchApplicationPolicies(); SubscriptionPolicyDiscoveryClient.getInstance().watchSubscriptionPolicies(); ApplicationKeyMappingDiscoveryClient.getInstance().watchApplicationKeyMappings(); From 1d10875c24e7a88c162f3424749a6a8bc4db0bae Mon Sep 17 00:00:00 2001 From: Viraj Salaka Date: Wed, 11 Oct 2023 23:23:56 +0530 Subject: [PATCH 4/7] Fix Go Vet failure: loop variable url captured by func literal --- adapter/internal/eventhub/subscription.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/adapter/internal/eventhub/subscription.go b/adapter/internal/eventhub/subscription.go index 4b509538d0..7f25122c3c 100644 --- a/adapter/internal/eventhub/subscription.go +++ b/adapter/internal/eventhub/subscription.go @@ -131,7 +131,7 @@ func LoadSubscriptionData(configFile *config.Config, initialAPIUUIDListMap map[s } else { // Keep the iteration going on until a response is recieved. logger.LoggerSync.Errorf("Error occurred while fetching data from control plane: %v", data.Error) - go func(d response) { + go func(d response, endpoint string, responseType interface{}) { // Retry fetching from control plane after a configured time interval if conf.ControlPlane.RetryInterval == 0 { // Assign default retry interval @@ -140,8 +140,8 @@ func LoadSubscriptionData(configFile *config.Config, initialAPIUUIDListMap map[s logger.LoggerSync.Debugf("Time Duration for retrying: %v", conf.ControlPlane.RetryInterval*time.Second) time.Sleep(conf.ControlPlane.RetryInterval * time.Second) logger.LoggerSync.Infof("Retrying to fetch APIs from control plane. Time Duration for the next retry: %v", conf.ControlPlane.RetryInterval*time.Second) - go InvokeService(url.endpoint, url.responseType, nil, responseChannel, 0) - }(data) + go InvokeService(endpoint, responseType, nil, responseChannel, 0) + }(data, url.endpoint, url.responseType) } } } From 795cdc96be1dc6c898f57812af2313d26f4f80b4 Mon Sep 17 00:00:00 2001 From: Viraj Salaka Date: Thu, 12 Oct 2023 09:07:52 +0530 Subject: [PATCH 5/7] Fix checkstyle issues --- .../connect/enforcer/discovery/ApplicationDiscoveryClient.java | 3 ++- .../discovery/ApplicationKeyMappingDiscoveryClient.java | 3 ++- .../enforcer/discovery/ApplicationPolicyDiscoveryClient.java | 3 ++- .../enforcer/discovery/SubscriptionDiscoveryClient.java | 3 ++- .../enforcer/subscription/SubscriptionDataStoreImpl.java | 1 - 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationDiscoveryClient.java b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationDiscoveryClient.java index 2d8fc402c0..dd3ff2d7ff 100644 --- a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationDiscoveryClient.java +++ b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationDiscoveryClient.java @@ -124,7 +124,8 @@ public void run() { public void watchApplications() { // TODO: (Praminda) implement a deadline with retries int maxSize = Integer.parseInt(ConfigHolder.getInstance().getEnvVarConfig().getXdsMaxMsgSize()); - reqObserver = stub.withMaxInboundMessageSize(maxSize).streamApplications(new StreamObserver() { + reqObserver = stub.withMaxInboundMessageSize(maxSize) + .streamApplications(new StreamObserver() { @Override public void onNext(DiscoveryResponse response) { logger.info("Application creation event received with version : " + response.getVersionInfo()); diff --git a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationKeyMappingDiscoveryClient.java b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationKeyMappingDiscoveryClient.java index 41a62a499b..c16d56c38b 100644 --- a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationKeyMappingDiscoveryClient.java +++ b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationKeyMappingDiscoveryClient.java @@ -124,7 +124,8 @@ public void run() { public void watchApplicationKeyMappings() { // TODO: (Praminda) implement a deadline with retries int maxSize = Integer.parseInt(ConfigHolder.getInstance().getEnvVarConfig().getXdsMaxMsgSize()); - reqObserver = stub.withMaxInboundMessageSize(maxSize).streamApplicationKeyMappings(new StreamObserver() { + reqObserver = stub.withMaxInboundMessageSize(maxSize) + .streamApplicationKeyMappings(new StreamObserver() { @Override public void onNext(DiscoveryResponse response) { logger.info("Application key generation event received with version : " + response.getVersionInfo()); diff --git a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationPolicyDiscoveryClient.java b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationPolicyDiscoveryClient.java index 803f44e6cd..9ef5c85c05 100644 --- a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationPolicyDiscoveryClient.java +++ b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationPolicyDiscoveryClient.java @@ -124,7 +124,8 @@ public void run() { public void watchApplicationPolicies() { // TODO: (Praminda) implement a deadline with retries int maxSize = Integer.parseInt(ConfigHolder.getInstance().getEnvVarConfig().getXdsMaxMsgSize()); - reqObserver = stub.withMaxInboundMessageSize(maxSize).streamApplicationPolicies(new StreamObserver() { + reqObserver = stub.withMaxInboundMessageSize(maxSize) + .streamApplicationPolicies(new StreamObserver() { @Override public void onNext(DiscoveryResponse response) { logger.info("Application policy event received with version : " + response.getVersionInfo()); diff --git a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/SubscriptionDiscoveryClient.java b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/SubscriptionDiscoveryClient.java index 435c792a81..fbbc6d64f0 100644 --- a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/SubscriptionDiscoveryClient.java +++ b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/SubscriptionDiscoveryClient.java @@ -123,7 +123,8 @@ public void run() { public void watchSubscriptions() { // TODO: (Praminda) implement a deadline with retries int maxSize = Integer.parseInt(ConfigHolder.getInstance().getEnvVarConfig().getXdsMaxMsgSize()); - reqObserver = stub.withMaxInboundMessageSize(maxSize).streamSubscriptions(new StreamObserver() { + reqObserver = stub.withMaxInboundMessageSize(maxSize) + .streamSubscriptions(new StreamObserver() { @Override public void onNext(DiscoveryResponse response) { logger.info("Subscription event received with version : " + response.getVersionInfo()); diff --git a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/subscription/SubscriptionDataStoreImpl.java b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/subscription/SubscriptionDataStoreImpl.java index 23e378d142..3584d4c50d 100644 --- a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/subscription/SubscriptionDataStoreImpl.java +++ b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/subscription/SubscriptionDataStoreImpl.java @@ -23,7 +23,6 @@ import org.apache.logging.log4j.Logger; import org.wso2.choreo.connect.discovery.subscription.APIs; import org.wso2.choreo.connect.enforcer.constants.APIConstants; -import org.wso2.choreo.connect.enforcer.discovery.ApiListDiscoveryClient; import org.wso2.choreo.connect.enforcer.discovery.ApplicationDiscoveryClient; import org.wso2.choreo.connect.enforcer.discovery.ApplicationKeyMappingDiscoveryClient; import org.wso2.choreo.connect.enforcer.discovery.ApplicationPolicyDiscoveryClient; From 096f97276bbbb26917c50fe19f678f6ab717e26d Mon Sep 17 00:00:00 2001 From: Viraj Salaka Date: Fri, 13 Oct 2023 15:38:50 +0530 Subject: [PATCH 6/7] Print an error log if the the grpc message size exceeds 90% of the maximum size --- .../connect/enforcer/discovery/ApiDiscoveryClient.java | 7 ++++++- .../enforcer/discovery/ApplicationDiscoveryClient.java | 7 ++++++- .../discovery/ApplicationKeyMappingDiscoveryClient.java | 7 ++++++- .../discovery/ApplicationPolicyDiscoveryClient.java | 7 ++++++- .../enforcer/discovery/KeyManagerDiscoveryClient.java | 7 ++++++- .../enforcer/discovery/RevokedTokenDiscoveryClient.java | 7 ++++++- .../enforcer/discovery/SubscriptionDiscoveryClient.java | 7 ++++++- .../discovery/SubscriptionPolicyDiscoveryClient.java | 7 ++++++- .../enforcer/discovery/ThrottleDataDiscoveryClient.java | 7 ++++++- 9 files changed, 54 insertions(+), 9 deletions(-) diff --git a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApiDiscoveryClient.java b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApiDiscoveryClient.java index e10d53e58d..107159d8ea 100644 --- a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApiDiscoveryClient.java +++ b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApiDiscoveryClient.java @@ -123,7 +123,12 @@ public void watchApis() { reqObserver = stub.withMaxInboundMessageSize(maxSize).streamApis(new StreamObserver<>() { @Override public void onNext(DiscoveryResponse response) { - logger.info("API event received with version : " + response.getVersionInfo()); + logger.info("API event received with version : " + response.getVersionInfo() + + " and size(bytes) : " + response.getSerializedSize()); + if ((double) response.getSerializedSize() / maxSize > 0.90) { + logger.error("Current response size exceeds 90% of the maximum message size for the type : " + + response.getTypeUrl()); + } logger.debug("Received API discovery response " + response); XdsSchedulerManager.getInstance().stopAPIDiscoveryScheduling(); latestReceived = response; diff --git a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationDiscoveryClient.java b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationDiscoveryClient.java index dd3ff2d7ff..7773edfabd 100644 --- a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationDiscoveryClient.java +++ b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationDiscoveryClient.java @@ -128,7 +128,12 @@ public void watchApplications() { .streamApplications(new StreamObserver() { @Override public void onNext(DiscoveryResponse response) { - logger.info("Application creation event received with version : " + response.getVersionInfo()); + logger.info("Application creation event received with version : " + response.getVersionInfo() + + " and size(bytes) : " + response.getSerializedSize()); + if ((double) response.getSerializedSize() / maxSize > 0.90) { + logger.error("Current response size exceeds 90% of the maximum message size for the type : " + + response.getTypeUrl()); + } logger.debug("Received Application discovery response " + response); XdsSchedulerManager.getInstance().stopApplicationDiscoveryScheduling(); latestReceived = response; diff --git a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationKeyMappingDiscoveryClient.java b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationKeyMappingDiscoveryClient.java index c16d56c38b..67b305d8a6 100644 --- a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationKeyMappingDiscoveryClient.java +++ b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationKeyMappingDiscoveryClient.java @@ -128,7 +128,12 @@ public void watchApplicationKeyMappings() { .streamApplicationKeyMappings(new StreamObserver() { @Override public void onNext(DiscoveryResponse response) { - logger.info("Application key generation event received with version : " + response.getVersionInfo()); + logger.info("Application key generation event received with version : " + response.getVersionInfo() + + " and size(bytes) : " + response.getSerializedSize()); + if ((double) response.getSerializedSize() / maxSize > 0.90) { + logger.error("Current response size exceeds 90% of the maximum message size for the type : " + + response.getTypeUrl()); + } logger.debug("Received Application Key Mapping discovery response " + response); XdsSchedulerManager.getInstance().stopApplicationKeyMappingDiscoveryScheduling(); latestReceived = response; diff --git a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationPolicyDiscoveryClient.java b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationPolicyDiscoveryClient.java index 9ef5c85c05..d8c47cacf5 100644 --- a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationPolicyDiscoveryClient.java +++ b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationPolicyDiscoveryClient.java @@ -128,7 +128,12 @@ public void watchApplicationPolicies() { .streamApplicationPolicies(new StreamObserver() { @Override public void onNext(DiscoveryResponse response) { - logger.info("Application policy event received with version : " + response.getVersionInfo()); + logger.info("Application policy event received with version : " + response.getVersionInfo() + + " and size(bytes) : " + response.getSerializedSize()); + if ((double) response.getSerializedSize() / maxSize > 0.90) { + logger.error("Current response size exceeds 90% of the maximum message size for the type : " + + response.getTypeUrl()); + } logger.debug("Received Application Policy discovery response " + response); XdsSchedulerManager.getInstance().stopApplicationPolicyDiscoveryScheduling(); latestReceived = response; diff --git a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/KeyManagerDiscoveryClient.java b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/KeyManagerDiscoveryClient.java index a84b19e1e1..fc8084dc01 100644 --- a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/KeyManagerDiscoveryClient.java +++ b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/KeyManagerDiscoveryClient.java @@ -126,7 +126,12 @@ public void watchKeyManagers() { reqObserver = stub.withMaxInboundMessageSize(maxSize).streamKeyManagers(new StreamObserver<>() { @Override public void onNext(DiscoveryResponse response) { - logger.info("Key manager event received with version : " + response.getVersionInfo()); + logger.info("Key manager event received with version : " + response.getVersionInfo() + + " and size(bytes) : " + response.getSerializedSize()); + if ((double) response.getSerializedSize() / maxSize > 0.90) { + logger.error("Current response size exceeds 90% of the maximum message size for the type : " + + response.getTypeUrl()); + } logger.debug("Received KeyManagers discovery response " + response); XdsSchedulerManager.getInstance().stopKeyManagerDiscoveryScheduling(); latestReceived = response; diff --git a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/RevokedTokenDiscoveryClient.java b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/RevokedTokenDiscoveryClient.java index c5cdd0d927..4d44350aac 100644 --- a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/RevokedTokenDiscoveryClient.java +++ b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/RevokedTokenDiscoveryClient.java @@ -129,7 +129,12 @@ public void watchRevokedTokens() { reqObserver = stub.withMaxInboundMessageSize(maxSize).streamTokens(new StreamObserver<>() { @Override public void onNext(DiscoveryResponse response) { - logger.info("Revoked token event received with version : " + response.getVersionInfo()); + logger.info("Revoked token event received with version : " + response.getVersionInfo() + + " and size(bytes) : " + response.getSerializedSize()); + if ((double) response.getSerializedSize() / maxSize > 0.90) { + logger.error("Current response size exceeds 90% of the maximum message size for the type : " + + response.getTypeUrl()); + } logger.debug("Received revoked tokens response " + response); XdsSchedulerManager.getInstance().stopRevokedTokenDiscoveryScheduling(); latestReceived = response; diff --git a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/SubscriptionDiscoveryClient.java b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/SubscriptionDiscoveryClient.java index fbbc6d64f0..51408f02ad 100644 --- a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/SubscriptionDiscoveryClient.java +++ b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/SubscriptionDiscoveryClient.java @@ -127,7 +127,12 @@ public void watchSubscriptions() { .streamSubscriptions(new StreamObserver() { @Override public void onNext(DiscoveryResponse response) { - logger.info("Subscription event received with version : " + response.getVersionInfo()); + logger.info("Subscription event received with version : " + response.getVersionInfo() + + " and size(bytes) : " + response.getSerializedSize()); + if ((double) response.getSerializedSize() / maxSize > 0.90) { + logger.error("Current response size exceeds 90% of the maximum message size for the type : " + + response.getTypeUrl()); + } logger.debug("Received Subscription discovery response " + response); XdsSchedulerManager.getInstance().stopSubscriptionDiscoveryScheduling(); latestReceived = response; diff --git a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/SubscriptionPolicyDiscoveryClient.java b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/SubscriptionPolicyDiscoveryClient.java index eebb4d27e9..bbef3611ea 100644 --- a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/SubscriptionPolicyDiscoveryClient.java +++ b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/SubscriptionPolicyDiscoveryClient.java @@ -126,7 +126,12 @@ public void watchSubscriptionPolicies() { reqObserver = stub.withMaxInboundMessageSize(maxSize).streamSubscriptionPolicies(new StreamObserver<>() { @Override public void onNext(DiscoveryResponse response) { - logger.info("Subscription policy event received with version : " + response.getVersionInfo()); + logger.info("Subscription policy event received with version : " + response.getVersionInfo() + + " and size(bytes) : " + response.getSerializedSize()); + if ((double) response.getSerializedSize() / maxSize > 0.90) { + logger.error("Current response size exceeds 90% of the maximum message size for the type : " + + response.getTypeUrl()); + } logger.debug("Received Subscription policy discovery response " + response); XdsSchedulerManager.getInstance().stopSubscriptionPolicyDiscoveryScheduling(); latestReceived = response; diff --git a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ThrottleDataDiscoveryClient.java b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ThrottleDataDiscoveryClient.java index 1964a01e36..557f05054f 100644 --- a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ThrottleDataDiscoveryClient.java +++ b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ThrottleDataDiscoveryClient.java @@ -124,7 +124,12 @@ public void watchThrottleData() { .streamThrottleData(new StreamObserver<>() { @Override public void onNext(DiscoveryResponse response) { - logger.info("Throttle data event received with version : " + response.getVersionInfo()); + logger.info("Throttle data event received with version : " + response.getVersionInfo() + + " and size(bytes) : " + response.getSerializedSize()); + if ((double) response.getSerializedSize() / maxSize > 0.90) { + logger.error("Current response size exceeds 90% of the maximum message size " + + "for the type : " + response.getTypeUrl()); + } logger.debug("Received ThrottleData discovery response " + response); XdsSchedulerManager.getInstance().stopThrottleDataDiscoveryScheduling(); latestReceived = response; From d5958851c589da1b4e12b21aaa2483c3556c66e8 Mon Sep 17 00:00:00 2001 From: Viraj Salaka Date: Fri, 13 Oct 2023 15:53:54 +0530 Subject: [PATCH 7/7] Change the error log printing threshold to 0.80 --- .../choreo/connect/enforcer/discovery/ApiDiscoveryClient.java | 4 ++-- .../enforcer/discovery/ApplicationDiscoveryClient.java | 4 ++-- .../discovery/ApplicationKeyMappingDiscoveryClient.java | 4 ++-- .../enforcer/discovery/ApplicationPolicyDiscoveryClient.java | 4 ++-- .../connect/enforcer/discovery/KeyManagerDiscoveryClient.java | 4 ++-- .../enforcer/discovery/RevokedTokenDiscoveryClient.java | 4 ++-- .../enforcer/discovery/SubscriptionDiscoveryClient.java | 4 ++-- .../enforcer/discovery/SubscriptionPolicyDiscoveryClient.java | 4 ++-- .../enforcer/discovery/ThrottleDataDiscoveryClient.java | 4 ++-- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApiDiscoveryClient.java b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApiDiscoveryClient.java index 107159d8ea..a30b3a9503 100644 --- a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApiDiscoveryClient.java +++ b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApiDiscoveryClient.java @@ -125,8 +125,8 @@ public void watchApis() { public void onNext(DiscoveryResponse response) { logger.info("API event received with version : " + response.getVersionInfo() + " and size(bytes) : " + response.getSerializedSize()); - if ((double) response.getSerializedSize() / maxSize > 0.90) { - logger.error("Current response size exceeds 90% of the maximum message size for the type : " + + if ((double) response.getSerializedSize() / maxSize > 0.80) { + logger.error("Current response size exceeds 80% of the maximum message size for the type : " + response.getTypeUrl()); } logger.debug("Received API discovery response " + response); diff --git a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationDiscoveryClient.java b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationDiscoveryClient.java index 7773edfabd..3cb6d65309 100644 --- a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationDiscoveryClient.java +++ b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationDiscoveryClient.java @@ -130,8 +130,8 @@ public void watchApplications() { public void onNext(DiscoveryResponse response) { logger.info("Application creation event received with version : " + response.getVersionInfo() + " and size(bytes) : " + response.getSerializedSize()); - if ((double) response.getSerializedSize() / maxSize > 0.90) { - logger.error("Current response size exceeds 90% of the maximum message size for the type : " + + if ((double) response.getSerializedSize() / maxSize > 0.80) { + logger.error("Current response size exceeds 80% of the maximum message size for the type : " + response.getTypeUrl()); } logger.debug("Received Application discovery response " + response); diff --git a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationKeyMappingDiscoveryClient.java b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationKeyMappingDiscoveryClient.java index 67b305d8a6..5b2582e0b4 100644 --- a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationKeyMappingDiscoveryClient.java +++ b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationKeyMappingDiscoveryClient.java @@ -130,8 +130,8 @@ public void watchApplicationKeyMappings() { public void onNext(DiscoveryResponse response) { logger.info("Application key generation event received with version : " + response.getVersionInfo() + " and size(bytes) : " + response.getSerializedSize()); - if ((double) response.getSerializedSize() / maxSize > 0.90) { - logger.error("Current response size exceeds 90% of the maximum message size for the type : " + + if ((double) response.getSerializedSize() / maxSize > 0.80) { + logger.error("Current response size exceeds 80% of the maximum message size for the type : " + response.getTypeUrl()); } logger.debug("Received Application Key Mapping discovery response " + response); diff --git a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationPolicyDiscoveryClient.java b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationPolicyDiscoveryClient.java index d8c47cacf5..65719b3677 100644 --- a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationPolicyDiscoveryClient.java +++ b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ApplicationPolicyDiscoveryClient.java @@ -130,8 +130,8 @@ public void watchApplicationPolicies() { public void onNext(DiscoveryResponse response) { logger.info("Application policy event received with version : " + response.getVersionInfo() + " and size(bytes) : " + response.getSerializedSize()); - if ((double) response.getSerializedSize() / maxSize > 0.90) { - logger.error("Current response size exceeds 90% of the maximum message size for the type : " + + if ((double) response.getSerializedSize() / maxSize > 0.80) { + logger.error("Current response size exceeds 80% of the maximum message size for the type : " + response.getTypeUrl()); } logger.debug("Received Application Policy discovery response " + response); diff --git a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/KeyManagerDiscoveryClient.java b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/KeyManagerDiscoveryClient.java index fc8084dc01..47871aa63d 100644 --- a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/KeyManagerDiscoveryClient.java +++ b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/KeyManagerDiscoveryClient.java @@ -128,8 +128,8 @@ public void watchKeyManagers() { public void onNext(DiscoveryResponse response) { logger.info("Key manager event received with version : " + response.getVersionInfo() + " and size(bytes) : " + response.getSerializedSize()); - if ((double) response.getSerializedSize() / maxSize > 0.90) { - logger.error("Current response size exceeds 90% of the maximum message size for the type : " + + if ((double) response.getSerializedSize() / maxSize > 0.80) { + logger.error("Current response size exceeds 80% of the maximum message size for the type : " + response.getTypeUrl()); } logger.debug("Received KeyManagers discovery response " + response); diff --git a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/RevokedTokenDiscoveryClient.java b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/RevokedTokenDiscoveryClient.java index 4d44350aac..0298e81c46 100644 --- a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/RevokedTokenDiscoveryClient.java +++ b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/RevokedTokenDiscoveryClient.java @@ -131,8 +131,8 @@ public void watchRevokedTokens() { public void onNext(DiscoveryResponse response) { logger.info("Revoked token event received with version : " + response.getVersionInfo() + " and size(bytes) : " + response.getSerializedSize()); - if ((double) response.getSerializedSize() / maxSize > 0.90) { - logger.error("Current response size exceeds 90% of the maximum message size for the type : " + + if ((double) response.getSerializedSize() / maxSize > 0.80) { + logger.error("Current response size exceeds 80% of the maximum message size for the type : " + response.getTypeUrl()); } logger.debug("Received revoked tokens response " + response); diff --git a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/SubscriptionDiscoveryClient.java b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/SubscriptionDiscoveryClient.java index 51408f02ad..9f1423dff4 100644 --- a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/SubscriptionDiscoveryClient.java +++ b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/SubscriptionDiscoveryClient.java @@ -129,8 +129,8 @@ public void watchSubscriptions() { public void onNext(DiscoveryResponse response) { logger.info("Subscription event received with version : " + response.getVersionInfo() + " and size(bytes) : " + response.getSerializedSize()); - if ((double) response.getSerializedSize() / maxSize > 0.90) { - logger.error("Current response size exceeds 90% of the maximum message size for the type : " + + if ((double) response.getSerializedSize() / maxSize > 0.80) { + logger.error("Current response size exceeds 80% of the maximum message size for the type : " + response.getTypeUrl()); } logger.debug("Received Subscription discovery response " + response); diff --git a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/SubscriptionPolicyDiscoveryClient.java b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/SubscriptionPolicyDiscoveryClient.java index bbef3611ea..96285cb5ba 100644 --- a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/SubscriptionPolicyDiscoveryClient.java +++ b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/SubscriptionPolicyDiscoveryClient.java @@ -128,8 +128,8 @@ public void watchSubscriptionPolicies() { public void onNext(DiscoveryResponse response) { logger.info("Subscription policy event received with version : " + response.getVersionInfo() + " and size(bytes) : " + response.getSerializedSize()); - if ((double) response.getSerializedSize() / maxSize > 0.90) { - logger.error("Current response size exceeds 90% of the maximum message size for the type : " + + if ((double) response.getSerializedSize() / maxSize > 0.80) { + logger.error("Current response size exceeds 80% of the maximum message size for the type : " + response.getTypeUrl()); } logger.debug("Received Subscription policy discovery response " + response); diff --git a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ThrottleDataDiscoveryClient.java b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ThrottleDataDiscoveryClient.java index 557f05054f..4f327efbff 100644 --- a/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ThrottleDataDiscoveryClient.java +++ b/enforcer-parent/enforcer/src/main/java/org/wso2/choreo/connect/enforcer/discovery/ThrottleDataDiscoveryClient.java @@ -126,8 +126,8 @@ public void watchThrottleData() { public void onNext(DiscoveryResponse response) { logger.info("Throttle data event received with version : " + response.getVersionInfo() + " and size(bytes) : " + response.getSerializedSize()); - if ((double) response.getSerializedSize() / maxSize > 0.90) { - logger.error("Current response size exceeds 90% of the maximum message size " + + if ((double) response.getSerializedSize() / maxSize > 0.80) { + logger.error("Current response size exceeds 80% of the maximum message size " + "for the type : " + response.getTypeUrl()); } logger.debug("Received ThrottleData discovery response " + response);