This is an automated email from the ASF dual-hosted git repository.
oipo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/celix.git
The following commit(s) were added to refs/heads/master by this push:
new 4ebde14 Add service ranking to wire protocols and make endpoint
matching print errors if match is mandatory but cannot be made
4ebde14 is described below
commit 4ebde14e5cd089223339f5a21c07c0cea9ab34f8
Author: Michael de Lang <[email protected]>
AuthorDate: Thu Oct 29 17:10:10 2020 +0100
Add service ranking to wire protocols and make endpoint matching print
errors if match is mandatory but cannot be made
---
bundles/pubsub/pubsub_admin_tcp/src/pubsub_tcp_admin.c | 2 +-
bundles/pubsub/pubsub_admin_udp_mc/src/pubsub_udpmc_admin.c | 2 +-
.../pubsub/pubsub_admin_websocket/src/pubsub_websocket_admin.c | 2 +-
bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_admin.c | 2 +-
.../pubsub_protocol_wire_v1/src/ps_wire_protocol_activator.c | 1 +
.../pubsub_protocol_wire_v2/src/ps_wire_v2_protocol_activator.c | 1 +
bundles/pubsub/pubsub_spi/include/pubsub_endpoint.h | 2 ++
bundles/pubsub/pubsub_spi/src/pubsub_endpoint_match.c | 9 +++++++++
8 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/bundles/pubsub/pubsub_admin_tcp/src/pubsub_tcp_admin.c
b/bundles/pubsub/pubsub_admin_tcp/src/pubsub_tcp_admin.c
index e7ad284..89f5863 100644
--- a/bundles/pubsub/pubsub_admin_tcp/src/pubsub_tcp_admin.c
+++ b/bundles/pubsub/pubsub_admin_tcp/src/pubsub_tcp_admin.c
@@ -398,7 +398,7 @@ pubsub_tcpAdmin_matchDiscoveredEndpoint(void *handle, const
celix_properties_t *
pubsub_tcp_admin_t *psa = handle;
L_DEBUG("[PSA_TCP] pubsub_tcpAdmin_matchEndpoint");
celix_status_t status = CELIX_SUCCESS;
- bool match = pubsubEndpoint_match(psa->ctx, endpoint,
PUBSUB_TCP_ADMIN_TYPE, true, NULL, NULL);
+ bool match = pubsubEndpoint_match(psa->ctx, psa->log, endpoint,
PUBSUB_TCP_ADMIN_TYPE, true, NULL, NULL);
if (outMatch != NULL) {
*outMatch = match;
}
diff --git a/bundles/pubsub/pubsub_admin_udp_mc/src/pubsub_udpmc_admin.c
b/bundles/pubsub/pubsub_admin_udp_mc/src/pubsub_udpmc_admin.c
index 18657a1..41941eb 100644
--- a/bundles/pubsub/pubsub_admin_udp_mc/src/pubsub_udpmc_admin.c
+++ b/bundles/pubsub/pubsub_admin_udp_mc/src/pubsub_udpmc_admin.c
@@ -281,7 +281,7 @@ celix_status_t pubsub_udpmcAdmin_matchEndpoint(void
*handle, const celix_propert
pubsub_udpmc_admin_t *psa = handle;
L_DEBUG("[PSA_UDPMC] pubsub_udpmcAdmin_matchEndpoint");
celix_status_t status = CELIX_SUCCESS;
- bool match = pubsubEndpoint_match(psa->ctx, endpoint,
PUBSUB_UDPMC_ADMIN_TYPE, false, NULL, NULL);
+ bool match = pubsubEndpoint_match(psa->ctx, psa->log, endpoint,
PUBSUB_UDPMC_ADMIN_TYPE, false, NULL, NULL);
if (outMatch != NULL) {
*outMatch = match;
}
diff --git a/bundles/pubsub/pubsub_admin_websocket/src/pubsub_websocket_admin.c
b/bundles/pubsub/pubsub_admin_websocket/src/pubsub_websocket_admin.c
index ba33252..9c4633a 100644
--- a/bundles/pubsub/pubsub_admin_websocket/src/pubsub_websocket_admin.c
+++ b/bundles/pubsub/pubsub_admin_websocket/src/pubsub_websocket_admin.c
@@ -260,7 +260,7 @@ celix_status_t
pubsub_websocketAdmin_matchDiscoveredEndpoint(void *handle, const
pubsub_websocket_admin_t *psa = handle;
L_DEBUG("[PSA_WEBSOCKET] pubsub_websocketAdmin_matchEndpoint");
celix_status_t status = CELIX_SUCCESS;
- bool match = pubsubEndpoint_match(psa->ctx, endpoint,
PUBSUB_WEBSOCKET_ADMIN_TYPE, false, NULL, NULL);
+ bool match = pubsubEndpoint_match(psa->ctx, psa->log, endpoint,
PUBSUB_WEBSOCKET_ADMIN_TYPE, false, NULL, NULL);
if (outMatch != NULL) {
*outMatch = match;
}
diff --git a/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_admin.c
b/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_admin.c
index b16321a..fb6206c 100644
--- a/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_admin.c
+++ b/bundles/pubsub/pubsub_admin_zmq/src/pubsub_zmq_admin.c
@@ -442,7 +442,7 @@ celix_status_t pubsub_zmqAdmin_matchDiscoveredEndpoint(void
*handle, const celix
pubsub_zmq_admin_t *psa = handle;
L_DEBUG("[PSA_ZMQ] pubsub_zmqAdmin_matchEndpoint");
celix_status_t status = CELIX_SUCCESS;
- bool match = pubsubEndpoint_match(psa->ctx, endpoint,
PUBSUB_ZMQ_ADMIN_TYPE, true, NULL, NULL);
+ bool match = pubsubEndpoint_match(psa->ctx, psa->log, endpoint,
PUBSUB_ZMQ_ADMIN_TYPE, true, NULL, NULL);
if (outMatch != NULL) {
*outMatch = match;
}
diff --git
a/bundles/pubsub/pubsub_protocol/pubsub_protocol_wire_v1/src/ps_wire_protocol_activator.c
b/bundles/pubsub/pubsub_protocol/pubsub_protocol_wire_v1/src/ps_wire_protocol_activator.c
index 3aff467..64abebe 100644
---
a/bundles/pubsub/pubsub_protocol/pubsub_protocol_wire_v1/src/ps_wire_protocol_activator.c
+++
b/bundles/pubsub/pubsub_protocol/pubsub_protocol_wire_v1/src/ps_wire_protocol_activator.c
@@ -38,6 +38,7 @@ static int ps_wp_start(ps_wp_activator_t *act,
celix_bundle_context_t *ctx) {
/* Set serializertype */
celix_properties_t *props = celix_properties_create();
celix_properties_set(props, PUBSUB_PROTOCOL_TYPE_KEY,
PUBSUB_WIRE_PROTOCOL_TYPE);
+ celix_properties_setLong(props, OSGI_FRAMEWORK_SERVICE_RANKING, 5);
act->protocolSvc.getHeaderSize = pubsubProtocol_getHeaderSize;
act->protocolSvc.getHeaderBufferSize =
pubsubProtocol_getHeaderBufferSize;
diff --git
a/bundles/pubsub/pubsub_protocol/pubsub_protocol_wire_v2/src/ps_wire_v2_protocol_activator.c
b/bundles/pubsub/pubsub_protocol/pubsub_protocol_wire_v2/src/ps_wire_v2_protocol_activator.c
index 80e4433..77a7b2f 100644
---
a/bundles/pubsub/pubsub_protocol/pubsub_protocol_wire_v2/src/ps_wire_v2_protocol_activator.c
+++
b/bundles/pubsub/pubsub_protocol/pubsub_protocol_wire_v2/src/ps_wire_v2_protocol_activator.c
@@ -38,6 +38,7 @@ static int ps_wp_start(ps_wp_activator_t *act,
celix_bundle_context_t *ctx) {
/* Set serializertype */
celix_properties_t *props = celix_properties_create();
celix_properties_set(props, PUBSUB_PROTOCOL_TYPE_KEY,
PUBSUB_WIRE_V2_PROTOCOL_TYPE);
+ celix_properties_setLong(props, OSGI_FRAMEWORK_SERVICE_RANKING, 10);
act->protocolSvc.getHeaderSize = pubsubProtocol_wire_v2_getHeaderSize;
act->protocolSvc.getHeaderBufferSize =
pubsubProtocol_wire_v2_getHeaderBufferSize;
diff --git a/bundles/pubsub/pubsub_spi/include/pubsub_endpoint.h
b/bundles/pubsub/pubsub_spi/include/pubsub_endpoint.h
index 2e1cfe9..ed6f9e3 100644
--- a/bundles/pubsub/pubsub_spi/include/pubsub_endpoint.h
+++ b/bundles/pubsub/pubsub_spi/include/pubsub_endpoint.h
@@ -20,6 +20,7 @@
#ifndef PUBSUB_ENDPOINT_H_
#define PUBSUB_ENDPOINT_H_
+#include "celix_log_helper.h"
#include "celix_bundle_context.h"
#include "celix_properties.h"
@@ -173,6 +174,7 @@ double pubsubEndpoint_matchSubscriber(
*/
bool pubsubEndpoint_match(
celix_bundle_context_t *ctx,
+ celix_log_helper_t *logHelper,
const celix_properties_t *endpoint,
const char *adminType,
bool matchProtocol,
diff --git a/bundles/pubsub/pubsub_spi/src/pubsub_endpoint_match.c
b/bundles/pubsub/pubsub_spi/src/pubsub_endpoint_match.c
index 041f0f5..ef99ff5 100644
--- a/bundles/pubsub/pubsub_spi/src/pubsub_endpoint_match.c
+++ b/bundles/pubsub/pubsub_spi/src/pubsub_endpoint_match.c
@@ -280,6 +280,7 @@ double pubsubEndpoint_matchSubscriber(
bool pubsubEndpoint_match(
celix_bundle_context_t *ctx,
+ celix_log_helper_t *logHelper,
const celix_properties_t *ep,
const char *adminType,
bool matchProtocol,
@@ -298,6 +299,10 @@ bool pubsubEndpoint_match(
const char *configured_serializer = celix_properties_get(ep,
PUBSUB_ENDPOINT_SERIALIZER, NULL);
serializerSvcId = getPSASerializer(ctx, configured_serializer);
serMatch = serializerSvcId >= 0;
+
+ if(!serMatch) {
+ celix_logHelper_log(logHelper, CELIX_LOG_LEVEL_ERROR, "Matching
endpoint for technology %s but couldn't get serializer %i", configured_admin,
configured_serializer);
+ }
}
bool match = psaMatch && serMatch;
@@ -309,6 +314,10 @@ bool pubsubEndpoint_match(
const char *configured_protocol = celix_properties_get(ep,
PUBSUB_ENDPOINT_PROTOCOL, NULL);
protocolSvcId = getPSAProtocol(ctx, configured_protocol);
protMatch = protocolSvcId >= 0;
+
+ if(!protMatch) {
+ celix_logHelper_log(logHelper, CELIX_LOG_LEVEL_ERROR,
"Matching endpoint for technology %s but couldn't get protocol %i",
configured_admin, configured_protocol);
+ }
}
match = match && protMatch;