Java Code Examples for rx.schedulers.Schedulers#computation()

The following examples show how to use rx.schedulers.Schedulers#computation() . 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: SimulatedTitusAgentCluster.java    From titus-control-plane with Apache License 2.0 6 votes vote down vote up
private SimulatedTitusAgent createAgent() {
    String hostName = ComputeResources.asHostname(computeResources.allocateIpAddress(), name);
    String zoneId = ZONES[(int) (zoneCounter.getAndIncrement() % ZONES.length)];
    Protos.SlaveID slaveId = Protos.SlaveID.newBuilder().setValue(hostName).build();

    Protos.Offer.Builder agentOfferTemplate = offerTemplate.clone()
            .setHostname(hostName)
            .addAttributes(Attribute.newBuilder().setName("zone").setType(Type.TEXT).setText(Text.newBuilder().setValue(zoneId).build()).build())
            .setUrl(Protos.URL.newBuilder()
                    .setScheme("http")
                    .setAddress(Protos.Address.newBuilder().setHostname(hostName).setPort(5051))
                    .setPath("slave")
            );

    SimulatedTitusAgent agent = new SimulatedTitusAgent(name, computeResources, hostName, slaveId, agentOfferTemplate, instanceType,
            cpus, gpus, memory, disk, networkMbs, ipPerEni, containerPlayersManager, Schedulers.computation());
    agents.put(agent.getId(), agent);
    topologUpdateSubject.onNext(AgentChangeEvent.newInstance(this, agent));
    return agent;
}
 
Example 2
Source File: ServiceDifferenceResolver.java    From titus-control-plane with Apache License 2.0 6 votes vote down vote up
@Inject
public ServiceDifferenceResolver(
        DirectKubeApiServerIntegrator kubeApiServerIntegrator,
        JobManagerConfiguration configuration,
        FeatureActivationConfiguration featureConfiguration,
        DirectKubeConfiguration kubeConfiguration,
        @Named(FeatureRolloutPlans.KUBE_SCHEDULER_FEATURE) Predicate<Pair<JobDescriptor, ApplicationSLA>> kubeSchedulerPredicate,
        ApplicationSlaManagementService capacityGroupService,
        SchedulingService<? extends TaskRequest> schedulingService,
        VirtualMachineMasterService vmService,
        JobStore jobStore,
        ConstraintEvaluatorTransformer<Pair<String, String>> constraintEvaluatorTransformer,
        SystemSoftConstraint systemSoftConstraint,
        SystemHardConstraint systemHardConstraint,
        TitusRuntime titusRuntime) {
    this(kubeApiServerIntegrator, configuration, featureConfiguration, kubeConfiguration, kubeSchedulerPredicate, capacityGroupService,
            schedulingService, vmService, jobStore, constraintEvaluatorTransformer, systemSoftConstraint,
            systemHardConstraint, titusRuntime, Schedulers.computation()
    );
}
 
Example 3
Source File: LeaderElectionOrchestrator.java    From titus-control-plane with Apache License 2.0 6 votes vote down vote up
@Inject
public LeaderElectionOrchestrator(SupervisorConfiguration configuration,
                                  LocalMasterInstanceResolver localMasterInstanceResolver,
                                  MasterMonitor masterMonitor,
                                  LeaderElector leaderElector,
                                  TitusRuntime titusRuntime) {
    this(
            configuration,
            localMasterInstanceResolver,
            masterMonitor,
            leaderElector,
            fetchInitialMasterInstance(localMasterInstanceResolver),
            titusRuntime,
            Schedulers.computation()
    );
}
 
Example 4
Source File: TaskRelocationDataInjector.java    From titus-control-plane with Apache License 2.0 5 votes vote down vote up
@Inject
TaskRelocationDataInjector(
        GrpcClientConfiguration configuration,
        JobManagerConfiguration jobManagerConfiguration,
        FeatureActivationConfiguration featureActivationConfiguration,
        RelocationServiceClient relocationServiceClient,
        RelocationDataReplicator relocationDataReplicator) {
    this(configuration, jobManagerConfiguration, featureActivationConfiguration, relocationServiceClient, relocationDataReplicator, Schedulers.computation());
}
 
Example 5
Source File: MockFragmentModule.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Mocks the error response
 */
