Java Code Examples for org.apache.flink.runtime.util.TestingFatalErrorHandler

The following examples show how to use org.apache.flink.runtime.util.TestingFatalErrorHandler. These examples are extracted from open source projects. 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 Project: Flink-CEPplus   Source File: YarnResourceManagerTest.java    License: Apache License 2.0 6 votes vote down vote up
@Before
public void setup() {
	testingFatalErrorHandler = new TestingFatalErrorHandler();

	flinkConfig = new Configuration();
	flinkConfig.setInteger(ResourceManagerOptions.CONTAINERIZED_HEAP_CUTOFF_MIN, 100);

	File root = folder.getRoot();
	File home = new File(root, "home");
	boolean created = home.mkdir();
	assertTrue(created);

	env = new HashMap<>();
	env.put(ENV_APP_ID, "foo");
	env.put(ENV_CLIENT_HOME_DIR, home.getAbsolutePath());
	env.put(ENV_CLIENT_SHIP_FILES, "");
	env.put(ENV_FLINK_CLASSPATH, "");
	env.put(ENV_HADOOP_USER_NAME, "foo");
	env.put(FLINK_JAR_PATH, root.toURI().toString());
}
 
Example 2
Source Project: Flink-CEPplus   Source File: JobMasterTest.java    License: Apache License 2.0 6 votes vote down vote up
@Before
public void setup() throws IOException {
	configuration = new Configuration();
	haServices = new TestingHighAvailabilityServices();
	jobMasterId = JobMasterId.generate();
	jmResourceId = ResourceID.generate();

	testingFatalErrorHandler = new TestingFatalErrorHandler();

	haServices.setCheckpointRecoveryFactory(new StandaloneCheckpointRecoveryFactory());

	rmLeaderRetrievalService = new SettableLeaderRetrievalService(
		null,
		null);
	haServices.setResourceManagerLeaderRetriever(rmLeaderRetrievalService);

	configuration.setString(BlobServerOptions.STORAGE_DIRECTORY, temporaryFolder.newFolder().getAbsolutePath());
}
 
Example 3
Source Project: Flink-CEPplus   Source File: TaskExecutorTest.java    License: Apache License 2.0 6 votes vote down vote up
@Before
public void setup() throws IOException {
	rpc = new TestingRpcService();
	timerService = new TimerService<>(TestingUtils.defaultExecutor(), timeout.toMilliseconds());

	dummyBlobCacheService = new BlobCacheService(
		new Configuration(),
		new VoidBlobStore(),
		null);

	configuration = new Configuration();
	taskManagerConfiguration = TaskManagerConfiguration.fromConfiguration(configuration);

	taskManagerLocation = new LocalTaskManagerLocation();
	jobId = new JobID();

	testingFatalErrorHandler = new TestingFatalErrorHandler();

	haServices = new TestingHighAvailabilityServices();
	resourceManagerLeaderRetriever = new SettableLeaderRetrievalService();
	jobManagerLeaderRetriever = new SettableLeaderRetrievalService();
	haServices.setResourceManagerLeaderRetriever(resourceManagerLeaderRetriever);
	haServices.setJobMasterLeaderRetriever(jobId, jobManagerLeaderRetriever);
}
 
Example 4
@Before
public void setup() throws Exception {
	rpcService = new TestingRpcService();

	createAndRegisterTaskExecutorGateway();
	taskExecutorResourceID = ResourceID.generate();
	resourceManagerResourceID = ResourceID.generate();
	testingFatalErrorHandler = new TestingFatalErrorHandler();
	TestingLeaderElectionService rmLeaderElectionService = new TestingLeaderElectionService();
	resourceManager = createAndStartResourceManager(rmLeaderElectionService, testingFatalErrorHandler);
	rmGateway = resourceManager.getSelfGateway(ResourceManagerGateway.class);
	wronglyFencedGateway = rpcService.connect(resourceManager.getAddress(), ResourceManagerId.generate(), ResourceManagerGateway.class)
		.get(TIMEOUT.toMilliseconds(), TimeUnit.MILLISECONDS);

	grantLeadership(rmLeaderElectionService).get(TIMEOUT.toMilliseconds(), TimeUnit.MILLISECONDS);
}
 
