List of usage examples for java.util LinkedHashMap values
public Collection<V> values()
From source file:org.springframework.cloud.netflix.zuul.filters.discovery.DiscoveryClientRouteLocator.java
@Override protected LinkedHashMap<String, ZuulRoute> locateRoutes() { LinkedHashMap<String, ZuulRoute> routesMap = new LinkedHashMap<String, ZuulRoute>(); routesMap.putAll(super.locateRoutes()); if (this.discovery != null) { Map<String, ZuulRoute> staticServices = new LinkedHashMap<String, ZuulRoute>(); for (ZuulRoute route : routesMap.values()) { String serviceId = route.getServiceId(); if (serviceId == null) { serviceId = route.getId(); }//from w w w. ja v a2 s . co m if (serviceId != null) { staticServices.put(serviceId, route); } } // Add routes for discovery services by default List<String> services = this.discovery.getServices(); String[] ignored = this.properties.getIgnoredServices().toArray(new String[0]); for (String serviceId : services) { // Ignore specifically ignored services and those that were manually // configured String key = "/" + mapRouteToService(serviceId) + "/**"; if (staticServices.containsKey(serviceId) && staticServices.get(serviceId).getUrl() == null) { // Explicitly configured with no URL, cannot be ignored // all static routes are already in routesMap // Update location using serviceId if location is null ZuulRoute staticRoute = staticServices.get(serviceId); if (!StringUtils.hasText(staticRoute.getLocation())) { staticRoute.setLocation(serviceId); } } if (!PatternMatchUtils.simpleMatch(ignored, serviceId) && !routesMap.containsKey(key)) { // Not ignored routesMap.put(key, new ZuulRoute(key, serviceId)); } } } if (routesMap.get(DEFAULT_ROUTE) != null) { ZuulRoute defaultRoute = routesMap.get(DEFAULT_ROUTE); // Move the defaultServiceId to the end routesMap.remove(DEFAULT_ROUTE); routesMap.put(DEFAULT_ROUTE, defaultRoute); } LinkedHashMap<String, ZuulRoute> values = new LinkedHashMap<>(); for (Entry<String, ZuulRoute> entry : routesMap.entrySet()) { String path = entry.getKey(); // Prepend with slash if not already present. if (!path.startsWith("/")) { path = "/" + path; } if (StringUtils.hasText(this.properties.getPrefix())) { path = this.properties.getPrefix() + path; if (!path.startsWith("/")) { path = "/" + path; } } values.put(path, entry.getValue()); } return values; }
From source file:org.waveprotocol.box.server.waveserver.SolrSearchProviderImpl.java
@Timed @Override// w ww. j ava 2 s . c o m public SearchResult search(final ParticipantId user, String query, int startAt, int numResults) { LOG.fine("Search query '" + query + "' from user: " + user + " [" + startAt + ", " + ((startAt + numResults) - 1) + "]"); // Maybe should be changed in case other folders in addition to 'inbox' are // added. final boolean isAllQuery = isAllQuery(query); LinkedHashMultimap<WaveId, WaveletId> currentUserWavesView = LinkedHashMultimap.create(); if (numResults > 0) { int start = startAt; int rows = Math.max(numResults, ROWS); /*- * "fq" stands for Filter Query. see * http://wiki.apache.org/solr/CommonQueryParameters#fq */ String fq = buildFilterQuery(query, isAllQuery, user.getAddress(), sharedDomainParticipantId); try { while (true) { String solrQuery = buildCurrentSolrQuery(start, rows, fq); JsonArray docsJson = sendSearchRequest(solrQuery, extractDocsJsonFunction); addSearchResultsToCurrentWaveView(currentUserWavesView, docsJson); if (docsJson.size() < rows) { break; } start += rows; } } catch (Exception e) { LOG.warning("Failed to execute query: " + query); LOG.warning(e.getMessage()); return digester.generateSearchResult(user, query, null); } } ensureWavesHaveUserDataWavelet(currentUserWavesView, user); LinkedHashMap<WaveId, WaveViewData> results = createResults(user, isAllQuery, currentUserWavesView); Collection<WaveViewData> searchResult = computeSearchResult(user, startAt, numResults, Lists.newArrayList(results.values())); LOG.info("Search response to '" + query + "': " + searchResult.size() + " results, user: " + user); return digester.generateSearchResult(user, query, searchResult); }
From source file:com.kunalkene1797.blackboxkit.utils.database.ProfileDB.java
public void putProfile(String name, LinkedHashMap<String, String> commands) { try {//from w ww . j ava2 s.co m JSONObject items = new JSONObject(); items.put("name", name); JSONArray commandArray = new JSONArray(); for (int i = 0; i < commands.size(); i++) { JSONObject item = new JSONObject(); item.put("path", commands.keySet().toArray()[i]); item.put("command", commands.values().toArray()[i]); commandArray.put(item); } items.put("commands", commandArray); putItem(items); } catch (JSONException e) { e.printStackTrace(); } }
From source file:org.jsweet.transpiler.candies.CandiesProcessor.java
/** * Do the processing for the candies jars found in the classpath. *///from w w w . j a v a 2 s . c o m public void processCandies(TranspilationHandler transpilationHandler) throws IOException { CandiesStore candiesStore = getCandiesStore(); LinkedHashMap<File, CandyDescriptor> newCandiesDescriptors = getCandiesDescriptorsFromClassPath( transpilationHandler); CandiesStore newStore = new CandiesStore(new ArrayList<>(newCandiesDescriptors.values())); if (newStore.equals(candiesStore)) { logger.info("candies are up to date"); return; } this.candiesStore = newStore; logger.info("candies changed, processing candies: " + this.candiesStore); try { extractCandies(newCandiesDescriptors); writeCandiesStore(); } catch (Throwable t) { logger.error("cannot generate candies bundle", t); // exit with fatal if no jar ? } }
From source file:org.jsweet.transpiler.candy.CandyProcessor.java
/** * Does the processing for the candies jars found in the classpath. */// ww w .j av a 2 s . c o m public void processCandies(TranspilationHandler transpilationHandler) throws IOException { CandyStore candiesStore = getCandiesStore(); LinkedHashMap<File, CandyDescriptor> newCandiesDescriptors = getCandiesDescriptorsFromClassPath( transpilationHandler); CandyStore newStore = new CandyStore(new ArrayList<>(newCandiesDescriptors.values())); if (newStore.equals(candiesStore)) { logger.info("candies are up to date"); return; } this.candiesStore = newStore; logger.info("candies changed, processing candies: " + this.candiesStore); try { extractCandies(newCandiesDescriptors); writeCandiesStore(); } catch (Throwable t) { logger.error("cannot generate candies bundle", t); // exit with fatal if no jar ? } }
From source file:controllers.impl.StandardApi.java
@Override public F.Promise<Result> updateStagePackageVersions(final String envName, final String stageName) { final models.Stage stage = models.Stage.getByEnvironmentNameAndName(envName, stageName); if (stage == null) { return F.Promise.pure(notFound()); }//from www. ja v a 2 s . co m final List<models.PackageVersion> versions = Lists.newArrayList(); final JsonNode requestJson = request().body().asJson(); if (requestJson == null) { return F.Promise.pure(badRequest()); } final ArrayNode packages = (ArrayNode) requestJson.get("packages"); for (final JsonNode node : packages) { final ObjectNode packageNode = (ObjectNode) node; final String packageName = packageNode.get("name").asText(); final String version = packageNode.get("version").asText(); final PackageVersion pkgVersion = getPackageVersion(packageName, version); versions.add(pkgVersion); } final ManifestHistory currentHistory = ManifestHistory.getCurrentForStage(stage); final Manifest currentManifest = currentHistory.getManifest(); final LinkedHashMap<String, PackageVersion> newPackages = Maps .newLinkedHashMap(currentManifest.asPackageMap()); versions.forEach(pv -> newPackages.put(pv.getPkg().getName(), pv)); final Manifest newManifest = new Manifest(); newManifest.getPackages().addAll(newPackages.values()); newManifest.save(); final Future<Object> ask = Patterns.ask(_deploymentManager, new FleetDeploymentCommands.DeployStage(stage, newManifest, "api"), Timeout.apply(30L, TimeUnit.SECONDS)); return F.Promise.wrap(ask).map(o -> { if (o instanceof Deployment) { final Deployment deployment = (Deployment) o; return ok(JsonNodeFactory.instance.objectNode().put("deployId", deployment.getId())); } Logger.error("Expected Deployment response from deployment manager, got " + o); return internalServerError(); }); }
From source file:edu.csun.ecs.cs.multitouchj.ui.event.ObjectEventManager.java
protected void handleEvent() { setRunning(true);//from w w w . j a va 2 s. co m for (ObjectType objectType : ObjectType.values()) { eventsCleaned.put(objectType, true); } while (isRunning()) { synchronized (activeObjects) { // check for "started" or "moved" if (isUpdated()) { for (ObjectType objectType : activeObjects.keySet()) { LinkedHashMap<Integer, ObjectObserverEvent> objects = activeObjects.get(objectType); if (objects.size() > 0) { LinkedList<ObjectObserverEvent> ooes = new LinkedList<ObjectObserverEvent>( objects.values()); ObjectEvent objectEvent = null; if (ObjectType.Floated.equals(objectType)) { objectEvent = new FloatEvent(this, ooes.getLast(), ooes, (eventsCleaned.get(objectType)) ? ObjectEvent.Status.Started : ObjectEvent.Status.Moved); } else { objectEvent = new TouchEvent(this, ooes.getLast(), ooes, (eventsCleaned.get(objectType)) ? ObjectEvent.Status.Started : ObjectEvent.Status.Moved); } notifyEventListeners(objectEvent); eventsCleaned.put(objectType, false); } } setUpdated(false); } // check for "ended" for (ObjectType objectType : activeObjects.keySet()) { LinkedHashMap<Integer, ObjectObserverEvent> objects = activeObjects.get(objectType); if (objects.size() > 0) { LinkedList<ObjectObserverEvent> ooes = new LinkedList<ObjectObserverEvent>( objects.values()); // check for ones expired long currentTime = (new Date()).getTime(); LinkedList<Integer> deletedIds = new LinkedList<Integer>(); for (ObjectObserverEvent ooe : ooes) { if ((currentTime - ooe.getTime()) >= CLEAN_UP_TIME) { deletedIds.add(ooe.getId()); } } for (int deletedId : deletedIds) { objects.remove(deletedId); } // check if all expired if (objects.size() == 0) { ObjectEvent objectEvent = null; if (ObjectType.Floated.equals(objectType)) { objectEvent = new FloatEvent(this, ooes.getLast(), ooes, ObjectEvent.Status.Ended); } else { objectEvent = new TouchEvent(this, ooes.getLast(), ooes, ObjectEvent.Status.Ended); } notifyEventListeners(objectEvent); eventsCleaned.put(objectType, true); } } } } try { Thread.sleep(15); } catch (Exception exception) { } } }
From source file:com.grarak.kerneladiutor.utils.database.ProfileDB.java
public void putProfile(String name, LinkedHashMap<String, String> commands) { try {//from ww w . j a v a 2 s .c o m JSONObject items = new JSONObject(); items.put("name", name); JSONArray commandArray = new JSONArray(); for (int i = 0; i < commands.size(); i++) { JSONObject item = new JSONObject(); item.put("path", commands.keySet().toArray()[i]); item.put("command", commands.values().toArray()[i]); commandArray.put(item); } items.put("commands", commandArray); items.put("id", UUID.randomUUID()); putItem(items); } catch (JSONException e) { e.printStackTrace(); } }
From source file:com.twitter.ambrose.hive.HiveDAGTransformer.java
/** * Gets all job aliases/*from w ww . j a va 2 s . co m*/ * * @param pathToAliases * @return */ private List<String> getAllJobAliases(LinkedHashMap<String, ArrayList<String>> pathToAliases) { if (pathToAliases == null || pathToAliases.isEmpty()) { return Collections.emptyList(); } List<String> result = new ArrayList<String>(); for (List<String> aliases : pathToAliases.values()) { if (aliases != null && !aliases.isEmpty()) { result.addAll(aliases); } } return result; }
From source file:com.alibaba.wasp.meta.TableSchemaCacheReader.java
public FTable addSchema(String tableName, FTable tableSchema) { if (tableSchema == null) { return null; }/*from w w w .java 2 s . c o m*/ LinkedHashMap<String, Index> indexs = tableSchema.getIndex(); if (indexs != null) { ConcurrentHashMap<String, List<Index>> col2IndexMap = new ConcurrentHashMap<String, List<Index>>(); ConcurrentHashMap<String, List<Index>> storing2IndexMap = new ConcurrentHashMap<String, List<Index>>(); for (Index index : indexs.values()) { for (Field field : index.getIndexKeys().values()) { mapping(index, field, col2IndexMap); } for (Field field : index.getStoring().values()) { mapping(index, field, storing2IndexMap); } mapping(index, tableName); } key2Index.put(tableName, col2IndexMap); storing2Index.put(tableName, storing2IndexMap); } return tableSchemas.put(tableName, tableSchema); }