-
Notifications
You must be signed in to change notification settings - Fork 8.9k
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
YARN-9708. Yarn Federation Router Support DelegationToken. #4746
Closed
Closed
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
d02516c
YARN-9708. Yarn Router Support DelegationToken.
690c035
YARN-9708. Fix CheckStyle.
8dfa838
YARN-9708. Fix CheckStyle.
b00e0a1
YARN-9708. Fix CheckStyle.
a8ec3f5
YARN-9708. Fix CheckStyle.
9e6760b
YARN-9708. Fix Junit Test Error.
e945c64
Merge branch 'trunk' into YARN-9708
slfan1989 c970950
YARN-9708. Fix CodeStyle.
7a2d1e2
Merge branch 'apache:trunk' into YARN-9708
slfan1989 1b8690e
YARN-9708. Fix CheckStyle.
1b918a4
YARN-11253. Fix CheckStyle.
745c5b8
YARN-9708. Fix CheckStyle.
0a30fe0
Merge branch 'apache:trunk' into YARN-9708
slfan1989 414140c
YARN-9708. Fix CheckStyle.
ca65a32
YARN-9708. Fix CheckStyle.
666853d
Merge branch 'apache:trunk' into YARN-9708
slfan1989 bba520a
YARN-9708. Fix CheckStyle.
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
200 changes: 200 additions & 0 deletions
200
...a/org/apache/hadoop/yarn/security/client/impl/pb/YARNDelegationTokenIdentifierPBImpl.java
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 |
---|---|---|
@@ -0,0 +1,200 @@ | ||
/** | ||
* 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.yarn.security.client.impl.pb; | ||
|
||
import org.apache.hadoop.classification.InterfaceAudience.Private; | ||
import org.apache.hadoop.classification.InterfaceStability.Unstable; | ||
import org.apache.hadoop.io.Text; | ||
import org.apache.hadoop.thirdparty.protobuf.TextFormat; | ||
import org.apache.hadoop.yarn.proto.YarnSecurityTokenProtos.YARNDelegationTokenIdentifierProto; | ||
import org.apache.hadoop.yarn.proto.YarnSecurityTokenProtos.YARNDelegationTokenIdentifierProtoOrBuilder; | ||
import org.apache.hadoop.yarn.security.client.YARNDelegationTokenIdentifier; | ||
|
||
@Private | ||
@Unstable | ||
public class YARNDelegationTokenIdentifierPBImpl extends YARNDelegationTokenIdentifier { | ||
|
||
private YARNDelegationTokenIdentifierProto proto = | ||
YARNDelegationTokenIdentifierProto.getDefaultInstance(); | ||
private YARNDelegationTokenIdentifierProto.Builder builder = null; | ||
private boolean viaProto = false; | ||
|
||
public YARNDelegationTokenIdentifierPBImpl() { | ||
builder = YARNDelegationTokenIdentifierProto.newBuilder(); | ||
} | ||
|
||
public YARNDelegationTokenIdentifierPBImpl(YARNDelegationTokenIdentifierProto identifierProto) { | ||
this.proto = identifierProto; | ||
viaProto = true; | ||
} | ||
|
||
public YARNDelegationTokenIdentifierProto getProto() { | ||
mergeLocalToProto(); | ||
proto = viaProto ? proto : builder.build(); | ||
viaProto = true; | ||
return proto; | ||
} | ||
|
||
private void mergeLocalToProto() { | ||
if (viaProto) { | ||
maybeInitBuilder(); | ||
} | ||
// mergeLocalToBuilder(); | ||
proto = builder.build(); | ||
viaProto = true; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return TextFormat.shortDebugString(getProto()); | ||
} | ||
|
||
private void maybeInitBuilder() { | ||
if (viaProto || builder == null) { | ||
if (proto == null) { | ||
proto = YARNDelegationTokenIdentifierProto.getDefaultInstance(); | ||
} | ||
builder = YARNDelegationTokenIdentifierProto.newBuilder(proto); | ||
} | ||
viaProto = false; | ||
} | ||
|
||
@Override | ||
public Text getOwner() { | ||
YARNDelegationTokenIdentifierProtoOrBuilder p = viaProto ? proto : builder; | ||
return new Text(p.getOwner()); | ||
} | ||
|
||
@Override | ||
public void setOwner(Text owner) { | ||
super.setOwner(owner); | ||
maybeInitBuilder(); | ||
if (owner == null) { | ||
builder.clearOwner(); | ||
return; | ||
} | ||
builder.setOwner(owner.toString()); | ||
} | ||
|
||
@Override | ||
public Text getRenewer() { | ||
YARNDelegationTokenIdentifierProtoOrBuilder p = viaProto ? proto : builder; | ||
return new Text(p.getRenewer()); | ||
} | ||
|
||
@Override | ||
public void setRenewer(Text renewer) { | ||
super.setRenewer(renewer); | ||
maybeInitBuilder(); | ||
if (renewer == null) { | ||
builder.clearRenewer(); | ||
return; | ||
} | ||
builder.setOwner(renewer.toString()); | ||
} | ||
|
||
@Override | ||
public Text getRealUser() { | ||
YARNDelegationTokenIdentifierProtoOrBuilder p = viaProto ? proto : builder; | ||
return new Text(p.getRealUser()); | ||
} | ||
|
||
@Override | ||
public void setRealUser(Text realUser) { | ||
super.setRealUser(realUser); | ||
maybeInitBuilder(); | ||
if (realUser == null) { | ||
builder.clearRealUser(); | ||
return; | ||
} | ||
builder.setRealUser(realUser.toString()); | ||
} | ||
|
||
@Override | ||
public void setIssueDate(long issueDate) { | ||
super.setIssueDate(issueDate); | ||
maybeInitBuilder(); | ||
builder.setIssueDate(issueDate); | ||
} | ||
|
||
@Override | ||
public long getIssueDate() { | ||
YARNDelegationTokenIdentifierProtoOrBuilder p = viaProto ? proto : builder; | ||
return p.getIssueDate(); | ||
} | ||
|
||
@Override | ||
public void setMaxDate(long maxDate) { | ||
super.setMaxDate(maxDate); | ||
maybeInitBuilder(); | ||
builder.setMaxDate(maxDate); | ||
} | ||
|
||
@Override | ||
public long getMaxDate() { | ||
YARNDelegationTokenIdentifierProtoOrBuilder p = viaProto ? proto : builder; | ||
return p.getMaxDate(); | ||
} | ||
|
||
@Override | ||
public void setSequenceNumber(int seqNum) { | ||
super.setSequenceNumber(seqNum); | ||
maybeInitBuilder(); | ||
builder.setSequenceNumber(seqNum); | ||
} | ||
|
||
@Override | ||
public int getSequenceNumber() { | ||
YARNDelegationTokenIdentifierProtoOrBuilder p = viaProto ? proto : builder; | ||
return p.getSequenceNumber(); | ||
} | ||
|
||
@Override | ||
public void setMasterKeyId(int newId) { | ||
super.setMasterKeyId(newId); | ||
maybeInitBuilder(); | ||
builder.setMasterKeyId(newId); | ||
} | ||
|
||
@Override | ||
public int getMasterKeyId() { | ||
YARNDelegationTokenIdentifierProtoOrBuilder p = viaProto ? proto : builder; | ||
return p.getMasterKeyId(); | ||
} | ||
|
||
@Override | ||
public Text getKind() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
if (other == null) { | ||
return false; | ||
} | ||
if (other.getClass().isAssignableFrom(this.getClass())) { | ||
return this.getProto().equals(this.getClass().cast(other).getProto()); | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return getProto().hashCode(); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...arn-common/src/main/java/org/apache/hadoop/yarn/security/client/impl/pb/package-info.java
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* 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. | ||
*/ | ||
@Public | ||
package org.apache.hadoop.yarn.security.client.impl.pb; | ||
import org.apache.hadoop.classification.InterfaceAudience.Public; |
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
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.
Do we have PBImpl tests?
It would be good to split the PR if possible.
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.
Thank you very much for your help reviewing the code, I will add PBImpl tests. This pr code is a bit too much, I will split this pr.