本文整理汇总了Java中java.util.concurrent.ConcurrentNavigableMap.remove方法的典型用法代码示例。如果您正苦于以下问题:Java ConcurrentNavigableMap.remove方法的具体用法?Java ConcurrentNavigableMap.remove怎么用?Java ConcurrentNavigableMap.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.concurrent.ConcurrentNavigableMap
的用法示例。
在下文中一共展示了ConcurrentNavigableMap.remove方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testPollFirstEntry
import java.util.concurrent.ConcurrentNavigableMap; //导入方法依赖的package包/类
/**
* pollFirstEntry returns entries in order
*/
public void testPollFirstEntry() {
ConcurrentNavigableMap map = map5();
Map.Entry e = map.pollFirstEntry();
assertEquals(one, e.getKey());
assertEquals("A", e.getValue());
e = map.pollFirstEntry();
assertEquals(two, e.getKey());
map.put(one, "A");
e = map.pollFirstEntry();
assertEquals(one, e.getKey());
assertEquals("A", e.getValue());
e = map.pollFirstEntry();
assertEquals(three, e.getKey());
map.remove(four);
e = map.pollFirstEntry();
assertEquals(five, e.getKey());
try {
e.setValue("A");
shouldThrow();
} catch (UnsupportedOperationException success) {}
e = map.pollFirstEntry();
assertNull(e);
}
示例2: testPollLastEntry
import java.util.concurrent.ConcurrentNavigableMap; //导入方法依赖的package包/类
/**
* pollLastEntry returns entries in order
*/
public void testPollLastEntry() {
ConcurrentNavigableMap map = map5();
Map.Entry e = map.pollLastEntry();
assertEquals(five, e.getKey());
assertEquals("E", e.getValue());
e = map.pollLastEntry();
assertEquals(four, e.getKey());
map.put(five, "E");
e = map.pollLastEntry();
assertEquals(five, e.getKey());
assertEquals("E", e.getValue());
e = map.pollLastEntry();
assertEquals(three, e.getKey());
map.remove(two);
e = map.pollLastEntry();
assertEquals(one, e.getKey());
try {
e.setValue("E");
shouldThrow();
} catch (UnsupportedOperationException success) {}
e = map.pollLastEntry();
assertNull(e);
}
示例3: testDescendingPollFirstEntry
import java.util.concurrent.ConcurrentNavigableMap; //导入方法依赖的package包/类
/**
* pollFirstEntry returns entries in order
*/
public void testDescendingPollFirstEntry() {
ConcurrentNavigableMap map = dmap5();
Map.Entry e = map.pollFirstEntry();
assertEquals(m1, e.getKey());
assertEquals("A", e.getValue());
e = map.pollFirstEntry();
assertEquals(m2, e.getKey());
map.put(m1, "A");
e = map.pollFirstEntry();
assertEquals(m1, e.getKey());
assertEquals("A", e.getValue());
e = map.pollFirstEntry();
assertEquals(m3, e.getKey());
map.remove(m4);
e = map.pollFirstEntry();
assertEquals(m5, e.getKey());
try {
e.setValue("A");
shouldThrow();
} catch (UnsupportedOperationException success) {}
e = map.pollFirstEntry();
assertNull(e);
}
示例4: testDescendingPollLastEntry
import java.util.concurrent.ConcurrentNavigableMap; //导入方法依赖的package包/类
/**
* pollLastEntry returns entries in order
*/
public void testDescendingPollLastEntry() {
ConcurrentNavigableMap map = dmap5();
Map.Entry e = map.pollLastEntry();
assertEquals(m5, e.getKey());
assertEquals("E", e.getValue());
e = map.pollLastEntry();
assertEquals(m4, e.getKey());
map.put(m5, "E");
e = map.pollLastEntry();
assertEquals(m5, e.getKey());
assertEquals("E", e.getValue());
e = map.pollLastEntry();
assertEquals(m3, e.getKey());
map.remove(m2);
e = map.pollLastEntry();
assertEquals(m1, e.getKey());
try {
e.setValue("E");
shouldThrow();
} catch (UnsupportedOperationException success) {}
e = map.pollLastEntry();
assertNull(e);
}
示例5: testRemove
import java.util.concurrent.ConcurrentNavigableMap; //导入方法依赖的package包/类
/**
* remove removes the correct key-value pair from the map
*/
public void testRemove() {
ConcurrentNavigableMap map = map5();
map.remove(five);
assertEquals(4, map.size());
assertFalse(map.containsKey(five));
}
示例6: testRemove2
import java.util.concurrent.ConcurrentNavigableMap; //导入方法依赖的package包/类
/**
* remove(key,value) removes only if pair present
*/
public void testRemove2() {
ConcurrentNavigableMap map = map5();
assertTrue(map.containsKey(five));
assertEquals("E", map.get(five));
map.remove(five, "E");
assertEquals(4, map.size());
assertFalse(map.containsKey(five));
map.remove(four, "A");
assertEquals(4, map.size());
assertTrue(map.containsKey(four));
}
示例7: testRemove1_NullPointerException
import java.util.concurrent.ConcurrentNavigableMap; //导入方法依赖的package包/类
/**
* remove(null) throws NPE
*/
public void testRemove1_NullPointerException() {
try {
ConcurrentNavigableMap c = map5();
c.remove(null);
shouldThrow();
} catch (NullPointerException success) {}
}
示例8: testRemove2_NullPointerException
import java.util.concurrent.ConcurrentNavigableMap; //导入方法依赖的package包/类
/**
* remove(null, x) throws NPE
*/
public void testRemove2_NullPointerException() {
try {
ConcurrentNavigableMap c = map5();
c.remove(null, "whatever");
shouldThrow();
} catch (NullPointerException success) {}
}
示例9: testDescendingRemove
import java.util.concurrent.ConcurrentNavigableMap; //导入方法依赖的package包/类
/**
* remove removes the correct key-value pair from the map
*/
public void testDescendingRemove() {
ConcurrentNavigableMap map = dmap5();
map.remove(m5);
assertEquals(4, map.size());
assertFalse(map.containsKey(m5));
}
示例10: testDescendingRemove2
import java.util.concurrent.ConcurrentNavigableMap; //导入方法依赖的package包/类
/**
* remove(key,value) removes only if pair present
*/
public void testDescendingRemove2() {
ConcurrentNavigableMap map = dmap5();
assertTrue(map.containsKey(m5));
assertEquals("E", map.get(m5));
map.remove(m5, "E");
assertEquals(4, map.size());
assertFalse(map.containsKey(m5));
map.remove(m4, "A");
assertEquals(4, map.size());
assertTrue(map.containsKey(m4));
}
示例11: testDescendingRemove1_NullPointerException
import java.util.concurrent.ConcurrentNavigableMap; //导入方法依赖的package包/类
/**
* remove(null) throws NPE
*/
public void testDescendingRemove1_NullPointerException() {
try {
ConcurrentNavigableMap c = dmap5();
c.remove(null);
shouldThrow();
} catch (NullPointerException success) {}
}
示例12: testDescendingRemove2_NullPointerException
import java.util.concurrent.ConcurrentNavigableMap; //导入方法依赖的package包/类
/**
* remove(null, x) throws NPE
*/
public void testDescendingRemove2_NullPointerException() {
try {
ConcurrentNavigableMap c = dmap5();
c.remove(null, "whatever");
shouldThrow();
} catch (NullPointerException success) {}
}
示例13: testCheckCommit
import java.util.concurrent.ConcurrentNavigableMap; //导入方法依赖的package包/类
@Test
// Validate all the commit check return codes OpenFileCtx.COMMIT_STATUS, which
// includes COMMIT_FINISHED, COMMIT_WAIT, COMMIT_INACTIVE_CTX,
// COMMIT_INACTIVE_WITH_PENDING_WRITE, COMMIT_ERROR, and COMMIT_DO_SYNC.
public void testCheckCommit() throws IOException {
DFSClient dfsClient = Mockito.mock(DFSClient.class);
Nfs3FileAttributes attr = new Nfs3FileAttributes();
HdfsDataOutputStream fos = Mockito.mock(HdfsDataOutputStream.class);
Mockito.when(fos.getPos()).thenReturn((long) 0);
NfsConfiguration conf = new NfsConfiguration();
conf.setBoolean(NfsConfigKeys.LARGE_FILE_UPLOAD, false);
OpenFileCtx ctx = new OpenFileCtx(fos, attr, "/dumpFilePath", dfsClient,
new ShellBasedIdMapping(conf), false, conf);
COMMIT_STATUS ret;
// Test inactive open file context
ctx.setActiveStatusForTest(false);
Channel ch = Mockito.mock(Channel.class);
ret = ctx.checkCommit(dfsClient, 0, ch, 1, attr, false);
Assert.assertTrue(ret == COMMIT_STATUS.COMMIT_INACTIVE_CTX);
ctx.getPendingWritesForTest().put(new OffsetRange(5, 10),
new WriteCtx(null, 0, 0, 0, null, null, null, 0, false, null));
ret = ctx.checkCommit(dfsClient, 0, ch, 1, attr, false);
Assert.assertTrue(ret == COMMIT_STATUS.COMMIT_INACTIVE_WITH_PENDING_WRITE);
// Test request with non zero commit offset
ctx.setActiveStatusForTest(true);
Mockito.when(fos.getPos()).thenReturn((long) 10);
ctx.setNextOffsetForTest(10);
COMMIT_STATUS status = ctx.checkCommitInternal(5, null, 1, attr, false);
Assert.assertTrue(status == COMMIT_STATUS.COMMIT_DO_SYNC);
// Do_SYNC state will be updated to FINISHED after data sync
ret = ctx.checkCommit(dfsClient, 5, ch, 1, attr, false);
Assert.assertTrue(ret == COMMIT_STATUS.COMMIT_FINISHED);
status = ctx.checkCommitInternal(10, ch, 1, attr, false);
Assert.assertTrue(status == COMMIT_STATUS.COMMIT_DO_SYNC);
ret = ctx.checkCommit(dfsClient, 10, ch, 1, attr, false);
Assert.assertTrue(ret == COMMIT_STATUS.COMMIT_FINISHED);
ConcurrentNavigableMap<Long, CommitCtx> commits = ctx
.getPendingCommitsForTest();
Assert.assertTrue(commits.size() == 0);
ret = ctx.checkCommit(dfsClient, 11, ch, 1, attr, false);
Assert.assertTrue(ret == COMMIT_STATUS.COMMIT_WAIT);
Assert.assertTrue(commits.size() == 1);
long key = commits.firstKey();
Assert.assertTrue(key == 11);
// Test request with zero commit offset
commits.remove(new Long(11));
// There is one pending write [5,10]
ret = ctx.checkCommit(dfsClient, 0, ch, 1, attr, false);
Assert.assertTrue(ret == COMMIT_STATUS.COMMIT_WAIT);
Assert.assertTrue(commits.size() == 1);
key = commits.firstKey();
Assert.assertTrue(key == 9);
// Empty pending writes
ctx.getPendingWritesForTest().remove(new OffsetRange(5, 10));
ret = ctx.checkCommit(dfsClient, 0, ch, 1, attr, false);
Assert.assertTrue(ret == COMMIT_STATUS.COMMIT_FINISHED);
}
示例14: testCheckCommitLargeFileUpload
import java.util.concurrent.ConcurrentNavigableMap; //导入方法依赖的package包/类
@Test
// Validate all the commit check return codes OpenFileCtx.COMMIT_STATUS with
// large file upload option.
public void testCheckCommitLargeFileUpload() throws IOException {
DFSClient dfsClient = Mockito.mock(DFSClient.class);
Nfs3FileAttributes attr = new Nfs3FileAttributes();
HdfsDataOutputStream fos = Mockito.mock(HdfsDataOutputStream.class);
Mockito.when(fos.getPos()).thenReturn((long) 0);
NfsConfiguration conf = new NfsConfiguration();
conf.setBoolean(NfsConfigKeys.LARGE_FILE_UPLOAD, true);
OpenFileCtx ctx = new OpenFileCtx(fos, attr, "/dumpFilePath", dfsClient,
new ShellBasedIdMapping(conf), false, conf);
COMMIT_STATUS ret;
// Test inactive open file context
ctx.setActiveStatusForTest(false);
Channel ch = Mockito.mock(Channel.class);
ret = ctx.checkCommit(dfsClient, 0, ch, 1, attr, false);
Assert.assertTrue(ret == COMMIT_STATUS.COMMIT_INACTIVE_CTX);
ctx.getPendingWritesForTest().put(new OffsetRange(10, 15),
new WriteCtx(null, 0, 0, 0, null, null, null, 0, false, null));
ret = ctx.checkCommit(dfsClient, 0, ch, 1, attr, false);
Assert.assertTrue(ret == COMMIT_STATUS.COMMIT_INACTIVE_WITH_PENDING_WRITE);
// Test request with non zero commit offset
ctx.setActiveStatusForTest(true);
Mockito.when(fos.getPos()).thenReturn((long) 8);
ctx.setNextOffsetForTest(10);
COMMIT_STATUS status = ctx.checkCommitInternal(5, null, 1, attr, false);
Assert.assertTrue(status == COMMIT_STATUS.COMMIT_DO_SYNC);
// Do_SYNC state will be updated to FINISHED after data sync
ret = ctx.checkCommit(dfsClient, 5, ch, 1, attr, false);
Assert.assertTrue(ret == COMMIT_STATUS.COMMIT_FINISHED);
// Test commit sequential writes
status = ctx.checkCommitInternal(10, ch, 1, attr, false);
Assert.assertTrue(status == COMMIT_STATUS.COMMIT_SPECIAL_WAIT);
ret = ctx.checkCommit(dfsClient, 10, ch, 1, attr, false);
Assert.assertTrue(ret == COMMIT_STATUS.COMMIT_SPECIAL_WAIT);
// Test commit non-sequential writes
ConcurrentNavigableMap<Long, CommitCtx> commits = ctx
.getPendingCommitsForTest();
Assert.assertTrue(commits.size() == 1);
ret = ctx.checkCommit(dfsClient, 16, ch, 1, attr, false);
Assert.assertTrue(ret == COMMIT_STATUS.COMMIT_SPECIAL_SUCCESS);
Assert.assertTrue(commits.size() == 1);
// Test request with zero commit offset
commits.remove(new Long(10));
// There is one pending write [10,15]
ret = ctx.checkCommitInternal(0, ch, 1, attr, false);
Assert.assertTrue(ret == COMMIT_STATUS.COMMIT_SPECIAL_WAIT);
ret = ctx.checkCommitInternal(9, ch, 1, attr, false);
Assert.assertTrue(ret == COMMIT_STATUS.COMMIT_SPECIAL_WAIT);
Assert.assertTrue(commits.size() == 2);
// Empty pending writes. nextOffset=10, flushed pos=8
ctx.getPendingWritesForTest().remove(new OffsetRange(10, 15));
ret = ctx.checkCommit(dfsClient, 0, ch, 1, attr, false);
Assert.assertTrue(ret == COMMIT_STATUS.COMMIT_SPECIAL_WAIT);
// Empty pending writes
ctx.setNextOffsetForTest((long) 8); // flushed pos = 8
ret = ctx.checkCommit(dfsClient, 0, ch, 1, attr, false);
Assert.assertTrue(ret == COMMIT_STATUS.COMMIT_FINISHED);
}