org.apache.flink.runtime.jobmaster.slotpool.DefaultSlotPoolFactory Java Examples

The following examples show how to use org.apache.flink.runtime.jobmaster.slotpool.DefaultSlotPoolFactory. 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: JobMasterBuilder.java    From flink with Apache License 2.0 6 votes vote down vote up
public JobMaster createJobMaster() throws Exception {
	final JobMasterConfiguration jobMasterConfiguration = JobMasterConfiguration.fromConfiguration(configuration);

	return new JobMaster(
		rpcService,
		jobMasterConfiguration,
		jmResourceId,
		jobGraph,
		highAvailabilityServices,
		slotPoolFactory != null ? slotPoolFactory : DefaultSlotPoolFactory.fromConfiguration(configuration),
		schedulerFactory != null ? schedulerFactory : DefaultSchedulerFactory.fromConfiguration(configuration),
		jobManagerSharedServices,
		heartbeatServices,
		UnregisteredJobManagerJobMetricGroupFactory.INSTANCE,
		onCompletionActions,
		fatalErrorHandler,
		JobMasterBuilder.class.getClassLoader(),
		SchedulerNGFactoryFactory.createSchedulerNGFactory(configuration),
		shuffleMaster,
		partitionTrackerFactory);
}
 
Example #2
Source File: JobMasterTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
/**
 * Tests that the timeout in {@link JobMasterGateway#triggerSavepoint(String, boolean, Time)}
 * is respected.
 */
@Test
public void testTriggerSavepointTimeout() throws Exception {
	final JobMaster jobMaster = new JobMaster(
		rpcService,
		JobMasterConfiguration.fromConfiguration(configuration),
		jmResourceId,
		jobGraph,
		haServices,
		DefaultSlotPoolFactory.fromConfiguration(configuration),
		DefaultSchedulerFactory.fromConfiguration(configuration),
		new TestingJobManagerSharedServicesBuilder().build(),
		heartbeatServices,
		UnregisteredJobManagerJobMetricGroupFactory.INSTANCE,
		new TestingOnCompletionActions(),
		testingFatalErrorHandler,
		JobMasterTest.class.getClassLoader()) {

		@Override
		public CompletableFuture<String> triggerSavepoint(
				@Nullable final String targetDirectory,
				final boolean cancelJob,
				final Time timeout) {
			return new CompletableFuture<>();
		}
	};

	try {
		final CompletableFuture<Acknowledge> startFuture = jobMaster.start(jobMasterId);
		startFuture.get(testingTimeout.toMilliseconds(), TimeUnit.MILLISECONDS);

		final JobMasterGateway jobMasterGateway = jobMaster.getSelfGateway(JobMasterGateway.class);
		final CompletableFuture<String> savepointFutureLowTimeout = jobMasterGateway.triggerSavepoint("/tmp", false, Time.milliseconds(1));
		final CompletableFuture<String> savepointFutureHighTimeout = jobMasterGateway.triggerSavepoint("/tmp", false, RpcUtils.INF_TIMEOUT);

		try {
			savepointFutureLowTimeout.get(testingTimeout.getSize(), testingTimeout.getUnit());
			fail();
		} catch (final ExecutionException e) {
			final Throwable cause = ExceptionUtils.stripExecutionException(e);
			assertThat(cause, instanceOf(TimeoutException.class));
		}

		assertThat(savepointFutureHighTimeout.isDone(), is(equalTo(false)));
	} finally {
		RpcUtils.terminateRpcEndpoint(jobMaster, testingTimeout);
	}
}
 
Example #3
Source File: JobMasterTest.java    From flink with Apache License 2.0 4 votes vote down vote up
/**
 * Tests that the timeout in {@link JobMasterGateway#triggerSavepoint(String, boolean, Time)}
 * is respected.
 */
