List of usage examples for com.google.common.collect Sets newConcurrentHashSet
public static <E> Set<E> newConcurrentHashSet()
From source file:org.apache.cassandra.castorture.Torturer.java
public static void main(String[] args) { OptionSet options = parseOptions(args); int numElements = (Integer) options.valueOf("n"); int numUpdaters = (Integer) options.valueOf("c"); int retries = (Integer) options.valueOf("r"); String ip = (String) options.valueOf("ip"); System.out.println("Initializing CAS Torture..."); System.out.println("Elements to add: " + numElements); System.out.println("Number of concurrent updaters: " + numUpdaters); System.out.println("Maximum retries per element: " + retries); System.out.println("Initial node ip: " + ip); System.out.println();//from w ww .j a v a 2s . c om Queue<Integer> queue = new ConcurrentLinkedDeque<>(); for (int i = 0; i < numElements; i++) queue.add(i); try { Cluster cluster = new Cluster.Builder().addContactPoints(ip).build(); Session session = cluster.connect(); PreparedStatement update = setup(session); Set<Integer> acked = Sets.newConcurrentHashSet(); List<Updater> updaters = new ArrayList<>(numUpdaters); for (int i = 0; i < numUpdaters; i++) updaters.add(new Updater(session, update, queue, acked, retries)); long start = System.currentTimeMillis(); for (Updater updater : updaters) updater.start(); for (Updater updater : updaters) updater.join(); System.out.println("\nCollecting results."); Set<Integer> survived = collectSurvived(session); System.out.println(survived); long delta = System.currentTimeMillis() - start; System.out.println("Writes completed in " + delta / 1000.0 + " seconds\n"); printReport(numElements, acked, collectSurvived(session)); System.exit(0); } catch (NoHostAvailableException e) { System.err.println("No alive hosts to use: " + e.getMessage()); System.exit(1); } catch (Exception e) { System.err.println("Unexpected error: " + e.getMessage()); e.printStackTrace(); System.exit(1); } }
From source file:components.execution.UniqueBlockingQueue.java
public UniqueBlockingQueue(SimpleBlockingQueue<T> queue) { set = Sets.newConcurrentHashSet(); this.queue = queue; }
From source file:io.atomix.core.set.impl.DefaultDistributedSetService.java
public DefaultDistributedSetService() { super(DistributedSetType.instance(), Sets.newConcurrentHashSet()); }
From source file:com.rh.consulting.twitterroute.CamelRunner.java
public CamelRunner() { routesBuilders = Sets.newConcurrentHashSet(); }
From source file:org.apache.druid.client.SegmentLoadInfo.java
public SegmentLoadInfo(DataSegment segment) { Preconditions.checkNotNull(segment, "segment"); this.segment = segment; this.servers = Sets.newConcurrentHashSet(); }
From source file:org.onosproject.ovsdbrest.OvsdbNodeConfig.java
public Set<OvsdbNode> getNodes() { Set<OvsdbNode> nodes = Sets.newConcurrentHashSet(); JsonNode jsnoNodes = object.path(NODES); jsnoNodes.forEach(node -> {//from w ww .j a va 2 s . c o m IpAddress ovsdbIp = IpAddress.valueOf(node.path(OVSDB_IP).textValue()); TpPort port = TpPort.tpPort(Integer.parseInt(node.path(OVSDB_PORT).asText())); log.info("Ovsdb port: " + port.toString()); nodes.add(new OvsdbNode(ovsdbIp, port)); }); return nodes; }
From source file:com.facebook.buck.io.watchman.WatchmanDiagnosticEventListener.java
public WatchmanDiagnosticEventListener(BuckEventBus outputEventBus) { this(outputEventBus, Sets.newConcurrentHashSet()); }
From source file:org.apache.james.mailrepository.memory.MemoryMailRepositoryUrlStore.java
public MemoryMailRepositoryUrlStore() { urls = Sets.newConcurrentHashSet(); }
From source file:com.mongodb.FakeDB.java
@Override public Set<String> getCollectionNames() { return Sets.newConcurrentHashSet(); }
From source file:org.apache.streams.verbs.VerbDefinitionResolver.java
public List<VerbDefinition> matchingVerbDefinitions(Activity activity) { Set<VerbDefinition> matches = Sets.newConcurrentHashSet(); for (VerbDefinition verbDefinition : verbDefinitionSet) { VerbDefinition verbDefinitionCopy = SerializationUtil.cloneBySerialization(verbDefinition); if (activity.getVerb().equals(verbDefinition.getValue())) { for (ObjectCombination criteria : verbDefinitionCopy.getObjects()) { if (filter(activity, criteria) == false) { verbDefinitionCopy.getObjects().remove(criteria); }// w w w . j av a2 s .c o m } if (verbDefinitionCopy.getObjects().size() > 0) matches.add(verbDefinitionCopy); } } return Lists.newArrayList(matches); }