Search in sources :

Example 1 with TaskManagerServicesConfiguration

use of org.apache.flink.runtime.taskexecutor.TaskManagerServicesConfiguration in project flink by apache.

the class TaskManagerMetricsTest method testMetricRegistryLifeCycle.

/**
	 * Tests the metric registry life cycle on JobManager re-connects.
	 */
@Test
public void testMetricRegistryLifeCycle() throws Exception {
    ActorSystem actorSystem = null;
    try {
        actorSystem = AkkaUtils.createLocalActorSystem(new Configuration());
        // ================================================================
        // Start JobManager
        // ================================================================
        final ActorRef jobManager = JobManager.startJobManagerActors(new Configuration(), actorSystem, TestingUtils.defaultExecutor(), TestingUtils.defaultExecutor(), JobManager.class, MemoryArchivist.class)._1();
        LeaderRetrievalService leaderRetrievalService = new StandaloneLeaderRetrievalService(jobManager.path().toString());
        // ================================================================
        // Start TaskManager
        // ================================================================
        final Configuration config = new Configuration();
        final ResourceID tmResourceID = ResourceID.generate();
        TaskManagerServicesConfiguration taskManagerServicesConfiguration = TaskManagerServicesConfiguration.fromConfiguration(config, InetAddress.getLocalHost(), false);
        TaskManagerConfiguration taskManagerConfiguration = TaskManagerConfiguration.fromConfiguration(config);
        TaskManagerServices taskManagerServices = TaskManagerServices.fromConfiguration(taskManagerServicesConfiguration, tmResourceID);
        final MetricRegistry tmRegistry = taskManagerServices.getMetricRegistry();
        // create the task manager
        final Props tmProps = TaskManager.getTaskManagerProps(TaskManager.class, taskManagerConfiguration, tmResourceID, taskManagerServices.getTaskManagerLocation(), taskManagerServices.getMemoryManager(), taskManagerServices.getIOManager(), taskManagerServices.getNetworkEnvironment(), leaderRetrievalService, tmRegistry);
        final ActorRef taskManager = actorSystem.actorOf(tmProps);
        new JavaTestKit(actorSystem) {

            {
                new Within(new FiniteDuration(5000, TimeUnit.SECONDS)) {

                    @Override
                    protected void run() {
                        taskManager.tell(TaskManagerMessages.getNotifyWhenRegisteredAtJobManagerMessage(), getTestActor());
                        // wait for the TM to be registered
                        expectMsgEquals(TaskManagerMessages.getRegisteredAtJobManagerMessage());
                        // trigger re-registration of TM; this should include a disconnect from the current JM
                        taskManager.tell(new TaskManagerMessages.JobManagerLeaderAddress(jobManager.path().toString(), null), jobManager);
                        // wait for re-registration to be completed
                        taskManager.tell(TaskManagerMessages.getNotifyWhenRegisteredAtJobManagerMessage(), getTestActor());
                        expectMsgEquals(TaskManagerMessages.getRegisteredAtJobManagerMessage());
                    }
                };
            }
        };
        // verify that the registry was not shutdown due to the disconnect
        Assert.assertFalse(tmRegistry.isShutdown());
        // shut down the actors and the actor system
        actorSystem.shutdown();
        actorSystem.awaitTermination();
    } finally {
        if (actorSystem != null) {
            actorSystem.shutdown();
        }
    }
}
Also used : ActorSystem(akka.actor.ActorSystem) TaskManagerConfiguration(org.apache.flink.runtime.taskexecutor.TaskManagerConfiguration) MemoryArchivist(org.apache.flink.runtime.jobmanager.MemoryArchivist) Configuration(org.apache.flink.configuration.Configuration) TaskManagerConfiguration(org.apache.flink.runtime.taskexecutor.TaskManagerConfiguration) TaskManagerServicesConfiguration(org.apache.flink.runtime.taskexecutor.TaskManagerServicesConfiguration) ActorRef(akka.actor.ActorRef) TaskManagerServices(org.apache.flink.runtime.taskexecutor.TaskManagerServices) FiniteDuration(scala.concurrent.duration.FiniteDuration) JobManager(org.apache.flink.runtime.jobmanager.JobManager) Props(akka.actor.Props) TaskManagerMessages(org.apache.flink.runtime.messages.TaskManagerMessages) ResourceID(org.apache.flink.runtime.clusterframework.types.ResourceID) LeaderRetrievalService(org.apache.flink.runtime.leaderretrieval.LeaderRetrievalService) StandaloneLeaderRetrievalService(org.apache.flink.runtime.leaderretrieval.StandaloneLeaderRetrievalService) StandaloneLeaderRetrievalService(org.apache.flink.runtime.leaderretrieval.StandaloneLeaderRetrievalService) TaskManagerServicesConfiguration(org.apache.flink.runtime.taskexecutor.TaskManagerServicesConfiguration) JavaTestKit(akka.testkit.JavaTestKit) Test(org.junit.Test)

Example 2 with TaskManagerServicesConfiguration

use of org.apache.flink.runtime.taskexecutor.TaskManagerServicesConfiguration in project flink by apache.

