コード例 #1
0
 private List<QueryQueue> getOrCreateQueues(
     Session session, Executor executor, List<QueryQueueDefinition> definitions) {
   ImmutableList.Builder<QueryQueue> queues = ImmutableList.builder();
   for (QueryQueueDefinition definition : definitions) {
     String expandedName = definition.getExpandedTemplate(session);
     QueueKey key = new QueueKey(definition, expandedName);
     if (!queryQueues.containsKey(key)) {
       QueryQueue queue =
           new QueryQueue(executor, definition.getMaxQueued(), definition.getMaxConcurrent());
       if (queryQueues.putIfAbsent(key, queue) == null) {
         // Export the mbean, after checking for races
         String objectName =
             ObjectNames.builder(QueryQueue.class, definition.getTemplate())
                 .withProperty("expansion", expandedName)
                 .build();
         mbeanExporter.export(objectName, queue);
       }
     }
     queues.add(queryQueues.get(key));
   }
   return queues.build();
 }