Example 5
Source Project: flink   Source File: YarnResourceManagerTest.java    License: Apache License 2.0 6 votes vote down vote up
@Before
public void setup() {
	testingFatalErrorHandler = new TestingFatalErrorHandler();

	flinkConfig = new Configuration();
	flinkConfig.setInteger(ResourceManagerOptions.CONTAINERIZED_HEAP_CUTOFF_MIN, 100);

	File root = folder.getRoot();
	File home = new File(root, "home");
	boolean created = home.mkdir();
	assertTrue(created);

	env = new HashMap<>();
	env.put(ENV_APP_ID, "foo");
	env.put(ENV_CLIENT_HOME_DIR, home.getAbsolutePath());
	env.put(ENV_CLIENT_SHIP_FILES, "");
	env.put(ENV_FLINK_CLASSPATH, "");
	env.put(ENV_HADOOP_USER_NAME, "foo");
	env.put(FLINK_JAR_PATH, root.toURI().toString());
}
 
Example 6
Source Project: flink   Source File: JobMasterTest.java    License: Apache License 2.0 6 votes vote down vote up
@Before
public void setup() throws IOException {
	configuration = new Configuration();
	haServices = new TestingHighAvailabilityServices();
	jobMasterId = JobMasterId.generate();
	jmResourceId = ResourceID.generate();

	testingFatalErrorHandler = new TestingFatalErrorHandler();

	haServices.setCheckpointRecoveryFactory(new StandaloneCheckpointRecoveryFactory());

	rmLeaderRetrievalService = new SettableLeaderRetrievalService(
		null,
		null);
	haServices.setResourceManagerLeaderRetriever(rmLeaderRetrievalService);

	configuration.setString(BlobServerOptions.STORAGE_DIRECTORY, temporaryFolder.newFolder().getAbsolutePath());
}
 
Example 7
Source Project: flink   Source File: TaskExecutorTest.java    License: Apache License 2.0 6 votes vote down vote up
@Before
public void setup() throws IOException {
	rpc = new TestingRpcService();
	timerService = new TimerService<>(TestingUtils.defaultExecutor(), timeout.toMilliseconds());

	dummyBlobCacheService = new BlobCacheService(
		new Configuration(),
		new VoidBlobStore(),
		null);

	configuration = new Configuration();
	taskManagerConfiguration = TaskManagerConfiguration.fromConfiguration(configuration);

	taskManagerLocation = new LocalTaskManagerLocation();
	jobId = new JobID();

	testingFatalErrorHandler = new TestingFatalErrorHandler();

	haServices = new TestingHighAvailabilityServices();
	resourceManagerLeaderRetriever = new SettableLeaderRetrievalService();
	jobManagerLeaderRetriever = new SettableLeaderRetrievalService();
	haServices.setResourceManagerLeaderRetriever(resourceManagerLeaderRetriever);
	haServices.setJobMasterLeaderRetriever(jobId, jobManagerLeaderRetriever);

	nettyShuffleEnvironment = new NettyShuffleEnvironmentBuilder().build();
}
 
Example 8
@Test
public void createResourceManager_WithLessMemoryThanContainerizedHeapCutoffMin_ShouldSucceed() throws Exception {
	final StandaloneResourceManagerFactory resourceManagerFactory = StandaloneResourceManagerFactory.INSTANCE;

	final TestingRpcService rpcService = new TestingRpcService();
	try {
		final Configuration configuration = new Configuration();
		configuration.setString(TaskManagerOptions.TASK_MANAGER_HEAP_MEMORY, new MemorySize(128 * 1024 * 1024).toString());
		configuration.setInteger(ResourceManagerOptions.CONTAINERIZED_HEAP_CUTOFF_MIN, 600);

		final ResourceManager<ResourceID> ignored = resourceManagerFactory.createResourceManager(
			configuration,
			ResourceID.generate(),
			rpcService,
			new TestingHighAvailabilityServices(),
			new TestingHeartbeatServices(),
			NoOpMetricRegistry.INSTANCE,
			new TestingFatalErrorHandler(),
			new ClusterInformation("foobar", 1234),
			null,
			UnregisteredMetricGroups.createUnregisteredJobManagerMetricGroup());
	} finally {
		RpcUtils.terminateRpcService(rpcService, Time.seconds(10L));
	}
}
 
