Skip to content

Commit

Permalink
Parallelize genomic node construction
Browse files Browse the repository at this point in the history
  • Loading branch information
ramari16 committed Jan 19, 2024
1 parent 8f00af0 commit 6465f5a
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.PropertySource;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -28,10 +31,11 @@ public GenomicProcessor localGenomicProcessor() {
@Bean(name = "localDistributedGenomicProcessor")
@ConditionalOnProperty(prefix = "hpds.genomicProcessor", name = "impl", havingValue = "localDistributed")
public GenomicProcessor localDistributedGenomicProcessor() {
List<GenomicProcessor> processorNodes = IntStream.range(1, 23)
.mapToObj(i -> new GenomicProcessorNodeImpl(hpdsGenomicDataDirectory + "/" + i + "/"))
.collect(Collectors.toList());
return new GenomicProcessorParentImpl(processorNodes);
List<GenomicProcessor> genomicProcessors = Flux.range(1, 22)
.flatMap(i -> Mono.fromCallable(() -> (GenomicProcessor) new GenomicProcessorNodeImpl(hpdsGenomicDataDirectory + "/" + i + "/")).subscribeOn(Schedulers.boundedElastic()))
.collectList()
.block();
return new GenomicProcessorParentImpl(genomicProcessors);
}

@Bean(name = "integrationTestGenomicProcessor")
Expand All @@ -47,7 +51,7 @@ public GenomicProcessor integrationTestGenomicProcessor() {
@Bean(name = "remoteGenomicProcessor")
@ConditionalOnProperty(prefix = "hpds.genomicProcessor", name = "impl", havingValue = "remote")
public GenomicProcessor remoteGenomicProcessor() {
// Just for testing, for now, move to a configuration file or something
// todo: Just for testing, for now, move to a configuration file or something
String[] hosts = new String[] {"http://localhost:8090/", "http://localhost:8091/"};
List<GenomicProcessor> nodes = List.of(
new GenomicProcessorRestClient(hosts[0]),
Expand Down

0 comments on commit 6465f5a

Please sign in to comment.