Java Code Examples for com.google.common.collect.LinkedListMultimap#put()
The following examples show how to use
com.google.common.collect.LinkedListMultimap#put() .
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: LocalSessionMgr.java From anima with GNU General Public License v3.0 | 6 votes |
/** * * @param sid * @param serverType * @param sequence * @param localSession * @return */ public LocalSession addSession(String serverId,String serverType,int sessionId,LocalSession localSession) { if (localSession == null) { return null; } localSession.setServerId(serverId); localSession.setServerType(serverType); localSession.setId(sessionId); localSession.setlistener(this.closeListener); localSession.setStatus(ISession.STATUS_WORKING); sessionBySid.put(serverId, localSession); synchronized(sessionByStype) { LinkedListMultimap<String, LocalSession> multimap = sessionByStype.get(serverType); if (multimap == null) { multimap = LinkedListMultimap.create(); sessionByStype.put(serverType, multimap); } multimap.put(serverId, localSession); } return localSession; }
Example 2
Source File: ClassPathBuilder.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
/** * Builds a classpath from the transitive dependency graph of a list of artifacts. * When there are multiple versions of an artifact in * the dependency tree, the closest to the root in breadth-first order is picked up. This "pick * closest" strategy follows Maven's dependency mediation. * * @param artifacts the first artifacts that appear in the classpath, in order */ public ClassPathResult resolve(List<Artifact> artifacts) { LinkedListMultimap<ClassPathEntry, DependencyPath> multimap = LinkedListMultimap.create(); if (artifacts.isEmpty()) { return new ClassPathResult(multimap, ImmutableList.of()); } // dependencyGraph holds multiple versions for one artifact key (groupId:artifactId) DependencyGraph result = dependencyGraphBuilder.buildFullDependencyGraph(artifacts); List<DependencyPath> dependencyPaths = result.list(); // TODO should DependencyGraphResult have a mediate() method that returns a ClassPathResult? // To remove duplicates on (groupId:artifactId) for dependency mediation MavenDependencyMediation mediation = new MavenDependencyMediation(); for (DependencyPath dependencyPath : dependencyPaths) { Artifact artifact = dependencyPath.getLeaf(); mediation.put(dependencyPath); if (mediation.selects(artifact)) { // We include multiple dependency paths to the first version of an artifact we see, // but not paths to other versions of that artifact. multimap.put(new ClassPathEntry(artifact), dependencyPath); } } return new ClassPathResult(multimap, result.getUnresolvedArtifacts()); }
Example 3
Source File: APICallVisitor.java From api-mining with GNU General Public License v3.0 | 5 votes |
/** * Get multimap of fq method names to fully qualified names of API calls * * @param namespace * API namespace (e.g. org.apache.hadoop), "" for all namespaces */ public LinkedListMultimap<String, String> getAPINames(final String namespace) { final LinkedListMultimap<String, String> fqAPICalls = LinkedListMultimap.create(); // Get scopes for variables final Table<ASTNode, String, String> variableScopeNameTypes = HashBasedTable.create(); for (final ASTNode parent : variableNames.keySet()) { final ASTNode scope = ASTVisitors.getCoveringBlock(rootNode, parent); for (final Entry<String, Integer> entry : variableNames.get(parent).entrySet()) variableScopeNameTypes.put(scope, entry.getKey(), box(variableTypes.get(entry.getValue()))); } for (final MethodDeclaration method : apiCalls.keySet()) { for (final Expression exp : apiCalls.get(method)) { final String fqCallingMethod = methodNames.get(method); final String parentClassName = fqCallingMethod.substring(0, fqCallingMethod.lastIndexOf(".")); final String fqMethodCall = getFullyQualifiedMethodNameFor(exp, parentClassName, variableScopeNameTypes); if (fqMethodCall.startsWith(namespace)) fqAPICalls.put(fqCallingMethod, fqMethodCall); } } for (final String className : unresClasses) System.out.println("+++++ INFO: Unable to resolve class " + className); for (final String name : unresMethods) System.out.println("+++++ INFO: Unable to resolve method " + name); return fqAPICalls; }
Example 4
Source File: FDSHttpClient.java From galaxy-fds-sdk-java with Apache License 2.0 | 5 votes |
public LinkedListMultimap<String, String> headerArray2MultiValuedMap(Header[] headers) { LinkedListMultimap<String, String> m = LinkedListMultimap.create(); if (headers != null) for (Header h : headers) { m.put(h.getName(), h.getValue()); } return m; }
Example 5
Source File: GalaxyFDSClient.java From galaxy-fds-sdk-java with Apache License 2.0 | 5 votes |
FDSObjectListing getObjectListing(ListObjectsResult result) { FDSObjectListing listing = null; if (result != null) { listing = new FDSObjectListing(); listing.setBucketName(result.getName()); listing.setPrefix(result.getPrefix()); listing.setDelimiter(result.getDelimiter()); listing.setMarker(result.getMarker()); listing.setNextMarker(result.getNextMarker()); listing.setMaxKeys(result.getMaxKeys()); listing.setTruncated(result.isTruncated()); listing.setReverse(result.isReverse()); listing.setWithMetaData(result.isWithMetaData()); List<FDSObjectSummary> summaries = new ArrayList<FDSObjectSummary>( result.getObjects().size()); for (ObjectBean o : result.getObjects()) { FDSObjectSummary summary = new FDSObjectSummary(); summary.setBucketName(result.getName()); summary.setObjectName(o.getName()); summary.setSize(o.getSize()); summary.setOwner(new Owner(o.getOwner().getId(), o.getOwner().getDisplayName())); summary.setUploadTime(o.getUploadTime()); if (o.getMetadataBean() != null) { Map<String, String> meta = o.getMetadataBean().getRawMeta(); LinkedListMultimap<String, String> linkedListMultimap = LinkedListMultimap.create(); for (Map.Entry<String, String> e : meta.entrySet()) { linkedListMultimap.put(e.getKey(), e.getValue()); } summary.setMetadata(FDSObjectMetadata.parseObjectMetadata(linkedListMultimap)); } summaries.add(summary); } listing.setObjectSummaries(summaries); listing.setCommonPrefixes(result.getCommonPrefixes()); } return listing; }
Example 6
Source File: GalaxyFDSClient.java From galaxy-fds-sdk-java with Apache License 2.0 | 5 votes |
private LinkedListMultimap<String, String> headerArray2MultiValuedMap(Header[] headers) { LinkedListMultimap<String, String> m = LinkedListMultimap.create(); if (headers != null) for (Header h : headers) { m.put(h.getName(), h.getValue()); } return m; }
Example 7
Source File: HttpUtils.java From galaxy-sdk-java with Apache License 2.0 | 5 votes |
public static LinkedListMultimap<String, String> parseUriParameters(URI uri) { LinkedListMultimap<String, String> params = LinkedListMultimap.create(); String query = uri.getQuery(); if (query != null) { for (String param : query.split("&")) { String[] kv = param.split("="); if (kv.length >= 2) { params.put(kv[0], param.substring(kv[0].length() + 1)); } else { params.put(kv[0], ""); } } } return params; }
Example 8
Source File: Signer.java From galaxy-sdk-java with Apache License 2.0 | 5 votes |
private static LinkedListMultimap<String, String> parseUriParameters(URI uri) { LinkedListMultimap<String, String> params = LinkedListMultimap.create(); String query = uri.getQuery(); if (query != null) { for (String param : query.split("&")) { String[] kv = param.split("="); if (kv.length >= 2) { params.put(kv[0], param.substring(kv[0].length() + 1)); } else { params.put(kv[0], ""); } } } return params; }
Example 9
Source File: MetricsHttpClient.java From galaxy-sdk-java with Apache License 2.0 | 5 votes |
/** * Set signature related headers when credential is properly set */ private MetricsHttpClient setAuthenticationHeaders(HttpPost post, byte[] data) { if (this.client != null && credential != null) { if (credential.getSecretKeyId() != null) { String host = this.host.toHostString(); host = host.split(":")[0]; post.setHeader(AuthenticationConstants.HK_HOST, host); // timestamp String timestamp = Long.toString(clock.getCurrentEpoch()); post.setHeader(AuthenticationConstants.HK_TIMESTAMP, timestamp); post.setHeader(HttpKeys.MI_DATE, HttpUtils.getGMTDatetime(new Date())); // content md5 String md5 = BytesUtil .bytesToHex(DigestUtil.digest(DigestUtil.DigestAlgorithm.MD5, data)); post.setHeader(com.xiaomi.infra.galaxy.sds.thrift.AuthenticationConstants.HK_CONTENT_MD5, md5); LinkedListMultimap<String, String> headers = LinkedListMultimap.create(); for (Header header : post.getAllHeaders()) { headers.put(header.getName().toLowerCase(), header.getValue()); } try { String authString = "Galaxy-V3 " + credential.getSecretKeyId() + ":" + Signer.signToBase64(HttpMethod.POST, post.getURI(), headers, credential.getSecretKey(), SignAlgorithm.HmacSHA1); post.setHeader(AuthenticationConstants.HK_AUTHORIZATION, authString); } catch (Exception e) { throw new RuntimeException("Failed to sign", e); } } else { throw new RuntimeException("SecretKeyId must not be null"); } } return this; }
Example 10
Source File: ExpectedHeadersAreEqualValidatorTest.java From timbuctoo with GNU General Public License v3.0 | 5 votes |
private LinkedListMultimap<String, String> multimap(String... contents) { LinkedListMultimap<String, String> result = LinkedListMultimap.create(contents.length / 2); for (int i = 0; i < contents.length; i += 2) { result.put(contents[i], contents[i+1]); } return result; }
Example 11
Source File: KeyRangeIterable.java From kite with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public Iterator<MarkerRange> iterator() { // this should be part of PartitionStrategy final LinkedListMultimap<String, FieldPartitioner> partitioners = LinkedListMultimap.create(); for (FieldPartitioner fp : Accessor.getDefault().getFieldPartitioners(strategy)) { partitioners.put(fp.getSourceName(), fp); } Iterator<MarkerRange.Builder> current = start(new MarkerRange.Builder(cmp)); // primarily loop over sources because the logical constraints are there for (String source : partitioners.keySet()) { Predicate constraint = predicates.get(source); List<FieldPartitioner> fps = partitioners.get(source); FieldPartitioner first = fps.get(0); if (first instanceof CalendarFieldPartitioner) { current = TimeDomain.get(strategy, source) .addStackedIterator(constraint, current); } else if (constraint instanceof In) { current = add((In) constraint, fps, current); } else if (constraint instanceof Range) { current = add((Range) constraint, fps, current); } } return Iterators.transform(current, new ToMarkerRangeFunction()); }
Example 12
Source File: GalaxyHttpClient.java From galaxy-sdk-java with Apache License 2.0 | 4 votes |
/** * Set signature related headers when credential is properly set */ private GalaxyHttpClient setAuthenticationHeaders(HttpPost post, byte[] data, boolean supportAccountKey) { if (this.client != null && credential != null) { HttpAuthorizationHeader authHeader = null; if (credential.getType() != null && credential.getSecretKeyId() != null) { // signature is supported if (AuthenticationConstants.SIGNATURE_SUPPORT.get(credential.getType())) { // host String host = this.host.toHostString(); host = host.split(":")[0]; post.setHeader(AuthenticationConstants.HK_HOST, host); // timestamp String timestamp = Long.toString(clock.getCurrentEpoch()); post.setHeader(AuthenticationConstants.HK_TIMESTAMP, timestamp); post.setHeader(HttpKeys.MI_DATE, HttpUtils.getGMTDatetime(new Date())); // content md5 String md5 = BytesUtil .bytesToHex(DigestUtil.digest(DigestUtil.DigestAlgorithm.MD5, data)); post.setHeader(AuthenticationConstants.HK_CONTENT_MD5, md5); // signature LinkedListMultimap<String, String> headers = LinkedListMultimap.create(); for (Header header : post.getAllHeaders()) { headers.put(header.getName().toLowerCase(), header.getValue()); } try { String authString = "Galaxy-V2 " + credential.getSecretKeyId() + ":" + Signer.signToBase64(HttpMethod.POST, post.getURI(), headers, credential.getSecretKey(), SignAlgorithm.HmacSHA1); post.setHeader(AuthenticationConstants.HK_AUTHORIZATION, authString); } catch (Exception e) { throw new RuntimeException("Failed to sign", e); } } else { authHeader = createSecretKeyHeader(); if (authHeader != null) { authHeader.setSupportAccountKey(supportAccountKey); post.setHeader(AuthenticationConstants.HK_AUTHORIZATION, encodeAuthorizationHeader(authHeader)); } } } } return this; }
Example 13
Source File: RequestCommand.java From timbuctoo with GNU General Public License v3.0 | 4 votes |
private HttpRequest parseRequest(Element element, Evaluator evaluator, ResultRecorder resultRecorder) { String contents = getTextAndRemoveIndent(element); contents = replaceVariableReferences(evaluator, contents, resultRecorder); SessionInputBufferImpl buffer = new SessionInputBufferImpl(new HttpTransportMetricsImpl(), contents.length()); buffer.bind(new ByteArrayInputStream(contents.getBytes(StandardCharsets.UTF_8))); DefaultHttpRequestParser defaultHttpRequestParser = new DefaultHttpRequestParser(buffer); LinkedListMultimap<String, String> queryParameters = LinkedListMultimap.create(); String method = ""; String url = ""; LinkedListMultimap<String, String> headers = LinkedListMultimap.create(); String body = null; String server = null; try { org.apache.http.HttpRequest httpRequest = defaultHttpRequestParser.parse(); method = httpRequest.getRequestLine().getMethod(); url = httpRequest.getRequestLine().getUri(); if (url.startsWith("#")) { url = "" + evaluator.evaluate(url); } Matcher matcher = Pattern.compile("(https?://[^/]+)(/.*)").matcher(url); if (matcher.matches()) { server = matcher.group(1); url = matcher.group(2); } if (url.contains("?")) { String[] urlAndQueryParameters = url.split("\\?"); url = urlAndQueryParameters[0]; for (String queryParameter : urlAndQueryParameters[1].split("&")) { String[] parameter = queryParameter.split("="); queryParameters.put(parameter[0], parameter[1]); } } for (Header header : httpRequest.getAllHeaders()) { headers.put(header.getName(), header.getValue()); } if (buffer.hasBufferedData()) { body = ""; while (buffer.hasBufferedData()) { body += (char) buffer.read(); } } } catch (IOException | HttpException e) { e.printStackTrace(); } return new HttpRequest(method, url, headers, body, server, queryParameters); }