Example 9
Source Project: flink   Source File: ResourceManagerTaskExecutorTest.java    License: Apache License 2.0 6 votes vote down vote up
@Before
public void setup() throws Exception {
	rpcService = new TestingRpcService();

	createAndRegisterTaskExecutorGateway();
	taskExecutorResourceID = ResourceID.generate();
	resourceManagerResourceID = ResourceID.generate();
	testingFatalErrorHandler = new TestingFatalErrorHandler();
	TestingLeaderElectionService rmLeaderElectionService = new TestingLeaderElectionService();
	resourceManager = createAndStartResourceManager(rmLeaderElectionService, testingFatalErrorHandler);
	rmGateway = resourceManager.getSelfGateway(ResourceManagerGateway.class);
	wronglyFencedGateway = rpcService.connect(resourceManager.getAddress(), ResourceManagerId.generate(), ResourceManagerGateway.class)
		.get(TIMEOUT.toMilliseconds(), TimeUnit.MILLISECONDS);

	grantLeadership(rmLeaderElectionService).get(TIMEOUT.toMilliseconds(), TimeUnit.MILLISECONDS);
}
 
Example 10
Source Project: flink   Source File: ActiveResourceManagerFactoryTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Test which ensures that the {@link ActiveResourceManagerFactory} sets the correct managed
 * memory when creating a resource manager.
 */
@Test
public void createResourceManager_WithDefaultConfiguration_ShouldSetManagedMemory() throws Exception {
	final Configuration configuration = new Configuration();

	final TestingActiveResourceManagerFactory resourceManagerFactory = new TestingActiveResourceManagerFactory();

	final TestingRpcService rpcService = new TestingRpcService();

	try {
		final ResourceManager<ResourceID> ignored = resourceManagerFactory.createResourceManager(
			configuration,
			ResourceID.generate(),
			rpcService,
			new TestingHighAvailabilityServices(),
			new TestingHeartbeatServices(),
			NoOpMetricRegistry.INSTANCE,
			new TestingFatalErrorHandler(),
			new ClusterInformation("foobar", 1234),
			null,
			UnregisteredMetricGroups.createUnregisteredJobManagerMetricGroup());
	} finally {
		RpcUtils.terminateRpcService(rpcService, Time.seconds(10L));
	}
}
 
Example 11
Source Project: flink   Source File: DefaultDispatcherRunnerITCase.java    License: Apache License 2.0 6 votes vote down vote up
@Before
public void setup() {
	dispatcherRunnerFactory = DefaultDispatcherRunnerFactory.createSessionRunner(SessionDispatcherFactory.INSTANCE);
	jobGraph = createJobGraph();
	dispatcherLeaderElectionService = new TestingLeaderElectionService();
	fatalErrorHandler = new TestingFatalErrorHandler();
	jobGraphStore = TestingJobGraphStore.newBuilder().build();

	partialDispatcherServices = new PartialDispatcherServices(
		new Configuration(),
		new TestingHighAvailabilityServicesBuilder().build(),
		CompletableFuture::new,
		blobServerResource.getBlobServer(),
		new TestingHeartbeatServices(),
		UnregisteredMetricGroups::createUnregisteredJobManagerMetricGroup,
		new MemoryArchivedExecutionGraphStore(),
		fatalErrorHandler,
		VoidHistoryServerArchivist.INSTANCE,
		null);
}
 
Example 12
Source Project: flink   Source File: SessionDispatcherLeaderProcessTest.java    License: Apache License 2.0 6 votes vote down vote up
private void runOnAddedJobGraphTest(TestingDispatcherGateway dispatcherGateway, ThrowingConsumer<TestingFatalErrorHandler, Exception> verificationLogic) throws Exception {
	jobGraphStore = TestingJobGraphStore.newBuilder()
		.setInitialJobGraphs(Collections.singleton(JOB_GRAPH))
		.build();
	dispatcherServiceFactory = TestingDispatcherServiceFactory.newBuilder()
		.setCreateFunction((dispatcherId, jobGraphs, jobGraphWriter) -> {
			assertThat(jobGraphs, containsInAnyOrder(JOB_GRAPH));

			return TestingDispatcherGatewayService.newBuilder()
				.setDispatcherGateway(dispatcherGateway)
				.build();
		})
		.build();

	try (final SessionDispatcherLeaderProcess dispatcherLeaderProcess = createDispatcherLeaderProcess()) {
		dispatcherLeaderProcess.start();

		dispatcherLeaderProcess.getDispatcherGateway().get();

		dispatcherLeaderProcess.onAddedJobGraph(JOB_GRAPH.getJobID());

		verificationLogic.accept(fatalErrorHandler);
	}
}
 
