You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pn...@apache.org on 2019/03/18 15:40:23 UTC
[celix] branch develop updated: CELIX-460: Updates logging of
pubsub etcd to include more information
This is an automated email from the ASF dual-hosted git repository.
pnoltes pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/celix.git
The following commit(s) were added to refs/heads/develop by this push:
new 47fad4d CELIX-460: Updates logging of pubsub etcd to include more information
47fad4d is described below
commit 47fad4dc17df2319e8f0b6467dfa160cfc256337
Author: Pepijn Noltes <pe...@gmail.com>
AuthorDate: Mon Mar 18 16:39:55 2019 +0100
CELIX-460: Updates logging of pubsub etcd to include more information
---
.../pubsub_discovery/src/pubsub_discovery_impl.c | 25 ++++++++--------
bundles/remote_services/discovery_etcd/README.md | 12 +++++---
.../remote_service_admin_dfi/README.md | 4 +--
.../src/remote_service_admin_dfi.c | 1 -
.../src/remote_service_admin_dfi.h | 5 +---
bundles/shell/shell_tui/private/src/activator.c | 34 +++++++++++++---------
6 files changed, 44 insertions(+), 37 deletions(-)
diff --git a/bundles/pubsub/pubsub_discovery/src/pubsub_discovery_impl.c b/bundles/pubsub/pubsub_discovery/src/pubsub_discovery_impl.c
index 4e902e3..b49398f 100644
--- a/bundles/pubsub/pubsub_discovery/src/pubsub_discovery_impl.c
+++ b/bundles/pubsub/pubsub_discovery/src/pubsub_discovery_impl.c
@@ -50,7 +50,7 @@
#define L_ERROR(...) \
logHelper_log(disc->logHelper, OSGI_LOGSERVICE_ERROR, __VA_ARGS__)
-static celix_properties_t* pubsub_discovery_parseEndpoint(pubsub_discovery_t *disc, const char *value);
+static celix_properties_t* pubsub_discovery_parseEndpoint(pubsub_discovery_t *disc, const char *key, const char *value);
static char* pubsub_discovery_createJsonEndpoint(const celix_properties_t *props);
static void pubsub_discovery_addDiscoveredEndpoint(pubsub_discovery_t *disc, celix_properties_t *endpoint);
static void pubsub_discovery_removeDiscoveredEndpoint(pubsub_discovery_t *disc, const char *uuid);
@@ -121,9 +121,9 @@ celix_status_t pubsub_discovery_destroy(pubsub_discovery_t *ps_discovery) {
}
-static void psd_etcdReadCallback(const char *key __attribute__((unused)), const char *value, void* arg) {
+static void psd_etcdReadCallback(const char *key, const char *value, void* arg) {
pubsub_discovery_t *disc = arg;
- celix_properties_t *props = pubsub_discovery_parseEndpoint(disc, value);
+ celix_properties_t *props = pubsub_discovery_parseEndpoint(disc, key, value);
if (props != NULL) {
pubsub_discovery_addDiscoveredEndpoint(disc, props);
}
@@ -155,7 +155,7 @@ static void psd_watchForChange(pubsub_discovery_t *disc, bool *connectedPtr, lon
//TODO add interruptable etcd_wait -> which returns a handle to interrupt and a can be used for a wait call
int rc = etcd_watch(disc->pubsubPath, watchIndex, &action, NULL, &value, &readKey, mIndex);
if (rc == ETCDLIB_RC_ERROR) {
- printf("[PSD] Error communicating with etcd. rc is %i, action value is %s\n", rc, action);
+ L_ERROR("[PSD] Communicating with etcd. rc is %i, action value is %s\n", rc, action);
*connectedPtr = false;
} else if (rc == ETCDLIB_RC_TIMEOUT || action == NULL) {
//nop
@@ -163,7 +163,7 @@ static void psd_watchForChange(pubsub_discovery_t *disc, bool *connectedPtr, lon
if (strncmp(ETCDLIB_ACTION_CREATE, action, strlen(ETCDLIB_ACTION_CREATE)) == 0 ||
strncmp(ETCDLIB_ACTION_SET, action, strlen(ETCDLIB_ACTION_SET)) == 0 ||
strncmp(ETCDLIB_ACTION_UPDATE, action, strlen(ETCDLIB_ACTION_UPDATE)) == 0) {
- celix_properties_t *props = pubsub_discovery_parseEndpoint(disc, value);
+ celix_properties_t *props = pubsub_discovery_parseEndpoint(disc, readKey, value);
if (props != NULL) {
pubsub_discovery_addDiscoveredEndpoint(disc, props);
}
@@ -264,7 +264,7 @@ void* psd_refresh(void *data) {
//only refresh ttl -> no index update -> no watch trigger
int rc = etcd_refresh(entry->key, disc->ttlForEntries);
if (rc != ETCDLIB_RC_OK) {
- L_WARN("[PSD] Warning: error refreshing etcd key %s\n", entry->key);
+ L_WARN("[PSD] Warning: Cannot refresh etcd key %s\n", entry->key);
entry->isSet = false;
entry->errorCount += 1;
} else {
@@ -277,7 +277,7 @@ void* psd_refresh(void *data) {
entry->isSet = true;
entry->setCount += 1;
} else {
- L_WARN("[PSD] Warning: error setting endpoint in etcd for key %s\n", entry->key);
+ L_WARN("[PSD] Warning: Cannot set endpoint in etcd for key %s\n", entry->key);
entry->errorCount += 1;
}
free(str);
@@ -434,7 +434,7 @@ celix_status_t pubsub_discovery_revokeEndpoint(void *handle, const celix_propert
entry = hashMap_remove(disc->announcedEndpoints, uuid);
celixThreadMutex_unlock(&disc->announcedEndpointsMutex);
} else {
- printf("[PSD] Error cannot remove announced endpoint. missing endpoint uuid property\n");
+ L_WARN("[PSD] Cannot remove announced endpoint. missing endpoint uuid property\n");
}
if (entry != NULL) {
@@ -469,7 +469,7 @@ static void pubsub_discovery_addDiscoveredEndpoint(pubsub_discovery_t *disc, cel
const char *type = celix_properties_get(endpoint, PUBSUB_ENDPOINT_TYPE, "!Error!");
const char *admin = celix_properties_get(endpoint, PUBSUB_ENDPOINT_ADMIN_TYPE, "!Error!");
const char *ser = celix_properties_get(endpoint, PUBSUB_SERIALIZER_TYPE_KEY, "!Error!");
- printf("[PSD] Adding discovered endpoint %s. type is %s, admin is %s, serializer is %s.\n",
+ L_INFO("[PSD] Adding discovered endpoint %s. type is %s, admin is %s, serializer is %s.\n",
uuid, type, admin, ser);
}
@@ -513,11 +513,11 @@ static void pubsub_discovery_removeDiscoveredEndpoint(pubsub_discovery_t *disc,
}
celixThreadMutex_unlock(&disc->discoveredEndpointsListenersMutex);
} else {
- L_ERROR("[PSD] Warning unexpected remove from non existing endpoint (uuid is %s)\n", uuid);
+ L_WARN("[PSD] Warning unexpected remove from non existing endpoint (uuid is %s)\n", uuid);
}
}
-celix_properties_t* pubsub_discovery_parseEndpoint(pubsub_discovery_t *disc, const char* etcdValue) {
+celix_properties_t* pubsub_discovery_parseEndpoint(pubsub_discovery_t *disc, const char *key, const char* etcdValue) {
properties_t *props = celix_properties_create();
// etcdValue contains the json formatted string
@@ -545,7 +545,8 @@ celix_properties_t* pubsub_discovery_parseEndpoint(pubsub_discovery_t *disc, con
bool valid = pubsubEndpoint_isValid(props, true, true);
if (!valid) {
- L_WARN("[PSD] Warning retrieved endpoint is not valid\n");
+ L_WARN("[PSD] Retrieved endpoint '%s' is not valid\n", key);
+ L_DEBUG("[PSD] Key %s: %s\n", key, etcdValue);
celix_properties_destroy(props);
props = NULL;
}
diff --git a/bundles/remote_services/discovery_etcd/README.md b/bundles/remote_services/discovery_etcd/README.md
index e560264..9af0fba 100644
--- a/bundles/remote_services/discovery_etcd/README.md
+++ b/bundles/remote_services/discovery_etcd/README.md
@@ -20,10 +20,14 @@ limitations under the License.
The Celix Discovery ETCD bundles realizes OSGi services discovery based on [etcd](https://github.com/coreos/etcd).
###### Properties
- DISCOVERY_ETCD_ROOT_PATH used path (default: discovery)
- DEFAULT_ETCD_SERVER_IP ip address of the etcd server (default: 127.0.0.1)
- DEFAULT_ETCD_SERVER_PORT port of the etcd server (default: 2379)
- DEFAULT_ETCD_TTL time-to-live for etcd entries in seconds (default: 30)
+ DISCOVERY_ETCD_ROOT_PATH Used path to announce and find discovery entpoints (default: discovery)
+ DISCOVERY_ETCD_SERVER_IP ip address of the etcd server (default: 127.0.0.1)
+ DISCOVERY_ETCD_SERVER_PORT port of the etcd server (default: 2379)
+ DISCOVERY_ETCD_TTL time-to-live for etcd entries in seconds (default: 30)
+
+ DISCOVERY_CFG_SERVER_IP The host to use/announce for this framewokr discovery endpoint. Default "127.0.0.1"
+ DISCOVERY_CFG_SERVER_PORT The port to use/announce for this framework endpoint endpoint. Default 9999
+ DISCOVERY_CFG_SERVER_PATH The path to use for this framework discovery endpoint.Default "/org.apache.celix.discovery.etcd"
###### CMake option
BUILD_RSA_DISCOVERY_ETCD=ON
diff --git a/bundles/remote_services/remote_service_admin_dfi/README.md b/bundles/remote_services/remote_service_admin_dfi/README.md
index 6a3ded4..47123b7 100644
--- a/bundles/remote_services/remote_service_admin_dfi/README.md
+++ b/bundles/remote_services/remote_service_admin_dfi/README.md
@@ -26,8 +26,8 @@ Libffi is configured using descriptor files in the bundles.
RSA_IP The RSA ip address to use for discovery (default 127.0.0.1)
RSA_INTERFACE If specified, the ip adress of interface (i.g. eth0) will be used.
- RSA_LOG_CALLS If set to true, the RSA will Log calls info (including serialized data) to the file in RSA_DUMP_CALLS_FILE. Default is false.
- RSA_LOG_CALLS_FILE If RSA_DUMP_CALLS is enabled to file to dump to (starting rsa will truncate file). Default is stdout.
+ RSA_LOG_CALLS If set to true, the RSA will Log calls info (including serialized data) to the file in RSA_LOG_CALLS_FILE. Default is false.
+ RSA_LOG_CALLS_FILE If RSA_LOG_CALLS is enabled to file to log to (starting rsa will truncate file). Default is stdout.
###### CMake option
RSA_REMOTE_SERVICE_ADMIN_DFI=ON
diff --git a/bundles/remote_services/remote_service_admin_dfi/src/remote_service_admin_dfi.c b/bundles/remote_services/remote_service_admin_dfi/src/remote_service_admin_dfi.c
index 9ecea65..f40a8e2 100644
--- a/bundles/remote_services/remote_service_admin_dfi/src/remote_service_admin_dfi.c
+++ b/bundles/remote_services/remote_service_admin_dfi/src/remote_service_admin_dfi.c
@@ -29,7 +29,6 @@
#include <jansson.h>
#include "json_serializer.h"
-#include "remote_service_admin.h"
#include "import_registration_dfi.h"
#include "export_registration_dfi.h"
diff --git a/bundles/remote_services/remote_service_admin_dfi/src/remote_service_admin_dfi.h b/bundles/remote_services/remote_service_admin_dfi/src/remote_service_admin_dfi.h
index dfadf8a..cd7d3b5 100644
--- a/bundles/remote_services/remote_service_admin_dfi/src/remote_service_admin_dfi.h
+++ b/bundles/remote_services/remote_service_admin_dfi/src/remote_service_admin_dfi.h
@@ -24,12 +24,9 @@
#include "bundle_context.h"
#include "endpoint_description.h"
+#include "export_registration_dfi.h"
-
-//forward declaration
typedef struct remote_service_admin *remote_service_admin_pt;
-typedef struct export_registration *export_registration_pt;
-typedef struct export_reference *export_reference_pt;
celix_status_t remoteServiceAdmin_create(bundle_context_pt context, remote_service_admin_pt *admin);
celix_status_t remoteServiceAdmin_destroy(remote_service_admin_pt *admin);
diff --git a/bundles/shell/shell_tui/private/src/activator.c b/bundles/shell/shell_tui/private/src/activator.c
index f25dd5b..3fdb260 100644
--- a/bundles/shell/shell_tui/private/src/activator.c
+++ b/bundles/shell/shell_tui/private/src/activator.c
@@ -16,15 +16,12 @@
*specific language governing permissions and limitations
*under the License.
*/
-/*
- * activator.c
- *
- * \date Jan 15, 2016
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
+
#include <stdlib.h>
#include <string.h>
+#include <zconf.h>
+#include <stdio.h>
+#include <unistd.h>
#include "bundle_context.h"
#include "bundle_activator.h"
@@ -62,6 +59,12 @@ static celix_status_t activator_removeShellService(void *handle, service_referen
celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
celix_status_t status = CELIX_SUCCESS;
+ //Check if tty exists
+ if (!isatty(fileno(stdin))) {
+ printf("[Shell TUI] no tty connected. Shell TUI will not activate.\n");
+ return status;
+ }
+
shell_tui_activator_t* activator = calloc(1, sizeof(*activator));
if (activator != NULL) {
@@ -100,12 +103,13 @@ celix_status_t bundleActivator_create(bundle_context_pt context, void **userData
celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
celix_status_t status = CELIX_SUCCESS;
-
shell_tui_activator_t* act = (shell_tui_activator_t*) userData;
- act->currentSvc = NULL;
- serviceTracker_open(act->tracker);
- shellTui_start(act->shellTui);
+ if (act != NULL) {
+ act->currentSvc = NULL;
+ serviceTracker_open(act->tracker);
+ shellTui_start(act->shellTui);
+ }
return status;
}
@@ -125,9 +129,11 @@ celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context)
celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
shell_tui_activator_t* act = (shell_tui_activator_t*) userData;
- shellTui_destroy(act->shellTui);
- serviceTracker_destroy(act->tracker);
- free(act);
+ if (act != NULL) {
+ shellTui_destroy(act->shellTui);
+ serviceTracker_destroy(act->tracker);
+ free(act);
+ }
return CELIX_SUCCESS;
}