@Override ImageValidator provideImageValidator(ImageInfoProvider imageInfoProvider) {
  Scheduler scheduler = Schedulers.computation();
  return new ImageValidator(scheduler, imageInfoProvider) {

    @Override public Completable validateOrGetException(String imagePath) {
      return Completable.defer(() -> {
        try {
          final List<InvalidImageException.ImageError> errors = new ArrayList<>();
          if (TestType.types.equals(TestType.TestTypes.ERRORDECONDINGTEST)) {
            errors.add(InvalidImageException.ImageError.ERROR_DECODING);
          }
          if (TestType.types.equals(TestType.TestTypes.MIN_HEIGHTTEST)) {
            errors.add(InvalidImageException.ImageError.MIN_HEIGHT);
          }
          if (TestType.types.equals(TestType.TestTypes.MIN_WIDTHTEST)) {
            errors.add(InvalidImageException.ImageError.MIN_WIDTH);
          }
          if (TestType.types.equals(TestType.TestTypes.MAX_HEIGHTTEST)) {
            errors.add(InvalidImageException.ImageError.MAX_HEIGHT);
          }
          if (TestType.types.equals(TestType.TestTypes.MAX_WIDTHTEST)) {
            errors.add(InvalidImageException.ImageError.MAX_WIDTH);
          }
          if (TestType.types.equals(TestType.TestTypes.MAX_IMAGE_SIZETEST)) {
            errors.add(InvalidImageException.ImageError.MAX_IMAGE_SIZE);
          }
          if (!errors.isEmpty()) {
            throw new InvalidImageException(errors);
          }
          return Completable.complete();
        } catch (InvalidImageException ex) {
          return Completable.error(ex);
        }
      })
          .subscribeOn(scheduler);
    }
  };
}
 
Example 6
Source File: Application.java    From MarketData with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws IOException {
    new StaticServer("marketdata-web", 8000).createServer().start();

    // if ever you need a static http server for the documentation...
    // new StaticServer("reactivex.io-mirror", 8001).createServer().start();

    Scheduler scheduler = Schedulers.computation();
    EventStreamClient forexEventStreamClient
            = new MulticastEventStreamClient(new RxNettyEventEventStreamClient(8096), scheduler);
    ForexServer forexServer = new ForexServer(8080, forexEventStreamClient);
    forexServer.createServer().start();

    EventStreamClient stockEventStreamClient
            = new MulticastEventStreamClient(new RxNettyEventEventStreamClient(8097), scheduler);
    StockQuoteServer stockQuoteServer
            = new StockQuoteServer(8081, stockEventStreamClient, forexEventStreamClient, scheduler);
    stockQuoteServer.createServer().start();

    EventStreamClient tradeEventStreamClient
            = new MulticastEventStreamClient(new RxNettyEventEventStreamClient(8098), scheduler);
    VwapServer vwapServer = new VwapServer(8082, tradeEventStreamClient, scheduler);
    vwapServer.createServer().start();

    RequestReplyClient stockStaticDataClient = new RxNettyRequestReplyClient(8099, "code");
    StockServer stockServer
            = new StockServer(8083, stockStaticDataClient, stockEventStreamClient, scheduler);
    stockServer.createServer().start();

    System.out.println("Servers ready!");
    System.out.println("Application available on http://localhost:8000");
    System.out.println("Press any key to exit");
    System.in.read();
}
 
Example 7
Source File: Orchestrator.java    From titus-control-plane with Apache License 2.0 5 votes vote down vote up
@Inject
public Orchestrator(ExecutionContext context) {
    this.context = context;
    this.metricsCollector = new MetricsCollector();
    metricsCollector.watch(context);
    this.textReporter = new TextReporter(metricsCollector, Schedulers.computation());
    textReporter.start();
}
 
Example 8
Source File: DefaultSchedulingService.java    From titus-control-plane with Apache License 2.0 5 votes vote down vote up
@Inject
public DefaultSchedulingService(V3JobOperations v3JobOperations,
                                AgentManagementService agentManagementService,
                                TaskInfoRequestFactory v3TaskInfoRequestFactory,
                                VMOperations vmOps,
                                final VirtualMachineMasterService virtualMachineService,
                                MasterConfiguration masterConfiguration,
                                SchedulerConfiguration schedulerConfiguration,
                                SystemHardConstraint systemHardConstraint,
                                TaskCache taskCache,
                                OpportunisticCpuCache opportunisticCpuCache,
                                TierSlaUpdater tierSlaUpdater,
                                Registry registry,
                                PreferentialNamedConsumableResourceEvaluator preferentialNamedConsumableResourceEvaluator,
                                AgentManagementFitnessCalculator agentManagementFitnessCalculator,
                                TitusRuntime titusRuntime,
                                AgentResourceCache agentResourceCache,
                                Config config,
                                MesosConfiguration mesosConfiguration,
                                ApplicationSlaManagementService capacityGroupService,
                                SchedulingMachinesFilter schedulingMachinesFilter) {
    this(v3JobOperations, agentManagementService, v3TaskInfoRequestFactory, vmOps, virtualMachineService,
            masterConfiguration, schedulerConfiguration, systemHardConstraint, taskCache, opportunisticCpuCache,
            Schedulers.computation(), tierSlaUpdater, registry, preferentialNamedConsumableResourceEvaluator,
            agentManagementFitnessCalculator, titusRuntime, agentResourceCache, config,
            mesosConfiguration, capacityGroupService, schedulingMachinesFilter);
}
 