Example 13
Source Project: flink   Source File: JobMasterTest.java    License: Apache License 2.0 6 votes vote down vote up
@Before
public void setup() throws IOException {
	configuration = new Configuration();
	haServices = new TestingHighAvailabilityServices();
	jobMasterId = JobMasterId.generate();
	jmResourceId = ResourceID.generate();

	testingFatalErrorHandler = new TestingFatalErrorHandler();

	haServices.setCheckpointRecoveryFactory(new StandaloneCheckpointRecoveryFactory());

	rmLeaderRetrievalService = new SettableLeaderRetrievalService(
		null,
		null);
	haServices.setResourceManagerLeaderRetriever(rmLeaderRetrievalService);

	configuration.setString(BlobServerOptions.STORAGE_DIRECTORY, temporaryFolder.newFolder().getAbsolutePath());
}
 
Example 14
Source Project: flink   Source File: TaskExecutorTest.java    License: Apache License 2.0 6 votes vote down vote up
@Before
public void setup() throws IOException {
	rpc = new TestingRpcService();

	dummyBlobCacheService = new BlobCacheService(
		new Configuration(),
		new VoidBlobStore(),
		null);

	configuration = new Configuration();

	unresolvedTaskManagerLocation = new LocalUnresolvedTaskManagerLocation();
	jobId = new JobID();

	testingFatalErrorHandler = new TestingFatalErrorHandler();

	haServices = new TestingHighAvailabilityServices();
	resourceManagerLeaderRetriever = new SettableLeaderRetrievalService();
	jobManagerLeaderRetriever = new SettableLeaderRetrievalService();
	haServices.setResourceManagerLeaderRetriever(resourceManagerLeaderRetriever);
	haServices.setJobMasterLeaderRetriever(jobId, jobManagerLeaderRetriever);

	nettyShuffleEnvironment = new NettyShuffleEnvironmentBuilder().build();
}
 
Example 15
Source Project: flink   Source File: ResourceManagerTaskExecutorTest.java    License: Apache License 2.0 6 votes vote down vote up
@Before
public void setup() throws Exception {
	rpcService = new TestingRpcService();

	createAndRegisterTaskExecutorGateway();
	taskExecutorResourceID = ResourceID.generate();
	resourceManagerResourceID = ResourceID.generate();
	testingFatalErrorHandler = new TestingFatalErrorHandler();
	TestingLeaderElectionService rmLeaderElectionService = new TestingLeaderElectionService();
	resourceManager = createAndStartResourceManager(rmLeaderElectionService, testingFatalErrorHandler);
	rmGateway = resourceManager.getSelfGateway(ResourceManagerGateway.class);
	wronglyFencedGateway = rpcService.connect(resourceManager.getAddress(), ResourceManagerId.generate(), ResourceManagerGateway.class)
		.get(TIMEOUT.toMilliseconds(), TimeUnit.MILLISECONDS);

	grantLeadership(rmLeaderElectionService).get(TIMEOUT.toMilliseconds(), TimeUnit.MILLISECONDS);
}
 
Example 16
Source Project: Flink-CEPplus   Source File: DispatcherTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
	final JobVertex testVertex = new JobVertex("testVertex");
	testVertex.setInvokableClass(NoOpInvokable.class);
	jobGraph = new JobGraph(TEST_JOB_ID, "testJob", testVertex);
	jobGraph.setAllowQueuedScheduling(true);

	fatalErrorHandler = new TestingFatalErrorHandler();
	heartbeatServices = new HeartbeatServices(1000L, 10000L);
	submittedJobGraphStore = new FaultySubmittedJobGraphStore();

	dispatcherLeaderElectionService = new TestingLeaderElectionService();
	jobMasterLeaderElectionService = new TestingLeaderElectionService();

	haServices = new TestingHighAvailabilityServices();
	haServices.setDispatcherLeaderElectionService(dispatcherLeaderElectionService);
	haServices.setSubmittedJobGraphStore(submittedJobGraphStore);
	haServices.setJobMasterLeaderElectionService(TEST_JOB_ID, jobMasterLeaderElectionService);
	haServices.setCheckpointRecoveryFactory(new StandaloneCheckpointRecoveryFactory());
	haServices.setResourceManagerLeaderRetriever(new SettableLeaderRetrievalService());
	runningJobsRegistry = haServices.getRunningJobsRegistry();

	configuration = new Configuration();

	configuration.setString(
		BlobServerOptions.STORAGE_DIRECTORY,
		temporaryFolder.newFolder().getAbsolutePath());

	createdJobManagerRunnerLatch = new CountDownLatch(2);
	blobServer = new BlobServer(configuration, new VoidBlobStore());
}
 
