Java Code Examples for com.google.common.collect.Multimaps#synchronizedSetMultimap()

The following examples show how to use com.google.common.collect.Multimaps#synchronizedSetMultimap() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RemoteConfigLongPollService.java    From apollo with Apache License 2.0 6 votes vote down vote up
/**
 * Constructor.
 */
public RemoteConfigLongPollService() {
  m_longPollFailSchedulePolicyInSecond = new ExponentialSchedulePolicy(1, 120); //in second
  m_longPollingStopped = new AtomicBoolean(false);
  m_longPollingService = Executors.newSingleThreadExecutor(
      ApolloThreadFactory.create("RemoteConfigLongPollService", true));
  m_longPollStarted = new AtomicBoolean(false);
  m_longPollNamespaces =
      Multimaps.synchronizedSetMultimap(HashMultimap.<String, RemoteConfigRepository>create());
  m_notifications = Maps.newConcurrentMap();
  m_remoteNotificationMessages = Maps.newConcurrentMap();
  m_responseType = new TypeToken<List<ApolloConfigNotification>>() {
  }.getType();
  gson = new Gson();
  m_configUtil = ApolloInjector.getInstance(ConfigUtil.class);
  m_httpUtil = ApolloInjector.getInstance(HttpUtil.class);
  m_serviceLocator = ApolloInjector.getInstance(ConfigServiceLocator.class);
  m_longPollRateLimiter = RateLimiter.create(m_configUtil.getLongPollQPS());
}
 
Example 2
Source File: Consultant.java    From consultant with Apache License 2.0 6 votes vote down vote up
private Consultant(ScheduledExecutorService executor, ObjectMapper mapper, URI consulUri,
		ServiceIdentifier identifier, SetMultimap<String, SettingListener> settingListeners,
		Set<ConfigListener> configListeners, ConfigValidator validator, CloseableHttpClient http,
		boolean pullConfig, String healthEndpoint, String kvPrefix, long whenLocatingServicesCacheResultsFor) {

	this.registered = new AtomicBoolean();
	this.settingListeners = Multimaps.synchronizedSetMultimap(settingListeners);
	this.configListeners = Sets.newConcurrentHashSet(configListeners);
	this.serviceInstanceBackend = new ServiceInstanceBackend(identifier.getDatacenter(), consulUri, mapper, http,
			whenLocatingServicesCacheResultsFor);

	this.mapper = mapper;
	this.validator = validator;
	this.executor = executor;
	this.consulUri = consulUri;
	this.id = identifier;
	this.pullConfig = pullConfig;
	this.validated = new Properties();
	this.healthEndpoint = healthEndpoint;
	this.http = http;
	this.kvPrefix = kvPrefix;
}
 
Example 3
Source File: EventDeadLettersContract.java    From james-project with Apache License 2.0 6 votes vote down vote up
@Test
default void storeShouldKeepConsistencyWhenConcurrentStore() throws Exception {
    EventDeadLetters eventDeadLetters = eventDeadLetters();

    ImmutableMap<Integer, Group> groups = concurrentGroups();
    Multimap<Integer, EventDeadLetters.InsertionId> storedInsertionIds = Multimaps.synchronizedSetMultimap(HashMultimap.create());

    ConcurrentTestRunner.builder()
        .operation((threadNumber, step) -> {
            Event.EventId eventId = Event.EventId.random();
            EventDeadLetters.InsertionId insertionId = eventDeadLetters.store(groups.get(threadNumber), event(eventId)).block();
            storedInsertionIds.put(threadNumber, insertionId);
        })
        .threadCount(THREAD_COUNT)
        .operationCount(OPERATION_COUNT)
        .runSuccessfullyWithin(RUN_SUCCESSFULLY_IN);

    groups.forEach((groupId, group) -> {
        Group storedGroup = groups.get(groupId);
        assertThat(eventDeadLetters.failedIds(storedGroup).collectList().block())
            .hasSameElementsAs(storedInsertionIds.get(groupId));
    });
}
 
Example 4
Source File: GrayReleaseRulesHolder.java    From apollo with Apache License 2.0 5 votes vote down vote up
public GrayReleaseRulesHolder() {
  loadVersion = new AtomicLong();
  grayReleaseRuleCache = Multimaps.synchronizedSetMultimap(
      TreeMultimap.create(String.CASE_INSENSITIVE_ORDER, Ordering.natural()));
  reversedGrayReleaseRuleCache = Multimaps.synchronizedSetMultimap(
      TreeMultimap.create(String.CASE_INSENSITIVE_ORDER, Ordering.natural()));
  executorService = Executors.newScheduledThreadPool(1, ApolloThreadFactory
      .create("GrayReleaseRulesHolder", true));
}
 
Example 5
Source File: MockZooKeeper.java    From pulsar with Apache License 2.0 5 votes vote down vote up
private void init(ExecutorService executor) {
    tree = Maps.newTreeMap();
    if (executor != null) {
        this.executor = executor;
    } else {
        this.executor = Executors.newFixedThreadPool(1, new DefaultThreadFactory("mock-zookeeper"));
    }
    SetMultimap<String, Watcher> w = HashMultimap.create();
    watchers = Multimaps.synchronizedSetMultimap(w);
    stopped = false;
    alwaysFail = new AtomicReference<>(KeeperException.Code.OK);
    failures = new CopyOnWriteArrayList<>();
}
 
Example 6
Source File: RibManager.java    From atrium-odl with Apache License 2.0 5 votes vote down vote up
@Override
public void onSessionInitiated(ProviderContext session) {
	LOG.info("Router Session Initiated");
	routesWaitingOnArp = Multimaps.synchronizedSetMultimap(HashMultimap.<AtriumIpAddress, RouteEntry> create());
	ribTable4 = new ConcurrentInvertedRadixTree<>(new DefaultByteArrayNodeFactory());
	bgpUpdatesExecutor = Executors
			.newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat("atrium-bgp-updates-%d").build());
}
 
Example 7
Source File: InVMEventBus.java    From james-project with Apache License 2.0 5 votes vote down vote up
@Inject
public InVMEventBus(EventDelivery eventDelivery, RetryBackoffConfiguration retryBackoff, EventDeadLetters eventDeadLetters) {
    this.eventDelivery = eventDelivery;
    this.retryBackoff = retryBackoff;
    this.eventDeadLetters = eventDeadLetters;
    this.registrations = Multimaps.synchronizedSetMultimap(HashMultimap.create());
    this.groups = new ConcurrentHashMap<>();
}
 
Example 8
Source File: StateChangeNotifier.java    From tez with Apache License 2.0 5 votes vote down vote up
public StateChangeNotifier(DAG dag) {
  this.dag = dag;
  this.vertexListeners = Multimaps.synchronizedSetMultimap(
      HashMultimap.<TezVertexID, ListenerContainer>create());
  this.lastKnowStatesMap = LinkedListMultimap.create();
  startThread();
}
 
Example 9
Source File: ApplicationSlaStoreCache.java    From titus-control-plane with Apache License 2.0 4 votes vote down vote up
private Multimap<String, ApplicationSLA> loadSchedulerMapCache(Map<String, ApplicationSLA> starterCache) {
    Multimap<String, ApplicationSLA> schedulerMapCache = Multimaps.synchronizedSetMultimap(HashMultimap.create());
    starterCache.values().forEach(applicationSLA -> schedulerMapCache.put(applicationSLA.getSchedulerName(), applicationSLA));
    return schedulerMapCache;
}
 
Example 10
Source File: MutableContextSetImpl.java    From LuckPerms with MIT License 4 votes vote down vote up
public MutableContextSetImpl() {
    this.map = Multimaps.synchronizedSetMultimap(HashMultimap.create());
}
 
Example 11
Source File: MutableContextSetImpl.java    From LuckPerms with MIT License 4 votes vote down vote up
MutableContextSetImpl(SetMultimap<String, String> other) {
    this.map = Multimaps.synchronizedSetMultimap(HashMultimap.create(other));
}
 
Example 12
Source File: InMemoryAttachmentMapper.java    From james-project with Apache License 2.0 4 votes vote down vote up
public InMemoryAttachmentMapper() {
    attachmentsById = new ConcurrentHashMap<>(INITIAL_SIZE);
    attachmentsRawContentById = new ConcurrentHashMap<>(INITIAL_SIZE);
    messageIdsByAttachmentId = Multimaps.synchronizedSetMultimap(HashMultimap.create());
    ownersByAttachmentId = Multimaps.synchronizedSetMultimap(HashMultimap.create());
}
 
Example 13
Source File: DeviceConfiguration.java    From onos with Apache License 2.0 4 votes vote down vote up
public SegmentRouterInfo() {
    gatewayIps = Multimaps.synchronizedSetMultimap(HashMultimap.create());
    subnets = Multimaps.synchronizedSetMultimap(HashMultimap.create());
}
 
Example 14
Source File: CacheManager.java    From elasticactors with Apache License 2.0 4 votes vote down vote up
public CacheManager(int maximumSize) {
    backingCache = CacheBuilder.newBuilder().maximumSize(maximumSize)
                                            .removalListener(globalRemovalListener).build();
    segmentIndex = Multimaps.synchronizedSetMultimap(HashMultimap.<Object,CacheKey>create());
}
 
Example 15
Source File: MutableDirectedGraph.java    From buck with Apache License 2.0 4 votes vote down vote up
public static <T> MutableDirectedGraph<T> createConcurrent() {
  return new MutableDirectedGraph<>(
      Collections.newSetFromMap(new ConcurrentHashMap<T, Boolean>()),
      Multimaps.synchronizedSetMultimap(HashMultimap.create()),
      Multimaps.synchronizedSetMultimap(HashMultimap.create()));
}