Skip to content

Commit

Permalink
YARN-9708. Fix CheckStyle.
Browse files Browse the repository at this point in the history
  • Loading branch information
slfan1989 committed Aug 14, 2022
1 parent 2ca1d47 commit 70d0c6a
Show file tree
Hide file tree
Showing 6 changed files with 265 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ public byte[] toByteArray() throws IOException {
public RMDelegationTokenIdentifier getTokenIdentifier() throws IOException {
ByteArrayInputStream in =
new ByteArrayInputStream(builder.getTokenIdentifier().toByteArray());
RMDelegationTokenIdentifier identifer = new RMDelegationTokenIdentifier();
identifer.readFields(new DataInputStream(in));
return identifer;
RMDelegationTokenIdentifier identifier = new RMDelegationTokenIdentifier();
identifier.readFields(new DataInputStream(in));
return identifier;
}

public Long getRenewDate() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,36 @@
*/
package org.apache.hadoop.yarn.server.federation.store.records.impl.pb;

import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.classification.InterfaceAudience.Private;
import org.apache.hadoop.classification.InterfaceStability.Unstable;
import org.apache.hadoop.thirdparty.protobuf.TextFormat;
import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.RouterMasterKeyProto;
import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.StoreNewMasterKeyRequestProto;
import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.StoreNewMasterKeyRequestProtoOrBuilder;
import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.RemoveStoredMasterKeyRequestProto;
import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.RemoveStoredMasterKeyRequestProtoOrBuilder;
import org.apache.hadoop.yarn.server.federation.store.records.RemoveStoredMasterKeyRequest;
import org.apache.hadoop.yarn.server.federation.store.records.RouterMasterKey;
import org.apache.hadoop.yarn.server.federation.store.records.StoreNewMasterKeyRequest;

@InterfaceAudience.Private
@InterfaceStability.Unstable
public class RemoveNewMasterKeyRequestPBImpl extends StoreNewMasterKeyRequest {
@Private
@Unstable
public class RemoveStoredMasterKeyRequestPBImpl extends RemoveStoredMasterKeyRequest {

private StoreNewMasterKeyRequestProto proto = StoreNewMasterKeyRequestProto.getDefaultInstance();
private RemoveStoredMasterKeyRequestProto proto = RemoveStoredMasterKeyRequestProto.getDefaultInstance();

private StoreNewMasterKeyRequestProto.Builder builder = null;
private RemoveStoredMasterKeyRequestProto.Builder builder = null;
private boolean viaProto = false;

private RouterMasterKey routerMasterKey = null;

public RemoveNewMasterKeyRequestPBImpl() {
builder = StoreNewMasterKeyRequestProto.newBuilder();
public RemoveStoredMasterKeyRequestPBImpl() {
builder = RemoveStoredMasterKeyRequestProto.newBuilder();
}

public RemoveNewMasterKeyRequestPBImpl(StoreNewMasterKeyRequestProto proto) {
public RemoveStoredMasterKeyRequestPBImpl(RemoveStoredMasterKeyRequestProto proto) {
this.proto = proto;
viaProto = true;
}

public StoreNewMasterKeyRequestProto getProto() {
public RemoveStoredMasterKeyRequestProto getProto() {
mergeLocalToProto();
proto = viaProto ? proto : builder.build();
viaProto = true;
Expand All @@ -63,7 +63,7 @@ private void mergeLocalToProto() {

private void maybeInitBuilder() {
if (viaProto || builder == null) {
builder = StoreNewMasterKeyRequestProto.newBuilder(proto);
builder = RemoveStoredMasterKeyRequestProto.newBuilder(proto);
}
viaProto = false;
}
Expand Down Expand Up @@ -100,7 +100,7 @@ public String toString() {

@Override
public RouterMasterKey getRouterMasterKey() {
StoreNewMasterKeyRequestProtoOrBuilder p = viaProto ? proto : builder;
RemoveStoredMasterKeyRequestProtoOrBuilder p = viaProto ? proto : builder;
if (this.routerMasterKey != null) {
return this.routerMasterKey;
}
Expand All @@ -116,6 +116,7 @@ public void setRouterMasterKey(RouterMasterKey masterKey) {
maybeInitBuilder();
if (masterKey == null) {
builder.clearRouterMasterKey();
return;
}
this.routerMasterKey = masterKey;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/**
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.server.federation.store.records.impl.pb;

import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos;
import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.RouterMasterKeyProto;
import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.RemoveStoredMasterKeyResponseProto;
import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.RemoveStoredMasterKeyResponseProtoOrBuilder;
import org.apache.hadoop.yarn.server.federation.store.records.RemoveStoredMasterKeyResponse;
import org.apache.hadoop.yarn.server.federation.store.records.RouterMasterKey;

public class RemoveStoredMasterKeyResponsePBImpl extends RemoveStoredMasterKeyResponse {

private RemoveStoredMasterKeyResponseProto proto =
RemoveStoredMasterKeyResponseProto.getDefaultInstance();

private RemoveStoredMasterKeyResponseProto.Builder builder = null;

private boolean viaProto = false;

private RouterMasterKey routerMasterKey = null;

public RemoveStoredMasterKeyResponsePBImpl() {
builder = RemoveStoredMasterKeyResponseProto.newBuilder();
}

public RemoveStoredMasterKeyResponsePBImpl(RemoveStoredMasterKeyResponseProto responseProto) {
this.proto = responseProto;
viaProto = true;
}

public RemoveStoredMasterKeyResponseProto getProto() {
mergeLocalToProto();
proto = viaProto ? proto : builder.build();
viaProto = true;
return proto;
}

private void mergeLocalToProto() {
if (viaProto) {
maybeInitBuilder();
}
mergeLocalToBuilder();
proto = builder.build();
viaProto = true;
}

private void maybeInitBuilder() {
if (viaProto || builder == null) {
builder = RemoveStoredMasterKeyResponseProto.newBuilder(proto);
}
viaProto = false;
}

private void mergeLocalToBuilder() {
if (this.routerMasterKey != null && !((RouterMasterKeyPBImpl) this.routerMasterKey).
getProto().equals(builder.getRouterMasterKey())) {
builder.setRouterMasterKey(convertToProtoFormat(this.routerMasterKey));
}
}

private YarnServerFederationProtos.RouterMasterKeyProto convertToProtoFormat(
RouterMasterKey masterKey) {
return ((RouterMasterKeyPBImpl) masterKey).getProto();
}


@Override
public RouterMasterKey getRouterMasterKey() {
RemoveStoredMasterKeyResponseProtoOrBuilder p = viaProto ? proto : builder;
if (this.routerMasterKey != null) {
return this.routerMasterKey;
}
if (!p.hasRouterMasterKey()) {
return null;
}
this.routerMasterKey = convertFromProtoFormat(p.getRouterMasterKey());
return this.routerMasterKey;
}

@Override
public void setRouterMasterKey(RouterMasterKey masterKey) {
maybeInitBuilder();
if (masterKey == null) {
builder.clearRouterMasterKey();
return;
}
this.routerMasterKey = masterKey;
}

private RouterMasterKey convertFromProtoFormat(RouterMasterKeyProto masterKey) {
return new RouterMasterKeyPBImpl(masterKey);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@
*/
package org.apache.hadoop.yarn.server.federation.store.records.impl.pb;

import org.apache.hadoop.classification.InterfaceAudience;
import org.apache.hadoop.classification.InterfaceStability;
import org.apache.hadoop.classification.InterfaceAudience.Private;
import org.apache.hadoop.classification.InterfaceStability.Unstable;
import org.apache.hadoop.thirdparty.protobuf.TextFormat;
import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.StoreNewMasterKeyRequestProto;
import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.RouterMasterKeyProto;
import org.apache.hadoop.yarn.server.federation.store.records.RouterMasterKey;
import org.apache.hadoop.yarn.server.federation.store.records.StoreNewMasterKeyRequest;
import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.StoreNewMasterKeyRequestProtoOrBuilder;

@InterfaceAudience.Private
@InterfaceStability.Unstable
@Private
@Unstable
public class StoreNewMasterKeyRequestPBImpl extends StoreNewMasterKeyRequest {

private StoreNewMasterKeyRequestProto proto = StoreNewMasterKeyRequestProto.getDefaultInstance();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/**
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.server.federation.store.records.impl.pb;

import org.apache.hadoop.classification.InterfaceAudience.Private;
import org.apache.hadoop.classification.InterfaceStability.Unstable;
import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.RouterMasterKeyProto;
import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.StoreNewMasterKeyResponseProto;
import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.StoreNewMasterKeyResponseProtoOrBuilder;
import org.apache.hadoop.yarn.server.federation.store.records.RouterMasterKey;
import org.apache.hadoop.yarn.server.federation.store.records.StoreNewMasterKeyResponse;

@Private
@Unstable
public class StoreNewMasterKeyResponsePBImpl extends StoreNewMasterKeyResponse {

private StoreNewMasterKeyResponseProto proto =
StoreNewMasterKeyResponseProto.getDefaultInstance();

private StoreNewMasterKeyResponseProto.Builder builder = null;

private boolean viaProto = false;

private RouterMasterKey routerMasterKey = null;

public StoreNewMasterKeyResponsePBImpl() {
builder = StoreNewMasterKeyResponseProto.newBuilder();
}

public StoreNewMasterKeyResponsePBImpl(StoreNewMasterKeyResponseProto responseProto) {
this.proto = responseProto;
viaProto = true;
}

public StoreNewMasterKeyResponseProto getProto() {
mergeLocalToProto();
proto = viaProto ? proto : builder.build();
viaProto = true;
return proto;
}

private void mergeLocalToProto() {
if (viaProto) {
maybeInitBuilder();
}
mergeLocalToBuilder();
proto = builder.build();
viaProto = true;
}

private void maybeInitBuilder() {
if (viaProto || builder == null) {
builder = StoreNewMasterKeyResponseProto.newBuilder(proto);
}
viaProto = false;
}

private void mergeLocalToBuilder() {
if (this.routerMasterKey != null && !((RouterMasterKeyPBImpl) this.routerMasterKey).
getProto().equals(builder.getRouterMasterKey())) {
builder.setRouterMasterKey(convertToProtoFormat(this.routerMasterKey));
}
}

@Override
public int hashCode() {
return getProto().hashCode();
}

@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;
}

private RouterMasterKeyProto convertToProtoFormat(
RouterMasterKey masterKey) {
return ((RouterMasterKeyPBImpl) masterKey).getProto();
}

@Override
public RouterMasterKey getRouterMasterKey() {
StoreNewMasterKeyResponseProtoOrBuilder p = viaProto ? proto : builder;
if (this.routerMasterKey != null) {
return this.routerMasterKey;
}
if (!p.hasRouterMasterKey()) {
return null;
}
this.routerMasterKey = convertFromProtoFormat(p.getRouterMasterKey());
return this.routerMasterKey;
}

@Override
public void setRouterMasterKey(RouterMasterKey masterKey) {
maybeInitBuilder();
if (masterKey == null) {
builder.clearRouterMasterKey();
return;
}
this.routerMasterKey = masterKey;
}

private RouterMasterKey convertFromProtoFormat(RouterMasterKeyProto masterKey) {
return new RouterMasterKeyPBImpl(masterKey);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.SubClusterRegisterResponseProto;
import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.UpdateApplicationHomeSubClusterRequestProto;
import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.UpdateApplicationHomeSubClusterResponseProto;
import org.apache.hadoop.yarn.federation.proto.YarnServerFederationProtos.StoreNewMasterKeyRequestProto;
import org.apache.hadoop.yarn.server.federation.store.records.impl.pb.AddApplicationHomeSubClusterRequestPBImpl;
import org.apache.hadoop.yarn.server.federation.store.records.impl.pb.AddApplicationHomeSubClusterResponsePBImpl;
import org.apache.hadoop.yarn.server.federation.store.records.impl.pb.DeleteApplicationHomeSubClusterRequestPBImpl;
Expand Down Expand Up @@ -75,6 +76,7 @@
import org.apache.hadoop.yarn.server.federation.store.records.impl.pb.SubClusterRegisterResponsePBImpl;
import org.apache.hadoop.yarn.server.federation.store.records.impl.pb.UpdateApplicationHomeSubClusterRequestPBImpl;
import org.apache.hadoop.yarn.server.federation.store.records.impl.pb.UpdateApplicationHomeSubClusterResponsePBImpl;
import org.apache.hadoop.yarn.server.federation.store.records.impl.pb.StoreNewMasterKeyRequestPBImpl;
import org.apache.hadoop.yarn.server.records.Version;
import org.junit.BeforeClass;
import org.junit.Test;
Expand Down Expand Up @@ -262,4 +264,9 @@ public void testGetSubClusterPoliciesConfigurationsResponse()
GetSubClusterPoliciesConfigurationsResponsePBImpl.class,
GetSubClusterPoliciesConfigurationsResponseProto.class);
}

@Test
public void testStoreNewMasterKeyRequest() throws Exception {

}
}

0 comments on commit 70d0c6a

Please sign in to comment.