Example 17
Source Project: Flink-CEPplus   Source File: MiniDispatcherTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws Exception {
	dispatcherLeaderElectionService = new TestingLeaderElectionService();
	highAvailabilityServices = new TestingHighAvailabilityServices();
	testingFatalErrorHandler = new TestingFatalErrorHandler();

	highAvailabilityServices.setDispatcherLeaderElectionService(dispatcherLeaderElectionService);

	jobGraphFuture = new CompletableFuture<>();
	resultFuture = new CompletableFuture<>();

	testingJobManagerRunnerFactory = new TestingJobManagerRunnerFactory(jobGraphFuture, resultFuture, CompletableFuture.completedFuture(null));
}
 
Example 18
Source Project: Flink-CEPplus   Source File: JobManagerRunnerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
	leaderElectionService = new TestingLeaderElectionService();
	haServices = new TestingHighAvailabilityServices();
	haServices.setJobMasterLeaderElectionService(jobGraph.getJobID(), leaderElectionService);
	haServices.setResourceManagerLeaderRetriever(new SettableLeaderRetrievalService());
	haServices.setCheckpointRecoveryFactory(new StandaloneCheckpointRecoveryFactory());

	fatalErrorHandler = new TestingFatalErrorHandler();
}
 
Example 19
Source Project: Flink-CEPplus   Source File: ResourceManagerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws Exception {
	highAvailabilityServices = new TestingHighAvailabilityServices();
	resourceManagerLeaderElectionService = new TestingLeaderElectionService();
	highAvailabilityServices.setResourceManagerLeaderElectionService(resourceManagerLeaderElectionService);
	testingFatalErrorHandler = new TestingFatalErrorHandler();
	resourceManagerResourceId = ResourceID.generate();
}
 
Example 20
@Before
public void setup() throws Exception {
	rpcService = new TestingRpcService();

	jobId = new JobID();

	createAndRegisterJobMasterGateway();
	jobMasterResourceId = ResourceID.generate();

	jobMasterLeaderRetrievalService = new SettableLeaderRetrievalService(
		jobMasterGateway.getAddress(),
		jobMasterGateway.getFencingToken().toUUID());
	resourceManagerLeaderElectionService = new TestingLeaderElectionService();

	haServices = new TestingHighAvailabilityServicesBuilder()
		.setJobMasterLeaderRetrieverFunction(requestedJobId -> {
			if (requestedJobId.equals(jobId)) {
				return jobMasterLeaderRetrievalService;
			} else {
				throw new FlinkRuntimeException(String.format("Unknown job id %s", jobId));
			}
		})
		.setResourceManagerLeaderElectionService(resourceManagerLeaderElectionService)
		.build();

	testingFatalErrorHandler = new TestingFatalErrorHandler();

	resourceManager = createAndStartResourceManager();

	// wait until the leader election has been completed
	resourceManagerLeaderElectionService.isLeader(UUID.randomUUID()).get();

	resourceManagerGateway = resourceManager.getSelfGateway(ResourceManagerGateway.class);
}
 
