Search in sources :

Example 46 with MetricRegistry

use of org.apache.flink.runtime.metrics.MetricRegistry in project flink by apache.

the class OperatorGroupTest method testCreateQueryServiceMetricInfo.

@Test
public void testCreateQueryServiceMetricInfo() {
    JobID jid = new JobID();
    AbstractID vid = new AbstractID();
    AbstractID eid = new AbstractID();
    MetricRegistry registry = new MetricRegistry(MetricRegistryConfiguration.defaultMetricRegistryConfiguration());
    TaskManagerMetricGroup tm = new TaskManagerMetricGroup(registry, "host", "id");
    TaskManagerJobMetricGroup job = new TaskManagerJobMetricGroup(registry, tm, jid, "jobname");
    TaskMetricGroup task = new TaskMetricGroup(registry, job, vid, eid, "taskName", 4, 5);
    OperatorMetricGroup operator = new OperatorMetricGroup(registry, task, "operator");
    QueryScopeInfo.OperatorQueryScopeInfo info = operator.createQueryServiceMetricInfo(new DummyCharacterFilter());
    assertEquals("", info.scope);
    assertEquals(jid.toString(), info.jobID);
    assertEquals(vid.toString(), info.vertexID);
    assertEquals(4, info.subtaskIndex);
    assertEquals("operator", info.operatorName);
}
Also used : QueryScopeInfo(org.apache.flink.runtime.metrics.dump.QueryScopeInfo) MetricRegistry(org.apache.flink.runtime.metrics.MetricRegistry) DummyCharacterFilter(org.apache.flink.runtime.metrics.util.DummyCharacterFilter) AbstractID(org.apache.flink.util.AbstractID) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 47 with MetricRegistry

use of org.apache.flink.runtime.metrics.MetricRegistry in project flink by apache.

the class TaskMetricGroupTest method testGenerateScopeDefault.

// ------------------------------------------------------------------------
//  scope tests
// -----------------------------------------------------------------------
@Test
public void testGenerateScopeDefault() {
    MetricRegistry registry = new MetricRegistry(MetricRegistryConfiguration.defaultMetricRegistryConfiguration());
    AbstractID vertexId = new AbstractID();
    AbstractID executionId = new AbstractID();
    TaskManagerMetricGroup tmGroup = new TaskManagerMetricGroup(registry, "theHostName", "test-tm-id");
    TaskManagerJobMetricGroup jmGroup = new TaskManagerJobMetricGroup(registry, tmGroup, new JobID(), "myJobName");
    TaskMetricGroup taskGroup = new TaskMetricGroup(registry, jmGroup, vertexId, executionId, "aTaskName", 13, 2);
    assertArrayEquals(new String[] { "theHostName", "taskmanager", "test-tm-id", "myJobName", "aTaskName", "13" }, taskGroup.getScopeComponents());
    assertEquals("theHostName.taskmanager.test-tm-id.myJobName.aTaskName.13.name", taskGroup.getMetricIdentifier("name"));
    registry.shutdown();
}
Also used : MetricRegistry(org.apache.flink.runtime.metrics.MetricRegistry) AbstractID(org.apache.flink.util.AbstractID) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 48 with MetricRegistry

use of org.apache.flink.runtime.metrics.MetricRegistry in project flink by apache.

the class YarnFlinkApplicationMasterRunner method runApplicationMaster.

@Override
protected int runApplicationMaster(Configuration config) {
    try {
        // ---- (1) create common services
        // try to start the rpc service
        // using the port range definition from the config.
        final String amPortRange = config.getString(ConfigConstants.YARN_APPLICATION_MASTER_PORT, ConfigConstants.DEFAULT_YARN_JOB_MANAGER_PORT);
        synchronized (lock) {
            LOG.info("Starting High Availability Services");
            haServices = HighAvailabilityServicesUtils.createAvailableOrEmbeddedServices(config);
            heartbeatServices = HeartbeatServices.fromConfiguration(config);
            metricRegistry = new MetricRegistry(MetricRegistryConfiguration.fromConfiguration(config));
            commonRpcService = createRpcService(config, appMasterHostname, amPortRange);
            // ---- (2) init resource manager -------
            resourceManager = createResourceManager(config);
            // ---- (3) init job master parameters
            jobManagerRunner = createJobManagerRunner(config);
            // ---- (4) start the resource manager  and job manager runner:
            resourceManager.start();
            LOG.debug("YARN Flink Resource Manager started");
            jobManagerRunner.start();
            LOG.debug("Job Manager Runner started");
        // ---- (5) start the web monitor
        // TODO: add web monitor
        }
        // wait for resource manager to finish
        resourceManager.getTerminationFuture().get();
        // everything started, we can wait until all is done or the process is killed
        LOG.info("YARN Application Master finished");
    } catch (Throwable t) {
        // make sure that everything whatever ends up in the log
        LOG.error("YARN Application Master initialization failed", t);
        shutdown(ApplicationStatus.FAILED, t.getMessage());
        return INIT_ERROR_EXIT_CODE;
    }
    return 0;
}
Also used : MetricRegistry(org.apache.flink.runtime.metrics.MetricRegistry)

Example 49 with MetricRegistry

use of org.apache.flink.runtime.metrics.MetricRegistry in project flink by apache.

the class ResourceManagerHATest method testGrantAndRevokeLeadership.

@Test
public void testGrantAndRevokeLeadership() throws Exception {
    RpcService rpcService = new TestingSerialRpcService();
    TestingLeaderElectionService leaderElectionService = new TestingLeaderElectionService();
    TestingHighAvailabilityServices highAvailabilityServices = new TestingHighAvailabilityServices();
    highAvailabilityServices.setResourceManagerLeaderElectionService(leaderElectionService);
    ResourceManagerConfiguration resourceManagerConfiguration = new ResourceManagerConfiguration(Time.seconds(5L), Time.seconds(5L), Time.minutes(5L));
    SlotManagerFactory slotManagerFactory = new TestingSlotManagerFactory();
    MetricRegistry metricRegistry = mock(MetricRegistry.class);
    JobLeaderIdService jobLeaderIdService = new JobLeaderIdService(highAvailabilityServices, rpcService.getScheduledExecutor(), resourceManagerConfiguration.getJobTimeout());
    TestingFatalErrorHandler testingFatalErrorHandler = new TestingFatalErrorHandler();
    final ResourceManager resourceManager = new StandaloneResourceManager(rpcService, resourceManagerConfiguration, highAvailabilityServices, slotManagerFactory, metricRegistry, jobLeaderIdService, testingFatalErrorHandler);
    resourceManager.start();
    // before grant leadership, resourceManager's leaderId is null
    Assert.assertEquals(null, resourceManager.getLeaderSessionId());
    final UUID leaderId = UUID.randomUUID();
    leaderElectionService.isLeader(leaderId);
    // after grant leadership, resourceManager's leaderId has value
    Assert.assertEquals(leaderId, resourceManager.getLeaderSessionId());
    // then revoke leadership, resourceManager's leaderId is null again
    leaderElectionService.notLeader();
    Assert.assertEquals(null, resourceManager.getLeaderSessionId());
    if (testingFatalErrorHandler.hasExceptionOccurred()) {
        testingFatalErrorHandler.rethrowError();
    }
}
Also used : TestingFatalErrorHandler(org.apache.flink.runtime.util.TestingFatalErrorHandler) TestingLeaderElectionService(org.apache.flink.runtime.leaderelection.TestingLeaderElectionService) MetricRegistry(org.apache.flink.runtime.metrics.MetricRegistry) TestingHighAvailabilityServices(org.apache.flink.runtime.highavailability.TestingHighAvailabilityServices) SlotManagerFactory(org.apache.flink.runtime.resourcemanager.slotmanager.SlotManagerFactory) RpcService(org.apache.flink.runtime.rpc.RpcService) TestingSerialRpcService(org.apache.flink.runtime.rpc.TestingSerialRpcService) TestingSerialRpcService(org.apache.flink.runtime.rpc.TestingSerialRpcService) UUID(java.util.UUID) Test(org.junit.Test)

Example 50 with MetricRegistry

use of org.apache.flink.runtime.metrics.MetricRegistry in project flink by apache.

the class ResourceManagerJobMasterTest method createAndStartResourceManager.

private ResourceManager createAndStartResourceManager(TestingLeaderElectionService resourceManagerLeaderElectionService, JobID jobID, TestingLeaderRetrievalService jobMasterLeaderRetrievalService, FatalErrorHandler fatalErrorHandler) throws Exception {
    TestingHighAvailabilityServices highAvailabilityServices = new TestingHighAvailabilityServices();
    highAvailabilityServices.setResourceManagerLeaderElectionService(resourceManagerLeaderElectionService);
    highAvailabilityServices.setJobMasterLeaderRetriever(jobID, jobMasterLeaderRetrievalService);
    ResourceManagerConfiguration resourceManagerConfiguration = new ResourceManagerConfiguration(Time.seconds(5L), Time.seconds(5L), Time.minutes(5L));
    SlotManagerFactory slotManagerFactory = new TestingSlotManagerFactory();
    MetricRegistry metricRegistry = mock(MetricRegistry.class);
    JobLeaderIdService jobLeaderIdService = new JobLeaderIdService(highAvailabilityServices, rpcService.getScheduledExecutor(), resourceManagerConfiguration.getJobTimeout());
    ResourceManager resourceManager = new StandaloneResourceManager(rpcService, resourceManagerConfiguration, highAvailabilityServices, slotManagerFactory, metricRegistry, jobLeaderIdService, fatalErrorHandler);
    resourceManager.start();
    return resourceManager;
}
Also used : TestingHighAvailabilityServices(org.apache.flink.runtime.highavailability.TestingHighAvailabilityServices) SlotManagerFactory(org.apache.flink.runtime.resourcemanager.slotmanager.SlotManagerFactory) MetricRegistry(org.apache.flink.runtime.metrics.MetricRegistry)

Aggregations

MetricRegistry (org.apache.flink.runtime.metrics.MetricRegistry)53 Test (org.junit.Test)47 Configuration (org.apache.flink.configuration.Configuration)27 JobID (org.apache.flink.api.common.JobID)26 MetricRegistryConfiguration (org.apache.flink.runtime.metrics.MetricRegistryConfiguration)25 AbstractID (org.apache.flink.util.AbstractID)13 TaskManagerMetricGroup (org.apache.flink.runtime.metrics.groups.TaskManagerMetricGroup)12 MetricReporter (org.apache.flink.metrics.reporter.MetricReporter)7 QueryScopeInfo (org.apache.flink.runtime.metrics.dump.QueryScopeInfo)7 DummyCharacterFilter (org.apache.flink.runtime.metrics.util.DummyCharacterFilter)7 Counter (org.apache.flink.metrics.Counter)4 MetricGroup (org.apache.flink.metrics.MetricGroup)4 ResourceID (org.apache.flink.runtime.clusterframework.types.ResourceID)4 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)4 ActorRef (akka.actor.ActorRef)3 UUID (java.util.UUID)3 ObjectName (javax.management.ObjectName)3 Time (org.apache.flink.api.common.time.Time)3 Gauge (org.apache.flink.metrics.Gauge)3 SimpleCounter (org.apache.flink.metrics.SimpleCounter)3