Source
xxxxxxxxxx
if (NULL == (hpi = (zbx_dc_host_proxy_index_t *)zbx_hashset_search(&get_dc_config()->host_proxy_index, &hpi_local)))
/*
** Copyright (C) 2001-2024 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
ZBX_PTR_VECTOR_IMPL(pg_proxy_ptr, zbx_pg_proxy_t *)
ZBX_PTR_VECTOR_IMPL(pg_group_ptr, zbx_pg_group_t *)
ZBX_VECTOR_IMPL(pg_host, zbx_pg_host_t)
ZBX_VECTOR_IMPL(pg_host_ref_ptr, zbx_pg_host_ref_t *)
static zbx_hash_t pg_host_ref_hash(const void *d)
{
const zbx_pg_host_ref_t *host = (const zbx_pg_host_ref_t *)d;
return ZBX_DEFAULT_UINT64_HASH_FUNC(&host->host->hostid);
}
static int pg_host_ref_compare(const void *d1, const void *d2)
{
const zbx_pg_host_ref_t *h1 = (const zbx_pg_host_ref_t *)d1;
const zbx_pg_host_ref_t *h2 = (const zbx_pg_host_ref_t *)d2;
ZBX_RETURN_IF_NOT_EQUAL(h1->host->hostid, h2->host->hostid);
return 0;
}
/******************************************************************************
* *
* Purpose: sync proxy groups with configuration cache *
* *
* Parameters: sync - [IN] db synchronization data *
* revision - [IN] current sync revision *
* *
* Comments: The result contains the following fields: *
* 0 - proxy_groupid *
* 1 - failover_delay *
* 2 - min_online *
* *
******************************************************************************/
void dc_sync_proxy_group(zbx_dbsync_t *sync, zbx_uint64_t revision)
{
char **row;
zbx_uint64_t rowid;
unsigned char tag;
zbx_dc_proxy_group_t *pg;
int ret;
zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __func__);
zbx_dcsync_sync_start(sync, dbconfig_used_size());
while (SUCCEED == (ret = zbx_dbsync_next(sync, &rowid, &row, &tag)))
{
/* removed rows will be always added at the end */
if (ZBX_DBSYNC_ROW_REMOVE == tag)
break;
zbx_uint64_t proxy_groupid;
int found;
ZBX_STR2UINT64(proxy_groupid, row[0]);
pg = (zbx_dc_proxy_group_t *)DCfind_id(&get_dc_config()->proxy_groups, proxy_groupid,
sizeof(zbx_dc_proxy_group_t), &found);
dc_strpool_replace(found, &pg->failover_delay, row[1]);
dc_strpool_replace(found, &pg->min_online, row[2]);