<commit_before>#include "ShardHeartbeatManager.h"
#include "System/Events/EventLoop.h"
#include "Application/Common/ContextTransport.h"
#include "Application/Common/ClusterMessage.h"
#include "ShardServer.h"
#include "System/Config.h"

ShardHeartbeatManager::ShardHeartbeatManager()
{
    heartbeatTimeout.SetCallable(MFUNC(ShardHeartbeatManager, OnHeartbeatTimeout));
    heartbeatTimeout.SetDelay(HEARTBEAT_TIMEOUT);    
}

void ShardHeartbeatManager::Init(ShardServer* shardServer_)
{
    EventLoop::Add(&heartbeatTimeout);
    
    shardServer = shardServer_;
}

void ShardHeartbeatManager::OnHeartbeatTimeout()
{
    unsigned                httpPort;
    unsigned                sdbpPort;
    uint64_t*               itShardID;
    ShardQuorumProcessor*   itQuorumProcessor;
    ClusterMessage          msg;
    QuorumPaxosID           quorumPaxosID;
    List<QuorumPaxosID>     quorumPaxosIDList;
    List<QuorumShardInfo>   quorumShardInfos;
    QuorumShardInfo         quorumShardInfo;
    StorageShard*           storageShard;
    ConfigState*            configState;
    ConfigQuorum*           configQuorum;
    
    Log_Trace();
    
    EventLoop::Add(&heartbeatTimeout);
    
    if (CONTEXT_TRANSPORT->IsAwaitingNodeID())
    {
        Log_Trace("not sending heartbeat");
        return;
    }
    
//    configState = shardServer->GetConfigState();
//
//    ShardServer::QuorumProcessorList* quorumProcessors = shardServer->GetQuorumProcessors();
//    FOREACH(itQuorumProcessor, *quorumProcessors)
//    {
//        quorumPaxosID.quorumID = itQuorumProcessor->GetQuorumID();
//        quorumPaxosID.paxosID = itQuorumProcessor->GetPaxosID();
//        quorumPaxosIDList.Append(quorumPaxosID);
//        
//        configQuorum = configState->GetQuorum(itQuorumProcessor->GetQuorumID());
//        FOREACH(itShardID, configQuorum->shards)
//        {
//            storageShard = shardServer->GetDatabaseManager()->GetShard(*itShardID);
//            if (!storageShard)
//                continue;
//            
//            // quorumShardInfo is only sent for shards which have already been split
//            // and "regular" shards
//            
//            quorumShardInfo.quorumID = itQuorumProcessor->GetQuorumID();
//            quorumShardInfo.shardID = *itShardID;
//            quorumShardInfo.shardSize = storageShard->GetSize();
//            storageShard->GetMidpoint(quorumShardInfo.splitKey);
//            
//            quorumShardInfos.Append(quorumShardInfo);
//        }
//    }

    httpPort = shardServer->GetHTTPPort();
    sdbpPort = shardServer->GetSDBPPort();
    
    msg.Heartbeat(CONTEXT_TRANSPORT->GetSelfNodeID(),
     quorumPaxosIDList, quorumShardInfos, httpPort, sdbpPort);
    shardServer->BroadcastToControllers(msg);
}<commit_msg>Fixed bug where paxosIDs are not sent by the shard servers.<commit_after>#include "ShardHeartbeatManager.h"
#include "System/Events/EventLoop.h"
#include "Application/Common/ContextTransport.h"
#include "Application/Common/ClusterMessage.h"
#include "ShardServer.h"
#include "System/Config.h"

ShardHeartbeatManager::ShardHeartbeatManager()
{
    heartbeatTimeout.SetCallable(MFUNC(ShardHeartbeatManager, OnHeartbeatTimeout));
    heartbeatTimeout.SetDelay(HEARTBEAT_TIMEOUT);    
}

void ShardHeartbeatManager::Init(ShardServer* shardServer_)
{
    EventLoop::Add(&heartbeatTimeout);
    
    shardServer = shardServer_;
}

void ShardHeartbeatManager::OnHeartbeatTimeout()
{
    unsigned                httpPort;
    unsigned                sdbpPort;
    ShardQuorumProcessor*   itQuorumProcessor;
    ClusterMessage          msg;
    QuorumPaxosID           quorumPaxosID;
    List<QuorumPaxosID>     quorumPaxosIDList;
    List<QuorumShardInfo>   quorumShardInfos;
    QuorumShardInfo         quorumShardInfo;
    ConfigState*            configState;
//    ConfigQuorum*           configQuorum;
    
    Log_Trace();
    
    EventLoop::Add(&heartbeatTimeout);
    
    if (CONTEXT_TRANSPORT->IsAwaitingNodeID())
    {
        Log_Trace("not sending heartbeat");
        return;
    }
    
    configState = shardServer->GetConfigState();

    ShardServer::QuorumProcessorList* quorumProcessors = shardServer->GetQuorumProcessors();
    FOREACH(itQuorumProcessor, *quorumProcessors)
    {
        quorumPaxosID.quorumID = itQuorumProcessor->GetQuorumID();
        quorumPaxosID.paxosID = itQuorumProcessor->GetPaxosID();
        quorumPaxosIDList.Append(quorumPaxosID);
        
//        configQuorum = configState->GetQuorum(itQuorumProcessor->GetQuorumID());
//        FOREACH(itShardID, configQuorum->shards)
//        {
//            storageShard = shardServer->GetDatabaseManager()->GetShard(*itShardID);
//            if (!storageShard)
//                continue;
//            
//            // quorumShardInfo is only sent for shards which have already been split
//            // and "regular" shards
//            
//            quorumShardInfo.quorumID = itQuorumProcessor->GetQuorumID();
//            quorumShardInfo.shardID = *itShardID;
//            quorumShardInfo.shardSize = storageShard->GetSize();
//            storageShard->GetMidpoint(quorumShardInfo.splitKey);
//            
//            quorumShardInfos.Append(quorumShardInfo);
//        }
    }

    httpPort = shardServer->GetHTTPPort();
    sdbpPort = shardServer->GetSDBPPort();
    
    msg.Heartbeat(CONTEXT_TRANSPORT->GetSelfNodeID(),
     quorumPaxosIDList, quorumShardInfos, httpPort, sdbpPort);
    shardServer->BroadcastToControllers(msg);
}
{'fraction_non_alphanumeric': 0.10624434389140272, 'fraction_numerical': 0.00036199095022624434, 'mean_word_length': 2.7849315068493152, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6198009', 'n_tokens_mistral': 1757, 'n_tokens_neox': 1729, 'n_words': 224}