Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions src/java/org/apache/cassandra/db/commitlog/CommitLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.file.FileStore;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
Expand All @@ -35,7 +33,6 @@
import java.util.concurrent.TimeUnit;
import java.util.function.BiPredicate;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.zip.CRC32;

import com.google.common.annotations.VisibleForTesting;
Expand Down Expand Up @@ -184,16 +181,16 @@ private File[] getUnmanagedFiles()
}

/**
* Updates the commit log storage directory and re-initializes the segment manager accordingly.
* Updates the commit log segment manager accordingly.
* <p/>
* Used by CNDB.
*
* @param commitLogLocation storage directory to update to
* @param manager commitlog segment manager to update to
* @return this commit log with updated storage directory
*/
public CommitLog forPath(File commitLogLocation)
public CommitLog forSegmentManager(AbstractCommitLogSegmentManager manager)
{
segmentManager = new CommitLogSegmentManagerStandard(this, commitLogLocation);
segmentManager = manager;
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,14 @@ public void before() throws IOException
}

@Test
public void testForPath()
public void testForSegmentManager()
{
AbstractCommitLogSegmentManager original = CommitLog.instance.getSegmentManager();

File location = FileUtils.getTempDir();
CommitLog.instance.forPath(location);
AbstractCommitLogSegmentManager update = new CommitLogSegmentManagerStandard(CommitLog.instance, location);

CommitLog.instance.forSegmentManager(update);
Assert.assertNotEquals(original, CommitLog.instance.getSegmentManager());
Assert.assertEquals(location, CommitLog.instance.getSegmentManager().storageDirectory);
}
Expand Down