Skip to content

Commit 1957e82

Browse files
committed
[SPARK-25299] Introduce the new shuffle writer API (#5) (apache-spark-on-k8s#520)
Introduces the new Shuffle Writer API. Ported from #5.
1 parent c277afb commit 1957e82

File tree

5 files changed

+180
-0
lines changed

5 files changed

+180
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.spark.api.shuffle;
19+
20+
import org.apache.spark.annotation.Experimental;
21+
22+
/**
23+
* :: Experimental ::
24+
* An interface for launching Shuffle related components
25+
*
26+
* @since 3.0.0
27+
*/
28+
@Experimental
29+
public interface ShuffleDataIO {
30+
ShuffleExecutorComponents executor();
31+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.spark.api.shuffle;
19+
20+
import org.apache.spark.annotation.Experimental;
21+
22+
/**
23+
* :: Experimental ::
24+
* An interface for building shuffle support for Executors
25+
*
26+
* @since 3.0.0
27+
*/
28+
@Experimental
29+
public interface ShuffleExecutorComponents {
30+
void intitializeExecutor(String appId, String execId);
31+
32+
ShuffleWriteSupport writes();
33+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.spark.api.shuffle;
19+
20+
import java.io.IOException;
21+
22+
import org.apache.spark.annotation.Experimental;
23+
24+
/**
25+
* :: Experimental ::
26+
* An interface for creating and managing shuffle partition writers
27+
*
28+
* @since 3.0.0
29+
*/
30+
@Experimental
31+
public interface ShuffleMapOutputWriter {
32+
ShufflePartitionWriter getNextPartitionWriter() throws IOException;
33+
34+
void commitAllPartitions() throws IOException;
35+
36+
void abort(Throwable error) throws IOException;
37+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.spark.api.shuffle;
19+
20+
import java.io.IOException;
21+
import java.io.OutputStream;
22+
import java.nio.channels.Channels;
23+
import java.nio.channels.WritableByteChannel;
24+
25+
import org.apache.http.annotation.Experimental;
26+
27+
/**
28+
* :: Experimental ::
29+
* An interface for giving streams / channels for shuffle writes
30+
*
31+
* @since 3.0.0
32+
*/
33+
@Experimental
34+
public interface ShufflePartitionWriter {
35+
OutputStream openStream() throws IOException;
36+
37+
long getLength();
38+
39+
default WritableByteChannel openChannel() throws IOException {
40+
return Channels.newChannel(openStream());
41+
}
42+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.spark.api.shuffle;
19+
20+
import java.io.IOException;
21+
22+
import org.apache.http.annotation.Experimental;
23+
24+
/**
25+
* :: Experimental ::
26+
* An interface for deploying a shuffle map output writer
27+
*
28+
* @since 3.0.0
29+
*/
30+
@Experimental
31+
public interface ShuffleWriteSupport {
32+
ShuffleMapOutputWriter createMapOutputWriter(
33+
String appId,
34+
int shuffleId,
35+
int mapId,
36+
int numPartitions) throws IOException;
37+
}

0 commit comments

Comments
 (0)