forked from apache/celeborn
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CELEBORN-1490][CIP-6] Extends message to support hybrid shuffle
### What changes were proposed in this pull request? This is the first PR to support Hybrid Shuffle. Extends message to support hybrid shuffle. ### Why are the changes needed? hybrid shuffle is a tiered storage architecture, which introduces the concept of `segment`. One segment's data selects a tier to send. Data is split into segments and sent to multiple tiers. This PR introduces segment-related message. In addition, hybrid shuffle needs to distinguish which subpartition it comes from when consuming data, so we need to extend the `SubpartitionId` field to `ReadData` (new class introduced for compatibility). ### Does this PR introduce _any_ user-facing change? no. ### How was this patch tested? no need. Closes apache#2714 from reswqa/cip6-1-extend-message. Authored-by: Weijie Guo <[email protected]> Signed-off-by: Shuang <[email protected]>
- Loading branch information
Showing
8 changed files
with
255 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 106 additions & 0 deletions
106
.../common/src/main/java/org/apache/celeborn/plugin/flink/protocol/SubPartitionReadData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/* | ||
* 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.celeborn.plugin.flink.protocol; | ||
|
||
import java.util.Objects; | ||
|
||
import org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf; | ||
|
||
import org.apache.celeborn.common.network.protocol.ReadData; | ||
import org.apache.celeborn.common.network.protocol.RequestMessage; | ||
|
||
/** | ||
* Comparing {@link ReadData}, this class has an additional field of subpartitionId. This class is | ||
* added to keep the backward compatibility. | ||
*/ | ||
public class SubPartitionReadData extends RequestMessage { | ||
private final long streamId; | ||
private final int subPartitionId; | ||
private ByteBuf flinkBuffer; | ||
|
||
@Override | ||
public boolean needCopyOut() { | ||
return true; | ||
} | ||
|
||
public SubPartitionReadData(long streamId, int subPartitionId) { | ||
this.subPartitionId = subPartitionId; | ||
this.streamId = streamId; | ||
} | ||
|
||
@Override | ||
public int encodedLength() { | ||
return 8 + 4; | ||
} | ||
|
||
// This method will not be called because ReadData won't be created at flink client. | ||
@Override | ||
public void encode(io.netty.buffer.ByteBuf buf) { | ||
buf.writeLong(streamId); | ||
buf.writeInt(subPartitionId); | ||
} | ||
|
||
public long getStreamId() { | ||
return streamId; | ||
} | ||
|
||
public int getSubPartitionId() { | ||
return subPartitionId; | ||
} | ||
|
||
@Override | ||
public Type type() { | ||
return Type.SUBPARTITION_READ_DATA; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
SubPartitionReadData readData = (SubPartitionReadData) o; | ||
return streamId == readData.streamId | ||
&& subPartitionId == readData.subPartitionId | ||
&& Objects.equals(flinkBuffer, readData.flinkBuffer); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(streamId, subPartitionId, flinkBuffer); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "SubpartitionReadData{" | ||
+ "streamId=" | ||
+ streamId | ||
+ ", subPartitionId=" | ||
+ subPartitionId | ||
+ ", flinkBuffer=" | ||
+ flinkBuffer | ||
+ '}'; | ||
} | ||
|
||
public ByteBuf getFlinkBuffer() { | ||
return flinkBuffer; | ||
} | ||
|
||
public void setFlinkBuffer(ByteBuf flinkBuffer) { | ||
this.flinkBuffer = flinkBuffer; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
common/src/main/java/org/apache/celeborn/common/network/protocol/SubPartitionReadData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* 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.celeborn.common.network.protocol; | ||
|
||
import java.util.Objects; | ||
|
||
import io.netty.buffer.ByteBuf; | ||
|
||
import org.apache.celeborn.common.network.buffer.NettyManagedBuffer; | ||
|
||
/** | ||
* Comparing {@link ReadData}, this class has an additional field of subpartitionId. This class is | ||
* added to keep the backward compatibility. | ||
*/ | ||
public class SubPartitionReadData extends RequestMessage { | ||
private long streamId; | ||
|
||
private int subPartitionId; | ||
|
||
public SubPartitionReadData(long streamId, int subPartitionId, ByteBuf buf) { | ||
super(new NettyManagedBuffer(buf)); | ||
this.streamId = streamId; | ||
this.subPartitionId = subPartitionId; | ||
} | ||
|
||
@Override | ||
public int encodedLength() { | ||
return 8 + 4; | ||
} | ||
|
||
@Override | ||
public void encode(ByteBuf buf) { | ||
buf.writeLong(streamId); | ||
buf.writeInt(subPartitionId); | ||
} | ||
|
||
public long getStreamId() { | ||
return streamId; | ||
} | ||
|
||
public int getSubPartitionId() { | ||
return subPartitionId; | ||
} | ||
|
||
@Override | ||
public Type type() { | ||
return Type.SUBPARTITION_READ_DATA; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
SubPartitionReadData readData = (SubPartitionReadData) o; | ||
return streamId == readData.streamId | ||
&& subPartitionId == readData.subPartitionId | ||
&& super.equals(o); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(streamId, subPartitionId, super.hashCode()); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "SubpartitionReadData{" | ||
+ "streamId=" | ||
+ streamId | ||
+ ", subPartitionId=" | ||
+ subPartitionId | ||
+ '}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters