-
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
Changes from 10 commits
d02516c
690c035
8dfa838
b00e0a1
a8ec3f5
9e6760b
e945c64
c970950
7a2d1e2
1b8690e
1b918a4
745c5b8
0a30fe0
414140c
ca65a32
666853d
bba520a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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; | ||
import org.apache.hadoop.classification.InterfaceStability; | ||
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; | ||
|
||
@InterfaceAudience.Private | ||
@InterfaceStability.Unstable | ||
public class YARNDelegationTokenIdentifierPBImpl extends YARNDelegationTokenIdentifier { | ||
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. Do we have PBImpl tests? 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. 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. |
||
|
||
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(); | ||
} | ||
} |
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. | ||
*/ | ||
@InterfaceAudience.Public | ||
package org.apache.hadoop.yarn.security.client.impl.pb; | ||
import org.apache.hadoop.classification.InterfaceAudience; | ||
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. Import Public 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. I will modify the code. |
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.
Import these things directly
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 fix it.