celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From erjanalt...@apache.org
Subject [1/2] celix git commit: Discovery subscriber failed reading ETCD when started without existing publisher
Date Thu, 08 Feb 2018 10:36:58 GMT
Repository: celix
Updated Branches:
  refs/heads/develop 24bad0e41 -> 490811d2c


Discovery subscriber failed reading ETCD when started without existing publisher


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/a0d4621d
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/a0d4621d
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/a0d4621d

Branch: refs/heads/develop
Commit: a0d4621d9056d208695cb5d97788153ddfa1b3bc
Parents: f988011
Author: Erjan Altena <erjanaltena@gmail.com>
Authored: Thu Feb 8 11:32:28 2018 +0100
Committer: Erjan Altena <erjanaltena@gmail.com>
Committed: Thu Feb 8 11:32:28 2018 +0100

----------------------------------------------------------------------
 etcdlib/src/etcd.c                          | 14 +++++++++++++-
 pubsub/pubsub_admin_zmq/src/psa_activator.c | 14 +++++++-------
 2 files changed, 20 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/a0d4621d/etcdlib/src/etcd.c
----------------------------------------------------------------------
diff --git a/etcdlib/src/etcd.c b/etcdlib/src/etcd.c
index f75fa03..cb5c0ff 100644
--- a/etcdlib/src/etcd.c
+++ b/etcdlib/src/etcd.c
@@ -33,6 +33,7 @@
 #define ETCD_JSON_VALUE                 "value"
 #define ETCD_JSON_DIR                   "dir"
 #define ETCD_JSON_MODIFIEDINDEX         "modifiedIndex"
+#define ETCD_JSON_INDEX                 "index"
 
 #define MAX_OVERHEAD_LENGTH           64
 #define DEFAULT_CURL_TIMEOUT          10
@@ -198,7 +199,6 @@ int etcd_get_directory(const char* directory, etcd_key_value_callback
callback,
 
 	res = performRequest(url, GET, WriteMemoryCallback, NULL, (void*) &reply);
 	free(url);
-
 	if (res == CURLE_OK) {
 		js_root = json_loads(reply.memory, 0, &error);
 		if (js_root != NULL) {
@@ -210,6 +210,18 @@ int etcd_get_directory(const char* directory, etcd_key_value_callback
callback,
 		if (js_rootnode != NULL) {
 			*modifiedIndex = 0;
 			retVal = etcd_get_recursive_values(js_rootnode, callback, arg, (json_int_t*)modifiedIndex);
+		} else {
+			// Error occured, retrieve the index of ETCD from the error code
+			js_rootnode = json_object_get(js_root, ETCD_JSON_INDEX);
+			if(js_rootnode) {
+				json_int_t index = json_integer_value(js_rootnode);
+				*modifiedIndex = index;
+
+			} else {
+				fprintf(stderr, "[ETCDLIB] Error: index not found in error %s\n", reply.memory);
+
+			}
+
 		}
 		if (js_root != NULL) {
 			json_decref(js_root);

http://git-wip-us.apache.org/repos/asf/celix/blob/a0d4621d/pubsub/pubsub_admin_zmq/src/psa_activator.c
----------------------------------------------------------------------
diff --git a/pubsub/pubsub_admin_zmq/src/psa_activator.c b/pubsub/pubsub_admin_zmq/src/psa_activator.c
index 73c45fa..f754cd1 100644
--- a/pubsub/pubsub_admin_zmq/src/psa_activator.c
+++ b/pubsub/pubsub_admin_zmq/src/psa_activator.c
@@ -108,14 +108,14 @@ celix_status_t bundleActivator_create(bundle_context_pt context, void
**userData
 				pubsubAdmin_destroy(activator->admin);
 			}
 		}
+		properties_pt shellProps = properties_create();
+		properties_set(shellProps, OSGI_SHELL_COMMAND_NAME, "psa_zmq_info");
+		properties_set(shellProps, OSGI_SHELL_COMMAND_USAGE, "psa_zmq_info");
+		properties_set(shellProps, OSGI_SHELL_COMMAND_DESCRIPTION, "psa_zmq_info: Overview of PubSub
ZMQ Admin");
+		activator->admin->shellCmdService.handle = activator;
+		activator->admin->shellCmdService.executeCommand = shellCommand;
+		bundleContext_registerService(context, OSGI_SHELL_COMMAND_SERVICE_NAME, &activator->admin->shellCmdService,
shellProps, &activator->admin->shellCmdReg);
 	}
-    properties_pt shellProps = properties_create();
-    properties_set(shellProps, OSGI_SHELL_COMMAND_NAME, "psa_zmq_info");
-    properties_set(shellProps, OSGI_SHELL_COMMAND_USAGE, "psa_zmq_info");
-    properties_set(shellProps, OSGI_SHELL_COMMAND_DESCRIPTION, "psa_zmq_info: Overview of
PubSub ZMQ Admin");
-    activator->admin->shellCmdService.handle = activator;
-    activator->admin->shellCmdService.executeCommand = shellCommand;
-    bundleContext_registerService(context, OSGI_SHELL_COMMAND_SERVICE_NAME, &activator->admin->shellCmdService,
shellProps, &activator->admin->shellCmdReg);
 	return status;
 }
 


Mime
View raw message