org.apache.flink.util.AbstractID Java Examples
The following examples show how to use
org.apache.flink.util.AbstractID.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PrometheusPushGatewayReporter.java From Flink-CEPplus with Apache License 2.0 | 7 votes |
@Override public void open(MetricConfig config) { super.open(config); String host = config.getString(HOST.key(), HOST.defaultValue()); int port = config.getInteger(PORT.key(), PORT.defaultValue()); String configuredJobName = config.getString(JOB_NAME.key(), JOB_NAME.defaultValue()); boolean randomSuffix = config.getBoolean(RANDOM_JOB_NAME_SUFFIX.key(), RANDOM_JOB_NAME_SUFFIX.defaultValue()); deleteOnShutdown = config.getBoolean(DELETE_ON_SHUTDOWN.key(), DELETE_ON_SHUTDOWN.defaultValue()); if (host == null || host.isEmpty() || port < 1) { throw new IllegalArgumentException("Invalid host/port configuration. Host: " + host + " Port: " + port); } if (randomSuffix) { this.jobName = configuredJobName + new AbstractID(); } else { this.jobName = configuredJobName; } pushGateway = new PushGateway(host + ':' + port); log.info("Configured PrometheusPushGatewayReporter with {host:{}, port:{}, jobName: {}, randomJobNameSuffix:{}, deleteOnShutdown:{}}", host, port, jobName, randomSuffix, deleteOnShutdown); }
Example #2
Source File: SlotSharingManager.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Allocates a MultiTaskSlot and registers it under the given groupId at * this MultiTaskSlot. * * @param slotRequestId of the new multi task slot * @param groupId under which the new multi task slot is registered * @return the newly allocated MultiTaskSlot */ MultiTaskSlot allocateMultiTaskSlot(SlotRequestId slotRequestId, AbstractID groupId) { Preconditions.checkState(!super.contains(groupId)); LOG.debug("Create nested multi task slot [{}] in parent multi task slot [{}] for group [{}].", slotRequestId, getSlotRequestId(), groupId); final MultiTaskSlot inner = new MultiTaskSlot( slotRequestId, groupId, this); children.put(groupId, inner); // register the newly allocated slot also at the SlotSharingManager allTaskSlots.put(slotRequestId, inner); return inner; }
Example #3
Source File: TaskMetricGroupTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testGenerateScopeWilcard() throws Exception { Configuration cfg = new Configuration(); cfg.setString(MetricOptions.SCOPE_NAMING_TASK, "*.<task_attempt_id>.<subtask_index>"); MetricRegistryImpl registry = new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(cfg)); 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, new JobVertexID(), executionId, "aTaskName", 13, 1); assertArrayEquals( new String[]{"theHostName", "taskmanager", "test-tm-id", "myJobName", executionId.toString(), "13"}, taskGroup.getScopeComponents()); assertEquals( "theHostName.taskmanager.test-tm-id.myJobName." + executionId + ".13.name", taskGroup.getMetricIdentifier("name")); registry.shutdown().get(); }
Example #4
Source File: OperatorGroupTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testCreateQueryServiceMetricInfo() { JobID jid = new JobID(); JobVertexID vid = new JobVertexID(); AbstractID eid = new AbstractID(); OperatorID oid = new OperatorID(); 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, oid, "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); }
Example #5
Source File: OperatorGroupTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testGenerateScopeDefault() throws Exception { TaskManagerMetricGroup tmGroup = new TaskManagerMetricGroup(registry, "theHostName", "test-tm-id"); TaskManagerJobMetricGroup jmGroup = new TaskManagerJobMetricGroup(registry, tmGroup, new JobID(), "myJobName"); TaskMetricGroup taskGroup = new TaskMetricGroup( registry, jmGroup, new JobVertexID(), new AbstractID(), "aTaskName", 11, 0); OperatorMetricGroup opGroup = new OperatorMetricGroup(registry, taskGroup, new OperatorID(), "myOpName"); assertArrayEquals( new String[] { "theHostName", "taskmanager", "test-tm-id", "myJobName", "myOpName", "11" }, opGroup.getScopeComponents()); assertEquals( "theHostName.taskmanager.test-tm-id.myJobName.myOpName.11.name", opGroup.getMetricIdentifier("name")); }
Example #6
Source File: TaskScopeFormat.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
public String[] formatScope( TaskManagerJobMetricGroup parent, AbstractID vertexId, AbstractID attemptId, String taskName, int subtask, int attemptNumber) { final String[] template = copyTemplate(); final String[] values = { parent.parent().hostname(), parent.parent().taskManagerId(), valueOrNull(parent.jobId()), valueOrNull(parent.jobName()), valueOrNull(vertexId), valueOrNull(attemptId), valueOrNull(taskName), String.valueOf(subtask), String.valueOf(attemptNumber) }; return bindVariables(template, values); }
Example #7
Source File: OperatorGroupTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testGenerateScopeDefault() throws Exception { TaskManagerMetricGroup tmGroup = new TaskManagerMetricGroup(registry, "theHostName", "test-tm-id"); TaskManagerJobMetricGroup jmGroup = new TaskManagerJobMetricGroup(registry, tmGroup, new JobID(), "myJobName"); TaskMetricGroup taskGroup = new TaskMetricGroup( registry, jmGroup, new JobVertexID(), new AbstractID(), "aTaskName", 11, 0); OperatorMetricGroup opGroup = new OperatorMetricGroup(registry, taskGroup, new OperatorID(), "myOpName"); assertArrayEquals( new String[] { "theHostName", "taskmanager", "test-tm-id", "myJobName", "myOpName", "11" }, opGroup.getScopeComponents()); assertEquals( "theHostName.taskmanager.test-tm-id.myJobName.myOpName.11.name", opGroup.getMetricIdentifier("name")); }
Example #8
Source File: TaskManagerJobMetricGroup.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
public void removeTaskMetricGroup(AbstractID executionId) { checkNotNull(executionId); boolean removeFromParent = false; synchronized (this) { if (!isClosed() && tasks.remove(executionId) != null && tasks.isEmpty()) { // this call removed the last task. close this group. removeFromParent = true; close(); } } // IMPORTANT: removing from the parent must not happen while holding the this group's lock, // because it would violate the "first parent then subgroup" lock acquisition order if (removeFromParent) { parent.removeJobMetricsGroup(jobId, this); } }
Example #9
Source File: TaskMetricGroupTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testOperatorNameTruncation() throws Exception { Configuration cfg = new Configuration(); cfg.setString(MetricOptions.SCOPE_NAMING_OPERATOR, ScopeFormat.SCOPE_OPERATOR_NAME); MetricRegistryImpl registry = new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(cfg)); TaskManagerMetricGroup tm = new TaskManagerMetricGroup(registry, "host", "id"); TaskManagerJobMetricGroup job = new TaskManagerJobMetricGroup(registry, tm, new JobID(), "jobname"); TaskMetricGroup taskMetricGroup = new TaskMetricGroup(registry, job, new JobVertexID(), new AbstractID(), "task", 0, 0); String originalName = new String(new char[100]).replace("\0", "-"); OperatorMetricGroup operatorMetricGroup = taskMetricGroup.getOrAddOperator(originalName); String storedName = operatorMetricGroup.getScopeComponents()[0]; Assert.assertEquals(TaskMetricGroup.METRICS_OPERATOR_NAME_MAX_LENGTH, storedName.length()); Assert.assertEquals(originalName.substring(0, TaskMetricGroup.METRICS_OPERATOR_NAME_MAX_LENGTH), storedName); registry.shutdown().get(); }
Example #10
Source File: TaskMetricGroupTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testTaskMetricGroupCleanup() throws Exception { CountingMetricRegistry registry = new CountingMetricRegistry(new Configuration()); TaskManagerMetricGroup taskManagerMetricGroup = new TaskManagerMetricGroup(registry, "localhost", "0"); TaskManagerJobMetricGroup taskManagerJobMetricGroup = new TaskManagerJobMetricGroup(registry, taskManagerMetricGroup, new JobID(), "job"); TaskMetricGroup taskMetricGroup = new TaskMetricGroup(registry, taskManagerJobMetricGroup, new JobVertexID(), new AbstractID(), "task", 0, 0); // the io metric should have registered predefined metrics assertTrue(registry.getNumberRegisteredMetrics() > 0); taskMetricGroup.close(); // now all registered metrics should have been unregistered assertEquals(0, registry.getNumberRegisteredMetrics()); registry.shutdown().get(); }
Example #11
Source File: SlotSharingManager.java From flink with Apache License 2.0 | 6 votes |
private SingleTaskSlot( SlotRequestId slotRequestId, ResourceProfile resourceProfile, AbstractID groupId, MultiTaskSlot parent, Locality locality) { super(slotRequestId, groupId); this.resourceProfile = Preconditions.checkNotNull(resourceProfile); this.parent = Preconditions.checkNotNull(parent); Preconditions.checkNotNull(locality); singleLogicalSlotFuture = parent.getSlotContextFuture() .thenApply( (SlotContext slotContext) -> { LOG.trace("Fulfill single task slot [{}] with slot [{}].", slotRequestId, slotContext.getAllocationId()); return new SingleLogicalSlot( slotRequestId, slotContext, slotSharingGroupId, locality, slotOwner); }); }
Example #12
Source File: TaskScopeFormat.java From flink with Apache License 2.0 | 6 votes |
public String[] formatScope( TaskManagerJobMetricGroup parent, AbstractID vertexId, AbstractID attemptId, String taskName, int subtask, int attemptNumber) { final String[] template = copyTemplate(); final String[] values = { parent.parent().hostname(), parent.parent().taskManagerId(), valueOrNull(parent.jobId()), valueOrNull(parent.jobName()), valueOrNull(vertexId), valueOrNull(attemptId), valueOrNull(taskName), String.valueOf(subtask), String.valueOf(attemptNumber) }; return bindVariables(template, values); }
Example #13
Source File: TaskMetricGroup.java From flink with Apache License 2.0 | 6 votes |
public TaskMetricGroup( MetricRegistry registry, TaskManagerJobMetricGroup parent, @Nullable JobVertexID vertexId, AbstractID executionId, @Nullable String taskName, int subtaskIndex, int attemptNumber) { super(registry, registry.getScopeFormats().getTaskFormat().formatScope( checkNotNull(parent), vertexId, checkNotNull(executionId), taskName, subtaskIndex, attemptNumber), parent); this.executionId = checkNotNull(executionId); this.vertexId = vertexId; this.taskName = taskName; this.subtaskIndex = subtaskIndex; this.attemptNumber = attemptNumber; this.ioMetrics = new TaskIOMetricGroup(this); }
Example #14
Source File: SlotSharingManager.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
private SingleTaskSlot( SlotRequestId slotRequestId, AbstractID groupId, MultiTaskSlot parent, Locality locality) { super(slotRequestId, groupId); this.parent = Preconditions.checkNotNull(parent); Preconditions.checkNotNull(locality); singleLogicalSlotFuture = parent.getSlotContextFuture() .thenApply( (SlotContext slotContext) -> { LOG.trace("Fulfill single task slot [{}] with slot [{}].", slotRequestId, slotContext.getAllocationId()); return new SingleLogicalSlot( slotRequestId, slotContext, slotSharingGroupId, locality, slotOwner); }); }
Example #15
Source File: SimpleSlot.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Creates a new simple slot that belongs to the given shared slot and * is identified by the given ID. * * @param owner The component from which this slot is allocated. * @param location The location info of the TaskManager where the slot was allocated from * @param slotNumber The number of the simple slot in its parent shared slot. * @param taskManagerGateway to communicate with the associated task manager. * @param parent The parent shared slot. * @param groupID The ID that identifies the group that the slot belongs to. */ public SimpleSlot( SlotOwner owner, TaskManagerLocation location, int slotNumber, TaskManagerGateway taskManagerGateway, @Nullable SharedSlot parent, @Nullable AbstractID groupID) { super( parent != null ? parent.getSlotContext() : new SimpleSlotContext( NO_ALLOCATION_ID, location, slotNumber, taskManagerGateway), owner, slotNumber, parent, groupID); }
Example #16
Source File: Slot.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Base constructor for slots. * * <p>This is the old way of constructing slots by the legacy code * * @param owner The component from which this slot is allocated. * @param location The location info of the TaskManager where the slot was allocated from * @param slotNumber The number of this slot. * @param taskManagerGateway The actor gateway to communicate with the TaskManager * @param parent The parent slot that contains this slot. May be null, if this slot is the root. * @param groupID The ID that identifies the task group for which this slot is allocated. May be null * if the slot does not belong to any task group. */ protected Slot( SlotOwner owner, TaskManagerLocation location, int slotNumber, TaskManagerGateway taskManagerGateway, @Nullable SharedSlot parent, @Nullable AbstractID groupID) { checkArgument(slotNumber >= 0); // create a simple slot context this.slotContext = new SimpleSlotContext( NO_ALLOCATION_ID, location, slotNumber, taskManagerGateway); this.owner = checkNotNull(owner); this.parent = parent; // may be null this.groupID = groupID; // may be null this.slotNumber = slotNumber; }
Example #17
Source File: TaskMetricGroupTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testOperatorNameTruncation() throws Exception { Configuration cfg = new Configuration(); cfg.setString(MetricOptions.SCOPE_NAMING_OPERATOR, ScopeFormat.SCOPE_OPERATOR_NAME); MetricRegistryImpl registry = new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(cfg)); TaskManagerMetricGroup tm = new TaskManagerMetricGroup(registry, "host", "id"); TaskManagerJobMetricGroup job = new TaskManagerJobMetricGroup(registry, tm, new JobID(), "jobname"); TaskMetricGroup taskMetricGroup = new TaskMetricGroup(registry, job, new JobVertexID(), new AbstractID(), "task", 0, 0); String originalName = new String(new char[100]).replace("\0", "-"); OperatorMetricGroup operatorMetricGroup = taskMetricGroup.getOrAddOperator(originalName); String storedName = operatorMetricGroup.getScopeComponents()[0]; Assert.assertEquals(TaskMetricGroup.METRICS_OPERATOR_NAME_MAX_LENGTH, storedName.length()); Assert.assertEquals(originalName.substring(0, TaskMetricGroup.METRICS_OPERATOR_NAME_MAX_LENGTH), storedName); registry.shutdown().get(); }
Example #18
Source File: SharedSlot.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Creates a new sub slot if the slot is not dead, yet. This method should only be called from * the assignment group instance to guarantee synchronization. * * <b>NOTE:</b> This method is not synchronized and must only be called from * the slot's assignment group. * * @param groupId The ID to identify tasks which can be deployed in this sub slot. * @return The new sub slot if the shared slot is still alive, otherwise null. */ SimpleSlot allocateSubSlot(AbstractID groupId) { if (isAlive()) { SimpleSlot slot = new SimpleSlot( getOwner(), getTaskManagerLocation(), subSlots.size(), getTaskManagerGateway(), this, groupId); subSlots.add(slot); return slot; } else { return null; } }
Example #19
Source File: SharedSlot.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
/** * Creates a new sub slot if the slot is not dead, yet. This method should only be called from * the assignment group instance to guarantee synchronization. * * NOTE: This method should only be called from the slot's assignment group. * * @param groupId The ID to identify tasks which can be deployed in this sub slot. * @return The new sub slot if the shared slot is still alive, otherwise null. */ SharedSlot allocateSharedSlot(AbstractID groupId){ if (isAlive()) { SharedSlot slot = new SharedSlot( getOwner(), getTaskManagerLocation(), subSlots.size(), getTaskManagerGateway(), assignmentGroup, this, groupId); subSlots.add(slot); return slot; } else { return null; } }
Example #20
Source File: TaskMetricGroupTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testGenerateScopeCustom() throws Exception { Configuration cfg = new Configuration(); cfg.setString(MetricOptions.SCOPE_NAMING_TM, "abc"); cfg.setString(MetricOptions.SCOPE_NAMING_TM_JOB, "def"); cfg.setString(MetricOptions.SCOPE_NAMING_TASK, "<tm_id>.<job_id>.<task_id>.<task_attempt_id>"); MetricRegistryImpl registry = new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(cfg)); JobID jid = new JobID(); JobVertexID vertexId = new JobVertexID(); AbstractID executionId = new AbstractID(); TaskManagerMetricGroup tmGroup = new TaskManagerMetricGroup(registry, "theHostName", "test-tm-id"); TaskManagerJobMetricGroup jmGroup = new TaskManagerJobMetricGroup(registry, tmGroup, jid, "myJobName"); TaskMetricGroup taskGroup = new TaskMetricGroup( registry, jmGroup, vertexId, executionId, "aTaskName", 13, 2); assertArrayEquals( new String[]{"test-tm-id", jid.toString(), vertexId.toString(), executionId.toString()}, taskGroup.getScopeComponents()); assertEquals( String.format("test-tm-id.%s.%s.%s.name", jid, vertexId, executionId), taskGroup.getMetricIdentifier("name")); registry.shutdown().get(); }
Example #21
Source File: TaskMetricGroupTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testGenerateScopeDefault() { JobVertexID vertexId = new JobVertexID(); 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")); }
Example #22
Source File: SlotSharingGroupAssignment.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
private static void removeSlotFromAllEntries( Map<AbstractID, Map<ResourceID, List<SharedSlot>>> availableSlots, SharedSlot slot) { final ResourceID taskManagerId = slot.getTaskManagerID(); for (Map.Entry<AbstractID, Map<ResourceID, List<SharedSlot>>> entry : availableSlots.entrySet()) { Map<ResourceID, List<SharedSlot>> map = entry.getValue(); List<SharedSlot> list = map.get(taskManagerId); if (list != null) { list.remove(slot); if (list.isEmpty()) { map.remove(taskManagerId); } } } }
Example #23
Source File: TaskManagerGroupTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testCloseClosesAll() throws IOException { final TaskManagerMetricGroup group = new TaskManagerMetricGroup( registry, "localhost", new AbstractID().toString()); final JobID jid1 = new JobID(); final JobID jid2 = new JobID(); final String jobName1 = "testjob"; final String jobName2 = "anotherJob"; final JobVertexID vertex11 = new JobVertexID(); final JobVertexID vertex12 = new JobVertexID(); final JobVertexID vertex21 = new JobVertexID(); final ExecutionAttemptID execution11 = new ExecutionAttemptID(); final ExecutionAttemptID execution12 = new ExecutionAttemptID(); final ExecutionAttemptID execution21 = new ExecutionAttemptID(); TaskMetricGroup tmGroup11 = group.addTaskForJob( jid1, jobName1, vertex11, execution11, "test", 17, 0); TaskMetricGroup tmGroup12 = group.addTaskForJob( jid1, jobName1, vertex12, execution12, "test", 13, 1); TaskMetricGroup tmGroup21 = group.addTaskForJob( jid2, jobName2, vertex21, execution21, "test", 7, 1); group.close(); assertTrue(tmGroup11.isClosed()); assertTrue(tmGroup12.isClosed()); assertTrue(tmGroup21.isClosed()); }
Example #24
Source File: OperatorGroupTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testVariables() { JobID jid = new JobID(); JobVertexID tid = new JobVertexID(); AbstractID eid = new AbstractID(); OperatorID oid = new OperatorID(); TaskManagerMetricGroup tmGroup = new TaskManagerMetricGroup(registry, "theHostName", "test-tm-id"); TaskManagerJobMetricGroup jmGroup = new TaskManagerJobMetricGroup(registry, tmGroup, jid, "myJobName"); TaskMetricGroup taskGroup = new TaskMetricGroup( registry, jmGroup, tid, eid, "aTaskName", 11, 0); OperatorMetricGroup opGroup = new OperatorMetricGroup(registry, taskGroup, oid, "myOpName"); Map<String, String> variables = opGroup.getAllVariables(); testVariable(variables, ScopeFormat.SCOPE_HOST, "theHostName"); testVariable(variables, ScopeFormat.SCOPE_TASKMANAGER_ID, "test-tm-id"); testVariable(variables, ScopeFormat.SCOPE_JOB_ID, jid.toString()); testVariable(variables, ScopeFormat.SCOPE_JOB_NAME, "myJobName"); testVariable(variables, ScopeFormat.SCOPE_TASK_VERTEX_ID, tid.toString()); testVariable(variables, ScopeFormat.SCOPE_TASK_NAME, "aTaskName"); testVariable(variables, ScopeFormat.SCOPE_TASK_ATTEMPT_ID, eid.toString()); testVariable(variables, ScopeFormat.SCOPE_TASK_SUBTASK_INDEX, "11"); testVariable(variables, ScopeFormat.SCOPE_TASK_ATTEMPT_NUM, "0"); testVariable(variables, ScopeFormat.SCOPE_OPERATOR_ID, oid.toString()); testVariable(variables, ScopeFormat.SCOPE_OPERATOR_NAME, "myOpName"); }
Example #25
Source File: DataSet.java From flink with Apache License 2.0 | 5 votes |
/** * Convenience method to get the count (number of elements) of a DataSet. * * @return A long integer that represents the number of elements in the data set. */ public long count() throws Exception { final String id = new AbstractID().toString(); output(new Utils.CountHelper<T>(id)).name("count()"); JobExecutionResult res = getExecutionEnvironment().execute(); return res.<Long> getAccumulatorResult(id); }
Example #26
Source File: SlotSharingManagerTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Tests that we can release inner slots and that this triggers the slot release for all * its children. */ @Test public void testInnerSlotRelease() { final TestingAllocatedSlotActions allocatedSlotActions = new TestingAllocatedSlotActions(); final SlotSharingManager slotSharingManager = new SlotSharingManager( SLOT_SHARING_GROUP_ID, allocatedSlotActions, SLOT_OWNER); SlotSharingManager.MultiTaskSlot rootSlot = slotSharingManager.createRootSlot( new SlotRequestId(), new CompletableFuture<>(), new SlotRequestId()); SlotSharingManager.MultiTaskSlot multiTaskSlot = rootSlot.allocateMultiTaskSlot( new SlotRequestId(), new AbstractID()); SlotSharingManager.SingleTaskSlot singleTaskSlot1 = multiTaskSlot.allocateSingleTaskSlot( new SlotRequestId(), new AbstractID(), Locality.LOCAL); SlotSharingManager.MultiTaskSlot multiTaskSlot1 = multiTaskSlot.allocateMultiTaskSlot( new SlotRequestId(), new AbstractID()); assertTrue(slotSharingManager.contains(multiTaskSlot1.getSlotRequestId())); assertTrue(slotSharingManager.contains(singleTaskSlot1.getSlotRequestId())); assertTrue(slotSharingManager.contains(multiTaskSlot.getSlotRequestId())); multiTaskSlot.release(new FlinkException("Test exception")); assertFalse(slotSharingManager.contains(multiTaskSlot1.getSlotRequestId())); assertFalse(slotSharingManager.contains(singleTaskSlot1.getSlotRequestId())); assertFalse(slotSharingManager.contains(multiTaskSlot.getSlotRequestId())); assertTrue(singleTaskSlot1.getLogicalSlotFuture().isCompletedExceptionally()); }
Example #27
Source File: SlotSharingManager.java From flink with Apache License 2.0 | 5 votes |
/** * Gets an unresolved slot which does not yet contain the given groupId. An unresolved * slot is a slot whose underlying allocated slot has not been allocated yet. * * @param groupId which the returned slot must not contain * @return the unresolved slot or null if there was no root slot with free capacities */ @Nullable MultiTaskSlot getUnresolvedRootSlot(AbstractID groupId) { return unresolvedRootSlots.values().stream() .filter(validMultiTaskSlotAndDoesNotContain(groupId)) .findFirst() .orElse(null); }
Example #28
Source File: SlotSharingManagerTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testGetUnresolvedSlot() { final TestingAllocatedSlotActions allocatedSlotActions = new TestingAllocatedSlotActions(); SlotSharingManager slotSharingManager = new SlotSharingManager( SLOT_SHARING_GROUP_ID, allocatedSlotActions, SLOT_OWNER); SlotSharingManager.MultiTaskSlot rootSlot1 = slotSharingManager.createRootSlot( new SlotRequestId(), new CompletableFuture<>(), new SlotRequestId()); final AbstractID groupId = new AbstractID(); SlotSharingManager.MultiTaskSlot unresolvedRootSlot = slotSharingManager.getUnresolvedRootSlot(groupId); assertNotNull(unresolvedRootSlot); assertEquals(rootSlot1.getSlotRequestId(), unresolvedRootSlot.getSlotRequestId()); // occupy the unresolved slot unresolvedRootSlot.allocateSingleTaskSlot( new SlotRequestId(), ResourceProfile.UNKNOWN, groupId, Locality.UNKNOWN); SlotSharingManager.MultiTaskSlot unresolvedRootSlot1 = slotSharingManager.getUnresolvedRootSlot(groupId); // we should no longer have a free unresolved root slot assertNull(unresolvedRootSlot1); }
Example #29
Source File: DataSetUtils.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Convenience method to get the count (number of elements) of a DataSet * as well as the checksum (sum over element hashes). * * @return A ChecksumHashCode that represents the count and checksum of elements in the data set. * @deprecated replaced with {@code org.apache.flink.graph.asm.dataset.ChecksumHashCode} in Gelly */ @Deprecated public static <T> Utils.ChecksumHashCode checksumHashCode(DataSet<T> input) throws Exception { final String id = new AbstractID().toString(); input.output(new Utils.ChecksumHashCodeHelper<T>(id)).name("ChecksumHashCode"); JobExecutionResult res = input.getExecutionEnvironment().execute(); return res.<Utils.ChecksumHashCode> getAccumulatorResult(id); }
Example #30
Source File: OperatorGroupTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testVariables() { JobID jid = new JobID(); JobVertexID tid = new JobVertexID(); AbstractID eid = new AbstractID(); OperatorID oid = new OperatorID(); TaskManagerMetricGroup tmGroup = new TaskManagerMetricGroup(registry, "theHostName", "test-tm-id"); TaskManagerJobMetricGroup jmGroup = new TaskManagerJobMetricGroup(registry, tmGroup, jid, "myJobName"); TaskMetricGroup taskGroup = new TaskMetricGroup( registry, jmGroup, tid, eid, "aTaskName", 11, 0); OperatorMetricGroup opGroup = new OperatorMetricGroup(registry, taskGroup, oid, "myOpName"); Map<String, String> variables = opGroup.getAllVariables(); testVariable(variables, ScopeFormat.SCOPE_HOST, "theHostName"); testVariable(variables, ScopeFormat.SCOPE_TASKMANAGER_ID, "test-tm-id"); testVariable(variables, ScopeFormat.SCOPE_JOB_ID, jid.toString()); testVariable(variables, ScopeFormat.SCOPE_JOB_NAME, "myJobName"); testVariable(variables, ScopeFormat.SCOPE_TASK_VERTEX_ID, tid.toString()); testVariable(variables, ScopeFormat.SCOPE_TASK_NAME, "aTaskName"); testVariable(variables, ScopeFormat.SCOPE_TASK_ATTEMPT_ID, eid.toString()); testVariable(variables, ScopeFormat.SCOPE_TASK_SUBTASK_INDEX, "11"); testVariable(variables, ScopeFormat.SCOPE_TASK_ATTEMPT_NUM, "0"); testVariable(variables, ScopeFormat.SCOPE_OPERATOR_ID, oid.toString()); testVariable(variables, ScopeFormat.SCOPE_OPERATOR_NAME, "myOpName"); }