List of usage examples for com.google.common.collect ImmutableMap get
V get(Object key);
From source file:com.mylife.hbase.mapper.HBaseEntityMapper.java
private Object fieldValue(final Field field, final Object hbasePersistableObject, final ImmutableMap<Class<?>, ImmutableMap<Field, Method>> map) { final Method getter = map.get(hbasePersistableObject.getClass()).get(field); ReflectionUtils.makeAccessible(getter); return ReflectionUtils.invokeMethod(getter, hbasePersistableObject); }
From source file:com.google.devtools.build.lib.skylarkdebug.server.ThreadHandler.java
/** * Returns true if there's a breakpoint at the current location, with a satisfied condition if * relevant.//from ww w. j a va2 s. co m */ private boolean hasBreakpointMatchedAtLocation(Environment env, Location location) throws ConditionalBreakpointException { // breakpoints is volatile, so taking a local copy ImmutableMap<SkylarkDebuggingProtos.Location, SkylarkDebuggingProtos.Breakpoint> breakpoints = this.breakpoints; if (breakpoints.isEmpty()) { return false; } SkylarkDebuggingProtos.Location locationProto = DebugEventHelper.getLocationProto(location); if (locationProto == null) { return false; } locationProto = locationProto.toBuilder().clearColumnNumber().build(); SkylarkDebuggingProtos.Breakpoint breakpoint = breakpoints.get(locationProto); if (breakpoint == null) { return false; } String condition = breakpoint.getExpression(); if (condition.isEmpty()) { return true; } try { return EvalUtils.toBoolean(doEvaluate(env, condition)); } catch (EvalException | InterruptedException e) { throw new ConditionalBreakpointException(e.getMessage()); } }
From source file:com.facebook.buck.apple.xcode.NewNativeTargetProjectMutator.java
private void addSourcePathToHeadersBuildPhase(SourcePath headerPath, PBXGroup headersGroup, Optional<PBXHeadersBuildPhase> headersBuildPhase, ImmutableMap<SourcePath, String> sourceFlags) { PBXFileReference fileReference = headersGroup.getOrCreateFileReferenceBySourceTreePath(new SourceTreePath( PBXReference.SourceTree.SOURCE_ROOT, pathRelativizer.outputPathToSourcePath(headerPath))); PBXBuildFile buildFile = new PBXBuildFile(fileReference); String headerFlags = sourceFlags.get(headerPath); if (headerFlags != null) { // If we specify nothing, Xcode will use "project" visibility. NSDictionary settings = new NSDictionary(); settings.put("ATTRIBUTES", new NSArray(new NSString(HeaderVisibility.fromString(headerFlags).toXcodeAttribute()))); buildFile.setSettings(Optional.of(settings)); } else {// w ww.jav a 2s . c om buildFile.setSettings(Optional.<NSDictionary>absent()); } if (headersBuildPhase.isPresent()) { headersBuildPhase.get().getFiles().add(buildFile); LOG.verbose("Added header path %s to headers group %s, flags %s, PBXFileReference %s", headerPath, headersGroup.getName(), headerFlags, fileReference); } else { LOG.verbose("Skipped header path %s to headers group %s, flags %s, PBXFileReference %s", headerPath, headersGroup.getName(), headerFlags, fileReference); } }
From source file:edu.mit.streamjit.impl.distributed.node.BlobsManagerImpl.java
private ImmutableMap<Token, BoundaryInputChannel> createInputChannels(Set<Token> inputTokens, ImmutableMap<Token, Buffer> bufferMap) { ImmutableMap.Builder<Token, BoundaryInputChannel> inputChannelMap = new ImmutableMap.Builder<>(); for (Token t : inputTokens) { TCPConnectionInfo conInfo = conInfoMap.get(t); inputChannelMap.put(t, new TCPInputChannel(bufferMap.get(t), conProvider, conInfo, t.toString(), 0)); }/*from ww w . ja v a 2s . c om*/ return inputChannelMap.build(); }
From source file:org.apache.cloudstack.outofbandmanagement.OutOfBandManagementServiceImpl.java
@Override @ActionEvent(eventType = EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_CHANGE_PASSWORD, eventDescription = "updating out-of-band management password") public OutOfBandManagementResponse changeOutOfBandManagementPassword(final Host host, final String newPassword) { checkOutOfBandManagementEnabledByZoneClusterHost(host); if (Strings.isNullOrEmpty(newPassword)) { throw new CloudRuntimeException(String.format( "Cannot change out-of-band management password as provided new-password is null or empty for the host %s.", host.getUuid()));/* ww w. ja v a2s . c o m*/ } final OutOfBandManagement outOfBandManagementConfig = outOfBandManagementDao.findByHost(host.getId()); final ImmutableMap<OutOfBandManagement.Option, String> options = getOptions(outOfBandManagementConfig); if (!(options.containsKey(OutOfBandManagement.Option.PASSWORD) && !Strings.isNullOrEmpty(options.get(OutOfBandManagement.Option.PASSWORD)))) { throw new CloudRuntimeException(String.format( "Cannot change out-of-band management password as we've no previously configured password for the host %s.", host.getUuid())); } final OutOfBandManagementDriver driver = getDriver(outOfBandManagementConfig); final OutOfBandManagementDriverChangePasswordCommand changePasswordCmd = new OutOfBandManagementDriverChangePasswordCommand( options, ActionTimeout.valueIn(host.getClusterId()), newPassword); final boolean changePasswordResult = Transaction.execute(new TransactionCallback<Boolean>() { @Override public Boolean doInTransaction(TransactionStatus status) { final OutOfBandManagement updatedOutOfBandManagementConfig = outOfBandManagementDao .findByHost(host.getId()); updatedOutOfBandManagementConfig.setPassword(newPassword); boolean result = outOfBandManagementDao.update(updatedOutOfBandManagementConfig.getId(), (OutOfBandManagementVO) updatedOutOfBandManagementConfig); if (!result) { throw new CloudRuntimeException(String.format( "Failed to change out-of-band management password for host (%s) in the database.", host.getUuid())); } final OutOfBandManagementDriverResponse driverResponse; try { driverResponse = driver.execute(changePasswordCmd); } catch (Exception e) { LOG.error( "Out-of-band management change password failed due to driver error: " + e.getMessage()); throw new CloudRuntimeException(String.format( "Failed to change out-of-band management password for host (%s) due to driver error: %s", host.getUuid(), e.getMessage())); } if (!driverResponse.isSuccess()) { throw new CloudRuntimeException(String.format( "Failed to change out-of-band management password for host (%s) with error: %s", host.getUuid(), driverResponse.getError())); } return result && driverResponse.isSuccess(); } }); final OutOfBandManagementResponse response = new OutOfBandManagementResponse(); response.setSuccess(changePasswordResult); response.setId(host.getUuid()); return response; }
From source file:edu.mit.streamjit.impl.distributed.node.BlobsManagerImpl.java
private ImmutableMap<Token, BoundaryOutputChannel> createOutputChannels(Set<Token> outputTokens, ImmutableMap<Token, Buffer> bufferMap) { ImmutableMap.Builder<Token, BoundaryOutputChannel> outputChannelMap = new ImmutableMap.Builder<>(); for (Token t : outputTokens) { TCPConnectionInfo conInfo = conInfoMap.get(t); outputChannelMap.put(t, new TCPOutputChannel(bufferMap.get(t), conProvider, conInfo, t.toString(), 0)); }//from www . j av a2s . c o m return outputChannelMap.build(); }
From source file:com.facebook.buck.versions.VersionedTargetGraphBuilder.java
private TargetNode<?, ?> resolveVersions(TargetNode<?, ?> node, ImmutableMap<BuildTarget, Version> selectedVersions) { Optional<TargetNode<VersionedAliasDescription.Arg, ?>> versionedNode = node .castArg(VersionedAliasDescription.Arg.class); if (versionedNode.isPresent()) { node = getNode(Preconditions.checkNotNull(versionedNode.get().getConstructorArg().versions .get(selectedVersions.get(node.getBuildTarget())))); }/* w ww. jav a2 s . c om*/ return node; }
From source file:com.facebook.buck.apple.ProvisioningProfileStore.java
public Optional<ProvisioningProfileMetadata> getBestProvisioningProfile(String bundleID, Optional<ImmutableMap<String, NSObject>> entitlements, Optional<? extends Iterable<CodeSignIdentity>> identities) { final Optional<String> prefix; if (entitlements.isPresent()) { prefix = ProvisioningProfileMetadata.prefixFromEntitlements(entitlements.get()); } else {/*from w w w . jav a 2 s . c om*/ prefix = Optional.empty(); } int bestMatchLength = -1; Optional<ProvisioningProfileMetadata> bestMatch = Optional.empty(); for (ProvisioningProfileMetadata profile : getProvisioningProfiles()) { if (profile.getExpirationDate().after(new Date())) { Pair<String, String> appID = profile.getAppID(); LOG.debug("Looking at provisioning profile " + profile.getUUID() + "," + appID.toString()); if (!prefix.isPresent() || prefix.get().equals(appID.getFirst())) { String profileBundleID = appID.getSecond(); boolean match; if (profileBundleID.endsWith("*")) { // Chop the ending * if wildcard. profileBundleID = profileBundleID.substring(0, profileBundleID.length() - 1); match = bundleID.startsWith(profileBundleID); } else { match = (bundleID.equals(profileBundleID)); } if (!match) { LOG.debug("Ignoring non-matching ID for profile " + profile.getUUID()); } // Match against other keys of the entitlements. Otherwise, we could potentially select // a profile that doesn't have all the needed entitlements, causing a error when // installing to device. // // For example: get-task-allow, aps-environment, etc. if (match && entitlements.isPresent()) { ImmutableMap<String, NSObject> entitlementsDict = entitlements.get(); ImmutableMap<String, NSObject> profileEntitlements = profile.getEntitlements(); for (Entry<String, NSObject> entry : entitlementsDict.entrySet()) { if (!(entry.getKey().equals("keychain-access-groups") || entry.getKey().equals("application-identifier") || entry.getKey().equals("com.apple.developer.associated-domains") || matchesOrArrayIsSubsetOf(entry.getValue(), profileEntitlements.get(entry.getKey())))) { match = false; LOG.debug("Ignoring profile " + profile.getUUID() + " with mismatched entitlement " + entry.getKey() + "; value is " + profileEntitlements.get(entry.getKey()) + " but expected " + entry.getValue()); break; } } } // Reject any certificate which we know we can't sign with the supplied identities. ImmutableSet<HashCode> validFingerprints = profile.getDeveloperCertificateFingerprints(); if (match && identities.isPresent() && !validFingerprints.isEmpty()) { match = false; for (CodeSignIdentity identity : identities.get()) { Optional<HashCode> fingerprint = identity.getFingerprint(); if (fingerprint.isPresent() && validFingerprints.contains(fingerprint.get())) { match = true; break; } } if (!match) { LOG.debug("Ignoring profile " + profile.getUUID() + " because it can't be signed with any valid identity in the current keychain."); } } if (match && profileBundleID.length() > bestMatchLength) { bestMatchLength = profileBundleID.length(); bestMatch = Optional.of(profile); } } } else { LOG.debug("Ignoring expired profile " + profile.getUUID()); } } LOG.debug("Found provisioning profile " + bestMatch.toString()); return bestMatch; }
From source file:com.facebook.buck.cli.Config.java
public boolean equalsIgnoring(Config other, ImmutableMap<String, ImmutableSet<String>> ignoredFields) { if (this == other) { return true; }/* www .j a va 2 s. co m*/ ImmutableMap<String, ImmutableMap<String, String>> left = this.sectionToEntries; ImmutableMap<String, ImmutableMap<String, String>> right = other.sectionToEntries; Sets.SetView<String> sections = Sets.union(left.keySet(), right.keySet()); for (String section : sections) { ImmutableMap<String, String> leftFields = left.get(section); ImmutableMap<String, String> rightFields = right.get(section); if (leftFields == null || rightFields == null) { return false; } Sets.SetView<String> fields = Sets.difference(Sets.union(leftFields.keySet(), rightFields.keySet()), Optional.fromNullable(ignoredFields.get(section)).or(ImmutableSet.<String>of())); for (String field : fields) { String leftValue = leftFields.get(field); String rightValue = rightFields.get(field); if (leftValue == null || rightValue == null || !leftValue.equals(rightValue)) { return false; } } } return true; }
From source file:io.fabric8.jube.local.ProcessMonitor.java
protected void processMonitor() { ImmutableMap<String, Installation> map = processManager.listInstallationMap(); ImmutableSet<Map.Entry<String, Installation>> entries = map.entrySet(); ImmutableMap<String, PodCurrentContainer> podRunningContainers = model.getPodRunningContainers(model); for (Map.Entry<String, Installation> entry : entries) { final String id = entry.getKey(); if (excludedPodIds.contains(id)) { continue; }//w w w. j a v a 2 s . c o m Installation installation = entry.getValue(); Long pid = null; try { pid = installation.getActivePid(); } catch (IOException e) { LOG.warn("Failed to access pid for " + id + ". " + e, e); } final boolean alive = pid != null && pid.longValue() > 0; final PodCurrentContainer podCurrentContainer = podRunningContainers.get(id); if (podCurrentContainer == null) { File installDir = installation.getInstallDir(); if (installDir.exists()) { LOG.debug("No pod container for id: " + id); } else { processManager.uninstall(installation); } } else { // lets mark the container as running or not... NodeHelper.podTransaction(model, podCurrentContainer.getPod(), new Runnable() { @Override public void run() { podCurrentContainer.containerAlive(id, alive); } }); } } }