Small improvement with logging
diff --git a/ccnx/ccnx-discovery.cpp b/ccnx/ccnx-discovery.cpp
index e5d9998..afb0307 100644
--- a/ccnx/ccnx-discovery.cpp
+++ b/ccnx/ccnx-discovery.cpp
@@ -54,9 +54,12 @@
, m_localPrefix("/")
{
m_scheduler->start();
- IntervalGeneratorPtr generator = boost::make_shared<SimpleIntervalGenerator>(INTERVAL);
- TaskPtr task = boost::make_shared<PeriodicTask>(boost::bind(&CcnxDiscovery::poll, this), "Local-Prefix-Check", m_scheduler, generator);
- m_scheduler->addTask(task);
+
+ Scheduler::scheduleOneTimeTask (m_scheduler, 0,
+ boost::bind(&CcnxDiscovery::poll, this), "Initial-Local-Prefix-Check");
+ Scheduler::schedulePeriodicTask (m_scheduler,
+ boost::make_shared<SimpleIntervalGenerator>(INTERVAL),
+ boost::bind(&CcnxDiscovery::poll, this), "Local-Prefix-Check");
}
CcnxDiscovery::~CcnxDiscovery()
diff --git a/log4cxx.properties b/log4cxx.properties
index 9593e06..a3663c4 100644
--- a/log4cxx.properties
+++ b/log4cxx.properties
@@ -13,7 +13,7 @@
log4j.logger.Executor = ERROR
log4j.logger.Sync.Log = ERROR
-log4j.logger.Sync.Core = ERROR
+log4j.logger.Sync.Core = DEBUG
log4j.logger.Scheduler = ERROR
#log4j.logger.Sync = DEBUG
diff --git "a/src/.\043object-manager.cc" "b/src/.\043object-manager.cc"
deleted file mode 120000
index 0a98ad3..0000000
--- "a/src/.\043object-manager.cc"
+++ /dev/null
@@ -1 +0,0 @@
-cawka@cawka-mac.9794
\ No newline at end of file
diff --git a/src/hash-helper.cc b/src/hash-helper.cc
index d92e6b0..6fe0ca9 100644
--- a/src/hash-helper.cc
+++ b/src/hash-helper.cc
@@ -24,11 +24,12 @@
#include <boost/assert.hpp>
#include <boost/throw_exception.hpp>
#include <boost/make_shared.hpp>
+#include <boost/lexical_cast.hpp>
#include <openssl/evp.h>
#include <fstream>
-typedef boost::error_info<struct tag_errmsg, std::string> errmsg_info_str;
-typedef boost::error_info<struct tag_errmsg, int> errmsg_info_int;
+typedef boost::error_info<struct tag_errmsg, std::string> errmsg_info_str;
+typedef boost::error_info<struct tag_errmsg, int> errmsg_info_int;
#include <boost/archive/iterators/transform_width.hpp>
#include <boost/iterator/transform_iterator.hpp>
@@ -80,7 +81,7 @@
value = lookup_table [(unsigned)ch];
if (value == -1)
BOOST_THROW_EXCEPTION (Error::HashConversion () << errmsg_info_int ((int)ch));
-
+
return value;
}
};
@@ -103,6 +104,13 @@
return os;
}
+std::string
+Hash::shortHash () const
+{
+ return lexical_cast<string> (*this).substr (0, 10);
+}
+
+
unsigned char Hash::_origin = 0;
HashPtr Hash::Origin(new Hash(&Hash::_origin, sizeof(unsigned char)));
@@ -110,7 +118,7 @@
Hash::FromString (const std::string &hashInTextEncoding)
{
HashPtr retval = make_shared<Hash> (reinterpret_cast<void*> (0), 0);
-
+
if (hashInTextEncoding.size () == 0)
{
return retval;
@@ -123,7 +131,7 @@
}
retval->m_buf = new unsigned char [EVP_MAX_MD_SIZE];
-
+
unsigned char *end = copy (string_to_binary (hashInTextEncoding.begin ()),
string_to_binary (hashInTextEncoding.end ()),
retval->m_buf);
@@ -154,7 +162,7 @@
EVP_DigestFinal_ex (hash_context,
retval->m_buf, &retval->m_length);
-
+
EVP_MD_CTX_destroy (hash_context);
return retval;
diff --git a/src/hash-helper.h b/src/hash-helper.h
index ab93697..41a8b8a 100644
--- a/src/hash-helper.h
+++ b/src/hash-helper.h
@@ -137,6 +137,9 @@
return m_length;
}
+ std::string
+ shortHash () const;
+
private:
unsigned char *m_buf;
unsigned int m_length;
diff --git a/src/sync-core.cc b/src/sync-core.cc
index 95a5d62..6c9df52 100644
--- a/src/sync-core.cc
+++ b/src/sync-core.cc
@@ -87,7 +87,7 @@
m_ccnx->publishData(syncName, *syncData, FRESHNESS);
_LOG_DEBUG ("[" << m_log->GetLocalName () << "] localStateChanged ");
- _LOG_TRACE ("[" << m_log->GetLocalName () << "] publishes: " << *oldHash);
+ _LOG_TRACE ("[" << m_log->GetLocalName () << "] publishes: " << oldHash->shortHash ());
// _LOG_TRACE (msg);
// no hurry in sending out new Sync Interest; if others send the new Sync Interest first, no problem, we know the new root hash already;
@@ -131,7 +131,7 @@
BytesPtr syncData = serializeMsg (*msg);
m_ccnx->publishData(name, *syncData, FRESHNESS);
- _LOG_TRACE ("[" << m_log->GetLocalName () << "] publishes " << hash);
+ _LOG_TRACE ("[" << m_log->GetLocalName () << "] publishes " << hash.shortHash ());
// _LOG_TRACE (msg);
}
else
@@ -150,7 +150,7 @@
if (*hash == *m_rootHash)
{
// we have the same hash; nothing needs to be done
- _LOG_TRACE ("same as root hash: " << *hash);
+ _LOG_TRACE ("same as root hash: " << hash->shortHash ());
return;
}
else if (m_log->LookupSyncLog(*hash) > 0)
@@ -161,14 +161,14 @@
BytesPtr syncData = serializeMsg (*msg);
m_ccnx->publishData(name, *syncData, FRESHNESS);
- _LOG_TRACE (m_log->GetLocalName () << " publishes: " << *hash);
+ _LOG_TRACE (m_log->GetLocalName () << " publishes: " << hash->shortHash ());
_LOG_TRACE (msg);
}
else
{
// we don't recognize the hash, send recover Interest if still don't know the hash after a randomized wait period
double wait = m_recoverWaitGenerator->nextInterval();
- _LOG_TRACE (m_log->GetLocalName () << ", rootHash: " << *m_rootHash << ", hash: " << *hash);
+ _LOG_TRACE (m_log->GetLocalName () << ", rootHash: " << *m_rootHash << ", hash: " << hash->shortHash ());
_LOG_TRACE ("recover task scheduled after wait: " << wait);
Scheduler::scheduleOneTimeTask (m_scheduler,
@@ -278,7 +278,7 @@
{
Name syncInterest = Name (m_syncPrefix)(m_rootHash->GetHash(), m_rootHash->GetHashBytes());
- _LOG_DEBUG ("[" << m_log->GetLocalName () << "] >>> SYNC Interest for " << *m_rootHash);
+ _LOG_DEBUG ("[" << m_log->GetLocalName () << "] >>> SYNC Interest for " << m_rootHash->shortHash () << ": " << syncInterest);
m_ccnx->sendInterest(syncInterest,
Closure (boost::bind(&SyncCore::handleSyncData, this, _1, _2),
@@ -290,7 +290,7 @@
{
if (!(*hash == *m_rootHash) && m_log->LookupSyncLog(*hash) <= 0)
{
- _LOG_TRACE (m_log->GetLocalName () << ", Recover for: " << *hash);
+ _LOG_TRACE (m_log->GetLocalName () << ", Recover for: " << hash->shortHash ());
// unfortunately we still don't recognize this hash
Bytes bytes;
readRaw(bytes, (const unsigned char *)hash->GetHash(), hash->GetHashBytes());
@@ -298,7 +298,7 @@
// append the unknown hash
Name recoverInterest = Name (m_syncPrefix)(RECOVER)(bytes);
- _LOG_DEBUG ("[" << m_log->GetLocalName () << "] >>> RECOVER Interests for " << *hash);
+ _LOG_DEBUG ("[" << m_log->GetLocalName () << "] >>> RECOVER Interests for " << hash->shortHash ());
m_ccnx->sendInterest(recoverInterest,
Closure (boost::bind(&SyncCore::handleRecoverData, this, _1, _2),