Search in sources :

Example 1 with SlotManager

use of org.apache.flink.runtime.resourcemanager.slotmanager.SlotManager in project flink by apache.

the class ResourceManagerTest method testDisconnectJobManagerClearsRequirements.

@Test
public void testDisconnectJobManagerClearsRequirements() throws Exception {
    final TestingJobMasterGateway jobMasterGateway = new TestingJobMasterGatewayBuilder().setAddress(UUID.randomUUID().toString()).build();
    rpcService.registerGateway(jobMasterGateway.getAddress(), jobMasterGateway);
    final JobLeaderIdService jobLeaderIdService = TestingJobLeaderIdService.newBuilder().setGetLeaderIdFunction(jobId -> CompletableFuture.completedFuture(jobMasterGateway.getFencingToken())).build();
    final CompletableFuture<JobID> clearRequirementsFuture = new CompletableFuture<>();
    final SlotManager slotManager = new TestingSlotManagerBuilder().setClearRequirementsConsumer(clearRequirementsFuture::complete).createSlotManager();
    resourceManager = new ResourceManagerBuilder().withJobLeaderIdService(jobLeaderIdService).withSlotManager(slotManager).buildAndStart();
    final JobID jobId = JobID.generate();
    final ResourceManagerGateway resourceManagerGateway = resourceManager.getSelfGateway(ResourceManagerGateway.class);
    resourceManagerGateway.registerJobMaster(jobMasterGateway.getFencingToken(), ResourceID.generate(), jobMasterGateway.getAddress(), jobId, TIMEOUT).get();
    resourceManagerGateway.declareRequiredResources(jobMasterGateway.getFencingToken(), ResourceRequirements.create(jobId, jobMasterGateway.getAddress(), Collections.singleton(ResourceRequirement.create(ResourceProfile.UNKNOWN, 1))), TIMEOUT).get();
    resourceManagerGateway.disconnectJobManager(jobId, JobStatus.FINISHED, new FlinkException("Test exception"));
    assertThat(clearRequirementsFuture.get(5, TimeUnit.SECONDS), is(jobId));
}
Also used : RegistrationResponse(org.apache.flink.runtime.registration.RegistrationResponse) TestingRpcService(org.apache.flink.runtime.rpc.TestingRpcService) ResourceRequirement(org.apache.flink.runtime.slots.ResourceRequirement) TimeoutException(java.util.concurrent.TimeoutException) TaskExecutorGateway(org.apache.flink.runtime.taskexecutor.TaskExecutorGateway) SettableLeaderRetrievalService(org.apache.flink.runtime.leaderretrieval.SettableLeaderRetrievalService) TestingFatalErrorHandler(org.apache.flink.runtime.util.TestingFatalErrorHandler) After(org.junit.After) Matchers.nullValue(org.hamcrest.Matchers.nullValue) TestLogger(org.apache.flink.util.TestLogger) TestingJobMasterGatewayBuilder(org.apache.flink.runtime.jobmaster.utils.TestingJobMasterGatewayBuilder) Assert.fail(org.junit.Assert.fail) AfterClass(org.junit.AfterClass) UUID(java.util.UUID) ResourceProfile(org.apache.flink.runtime.clusterframework.types.ResourceProfile) HeartbeatServices(org.apache.flink.runtime.heartbeat.HeartbeatServices) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) TestingUtils(org.apache.flink.testutils.TestingUtils) Matchers.equalTo(org.hamcrest.Matchers.equalTo) Matchers.is(org.hamcrest.Matchers.is) Matchers.anyOf(org.hamcrest.Matchers.anyOf) Time(org.apache.flink.api.common.time.Time) OneShotLatch(org.apache.flink.core.testutils.OneShotLatch) FlinkException(org.apache.flink.util.FlinkException) BeforeClass(org.junit.BeforeClass) TaskExecutorMemoryConfiguration(org.apache.flink.runtime.taskexecutor.TaskExecutorMemoryConfiguration) CompletableFuture(java.util.concurrent.CompletableFuture) JobStatus(org.apache.flink.api.common.JobStatus) Function(java.util.function.Function) TestingJobMasterGateway(org.apache.flink.runtime.jobmaster.utils.TestingJobMasterGateway) DeclarativeSlotManagerBuilder(org.apache.flink.runtime.resourcemanager.slotmanager.DeclarativeSlotManagerBuilder) FutureUtils(org.apache.flink.util.concurrent.FutureUtils) LeaderRetrievalService(org.apache.flink.runtime.leaderretrieval.LeaderRetrievalService) ResourceManagerException(org.apache.flink.runtime.resourcemanager.exceptions.ResourceManagerException) NoOpResourceManagerPartitionTracker(org.apache.flink.runtime.io.network.partition.NoOpResourceManagerPartitionTracker) SlotManager(org.apache.flink.runtime.resourcemanager.slotmanager.SlotManager) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) ResourceID(org.apache.flink.runtime.clusterframework.types.ResourceID) ResourceRequirements(org.apache.flink.runtime.slots.ResourceRequirements) ThrowingConsumer(org.apache.flink.util.function.ThrowingConsumer) Before(org.junit.Before) Matchers.empty(org.hamcrest.Matchers.empty) TestingLeaderElectionService(org.apache.flink.runtime.leaderelection.TestingLeaderElectionService) HardwareDescription(org.apache.flink.runtime.instance.HardwareDescription) TaskManagerInfo(org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerInfo) Test(org.junit.Test) TaskExecutorThreadInfoGateway(org.apache.flink.runtime.taskexecutor.TaskExecutorThreadInfoGateway) RpcUtils(org.apache.flink.runtime.rpc.RpcUtils) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) JobID(org.apache.flink.api.common.JobID) UnregisteredMetricGroups(org.apache.flink.runtime.metrics.groups.UnregisteredMetricGroups) TestingTaskExecutorGatewayBuilder(org.apache.flink.runtime.taskexecutor.TestingTaskExecutorGatewayBuilder) TestingSlotManagerBuilder(org.apache.flink.runtime.resourcemanager.slotmanager.TestingSlotManagerBuilder) TestingHighAvailabilityServices(org.apache.flink.runtime.highavailability.TestingHighAvailabilityServices) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) RecipientUnreachableException(org.apache.flink.runtime.rpc.exceptions.RecipientUnreachableException) TestingJobMasterGateway(org.apache.flink.runtime.jobmaster.utils.TestingJobMasterGateway) CompletableFuture(java.util.concurrent.CompletableFuture) TestingJobMasterGatewayBuilder(org.apache.flink.runtime.jobmaster.utils.TestingJobMasterGatewayBuilder) SlotManager(org.apache.flink.runtime.resourcemanager.slotmanager.SlotManager) JobID(org.apache.flink.api.common.JobID) FlinkException(org.apache.flink.util.FlinkException) TestingSlotManagerBuilder(org.apache.flink.runtime.resourcemanager.slotmanager.TestingSlotManagerBuilder) Test(org.junit.Test)

