Skip to content

Commit 93bb368

Browse files
committed
HDFS-14983. RBF: Add dfsrouteradmin -refreshSuperUserGroupsConfiguration command option. Contributed by Xieming Li
1 parent b56c08b commit 93bb368

15 files changed

+561
-3
lines changed

hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/protocolPB/RouterAdminProtocol.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.apache.hadoop.classification.InterfaceAudience;
2121
import org.apache.hadoop.classification.InterfaceStability;
2222
import org.apache.hadoop.hdfs.server.federation.resolver.MountTableManager;
23+
import org.apache.hadoop.hdfs.server.federation.resolver.RouterGenericManager;
2324
import org.apache.hadoop.hdfs.server.federation.router.NameserviceManager;
2425
import org.apache.hadoop.hdfs.server.federation.router.RouterStateManager;
2526
import org.apache.hadoop.ipc.GenericRefreshProtocol;
@@ -30,5 +31,6 @@
3031
@InterfaceAudience.Private
3132
@InterfaceStability.Stable
3233
public interface RouterAdminProtocol extends MountTableManager,
33-
RouterStateManager, NameserviceManager, GenericRefreshProtocol {
34+
RouterStateManager, NameserviceManager, GenericRefreshProtocol,
35+
RouterGenericManager {
3436
}

hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/protocolPB/RouterAdminProtocolServerSideTranslatorPB.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.RemoveMountTableEntryResponseProto;
4646
import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.UpdateMountTableEntryRequestProto;
4747
import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.UpdateMountTableEntryResponseProto;
48+
import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.RefreshSuperUserGroupsConfigurationRequestProto;
49+
import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.RefreshSuperUserGroupsConfigurationResponseProto;
4850
import org.apache.hadoop.hdfs.server.federation.router.RouterAdminServer;
4951
import org.apache.hadoop.hdfs.server.federation.store.protocol.AddMountTableEntryRequest;
5052
import org.apache.hadoop.hdfs.server.federation.store.protocol.AddMountTableEntryResponse;
@@ -54,6 +56,7 @@
5456
import org.apache.hadoop.hdfs.server.federation.store.protocol.EnableNameserviceResponse;
5557
import org.apache.hadoop.hdfs.server.federation.store.protocol.EnterSafeModeRequest;
5658
import org.apache.hadoop.hdfs.server.federation.store.protocol.EnterSafeModeResponse;
59+
import org.apache.hadoop.hdfs.server.federation.store.protocol.RefreshSuperUserGroupsConfigurationResponse;
5760
import org.apache.hadoop.hdfs.server.federation.store.protocol.GetDisabledNameservicesRequest;
5861
import org.apache.hadoop.hdfs.server.federation.store.protocol.GetDisabledNameservicesResponse;
5962
import org.apache.hadoop.hdfs.server.federation.store.protocol.GetDestinationRequest;
@@ -90,6 +93,7 @@
9093
import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.LeaveSafeModeResponsePBImpl;
9194
import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.RefreshMountTableEntriesRequestPBImpl;
9295
import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.RefreshMountTableEntriesResponsePBImpl;
96+
import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.RefreshSuperUserGroupsConfigurationResponsePBImpl;
9397
import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.RemoveMountTableEntryRequestPBImpl;
9498
import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.RemoveMountTableEntryResponsePBImpl;
9599
import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.UpdateMountTableEntryRequestPBImpl;
@@ -197,6 +201,28 @@ public UpdateMountTableEntryResponseProto updateMountTableEntry(
197201
}
198202
}
199203

