-
Notifications
You must be signed in to change notification settings - Fork 28.7k
[SPARK-4242] [Core] Add SASL to external shuffle service #3108
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
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2bf2908
[SPARK-4242] [Core] Add SASL to external shuffle service
aarondav cbe451a
Address comments
aarondav b58518a
ByteStreams.limit() not available :(
aarondav 3543b70
Back out of pom change due to unknown test issue?
aarondav 48b622d
Screw it, let's just get LimitedInputStream
aarondav File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
87 changes: 87 additions & 0 deletions
87
network/common/src/main/java/org/apache/spark/network/util/LimitedInputStream.java
This file contains hidden or 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,87 @@ | ||
/* | ||
* 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.network.util; | ||
|
||
import java.io.FilterInputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
import com.google.common.base.Preconditions; | ||
|
||
/** | ||
* Wraps a {@link InputStream}, limiting the number of bytes which can be read. | ||
* | ||
* This code is from Guava's 14.0 source code, because there is no compatible way to | ||
* use this functionality in both a Guava 11 environment and a Guava >14 environment. | ||
*/ | ||
public final class LimitedInputStream extends FilterInputStream { | ||
private long left; | ||
private long mark = -1; | ||
|
||
public LimitedInputStream(InputStream in, long limit) { | ||
super(in); | ||
Preconditions.checkNotNull(in); | ||
Preconditions.checkArgument(limit >= 0, "limit must be non-negative"); | ||
left = limit; | ||
} | ||
@Override public int available() throws IOException { | ||
return (int) Math.min(in.available(), left); | ||
} | ||
// it's okay to mark even if mark isn't supported, as reset won't work | ||
@Override public synchronized void mark(int readLimit) { | ||
in.mark(readLimit); | ||
mark = left; | ||
} | ||
@Override public int read() throws IOException { | ||
if (left == 0) { | ||
return -1; | ||
} | ||
int result = in.read(); | ||
if (result != -1) { | ||
--left; | ||
} | ||
return result; | ||
} | ||
@Override public int read(byte[] b, int off, int len) throws IOException { | ||
if (left == 0) { | ||
return -1; | ||
} | ||
len = (int) Math.min(len, left); | ||
int result = in.read(b, off, len); | ||
if (result != -1) { | ||
left -= result; | ||
} | ||
return result; | ||
} | ||
@Override public synchronized void reset() throws IOException { | ||
if (!in.markSupported()) { | ||
throw new IOException("Mark not supported"); | ||
} | ||
if (mark == -1) { | ||
throw new IOException("Mark not set"); | ||
} | ||
in.reset(); | ||
left = mark; | ||
} | ||
@Override public long skip(long n) throws IOException { | ||
n = Math.min(n, left); | ||
long skipped = in.skip(n); | ||
left -= skipped; | ||
return skipped; | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pwendell I don't know if this is kosher - it helps us compile in a YARN-compatible way, and Guava usually just adds and deprecates APIs.