Skip to content

[SPARK-25299][LIVE-DIFF] Use remote storage for persisting shuffle data #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 18 commits into
base: upstream-master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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.spark.api.shuffle;

import org.apache.spark.annotation.Experimental;

import java.io.Serializable;

/**
* Represents metadata about where shuffle blocks were written in a single map task.
* <p>
* This is optionally returned by shuffle writers. The inner shuffle locations may
* be accessed by shuffle readers. Shuffle locations are only necessary when the
* location of shuffle blocks needs to be managed by the driver; shuffle plugins
* may choose to use an external database or other metadata management systems to
* track the locations of shuffle blocks instead.
*/
@Experimental
public interface MapShuffleLocations extends Serializable {

/**
* Get the location for a given shuffle block written by this map task.
*/
ShuffleLocation getLocationForBlock(int reduceId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* 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.spark.api.shuffle;

import org.apache.spark.api.java.Optional;

import java.util.Objects;

/**
* :: Experimental ::
* An object defining the shuffle block and length metadata associated with the block.
* @since 3.0.0
*/
public class ShuffleBlockInfo {
private final int shuffleId;
private final int mapId;
private final int reduceId;
private final long length;
private final Optional<ShuffleLocation> shuffleLocation;

public ShuffleBlockInfo(int shuffleId, int mapId, int reduceId, long length,
Optional<ShuffleLocation> shuffleLocation) {
this.shuffleId = shuffleId;
this.mapId = mapId;
this.reduceId = reduceId;
this.length = length;
this.shuffleLocation = shuffleLocation;
}

public int getShuffleId() {
return shuffleId;
}

public int getMapId() {
return mapId;
}

public int getReduceId() {
return reduceId;
}

public long getLength() {
return length;
}

public Optional<ShuffleLocation> getShuffleLocation() {
return shuffleLocation;
}

@Override
public boolean equals(Object other) {
return other instanceof ShuffleBlockInfo
&& shuffleId == ((ShuffleBlockInfo) other).shuffleId
&& mapId == ((ShuffleBlockInfo) other).mapId
&& reduceId == ((ShuffleBlockInfo) other).reduceId
&& length == ((ShuffleBlockInfo) other).length
&& Objects.equals(shuffleLocation, ((ShuffleBlockInfo) other).shuffleLocation);
}

@Override
public int hashCode() {
return Objects.hash(shuffleId, mapId, reduceId, length, shuffleLocation);
}
}
34 changes: 34 additions & 0 deletions core/src/main/java/org/apache/spark/api/shuffle/ShuffleDataIO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* 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.spark.api.shuffle;

import org.apache.spark.annotation.Experimental;

/**
* :: Experimental ::
* An interface for launching Shuffle related components
*
* @since 3.0.0
*/
@Experimental
public interface ShuffleDataIO {
String SHUFFLE_SPARK_CONF_PREFIX = "spark.shuffle.plugin.";

ShuffleDriverComponents driver();
ShuffleExecutorComponents executor();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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.spark.api.shuffle;

import java.io.IOException;
import java.util.Map;

public interface ShuffleDriverComponents {

/**
* @return additional SparkConf values necessary for the executors.
*/
Map<String, String> initializeApplication();

void cleanupApplication() throws IOException;

void removeShuffleData(int shuffleId, boolean blocking) throws IOException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* 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.spark.api.shuffle;

import org.apache.spark.annotation.Experimental;

import java.util.Map;

/**
* :: Experimental ::
* An interface for building shuffle support for Executors
*
* @since 3.0.0
*/
@Experimental
public interface ShuffleExecutorComponents {
void initializeExecutor(String appId, String execId, Map<String, String> extraConfigs);

ShuffleWriteSupport writes();

ShuffleReadSupport reads();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* 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.spark.api.shuffle;

/**
* Marker interface representing a location of a shuffle block. Implementations of shuffle readers
* and writers are expected to cast this down to an implementation-specific representation.
*/
public interface ShuffleLocation {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 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.spark.api.shuffle;

import java.io.IOException;

import org.apache.spark.annotation.Experimental;
import org.apache.spark.api.java.Optional;

/**
* :: Experimental ::
* An interface for creating and managing shuffle partition writers
*
* @since 3.0.0
*/
@Experimental
public interface ShuffleMapOutputWriter {
ShufflePartitionWriter getPartitionWriter(int partitionId) throws IOException;

Optional<MapShuffleLocations> commitAllPartitions() throws IOException;

void abort(Throwable error) throws IOException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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.spark.api.shuffle;

import java.io.IOException;
import java.io.OutputStream;

import org.apache.spark.annotation.Experimental;

/**
* :: Experimental ::
* An interface for giving streams / channels for shuffle writes.
*
* @since 3.0.0
*/
@Experimental
public interface ShufflePartitionWriter {

/**
* Opens and returns an underlying {@link OutputStream} that can write bytes to the underlying
* data store.
*/
OutputStream openStream() throws IOException;

/**
* Get the number of bytes written by this writer's stream returned by {@link #openStream()}.
*/
long getNumBytesWritten();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 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.spark.api.shuffle;

import org.apache.spark.annotation.Experimental;

import java.io.IOException;
import java.io.InputStream;

/**
* :: Experimental ::
* An interface for reading shuffle records.
* @since 3.0.0
*/
@Experimental
public interface ShuffleReadSupport {
/**
* Returns an underlying {@link Iterable<InputStream>} that will iterate
* through shuffle data, given an iterable for the shuffle blocks to fetch.
*/
Iterable<InputStream> getPartitionReaders(Iterable<ShuffleBlockInfo> blockMetadata)
throws IOException;
}
Loading