List of usage examples for java.util.concurrent ConcurrentSkipListSet ConcurrentSkipListSet
public ConcurrentSkipListSet()
From source file:org.vaadin.spring.navigator.SpringViewProvider.java
@PostConstruct void init() {/*w w w.j a v a 2s . c o m*/ logger.info("Looking up VaadinViews"); final String[] viewBeanNames = applicationContext.getBeanNamesForAnnotation(VaadinView.class); for (String beanName : viewBeanNames) { final Class<?> type = applicationContext.getType(beanName); if (View.class.isAssignableFrom(type)) { final VaadinView annotation = type.getAnnotation(VaadinView.class); final String viewName = annotation.name(); logger.debug(String.format("Found VaadinView bean [%s] with view name [%s]", beanName, viewName)); Set<String> beanNames = viewNameToBeanNamesMap.get(viewName); if (beanNames == null) { beanNames = new ConcurrentSkipListSet<>(); viewNameToBeanNamesMap.put(viewName, beanNames); } beanNames.add(beanName); } } }
From source file:org.darkware.wpman.security.ChecksumDatabase.java
/** * Create a new {@code ChecksumDatabase} for files under the declared root and using the * given file for saved state./*from w w w.ja va 2 s.c o m*/ * * @param dbFile The file to load and store the database data into. * @param root The highest level directory represented in the database. */ public ChecksumDatabase(final Path dbFile, final Path root) { super(); this.root = root; this.dbFile = dbFile; this.hashes = new ConcurrentSkipListMap<>(); this.suppressed = new ConcurrentSkipListSet<>(); this.initialized = new AtomicBoolean(false); this.lock = new ReentrantReadWriteLock(); this.initialize(); }
From source file:com.joshlong.esb.springintegration.modules.net.feed.web.test.SimpleRSSSynthesizingServlet.java
public void afterPropertiesSet() throws Exception { this.newsItems = new ConcurrentSkipListSet<NewsItem>(); this.feedUtils = new FeedUtils(); this.feedUtils.afterPropertiesSet(); this.objectToItemConvertorStrategy = new MyNewsItemToItemConvertorStrategy(); }
From source file:io.pravega.segmentstore.server.host.ZKSegmentContainerMonitor.java
/** * Creates an instance of ZKSegmentContainerMonitor. * * @param containerRegistry The registry used to control the container state. * @param zkClient The curator client. * @param pravegaServiceEndpoint The pravega endpoint for which we need to fetch the container assignment. *//* w w w. j ava 2s.c o m*/ ZKSegmentContainerMonitor(SegmentContainerRegistry containerRegistry, CuratorFramework zkClient, Host pravegaServiceEndpoint, ScheduledExecutorService executor) { Preconditions.checkNotNull(zkClient, "zkClient"); this.registry = Preconditions.checkNotNull(containerRegistry, "containerRegistry"); this.host = Preconditions.checkNotNull(pravegaServiceEndpoint, "pravegaServiceEndpoint"); this.executor = Preconditions.checkNotNull(executor, "executor"); this.handles = new ConcurrentHashMap<>(); this.pendingTasks = new ConcurrentSkipListSet<>(); String clusterPath = ZKPaths.makePath("cluster", "segmentContainerHostMapping"); this.hostContainerMapNode = new NodeCache(zkClient, clusterPath); this.assigmentTask = new AtomicReference<>(); }
From source file:annis.gui.flatquerybuilder.ValueField.java
@Override public void textChange(TextChangeEvent event) { ReducingStringComparator rsc = sq.getRSC(); String fm = sq.getFilterMechanism(); if (!"generic".equals(fm)) { ConcurrentSkipListSet<String> notInYet = new ConcurrentSkipListSet<>(); String txt = event.getText(); if (!txt.equals("")) { scb.removeAllItems();//from ww w . j av a 2 s . co m for (Iterator<String> it = values.keySet().iterator(); it.hasNext();) { String s = it.next(); if (rsc.compare(s, txt, fm) == 0) { scb.addItem(s); } else { notInYet.add(s); } } //startsWith for (String s : notInYet) { if (rsc.startsWith(s, txt, fm)) { scb.addItem(s); notInYet.remove(s); } } //contains for (String s : notInYet) { if (rsc.contains(s, txt, fm)) { scb.addItem(s); } } } else { buildValues(this.vm); } } else { String txt = event.getText(); HashMap<Integer, Collection> levdistvals = new HashMap<>(); if (txt.length() > 1) { scb.removeAllItems(); for (String s : values.keySet()) { Integer d = StringUtils.getLevenshteinDistance(removeAccents(txt).toLowerCase(), removeAccents(s).toLowerCase()); if (levdistvals.containsKey(d)) { levdistvals.get(d).add(s); } if (!levdistvals.containsKey(d)) { Set<String> newc = new TreeSet<>(); newc.add(s); levdistvals.put(d, newc); } } SortedSet<Integer> keys = new TreeSet<>(levdistvals.keySet()); for (Integer k : keys.subSet(0, 10)) { List<String> valueList = new ArrayList(levdistvals.get(k)); Collections.sort(valueList, String.CASE_INSENSITIVE_ORDER); for (String v : valueList) { scb.addItem(v); } } } } }
From source file:net.mach6.listeners.DependencyReportingListener.java
@Override public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) { if (Option.ENABLED.isSet("false")) { return;/*from www. jav a2 s .c om*/ } final String TOP_DIR = outputDirectory + OUTPUT_DIR; // Clean out any old results, if they exist FileUtils.deleteQuietly(new File(TOP_DIR)); // Build the TestSuiteInfo Set Set<TestSuiteInfo> suiteInfoSet = new ConcurrentSkipListSet<>(); for (ISuite suite : suites) { TestSuiteInfo suiteInfo = new TestSuiteInfo(suite); suiteInfoSet.add(suiteInfo); } generateOutput(suiteInfoSet, TOP_DIR); logCompletion(suiteInfoSet); }
From source file:org.springframework.kafka.listener.ConcurrentMessageListenerContainerTests.java
@Test public void testAutoCommit() throws Exception { this.logger.info("Start auto"); Map<String, Object> props = KafkaTestUtils.consumerProps("test1", "true", embeddedKafka); DefaultKafkaConsumerFactory<Integer, String> cf = new DefaultKafkaConsumerFactory<>(props); ContainerProperties containerProps = new ContainerProperties(topic1); final CountDownLatch latch = new CountDownLatch(4); final Set<String> listenerThreadNames = new ConcurrentSkipListSet<>(); containerProps.setMessageListener((MessageListener<Integer, String>) message -> { ConcurrentMessageListenerContainerTests.this.logger.info("auto: " + message); listenerThreadNames.add(Thread.currentThread().getName()); latch.countDown();/*from ww w .ja v a2 s .co m*/ }); ConcurrentMessageListenerContainer<Integer, String> container = new ConcurrentMessageListenerContainer<>(cf, containerProps); container.setConcurrency(2); container.setBeanName("testAuto"); container.start(); ContainerTestUtils.waitForAssignment(container, embeddedKafka.getPartitionsPerTopic()); Map<String, Object> senderProps = KafkaTestUtils.producerProps(embeddedKafka); ProducerFactory<Integer, String> pf = new DefaultKafkaProducerFactory<>(senderProps); KafkaTemplate<Integer, String> template = new KafkaTemplate<>(pf); template.setDefaultTopic(topic1); template.sendDefault(0, "foo"); template.sendDefault(2, "bar"); template.sendDefault(0, "baz"); template.sendDefault(2, "qux"); template.flush(); assertThat(latch.await(60, TimeUnit.SECONDS)).isTrue(); assertThat(listenerThreadNames).allMatch(threadName -> threadName.contains("-consumer-")); @SuppressWarnings("unchecked") List<KafkaMessageListenerContainer<Integer, String>> containers = KafkaTestUtils.getPropertyValue(container, "containers", List.class); assertThat(containers.size()).isEqualTo(2); for (int i = 0; i < 2; i++) { assertThat(KafkaTestUtils.getPropertyValue(containers.get(i), "listenerConsumer.acks", Collection.class) .size()).isEqualTo(0); } container.stop(); this.logger.info("Stop auto"); }
From source file:org.apache.qpid.server.security.group.FileGroupDatabase.java
@Override public synchronized void createGroup(String group) { Set<String> users = new ConcurrentSkipListSet<String>(); _groupToUserMap.put(group, users);// ww w. j a va2 s . co m update(); }
From source file:com.googlecode.fightinglayoutbugs.DetectInvalidImageUrls.java
public Collection<LayoutBug> findLayoutBugsIn(@Nonnull WebPage webPage) { try {//from w w w.j a v a2 s .c o m _webPage = webPage; _baseUrl = _webPage.getUrl(); _documentCharset = (String) _webPage.executeJavaScript("return document.characterSet"); _screenshotTaken = false; _checkedCssUrls = new ConcurrentSkipListSet<String>(); _faviconUrl = "/favicon.ico"; _layoutBugs = new ArrayList<LayoutBug>(); _mockBrowser = new MockBrowser( _httpClient == null ? new HttpClient(new MultiThreadedHttpConnectionManager()) : _httpClient); try { // 1. Check the src attribute of all visible <img> elements ... checkVisibleImgElements(); // 2. Check the style attribute of all elements ... checkStyleAttributes(); // 3. Check all <style> elements ... checkStyleElements(); // 4. Check all linked CSS resources ... checkLinkedCss(); // 5. Check favicon ... checkFavicon(); // 6. Wait until all asynchronous checks are finished ... _mockBrowser.waitUntilAllDownloadsAreFinished(); return _layoutBugs; } finally { _mockBrowser.dispose(); } } finally { // Free resources for garbage collection ... _mockBrowser = null; _layoutBugs = null; _faviconUrl = null; _checkedCssUrls = null; _documentCharset = null; _baseUrl = null; _webPage = null; } }