Search in sources :

Example 1 with ConcurrentSkipListMap

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());
}
Also used : ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap) ConcurrentNavigableMap(java.util.concurrent.ConcurrentNavigableMap) Test(org.junit.Test)

Example 2 with ConcurrentSkipListMap

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;
}
Also used : ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap) PersistentOfflineTopicStats(com.yahoo.pulsar.common.policies.data.PersistentOfflineTopicStats) MLDataFormats(org.apache.bookkeeper.mledger.proto.MLDataFormats)

Example 3 with ConcurrentSkipListMap

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());
}
Also used : ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap) ServiceMonitor(org.opennms.netmgt.poller.ServiceMonitor) PollStatus(org.opennms.netmgt.poller.PollStatus) MonitoredService(org.opennms.netmgt.poller.MonitoredService) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 4 with ConcurrentSkipListMap

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());
}
Also used : ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap) ServiceMonitor(org.opennms.netmgt.poller.ServiceMonitor) PollStatus(org.opennms.netmgt.poller.PollStatus) MonitoredService(org.opennms.netmgt.poller.MonitoredService) Parameter(org.opennms.netmgt.config.poller.Parameter) Test(org.junit.Test)

Example 5 with ConcurrentSkipListMap

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());
}
Also used : ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap) ServiceMonitor(org.opennms.netmgt.poller.ServiceMonitor) PollStatus(org.opennms.netmgt.poller.PollStatus) MonitoredService(org.opennms.netmgt.poller.MonitoredService) Parameter(org.opennms.netmgt.config.poller.Parameter) Test(org.junit.Test) JUnitHttpServer(org.opennms.core.test.http.annotations.JUnitHttpServer)

Aggregations

ConcurrentSkipListMap (java.util.concurrent.ConcurrentSkipListMap)183 Test (org.junit.Test)66 PollStatus (org.opennms.netmgt.poller.PollStatus)32 MonitoredService (org.opennms.netmgt.poller.MonitoredService)31 Map (java.util.Map)30 ServiceMonitor (org.opennms.netmgt.poller.ServiceMonitor)25 MqttDeviceTwin (com.microsoft.azure.sdk.iot.device.transport.mqtt.MqttDeviceTwin)23 HashMap (java.util.HashMap)21 DeviceTwinMessage (com.microsoft.azure.sdk.iot.device.DeviceTwin.DeviceTwinMessage)17 NavigableMap (java.util.NavigableMap)14 Set (java.util.Set)12 Iterator (java.util.Iterator)11 NavigableSet (java.util.NavigableSet)11 MockMonitoredService (org.opennms.netmgt.poller.mock.MockMonitoredService)11 IOException (java.io.IOException)10 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)10 ArrayList (java.util.ArrayList)9 BitSet (java.util.BitSet)9 DeviceOperations (com.microsoft.azure.sdk.iot.device.DeviceTwin.DeviceOperations)8 JUnitHttpServer (org.opennms.core.test.http.annotations.JUnitHttpServer)8