Example usage for com.google.common.collect Sets newConcurrentHashSet

List of usage examples for com.google.common.collect Sets newConcurrentHashSet

Introduction

In this page you can find the example usage for com.google.common.collect Sets newConcurrentHashSet.

Prototype

public static <E> Set<E> newConcurrentHashSet() 

Source Link

Document

Creates a thread-safe set backed by a hash map.

Usage

From source file:org.pentaho.reporting.platform.plugin.async.JobIdGenerator.java

@Override
public UUID generateId(final IPentahoSession session) {
    ArgumentNullException.validate(SESSION, session);
    final Set<Object> freshSet = Sets.newConcurrentHashSet();
    final UUID uuid = UUID.randomUUID();

    Set<Object> sessionIds = reservedIds.putIfAbsent(session, freshSet);
    if (sessionIds == null) {
        sessionIds = freshSet;//from   www.  j  ava 2  s  .  com
    }
    sessionIds.add(uuid);
    return uuid;
}

From source file:com.navercorp.pinpoint.web.service.map.processor.AcceptApplicationLocalCache.java

public void put(RpcApplication findKey, Set<AcceptApplication> acceptApplicationSet) {
    if (CollectionUtils.isEmpty(acceptApplicationSet)) {

        // initialize for empty value
        this.acceptApplicationLocalCache.putIfAbsent(findKey, Sets.newConcurrentHashSet());
        return;//from   w  w w .  ja  v  a  2  s  .  co  m
    }
    logger.debug("findAcceptApplication:{}", acceptApplicationSet);
    // build cache
    // set AcceptApplication for each url
    for (AcceptApplication acceptApplication : acceptApplicationSet) {
        // acceptApplicationSet data contains the url and the accept node's applicationName.
        // we need to recreate the key set based on the url and the calling application.
        RpcApplication newKey = new RpcApplication(acceptApplication.getHost(), findKey.getApplication());
        Set<AcceptApplication> findSet = this.acceptApplicationLocalCache.get(newKey);
        if (findSet == null) {
            Set<AcceptApplication> set = Sets.newConcurrentHashSet();
            findSet = this.acceptApplicationLocalCache.putIfAbsent(newKey, set);
            if (findSet == null) {
                findSet = set;
            }
        }
        findSet.add(acceptApplication);
    }
}

From source file:org.restcomm.media.control.mgcp.network.netty.MgcpChannelInboundHandler.java

public MgcpChannelInboundHandler() {
    this.observers = Sets.newConcurrentHashSet();
}

From source file:com.google.devtools.build.lib.query2.engine.SiblingsFunction.java

@Override
public <T> QueryTaskFuture<Void> eval(QueryEnvironment<T> env, VariableContext<T> context,
        final QueryExpression expression, List<Argument> args, final Callback<T> callback) {
    final TargetAccessor<T> targetAccessor = env.getAccessor();
    Set<String> packageNames = Sets.newConcurrentHashSet();
    return env.eval(args.get(0).getExpression(), context, new Callback<T>() {
        @Override//from   www .  j a v  a2  s.com
        public void process(Iterable<T> partialResult) throws QueryException, InterruptedException {
            for (T target : partialResult) {
                if (packageNames.add(targetAccessor.getPackage(target))) {
                    callback.process(env.getSiblingTargetsInPackage(target));
                }
            }
        }
    });
}

From source file:org.restcomm.media.control.mgcp.network.netty.AsyncMgcpChannel.java

public AsyncMgcpChannel(NettyNetworkChannelGlobalContext context, MgcpChannelInboundHandler handler) {
    super(context);
    handler.observe(this);
    this.observers = Sets.newConcurrentHashSet();
}

From source file:com.navercorp.pinpoint.web.service.map.ParallelApplicationsMapCreator.java

@Override
public LinkDataDuplexMap createLinkDataDuplexMap(List<Application> applications,
        LinkSelectContext linkSelectContext) {
    final Set<LinkDataDuplexMap> searchResults = Sets.newConcurrentHashSet();
    CompletableFuture[] futures = getLinkDataMapFutures(searchResults, applications, linkSelectContext);
    try {//  ww  w. j a  va  2 s.  com
        CompletableFuture.allOf(futures).join();
    } catch (Exception e) {
        logger.error("Error selecting link", e);
        return new LinkDataDuplexMap();
    }
    LinkDataDuplexMap resultMap = new LinkDataDuplexMap();
    for (LinkDataDuplexMap searchResult : searchResults) {
        resultMap.addLinkDataDuplexMap(searchResult);
    }
    return resultMap;
}

From source file:net.t7seven7t.viewit.SimpleScoreboardService.java

public SimpleScoreboardService(Plugin plugin) {
    this.elementsMap = new MapMaker().weakKeys().makeMap();
    this.elementUpdatesMap = new MapMaker().makeMap();
    this.invisibleTo = Sets.newConcurrentHashSet();
    Bukkit.getPluginManager().registerEvents(new SimpleScoreboardListener(plugin), plugin);
    Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, this::update, 1L,
            plugin.getConfig().getLong("scoreboard-tick-interval", 1L));
}

From source file:com.google.errorprone.apply.DiffApplier.java

public DiffApplier(int diffParallelism, FileSource source, FileDestination destination) {
    Preconditions.checkNotNull(source);//from  w  w w  .j  a  v a  2s.  c  om
    Preconditions.checkNotNull(destination);
    this.diffsFailedPaths = new ConcurrentSkipListSet<>();
    this.refactoredPaths = Sets.newConcurrentHashSet();
    this.source = source;
    this.destination = destination;
    this.completedFiles = new AtomicInteger(0);
    this.stopwatch = Stopwatch.createUnstarted();
    // configure a bounded queue and a rejectedexecutionpolicy.
    // In this case CallerRuns may be appropriate.
    this.workerService = new ThreadPoolExecutor(0, diffParallelism, 5, TimeUnit.SECONDS,
            new ArrayBlockingQueue<Runnable>(50), new ThreadPoolExecutor.CallerRunsPolicy());
}

From source file:org.restcomm.media.control.mgcp.transaction.GlobalMgcpTransactionManager.java

public GlobalMgcpTransactionManager(MgcpTransactionManagerProvider provider) {
    this.provider = provider;
    this.managers = new ConcurrentHashMap<>();
    this.observers = Sets.newConcurrentHashSet();
}

From source file:org.onosproject.ecord.carrierethernet.app.CarrierEthernetEnni.java

@Deprecated
public CarrierEthernetEnni(ConnectPoint cp, String uniCfgId, Role role, VlanId sVlanId, String tpid,
        Bandwidth usedCapacity) {/*  www.j  av  a2 s.c o m*/
    super(cp, Type.ENNI, uniCfgId);
    // TODO: Check for null
    this.role = role;
    this.sVlanIdSet = Sets.newConcurrentHashSet();
    // The following applies only to service-specific ENNIs
    if (sVlanId != null) {
        this.sVlanIdSet.add(sVlanId);
        // TODO: Use Hub/Spoke role correctly
        this.role = Role.HUB;
        this.usedCapacity = usedCapacity;
        this.tpid = tpid;
    }
}