com.netflix.fenzo.functions.Action1 Java Examples

The following examples show how to use com.netflix.fenzo.functions.Action1. 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: MesosResourceManager.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Creates the Fenzo optimizer (builder).
 * The builder is an indirection to facilitate unit testing of the Launch Coordinator.
 */
private static TaskSchedulerBuilder createOptimizer() {
	return new TaskSchedulerBuilder() {
		TaskScheduler.Builder builder = new TaskScheduler.Builder();

		@Override
		public TaskSchedulerBuilder withLeaseRejectAction(Action1<VirtualMachineLease> action) {
			builder.withLeaseRejectAction(action);
			return this;
		}

		@Override
		public TaskScheduler build() {
			return builder.build();
		}
	};
}
 
Example #2
Source File: MesosResourceManager.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Creates the Fenzo optimizer (builder).
 * The builder is an indirection to facilitate unit testing of the Launch Coordinator.
 */
private static TaskSchedulerBuilder createOptimizer() {
	return new TaskSchedulerBuilder() {
		TaskScheduler.Builder builder = new TaskScheduler.Builder();

		@Override
		public TaskSchedulerBuilder withLeaseRejectAction(Action1<VirtualMachineLease> action) {
			builder.withLeaseRejectAction(action);
			return this;
		}

		@Override
		public TaskScheduler build() {
			return builder.build();
		}
	};
}
 
Example #3
Source File: SchedulerService.java    From shardingsphere-elasticjob-cloud with Apache License 2.0 5 votes vote down vote up
private TaskScheduler getTaskScheduler() {
    return new TaskScheduler.Builder()
            .withLeaseOfferExpirySecs(1000000000L)
            .withLeaseRejectAction(new Action1<VirtualMachineLease>() {
                
                @Override
                public void call(final VirtualMachineLease lease) {
                    log.warn("Declining offer on '{}'", lease.hostname());
                    schedulerDriver.declineOffer(lease.getOffer().getId());
                }
            }).build();
}
 
Example #4
Source File: AppConstraintEvaluatorTest.java    From shardingsphere-elasticjob-cloud with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    taskScheduler = new TaskScheduler.Builder().withLeaseOfferExpirySecs(1000000000L).withLeaseRejectAction(new Action1<VirtualMachineLease>() {
        
        @Override
        public void call(final VirtualMachineLease virtualMachineLease) {
        }
    }).build();
}
 
Example #5
Source File: MesosResourceManager.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the Fenzo optimizer (builder).
 * The builder is an indirection to facilitate unit testing of the Launch Coordinator.
 */
private static TaskSchedulerBuilder createOptimizer() {
	return new TaskSchedulerBuilder() {
		TaskScheduler.Builder builder = new TaskScheduler.Builder();

		@Override
		public TaskSchedulerBuilder withLeaseRejectAction(Action1<VirtualMachineLease> action) {
			builder.withLeaseRejectAction(action);
			return this;
		}

		@Override
		public TaskSchedulerBuilder withRejectAllExpiredOffers() {
			builder.withRejectAllExpiredOffers();
			return this;
		}

		@Override
		public TaskSchedulerBuilder withLeaseOfferExpirySecs(long leaseOfferExpirySecs) {
			builder.withLeaseOfferExpirySecs(leaseOfferExpirySecs);
			return this;
		}

		@Override
		public TaskScheduler build() {
			return builder.build();
		}
	};
}
 
Example #6
Source File: VirtualMachineMasterServiceMesosImpl.java    From titus-control-plane with Apache License 2.0 5 votes vote down vote up
@Override
public void setVMLeaseHandler(Action1<List<? extends VirtualMachineLease>> leaseHandler) {
    this.leaseHandler = virtualMachineLeases -> {
        drainKillTaskQueue();
        leaseHandler.call(virtualMachineLeases);
    };
}
 
Example #7
Source File: KubeApiServerIntegrator.java    From titus-control-plane with Apache License 2.0 4 votes vote down vote up
@Override
public void setVMLeaseHandler(Action1<List<? extends VirtualMachineLease>> leaseHandler) {
    this.leaseHandler = leaseHandler;
}
 
Example #8
Source File: KubeApiServerIntegrator.java    From titus-control-plane with Apache License 2.0 4 votes vote down vote up
@Override
public void setRescindLeaseHandler(Action1<List<LeaseRescindedEvent>> rescindLeaseHandler) {
    this.rescindLeaseHandler = rescindLeaseHandler;
}
 
Example #9
Source File: StubbedVirtualMachineMasterService.java    From titus-control-plane with Apache License 2.0 4 votes vote down vote up
@Override
public void setRescindLeaseHandler(Action1<List<LeaseRescindedEvent>> rescindLeaseHandler) {
    throw new IllegalStateException("method not supported");
}
 
