List of usage examples for com.google.common.collect ImmutableMap containsKey
@Override public boolean containsKey(@Nullable Object key)
From source file:com.jejking.hh.nord.gazetteer.osm.poi.IsOsmFeaturePointOfInterest.java
@Override public Boolean call(OsmComponent component) { ImmutableMap<String, String> props = component.getProperties(); for (String tagInterestingIfNamed : interestingTagsWithNameOnly.keySet()) { if (props.containsKey(tagInterestingIfNamed) && hasInterestingValue(interestingTagsWithNameOnly, props, tagInterestingIfNamed) && props.containsKey(name)) { return Boolean.TRUE; }/*w w w .ja v a2s.c om*/ } return Boolean.FALSE; }
From source file:com.facebook.buck.simulate.SimulateTimes.java
public boolean hasMillisForTarget(String buildTarget, String timeAggregate) { if (buildTargetTimes.containsKey(buildTarget)) { ImmutableMap<String, Long> timesForRule = Preconditions.checkNotNull(buildTargetTimes.get(buildTarget)); if (timesForRule.containsKey(timeAggregate)) { return true; }//from w ww.ja v a2 s.co m } return false; }
From source file:com.pinterest.pinlater.backends.mysql.MySQLHealthMonitor.java
public synchronized boolean isHealthy(String shardName) { long currentTimeMillis = System.currentTimeMillis(); ImmutableMap<String, ShardState> shardHealthMap = shardHealthMapRef.get(); if (!shardHealthMap.containsKey(shardName)) { LOG.error("Health monitor map doesn't have shard name {}", shardName); return false; }// w w w . ja v a 2 s . c om ShardState shardState = shardHealthMap.get(shardName); if (shardState.isHealthy) { if (shardState.healthSamples.remainingCapacity() == 0 && shardState.numSuccessesInWindow < healthySuccessThreshold) { LOG.info("Marking mysql shard {} unhealthy due to {} successes / 100", shardName, shardState.numSuccessesInWindow); shardState.isHealthy = false; shardState.lastUnhealthyTimestampMillis = currentTimeMillis; } } else if (currentTimeMillis >= shardState.lastUnhealthyTimestampMillis + unhealthyResetPeriodMillis) { LOG.info("Resetting health state for mysql shard {}", shardName); shardState.reset(); } return shardState.isHealthy; }
From source file:org.locationtech.geogig.plumbing.merge.MergeFeaturesOp.java
private Map<ObjectId, RevObject> getObjects(NodeRef ancestorRef, NodeRef nodeRefA, NodeRef nodeRefB) { final ObjectId metadataId = ancestorRef.getMetadataId(); final ObjectId ancestorFeatureId = ancestorRef.getObjectId(); final ObjectId featureAId = nodeRefA.getObjectId(); final ObjectId featureBId = nodeRefB.getObjectId(); Iterable<ObjectId> ids = ImmutableList.of(metadataId, ancestorFeatureId, featureAId, featureBId); Iterator<RevObject> objsit = objectDatabase().getAll(ids, BulkOpListener.NOOP_LISTENER); ImmutableMap<ObjectId, RevObject> map = Maps.uniqueIndex(objsit, (o) -> o.getId()); checkState(map.containsKey(metadataId), "Invalid reference: %s", metadataId); checkState(map.containsKey(ancestorFeatureId), "Invalid reference: %s", ancestorFeatureId); checkState(map.containsKey(featureAId), "Invalid reference: %s", featureAId); checkState(map.containsKey(featureBId), "Invalid reference: %s", featureBId); return map;/* www . j a va 2 s . c o m*/ }
From source file:cz.cuni.mff.ms.brodecva.botnicek.ide.project.views.DefaultPrefixesSettingsTableModel.java
@Override public void update(final Map<URI, String> namespacesToPrefixes) { final ImmutableMap<URI, String> copy = ImmutableMap.copyOf(namespacesToPrefixes); Preconditions.checkArgument(copy.containsKey(URI.create(AIML.NAMESPACE_URI.getValue()))); Preconditions.checkArgument(copy.containsKey(URI.create(XML.SCHEMA_NAMESPACE_URI.getValue()))); super.update(copy); }
From source file:com.srotya.flume.kinesis.source.KinesisSource.java
@Override protected void doConfigure(Context ctx) throws FlumeException { ImmutableMap<String, String> props = ctx.getSubProperties(Constants.SETTINGS); if (!props.containsKey(Constants.ACCESS_KEY) || !props.containsKey(Constants.ACCESS_SECRET)) { Throwables.propagate(/*from www. ja v a 2 s .c o m*/ new InvalidArgumentException("Must provide AWS credentials i.e. accessKey and accessSecret")); } awsCredentials = new BasicAWSCredentials(props.get(Constants.ACCESS_KEY), props.get(Constants.ACCESS_SECRET)); clientConfig = new ClientConfiguration(); if (props.containsKey(Constants.PROXY_HOST)) { clientConfig.setProxyHost(props.get(Constants.PROXY_HOST)); clientConfig.setProxyPort(Integer.parseInt(props.getOrDefault(Constants.PROXY_PORT, "80"))); clientConfig.setProtocol(Protocol.valueOf(props.getOrDefault(Constants.PROTOCOL, "HTTPS"))); } if (!props.containsKey(Constants.STREAM_NAME)) { Throwables.propagate(new InvalidArgumentException("Must provide Kinesis stream name")); } streamName = props.get(Constants.STREAM_NAME); putSize = Integer.parseInt(props.getOrDefault(Constants.PUT_SIZE, "100")); if (putSize > 500) { Throwables.propagate( new InvalidArgumentException("AWS Kinesis doesn't allow more than 500 put requests")); } endpoint = props.getOrDefault(Constants.ENDPOINT, Constants.DEFAULT_ENDPOINT); String serializerClass = props.getOrDefault(Constants.SERIALIZER, GsonSerializer.class.getName()); try { serializer = (KinesisSerializer) Class.forName(serializerClass).newInstance(); } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { Throwables.propagate(e); } serializer.configure(props); shardId = Integer.parseInt(props.getOrDefault(SHARD_INDEX, "0")); shardIteratorType = props.getOrDefault(ITERATOR_TYPE, DEFAULT_ITERATOR_TYPE); }
From source file:org.apache.james.jmap.methods.SetMailboxesDestructionProcessor.java
private void notDestroyedRequests(SetMailboxesRequest request, ImmutableMap<MailboxId, Mailbox> idToMailbox, SetMailboxesResponse.Builder builder) { request.getDestroy().stream().filter(id -> !idToMailbox.containsKey(id)) .forEach(id -> notDestroy(id, builder)); }
From source file:org.apache.cloudstack.outofbandmanagement.driver.nestedcloudstack.NestedCloudStackOutOfBandManagementDriver.java
protected void ensureOptionExists(final ImmutableMap<OutOfBandManagement.Option, String> options, final OutOfBandManagement.Option option) { if (options != null && option != null && options.containsKey(option) && !Strings.isNullOrEmpty(options.get(option))) { return;/*ww w . j a v a2 s . com*/ } throw new CloudRuntimeException( "Invalid out-of-band management configuration detected for the nested-cloudstack driver"); }
From source file:cz.cuni.mff.ms.brodecva.botnicek.ide.render.DefaultRenderingVisitor.java
private DefaultRenderingVisitor(final Map<? extends URI, ? extends String> namespacesToPrefixes) { Preconditions.checkNotNull(namespacesToPrefixes); final ImmutableMap<URI, String> namespacesToPrefixesCopy = ImmutableMap.copyOf(namespacesToPrefixes); Preconditions// ww w . ja v a2 s .c o m .checkArgument(namespacesToPrefixesCopy.containsKey(URI.create(AIML.NAMESPACE_URI.getValue()))); this.namespacesToPrefixes = namespacesToPrefixesCopy; }
From source file:org.apache.phoenix.log.TableLogWriter.java
@Override public void write(RingBufferEvent event) throws SQLException, IOException, ClassNotFoundException { if (isClosed()) { LOG.warn("Unable to commit query log as Log committer is already closed"); return;/*from ww w . j av a 2 s. c o m*/ } if (connection == null) { synchronized (this) { if (connection == null) { connection = QueryUtil.getConnectionForQueryLog(this.config); this.upsertStatement = buildUpsertStatement(connection); } } } ImmutableMap<QueryLogInfo, Object> queryInfoMap = event.getQueryInfo(); for (QueryLogInfo info : QueryLogInfo.values()) { if (queryInfoMap.containsKey(info) && info.logLevel.ordinal() <= event.getConnectionLogLevel().ordinal()) { upsertStatement.setObject(info.ordinal() + 1, queryInfoMap.get(info)); } else { upsertStatement.setObject(info.ordinal() + 1, null); } } Map<MetricType, Long> overAllMetrics = event.getOverAllMetrics(); Map<String, Map<MetricType, Long>> readMetrics = event.getReadMetrics(); for (MetricType metric : MetricType.values()) { if (overAllMetrics != null && overAllMetrics.containsKey(metric) && metric.isLoggingEnabled(event.getConnectionLogLevel())) { upsertStatement.setObject(metricOrdinals.get(metric), overAllMetrics.get(metric)); } else { if (metric.logLevel() != LogLevel.OFF) { upsertStatement.setObject(metricOrdinals.get(metric), null); } } } if (readMetrics != null && !readMetrics.isEmpty()) { for (Map.Entry<String, Map<MetricType, Long>> entry : readMetrics.entrySet()) { upsertStatement.setObject(QueryLogInfo.TABLE_NAME_I.ordinal() + 1, entry.getKey()); for (MetricType metric : entry.getValue().keySet()) { if (metric.isLoggingEnabled(event.getConnectionLogLevel())) { upsertStatement.setObject(metricOrdinals.get(metric), entry.getValue().get(metric)); } } upsertStatement.executeUpdate(); } } else { upsertStatement.executeUpdate(); } connection.commit(); }