Search in sources :

Example 1 with DataSetMetaInfo

use of org.apache.flink.runtime.io.network.partition.DataSetMetaInfo in project flink by apache.

the class ClusterDataSetListResponseBodyTest method getTestResponseInstance.

@Override
protected ClusterDataSetListResponseBody getTestResponseInstance() throws Exception {
    final Map<IntermediateDataSetID, DataSetMetaInfo> dataSets = new HashMap<>();
    dataSets.put(new IntermediateDataSetID(), DataSetMetaInfo.withNumRegisteredPartitions(1, 2));
    return ClusterDataSetListResponseBody.from(dataSets);
}
Also used : HashMap(java.util.HashMap) DataSetMetaInfo(org.apache.flink.runtime.io.network.partition.DataSetMetaInfo) IntermediateDataSetID(org.apache.flink.runtime.jobgraph.IntermediateDataSetID)

Example 2 with DataSetMetaInfo

use of org.apache.flink.runtime.io.network.partition.DataSetMetaInfo in project flink by apache.

the class ClusterDataSetListResponseBodyTest method testFrom.

@Test
public void testFrom() {
    final Map<IntermediateDataSetID, DataSetMetaInfo> originalDataSets = new HashMap<>();
    originalDataSets.put(new IntermediateDataSetID(), DataSetMetaInfo.withNumRegisteredPartitions(1, 2));
    originalDataSets.put(new IntermediateDataSetID(), DataSetMetaInfo.withNumRegisteredPartitions(2, 2));
    List<ClusterDataSetEntry> convertedDataSets = ClusterDataSetListResponseBody.from(originalDataSets).getDataSets();
    assertThat(convertedDataSets, hasSize(2));
    for (ClusterDataSetEntry convertedDataSet : convertedDataSets) {
        IntermediateDataSetID id = new IntermediateDataSetID(new AbstractID(StringUtils.hexStringToByte(convertedDataSet.getDataSetId())));
        DataSetMetaInfo dataSetMetaInfo = originalDataSets.get(id);
        assertThat(convertedDataSet.isComplete(), is(dataSetMetaInfo.getNumRegisteredPartitions().orElse(0) == dataSetMetaInfo.getNumTotalPartitions()));
    }
}
Also used : HashMap(java.util.HashMap) DataSetMetaInfo(org.apache.flink.runtime.io.network.partition.DataSetMetaInfo) IntermediateDataSetID(org.apache.flink.runtime.jobgraph.IntermediateDataSetID) AbstractID(org.apache.flink.util.AbstractID) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)2 DataSetMetaInfo (org.apache.flink.runtime.io.network.partition.DataSetMetaInfo)2 IntermediateDataSetID (org.apache.flink.runtime.jobgraph.IntermediateDataSetID)2 AbstractID (org.apache.flink.util.AbstractID)1 Test (org.junit.Test)1