Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
Eliminate creation of unnecessary empty files
Browse files Browse the repository at this point in the history
Summary:
Two changes to help eliminate empty files when running with replay_buffer=no,
i.e. when we care
about what data shows up in both primary and secondary

1. eliminate unnecessary periodicCheck calls.
there are a lot of empty files created due periodicchecks on closed stores

2. We dont take any action on failure to open secondary so trying to do
that in bufferstore::open is useless

This should also fix the bucketupdater path problem for running
testsuite

Test Plan:
testsuite

DiffCamp Revision: 115118
Reviewed By: jsong
Commenters: agiardullo
CC: agiardullo, jsong, groys, scribe-dev@lists
Revert Plan:
OK

git-svn-id: svn+ssh://tubbs/svnapps/fbomb/branches/scribe-os/fbcode/scribe@28040 2248de34-8caa-4a3c-bc55-5e52d9d7b73a
  • Loading branch information
groys authored and groys committed Jun 7, 2010
1 parent be5d12d commit 17fe373
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,13 @@ bool FileStore::handleMessages(boost::shared_ptr<logentry_vector_t> messages) {
return writeMessages(messages);
}

void FileStore::periodicCheck() {
if (!isOpen()) {
return;
}
FileStoreBase::periodicCheck();
}

// writes messages to either the specified file or the the current writeFile
bool FileStore::writeMessages(boost::shared_ptr<logentry_vector_t> messages,
boost::shared_ptr<FileInterface> file) {
Expand Down Expand Up @@ -1362,14 +1369,13 @@ bool BufferStore::open() {

// try to open the primary store, and set the state accordingly
if (primaryStore->open()) {
// in case there are files left over from a previous instance
changeState(SENDING_BUFFER);

// If we don't need to send buffers, skip to streaming
if (!replayBuffer) {
// We still switch state to SENDING_BUFFER first just to make sure we
// can open the secondary store
changeState(STREAMING);
} else {
// in case there are files left over from a previous instance
changeState(SENDING_BUFFER);
}
} else {
secondaryStore->open();
Expand Down
74 changes: 74 additions & 0 deletions test/tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,80 @@
include_once $GLOBALS['THRIFT_ROOT'].'/protocol/TBinaryProtocol.php';
include_once $GLOBALS['THRIFT_ROOT'].'/transport/TFramedTransport.php';
include_once $GLOBALS['THRIFT_ROOT'].'/transport/TSocketPool.php';
// need to get to the gen-php
require_once $GLOBALS['SCRIBE_ROOT'].'/BucketStoreMapping.php';

function reload_test($file) {
static $numTest = 0;
$numTest++;

echo "reload_test($file)\n";
$msg1 = new LogEntry;
$msg1->category = "reload";
$msg1->message = "msg{$numTest}";

$scribe_client = create_scribe_client();
scribe_Log_test(array($msg1), $scribe_client);
sleep(2);

// check
$cmd = "grep -q \"msg{$numTest}\" $file";
system($cmd, $retVal);
echo "$cmd => $retVal\n";

if ($retVal != 0) {
echo "Error: can't find \"msg{$numTest}\" in $file\n";
}
return $retVal == 0;
}

function bucketupdater_test($bid1Path,
$bid2Path,
$bid3Path) {
static $numTest = 0;
$numTest++;

// append /tmp/scribetest_/bucketupdater/ to all the paths
$bid1Path = "/tmp/scribetest_/bucketupdater/$bid1Path";
$bid2Path = "/tmp/scribetest_/bucketupdater/$bid2Path";
$bid3Path = "/tmp/scribetest_/bucketupdater/$bid3Path";

echo "bucketupdater_test($bid1Path, $bid2Path, $bid3Path)\n";
// bucket 1 message
$msg1 = new LogEntry;
$msg1->category = "bucketupdater";
$msg1->message = "0;test #{$numTest}\n";

// bucket 2 message
$msg2 = new LogEntry;
$msg2->category = "bucketupdater";
$msg2->message = "1;test #{$numTest}\n";

$scribe_client = create_scribe_client();
$ret = scribe_Log_test(array($msg1, $msg2), $scribe_client);
echo "scirbe log => $ret\n";
sleep(2);

// check
$cmd = "/bin/grep -q \"0;test #{$numTest}\" $bid1Path";
system($cmd, $retVal);
echo "$cmd => $retVal\n";

if ($retVal != 0) {
echo "Error: can't find \"2;test #{$numTest}\" in $bid1Path\n";
return false;
}

$cmd = "/bin/grep -q \"1;test #{$numTest}\" $bid2Path";
system($cmd, $retVal);
echo "$cmd => $retVal\n";

if ($retVal != 0) {
echo "Error: can't find \"1;test #{$numTest}\" in $bid2Path\n";
}

return $retVal == 0;
}

/**
* testing scribe configuration parameter inheritance.
Expand Down

0 comments on commit 17fe373

Please sign in to comment.