Skip to content

Commit

Permalink
Build failure has been fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
laa committed Nov 27, 2017
1 parent ae578fa commit 8c45d71
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
Expand Up @@ -1201,21 +1201,22 @@ public void addEventAt(OLogSequenceNumber lsn, Runnable event) {
* @inheritDoc
*/
@Override
public void appendNewSegment() {
public boolean appendNewSegment() {
syncObject.lock();
try {
if (!activeOperations.isEmpty())
throw new OStorageException("Can not change end of WAL because there are active atomic operations in the log.");

if (end() == null)
throw new OStorageException("Can not change end of WAL because WAL is empty");
return false; //nothing to do next records will be in new segment

OLogSegment last = logSegments.get(logSegments.size() - 1);
if (last.filledUpTo() == 0) {
return; //nothing to do next records will be in new segment
return false; //nothing to do next records will be in new segment
}

appendNewSegment(last);
return true;
} catch (IOException ioe) {
throw OException.wrapException(new OIOException("Error during appending of new segment to the WAL"), ioe);
} finally {
Expand Down
Expand Up @@ -164,6 +164,7 @@ public void addEventAt(OLogSequenceNumber lsn, Runnable event) {
}

@Override
public void appendNewSegment() {
public boolean appendNewSegment() {
return false;
}
}
Expand Up @@ -98,7 +98,6 @@ OLogSequenceNumber logAtomicOperationEndRecord(OOperationUnitId operationUnitId,

/**
* Next LSN generated by WAL will be bigger than passed in value.
* <p>
* DO NOT REMOVE IT, USED IN ENTERPRISE STORAGE.
*/
@SuppressWarnings("unused")
Expand Down Expand Up @@ -134,11 +133,9 @@ OLogSequenceNumber logAtomicOperationEndRecord(OOperationUnitId operationUnitId,

/**
* Adds the event to fire when this write ahead log instances reaches the given LSN.
* <p>
* The thread on which the event will be fired is unspecified, the event may be even fired synchronously before this method
* returns. Avoid running long tasks in the event handler since this may degrade the performance of this write ahead log and/or
* its event managing component.
* <p>
* The exact LSN, up to which this write ahead log is actually grown, may differ from the event's LSN at the moment of invocation.
* But it's guarantied that the write ahead log's LSN will be larger than or equal to the event's LSN. In other words, the event
* invocation may be postponed, exact timings depend on implementation details of this write ahead log.
Expand All @@ -150,6 +147,16 @@ OLogSequenceNumber logAtomicOperationEndRecord(OOperationUnitId operationUnitId,

/**
* Adds new segment so all subsequent log entries will be added to this new segment.
* New segment can not be appended if:
* <ol>
* <li>WAL is empty</li>
* <li>There last segment in WAL is empty.</li>
* </ol>
* Despite of the fact that WAL segment will not be appended, method call still will reach its main target, all subsequent log
* records will have segment number higher than previously logged records. But to inform user that segment is not added result of
* success of failure of this method will be returned.
*
* @return <code>true</code> if new segment is added, and <code>false</code> otherwise.
*/
void appendNewSegment();
boolean appendNewSegment();
}
Expand Up @@ -2335,9 +2335,9 @@ public void testTruncateLastSegment() throws IOException {
Assert.assertEquals(writeAheadLog.size(), OWALPage.PAGE_SIZE / 2);
}

@Test(expected = OStorageException.class)
@Test
public void testEmptyWalCannotBeAppended() {
writeAheadLog.appendNewSegment();
Assert.assertFalse(writeAheadLog.appendNewSegment());
}

@Test
Expand All @@ -2355,7 +2355,7 @@ public void appendIsNotAllowedWithOnGoingOperations() throws Exception {
OLogSequenceNumber endLsn = writeAheadLog.logAtomicOperationEndRecord(operationUnitId, false, new OLogSequenceNumber(0, 0),
Collections.<String, OAtomicOperationMetadata<?>>emptyMap());

writeAheadLog.appendNewSegment();
Assert.assertTrue(writeAheadLog.appendNewSegment());

OLogSequenceNumber lsn = writeAheadLog.log(new TestRecord(0, SEGMENT_SIZE, 100, false, true));

Expand All @@ -2370,7 +2370,7 @@ public void emptySegmentNoOpOnAppend() throws Exception {
final List<String> walFiles = writeAheadLog.getWalFiles();
Assert.assertEquals(2, walFiles.size());

writeAheadLog.appendNewSegment();
Assert.assertFalse(writeAheadLog.appendNewSegment());

Assert.assertEquals(walFiles, writeAheadLog.getWalFiles());
OLogSequenceNumber appLsn = writeAheadLog.log(new TestRecord(0, 100, SEGMENT_SIZE, true, false));
Expand All @@ -2389,7 +2389,7 @@ public void testAppendSegment() throws Exception {
}

OLogSequenceNumber end = writeAheadLog.end();
writeAheadLog.appendNewSegment();
Assert.assertTrue(writeAheadLog.appendNewSegment());

TestRecord walRecord = new TestRecord(0, SEGMENT_SIZE, 512, false, true);
writeAheadLog.log(walRecord);
Expand Down

0 comments on commit 8c45d71

Please sign in to comment.