Refine search
public Collection<ServerHolder> getAllServers() { final int historicalSize = historicals.values().stream().mapToInt(Collection::size).sum(); final int realtimeSize = realtimes.size(); final List<ServerHolder> allServers = new ArrayList<>(historicalSize + realtimeSize); historicals.values().forEach(allServers::addAll); allServers.addAll(realtimes); return allServers; }
public static List<Section> order(Collection<Section> sections, String... orderedNames) { Map<String, Section> alphabeticalOrderedMap = new TreeMap<>(); sections.forEach(section -> alphabeticalOrderedMap.put(section.getName(), section)); List<Section> result = new ArrayList<>(sections.size()); stream(orderedNames).forEach(name -> { Section section = alphabeticalOrderedMap.remove(name); if (section != null) { result.add(section); } }); result.addAll(alphabeticalOrderedMap.values()); return result; } }
public DefaultAsyncDistributedLog(String name, LogClient client, Serializer serializer) { this.name = checkNotNull(name); this.client = checkNotNull(client); this.serializer = checkNotNull(serializer); client.getPartitions().forEach(partition -> { DefaultAsyncDistributedLogPartition<E> logPartition = new DefaultAsyncDistributedLogPartition<>(this, partition, serializer); partitions.put(partition.partitionId().id(), logPartition); sortedPartitions.add(logPartition); }); }
private List<Entry> buildTree(Map<Long, Entry> procMap) { List<Entry> rootEntries = new ArrayList<>(); procMap.values().forEach(entry -> { if (!entry.proc.hasParentId()) { rootEntries.add(entry); } else { Entry parentEntry = procMap.get(entry.proc.getParentId()); // For a valid procedure this should not be null. We will log the error later if it is null, // as it will not be referenced by any root procedures. if (parentEntry != null) { parentEntry.subProcs.add(entry); } } }); return rootEntries; }
private void addConfigToCache(File file, ESSyncConfig config) { esAdapter.getEsSyncConfig().put(file.getName(), config); SchemaItem schemaItem = SqlParser.parse(config.getEsMapping().getSql()); config.getEsMapping().setSchemaItem(schemaItem); DruidDataSource dataSource = DatasourceConfig.DATA_SOURCES.get(config.getDataSourceKey()); if (dataSource == null || dataSource.getUrl() == null) { throw new RuntimeException("No data source found: " + config.getDataSourceKey()); } Pattern pattern = Pattern.compile(".*:(.*)://.*/(.*)\\?.*$"); Matcher matcher = pattern.matcher(dataSource.getUrl()); if (!matcher.find()) { throw new RuntimeException("Not found the schema of jdbc-url: " + config.getDataSourceKey()); } String schema = matcher.group(2); schemaItem.getAliasTableItems().values().forEach(tableItem -> { Map<String, ESSyncConfig> esSyncConfigMap = esAdapter.getDbTableEsSyncConfig() .computeIfAbsent(schema + "-" + tableItem.getTableName(), k -> new HashMap<>()); esSyncConfigMap.put(file.getName(), config); }); }
protected <T> Flux<T> doInsertAll(Collection<? extends T> listToSave, MongoWriter<Object> writer) { Map<String, List<T>> elementsByCollection = new HashMap<>(); listToSave.forEach(element -> { MongoPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(element.getClass()); String collection = entity.getCollection(); List<T> collectionElements = elementsByCollection.computeIfAbsent(collection, k -> new ArrayList<>()); collectionElements.add(element); }); return Flux.fromIterable(elementsByCollection.keySet()) .flatMap(collectionName -> doInsertBatch(collectionName, elementsByCollection.get(collectionName), writer)); }
public void sync(Dml dml) { if (dml == null) { return; } String destination = StringUtils.trimToEmpty(dml.getDestination()); String database = dml.getDatabase(); String table = dml.getTable(); Map<String, MappingConfig> configMap = mappingConfigCache.get(destination + "." + database + "." + table); if (configMap != null) { configMap.values().forEach(config -> hbaseSyncService.sync(config, dml)); } }
public Set<String> getAllTiers() { ImmutableSet.Builder<String> builder = new ImmutableSet.Builder<>(); druidNodeDiscovery.getAllNodes().forEach( node -> builder.add(((LookupNodeService) node.getServices() .get(LookupNodeService.DISCOVERY_SERVICE_KEY)).getLookupTier()) ); return builder.build(); } }
private ModifyableTableDescriptor(final TableName name, final Collection<ColumnFamilyDescriptor> families, Map<Bytes, Bytes> values) { this.name = name; families.forEach(c -> this.families.put(c.getName(), ColumnFamilyDescriptorBuilder.copy(c))); this.values.putAll(values); this.values.put(IS_META_KEY, new Bytes(Bytes.toBytes(Boolean.toString(name.equals(TableName.META_TABLE_NAME))))); }