Permalink
Browse files

Force syncing changes to log

  • Loading branch information...
jarulraj committed Mar 21, 2014
1 parent fe923be commit f7d5eed6583345be688c71e7050364a193b00244
@@ -37,13 +37,21 @@ AriesLogProxy::AriesLogProxy(VoltDBEngine *engine, string logfileName) {
}
void AriesLogProxy::init(VoltDBEngine *engine, string logfileName) {
this->logfileName = logfileName;
this->logFileName = logfileName;
// XXX originally true
jniLogging = false;
if (!jniLogging) {
logfile.open(logfileName.c_str(), ios::out | ios::binary | ios::app);
VOLT_DEBUG("AriesLogProxy : opened logfile %s :: pos %ld", logfileName.c_str(), logfile.tellp());
// append + binary mode
logFile = fopen(logfileName.c_str(), "ab+");
logFileFD = fileno(logFile);
if(logFile != NULL){
VOLT_DEBUG("AriesLogProxy : opened logfile %s ", logFileName.c_str());
}
else{
VOLT_ERROR("AriesLogProxy : cannot open logfile %s ", logFileName.c_str());
}
} else {
if (engine == NULL) {
cout << "what in the god's name is this shit " << endl;
@@ -53,10 +61,15 @@ void AriesLogProxy::init(VoltDBEngine *engine, string logfileName) {
}
AriesLogProxy::~AriesLogProxy() {
VOLT_DEBUG("AriesLogProxy : destructor : %s", logfileName.c_str());
if (logfile.is_open()) {
logfile.close();
VOLT_DEBUG("AriesLogProxy : closed logfile %s", logfileName.c_str());
if(logFile != NULL){
int ret = fclose(logFile);
if(ret == 0){
VOLT_DEBUG("AriesLogProxy : closed logfile %s", logFileName.c_str());
}
else{
VOLT_ERROR("AriesLogProxy : could not close logfile %s", logFileName.c_str());
}
}
}
@@ -76,7 +89,7 @@ AriesLogProxy* AriesLogProxy::getAriesLogProxy(VoltDBEngine *engine) {
}
string AriesLogProxy::getLogFileName() {
return logfileName;
return logFileName;
}
void AriesLogProxy::log(LoggerId loggerId, LogLevel level, const char *statement) const {
@@ -145,20 +158,31 @@ void AriesLogProxy::logBinaryOutput(const char *data, size_t size) {
}
void AriesLogProxy::logLocally(const char *data, size_t size) {
logfile.write(data, size);
size_t s_ret = -1;
int ret = -1;
if (logfile.fail()) {
// XXX: couldn't write, wait what?
if(logfile.bad()){
VOLT_ERROR("logLocally failed : badbit set");
}
else{
VOLT_ERROR("logLocally failed : failbit set");
}
s_ret = fwrite (data , sizeof(char), size, logFile);
if(s_ret != size){
VOLT_ERROR("logLocally failed : badbit set");
}
ret = fflush(logFile);
if(ret == 0){
VOLT_DEBUG("logLocally : flushed : file pos %ld", ftell(logFile));
}
else{
VOLT_ERROR("logLocally : flushed : file pos %ld", ftell(logFile));
}
// SYNC changes
ret = fsync(logFileFD);
if(ret == 0){
VOLT_DEBUG("logLocally : synced file");
}
else{
VOLT_ERROR("logLocally : could not sync file ");
}
logfile.flush();
VOLT_DEBUG("logLocally : flushed : file pos %ld", logfile.tellp());
}
void AriesLogProxy::logToEngineBuffer(const char *data, size_t size) {
@@ -22,6 +22,7 @@
#include "logging/LogProxy.h"
#include <iostream>
#include <cstdio>
#include <fstream>
namespace voltdb {
@@ -52,8 +53,9 @@ class AriesLogProxy : public LogProxy {
void logLocally(const char *data, size_t size);
void logToEngineBuffer(const char *data, size_t size);
std::string logfileName;
std::ofstream logfile;
std::string logFileName;
FILE* logFile;
int logFileFD; // fd equivalent for fsync
bool jniLogging;
VoltDBEngine* engine;
@@ -289,11 +289,14 @@ void TableFactory::configureStats(voltdb::CatalogId databaseId,
ExecutorContext *ctx,
std::string name,
Table *table) {
std::string hostname = "";
if(ctx != NULL)
hostname = ctx->m_hostname;
// initialize stats for the table
table->getTableStats()->configure(name + " stats",
ctx->m_hostId,
ctx->m_hostname,
hostname,
ctx->m_siteId,
ctx->m_partitionId,
databaseId);
@@ -305,7 +308,7 @@ void TableFactory::configureStats(voltdb::CatalogId databaseId,
index->getIndexStats()->configure(index->getName() + " stats",
table->name(),
ctx->m_hostId,
ctx->m_hostname,
hostname,
ctx->m_siteId,
ctx->m_partitionId,
databaseId);
@@ -411,9 +411,9 @@ static public Test suite() {
// COMMAND LOG
builder.setGlobalConfParameter("site.commandlog_enable", true);
builder.setGlobalConfParameter("site.commandlog_timeout", 10);
builder.setGlobalConfParameter("site.commandlog_timeout", 1000);
//builder.setGlobalConfParameter("site.commandlog_dir", "/mnt/pmfs/cmdlog");
builder.setGlobalConfParameter("site.snapshot", true);
builder.setGlobalConfParameter("site.anticache_enable", false);
TPCCProjectBuilder project = new TPCCProjectBuilder();
@@ -191,6 +191,7 @@ static public Test suite() {
// PHYSICAL
builder.setGlobalConfParameter("site.aries", true);
builder.setGlobalConfParameter("site.aries_forward_only", false);
//builder.setGlobalConfParameter("site.aries_dir", "/mnt/pmfs/aries");
builder.setGlobalConfParameter("site.anticache_enable", false);

0 comments on commit f7d5eed

Please sign in to comment.