Example #10
Source File: MesosSchedulerCallbackHandler.java    From titus-control-plane with Apache License 2.0 4 votes vote down vote up
public MesosSchedulerCallbackHandler(
        Action1<List<? extends VirtualMachineLease>> leaseHandler,
        Observer<LeaseRescindedEvent> vmLeaseRescindedObserver,
        Observer<ContainerEvent> vmTaskStatusObserver,
        V3JobOperations v3JobOperations,
        Optional<FitInjection> taskStatusUpdateFitInjection,
        MasterConfiguration config,
        MesosConfiguration mesosConfiguration,
        TitusRuntime titusRuntime) {
    this.leaseHandler = leaseHandler;
    this.vmLeaseRescindedObserver = vmLeaseRescindedObserver;
    this.vmTaskStatusObserver = vmTaskStatusObserver;
    this.v3JobOperations = v3JobOperations;
    this.taskStatusUpdateFitInjection = taskStatusUpdateFitInjection;
    this.config = config;
    this.mesosConfiguration = mesosConfiguration;
    this.registry = titusRuntime.getRegistry();
    this.mesosStateTracker = new MesosStateTracker(config, titusRuntime, Schedulers.computation());

    numMesosRegistered = registry.counter(MetricConstants.METRIC_MESOS + "numMesosRegistered");
    numMesosDisconnects = registry.counter(MetricConstants.METRIC_MESOS + "numMesosDisconnects");
    numOfferRescinded = registry.counter(MetricConstants.METRIC_MESOS + "numOfferRescinded");
    numReconcileTasks = registry.counter(MetricConstants.METRIC_MESOS + "numReconcileTasks");
    lastOfferReceivedMillis = registry.gauge(MetricConstants.METRIC_MESOS + "lastOfferReceivedMillis", new AtomicLong());
    lastValidOfferReceiveMillis = registry.gauge(MetricConstants.METRIC_MESOS + "lastValidOfferReceiveMillis", new AtomicLong());
    numInvalidOffers = registry.counter(MetricConstants.METRIC_MESOS + "numInvalidOffers");
    numOfferTooSmall = registry.counter(MetricConstants.METRIC_MESOS + "numOfferTooSmall");

    this.invalidRequestMessageMatcherFactory = RegExpExt.dynamicMatcher(mesosConfiguration::getInvalidRequestMessagePattern, "invalidRequestMessagePattern", Pattern.DOTALL, logger);
    this.crashedMessageMatcherFactory = RegExpExt.dynamicMatcher(mesosConfiguration::getCrashedMessagePattern, "crashedMessagePattern", Pattern.DOTALL, logger);
    this.transientSystemErrorMessageMatcherFactory = RegExpExt.dynamicMatcher(mesosConfiguration::getTransientSystemErrorMessagePattern, "transientSystemErrorMessagePattern", Pattern.DOTALL, logger);
    this.localSystemErrorMessageMatcherFactory = RegExpExt.dynamicMatcher(mesosConfiguration::getLocalSystemErrorMessagePattern, "localSystemErrorMessagePattern", Pattern.DOTALL, logger);
    this.unknownSystemErrorMessageMatcherFactory = RegExpExt.dynamicMatcher(mesosConfiguration::getUnknownSystemErrorMessagePattern, "unknownSystemErrorMessagePattern", Pattern.DOTALL, logger);

    this.subscription = Observable
            .interval(10, 10, TimeUnit.SECONDS)
            .doOnNext(tick -> {
                lastOfferReceivedMillis.set(System.currentTimeMillis() - lastOfferReceivedAt.get());
                lastValidOfferReceiveMillis.set(System.currentTimeMillis() - lastValidOfferReceivedAt.get());
            })
            .subscribe();
}
 
Example #11
Source File: VirtualMachineMasterServiceMesosImpl.java    From titus-control-plane with Apache License 2.0 4 votes vote down vote up
@Override
public void setRescindLeaseHandler(Action1<List<LeaseRescindedEvent>> rescindLeaseHandler) {
    // do nothing
}
 
Example #12
Source File: StubbedVirtualMachineMasterService.java    From titus-control-plane with Apache License 2.0 4 votes vote down vote up
@Override
public void setVMLeaseHandler(Action1<List<? extends VirtualMachineLease>> leaseHandler) {
    throw new IllegalStateException("method not supported");
}
 
Example #13
Source File: TaskSchedulerBuilder.java    From Flink-CEPplus with Apache License 2.0 2 votes vote down vote up
/**
 * Set the callback action for rejecting a lease.
 */
TaskSchedulerBuilder withLeaseRejectAction(Action1<VirtualMachineLease> action);
 
Example #14
Source File: TaskSchedulerBuilder.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Set the callback action for rejecting a lease.
 */
TaskSchedulerBuilder withLeaseRejectAction(Action1<VirtualMachineLease> action);
 
Example #15
Source File: TaskSchedulerBuilder.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Set the callback action for rejecting a lease.
 */
TaskSchedulerBuilder withLeaseRejectAction(Action1<VirtualMachineLease> action);
 
Example #16
Source File: VirtualMachineMasterService.java    From titus-control-plane with Apache License 2.0 votes vote down vote up
void setRescindLeaseHandler(Action1<List<LeaseRescindedEvent>> rescindLeaseHandler); 
Example #17
Source File: VirtualMachineMasterService.java    From titus-control-plane with Apache License 2.0 votes vote down vote up
void setVMLeaseHandler(Action1<List<? extends VirtualMachineLease>> leaseHandler);