<commit_before>#include "ReplicationConfig.h"
#include "System/Buffers/Buffer.h"
#include "Framework/Storage/StorageEnvironment.h"

#define WIDTH_NODEID                16
#define WIDTH_RUNID                 16

ReplicationConfig* replicationConfig = NULL;

ReplicationConfig* ReplicationConfig::Get()
{
    if (replicationConfig == NULL)
        replicationConfig = new ReplicationConfig();
    
    return replicationConfig;
}

ReplicationConfig::ReplicationConfig()
{
    runID = 0;
    nodeID = 0;
    clusterID = 0;
}

void ReplicationConfig::Init(StorageShardProxy* shard_)
{
    ReadBuffer  value;
    bool        ret;
    unsigned    nread;
    
    shard = shard_;

    // TODO: HACK
    shard->GetEnvironment()->CreateShard(shard->GetContextID(), shard->GetShardID(), 
     0, "", "", true, false);
    
    ret = shard->Get(ReadBuffer("nodeID"), value);
    nread = 0;
    nodeID = BufferToUInt64(value.GetBuffer(), value.GetLength(), &nread);
    if (!ret || nread != value.GetLength())
    {
        Log_Message("No nodeID read from database");
        nodeID = 0;
    }

    ret = shard->Get(ReadBuffer("runID"), value);
    nread = 0;
    runID = BufferToUInt64(value.GetBuffer(), value.GetLength(), &nread);
    if (!ret || nread != value.GetLength())
    {
        Log_Message("No runID read from database");
        runID = 0;
    }<commit_msg>Added "My nodeID is ..." Log_Message.<commit_after>#include "ReplicationConfig.h"
#include "System/Buffers/Buffer.h"
#include "Framework/Storage/StorageEnvironment.h"

#define WIDTH_NODEID                16
#define WIDTH_RUNID                 16

ReplicationConfig* replicationConfig = NULL;

ReplicationConfig* ReplicationConfig::Get()
{
    if (replicationConfig == NULL)
        replicationConfig = new ReplicationConfig();
    
    return replicationConfig;
}

ReplicationConfig::ReplicationConfig()
{
    runID = 0;
    nodeID = 0;
    clusterID = 0;
}

void ReplicationConfig::Init(StorageShardProxy* shard_)
{
    ReadBuffer  value;
    bool        ret;
    unsigned    nread;
    
    shard = shard_;

    // TODO: HACK
    shard->GetEnvironment()->CreateShard(shard->GetContextID(), shard->GetShardID(), 
     0, "", "", true, false);
    
    ret = shard->Get(ReadBuffer("nodeID"), value);
    nread = 0;
    nodeID = BufferToUInt64(value.GetBuffer(), value.GetLength(), &nread);
    if (!ret || nread != value.GetLength())
    {
        Log_Message("No nodeID read from database");
        nodeID = 0;
    }
    else
    {
        Log_Message("My nodeID is %U", nodeID);
    }

    ret = shard->Get(ReadBuffer("runID"), value);
    nread = 0;
    runID = BufferToUInt64(value.GetBuffer(), value.GetLength(), &nread);
    if (!ret || nread != value.GetLength())
    {
        Log_Message("No runID read from database");
        runID = 0;
    }
{'fraction_non_alphanumeric': 0.13534635879218473, 'fraction_numerical': 0.011367673179396092, 'mean_word_length': 2.889502762430939, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '6880867', 'n_tokens_mistral': 926, 'n_tokens_neox': 885, 'n_words': 190}