Example 2 with SlotManager

use of org.apache.flink.runtime.resourcemanager.slotmanager.SlotManager in project flink by apache.

the class StandaloneResourceManagerTest method testStartupPeriod.

@Test
public void testStartupPeriod() throws Exception {
    final LinkedBlockingQueue<Boolean> setFailUnfulfillableRequestInvokes = new LinkedBlockingQueue<>();
    final SlotManager slotManager = new TestingSlotManagerBuilder().setSetFailUnfulfillableRequestConsumer(setFailUnfulfillableRequestInvokes::add).createSlotManager();
    final TestingStandaloneResourceManager rm = createResourceManager(Time.milliseconds(1L), slotManager);
    assertThat(setFailUnfulfillableRequestInvokes.take(), is(false));
    assertThat(setFailUnfulfillableRequestInvokes.take(), is(true));
    rm.close();
}
Also used : SlotManager(org.apache.flink.runtime.resourcemanager.slotmanager.SlotManager) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) TestingSlotManagerBuilder(org.apache.flink.runtime.resourcemanager.slotmanager.TestingSlotManagerBuilder) Test(org.junit.Test)

Example 3 with SlotManager

use of org.apache.flink.runtime.resourcemanager.slotmanager.SlotManager in project flink by apache.

the class StandaloneResourceManagerTest method testNoStartupPeriod.

