Search in sources :

Example 1 with TimerService

use of org.apache.flink.runtime.taskexecutor.slot.TimerService in project flink by apache.

the class TaskManagerServices method fromConfiguration.

// --------------------------------------------------------------------------------------------
//  Static factory methods for task manager services
// --------------------------------------------------------------------------------------------
/**
	 * Creates and returns the task manager services.
	 *
	 * @param resourceID resource ID of the task manager
	 * @param taskManagerServicesConfiguration task manager configuration
	 * @return task manager components
	 * @throws Exception
	 */
public static TaskManagerServices fromConfiguration(TaskManagerServicesConfiguration taskManagerServicesConfiguration, ResourceID resourceID) throws Exception {
    // pre-start checks
    checkTempDirs(taskManagerServicesConfiguration.getTmpDirPaths());
    final NetworkEnvironment network = createNetworkEnvironment(taskManagerServicesConfiguration);
    network.start();
    final TaskManagerLocation taskManagerLocation = new TaskManagerLocation(resourceID, taskManagerServicesConfiguration.getTaskManagerAddress(), network.getConnectionManager().getDataPort());
    // this call has to happen strictly after the network stack has been initialized
    final MemoryManager memoryManager = createMemoryManager(taskManagerServicesConfiguration);
    // start the I/O manager, it will create some temp directories.
    final IOManager ioManager = new IOManagerAsync(taskManagerServicesConfiguration.getTmpDirPaths());
    final MetricRegistry metricRegistry = new MetricRegistry(taskManagerServicesConfiguration.getMetricRegistryConfiguration());
    final TaskManagerMetricGroup taskManagerMetricGroup = new TaskManagerMetricGroup(metricRegistry, taskManagerLocation.getHostname(), taskManagerLocation.getResourceID().toString());
    // Initialize the TM metrics
    TaskExecutorMetricsInitializer.instantiateStatusMetrics(taskManagerMetricGroup, network);
    final BroadcastVariableManager broadcastVariableManager = new BroadcastVariableManager();
    final FileCache fileCache = new FileCache(taskManagerServicesConfiguration.getTmpDirPaths());
    final List<ResourceProfile> resourceProfiles = new ArrayList<>(taskManagerServicesConfiguration.getNumberOfSlots());
    for (int i = 0; i < taskManagerServicesConfiguration.getNumberOfSlots(); i++) {
        resourceProfiles.add(new ResourceProfile(1.0, 42));
    }
    final TimerService<AllocationID> timerService = new TimerService<>(new ScheduledThreadPoolExecutor(1), taskManagerServicesConfiguration.getTimerServiceShutdownTimeout());
    final TaskSlotTable taskSlotTable = new TaskSlotTable(resourceProfiles, timerService);
    final JobManagerTable jobManagerTable = new JobManagerTable();
    final JobLeaderService jobLeaderService = new JobLeaderService(taskManagerLocation);
    return new TaskManagerServices(taskManagerLocation, memoryManager, ioManager, network, metricRegistry, taskManagerMetricGroup, broadcastVariableManager, fileCache, taskSlotTable, jobManagerTable, jobLeaderService);
}
Also used : ResourceProfile(org.apache.flink.runtime.clusterframework.types.ResourceProfile) IOManager(org.apache.flink.runtime.io.disk.iomanager.IOManager) TaskManagerLocation(org.apache.flink.runtime.taskmanager.TaskManagerLocation) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) MetricRegistry(org.apache.flink.runtime.metrics.MetricRegistry) TaskManagerMetricGroup(org.apache.flink.runtime.metrics.groups.TaskManagerMetricGroup) AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) ArrayList(java.util.ArrayList) MemoryManager(org.apache.flink.runtime.memory.MemoryManager) TimerService(org.apache.flink.runtime.taskexecutor.slot.TimerService) FileCache(org.apache.flink.runtime.filecache.FileCache) IOManagerAsync(org.apache.flink.runtime.io.disk.iomanager.IOManagerAsync) TaskSlotTable(org.apache.flink.runtime.taskexecutor.slot.TaskSlotTable) BroadcastVariableManager(org.apache.flink.runtime.broadcast.BroadcastVariableManager) NetworkEnvironment(org.apache.flink.runtime.io.network.NetworkEnvironment)

Aggregations

ArrayList (java.util.ArrayList)1 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)1 BroadcastVariableManager (org.apache.flink.runtime.broadcast.BroadcastVariableManager)1 AllocationID (org.apache.flink.runtime.clusterframework.types.AllocationID)1 ResourceProfile (org.apache.flink.runtime.clusterframework.types.ResourceProfile)1 FileCache (org.apache.flink.runtime.filecache.FileCache)1 IOManager (org.apache.flink.runtime.io.disk.iomanager.IOManager)1 IOManagerAsync (org.apache.flink.runtime.io.disk.iomanager.IOManagerAsync)1 NetworkEnvironment (org.apache.flink.runtime.io.network.NetworkEnvironment)1 MemoryManager (org.apache.flink.runtime.memory.MemoryManager)1 MetricRegistry (org.apache.flink.runtime.metrics.MetricRegistry)1 TaskManagerMetricGroup (org.apache.flink.runtime.metrics.groups.TaskManagerMetricGroup)1 TaskSlotTable (org.apache.flink.runtime.taskexecutor.slot.TaskSlotTable)1 TimerService (org.apache.flink.runtime.taskexecutor.slot.TimerService)1 TaskManagerLocation (org.apache.flink.runtime.taskmanager.TaskManagerLocation)1