Skip to content

Commit c6fbc69

Browse files
committed
HADOOP-10285. Admin interface to swap callqueue at runtime. (Contributed by Chris Li)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1573052 13f79535-47bb-0310-9956-ffa450edef68
1 parent 18b64d9 commit c6fbc69

File tree

14 files changed

+365
-1
lines changed

14 files changed

+365
-1
lines changed

hadoop-common-project/hadoop-common/CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,9 @@ Release 2.5.0 - UNRELEASED
314314
HADOOP-10278. Refactor to make CallQueue pluggable. (Chris Li via
315315
Arpit Agarwal)
316316

317+
HADOOP-10285. Admin interface to swap callqueue at runtime. (Chris Li via
318+
Arpit Agarwal)
319+
317320
OPTIMIZATIONS
318321

319322
BUG FIXES

hadoop-common-project/hadoop-common/dev-support/findbugsExcludeFile.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,10 @@
301301
<!-- protobuf generated code -->
302302
<Class name="~org\.apache\.hadoop\.ipc\.protobuf\.TestProtos.*"/>
303303
</Match>
304+
<Match>
305+
<!-- protobuf generated code -->
306+
<Class name="~org\.apache\.hadoop\.ipc\.proto\.RefreshCallQueueProtocolProtos.*"/>
307+
</Match>
304308

305309
<!--
306310
Manually checked, misses child thread manually syncing on parent's intrinsic lock.

