Search in sources :

Example 11 with ConcurrentSkipListSet

use of java.util.concurrent.ConcurrentSkipListSet in project mapdb by jankotek.

the class ConcurrentSkipListSubSetTest method set0.

private static NavigableSet set0() {
    ConcurrentSkipListSet set = new ConcurrentSkipListSet();
    assertTrue(set.isEmpty());
    return set.tailSet(m1, true);
}
Also used : ConcurrentSkipListSet(java.util.concurrent.ConcurrentSkipListSet)

Example 12 with ConcurrentSkipListSet

use of java.util.concurrent.ConcurrentSkipListSet in project Mycat-Server by MyCATApache.

the class IncrSequenceZKHandlerTest method initialize.

@Before
public void initialize() throws Exception {
    testingServer = new TestingServer();
    testingServer.start();
    incrSequenceZKHandler = new IncrSequenceZKHandler[MAX_CONNECTION];
    results = new ConcurrentSkipListSet();
}
Also used : TestingServer(org.apache.curator.test.TestingServer) ConcurrentSkipListSet(java.util.concurrent.ConcurrentSkipListSet) Before(org.junit.Before)

Example 13 with ConcurrentSkipListSet

use of java.util.concurrent.ConcurrentSkipListSet in project graylog2-server by Graylog2.

the class GelfChunkAggregatorTest method testChunkEntryCompareTo.

@Test
public void testChunkEntryCompareTo() throws Exception {
    // Test if the ChunkEntry#compareTo() method can handle ChunkEntry objects which have the same timestamp.
    // See: https://github.com/Graylog2/graylog2-server/issues/1462
    final ConcurrentSkipListSet<GelfChunkAggregator.ChunkEntry> sortedEvictionSet = new ConcurrentSkipListSet<>();
    final long currentTime = System.currentTimeMillis();
    for (int i = 0; i < 10; i++) {
        sortedEvictionSet.add(new GelfChunkAggregator.ChunkEntry(1, currentTime, "a" + i));
    }
    final int size = sortedEvictionSet.size();
    for (int i = 0; i < size; i++) {
        sortedEvictionSet.remove(sortedEvictionSet.first());
    }
    assertTrue("eviction set should be empty", sortedEvictionSet.isEmpty());
}
Also used : ChunkEntry(org.graylog2.inputs.codecs.GelfChunkAggregator.ChunkEntry) ConcurrentSkipListSet(java.util.concurrent.ConcurrentSkipListSet) ChunkEntry(org.graylog2.inputs.codecs.GelfChunkAggregator.ChunkEntry) Test(org.junit.Test)

Example 14 with ConcurrentSkipListSet

use of java.util.concurrent.ConcurrentSkipListSet in project opennms by OpenNMS.

the class JRobinConverter method execute.

public void execute(final String[] args) throws ParseException, ConverterException, RrdException {
    if (args.length == 0) {
        LogUtils.errorf(this, "no files or directories specified!");
        System.exit(1);
    }
    final Options options = new Options();
    options.addOption("h", "help", false, "This help.");
    options.addOption("f", "factory", true, "The JRobin factory to use. (Default: " + DEFAULT_JROBIN_FACTORY + ")");
    options.addOption("l", "log", true, "The log level to use. (Default: " + DEFAULT_LOG_LEVEL + ")");
    options.addOption("t", "threads", true, "Number of threads to start. (Default: " + DEFAULT_NUMBER_OF_THREADS + ")");
    options.addOption("c", "clean", false, "Remove old single-metric JRBs and temporal files. (Use it only after migrating all your files)");
    options.addOption("v", "validate", false, "Validate current JRBs ffiles.");
    final CommandLineParser parser = new GnuParser();
    final CommandLine cmd = parser.parse(options, args);
    LogUtils.setLevel(Level.valueOf(cmd.getOptionValue("l", DEFAULT_LOG_LEVEL)));
    RrdBackendFactory.setDefaultFactory(cmd.getOptionValue("f", DEFAULT_JROBIN_FACTORY));
    final Set<File> rrds = new ConcurrentSkipListSet<File>();
    if (cmd.hasOption("h")) {
        new HelpFormatter().printHelp("jrobin-converter [options] [file-or-directory1] [...file-or-directoryN]", options);
        System.exit(1);
    }
    if (cmd.getArgList().size() == 0) {
        LogUtils.infof(this, "No files or directories specified!  Exiting.");
        System.exit(0);
    }
    if (cmd.hasOption("c")) {
        new RrdCleaner().execute(cmd);
        System.exit(1);
    }
    if (cmd.hasOption("v")) {
        new RrdValidator().execute(cmd);
        System.exit(1);
    }
    int threads = DEFAULT_NUMBER_OF_THREADS;
    if (cmd.hasOption("t")) {
        try {
            threads = Integer.valueOf(cmd.getOptionValue("t"));
        } catch (final NumberFormatException e) {
            LogUtils.warnf(JRobinConverter.class, e, "failed to format -t %s to a number", cmd.getOptionValue("t"));
        }
    }
    final ExecutorService executor = Executors.newFixedThreadPool(threads);
    for (final Object arg : cmd.getArgList()) {
        LogUtils.infof(this, "Scanning %s for storeByGroup data.", arg);
        final File f = new File((String) arg);
        if (f.exists()) {
            if (f.isDirectory()) {
                rrds.addAll(findGroupRrds(f));
                for (final File rrdFile : findGroupRrds(f)) {
                    consolidateRrd(executor, rrdFile);
                }
            } else {
                consolidateRrd(executor, f);
            }
        }
    }
    LogUtils.infof(this, "Finished scanning for storeByGroup RRDs. (Total RRD count: %d)", m_total.get());
    executor.shutdown();
}
Also used : Options(org.apache.commons.cli.Options) ConcurrentSkipListSet(java.util.concurrent.ConcurrentSkipListSet) GnuParser(org.apache.commons.cli.GnuParser) HelpFormatter(org.apache.commons.cli.HelpFormatter) CommandLine(org.apache.commons.cli.CommandLine) ExecutorService(java.util.concurrent.ExecutorService) CommandLineParser(org.apache.commons.cli.CommandLineParser) File(java.io.File)