the class TaskManagerTest method testTaskManagerServicesConfiguration.

@Test
public void testTaskManagerServicesConfiguration() throws Exception {
    // set some non-default values
    final Configuration config = new Configuration();
    config.setInteger(TaskManagerOptions.NETWORK_REQUEST_BACKOFF_INITIAL, 100);
    config.setInteger(TaskManagerOptions.NETWORK_REQUEST_BACKOFF_MAX, 200);
    config.setInteger(TaskManagerOptions.NETWORK_BUFFERS_PER_CHANNEL, 10);
    config.setInteger(TaskManagerOptions.NETWORK_EXTRA_BUFFERS_PER_GATE, 100);
    TaskManagerServicesConfiguration tmConfig = TaskManagerServicesConfiguration.fromConfiguration(config, InetAddress.getLoopbackAddress(), true);
    assertEquals(tmConfig.getNetworkConfig().partitionRequestInitialBackoff(), 100);
    assertEquals(tmConfig.getNetworkConfig().partitionRequestMaxBackoff(), 200);
    assertEquals(tmConfig.getNetworkConfig().networkBuffersPerChannel(), 10);
    assertEquals(tmConfig.getNetworkConfig().extraNetworkBuffersPerGate(), 100);
}
Also used : TaskManagerServicesConfiguration(org.apache.flink.runtime.taskexecutor.TaskManagerServicesConfiguration) Configuration(org.apache.flink.configuration.Configuration) TaskManagerServicesConfiguration(org.apache.flink.runtime.taskexecutor.TaskManagerServicesConfiguration) Test(org.junit.Test)

Example 3 with TaskManagerServicesConfiguration

use of org.apache.flink.runtime.taskexecutor.TaskManagerServicesConfiguration in project flink by apache.

the class TaskExecutorLocalStateStoresManagerTest method testCreationFromConfigDefault.

/**
 * This tests that the creation of {@link TaskManagerServices} correctly falls back to the first
 * tmp directory of the IOManager as default for the local state root directory.
 */
@Test
public void testCreationFromConfigDefault() throws Exception {
    final Configuration config = new Configuration();
    final WorkingDirectory workingDirectory = WORKING_DIRECTORY_RESOURCE.createNewWorkingDirectory();
    TaskManagerServicesConfiguration taskManagerServicesConfiguration = createTaskManagerServiceConfiguration(config, workingDirectory);
    TaskManagerServices taskManagerServices = createTaskManagerServices(taskManagerServicesConfiguration, workingDirectory);
    try {
        TaskExecutorLocalStateStoresManager taskStateManager = taskManagerServices.getTaskManagerStateStore();
        File[] localStateRootDirectories = taskStateManager.getLocalStateRootDirectories();
        for (int i = 0; i < localStateRootDirectories.length; ++i) {
            Assert.assertEquals(workingDirectory.getLocalStateDirectory(), localStateRootDirectories[i]);
        }
        Assert.assertFalse(taskStateManager.isLocalRecoveryEnabled());
    } finally {
        taskManagerServices.shutDown();
    }
}
Also used : WorkingDirectory(org.apache.flink.runtime.entrypoint.WorkingDirectory) Configuration(org.apache.flink.configuration.Configuration) TaskManagerServicesConfiguration(org.apache.flink.runtime.taskexecutor.TaskManagerServicesConfiguration) TaskManagerServices(org.apache.flink.runtime.taskexecutor.TaskManagerServices) TaskManagerServicesConfiguration(org.apache.flink.runtime.taskexecutor.TaskManagerServicesConfiguration) File(java.io.File) Test(org.junit.Test)

Aggregations

Configuration (org.apache.flink.configuration.Configuration)3 TaskManagerServicesConfiguration (org.apache.flink.runtime.taskexecutor.TaskManagerServicesConfiguration)3 Test (org.junit.Test)3 TaskManagerServices (org.apache.flink.runtime.taskexecutor.TaskManagerServices)2 ActorRef (akka.actor.ActorRef)1 ActorSystem (akka.actor.ActorSystem)1 Props (akka.actor.Props)1 JavaTestKit (akka.testkit.JavaTestKit)1 File (java.io.File)1 ResourceID (org.apache.flink.runtime.clusterframework.types.ResourceID)1 WorkingDirectory (org.apache.flink.runtime.entrypoint.WorkingDirectory)1 JobManager (org.apache.flink.runtime.jobmanager.JobManager)1 MemoryArchivist (org.apache.flink.runtime.jobmanager.MemoryArchivist)1 LeaderRetrievalService (org.apache.flink.runtime.leaderretrieval.LeaderRetrievalService)1 StandaloneLeaderRetrievalService (org.apache.flink.runtime.leaderretrieval.StandaloneLeaderRetrievalService)1 TaskManagerMessages (org.apache.flink.runtime.messages.TaskManagerMessages)1 TaskManagerConfiguration (org.apache.flink.runtime.taskexecutor.TaskManagerConfiguration)1 FiniteDuration (scala.concurrent.duration.FiniteDuration)1