Example 21
Source Project: flink   Source File: DispatcherTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
	final JobVertex testVertex = new JobVertex("testVertex");
	testVertex.setInvokableClass(NoOpInvokable.class);
	jobGraph = new JobGraph(TEST_JOB_ID, "testJob", testVertex);
	jobGraph.setAllowQueuedScheduling(true);

	fatalErrorHandler = new TestingFatalErrorHandler();
	heartbeatServices = new HeartbeatServices(1000L, 10000L);
	submittedJobGraphStore = new FaultySubmittedJobGraphStore();

	dispatcherLeaderElectionService = new TestingLeaderElectionService();
	jobMasterLeaderElectionService = new TestingLeaderElectionService();

	haServices = new TestingHighAvailabilityServices();
	haServices.setDispatcherLeaderElectionService(dispatcherLeaderElectionService);
	haServices.setSubmittedJobGraphStore(submittedJobGraphStore);
	haServices.setJobMasterLeaderElectionService(TEST_JOB_ID, jobMasterLeaderElectionService);
	haServices.setCheckpointRecoveryFactory(new StandaloneCheckpointRecoveryFactory());
	haServices.setResourceManagerLeaderRetriever(new SettableLeaderRetrievalService());
	runningJobsRegistry = haServices.getRunningJobsRegistry();

	configuration = new Configuration();

	configuration.setString(
		BlobServerOptions.STORAGE_DIRECTORY,
		temporaryFolder.newFolder().getAbsolutePath());

	createdJobManagerRunnerLatch = new CountDownLatch(2);
	blobServer = new BlobServer(configuration, new VoidBlobStore());
}
 
Example 22
Source Project: flink   Source File: MiniDispatcherTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws Exception {
	dispatcherLeaderElectionService = new TestingLeaderElectionService();
	highAvailabilityServices = new TestingHighAvailabilityServices();
	testingFatalErrorHandler = new TestingFatalErrorHandler();

	highAvailabilityServices.setDispatcherLeaderElectionService(dispatcherLeaderElectionService);

	jobGraphFuture = new CompletableFuture<>();
	resultFuture = new CompletableFuture<>();

	testingJobManagerRunnerFactory = new TestingJobManagerRunnerFactory(jobGraphFuture, resultFuture, CompletableFuture.completedFuture(null));
}
 
Example 23
Source Project: flink   Source File: JobManagerRunnerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
	leaderElectionService = new TestingLeaderElectionService();
	haServices = new TestingHighAvailabilityServices();
	haServices.setJobMasterLeaderElectionService(jobGraph.getJobID(), leaderElectionService);
	haServices.setResourceManagerLeaderRetriever(new SettableLeaderRetrievalService());
	haServices.setCheckpointRecoveryFactory(new StandaloneCheckpointRecoveryFactory());

	fatalErrorHandler = new TestingFatalErrorHandler();
}
 
Example 24
Source Project: flink   Source File: ResourceManagerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws Exception {
	highAvailabilityServices = new TestingHighAvailabilityServices();
	resourceManagerLeaderElectionService = new TestingLeaderElectionService();
	highAvailabilityServices.setResourceManagerLeaderElectionService(resourceManagerLeaderElectionService);
	testingFatalErrorHandler = new TestingFatalErrorHandler();
	resourceManagerResourceId = ResourceID.generate();
}
 
Example 25
Source Project: flink   Source File: ResourceManagerJobMasterTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws Exception {
	rpcService = new TestingRpcService();

	jobId = new JobID();

	createAndRegisterJobMasterGateway();
	jobMasterResourceId = ResourceID.generate();

	jobMasterLeaderRetrievalService = new SettableLeaderRetrievalService(
		jobMasterGateway.getAddress(),
		jobMasterGateway.getFencingToken().toUUID());
	resourceManagerLeaderElectionService = new TestingLeaderElectionService();

	haServices = new TestingHighAvailabilityServicesBuilder()
		.setJobMasterLeaderRetrieverFunction(requestedJobId -> {
			if (requestedJobId.equals(jobId)) {
				return jobMasterLeaderRetrievalService;
			} else {
				throw new FlinkRuntimeException(String.format("Unknown job id %s", jobId));
			}
		})
		.setResourceManagerLeaderElectionService(resourceManagerLeaderElectionService)
		.build();

	testingFatalErrorHandler = new TestingFatalErrorHandler();

	resourceManager = createAndStartResourceManager();

	// wait until the leader election has been completed
	resourceManagerLeaderElectionService.isLeader(UUID.randomUUID()).get();

	resourceManagerGateway = resourceManager.getSelfGateway(ResourceManagerGateway.class);
}
 
