stasis: Use an implementation specific channel snapshot cache.

Channels no longer use the Stasis cache for channel snapshots. Instead
they are stored in a hash table in stasis_channels which reduces the
number of Stasis messages created and allows better storage.

As a result the following APIs are no longer available since the stasis
cache is no longer used:
ast_channel_topic_cached()
ast_channel_topic_all_cached()

The ast_channel_cache_all() and ast_channel_cache_by_name() functions
now return an ao2_container of ast_channel_snapshots rather than
a container of stasis_messages therefore you can't (and don't need
to) call stasis_cache functions on it.

The ast_channel_topic_all() function now returns a normal topic not
a cached one so you can't use stasis cache functions on it either.

The ast_channel_snapshot_type() stasis message now has the
ast_channel_snapshot_update structure as it's data. It contains the
last snapshot and the new one.

ast_channel_snapshot_get_latest() still returns the latest snapshot.

The latest snapshot is now stored on the channel itself to eliminate
cache hits when Stasis messages that have the snapshot as a payload
are created.

ASTERISK-28102

Change-Id: I9334febff60a82d7c39703e49059fa3a68825786
This commit is contained in:
Joshua Colp
2018-10-10 11:28:18 -03:00
parent 0a60bc1a68
commit d0ccbb3377
28 changed files with 456 additions and 551 deletions

View File

@@ -6250,7 +6250,7 @@ static int action_coreshowchannels(struct mansession *s, const struct message *m
int numchans = 0;
struct ao2_container *channels;
struct ao2_iterator it_chans;
struct stasis_message *msg;
struct ast_channel_snapshot *cs;
if (!ast_strlen_zero(actionid)) {
snprintf(idText, sizeof(idText), "ActionID: %s\r\n", actionid);
@@ -6258,17 +6258,12 @@ static int action_coreshowchannels(struct mansession *s, const struct message *m
idText[0] = '\0';
}
channels = stasis_cache_dump(ast_channel_cache_by_name(), ast_channel_snapshot_type());
if (!channels) {
astman_send_error(s, m, "Could not get cached channels");
return 0;
}
channels = ast_channel_cache_by_name();
astman_send_listack(s, m, "Channels will follow", "start");
it_chans = ao2_iterator_init(channels, 0);
for (; (msg = ao2_iterator_next(&it_chans)); ao2_ref(msg, -1)) {
struct ast_channel_snapshot *cs = stasis_message_data(msg);
for (; (cs = ao2_iterator_next(&it_chans)); ao2_ref(cs, -1)) {
struct ast_str *built = ast_manager_build_channel_state_string_prefix(cs, "");
char durbuf[16] = "";