204+
/**
205+
* Refresh superuser proxy groups mappings.
206+
*/
207+
@Override
208+
public RefreshSuperUserGroupsConfigurationResponseProto
209+
refreshSuperUserGroupsConfiguration(
210+
RpcController controller,
211+
RefreshSuperUserGroupsConfigurationRequestProto request)
212+
throws ServiceException {
213+
try {
214+
boolean result = server.refreshSuperUserGroupsConfiguration();
215+
RefreshSuperUserGroupsConfigurationResponse response =
216+
RefreshSuperUserGroupsConfigurationResponsePBImpl.newInstance(result);
217+
RefreshSuperUserGroupsConfigurationResponsePBImpl responsePB =
218+
(RefreshSuperUserGroupsConfigurationResponsePBImpl) response;
219+
return responsePB.getProto();
220+
} catch (IOException e) {
221+
throw new ServiceException(e);
222+
}
223+
}
224+
225+
200226
@Override
201227
public EnterSafeModeResponseProto enterSafeMode(RpcController controller,
202228
EnterSafeModeRequestProto request) throws ServiceException {

hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/protocolPB/RouterAdminProtocolTranslatorPB.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,14 @@
4242
import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.LeaveSafeModeResponseProto;
4343
import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.RefreshMountTableEntriesRequestProto;
4444
import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.RefreshMountTableEntriesResponseProto;
45+
import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.RefreshSuperUserGroupsConfigurationRequestProto;
46+
import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.RefreshSuperUserGroupsConfigurationResponseProto;
4547
import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.RemoveMountTableEntryRequestProto;
4648
import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.RemoveMountTableEntryResponseProto;
4749
import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.UpdateMountTableEntryRequestProto;
4850
import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.UpdateMountTableEntryResponseProto;
4951
import org.apache.hadoop.hdfs.server.federation.resolver.MountTableManager;
52+
import org.apache.hadoop.hdfs.server.federation.resolver.RouterGenericManager;
5053
import org.apache.hadoop.hdfs.server.federation.router.NameserviceManager;
5154
import org.apache.hadoop.hdfs.server.federation.router.RouterStateManager;
5255
import org.apache.hadoop.hdfs.server.federation.store.protocol.AddMountTableEntryRequest;
@@ -89,6 +92,7 @@
8992
import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.LeaveSafeModeResponsePBImpl;
9093
import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.RefreshMountTableEntriesRequestPBImpl;
9194
import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.RefreshMountTableEntriesResponsePBImpl;
95+
import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.RefreshSuperUserGroupsConfigurationResponsePBImpl;
9296
import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.RemoveMountTableEntryRequestPBImpl;
9397
import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.RemoveMountTableEntryResponsePBImpl;
9498
import org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb.UpdateMountTableEntryRequestPBImpl;
@@ -110,7 +114,8 @@
110114
@InterfaceStability.Stable
111115
public class RouterAdminProtocolTranslatorPB
112116
implements ProtocolMetaInterface, MountTableManager,
113-
Closeable, ProtocolTranslator, RouterStateManager, NameserviceManager {
117+
Closeable, ProtocolTranslator, RouterStateManager, NameserviceManager,
118+
RouterGenericManager {
114119
final private RouterAdminProtocolPB rpcProxy;
115120

116121
public RouterAdminProtocolTranslatorPB(RouterAdminProtocolPB proxy) {
@@ -309,4 +314,18 @@ public GetDestinationResponse getDestination(
309314
throw new IOException(ProtobufHelper.getRemoteException(e).getMessage());
310315
}
311316
}
317+
318+
@Override
319+
public boolean refreshSuperUserGroupsConfiguration() throws IOException {
320+
RefreshSuperUserGroupsConfigurationRequestProto proto =
321+
RefreshSuperUserGroupsConfigurationRequestProto.newBuilder().build();
322+
try {
323+
RefreshSuperUserGroupsConfigurationResponseProto response =
324+
rpcProxy.refreshSuperUserGroupsConfiguration(null, proto);
325+
return new RefreshSuperUserGroupsConfigurationResponsePBImpl(response)
326+
.getStatus();
327+
} catch (ServiceException e) {
328+
throw new IOException(ProtobufHelper.getRemoteException(e).getMessage());
329+
}
330+
}
312331
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package org.apache.hadoop.hdfs.server.federation.resolver;
19+
20+
import java.io.IOException;
21+
22+
/**
23+
* Generic methods for managing Router.
24+
*/
25+
public interface RouterGenericManager {
26+
/**
27+
* Refresh superuser proxy groups mappings (used in RBF).
28+
* @return true if the operation was successful.
29+
* @throws IOException if operation was not successful.
30+
*/
31+
boolean refreshSuperUserGroupsConfiguration() throws IOException;
32+
}

hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterAdminServer.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
import org.apache.hadoop.ipc.protocolPB.GenericRefreshProtocolServerSideTranslatorPB;
8585
import org.apache.hadoop.security.AccessControlException;
8686
import org.apache.hadoop.security.UserGroupInformation;
87+
import org.apache.hadoop.security.authorize.ProxyUsers;
8788
import org.apache.hadoop.service.AbstractService;
8889
import org.slf4j.Logger;
8990
import org.slf4j.LoggerFactory;
@@ -619,4 +620,10 @@ public Collection<RefreshResponse> refresh(String identifier, String[] args) {
619620
// Let the registry handle as needed
620621
return RefreshRegistry.defaultRegistry().dispatch(identifier, args);
621622
}
623+
624+
@Override // RouterGenericManager
625+
public boolean refreshSuperUserGroupsConfiguration() throws IOException {
626+
ProxyUsers.refreshSuperUserGroupsConfiguration();
627+
return true;
628+
}
622629
}

hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterClient.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.apache.hadoop.hdfs.protocolPB.RouterAdminProtocolPB;
2828
import org.apache.hadoop.hdfs.protocolPB.RouterAdminProtocolTranslatorPB;
2929
import org.apache.hadoop.hdfs.server.federation.resolver.MountTableManager;
30+
import org.apache.hadoop.hdfs.server.federation.resolver.RouterGenericManager;
3031
import org.apache.hadoop.ipc.ProtobufRpcEngine;
3132
import org.apache.hadoop.ipc.RPC;
3233
import org.apache.hadoop.net.NetUtils;
@@ -77,6 +78,10 @@ public NameserviceManager getNameserviceManager() {
7778
return proxy;
7879
}
7980

81+
public RouterGenericManager getRouterGenericManager() {
82+
return proxy;
83+
}
84+
8085
@Override
8186
public synchronized void close() throws IOException {
8287
RPC.stopProxy(proxy);
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package org.apache.hadoop.hdfs.server.federation.store.protocol;
19+
20+
import java.io.IOException;
21+
22+
import org.apache.hadoop.hdfs.server.federation.store.driver.StateStoreSerializer;
23+
24+
/**
25+
* API request for refreshing super user groups on router.
26+
*/
27+
public abstract class RefreshSuperUserGroupsConfigurationRequest {
28+
public static RefreshSuperUserGroupsConfigurationRequest newInstance()
29+
throws IOException {
30+
return StateStoreSerializer
31+
.newRecord(RefreshSuperUserGroupsConfigurationRequest.class);
32+
}
33+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package org.apache.hadoop.hdfs.server.federation.store.protocol;
19+
20+
import java.io.IOException;
21+
22+
import org.apache.hadoop.classification.InterfaceAudience.Public;
23+
import org.apache.hadoop.classification.InterfaceStability.Unstable;
24+
import org.apache.hadoop.hdfs.server.federation.store.driver.StateStoreSerializer;
25+
26+
/**
27+
* API response for refreshing super user groups on router.
28+
*/
29+
public abstract class RefreshSuperUserGroupsConfigurationResponse {
30+
31+
public static RefreshSuperUserGroupsConfigurationResponse newInstance()
32+
throws IOException {
33+
return StateStoreSerializer.
34+
newRecord(RefreshSuperUserGroupsConfigurationResponse.class);
35+
}
36+
37+
public static RefreshSuperUserGroupsConfigurationResponse
38+
newInstance(boolean status) throws IOException {
39+
RefreshSuperUserGroupsConfigurationResponse response = newInstance();
40+
response.setStatus(status);
41+
return response;
42+
}
43+
44+
@Public
45+
@Unstable
46+
public abstract boolean getStatus();
47+
48+
@Public
49+
@Unstable
50+
public abstract void setStatus(boolean result);
51+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package org.apache.hadoop.hdfs.server.federation.store.protocol.impl.pb;
19+
20+
import com.google.protobuf.Message;
21+
import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.RefreshSuperUserGroupsConfigurationRequestProto;
22+
import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.RefreshSuperUserGroupsConfigurationRequestProtoOrBuilder;
23+
import org.apache.hadoop.hdfs.federation.protocol.proto.HdfsServerFederationProtos.RefreshSuperUserGroupsConfigurationRequestProto.Builder;
24+
import org.apache.hadoop.hdfs.server.federation.store.protocol.RefreshSuperUserGroupsConfigurationRequest;
25+
import org.apache.hadoop.hdfs.server.federation.store.records.impl.pb.PBRecord;
26+
27+
import java.io.IOException;
28+
29+
/**
30+
* Protobuf implementation of the state store API object
31+
* RefreshSuperUserGroupsConfigurationRequest.
32+
*/
33+
public class RefreshSuperUserGroupsConfigurationRequestPBImpl
34+
extends RefreshSuperUserGroupsConfigurationRequest
35+
implements PBRecord {
36+
37+
private FederationProtocolPBTranslator<
38+
RefreshSuperUserGroupsConfigurationRequestProto, Builder,
39+
RefreshSuperUserGroupsConfigurationRequestProtoOrBuilder> translator =
40+
new FederationProtocolPBTranslator<>(
41+
RefreshSuperUserGroupsConfigurationRequestProto.class);
42+
43+
public RefreshSuperUserGroupsConfigurationRequestPBImpl() {
44+
}
45+
46+
public RefreshSuperUserGroupsConfigurationRequestPBImpl(
47+
RefreshSuperUserGroupsConfigurationRequestProto proto) {
48+
this.translator.setProto(proto);
49+
}
50+
51+
@Override
52+
public RefreshSuperUserGroupsConfigurationRequestProto getProto() {
53+
this.translator.getBuilder();
54+
return this.translator.build();
55+
}
56+
57+
@Override
58+
public void setProto(Message proto) {
59+
this.translator.setProto(proto);
60+
}
61+
62+
@Override
63+
public void readInstance(String base64String) throws IOException {
64+
this.translator.readInstance(base64String);
65+
}
66+
}

0 commit comments

Comments
 (0)