Example 9
Source File: DefaultAppScaleManagerTest.java    From titus-control-plane with Apache License 2.0 5 votes vote down vote up
@Test
public void checkBulkPolicyCreations() {
    AutoScalingPolicyTests.MockAlarmClient mockAlarmClient = new AutoScalingPolicyTests.MockAlarmClient();
    AutoScalingPolicyTests.MockAppAutoScalingClient mockAppAutoScalingClient = new AutoScalingPolicyTests.MockAppAutoScalingClient();
    InMemoryPolicyStore policyStore = new InMemoryPolicyStore();

    final int totalJobs = 300;
    List<String> jobIds = new ArrayList<>(totalJobs);
    for (int i = 0; i < totalJobs; i++) {
        String jobId = UUID.randomUUID().toString();
        jobIds.add(jobId);
    }

    V3JobOperations v3JobOperations = mockV3OperationsForJobs(jobIds);
    DefaultAppScaleManager appScaleManager = new DefaultAppScaleManager(policyStore, mockAlarmClient,
            mockAppAutoScalingClient,
            v3JobOperations,
            new DefaultRegistry(),
            AutoScalingPolicyTests.mockAppScaleManagerConfiguration(),
            Schedulers.computation(),
            mock(TitusRuntime.class));

    final CountDownLatch latch = new CountDownLatch(totalJobs);
    for (int i = 0; i < totalJobs; i++) {
        final AutoScalingPolicy autoScalingPolicy = AutoScalingPolicyTests.buildStepScalingPolicy(jobIds.get(i));
        appScaleManager.createAutoScalingPolicy(autoScalingPolicy).subscribe(pid -> {
            log.info("Policy created {}", pid);
            latch.countDown();
        });
    }

    await().timeout(30, TimeUnit.SECONDS).until(() -> mockAppAutoScalingClient.getNumPolicies() == totalJobs);
}
 
Example 10
Source File: ZookeeperMasterMonitor.java    From titus-control-plane with Apache License 2.0 4 votes vote down vote up
@Inject
public ZookeeperMasterMonitor(ZookeeperPaths zkPaths, CuratorService curatorService, TitusRuntime titusRuntime) {
    this(zkPaths, curatorService.getCurator(), null, titusRuntime, Schedulers.computation());
}
 
Example 11
Source File: FragmentModule.java    From aptoide-client-v8 with GNU General Public License v3.0 4 votes vote down vote up
@FragmentScope @Provides ImageValidator provideImageValidator(
    ImageInfoProvider imageInfoProvider) {
  return new ImageValidator(Schedulers.computation(), imageInfoProvider);
}
 
Example 12
Source File: InstanceReaper.java    From titus-control-plane with Apache License 2.0 4 votes vote down vote up
@Inject
public InstanceReaper(AwsConfiguration configuration,
                      AwsInstanceCloudConnector connector,
                      Registry registry) {
    this(configuration, connector, registry, Schedulers.computation());
}
 
Example 13
Source File: AwsInstanceCloudConnector.java    From titus-control-plane with Apache License 2.0 4 votes vote down vote up
@Inject
public AwsInstanceCloudConnector(AwsConfiguration configuration,
                                 AmazonEC2Async ec2Client,
                                 @Named(DataPlaneAmazonAutoScalingAsyncProvider.NAME) AmazonAutoScalingAsync autoScalingClient) {
    this(configuration, ec2Client, autoScalingClient, Schedulers.computation());
}
 
Example 14
Source File: StaticServerPoller.java    From mantis with Apache License 2.0 4 votes vote down vote up
public StaticServerPoller(Set<ServerInfo> servers, int periodSeconds) {
    this(servers, periodSeconds, Schedulers.computation());
}
 
Example 15
Source File: DefaultAgentResourceCache.java    From titus-control-plane with Apache License 2.0 4 votes vote down vote up
@Inject
public DefaultAgentResourceCache(Registry registry) {
    this(registry, Schedulers.computation());
}
 
Example 16
Source File: DefaultResourceConsumptionService.java    From titus-control-plane with Apache License 2.0 4 votes vote down vote up
@Inject
public DefaultResourceConsumptionService(ApplicationSlaManagementService applicationSlaManagementService,
                                         V3JobOperations v3JobOperations,
                                         Registry registry) {
    this(ResourceConsumptionEvaluator.newEvaluator(applicationSlaManagementService, v3JobOperations), registry, Schedulers.computation());
}
 
Example 17
Source File: RingTopology.java    From ocelli with Apache License 2.0 4 votes vote down vote up
public RingTopology(final K localKey, final Func1<T, K> keyFunc, Func1<Integer, Integer> countFunc) {
    this(localKey, keyFunc, countFunc, Schedulers.computation());
}
 
Example 18
Source File: SchedulerProvider.java    From ESeal with Apache License 2.0 4 votes vote down vote up
@NonNull
@Override
public Scheduler computation() {
    return Schedulers.computation();
}
 
Example 19
Source File: RxModule.java    From photoviewer with Apache License 2.0 4 votes vote down vote up
@Provides @Singleton @Named(COMPUTATION) Scheduler provideComputationScheduler() {
  return Schedulers.computation();
}
 
Example 20
Source File: Rx.java    From mesos-rxjava with Apache License 2.0 2 votes vote down vote up
/**
 * This method will return the {@link Scheduler} that is used for all "computation" workloads.
 * <p>
 * The idea of a computation workload is one that is CPU bound.
 * @return The {@link Scheduler} that is to be used for all CPU bound workloads.
 */
@NotNull
public static Scheduler compute() {
    return Schedulers.computation();
}