@Test
public void testTriggerSavepointTimeout() throws Exception {
	final JobManagerSharedServices jobManagerSharedServices = new TestingJobManagerSharedServicesBuilder().build();
	final JobMasterConfiguration jobMasterConfiguration = JobMasterConfiguration.fromConfiguration(configuration);

	final SchedulerNGFactory schedulerNGFactory = new LegacySchedulerFactory(
		jobManagerSharedServices.getRestartStrategyFactory());

	final JobMaster jobMaster = new JobMaster(
		rpcService,
		jobMasterConfiguration,
		jmResourceId,
		jobGraph,
		haServices,
		DefaultSlotPoolFactory.fromConfiguration(configuration),
		DefaultSchedulerFactory.fromConfiguration(configuration),
		jobManagerSharedServices,
		heartbeatServices,
		UnregisteredJobManagerJobMetricGroupFactory.INSTANCE,
		new TestingOnCompletionActions(),
		testingFatalErrorHandler,
		JobMasterTest.class.getClassLoader(),
		schedulerNGFactory,
		NettyShuffleMaster.INSTANCE,
		NoOpPartitionTracker.FACTORY) {

		@Override
		public CompletableFuture<String> triggerSavepoint(
			@Nullable final String targetDirectory,
			final boolean cancelJob,
			final Time timeout) {
			return new CompletableFuture<>();
		}
	};

	try {
		final CompletableFuture<Acknowledge> startFuture = jobMaster.start(jobMasterId);
		startFuture.get(testingTimeout.toMilliseconds(), TimeUnit.MILLISECONDS);

		final JobMasterGateway jobMasterGateway = jobMaster.getSelfGateway(JobMasterGateway.class);
		final CompletableFuture<String> savepointFutureLowTimeout = jobMasterGateway.triggerSavepoint("/tmp", false, Time.milliseconds(1));
		final CompletableFuture<String> savepointFutureHighTimeout = jobMasterGateway.triggerSavepoint("/tmp", false, RpcUtils.INF_TIMEOUT);

		try {
			savepointFutureLowTimeout.get(testingTimeout.getSize(), testingTimeout.getUnit());
			fail();
		} catch (final ExecutionException e) {
			final Throwable cause = ExceptionUtils.stripExecutionException(e);
			assertThat(cause, instanceOf(TimeoutException.class));
		}

		assertThat(savepointFutureHighTimeout.isDone(), is(equalTo(false)));
	} finally {
		RpcUtils.terminateRpcEndpoint(jobMaster, testingTimeout);
	}
}
 
Example #4
Source File: JobMasterTest.java    From flink with Apache License 2.0 4 votes vote down vote up
/**
 * Tests that the timeout in {@link JobMasterGateway#triggerSavepoint(String, boolean, Time)}
 * is respected.
 */
@Test
public void testTriggerSavepointTimeout() throws Exception {
	final JobManagerSharedServices jobManagerSharedServices = new TestingJobManagerSharedServicesBuilder().build();
	final JobMasterConfiguration jobMasterConfiguration = JobMasterConfiguration.fromConfiguration(configuration);

	final SchedulerNGFactory schedulerNGFactory = SchedulerNGFactoryFactory.createSchedulerNGFactory(configuration);

	final JobMaster jobMaster = new JobMaster(
		rpcService,
		jobMasterConfiguration,
		jmResourceId,
		jobGraph,
		haServices,
		DefaultSlotPoolFactory.fromConfiguration(configuration),
		DefaultSchedulerFactory.fromConfiguration(configuration),
		jobManagerSharedServices,
		heartbeatServices,
		UnregisteredJobManagerJobMetricGroupFactory.INSTANCE,
		new JobMasterBuilder.TestingOnCompletionActions(),
		testingFatalErrorHandler,
		JobMasterTest.class.getClassLoader(),
		schedulerNGFactory,
		NettyShuffleMaster.INSTANCE,
		NoOpJobMasterPartitionTracker.FACTORY) {

		@Override
		public CompletableFuture<String> triggerSavepoint(
			@Nullable final String targetDirectory,
			final boolean cancelJob,
			final Time timeout) {
			return new CompletableFuture<>();
		}
	};

	try {
		final CompletableFuture<Acknowledge> startFuture = jobMaster.start(jobMasterId);
		startFuture.get(testingTimeout.toMilliseconds(), TimeUnit.MILLISECONDS);

		final JobMasterGateway jobMasterGateway = jobMaster.getSelfGateway(JobMasterGateway.class);
		final CompletableFuture<String> savepointFutureLowTimeout = jobMasterGateway.triggerSavepoint("/tmp", false, Time.milliseconds(1));
		final CompletableFuture<String> savepointFutureHighTimeout = jobMasterGateway.triggerSavepoint("/tmp", false, RpcUtils.INF_TIMEOUT);

		try {
			savepointFutureLowTimeout.get(testingTimeout.getSize(), testingTimeout.getUnit());
			fail();
		} catch (final ExecutionException e) {
			final Throwable cause = ExceptionUtils.stripExecutionException(e);
			assertThat(cause, instanceOf(TimeoutException.class));
		}

		assertThat(savepointFutureHighTimeout.isDone(), is(equalTo(false)));
	} finally {
		RpcUtils.terminateRpcEndpoint(jobMaster, testingTimeout);
	}
}