zentol commented on a change in pull request #8687: [FLINK-12612][coordination] 
Track stored partition on the TaskExecutor 
URL: https://github.com/apache/flink/pull/8687#discussion_r295841724
 
 

 ##########
 File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/taskexecutor/partition/JobAwareShuffleEnvironmentImplTest.java
 ##########
 @@ -0,0 +1,371 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.taskexecutor.partition;
+
+import org.apache.flink.api.common.JobID;
+import org.apache.flink.metrics.MetricGroup;
+import org.apache.flink.metrics.groups.UnregisteredMetricsGroup;
+import org.apache.flink.runtime.clusterframework.types.ResourceID;
+import org.apache.flink.runtime.deployment.InputGateDeploymentDescriptor;
+import org.apache.flink.runtime.deployment.ResultPartitionDeploymentDescriptor;
+import org.apache.flink.runtime.executiongraph.ExecutionAttemptID;
+import org.apache.flink.runtime.executiongraph.PartitionInfo;
+import org.apache.flink.runtime.io.network.api.writer.ResultPartitionWriter;
+import org.apache.flink.runtime.io.network.buffer.BufferBuilder;
+import org.apache.flink.runtime.io.network.buffer.BufferConsumer;
+import 
org.apache.flink.runtime.io.network.partition.PartitionProducerStateProvider;
+import org.apache.flink.runtime.io.network.partition.ResultPartitionID;
+import org.apache.flink.runtime.io.network.partition.ResultPartitionType;
+import org.apache.flink.runtime.io.network.partition.consumer.InputGate;
+import org.apache.flink.runtime.jobgraph.IntermediateDataSetID;
+import org.apache.flink.runtime.jobgraph.IntermediateResultPartitionID;
+import org.apache.flink.runtime.shuffle.PartitionDescriptor;
+import org.apache.flink.runtime.shuffle.ShuffleDescriptor;
+import org.apache.flink.runtime.shuffle.ShuffleEnvironment;
+import org.apache.flink.util.TestLogger;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.annotation.Nullable;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Optional;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import static junit.framework.TestCase.assertTrue;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.collection.IsEmptyCollection.empty;
+import static org.junit.Assert.assertFalse;
+
+/**
+ * Tests for the {@link JobAwareShuffleEnvironmentImpl}.
+ */
+public class JobAwareShuffleEnvironmentImplTest extends TestLogger {
+
+       private final JobID jobId = new JobID();
+       private TestResultPartitionWriter retainedOnConsumptionWriter;
+       private TestResultPartitionWriter releasedOnConsumptionWriter;
+       private TestShuffleEnvironment wrappedEnvironment;
+       private JobAwareShuffleEnvironmentImpl<?> jobAwareEnvironment;
+       private Collection<ResultPartitionWriter> writers;
+
+       @Before
+       public void setup() {
+               final ExecutionAttemptID executionAttemptId = new 
ExecutionAttemptID();
+               retainedOnConsumptionWriter = new TestResultPartitionWriter(
+                       new ResultPartitionID(new 
IntermediateResultPartitionID(), executionAttemptId));
+               releasedOnConsumptionWriter = new TestResultPartitionWriter(
+                       new ResultPartitionID(new 
IntermediateResultPartitionID(), executionAttemptId));
+               TestResultPartitionWriter 
releasedOnConsumptionWithoutLocalResourcesWriter = new 
TestResultPartitionWriter(
+                       new ResultPartitionID(new 
IntermediateResultPartitionID(), executionAttemptId));
+               TestResultPartitionWriter 
retainedOnConsumptionWithoutLocalResourcesWriter = new 
TestResultPartitionWriter(
+                       new ResultPartitionID(new 
IntermediateResultPartitionID(), executionAttemptId));
+
+               wrappedEnvironment = new TestShuffleEnvironment(
+                       Arrays.asList(retainedOnConsumptionWriter, 
releasedOnConsumptionWriter));
+
+               jobAwareEnvironment = new 
JobAwareShuffleEnvironmentImpl<>(wrappedEnvironment);
+
+               ResultPartitionDeploymentDescriptor deploymentDescriptor1 = 
createResultPartitionDeploymentDescriptor(
+                       retainedOnConsumptionWriter.resultPartitionID, false, 
true);
+               ResultPartitionDeploymentDescriptor deploymentDescriptor2 = 
createResultPartitionDeploymentDescriptor(
+                       releasedOnConsumptionWriter.resultPartitionID, true, 
true);
+               ResultPartitionDeploymentDescriptor deploymentDescriptor3 = 
createResultPartitionDeploymentDescriptor(
+                       
releasedOnConsumptionWithoutLocalResourcesWriter.resultPartitionID, false, 
false);
+               ResultPartitionDeploymentDescriptor deploymentDescriptor4 = 
createResultPartitionDeploymentDescriptor(
+                       
retainedOnConsumptionWithoutLocalResourcesWriter.resultPartitionID, true, 
false);
+
+               writers = jobAwareEnvironment.createResultPartitionWriters(
+                       jobId,
+                       "test",
+                       executionAttemptId,
+                       Arrays.asList(deploymentDescriptor1, 
deploymentDescriptor2, deploymentDescriptor3, deploymentDescriptor4),
 
 Review comment:
   The ShuffleEnvironment docs specify that the order of the returned 
partitions writers must correspond to the order of input deployment 
descriptors. One can interpret this to also mean that the number of writers 
must be equal to the number of deployment descriptors.
   @azagrebin 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to