Example 15 with ConcurrentSkipListSet

use of java.util.concurrent.ConcurrentSkipListSet in project gora by apache.

the class JCacheStore method getPartitions.

@Override
public List<PartitionQuery<K, T>> getPartitions(Query<K, T> query) throws IOException {
    List<PartitionQuery<K, T>> partitions = new ArrayList<>();
    try {
        Member[] clusterMembers = new Member[hazelcastInstance.getCluster().getMembers().size()];
        this.hazelcastInstance.getCluster().getMembers().toArray(clusterMembers);
        for (Member member : clusterMembers) {
            JCacheResult<K, T> result = ((JCacheResult<K, T>) query.execute());
            ConcurrentSkipListSet<K> memberOwnedCacheEntries = new ConcurrentSkipListSet<>();
            while (result.next()) {
                K key = result.getKey();
                Partition partition = hazelcastInstance.getPartitionService().getPartition(key);
                if (partition.getOwner().getUuid().equals(member.getUuid())) {
                    memberOwnedCacheEntries.add(key);
                }
            }
            PartitionQueryImpl<K, T> partition = new PartitionQueryImpl<>(query, memberOwnedCacheEntries.first(), memberOwnedCacheEntries.last(), member.getSocketAddress().getHostString());
            partition.setConf(this.getConf());
            partitions.add(partition);
        }
    } catch (java.lang.Exception ex) {
        LOG.error("Exception occurred while partitioning the query based on Hazelcast partitions.", ex);
        return null;
    }
    LOG.info("Query is partitioned to {} number of partitions.", partitions.size());
    return partitions;
}
Also used : Partition(com.hazelcast.core.Partition) PartitionQueryImpl(org.apache.gora.query.impl.PartitionQueryImpl) ConcurrentSkipListSet(java.util.concurrent.ConcurrentSkipListSet) ArrayList(java.util.ArrayList) PartitionQuery(org.apache.gora.query.PartitionQuery) Member(com.hazelcast.core.Member)

Aggregations

ConcurrentSkipListSet (java.util.concurrent.ConcurrentSkipListSet)17 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 ByteBuffer (java.nio.ByteBuffer)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 NavigableSet (java.util.NavigableSet)2 Set (java.util.Set)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 ExecutorService (java.util.concurrent.ExecutorService)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 Ignite (org.apache.ignite.Ignite)2 DefaultMQPullConsumer (com.alibaba.rocketmq.client.consumer.DefaultMQPullConsumer)1 OffsetStore (com.alibaba.rocketmq.client.consumer.store.OffsetStore)1 MQClientException (com.alibaba.rocketmq.client.exception.MQClientException)1 MessageExt (com.alibaba.rocketmq.common.message.MessageExt)1 MessageQueue (com.alibaba.rocketmq.common.message.MessageQueue)1 LongObjectHashMap (com.carrotsearch.hppc.LongObjectHashMap)1