use of java.util.concurrent.ConcurrentSkipListMap in project mapdb by jankotek.
the class TupleTest method testSubMap.
@Test
public void testSubMap() {
int[] nums = { 1, 2, 3, 4, 5 };
ConcurrentNavigableMap m = new ConcurrentSkipListMap();
for (int a : nums) for (int b : nums) {
m.put(t2(a, b), "");
}
assertEquals(5, m.subMap(t2(3, null), t2(3, HI)).size());
assertEquals(3, m.subMap(t2(3, 3), t2(3, HI)).size());
assertEquals(10, m.headMap(t2(3, null)).size());
assertEquals(15, m.tailMap(t2(3, null)).size());
assertEquals(10, m.headMap(t2(2, HI)).size());
assertEquals(15, m.tailMap(t2(2, HI)).size());
}
use of java.util.concurrent.ConcurrentSkipListMap in project pulsar by yahoo.
the class ManagedLedgerOfflineBacklog method estimateUnloadedTopicBacklog.
public PersistentOfflineTopicStats estimateUnloadedTopicBacklog(ManagedLedgerFactoryImpl factory, DestinationName dn) throws Exception {
String managedLedgerName = dn.getPersistenceNamingEncoding();
long numberOfEntries = 0;
long totalSize = 0;
final NavigableMap<Long, MLDataFormats.ManagedLedgerInfo.LedgerInfo> ledgers = new ConcurrentSkipListMap<>();
final PersistentOfflineTopicStats offlineTopicStats = new PersistentOfflineTopicStats(managedLedgerName, brokerName);
// calculate total managed ledger size and number of entries without loading the topic
readLedgerMeta(factory, dn, ledgers);
for (MLDataFormats.ManagedLedgerInfo.LedgerInfo ls : ledgers.values()) {
numberOfEntries += ls.getEntries();
totalSize += ls.getSize();
if (accurate) {
offlineTopicStats.addLedgerDetails(ls.getEntries(), ls.getTimestamp(), ls.getSize(), ls.getLedgerId());
}
}
offlineTopicStats.totalMessages = numberOfEntries;
offlineTopicStats.storageSize = totalSize;
if (log.isDebugEnabled()) {
log.debug("[{}] Total number of entries - {} and size - {}", managedLedgerName, numberOfEntries, totalSize);
}
// calculate per cursor message backlog
calculateCursorBacklogs(factory, dn, ledgers, offlineTopicStats);
offlineTopicStats.statGeneratedAt.setTime(System.currentTimeMillis());
return offlineTopicStats;
}
use of java.util.concurrent.ConcurrentSkipListMap in project opennms by OpenNMS.
the class RadiusAuthMonitorTest method testResponse.
@Test
@Ignore("have to have a radius server set up")
public void testResponse() throws Exception {
final Map<String, Object> m = new ConcurrentSkipListMap<String, Object>();
final ServiceMonitor monitor = new RadiusAuthMonitor();
final MonitoredService svc = MonitorTestUtils.getMonitoredService(99, InetAddressUtils.addr("192.168.211.11"), "RADIUS");
m.put("user", "testing");
m.put("password", "password");
m.put("retry", "1");
m.put("secret", "testing123");
m.put("authtype", "chap");
final PollStatus status = monitor.poll(svc, m);
MockUtil.println("Reason: " + status.getReason());
assertEquals(PollStatus.SERVICE_AVAILABLE, status.getStatusCode());
}
use of java.util.concurrent.ConcurrentSkipListMap in project opennms by OpenNMS.
the class TcpMonitorIT method testExternalServerConnection.
/*
* Test method for 'org.opennms.netmgt.poller.monitors.TcpMonitor.poll(NetworkInterface, Map, Package)'
*/
@Test
public void testExternalServerConnection() throws UnknownHostException {
Map<String, Object> m = new ConcurrentSkipListMap<String, Object>();
Parameter p = new Parameter();
ServiceMonitor monitor = new TcpMonitor();
MonitoredService svc = MonitorTestUtils.getMonitoredService(99, "www.opennms.org", DnsUtils.resolveHostname("www.opennms.org"), "TCP");
p.setKey("port");
p.setValue("3020");
m.put(p.getKey(), p.getValue());
p.setKey("retry");
p.setValue("1");
m.put(p.getKey(), p.getValue());
p.setKey("timeout");
p.setValue("500");
m.put(p.getKey(), p.getValue());
PollStatus status = monitor.poll(svc, m);
MockUtil.println("Reason: " + status.getReason());
assertEquals(PollStatus.SERVICE_UNAVAILABLE, status.getStatusCode());
assertNotNull(status.getReason());
}
use of java.util.concurrent.ConcurrentSkipListMap in project opennms by OpenNMS.
the class TcpMonitorIT method testLocalhostConnection.
@Test
@JUnitHttpServer(port = 10342)
public void testLocalhostConnection() throws UnknownHostException {
Map<String, Object> m = new ConcurrentSkipListMap<String, Object>();
Parameter p = new Parameter();
ServiceMonitor monitor = new TcpMonitor();
MonitoredService svc = MonitorTestUtils.getMonitoredService(3, "localhost", DnsUtils.resolveHostname("localhost"), "TCP");
p.setKey("port");
p.setValue("10342");
m.put(p.getKey(), p.getValue());
p.setKey("retry");
p.setValue("1");
m.put(p.getKey(), p.getValue());
p.setKey("timeout");
p.setValue("500");
m.put(p.getKey(), p.getValue());
PollStatus status = monitor.poll(svc, m);
MockUtil.println("Reason: " + status.getReason());
assertEquals(PollStatus.SERVICE_AVAILABLE, status.getStatusCode());
assertNull(status.getReason());
}
Aggregations