@Test
public void testNoStartupPeriod() throws Exception {
    final LinkedBlockingQueue<Boolean> setFailUnfulfillableRequestInvokes = new LinkedBlockingQueue<>();
    final SlotManager slotManager = new TestingSlotManagerBuilder().setSetFailUnfulfillableRequestConsumer(setFailUnfulfillableRequestInvokes::add).createSlotManager();
    final TestingStandaloneResourceManager rm = createResourceManager(Time.milliseconds(-1L), slotManager);
    assertThat(setFailUnfulfillableRequestInvokes.take(), is(false));
    assertThat(setFailUnfulfillableRequestInvokes.poll(50L, TimeUnit.MILLISECONDS), is(nullValue()));
    rm.close();
}
Also used : SlotManager(org.apache.flink.runtime.resourcemanager.slotmanager.SlotManager) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) TestingSlotManagerBuilder(org.apache.flink.runtime.resourcemanager.slotmanager.TestingSlotManagerBuilder) Test(org.junit.Test)

Example 4 with SlotManager

use of org.apache.flink.runtime.resourcemanager.slotmanager.SlotManager in project flink by apache.

the class ResourceManagerRuntimeServices method fromConfiguration.

// -------------------- Static methods --------------------------------------
public static ResourceManagerRuntimeServices fromConfiguration(ResourceManagerRuntimeServicesConfiguration configuration, HighAvailabilityServices highAvailabilityServices, ScheduledExecutor scheduledExecutor, SlotManagerMetricGroup slotManagerMetricGroup) {
    final SlotManager slotManager = createSlotManager(configuration, scheduledExecutor, slotManagerMetricGroup);
    final JobLeaderIdService jobLeaderIdService = new DefaultJobLeaderIdService(highAvailabilityServices, scheduledExecutor, configuration.getJobTimeout());
    return new ResourceManagerRuntimeServices(slotManager, jobLeaderIdService);
}
Also used : FineGrainedSlotManager(org.apache.flink.runtime.resourcemanager.slotmanager.FineGrainedSlotManager) DeclarativeSlotManager(org.apache.flink.runtime.resourcemanager.slotmanager.DeclarativeSlotManager) SlotManager(org.apache.flink.runtime.resourcemanager.slotmanager.SlotManager)

Aggregations

SlotManager (org.apache.flink.runtime.resourcemanager.slotmanager.SlotManager)4 TestingSlotManagerBuilder (org.apache.flink.runtime.resourcemanager.slotmanager.TestingSlotManagerBuilder)3 Test (org.junit.Test)3 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)2 Collections (java.util.Collections)1 UUID (java.util.UUID)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 TimeUnit (java.util.concurrent.TimeUnit)1 TimeoutException (java.util.concurrent.TimeoutException)1 Consumer (java.util.function.Consumer)1 Function (java.util.function.Function)1 JobID (org.apache.flink.api.common.JobID)1 JobStatus (org.apache.flink.api.common.JobStatus)1 Time (org.apache.flink.api.common.time.Time)1 OneShotLatch (org.apache.flink.core.testutils.OneShotLatch)1 ResourceID (org.apache.flink.runtime.clusterframework.types.ResourceID)1 ResourceProfile (org.apache.flink.runtime.clusterframework.types.ResourceProfile)1 HeartbeatServices (org.apache.flink.runtime.heartbeat.HeartbeatServices)1 TestingHighAvailabilityServices (org.apache.flink.runtime.highavailability.TestingHighAvailabilityServices)1 HardwareDescription (org.apache.flink.runtime.instance.HardwareDescription)1