Example usage for com.google.common.collect Maps newConcurrentMap

List of usage examples for com.google.common.collect Maps newConcurrentMap

Introduction

In this page you can find the example usage for com.google.common.collect Maps newConcurrentMap.

Prototype

public static <K, V> ConcurrentMap<K, V> newConcurrentMap() 

Source Link

Document

Returns a general-purpose instance of ConcurrentMap , which supports all optional operations of the ConcurrentMap interface.

Usage

From source file:com.gwtplatform.dispatch.rebind.RebindModule.java

@Provides
@Singleton//from   ww w  .  ja  va2s. c  om
Set<JClassType> getRegisteredClassTypes() {
    ConcurrentMap<JClassType, Boolean> backingConcurrentMap = Maps.newConcurrentMap();
    return Collections.newSetFromMap(backingConcurrentMap);
}

From source file:org.syncany.gui.tray.DefaultTrayIcon.java

public DefaultTrayIcon(final Shell shell, final TrayIconTheme theme) {
    super(shell, theme);

    this.trayItem = null;
    this.menu = null;

    this.addFolderMenuItem = null;

    this.watches = Collections.synchronizedList(new ArrayList<File>());
    this.watchedFolderMenuItems = Maps.newConcurrentMap();

    this.recentFileChangesItem = null;

    this.statusTexts = Maps.newConcurrentMap();
    this.statusTextItems = Maps.newConcurrentMap();

    this.images = null;

    setTrayImageResourcesRoot();/*from w  w w  .j  a v  a 2 s.c  om*/
    fillImageCache();
    buildTray();
}

From source file:com.cloudera.hadoop.hdfs.nfs.security.SecurityHandlerFactory.java

public SecurityHandlerFactory(Configuration configuration, Supplier<GSSManager> gssManagerSupplier,
        SessionSecurityHandlerGSSFactory sessionSecurityHandlerGSSFactory) {
    mConfiguration = configuration;//from w  w  w.  jav a2s .c om
    mGSSManagerSupplier = gssManagerSupplier;
    mSessionSecurityHandlerGSSFactory = sessionSecurityHandlerGSSFactory;

    String allowedHosts = mConfiguration.get(SECURITY_ALLOWED_HOSTS, "").trim();
    if (allowedHosts.isEmpty()) {
        throw new IllegalArgumentException("Required argument not found " + SECURITY_ALLOWED_HOSTS);
    }
    mClientHostsMatcher = new ClientHostsMatcher(allowedHosts);
    String securityFlavor = mConfiguration.get(SECURITY_FLAVOR, "").trim();
    if (SECURITY_FLAVOR_KERBEROS.equalsIgnoreCase(securityFlavor)) {
        mKerberosEnabled = true;
    } else if (SECURITY_FLAVOR_DEFAULT.equalsIgnoreCase(securityFlavor)) {
        mKerberosEnabled = false;
    } else {
        throw new IllegalArgumentException("Unknown security flavor '" + securityFlavor + "'");
    }
    mHandlers = Maps.newConcurrentMap();
    mContextIDGenerator = new AtomicInteger(0);
}

From source file:org.apache.drill.exec.cache.local.LocalCache.java

@Override
public void run() throws DrillbitStartupException {
    maps = Maps.newConcurrentMap();
    multiMaps = Maps.newConcurrentMap();
    counters = Maps.newConcurrentMap();
}

From source file:io.druid.client.BrokerServerView.java