hadoop-common-project/hadoop-common/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@
337337
<include>GetUserMappingsProtocol.proto</include>
338338
<include>RefreshAuthorizationPolicyProtocol.proto</include>
339339
<include>RefreshUserMappingsProtocol.proto</include>
340+
<include>RefreshCallQueueProtocol.proto</include>
340341
</includes>
341342
</source>
342343
<output>${project.build.directory}/generated-sources/java</output>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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.ipc;
19+
20+
import java.io.IOException;
21+
22+
import org.apache.hadoop.classification.InterfaceAudience;
23+
import org.apache.hadoop.classification.InterfaceStability;
24+
import org.apache.hadoop.fs.CommonConfigurationKeys;
25+
import org.apache.hadoop.io.retry.Idempotent;
26+
import org.apache.hadoop.security.KerberosInfo;
27+
28+
/**
29+
* Protocol which is used to refresh the call queue in use currently.
30+
*/
31+
@KerberosInfo(
32+
serverPrincipal=CommonConfigurationKeys.HADOOP_SECURITY_SERVICE_USER_NAME_KEY)
33+
@InterfaceAudience.LimitedPrivate({"HDFS"})
34+
@InterfaceStability.Evolving
35+
public interface RefreshCallQueueProtocol {
36+
37+
/**
38+
* Version 1: Initial version
39+
*/
40+
public static final long versionID = 1L;
41+
42+
/**
43+
* Refresh the callqueue.
44+
* @throws IOException
45+
*/
46+
@Idempotent
47+
void refreshCallQueue() throws IOException;
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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+
19+
package org.apache.hadoop.ipc.protocolPB;
20+
21+
import java.io.Closeable;
22+
import java.io.IOException;
23+
24+
import org.apache.hadoop.ipc.ProtobufHelper;
25+
import org.apache.hadoop.ipc.ProtocolMetaInterface;
26+
import org.apache.hadoop.ipc.RPC;
27+
import org.apache.hadoop.ipc.RpcClientUtil;
28+
import org.apache.hadoop.ipc.RefreshCallQueueProtocol;
29+
import org.apache.hadoop.ipc.proto.RefreshCallQueueProtocolProtos.RefreshCallQueueRequestProto;
30+
import org.apache.hadoop.ipc.protocolPB.RefreshCallQueueProtocolPB;
31+
32+
import com.google.protobuf.RpcController;
33+
import com.google.protobuf.ServiceException;
34+
35+
public class RefreshCallQueueProtocolClientSideTranslatorPB implements
36+
ProtocolMetaInterface, RefreshCallQueueProtocol, Closeable {
37+
38+
/** RpcController is not used and hence is set to null */
39+
private final static RpcController NULL_CONTROLLER = null;
40+
private final RefreshCallQueueProtocolPB rpcProxy;
41+
42+
private final static RefreshCallQueueRequestProto
43+
VOID_REFRESH_CALL_QUEUE_REQUEST =
44+
RefreshCallQueueRequestProto.newBuilder().build();
45+
46+
public RefreshCallQueueProtocolClientSideTranslatorPB(
47+
RefreshCallQueueProtocolPB rpcProxy) {
48+
this.rpcProxy = rpcProxy;
49+
}
50+
51+
@Override
52+
public void close() throws IOException {
53+
RPC.stopProxy(rpcProxy);
54+
}
55+
56+
@Override
57+
public void refreshCallQueue() throws IOException {
58+
try {
59+
rpcProxy.refreshCallQueue(NULL_CONTROLLER,
60+
VOID_REFRESH_CALL_QUEUE_REQUEST);
61+
} catch (ServiceException se) {
62+
throw ProtobufHelper.getRemoteException(se);
63+
}
64+
}
65+
66+
@Override
67+
public boolean isMethodSupported(String methodName) throws IOException {
68+
return RpcClientUtil.isMethodSupported(rpcProxy,
69+
RefreshCallQueueProtocolPB.class,
70+
RPC.RpcKind.RPC_PROTOCOL_BUFFER,
71+
RPC.getProtocolVersion(RefreshCallQueueProtocolPB.class),
72+
methodName);
73+
}
74+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
19+
package org.apache.hadoop.ipc.protocolPB;
20+
21+
import org.apache.hadoop.classification.InterfaceAudience;
22+
import org.apache.hadoop.classification.InterfaceStability;
23+
import org.apache.hadoop.fs.CommonConfigurationKeys;
24+
import org.apache.hadoop.ipc.ProtocolInfo;
25+
import org.apache.hadoop.security.KerberosInfo;
26+
import org.apache.hadoop.ipc.proto.RefreshCallQueueProtocolProtos.RefreshCallQueueProtocolService;
27+
28+
@KerberosInfo(
29+
serverPrincipal=CommonConfigurationKeys.HADOOP_SECURITY_SERVICE_USER_NAME_KEY)
30+
@ProtocolInfo(
31+
protocolName = "org.apache.hadoop.ipc.RefreshCallQueueProtocol",
32+
protocolVersion = 1)
33+
@InterfaceAudience.LimitedPrivate({"HDFS"})
34+
@InterfaceStability.Evolving
35+
public interface RefreshCallQueueProtocolPB extends
36+
RefreshCallQueueProtocolService.BlockingInterface {
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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+
19+
package org.apache.hadoop.ipc.protocolPB;
20+
21+
import java.io.IOException;
22+
23+
import org.apache.hadoop.ipc.RefreshCallQueueProtocol;
24+
import org.apache.hadoop.ipc.proto.RefreshCallQueueProtocolProtos.RefreshCallQueueRequestProto;
25+
import org.apache.hadoop.ipc.proto.RefreshCallQueueProtocolProtos.RefreshCallQueueResponseProto;
26+
27+
import com.google.protobuf.RpcController;
28+
import com.google.protobuf.ServiceException;
29+
30+
public class RefreshCallQueueProtocolServerSideTranslatorPB implements
31+
RefreshCallQueueProtocolPB {
32+
33+
private final RefreshCallQueueProtocol impl;
34+
35+
private final static RefreshCallQueueResponseProto
36+
VOID_REFRESH_CALL_QUEUE_RESPONSE = RefreshCallQueueResponseProto
37+
.newBuilder().build();
38+
39+
public RefreshCallQueueProtocolServerSideTranslatorPB(
40+
RefreshCallQueueProtocol impl) {
41+
this.impl = impl;
42+
}
43+
44+
@Override
45+
public RefreshCallQueueResponseProto refreshCallQueue(
46+
RpcController controller, RefreshCallQueueRequestProto request)
47+
throws ServiceException {
48+
try {
49+
impl.refreshCallQueue();
50+
} catch (IOException e) {
51+
throw new ServiceException(e);
52+
}
53+
return VOID_REFRESH_CALL_QUEUE_RESPONSE;
54+
}
55+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
19+
/**
20+
* These .proto interfaces are private and stable.
21+
* Please see http://wiki.apache.org/hadoop/Compatibility
22+
* for what changes are allowed for a *stable* .proto interface.
23+
*/
24+
25+
option java_package = "org.apache.hadoop.ipc.proto";
26+
option java_outer_classname = "RefreshCallQueueProtocolProtos";
27+
option java_generic_services = true;
28+
option java_generate_equals_and_hash = true;
29+
package hadoop.common;
30+
31+
/**
32+
* Refresh callqueue request.
33+
*/
34+
message RefreshCallQueueRequestProto {
35+
}
36+
37+
/**
38+
* void response.
39+
*/
40+
message RefreshCallQueueResponseProto {
41+
}
42+
43+
/**
44+
* Protocol which is used to refresh the callqueue.
45+
*/
46+
service RefreshCallQueueProtocolService {
47+
/**
48+
* Refresh the callqueue.
49+
*/
50+
rpc refreshCallQueue(RefreshCallQueueRequestProto)
51+
returns(RefreshCallQueueResponseProto);
52+
}

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/NameNodeProxies.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@
7575
import org.apache.hadoop.security.protocolPB.RefreshAuthorizationPolicyProtocolPB;
7676
import org.apache.hadoop.security.protocolPB.RefreshUserMappingsProtocolClientSideTranslatorPB;
7777
import org.apache.hadoop.security.protocolPB.RefreshUserMappingsProtocolPB;
78+
import org.apache.hadoop.ipc.RefreshCallQueueProtocol;
79+
import org.apache.hadoop.ipc.protocolPB.RefreshCallQueueProtocolPB;
80+
import org.apache.hadoop.ipc.protocolPB.RefreshCallQueueProtocolClientSideTranslatorPB;
7881
import org.apache.hadoop.tools.GetUserMappingsProtocol;
7982
import org.apache.hadoop.tools.protocolPB.GetUserMappingsProtocolClientSideTranslatorPB;
8083
import org.apache.hadoop.tools.protocolPB.GetUserMappingsProtocolPB;
@@ -252,13 +255,16 @@ public static <T> ProxyAndInfo<T> createNonHAProxy(
252255
} else if (xface == RefreshAuthorizationPolicyProtocol.class) {
253256
proxy = (T) createNNProxyWithRefreshAuthorizationPolicyProtocol(nnAddr,
254257
conf, ugi);
258+
} else if (xface == RefreshCallQueueProtocol.class) {
259+
proxy = (T) createNNProxyWithRefreshCallQueueProtocol(nnAddr, conf, ugi);
255260
} else {
256-
String message = "Upsupported protocol found when creating the proxy " +
261+
String message = "Unsupported protocol found when creating the proxy " +
257262
"connection to NameNode: " +
258263
((xface != null) ? xface.getClass().getName() : "null");
259264
LOG.error(message);
260265
throw new IllegalStateException(message);
261266
}
267+
262268
return new ProxyAndInfo<T>(proxy, dtService);
263269
}
264270

@@ -286,6 +292,14 @@ private static JournalProtocol createNNProxyWithJournalProtocol(
286292
return new RefreshUserMappingsProtocolClientSideTranslatorPB(proxy);
287293
}
288294

295+
private static RefreshCallQueueProtocol
296+
createNNProxyWithRefreshCallQueueProtocol(InetSocketAddress address,
297+
Configuration conf, UserGroupInformation ugi) throws IOException {
298+
RefreshCallQueueProtocolPB proxy = (RefreshCallQueueProtocolPB)
299+
createNameNodeProxy(address, conf, ugi, RefreshCallQueueProtocolPB.class, 0);
300+
return new RefreshCallQueueProtocolClientSideTranslatorPB(proxy);
301+
}
302+
289303
private static GetUserMappingsProtocol createNNProxyWithGetUserMappingsProtocol(
290304
InetSocketAddress address, Configuration conf, UserGroupInformation ugi)
291305
throws IOException {

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
import org.apache.hadoop.security.SecurityUtil;
5757
import org.apache.hadoop.security.UserGroupInformation;
5858
import org.apache.hadoop.security.authorize.RefreshAuthorizationPolicyProtocol;
59+
import org.apache.hadoop.ipc.RefreshCallQueueProtocol;
5960
import org.apache.hadoop.tools.GetUserMappingsProtocol;
6061
import org.apache.hadoop.util.ExitUtil.ExitException;
6162
import org.apache.hadoop.util.GenericOptionsParser;
@@ -224,6 +225,8 @@ public long getProtocolVersion(String protocol,
224225
return RefreshAuthorizationPolicyProtocol.versionID;
225226
} else if (protocol.equals(RefreshUserMappingsProtocol.class.getName())){
226227
return RefreshUserMappingsProtocol.versionID;
228+
} else if (protocol.equals(RefreshCallQueueProtocol.class.getName())) {
229+
return RefreshCallQueueProtocol.versionID;
227230
} else if (protocol.equals(GetUserMappingsProtocol.class.getName())){
228231
return GetUserMappingsProtocol.versionID;
229232
} else {

0 commit comments

Comments
 (0)