List of usage examples for com.google.common.collect Maps newConcurrentMap
public static <K, V> ConcurrentMap<K, V> newConcurrentMap()
From source file:com.querydsl.webhooks.GithubReviewWindow.java
@Bean public PullRequestHandler reviewWindowHandler(Environment environment) { Duration defaultReviewWindow = Duration.parse(environment.getRequiredProperty("duration")); //duration is the default window Map<String, ScheduledFuture<?>> asyncTasks = Maps.newConcurrentMap(); return payload -> { PullRequest pullRequest = payload.getPullRequest(); Ref head = pullRequest.getHead(); try {//from ww w .j av a2 s . c om GHRepository repository = github.getRepository(payload.getRepository().getFullName()); Collection<GHLabel> labels = repository.getIssue(pullRequest.getNumber()).getLabels(); Duration reviewTime = labels.stream().map(label -> "duration." + label.getName()) //for all duration.[label] properties .map(environment::getProperty).filter(Objects::nonNull) //look for a Duration .findFirst().map(Duration::parse).orElse(defaultReviewWindow); //if none found, use the default window ZonedDateTime creationTime = pullRequest.getCreatedAt(); ZonedDateTime windowCloseTime = creationTime.plus(reviewTime); boolean windowPassed = now().isAfter(windowCloseTime); logger.info("creationTime({}) + reviewTime({}) = windowCloseTime({}), so windowPassed = {}", creationTime, reviewTime, windowCloseTime, windowPassed); if (windowPassed) { completeAndCleanUp(asyncTasks, repository, head); } else { createPendingMessage(repository, head, reviewTime); ScheduledFuture<?> scheduledTask = taskScheduler.schedule( () -> completeAndCleanUp(asyncTasks, repository, head), Date.from(windowCloseTime.toInstant())); replaceCompletionTask(asyncTasks, scheduledTask, head); } } catch (IOException ex) { throw Throwables.propagate(ex); } }; }
From source file:com.moz.fiji.mapreduce.kvstore.KeyValueStoreReaderFactory.java
/** * Creates a KeyValueStoreReaderFactory backed by a map of specific store bindings. * * @param storeBindings defines the set of KeyValueStores available, and the * names by which they are registered. *//*w w w .j ava 2 s . co m*/ private KeyValueStoreReaderFactory(Map<String, KeyValueStore<?, ?>> storeBindings) { mKeyValueStores = Collections.unmodifiableMap(new HashMap<String, KeyValueStore<?, ?>>(storeBindings)); mKVStoreReaderCache = Maps.newConcurrentMap(); }
From source file:co.cask.cdap.route.store.ZKRouteStore.java
@Inject public ZKRouteStore(ZKClient zkClient) { this.zkClient = zkClient; this.routeConfigMap = Maps.newConcurrentMap(); }
From source file:ro.cosu.vampires.server.rest.controllers.FilesController.java
@Inject FilesController(Config config) {/*from w w w .j a va2 s. c o m*/ uploadDir = new File(Paths.get(config.getString("uploadDir"), "/vampires").toUri()); uploadDir.mkdir(); try { files = getAllFilesInfo(); } catch (IOException e) { LOG.error("can not read files"); files = Maps.newConcurrentMap(); } LOG.debug("Upload dir {}", uploadDir); Spark.post("/upload", upload(), JsonTransformer.get()); Spark.get("/upload", list(), JsonTransformer.get()); Spark.get("/upload/:id", get()); Spark.delete("/upload/:id", delete(), JsonTransformer.get()); }
From source file:com.zaradai.kunzite.optimizer.data.DisruptorDataRequestManager.java
protected Map<UUID, DataRequester> createRequesterMap() { return Maps.newConcurrentMap(); }
From source file:org.ros.internal.transport.ConnectionHeader.java
public ConnectionHeader() { this.fields = Maps.newConcurrentMap(); }
From source file:tv.icntv.log.stb.core.AbstractJob.java
@Override public int run(String[] args) throws Exception { if (null == args || args.length < 1) { logger.error("usage :-ruleFile <rule_file>"); return -1; }/* w ww . j a v a 2s . c o m*/ Map temp = Maps.newConcurrentMap(); CommandLineParser parser = new PosixParser(); CommandLine line = parser.parse(init(), args); for (Option option : line.getOptions()) { System.out.println(maps.get(option.getOpt()) + "\t" + option.getValue()); temp.put(maps.get(option.getOpt()), option.getValue()); } ; Configuration conf = super.getConf(); conf.set("mapreduce.output.fileoutputformat.compress", "true"); conf.set("mapreduce.output.fileoutputformat.compress.codec", "com.hadoop.compression.lzo.LzopCodec"); conf.set("mapreduce.map.output.compress", "true"); conf.set("mapreduce.map.output.compress.codec", "com.hadoop.compression.lzo.LzopCodec"); return run(temp) ? 0 : 1; }
From source file:org.onosproject.incubator.store.virtual.impl.SimpleVirtualFlowObjectiveStore.java
protected void initNextGroupsMap() { nextGroupsMap = Maps.newConcurrentMap(); }
From source file:org.apache.giraph.comm.messages.DiskBackedMessageStoreByPartition.java
/** * @param service Service worker * @param maxNumberOfMessagesInMemory Number of messages to keep in memory * @param fileStoreFactory Factory for creating file stores * when flushing *//*from w ww .ja va 2 s . co m*/ public DiskBackedMessageStoreByPartition(CentralizedServiceWorker<I, V, E, M> service, int maxNumberOfMessagesInMemory, MessageStoreFactory<I, M, FlushableMessageStore<I, M>> fileStoreFactory) { this.service = service; this.maxNumberOfMessagesInMemory = maxNumberOfMessagesInMemory; this.fileStoreFactory = fileStoreFactory; partitionMessageStores = Maps.newConcurrentMap(); }
From source file:org.apache.kylin.metadata.realization.RealizationRegistry.java
private void init() { providers = Maps.newConcurrentMap(); // use reflection to load providers String[] providerNames = config.getRealizationProviders(); for (String clsName : providerNames) { try {// ww w . j a v a 2 s . c o m Class<? extends IRealizationProvider> cls = ClassUtil.forName(clsName, IRealizationProvider.class); IRealizationProvider p = (IRealizationProvider) cls.getMethod("getInstance", KylinConfig.class) .invoke(null, config); providers.put(p.getRealizationType(), p); } catch (Exception | NoClassDefFoundError e) { if (e instanceof ClassNotFoundException || e instanceof NoClassDefFoundError) logger.warn("Failed to create realization provider " + e); else logger.error("Failed to create realization provider", e); } } if (providers.isEmpty()) throw new IllegalArgumentException( "Failed to find realization provider by url: " + config.getMetadataUrl()); logger.info("RealizationRegistry is " + providers); }