You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@celix.apache.org by Alexander Broekhuis <a....@gmail.com> on 2014/10/17 15:05:17 UTC
Re: svn commit: r1632480 - in /celix/trunk/remote_services/discovery_etcd/private/src:
discovery_impl.c etcd_watcher.c
Hi Bjoern,
I think you forgot to add a file to the commit. It is not building for me:
remote_services/discovery_etcd/private/src/etcd_watcher.c:237:16: error:
conflicting types for ‘etcdWatcher_create’
celix_status_t etcdWatcher_create(discovery_pt discovery, bundle_context_pt
context,
remote_services/discovery_etcd/private/include/etcd_watcher.h:36:16: note:
previous declaration of ‘etcdWatcher_create’ was here
celix_status_t etcdWatcher_create(endpoint_discovery_poller_pt poller,
bundle_context_pt context, etcd_watcher_pt *watcher);
2014-10-17 3:16 GMT-04:00 <bp...@apache.org>:
> Author: bpetri
> Date: Fri Oct 17 07:16:29 2014
> New Revision: 1632480
>
> URL: http://svn.apache.org/r1632480
> Log:
> CELIX-168: Added new property DISCOVERY_ETCD_ROOT_PATH, which allows to
> change the etcd root path
>
> Modified:
> celix/trunk/remote_services/discovery_etcd/private/src/discovery_impl.c
> celix/trunk/remote_services/discovery_etcd/private/src/etcd_watcher.c
>
> Modified:
> celix/trunk/remote_services/discovery_etcd/private/src/discovery_impl.c
> URL:
> http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery_etcd/private/src/discovery_impl.c?rev=1632480&r1=1632479&r2=1632480&view=diff
>
> ==============================================================================
> ---
> celix/trunk/remote_services/discovery_etcd/private/src/discovery_impl.c
> (original)
> +++
> celix/trunk/remote_services/discovery_etcd/private/src/discovery_impl.c Fri
> Oct 17 07:16:29 2014
> @@ -124,12 +124,12 @@ celix_status_t discovery_start(discovery
> return CELIX_BUNDLE_EXCEPTION;
> }
>
> - status = etcdWatcher_create(discovery->poller, discovery->context,
> &discovery->watcher);
> + status = endpointDiscoveryServer_create(discovery,
> discovery->context, &discovery->server);
> if (status != CELIX_SUCCESS) {
> - return CELIX_BUNDLE_EXCEPTION;
> + return CELIX_BUNDLE_EXCEPTION;
> }
>
> - status = endpointDiscoveryServer_create(discovery,
> discovery->context, &discovery->server);
> + status = etcdWatcher_create(discovery, discovery->context,
> &discovery->watcher);
> if (status != CELIX_SUCCESS) {
> return CELIX_BUNDLE_EXCEPTION;
> }
> @@ -140,12 +140,12 @@ celix_status_t discovery_start(discovery
> celix_status_t discovery_stop(discovery_pt discovery) {
> celix_status_t status;
>
> - status = endpointDiscoveryServer_destroy(discovery->server);
> + status = etcdWatcher_destroy(discovery->watcher);
> if (status != CELIX_SUCCESS) {
> return CELIX_BUNDLE_EXCEPTION;
> }
>
> - status = etcdWatcher_destroy(discovery->watcher);
> + status = endpointDiscoveryServer_destroy(discovery->server);
> if (status != CELIX_SUCCESS) {
> return CELIX_BUNDLE_EXCEPTION;
> }
>
> Modified:
> celix/trunk/remote_services/discovery_etcd/private/src/etcd_watcher.c
> URL:
> http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery_etcd/private/src/etcd_watcher.c?rev=1632480&r1=1632479&r2=1632480&view=diff
>
> ==============================================================================
> --- celix/trunk/remote_services/discovery_etcd/private/src/etcd_watcher.c
> (original)
> +++ celix/trunk/remote_services/discovery_etcd/private/src/etcd_watcher.c
> Fri Oct 17 07:16:29 2014
> @@ -38,8 +38,7 @@
> #include "endpoint_discovery_poller.h"
>
> struct etcd_watcher {
> - endpoint_discovery_poller_pt poller;
> - bundle_context_pt context;
> + discovery_pt discovery;
>
> celix_thread_mutex_t watcherLock;
> celix_thread_t watcherThread;
> @@ -47,6 +46,9 @@ struct etcd_watcher {
> volatile bool running;
> };
>
> +#define CFG_ETCD_ROOT_PATH "DISCOVERY_ETCD_ROOT_PATH"
> +#define DEFAULT_ETCD_ROOTPATH "discovery"
> +
> #define CFG_ETCD_SERVER_IP "DISCOVERY_ETCD_SERVER_IP"
> #define DEFAULT_ETCD_SERVER_IP "127.0.0.1"
>
> @@ -59,10 +61,16 @@ struct etcd_watcher {
>
>
> // note that the rootNode shouldn't have a leading slash
> -static celix_status_t etcdWatcher_getRootPath(char* rootNode) {
> +static celix_status_t etcdWatcher_getRootPath(bundle_context_pt context,
> char* rootNode) {
> celix_status_t status = CELIX_SUCCESS;
> + char* rootPath = NULL;
>
> - strcpy(rootNode, "discovery");
> + if (((bundleContext_getProperty(context, CFG_ETCD_ROOT_PATH,
> &rootPath)) != CELIX_SUCCESS) || (!rootPath)) {
> + strcpy(rootNode, DEFAULT_ETCD_ROOTPATH);
> + }
> + else {
> + strcpy(rootNode, rootPath);
> + }
>
> return status;
> }
> @@ -73,7 +81,7 @@ static celix_status_t etcdWatcher_getLoc
> char rootPath[MAX_ROOTNODE_LENGTH];
> char* uuid = NULL;
>
> - if (((etcdWatcher_getRootPath(&rootPath[0]) != CELIX_SUCCESS)) ||
> (!rootPath)) {
> + if ((etcdWatcher_getRootPath(context, &rootPath[0]) !=
> CELIX_SUCCESS)) {
> status = CELIX_ILLEGAL_STATE;
> }
> else if (((bundleContext_getProperty(context,
> OSGI_FRAMEWORK_FRAMEWORK_UUID, &uuid)) != CELIX_SUCCESS) || (!uuid)) {
> @@ -95,7 +103,7 @@ static celix_status_t etcdWatcher_getLoc
> * returns the modifiedIndex of the last modified
> * discovery endpoint (see etcd documentation).
> */
> -static celix_status_t
> etcdWatcher_addAlreadyExistingWatchpoints(endpoint_discovery_poller_pt
> poller, int* highestModified) {
> +static celix_status_t
> etcdWatcher_addAlreadyExistingWatchpoints(discovery_pt discovery, int*
> highestModified) {
> celix_status_t status = CELIX_SUCCESS;
> char** nodeArr = calloc(MAX_NODES, sizeof(*nodeArr));
> char rootPath[MAX_ROOTNODE_LENGTH];
> @@ -108,7 +116,7 @@ static celix_status_t etcdWatcher_addAlr
> }
>
> // we need to go though all nodes and get the highest modifiedIndex
> - if (((status = etcdWatcher_getRootPath(&rootPath[0])) ==
> CELIX_SUCCESS) &&
> + if (((status = etcdWatcher_getRootPath(discovery->context,
> &rootPath[0])) == CELIX_SUCCESS) &&
> (etcd_getNodes(rootPath, nodeArr, &size) == true)) {
> for (i = 0; i < size; i++) {
> char* key = nodeArr[i];
> @@ -118,7 +126,7 @@ static celix_status_t etcdWatcher_addAlr
>
> if (etcd_get(key, &value[0], &action[0],
> &modIndex) == true) {
> // check that this is not equals to the
> local endpoint
> -
> endpointDiscoveryPoller_addDiscoveryEndpoint(poller, strdup(&value[0]));
> +
> endpointDiscoveryPoller_addDiscoveryEndpoint(discovery->poller,
> strdup(&value[0]));
>
> if (modIndex > *highestModified) {
> *highestModified = modIndex;
> @@ -193,8 +201,11 @@ static void* etcdWatcher_run(void* data)
> static char rootPath[MAX_ROOTNODE_LENGTH];
> int highestModified = 0;
>
> - etcdWatcher_addAlreadyExistingWatchpoints(watcher->poller,
> &highestModified);
> - etcdWatcher_getRootPath(&rootPath[0]);
> + bundle_context_pt context = watcher->discovery->context;
> + endpoint_discovery_poller_pt poller = watcher->discovery->poller;
> +
> + etcdWatcher_addAlreadyExistingWatchpoints(watcher->discovery,
> &highestModified);
> + etcdWatcher_getRootPath(context, &rootPath[0]);
>
> while (watcher->running) {
> char value[MAX_VALUE_LENGTH];
> @@ -204,16 +215,16 @@ static void* etcdWatcher_run(void* data)
> if (etcd_watch(rootPath, highestModified + 1, &action[0],
> &preValue[0], &value[0]) == true) {
>
> if (strcmp(action, "set") == 0) {
> -
> endpointDiscoveryPoller_removeDiscoveryEndpoint(watcher->poller,
> &preValue[0]);
> -
> endpointDiscoveryPoller_addDiscoveryEndpoint(watcher->poller, &value[0]);
> +
> endpointDiscoveryPoller_removeDiscoveryEndpoint(poller, &preValue[0]);
> +
> endpointDiscoveryPoller_addDiscoveryEndpoint(poller, &value[0]);
> } else if (strcmp(action, "delete") == 0) {
> -
> endpointDiscoveryPoller_removeDiscoveryEndpoint(watcher->poller,
> &preValue[0]);
> +
> endpointDiscoveryPoller_removeDiscoveryEndpoint(poller, &preValue[0]);
> } else {
> fw_log(logger, OSGI_FRAMEWORK_LOG_INFO,
> "Unexpected action: %s", action);
> }
> }
> // update own framework uuid in any case;
> - etcdWatcher_addOwnFramework(watcher->context);
> + etcdWatcher_addOwnFramework(context);
> }
>
> return NULL;
> @@ -223,7 +234,7 @@ static void* etcdWatcher_run(void* data)
> * the ectdWatcher needs to have access to the endpoint_discovery_poller
> and therefore is only
> * allowed to be created after the endpoint_discovery_poller
> */
> -celix_status_t etcdWatcher_create(endpoint_discovery_poller_pt poller,
> bundle_context_pt context,
> +celix_status_t etcdWatcher_create(discovery_pt discovery,
> bundle_context_pt context,
> etcd_watcher_pt *watcher)
> {
> celix_status_t status = CELIX_SUCCESS;
> @@ -232,7 +243,7 @@ celix_status_t etcdWatcher_create(endpoi
> char* etcd_port_string = NULL;
> int etcd_port = 0;
>
> - if (poller == NULL) {
> + if (discovery == NULL) {
> return CELIX_BUNDLE_EXCEPTION;
> }
>
> @@ -242,8 +253,7 @@ celix_status_t etcdWatcher_create(endpoi
> }
> else
> {
> - (*watcher)->poller = poller;
> - (*watcher)->context = context;
> + (*watcher)->discovery = discovery;
> }
>
> if ((bundleContext_getProperty(context, CFG_ETCD_SERVER_IP,
> &etcd_server) != CELIX_SUCCESS) || !etcd_server) {
> @@ -263,8 +273,6 @@ celix_status_t etcdWatcher_create(endpoi
> }
> }
>
> -
> -
> if (etcd_init(etcd_server, etcd_port) == false)
> {
> return CELIX_BUNDLE_EXCEPTION;
> @@ -302,7 +310,8 @@ celix_status_t etcdWatcher_destroy(etcd_
> celixThread_join(watcher->watcherThread, NULL);
>
> // register own framework
> - if ((status = etcdWatcher_getLocalNodePath(watcher->context,
> &localNodePath[0])) != CELIX_SUCCESS) {
> + if ((status = etcdWatcher_getLocalNodePath(
> + watcher->discovery->context, &localNodePath[0]))
> != CELIX_SUCCESS) {
> return status;
> }
>
>
>
>
--
Met vriendelijke groet,
Alexander Broekhuis
Re: svn commit: r1632480 - in /celix/trunk/remote_services/discovery_etcd/private/src:
discovery_impl.c etcd_watcher.c
Posted by Alexander Broekhuis <a....@gmail.com>.
2014-10-17 9:25 GMT-04:00 Bjoern Petri <bj...@sundevil.de>:
>
> Ah - sorry, I just see that you refer to the commit from this morning. A
> minute before I saw your mail, I committed some more changes which also
> seems to fix this issue (at least I cannot reproduce it). I was already
> wondering how fast you are checking commits :).
Not that fast ;). Though I try to keep up.
I'll take a look at that last commit. Thanks for the response.
--
Met vriendelijke groet,
Alexander Broekhuis
Re: svn commit: r1632480 - in /celix/trunk/remote_services/discovery_etcd/private/src: discovery_impl.c etcd_watcher.c
Posted by Bjoern Petri <bj...@sundevil.de>.
Ah - sorry, I just see that you refer to the commit from this morning. A
minute before I saw your mail, I committed some more changes which also
seems to fix this issue (at least I cannot reproduce it). I was already
wondering how fast you are checking commits :).
Regards,
Bjoern
On 2014-10-17 15:05, Alexander Broekhuis wrote:
> Hi Bjoern,
>
> I think you forgot to add a file to the commit. It is not building for
> me:
>
> remote_services/discovery_etcd/private/src/etcd_watcher.c:237:16:
> error:
> conflicting types for ‘etcdWatcher_create’
> celix_status_t etcdWatcher_create(discovery_pt discovery,
> bundle_context_pt
> context,
>
> remote_services/discovery_etcd/private/include/etcd_watcher.h:36:16:
> note:
> previous declaration of ‘etcdWatcher_create’ was here
> celix_status_t etcdWatcher_create(endpoint_discovery_poller_pt poller,
> bundle_context_pt context, etcd_watcher_pt *watcher);
>
>
> 2014-10-17 3:16 GMT-04:00 <bp...@apache.org>:
>
>> Author: bpetri
>> Date: Fri Oct 17 07:16:29 2014
>> New Revision: 1632480
>>
>> URL: http://svn.apache.org/r1632480
>> Log:
>> CELIX-168: Added new property DISCOVERY_ETCD_ROOT_PATH, which allows
>> to
>> change the etcd root path
>>
>> Modified:
>>
>> celix/trunk/remote_services/discovery_etcd/private/src/discovery_impl.c
>>
>> celix/trunk/remote_services/discovery_etcd/private/src/etcd_watcher.c
>>
>> Modified:
>> celix/trunk/remote_services/discovery_etcd/private/src/discovery_impl.c
>> URL:
>> http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery_etcd/private/src/discovery_impl.c?rev=1632480&r1=1632479&r2=1632480&view=diff
>>
>> ==============================================================================
>> ---
>> celix/trunk/remote_services/discovery_etcd/private/src/discovery_impl.c
>> (original)
>> +++
>> celix/trunk/remote_services/discovery_etcd/private/src/discovery_impl.c
>> Fri
>> Oct 17 07:16:29 2014
>> @@ -124,12 +124,12 @@ celix_status_t discovery_start(discovery
>> return CELIX_BUNDLE_EXCEPTION;
>> }
>>
>> - status = etcdWatcher_create(discovery->poller,
>> discovery->context,
>> &discovery->watcher);
>> + status = endpointDiscoveryServer_create(discovery,
>> discovery->context, &discovery->server);
>> if (status != CELIX_SUCCESS) {
>> - return CELIX_BUNDLE_EXCEPTION;
>> + return CELIX_BUNDLE_EXCEPTION;
>> }
>>
>> - status = endpointDiscoveryServer_create(discovery,
>> discovery->context, &discovery->server);
>> + status = etcdWatcher_create(discovery, discovery->context,
>> &discovery->watcher);
>> if (status != CELIX_SUCCESS) {
>> return CELIX_BUNDLE_EXCEPTION;
>> }
>> @@ -140,12 +140,12 @@ celix_status_t discovery_start(discovery
>> celix_status_t discovery_stop(discovery_pt discovery) {
>> celix_status_t status;
>>
>> - status = endpointDiscoveryServer_destroy(discovery->server);
>> + status = etcdWatcher_destroy(discovery->watcher);
>> if (status != CELIX_SUCCESS) {
>> return CELIX_BUNDLE_EXCEPTION;
>> }
>>
>> - status = etcdWatcher_destroy(discovery->watcher);
>> + status = endpointDiscoveryServer_destroy(discovery->server);
>> if (status != CELIX_SUCCESS) {
>> return CELIX_BUNDLE_EXCEPTION;
>> }
>>
>> Modified:
>> celix/trunk/remote_services/discovery_etcd/private/src/etcd_watcher.c
>> URL:
>> http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery_etcd/private/src/etcd_watcher.c?rev=1632480&r1=1632479&r2=1632480&view=diff
>>
>> ==============================================================================
>> ---
>> celix/trunk/remote_services/discovery_etcd/private/src/etcd_watcher.c
>> (original)
>> +++
>> celix/trunk/remote_services/discovery_etcd/private/src/etcd_watcher.c
>> Fri Oct 17 07:16:29 2014
>> @@ -38,8 +38,7 @@
>> #include "endpoint_discovery_poller.h"
>>
>> struct etcd_watcher {
>> - endpoint_discovery_poller_pt poller;
>> - bundle_context_pt context;
>> + discovery_pt discovery;
>>
>> celix_thread_mutex_t watcherLock;
>> celix_thread_t watcherThread;
>> @@ -47,6 +46,9 @@ struct etcd_watcher {
>> volatile bool running;
>> };
>>
>> +#define CFG_ETCD_ROOT_PATH "DISCOVERY_ETCD_ROOT_PATH"
>> +#define DEFAULT_ETCD_ROOTPATH "discovery"
>> +
>> #define CFG_ETCD_SERVER_IP "DISCOVERY_ETCD_SERVER_IP"
>> #define DEFAULT_ETCD_SERVER_IP "127.0.0.1"
>>
>> @@ -59,10 +61,16 @@ struct etcd_watcher {
>>
>>
>> // note that the rootNode shouldn't have a leading slash
>> -static celix_status_t etcdWatcher_getRootPath(char* rootNode) {
>> +static celix_status_t etcdWatcher_getRootPath(bundle_context_pt
>> context,
>> char* rootNode) {
>> celix_status_t status = CELIX_SUCCESS;
>> + char* rootPath = NULL;
>>
>> - strcpy(rootNode, "discovery");
>> + if (((bundleContext_getProperty(context, CFG_ETCD_ROOT_PATH,
>> &rootPath)) != CELIX_SUCCESS) || (!rootPath)) {
>> + strcpy(rootNode, DEFAULT_ETCD_ROOTPATH);
>> + }
>> + else {
>> + strcpy(rootNode, rootPath);
>> + }
>>
>> return status;
>> }
>> @@ -73,7 +81,7 @@ static celix_status_t etcdWatcher_getLoc
>> char rootPath[MAX_ROOTNODE_LENGTH];
>> char* uuid = NULL;
>>
>> - if (((etcdWatcher_getRootPath(&rootPath[0]) != CELIX_SUCCESS)) ||
>> (!rootPath)) {
>> + if ((etcdWatcher_getRootPath(context, &rootPath[0]) !=
>> CELIX_SUCCESS)) {
>> status = CELIX_ILLEGAL_STATE;
>> }
>> else if (((bundleContext_getProperty(context,
>> OSGI_FRAMEWORK_FRAMEWORK_UUID, &uuid)) != CELIX_SUCCESS) || (!uuid)) {
>> @@ -95,7 +103,7 @@ static celix_status_t etcdWatcher_getLoc
>> * returns the modifiedIndex of the last modified
>> * discovery endpoint (see etcd documentation).
>> */
>> -static celix_status_t
>> etcdWatcher_addAlreadyExistingWatchpoints(endpoint_discovery_poller_pt
>> poller, int* highestModified) {
>> +static celix_status_t
>> etcdWatcher_addAlreadyExistingWatchpoints(discovery_pt discovery, int*
>> highestModified) {
>> celix_status_t status = CELIX_SUCCESS;
>> char** nodeArr = calloc(MAX_NODES, sizeof(*nodeArr));
>> char rootPath[MAX_ROOTNODE_LENGTH];
>> @@ -108,7 +116,7 @@ static celix_status_t etcdWatcher_addAlr
>> }
>>
>> // we need to go though all nodes and get the highest
>> modifiedIndex
>> - if (((status = etcdWatcher_getRootPath(&rootPath[0])) ==
>> CELIX_SUCCESS) &&
>> + if (((status = etcdWatcher_getRootPath(discovery->context,
>> &rootPath[0])) == CELIX_SUCCESS) &&
>> (etcd_getNodes(rootPath, nodeArr, &size) == true)) {
>> for (i = 0; i < size; i++) {
>> char* key = nodeArr[i];
>> @@ -118,7 +126,7 @@ static celix_status_t etcdWatcher_addAlr
>>
>> if (etcd_get(key, &value[0], &action[0],
>> &modIndex) == true) {
>> // check that this is not equals to
>> the
>> local endpoint
>> -
>> endpointDiscoveryPoller_addDiscoveryEndpoint(poller,
>> strdup(&value[0]));
>> +
>> endpointDiscoveryPoller_addDiscoveryEndpoint(discovery->poller,
>> strdup(&value[0]));
>>
>> if (modIndex > *highestModified) {
>> *highestModified = modIndex;
>> @@ -193,8 +201,11 @@ static void* etcdWatcher_run(void* data)
>> static char rootPath[MAX_ROOTNODE_LENGTH];
>> int highestModified = 0;
>>
>> - etcdWatcher_addAlreadyExistingWatchpoints(watcher->poller,
>> &highestModified);
>> - etcdWatcher_getRootPath(&rootPath[0]);
>> + bundle_context_pt context = watcher->discovery->context;
>> + endpoint_discovery_poller_pt poller =
>> watcher->discovery->poller;
>> +
>> + etcdWatcher_addAlreadyExistingWatchpoints(watcher->discovery,
>> &highestModified);
>> + etcdWatcher_getRootPath(context, &rootPath[0]);
>>
>> while (watcher->running) {
>> char value[MAX_VALUE_LENGTH];
>> @@ -204,16 +215,16 @@ static void* etcdWatcher_run(void* data)
>> if (etcd_watch(rootPath, highestModified + 1,
>> &action[0],
>> &preValue[0], &value[0]) == true) {
>>
>> if (strcmp(action, "set") == 0) {
>> -
>> endpointDiscoveryPoller_removeDiscoveryEndpoint(watcher->poller,
>> &preValue[0]);
>> -
>> endpointDiscoveryPoller_addDiscoveryEndpoint(watcher->poller,
>> &value[0]);
>> +
>> endpointDiscoveryPoller_removeDiscoveryEndpoint(poller,
>> &preValue[0]);
>> +
>> endpointDiscoveryPoller_addDiscoveryEndpoint(poller, &value[0]);
>> } else if (strcmp(action, "delete") == 0) {
>> -
>> endpointDiscoveryPoller_removeDiscoveryEndpoint(watcher->poller,
>> &preValue[0]);
>> +
>> endpointDiscoveryPoller_removeDiscoveryEndpoint(poller,
>> &preValue[0]);
>> } else {
>> fw_log(logger,
>> OSGI_FRAMEWORK_LOG_INFO,
>> "Unexpected action: %s", action);
>> }
>> }
>> // update own framework uuid in any case;
>> - etcdWatcher_addOwnFramework(watcher->context);
>> + etcdWatcher_addOwnFramework(context);
>> }
>>
>> return NULL;
>> @@ -223,7 +234,7 @@ static void* etcdWatcher_run(void* data)
>> * the ectdWatcher needs to have access to the
>> endpoint_discovery_poller
>> and therefore is only
>> * allowed to be created after the endpoint_discovery_poller
>> */
>> -celix_status_t etcdWatcher_create(endpoint_discovery_poller_pt
>> poller,
>> bundle_context_pt context,
>> +celix_status_t etcdWatcher_create(discovery_pt discovery,
>> bundle_context_pt context,
>> etcd_watcher_pt *watcher)
>> {
>> celix_status_t status = CELIX_SUCCESS;
>> @@ -232,7 +243,7 @@ celix_status_t etcdWatcher_create(endpoi
>> char* etcd_port_string = NULL;
>> int etcd_port = 0;
>>
>> - if (poller == NULL) {
>> + if (discovery == NULL) {
>> return CELIX_BUNDLE_EXCEPTION;
>> }
>>
>> @@ -242,8 +253,7 @@ celix_status_t etcdWatcher_create(endpoi
>> }
>> else
>> {
>> - (*watcher)->poller = poller;
>> - (*watcher)->context = context;
>> + (*watcher)->discovery = discovery;
>> }
>>
>> if ((bundleContext_getProperty(context, CFG_ETCD_SERVER_IP,
>> &etcd_server) != CELIX_SUCCESS) || !etcd_server) {
>> @@ -263,8 +273,6 @@ celix_status_t etcdWatcher_create(endpoi
>> }
>> }
>>
>> -
>> -
>> if (etcd_init(etcd_server, etcd_port) == false)
>> {
>> return CELIX_BUNDLE_EXCEPTION;
>> @@ -302,7 +310,8 @@ celix_status_t etcdWatcher_destroy(etcd_
>> celixThread_join(watcher->watcherThread, NULL);
>>
>> // register own framework
>> - if ((status = etcdWatcher_getLocalNodePath(watcher->context,
>> &localNodePath[0])) != CELIX_SUCCESS) {
>> + if ((status = etcdWatcher_getLocalNodePath(
>> + watcher->discovery->context,
>> &localNodePath[0]))
>> != CELIX_SUCCESS) {
>> return status;
>> }
>>
>>
>>
>>
Re: svn commit: r1632480 - in /celix/trunk/remote_services/discovery_etcd/private/src:
discovery_impl.c etcd_watcher.c
Posted by Alexander Broekhuis <a....@gmail.com>.
2014-10-17 9:22 GMT-04:00 Bjoern Petri <bj...@sundevil.de>:
>
>
> Hi Alexander,
>
> Currently, I cannot find the problem. The etcd_watcher.h should not
> contain the function signature shown in the error message any more. Could
> you do me the favor and shortly check whether the etcd_watcher.h (rev
> 1632567) still contains this?
>
I'll take a look, perhaps I'm somewhere in between 2 commits. I thought I
had updated, but might be due to network issues here.
--
Met vriendelijke groet,
Alexander Broekhuis
Re: svn commit: r1632480 - in /celix/trunk/remote_services/discovery_etcd/private/src: discovery_impl.c etcd_watcher.c
Posted by Bjoern Petri <bj...@sundevil.de>.
Hi Alexander,
Currently, I cannot find the problem. The etcd_watcher.h should not
contain the function signature shown in the error message any more.
Could you do me the favor and shortly check whether the etcd_watcher.h
(rev 1632567) still contains this?
Regards,
Bjoern
On 2014-10-17 15:05, Alexander Broekhuis wrote:
> Hi Bjoern,
>
> I think you forgot to add a file to the commit. It is not building for
> me:
>
> remote_services/discovery_etcd/private/src/etcd_watcher.c:237:16:
> error:
> conflicting types for ‘etcdWatcher_create’
> celix_status_t etcdWatcher_create(discovery_pt discovery,
> bundle_context_pt
> context,
>
> remote_services/discovery_etcd/private/include/etcd_watcher.h:36:16:
> note:
> previous declaration of ‘etcdWatcher_create’ was here
> celix_status_t etcdWatcher_create(endpoint_discovery_poller_pt poller,
> bundle_context_pt context, etcd_watcher_pt *watcher);
>
>
> 2014-10-17 3:16 GMT-04:00 <bp...@apache.org>:
>
>> Author: bpetri
>> Date: Fri Oct 17 07:16:29 2014
>> New Revision: 1632480
>>
>> URL: http://svn.apache.org/r1632480
>> Log:
>> CELIX-168: Added new property DISCOVERY_ETCD_ROOT_PATH, which allows
>> to
>> change the etcd root path
>>
>> Modified:
>>
>> celix/trunk/remote_services/discovery_etcd/private/src/discovery_impl.c
>>
>> celix/trunk/remote_services/discovery_etcd/private/src/etcd_watcher.c
>>
>> Modified:
>> celix/trunk/remote_services/discovery_etcd/private/src/discovery_impl.c
>> URL:
>> http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery_etcd/private/src/discovery_impl.c?rev=1632480&r1=1632479&r2=1632480&view=diff
>>
>> ==============================================================================
>> ---
>> celix/trunk/remote_services/discovery_etcd/private/src/discovery_impl.c
>> (original)
>> +++
>> celix/trunk/remote_services/discovery_etcd/private/src/discovery_impl.c
>> Fri
>> Oct 17 07:16:29 2014
>> @@ -124,12 +124,12 @@ celix_status_t discovery_start(discovery
>> return CELIX_BUNDLE_EXCEPTION;
>> }
>>
>> - status = etcdWatcher_create(discovery->poller,
>> discovery->context,
>> &discovery->watcher);
>> + status = endpointDiscoveryServer_create(discovery,
>> discovery->context, &discovery->server);
>> if (status != CELIX_SUCCESS) {
>> - return CELIX_BUNDLE_EXCEPTION;
>> + return CELIX_BUNDLE_EXCEPTION;
>> }
>>
>> - status = endpointDiscoveryServer_create(discovery,
>> discovery->context, &discovery->server);
>> + status = etcdWatcher_create(discovery, discovery->context,
>> &discovery->watcher);
>> if (status != CELIX_SUCCESS) {
>> return CELIX_BUNDLE_EXCEPTION;
>> }
>> @@ -140,12 +140,12 @@ celix_status_t discovery_start(discovery
>> celix_status_t discovery_stop(discovery_pt discovery) {
>> celix_status_t status;
>>
>> - status = endpointDiscoveryServer_destroy(discovery->server);
>> + status = etcdWatcher_destroy(discovery->watcher);
>> if (status != CELIX_SUCCESS) {
>> return CELIX_BUNDLE_EXCEPTION;
>> }
>>
>> - status = etcdWatcher_destroy(discovery->watcher);
>> + status = endpointDiscoveryServer_destroy(discovery->server);
>> if (status != CELIX_SUCCESS) {
>> return CELIX_BUNDLE_EXCEPTION;
>> }
>>
>> Modified:
>> celix/trunk/remote_services/discovery_etcd/private/src/etcd_watcher.c
>> URL:
>> http://svn.apache.org/viewvc/celix/trunk/remote_services/discovery_etcd/private/src/etcd_watcher.c?rev=1632480&r1=1632479&r2=1632480&view=diff
>>
>> ==============================================================================
>> ---
>> celix/trunk/remote_services/discovery_etcd/private/src/etcd_watcher.c
>> (original)
>> +++
>> celix/trunk/remote_services/discovery_etcd/private/src/etcd_watcher.c
>> Fri Oct 17 07:16:29 2014
>> @@ -38,8 +38,7 @@
>> #include "endpoint_discovery_poller.h"
>>
>> struct etcd_watcher {
>> - endpoint_discovery_poller_pt poller;
>> - bundle_context_pt context;
>> + discovery_pt discovery;
>>
>> celix_thread_mutex_t watcherLock;
>> celix_thread_t watcherThread;
>> @@ -47,6 +46,9 @@ struct etcd_watcher {
>> volatile bool running;
>> };
>>
>> +#define CFG_ETCD_ROOT_PATH "DISCOVERY_ETCD_ROOT_PATH"
>> +#define DEFAULT_ETCD_ROOTPATH "discovery"
>> +
>> #define CFG_ETCD_SERVER_IP "DISCOVERY_ETCD_SERVER_IP"
>> #define DEFAULT_ETCD_SERVER_IP "127.0.0.1"
>>
>> @@ -59,10 +61,16 @@ struct etcd_watcher {
>>
>>
>> // note that the rootNode shouldn't have a leading slash
>> -static celix_status_t etcdWatcher_getRootPath(char* rootNode) {
>> +static celix_status_t etcdWatcher_getRootPath(bundle_context_pt
>> context,
>> char* rootNode) {
>> celix_status_t status = CELIX_SUCCESS;
>> + char* rootPath = NULL;
>>
>> - strcpy(rootNode, "discovery");
>> + if (((bundleContext_getProperty(context, CFG_ETCD_ROOT_PATH,
>> &rootPath)) != CELIX_SUCCESS) || (!rootPath)) {
>> + strcpy(rootNode, DEFAULT_ETCD_ROOTPATH);
>> + }
>> + else {
>> + strcpy(rootNode, rootPath);
>> + }
>>
>> return status;
>> }
>> @@ -73,7 +81,7 @@ static celix_status_t etcdWatcher_getLoc
>> char rootPath[MAX_ROOTNODE_LENGTH];
>> char* uuid = NULL;
>>
>> - if (((etcdWatcher_getRootPath(&rootPath[0]) != CELIX_SUCCESS)) ||
>> (!rootPath)) {
>> + if ((etcdWatcher_getRootPath(context, &rootPath[0]) !=
>> CELIX_SUCCESS)) {
>> status = CELIX_ILLEGAL_STATE;
>> }
>> else if (((bundleContext_getProperty(context,
>> OSGI_FRAMEWORK_FRAMEWORK_UUID, &uuid)) != CELIX_SUCCESS) || (!uuid)) {
>> @@ -95,7 +103,7 @@ static celix_status_t etcdWatcher_getLoc
>> * returns the modifiedIndex of the last modified
>> * discovery endpoint (see etcd documentation).
>> */
>> -static celix_status_t
>> etcdWatcher_addAlreadyExistingWatchpoints(endpoint_discovery_poller_pt
>> poller, int* highestModified) {
>> +static celix_status_t
>> etcdWatcher_addAlreadyExistingWatchpoints(discovery_pt discovery, int*
>> highestModified) {
>> celix_status_t status = CELIX_SUCCESS;
>> char** nodeArr = calloc(MAX_NODES, sizeof(*nodeArr));
>> char rootPath[MAX_ROOTNODE_LENGTH];
>> @@ -108,7 +116,7 @@ static celix_status_t etcdWatcher_addAlr
>> }
>>
>> // we need to go though all nodes and get the highest
>> modifiedIndex
>> - if (((status = etcdWatcher_getRootPath(&rootPath[0])) ==
>> CELIX_SUCCESS) &&
>> + if (((status = etcdWatcher_getRootPath(discovery->context,
>> &rootPath[0])) == CELIX_SUCCESS) &&
>> (etcd_getNodes(rootPath, nodeArr, &size) == true)) {
>> for (i = 0; i < size; i++) {
>> char* key = nodeArr[i];
>> @@ -118,7 +126,7 @@ static celix_status_t etcdWatcher_addAlr
>>
>> if (etcd_get(key, &value[0], &action[0],
>> &modIndex) == true) {
>> // check that this is not equals to
>> the
>> local endpoint
>> -
>> endpointDiscoveryPoller_addDiscoveryEndpoint(poller,
>> strdup(&value[0]));
>> +
>> endpointDiscoveryPoller_addDiscoveryEndpoint(discovery->poller,
>> strdup(&value[0]));
>>
>> if (modIndex > *highestModified) {
>> *highestModified = modIndex;
>> @@ -193,8 +201,11 @@ static void* etcdWatcher_run(void* data)
>> static char rootPath[MAX_ROOTNODE_LENGTH];
>> int highestModified = 0;
>>
>> - etcdWatcher_addAlreadyExistingWatchpoints(watcher->poller,
>> &highestModified);
>> - etcdWatcher_getRootPath(&rootPath[0]);
>> + bundle_context_pt context = watcher->discovery->context;
>> + endpoint_discovery_poller_pt poller =
>> watcher->discovery->poller;
>> +
>> + etcdWatcher_addAlreadyExistingWatchpoints(watcher->discovery,
>> &highestModified);
>> + etcdWatcher_getRootPath(context, &rootPath[0]);
>>
>> while (watcher->running) {
>> char value[MAX_VALUE_LENGTH];
>> @@ -204,16 +215,16 @@ static void* etcdWatcher_run(void* data)
>> if (etcd_watch(rootPath, highestModified + 1,
>> &action[0],
>> &preValue[0], &value[0]) == true) {
>>
>> if (strcmp(action, "set") == 0) {
>> -
>> endpointDiscoveryPoller_removeDiscoveryEndpoint(watcher->poller,
>> &preValue[0]);
>> -
>> endpointDiscoveryPoller_addDiscoveryEndpoint(watcher->poller,
>> &value[0]);
>> +
>> endpointDiscoveryPoller_removeDiscoveryEndpoint(poller,
>> &preValue[0]);
>> +
>> endpointDiscoveryPoller_addDiscoveryEndpoint(poller, &value[0]);
>> } else if (strcmp(action, "delete") == 0) {
>> -
>> endpointDiscoveryPoller_removeDiscoveryEndpoint(watcher->poller,
>> &preValue[0]);
>> +
>> endpointDiscoveryPoller_removeDiscoveryEndpoint(poller,
>> &preValue[0]);
>> } else {
>> fw_log(logger,
>> OSGI_FRAMEWORK_LOG_INFO,
>> "Unexpected action: %s", action);
>> }
>> }
>> // update own framework uuid in any case;
>> - etcdWatcher_addOwnFramework(watcher->context);
>> + etcdWatcher_addOwnFramework(context);
>> }
>>
>> return NULL;
>> @@ -223,7 +234,7 @@ static void* etcdWatcher_run(void* data)
>> * the ectdWatcher needs to have access to the
>> endpoint_discovery_poller
>> and therefore is only
>> * allowed to be created after the endpoint_discovery_poller
>> */
>> -celix_status_t etcdWatcher_create(endpoint_discovery_poller_pt
>> poller,
>> bundle_context_pt context,
>> +celix_status_t etcdWatcher_create(discovery_pt discovery,
>> bundle_context_pt context,
>> etcd_watcher_pt *watcher)
>> {
>> celix_status_t status = CELIX_SUCCESS;
>> @@ -232,7 +243,7 @@ celix_status_t etcdWatcher_create(endpoi
>> char* etcd_port_string = NULL;
>> int etcd_port = 0;
>>
>> - if (poller == NULL) {
>> + if (discovery == NULL) {
>> return CELIX_BUNDLE_EXCEPTION;
>> }
>>
>> @@ -242,8 +253,7 @@ celix_status_t etcdWatcher_create(endpoi
>> }
>> else
>> {
>> - (*watcher)->poller = poller;
>> - (*watcher)->context = context;
>> + (*watcher)->discovery = discovery;
>> }
>>
>> if ((bundleContext_getProperty(context, CFG_ETCD_SERVER_IP,
>> &etcd_server) != CELIX_SUCCESS) || !etcd_server) {
>> @@ -263,8 +273,6 @@ celix_status_t etcdWatcher_create(endpoi
>> }
>> }
>>
>> -
>> -
>> if (etcd_init(etcd_server, etcd_port) == false)
>> {
>> return CELIX_BUNDLE_EXCEPTION;
>> @@ -302,7 +310,8 @@ celix_status_t etcdWatcher_destroy(etcd_
>> celixThread_join(watcher->watcherThread, NULL);
>>
>> // register own framework
>> - if ((status = etcdWatcher_getLocalNodePath(watcher->context,
>> &localNodePath[0])) != CELIX_SUCCESS) {
>> + if ((status = etcdWatcher_getLocalNodePath(
>> + watcher->discovery->context,
>> &localNodePath[0]))
>> != CELIX_SUCCESS) {
>> return status;
>> }
>>
>>
>>
>>