Skip to content

Commit

Permalink
ZOOKEEPER-3027: Accidently removed public API of FileTxnLog.setPreall…
Browse files Browse the repository at this point in the history
…ocSize()

In my latest commit regarding TxnLogToolkit there's a refactor to outsource file padding logic from FileTxnLog to a separate class:

apache@126fb0f#diff-89717124564925d61d29dd817bcdd915L147

Unfortunately public static method setPreallocSize(int) has also been moved to the new class, but it's being actively used by hadoop-common project too:

https://github.com/apache/hadoop/blob/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ha/ClientBaseWithFixes.java#L384

I'd like to submit a patch to revert the deleted method which is going to call the new one, but will keep backward compatibility with Hadoop.

Author: Andor Molnar <[email protected]>

Reviewers: [email protected]

Closes apache#509 from anmolnar/ZOOKEEPER-3027

Change-Id: I7333b5e24c2a78d10a5c5a74c181633050bd225d
  • Loading branch information
anmolnar authored and phunt committed Apr 27, 2018
1 parent 2c0168a commit 5c96887
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ public class FilePadding {

private long currentSize;

/**
* Getter of preAllocSize has been added for testing
*/
public static long getPreAllocSize() {
return preAllocSize;
}

/**
* method to allow setting preallocate size
* of log file to pad the file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@ public FileTxnLog(File logDir) {
this.logDir = logDir;
}

/**
* method to allow setting preallocate size
* of log file to pad the file.
* @param size the size to set to in bytes
*/
public static void setPreallocSize(long size) {
FilePadding.setPreallocSize(size);
}

/**
* creates a checksum algorithm to be used
* @return the checksum used for this txnlog
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
import java.io.IOException;
import java.util.Arrays;

import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsEqual.equalTo;

public class FileTxnLogTest extends ZKTestCase {
protected static final Logger LOG = LoggerFactory.getLogger(FileTxnLogTest.class);

Expand Down Expand Up @@ -98,4 +101,11 @@ public void testPreAllocSizeSmallerThanTxnData() throws IOException {
createTxn = (CreateTxn) fileTxnIterator.getTxn();
Assert.assertTrue(Arrays.equals(createTxn.getData(), new byte[]{}));
}

@Test
public void testSetPreallocSize() {
long customPreallocSize = 10101;
FileTxnLog.setPreallocSize(customPreallocSize);
Assert.assertThat(FilePadding.getPreAllocSize(), is(equalTo(customPreallocSize)));
}
}

0 comments on commit 5c96887

Please sign in to comment.