-
Notifications
You must be signed in to change notification settings - Fork 9.1k
HDFS-13522: IPC changes to support observer reads through routers. #4311
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
4 commits
Select commit
Hold shift + click to select a range
a243ca8
HDFS-13522: Add federated nameservices states to client protocol and …
simbadzina 30497ad
Avoiding denial of service between clients.
simbadzina 8b59b80
Addressing review comments. Mostly refactoring.
simbadzina faa6493
Formatting fixes.
simbadzina 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
103 changes: 103 additions & 0 deletions
103
...f/src/main/java/org/apache/hadoop/hdfs/server/federation/router/PoolAlignmentContext.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,103 @@ | ||
/** | ||
* 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.hadoop.hdfs.server.federation.router; | ||
|
||
import java.io.IOException; | ||
import java.util.concurrent.atomic.LongAccumulator; | ||
import org.apache.hadoop.ipc.AlignmentContext; | ||
import org.apache.hadoop.ipc.protobuf.RpcHeaderProtos; | ||
|
||
|
||
simbadzina marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/** | ||
* An alignment context shared by all connections in a {@link ConnectionPool}. | ||
* There is a distinct connection pool for each [namespace,UGI] pairing. | ||
* <p> | ||
* {@link #sharedGlobalStateId} is a reference to a | ||
* shared {@link LongAccumulator} object in the {@link RouterStateIdContext}. | ||
* {@link #poolLocalStateId} is specific to each PoolAlignmentContext. | ||
* <p> | ||
* The shared {@link #sharedGlobalStateId} is updated only using | ||
* responses from NameNodes, so clients cannot poison it. | ||
* {@link #poolLocalStateId} is used to propagate client observed | ||
* state into NameNode requests. A misbehaving client can poison this but the effect is only | ||
* visible to other clients with the same UGI and accessing the same namespace. | ||
*/ | ||
public class PoolAlignmentContext implements AlignmentContext { | ||
private LongAccumulator sharedGlobalStateId; | ||
private LongAccumulator poolLocalStateId; | ||
|
||
PoolAlignmentContext(RouterStateIdContext routerStateIdContext, String namespaceId) { | ||
sharedGlobalStateId = routerStateIdContext.getNamespaceStateId(namespaceId); | ||
poolLocalStateId = new LongAccumulator(Math::max, Long.MIN_VALUE); | ||
} | ||
|
||
/** | ||
* Client side implementation only receives state alignment info. | ||
* It does not provide state alignment info therefore this does nothing. | ||
*/ | ||
@Override | ||
public void updateResponseState(RpcHeaderProtos.RpcResponseHeaderProto.Builder header) { | ||
// Do nothing. | ||
} | ||
|
||
/** | ||
* Router updates a globally shared value using response from | ||
* namenodes. | ||
*/ | ||
@Override | ||
public void receiveResponseState(RpcHeaderProtos.RpcResponseHeaderProto header) { | ||
sharedGlobalStateId.accumulate(header.getStateId()); | ||
} | ||
|
||
/** | ||
* Client side implementation for routers to provide state info in requests to | ||
* namenodes. | ||
*/ | ||
@Override | ||
public void updateRequestState(RpcHeaderProtos.RpcRequestHeaderProto.Builder header) { | ||
long maxStateId = Long.max(poolLocalStateId.get(), sharedGlobalStateId.get()); | ||
header.setStateId(maxStateId); | ||
} | ||
|
||
/** | ||
* Client side implementation only provides state alignment info in requests. | ||
* Client does not receive RPC requests therefore this does nothing. | ||
*/ | ||
@Override | ||
public long receiveRequestState(RpcHeaderProtos.RpcRequestHeaderProto header, long threshold) | ||
throws IOException { | ||
// Do nothing. | ||
return 0; | ||
} | ||
|
||
@Override | ||
public long getLastSeenStateId() { | ||
return sharedGlobalStateId.get(); | ||
} | ||
|
||
@Override | ||
public boolean isCoordinatedCall(String protocolName, String method) { | ||
throw new UnsupportedOperationException( | ||
"Client should not be checking uncoordinated call"); | ||
} | ||
|
||
public void advanceClientStateId(Long clientStateId) { | ||
poolLocalStateId.accumulate(clientStateId); | ||
} | ||
} |
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.
Uh oh!
There was an error while loading. Please reload this page.