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

@@ -179,25 +179,23 @@ int ast_endpoint_add_channel(struct ast_endpoint *endpoint,
return 0;
}
/*! \brief Handler for channel snapshot cache clears */
/*! \brief Handler for channel snapshot update */
static void endpoint_cache_clear(void *data,
struct stasis_subscription *sub,
struct stasis_message *message)
{
struct ast_endpoint *endpoint = data;
struct stasis_message *clear_msg = stasis_message_data(message);
struct ast_channel_snapshot *clear_snapshot;
struct ast_channel_snapshot_update *update = stasis_message_data(message);
if (stasis_message_type(clear_msg) != ast_channel_snapshot_type()) {
/* Only when the channel is dead do we remove it */
if (!ast_test_flag(&update->new_snapshot->flags, AST_FLAG_DEAD)) {
return;
}
clear_snapshot = stasis_message_data(clear_msg);
ast_assert(endpoint != NULL);
ao2_lock(endpoint);
ast_str_container_remove(endpoint->channel_ids, clear_snapshot->uniqueid);
ast_str_container_remove(endpoint->channel_ids, update->new_snapshot->uniqueid);
ao2_unlock(endpoint);
endpoint_publish_snapshot(endpoint);
}
@@ -271,7 +269,7 @@ static struct ast_endpoint *endpoint_internal_create(const char *tech, const cha
return NULL;
}
r |= stasis_message_router_add(endpoint->router,
stasis_cache_clear_type(), endpoint_cache_clear,
ast_channel_snapshot_type(), endpoint_cache_clear,
endpoint);
r |= stasis_message_router_add(endpoint->router,
stasis_subscription_change_type(), endpoint_subscription_change,