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);
}
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();
}
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());
}
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();
}
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;
}
Aggregations