<commit_before>/* -------------------------------------------------------------------------- */
/* Copyright 2002-2016, OpenNebula Project, OpenNebula Systems                */
/*                                                                            */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may    */
/* not use this file except in compliance with the License. You may obtain    */
/* a copy of the License at                                                   */
/*                                                                            */
/* http://www.apache.org/licenses/LICENSE-2.0                                 */
/*                                                                            */
/* Unless required by applicable law or agreed to in writing, software        */
/* distributed under the License is distributed on an "AS IS" BASIS,          */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   */
/* See the License for the specific language governing permissions and        */
/* limitations under the License.                                             */
/* -------------------------------------------------------------------------- */

#include "FedReplicaManager.h"
#include "ReplicaThread.h"
#include "Nebula.h"

/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

const char * FedReplicaManager::table = "fed_logdb";

const char * FedReplicaManager::db_names = "log_index, sql";

const char * FedReplicaManager::db_bootstrap = "CREATE TABLE IF NOT EXISTS "
        "fed_logdb (log_index INTEGER PRIMARY KEY, sql MEDIUMTEXT)";

const time_t FedReplicaManager::xmlrpc_timeout_ms = 2000;

/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

FedReplicaManager::FedReplicaManager(time_t _t, time_t _p, SqlDB * d,
    const std::string& l, bool s): ReplicaManager(), timer_period(_t),
    purge_period(_t), logdb(d), log_retention(l)
{
    Nebula& nd       = Nebula::instance();
    ZonePool * zpool = nd.get_zonepool();

    std::vector<int> zone_ids;
    vector<int>::iterator it;

    std::map<int, std::string> zone_servers;

    int zone_id = nd.get_zone_id();

    am.addListener(this);

    if ( zpool->list_zones(zone_ids) != 0 )
    {
        return;
    }

    for ( it = zone_ids.begin() ; it != zone_ids.end(); )
    {
        if ( *it == zone_id )
        {
            it = zone_ids.erase(it);
        }
        else
        {
            zpool->get_zone_servers(*it, zone_servers);

            ZoneServers * zs = new ZoneServers(*it, zone_servers);<commit_msg>F #4809: Fix timers in federation replica manager<commit_after>/* -------------------------------------------------------------------------- */
/* Copyright 2002-2016, OpenNebula Project, OpenNebula Systems                */
/*                                                                            */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may    */
/* not use this file except in compliance with the License. You may obtain    */
/* a copy of the License at                                                   */
/*                                                                            */
/* http://www.apache.org/licenses/LICENSE-2.0                                 */
/*                                                                            */
/* Unless required by applicable law or agreed to in writing, software        */
/* distributed under the License is distributed on an "AS IS" BASIS,          */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   */
/* See the License for the specific language governing permissions and        */
/* limitations under the License.                                             */
/* -------------------------------------------------------------------------- */

#include "FedReplicaManager.h"
#include "ReplicaThread.h"
#include "Nebula.h"

/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

const char * FedReplicaManager::table = "fed_logdb";

const char * FedReplicaManager::db_names = "log_index, sql";

const char * FedReplicaManager::db_bootstrap = "CREATE TABLE IF NOT EXISTS "
        "fed_logdb (log_index INTEGER PRIMARY KEY, sql MEDIUMTEXT)";

const time_t FedReplicaManager::xmlrpc_timeout_ms = 2000;

/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */

FedReplicaManager::FedReplicaManager(time_t _t, time_t _p, SqlDB * d,
    const std::string& l, bool s): ReplicaManager(), timer_period(_t),
    purge_period(_p), logdb(d), log_retention(l)
{
    Nebula& nd       = Nebula::instance();
    ZonePool * zpool = nd.get_zonepool();

    std::vector<int> zone_ids;
    vector<int>::iterator it;

    std::map<int, std::string> zone_servers;

    int zone_id = nd.get_zone_id();

    am.addListener(this);

    if ( zpool->list_zones(zone_ids) != 0 )
    {
        return;
    }

    for ( it = zone_ids.begin() ; it != zone_ids.end(); )
    {
        if ( *it == zone_id )
        {
            it = zone_ids.erase(it);
        }
        else
        {
            zpool->get_zone_servers(*it, zone_servers);

            ZoneServers * zs = new ZoneServers(*it, zone_servers);
{'fraction_non_alphanumeric': 0.25427350427350426, 'fraction_numerical': 0.006766381766381766, 'mean_word_length': 1.118024132730015, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4713506', 'n_tokens_mistral': 1330, 'n_tokens_neox': 1298, 'n_words': 354}