forked from netdata/netdata
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Streaming Improvements No 5 (netdata#19193)
* rrdhost state id is now used to detect not available functions * acquire release for rrdhost state * initialize rddhost state for local hosts * track send misses * log for functions that return 503 * fix rrd_collector_finished() call from stream threads
- Loading branch information
Showing
16 changed files
with
182 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#include "rrdhost-state-id.h" | ||
#include "rrd.h" | ||
|
||
RRDHOST_STATE rrdhost_state_id(struct rrdhost *host) { | ||
return __atomic_load_n(&host->state_id, __ATOMIC_RELAXED); | ||
} | ||
|
||
bool rrdhost_state_connected(RRDHOST *host) { | ||
__atomic_add_fetch(&host->state_id, 1, __ATOMIC_RELAXED); | ||
|
||
int32_t expected = __atomic_load_n(&host->state_refcount, __ATOMIC_RELAXED); | ||
int32_t desired; | ||
|
||
do { | ||
if(expected >= 0) { | ||
internal_fatal(true, "Cannot get the node connected"); | ||
return false; | ||
} | ||
|
||
desired = 0; | ||
|
||
} while(!__atomic_compare_exchange_n( | ||
&host->state_refcount, &expected, desired, false, __ATOMIC_RELAXED, __ATOMIC_RELAXED)); | ||
|
||
return true; | ||
} | ||
|
||
bool rrdhost_state_disconnected(RRDHOST *host) { | ||
__atomic_add_fetch(&host->state_id, 1, __ATOMIC_RELAXED); | ||
|
||
int32_t expected = __atomic_load_n(&host->state_refcount, __ATOMIC_RELAXED); | ||
int32_t desired; | ||
|
||
do { | ||
if(expected < 0) { | ||
internal_fatal(true, "Cannot get the node disconnected"); | ||
return false; | ||
} | ||
|
||
desired = -1; | ||
|
||
} while(!__atomic_compare_exchange_n( | ||
&host->state_refcount, &expected, desired, false, __ATOMIC_RELAXED, __ATOMIC_RELAXED)); | ||
|
||
return true; | ||
} | ||
|
||
bool rrdhost_state_acquire(RRDHOST *host, RRDHOST_STATE wanted_state_id) { | ||
int32_t expected = __atomic_load_n(&host->state_refcount, __ATOMIC_RELAXED); | ||
int32_t desired; | ||
|
||
do { | ||
if(expected < 0) | ||
return false; | ||
|
||
desired = expected + 1; | ||
|
||
} while(!__atomic_compare_exchange_n( | ||
&host->state_refcount, &expected, desired, false, __ATOMIC_RELAXED, __ATOMIC_RELAXED)); | ||
|
||
if(rrdhost_state_id(host) != wanted_state_id) { | ||
rrdhost_state_release(host); | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
void rrdhost_state_release(RRDHOST *host) { | ||
__atomic_sub_fetch(&host->state_refcount, 1, __ATOMIC_RELAXED); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#ifndef NETDATA_RRDHOST_STATE_ID_H | ||
#define NETDATA_RRDHOST_STATE_ID_H | ||
|
||
#include "libnetdata/libnetdata.h" | ||
|
||
typedef uint32_t RRDHOST_STATE; | ||
|
||
struct rrdhost; | ||
RRDHOST_STATE rrdhost_state_id(struct rrdhost *host); | ||
|
||
bool rrdhost_state_connected(struct rrdhost *host); | ||
bool rrdhost_state_disconnected(struct rrdhost *host); | ||
|
||
bool rrdhost_state_acquire(struct rrdhost *host, RRDHOST_STATE wanted_state_id); | ||
void rrdhost_state_release(struct rrdhost *host); | ||
|
||
#endif //NETDATA_RRDHOST_STATE_ID_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.