@Inject
public BrokerServerView(QueryToolChestWarehouse warehouse, QueryWatcher queryWatcher,
        @Smile ObjectMapper smileMapper, @Client HttpClient httpClient, ServerInventoryView baseView,
        TierSelectorStrategy tierSelectorStrategy, ServiceEmitter emitter) {
    this.warehouse = warehouse;
    this.queryWatcher = queryWatcher;
    this.smileMapper = smileMapper;
    this.httpClient = httpClient;
    this.baseView = baseView;
    this.tierSelectorStrategy = tierSelectorStrategy;
    this.emitter = emitter;

    this.clients = Maps.newConcurrentMap();
    this.selectors = Maps.newHashMap();
    this.timelines = Maps.newHashMap();

    ExecutorService exec = Execs.singleThreaded("BrokerServerView-%s");
    baseView.registerSegmentCallback(exec, new ServerView.SegmentCallback() {
        @Override//  w ww.  ja  v  a 2 s .  c  om
        public ServerView.CallbackAction segmentAdded(DruidServerMetadata server, DataSegment segment) {
            serverAddedSegment(server, segment);
            return ServerView.CallbackAction.CONTINUE;
        }

        @Override
        public ServerView.CallbackAction segmentRemoved(final DruidServerMetadata server, DataSegment segment) {
            serverRemovedSegment(server, segment);
            return ServerView.CallbackAction.CONTINUE;
        }

        @Override
        public CallbackAction segmentViewInitialized() {
            initialized = true;
            return ServerView.CallbackAction.CONTINUE;
        }
    });

    baseView.registerServerCallback(exec, new ServerView.ServerCallback() {
        @Override
        public ServerView.CallbackAction serverRemoved(DruidServer server) {
            removeServer(server);
            return ServerView.CallbackAction.CONTINUE;
        }
    });
}

From source file:org.onosproject.incubator.store.virtual.impl.SimpleVirtualFlowObjectiveStore.java

protected ConcurrentMap<Integer, byte[]> getNextGroups(NetworkId networkId) {
    nextGroupsMap.computeIfAbsent(networkId, n -> Maps.newConcurrentMap());
    return nextGroupsMap.get(networkId);
}

From source file:io.soabase.core.SoaFeaturesImpl.java

@Override
public <T> void putNamed(T o, Class<T> clazz, String name) {
    clazz = Preconditions.checkNotNull(clazz, "clazz cannot be null");
    name = Preconditions.checkNotNull(name, "name cannot be null");
    o = Preconditions.checkNotNull(o, "object cannot be null");
    Preconditions.checkArgument(name.length() > 0, "name cannot be the empty string");

    ConcurrentMap<String, Object> newMap = Maps.newConcurrentMap();
    ConcurrentMap<String, Object> oldMap = named.putIfAbsent(clazz, newMap);
    ConcurrentMap<String, Object> useMap = (oldMap != null) ? oldMap : newMap;

    Object old = useMap.putIfAbsent(name, o);
    Preconditions.checkArgument(old == null,
            "Named value already set for: " + name + " and " + clazz.getName());
}

From source file:org.onosproject.store.consistent.impl.PartitionedDatabase.java

@Override
public CompletableFuture<Map<String, Long>> counters() {
    checkState(isOpen.get(), DB_NOT_OPEN);
    Map<String, Long> counters = Maps.newConcurrentMap();
    return CompletableFuture.allOf(partitions.stream().map(db -> db.counters().thenApply(m -> {
        counters.putAll(m);/*  w w  w.j  a  v a 2s . c  o m*/
        return null;
    })).toArray(CompletableFuture[]::new)).thenApply(v -> counters);
}

From source file:com.quancheng.saluki.core.grpc.client.GrpcClientStrategy.java

private Map<String, Integer> cacheRetries(String[] methodNames, int reties) {
    Map<String, Integer> methodRetries = Maps.newConcurrentMap();
    if (reties > 0) {
        if (methodNames != null && methodNames.length > 1) {
            for (String methodName : methodNames) {
                methodRetries.putIfAbsent(methodName, Integer.valueOf(reties));
            }//from   w w w  .ja  v a 2  s . c o  m
        } else {
            methodRetries.putIfAbsent("*", Integer.valueOf(reties));
        }
    }
    return methodRetries;
}

From source file:org.ldp4j.application.kernel.impl.InMemoryContainer.java

InMemoryContainer(ResourceId id, ResourceId parentId) {
    super(id, parentId);
    this.members = Maps.newConcurrentMap();
    this.memberCounter = new AtomicLong();
    this.slugs = Maps.newConcurrentMap();
}