-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
HBASE-24055 Make AsyncFSWAL can run on EC cluster #1437
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 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 |
---|---|---|
|
@@ -17,8 +17,6 @@ | |
*/ | ||
package org.apache.hadoop.hbase.io.asyncfs; | ||
|
||
import static org.apache.hadoop.fs.CreateFlag.CREATE; | ||
import static org.apache.hadoop.fs.CreateFlag.OVERWRITE; | ||
import static org.apache.hadoop.hbase.io.asyncfs.FanOutOneBlockAsyncDFSOutputSaslHelper.createEncryptor; | ||
import static org.apache.hadoop.hbase.io.asyncfs.FanOutOneBlockAsyncDFSOutputSaslHelper.trySaslNegotiate; | ||
import static org.apache.hadoop.hdfs.client.HdfsClientConfigKeys.DFS_CLIENT_SOCKET_TIMEOUT_KEY; | ||
|
@@ -177,6 +175,11 @@ Object createObject(ClientProtocol instance, String src, FsPermission masked, St | |
|
||
private static final FileCreator FILE_CREATOR; | ||
|
||
// CreateFlag.SHOULD_REPLICATE is to make OutputStream on a EC directory support hflush/hsync, but | ||
// EC is introduced in hadoop 3.x so we do not have this enum on 2.x, that's why we need to | ||
// indirectly reference it through reflection. | ||
private static final CreateFlag SHOULD_REPLICATE_FLAG; | ||
|
||
private static DFSClientAdaptor createDFSClientAdaptor() throws NoSuchMethodException { | ||
Method isClientRunningMethod = DFSClient.class.getDeclaredMethod("isClientRunning"); | ||
isClientRunningMethod.setAccessible(true); | ||
|
@@ -272,6 +275,15 @@ private static FileCreator createFileCreator() throws NoSuchMethodException { | |
return createFileCreator2(); | ||
} | ||
|
||
private static CreateFlag loadShouldReplicateFlag() { | ||
try { | ||
return CreateFlag.valueOf("SHOULD_REPLICATE"); | ||
} catch (IllegalArgumentException e) { | ||
LOG.debug("can not find SHOULD_REPLICATE flag, should be hadoop 2.x", e); | ||
return null; | ||
} | ||
} | ||
|
||
// cancel the processing if DFSClient is already closed. | ||
static final class CancelOnClose implements CancelableProgressable { | ||
|
||
|
@@ -292,6 +304,7 @@ public boolean progress() { | |
LEASE_MANAGER = createLeaseManager(); | ||
DFS_CLIENT_ADAPTOR = createDFSClientAdaptor(); | ||
FILE_CREATOR = createFileCreator(); | ||
SHOULD_REPLICATE_FLAG = loadShouldReplicateFlag(); | ||
} catch (Exception e) { | ||
String msg = "Couldn't properly initialize access to HDFS internals. Please " + | ||
"update your WAL Provider to not make use of the 'asyncfs' provider. See " + | ||
|
@@ -486,6 +499,18 @@ public NameNodeException(Throwable cause) { | |
} | ||
} | ||
|
||
private static EnumSetWritable<CreateFlag> getCreateFlags(boolean overwrite) { | ||
List<CreateFlag> flags = new ArrayList<>(); | ||
flags.add(CreateFlag.CREATE); | ||
if (overwrite) { | ||
flags.add(CreateFlag.OVERWRITE); | ||
} | ||
if (SHOULD_REPLICATE_FLAG != null) { | ||
flags.add(SHOULD_REPLICATE_FLAG); | ||
} | ||
return new EnumSetWritable<>(EnumSet.copyOf(flags)); | ||
} | ||
|
||
private static FanOutOneBlockAsyncDFSOutput createOutput(DistributedFileSystem dfs, String src, | ||
boolean overwrite, boolean createParent, short replication, long blockSize, | ||
EventLoopGroup eventLoopGroup, Class<? extends Channel> channelClass) throws IOException { | ||
|
@@ -502,8 +527,8 @@ private static FanOutOneBlockAsyncDFSOutput createOutput(DistributedFileSystem d | |
try { | ||
stat = FILE_CREATOR.create(namenode, src, | ||
FsPermission.getFileDefault().applyUMask(FsPermission.getUMask(conf)), clientName, | ||
new EnumSetWritable<>(overwrite ? EnumSet.of(CREATE, OVERWRITE) : EnumSet.of(CREATE)), | ||
createParent, replication, blockSize, CryptoProtocolVersion.supported()); | ||
getCreateFlags(overwrite), createParent, replication, blockSize, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice cleanup. |
||
CryptoProtocolVersion.supported()); | ||
} catch (Exception e) { | ||
if (e instanceof RemoteException) { | ||
throw (RemoteException) e; | ||
|
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
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.
Should this be logged at
warn
instead?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.
I used to make all the adaptor code to log as WARN but it was proven to be annoying for most users and we changed them all to debug...
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.
This happens every time we open a file in hadoop2? Or just once on class loading? (Looks like the latter).
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.
This is how we test if the the SHOULD_REPLICATE flag is available? It is not available if hadoop2? If so, can we have a comment on the method to this effect? The log is a little confusing. Suggest: "SHOULD_REPLICATE is not available; this is a problem if we are running on hadoop3 (Its expected if hadoop2)".
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.
Only once when loading.
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.
All the other log messages are just like this, so do not want to only change this one. Let me add some comments on the field.