-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding tx.DataStructureFactory which builds proxy objects
that use a TransactionalNodeStore to commit all writes after a data structure operation. This allows the user to wrap operations in locks they are able to coordinate between all clients.
- Loading branch information
Showing
8 changed files
with
173 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 51 additions & 2 deletions
53
src/test/java/org/sdsai/dsds/node/tx/DataStructureFactoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,62 @@ | ||
package org.sdsai.dsds.node.tx; | ||
|
||
import java.util.UUID; | ||
import java.util.Map; | ||
import java.util.List; | ||
|
||
import org.sdsai.dsds.BaseTest; | ||
import org.sdsai.dsds.BTree; | ||
import org.sdsai.dsds.node.NodeStore; | ||
import org.sdsai.dsds.fs.DirectoryNodeStore; | ||
import java.io.File; | ||
import java.io.Serializable; | ||
|
||
import org.junit.Test; | ||
import org.junit.Before; | ||
import org.junit.Ignore; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class DataStructureFactoryTest extends BaseTest<UUID> | ||
import static java.util.UUID.randomUUID; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
public class DataStructureFactoryTest | ||
{ | ||
private final Logger logger = LoggerFactory.getLogger(BTreeTest.class); | ||
private final Logger logger = LoggerFactory.getLogger(DataStructureFactoryTest.class); | ||
|
||
private static <USERKEY extends Serializable> NodeStore<USERKEY, File, String> buildNodeStore(final Class<USERKEY> clazz) | ||
{ | ||
final NodeStore<USERKEY, File, String> nodeStore = | ||
new DirectoryNodeStore<USERKEY, String>("target/DirectoryNodeStore/"+DataStructureFactoryTest.class.getSimpleName()); | ||
|
||
return nodeStore; | ||
} | ||
|
||
@Test | ||
public void testTxBTree() | ||
{ | ||
final UUID btKey = randomUUID(); | ||
final Map<UUID, String> map = DataStructureFactory.bTree(btKey, buildNodeStore(UUID.class)); | ||
} | ||
|
||
@Test | ||
public void testTxPagedList() | ||
{ | ||
final NodeStore<File, File, String> nodeStore = buildNodeStore(File.class); | ||
|
||
final List<String> list = DataStructureFactory.pagedList(nodeStore.generateKey(null, null), nodeStore, 3); | ||
|
||
for(int i = 0; i < 100; i++) | ||
{ | ||
list.add("Hi "+i); | ||
} | ||
|
||
for(int i = 0; i < 100; i++) | ||
{ | ||
final String s = "Hi "+i; | ||
assertEquals(s, list.get(i)); | ||
} | ||
|
||
list.clear(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters