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);
}
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();
}
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;
}
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();
}
}
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;
}
Aggregations