Search in sources :

Example 1 with RMTimelineCollectorManager

use of org.apache.hadoop.yarn.server.resourcemanager.timelineservice.RMTimelineCollectorManager in project hadoop by apache.

the class TestSystemMetricsPublisherForV2 method setup.

@BeforeClass
public static void setup() throws Exception {
    if (testRootDir.exists()) {
        //cleanup before hand
        FileContext.getLocalFSFileContext().delete(new Path(testRootDir.getAbsolutePath()), true);
    }
    RMContext rmContext = mock(RMContext.class);
    rmAppsMapInContext = new ConcurrentHashMap<ApplicationId, RMApp>();
    when(rmContext.getRMApps()).thenReturn(rmAppsMapInContext);
    rmTimelineCollectorManager = new RMTimelineCollectorManager(rmContext);
    when(rmContext.getRMTimelineCollectorManager()).thenReturn(rmTimelineCollectorManager);
    Configuration conf = getTimelineV2Conf();
    conf.setClass(YarnConfiguration.TIMELINE_SERVICE_WRITER_CLASS, FileSystemTimelineWriterImpl.class, TimelineWriter.class);
    rmTimelineCollectorManager.init(conf);
    rmTimelineCollectorManager.start();
    dispatcher.init(conf);
    dispatcher.start();
    metricsPublisher = new TimelineServiceV2Publisher(rmContext) {

        @Override
        protected Dispatcher getDispatcher() {
            return dispatcher;
        }
    };
    metricsPublisher.init(conf);
    metricsPublisher.start();
}
Also used : Path(org.apache.hadoop.fs.Path) RMContext(org.apache.hadoop.yarn.server.resourcemanager.RMContext) RMApp(org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp) RMTimelineCollectorManager(org.apache.hadoop.yarn.server.resourcemanager.timelineservice.RMTimelineCollectorManager) Configuration(org.apache.hadoop.conf.Configuration) YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) Dispatcher(org.apache.hadoop.yarn.event.Dispatcher) DrainDispatcher(org.apache.hadoop.yarn.event.DrainDispatcher) BeforeClass(org.junit.BeforeClass)

Example 2 with RMTimelineCollectorManager

use of org.apache.hadoop.yarn.server.resourcemanager.timelineservice.RMTimelineCollectorManager in project hadoop by apache.

the class ResourceManager method serviceInit.

@Override
protected void serviceInit(Configuration conf) throws Exception {
    this.conf = conf;
    this.rmContext = new RMContextImpl();
    rmContext.setResourceManager(this);
    this.configurationProvider = ConfigurationProviderFactory.getConfigurationProvider(conf);
    this.configurationProvider.init(this.conf);
    rmContext.setConfigurationProvider(configurationProvider);
    // load core-site.xml
    InputStream coreSiteXMLInputStream = this.configurationProvider.getConfigurationInputStream(this.conf, YarnConfiguration.CORE_SITE_CONFIGURATION_FILE);
    if (coreSiteXMLInputStream != null) {
        this.conf.addResource(coreSiteXMLInputStream, YarnConfiguration.CORE_SITE_CONFIGURATION_FILE);
    }
    // Do refreshUserToGroupsMappings with loaded core-site.xml
    Groups.getUserToGroupsMappingServiceWithLoadedConfiguration(this.conf).refresh();
    // Do refreshSuperUserGroupsConfiguration with loaded core-site.xml
    // Or use RM specific configurations to overwrite the common ones first
    // if they exist
    RMServerUtils.processRMProxyUsersConf(conf);
    ProxyUsers.refreshSuperUserGroupsConfiguration(this.conf);
    // load yarn-site.xml
    InputStream yarnSiteXMLInputStream = this.configurationProvider.getConfigurationInputStream(this.conf, YarnConfiguration.YARN_SITE_CONFIGURATION_FILE);
    if (yarnSiteXMLInputStream != null) {
        this.conf.addResource(yarnSiteXMLInputStream, YarnConfiguration.YARN_SITE_CONFIGURATION_FILE);
    }
    validateConfigs(this.conf);
    // Set HA configuration should be done before login
    this.rmContext.setHAEnabled(HAUtil.isHAEnabled(this.conf));
    if (this.rmContext.isHAEnabled()) {
        HAUtil.verifyAndSetConfiguration(this.conf);
    }
    // Set UGI and do login
    // If security is enabled, use login user
    // If security is not enabled, use current user
    this.rmLoginUGI = UserGroupInformation.getCurrentUser();
    try {
        doSecureLogin();
    } catch (IOException ie) {
        throw new YarnRuntimeException("Failed to login", ie);
    }
    // register the handlers for all AlwaysOn services using setupDispatcher().
    rmDispatcher = setupDispatcher();
    addIfService(rmDispatcher);
    rmContext.setDispatcher(rmDispatcher);
    // The order of services below should not be changed as services will be
    // started in same order
    // As elector service needs admin service to be initialized and started,
    // first we add admin service then elector service
    adminService = createAdminService();
    addService(adminService);
    rmContext.setRMAdminService(adminService);
    // elector must be added post adminservice
    if (this.rmContext.isHAEnabled()) {
        // initialize the leader elector.
        if (HAUtil.isAutomaticFailoverEnabled(conf) && HAUtil.isAutomaticFailoverEmbedded(conf)) {
            EmbeddedElector elector = createEmbeddedElector();
            addIfService(elector);
            rmContext.setLeaderElectorService(elector);
        }
    }
    rmContext.setYarnConfiguration(conf);
    createAndInitActiveServices(false);
    webAppAddress = WebAppUtils.getWebAppBindURL(this.conf, YarnConfiguration.RM_BIND_HOST, WebAppUtils.getRMWebAppURLWithoutScheme(this.conf));
    RMApplicationHistoryWriter rmApplicationHistoryWriter = createRMApplicationHistoryWriter();
    addService(rmApplicationHistoryWriter);
    rmContext.setRMApplicationHistoryWriter(rmApplicationHistoryWriter);
    // publisher can bind to it
    if (YarnConfiguration.timelineServiceV2Enabled(this.conf)) {
        RMTimelineCollectorManager timelineCollectorManager = createRMTimelineCollectorManager();
        addService(timelineCollectorManager);
        rmContext.setRMTimelineCollectorManager(timelineCollectorManager);
    }
    SystemMetricsPublisher systemMetricsPublisher = createSystemMetricsPublisher();
    addIfService(systemMetricsPublisher);
    rmContext.setSystemMetricsPublisher(systemMetricsPublisher);
    super.serviceInit(this.conf);
}
Also used : YarnRuntimeException(org.apache.hadoop.yarn.exceptions.YarnRuntimeException) RMTimelineCollectorManager(org.apache.hadoop.yarn.server.resourcemanager.timelineservice.RMTimelineCollectorManager) SystemMetricsPublisher(org.apache.hadoop.yarn.server.resourcemanager.metrics.SystemMetricsPublisher) InputStream(java.io.InputStream) RMApplicationHistoryWriter(org.apache.hadoop.yarn.server.resourcemanager.ahs.RMApplicationHistoryWriter) IOException(java.io.IOException)

Aggregations

RMTimelineCollectorManager (org.apache.hadoop.yarn.server.resourcemanager.timelineservice.RMTimelineCollectorManager)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Configuration (org.apache.hadoop.conf.Configuration)1 Path (org.apache.hadoop.fs.Path)1 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)1 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)1 Dispatcher (org.apache.hadoop.yarn.event.Dispatcher)1 DrainDispatcher (org.apache.hadoop.yarn.event.DrainDispatcher)1 YarnRuntimeException (org.apache.hadoop.yarn.exceptions.YarnRuntimeException)1 RMContext (org.apache.hadoop.yarn.server.resourcemanager.RMContext)1 RMApplicationHistoryWriter (org.apache.hadoop.yarn.server.resourcemanager.ahs.RMApplicationHistoryWriter)1 SystemMetricsPublisher (org.apache.hadoop.yarn.server.resourcemanager.metrics.SystemMetricsPublisher)1 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)1 BeforeClass (org.junit.BeforeClass)1