Example 26
Source Project: flink   Source File: YarnResourceManagerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws IOException {
	testingFatalErrorHandler = new TestingFatalErrorHandler();

	flinkConfig = new Configuration();
	flinkConfig.set(TaskManagerOptions.TOTAL_FLINK_MEMORY, MemorySize.parse("1g"));

	File root = folder.getRoot();
	File home = new File(root, "home");
	boolean created = home.mkdir();
	assertTrue(created);

	env = new HashMap<>();
	env.put(ENV_APP_ID, "foo");
	env.put(ENV_CLIENT_HOME_DIR, home.getAbsolutePath());
	env.put(ENV_CLIENT_SHIP_FILES, "");
	env.put(ENV_FLINK_CLASSPATH, "");
	env.put(ENV_HADOOP_USER_NAME, "foo");
	env.put(FLINK_DIST_JAR, new YarnLocalResourceDescriptor(
		"flink.jar",
		new Path("/tmp/flink.jar"),
		0,
		System.currentTimeMillis(),
		LocalResourceVisibility.APPLICATION).toString());
	env.put(ApplicationConstants.Environment.PWD.key(), home.getAbsolutePath());

	BootstrapTools.writeConfiguration(flinkConfig, new File(home.getAbsolutePath(), FLINK_CONF_FILENAME));
}
 
Example 27
@Before
public void setup() throws IOException {
	fatalErrorHandler = new TestingFatalErrorHandler();
	configuration = new Configuration();
	configuration.setString(HighAvailabilityOptions.HA_MODE, "zookeeper");
	configuration.setString(HighAvailabilityOptions.HA_ZOOKEEPER_QUORUM, zooKeeperResource.getConnectString());
	configuration.setString(HighAvailabilityOptions.HA_STORAGE_PATH, temporaryFolder.newFolder().getAbsolutePath());

	clusterHaStorageDir = new File(HighAvailabilityServicesUtils.getClusterHighAvailableStoragePath(configuration).toString());
	blobServer = new BlobServer(configuration, BlobUtils.createBlobStoreFromConfig(configuration));
}
 
Example 28
Source Project: flink   Source File: WebMonitorEndpointTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void cleansUpExpiredExecutionGraphs() throws Exception {
	final Configuration configuration = new Configuration();
	configuration.setString(RestOptions.ADDRESS, "localhost");
	configuration.setLong(WebOptions.REFRESH_INTERVAL, 5L);
	final ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
	final long timeout = 10000L;

	final OneShotLatch cleanupLatch = new OneShotLatch();
	final TestingExecutionGraphCache executionGraphCache = TestingExecutionGraphCache.newBuilder()
		.setCleanupRunnable(cleanupLatch::trigger)
		.build();
	try (final WebMonitorEndpoint<RestfulGateway> webMonitorEndpoint = new WebMonitorEndpoint<>(
		RestServerEndpointConfiguration.fromConfiguration(configuration),
		CompletableFuture::new,
		configuration,
		RestHandlerConfiguration.fromConfiguration(configuration),
		CompletableFuture::new,
		NoOpTransientBlobService.INSTANCE,
		executor,
		VoidMetricFetcher.INSTANCE,
		new TestingLeaderElectionService(),
		executionGraphCache,
		new TestingFatalErrorHandler())) {

		webMonitorEndpoint.start();

		// check that the cleanup will be triggered
		cleanupLatch.await(timeout, TimeUnit.MILLISECONDS);
	} finally {
		ExecutorUtils.gracefulShutdown(timeout, TimeUnit.MILLISECONDS, executor);
	}
}
 
Example 29
Source Project: flink   Source File: JobManagerRunnerImplTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
	leaderElectionService = new TestingLeaderElectionService();
	haServices = new TestingHighAvailabilityServices();
	haServices.setJobMasterLeaderElectionService(jobGraph.getJobID(), leaderElectionService);
	haServices.setResourceManagerLeaderRetriever(new SettableLeaderRetrievalService());
	haServices.setCheckpointRecoveryFactory(new StandaloneCheckpointRecoveryFactory());

	fatalErrorHandler = new TestingFatalErrorHandler();
}
 
Example 30
Source Project: flink   Source File: ResourceManagerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws Exception {
	highAvailabilityServices = new TestingHighAvailabilityServices();
	resourceManagerLeaderElectionService = new TestingLeaderElectionService();
	highAvailabilityServices.setResourceManagerLeaderElectionService(resourceManagerLeaderElectionService);
	testingFatalErrorHandler = new TestingFatalErrorHandler();
	resourceManagerResourceId = ResourceID.generate();
}