You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ji...@apache.org on 2017/09/05 05:10:44 UTC
[20/51] [abbrv] hadoop git commit: YARN-7050. Post cleanup after
YARN-6903, removal of org.apache.slider package. Contributed by Jian He
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bf581071/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/rpc/SliderClusterProtocolProxy.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/rpc/SliderClusterProtocolProxy.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/rpc/SliderClusterProtocolProxy.java
deleted file mode 100644
index 2e40a9b..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/rpc/SliderClusterProtocolProxy.java
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
- * 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.slider.server.appmaster.rpc;
-
-import com.google.common.base.Preconditions;
-import com.google.protobuf.RpcController;
-import com.google.protobuf.ServiceException;
-import org.apache.hadoop.ipc.ProtobufHelper;
-import org.apache.hadoop.ipc.ProtocolSignature;
-import org.apache.hadoop.ipc.RPC;
-import org.apache.hadoop.ipc.RemoteException;
-import org.apache.hadoop.yarn.exceptions.YarnException;
-import org.apache.slider.api.SliderClusterProtocol;
-import org.apache.slider.api.proto.Messages;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-
-public class SliderClusterProtocolProxy implements SliderClusterProtocol {
-
- private static final RpcController NULL_CONTROLLER = null;
- private final SliderClusterProtocolPB endpoint;
- private final InetSocketAddress address;
-
- public SliderClusterProtocolProxy(SliderClusterProtocolPB endpoint,
- InetSocketAddress address) {
- Preconditions.checkArgument(endpoint != null, "null endpoint");
- Preconditions.checkNotNull(address != null, "null address");
- this.endpoint = endpoint;
- this.address = address;
- }
-
- @Override
- public String toString() {
- final StringBuilder sb =
- new StringBuilder("SliderClusterProtocolProxy{");
- sb.append("address=").append(address);
- sb.append('}');
- return sb.toString();
- }
-
- @Override
- public ProtocolSignature getProtocolSignature(String protocol,
- long clientVersion,
- int clientMethodsHash)
- throws IOException {
- if (!protocol.equals(RPC.getProtocolName(SliderClusterProtocolPB.class))) {
- throw new IOException("Serverside implements " +
- RPC.getProtocolName(SliderClusterProtocolPB.class) +
- ". The following requested protocol is unknown: " +
- protocol);
- }
-
- return ProtocolSignature.getProtocolSignature(clientMethodsHash,
- RPC.getProtocolVersion(
- SliderClusterProtocol.class),
- SliderClusterProtocol.class);
- }
-
- @Override
- public long getProtocolVersion(String protocol, long clientVersion)
- throws IOException {
- return SliderClusterProtocol.versionID;
- }
-
- private IOException convert(ServiceException se) {
- IOException ioe = ProtobufHelper.getRemoteException(se);
- if (ioe instanceof RemoteException) {
- RemoteException remoteException = (RemoteException) ioe;
- return remoteException.unwrapRemoteException();
- }
- return ioe;
- }
-
- @Override public Messages.StopClusterResponseProto stopCluster(
- Messages.StopClusterRequestProto request)
- throws IOException, YarnException {
- try {
- return endpoint.stopCluster(NULL_CONTROLLER, request);
- } catch (ServiceException e) {
- throw convert(e);
- }
- }
-
- @Override
- public Messages.UpgradeContainersResponseProto upgradeContainers(
- Messages.UpgradeContainersRequestProto request) throws IOException,
- YarnException {
- try {
- return endpoint.upgradeContainers(NULL_CONTROLLER, request);
- } catch (ServiceException e) {
- throw convert(e);
- }
- }
-
- @Override
- public Messages.FlexComponentsResponseProto flexComponents(
- Messages.FlexComponentsRequestProto request) throws IOException {
- try {
- return endpoint.flexComponents(NULL_CONTROLLER, request);
- } catch (ServiceException e) {
- throw convert(e);
- }
- }
-
- @Override
- public Messages.GetJSONClusterStatusResponseProto getJSONClusterStatus(
- Messages.GetJSONClusterStatusRequestProto request) throws
- IOException,
- YarnException {
- try {
- return endpoint.getJSONClusterStatus(NULL_CONTROLLER, request);
- } catch (ServiceException e) {
- throw convert(e);
- }
- }
-
- @Override
- public Messages.ListNodeUUIDsByRoleResponseProto listNodeUUIDsByRole(Messages.ListNodeUUIDsByRoleRequestProto request) throws
- IOException,
- YarnException {
- try {
- return endpoint.listNodeUUIDsByRole(NULL_CONTROLLER, request);
- } catch (ServiceException e) {
- throw convert(e);
- }
- }
-
- @Override
- public Messages.GetNodeResponseProto getNode(Messages.GetNodeRequestProto request) throws
- IOException,
- YarnException {
- try {
- return endpoint.getNode(NULL_CONTROLLER, request);
- } catch (ServiceException e) {
- throw convert(e);
- }
- }
-
- @Override
- public Messages.GetClusterNodesResponseProto getClusterNodes(Messages.GetClusterNodesRequestProto request) throws
- IOException,
- YarnException {
- try {
- return endpoint.getClusterNodes(NULL_CONTROLLER, request);
- } catch (ServiceException e) {
- throw convert(e);
- }
- }
-
-
- @Override
- public Messages.EchoResponseProto echo(Messages.EchoRequestProto request) throws
- IOException,
- YarnException {
- try {
- return endpoint.echo(NULL_CONTROLLER, request);
- } catch (ServiceException e) {
- throw convert(e);
- }
- }
-
-
- @Override
- public Messages.KillContainerResponseProto killContainer(Messages.KillContainerRequestProto request) throws
- IOException,
- YarnException {
- try {
- return endpoint.killContainer(NULL_CONTROLLER, request);
- } catch (ServiceException e) {
- throw convert(e);
- }
- }
-
- @Override
- public Messages.AMSuicideResponseProto amSuicide(Messages.AMSuicideRequestProto request) throws
- IOException {
- try {
- return endpoint.amSuicide(NULL_CONTROLLER, request);
- } catch (ServiceException e) {
- throw convert(e);
- }
- }
-
- @Override
- public Messages.ApplicationLivenessInformationProto getLivenessInformation(
- Messages.GetApplicationLivenessRequestProto request) throws IOException {
- try {
- return endpoint.getLivenessInformation(NULL_CONTROLLER, request);
- } catch (ServiceException e) {
- throw convert(e);
- }
- }
-
- @Override
- public Messages.GetLiveContainersResponseProto getLiveContainers(Messages.GetLiveContainersRequestProto request) throws
- IOException {
- try {
- return endpoint.getLiveContainers(NULL_CONTROLLER, request);
- } catch (ServiceException e) {
- throw convert(e);
- }
- }
-
- @Override
- public Messages.ContainerInformationProto getLiveContainer(Messages.GetLiveContainerRequestProto request) throws
- IOException {
- try {
- return endpoint.getLiveContainer(NULL_CONTROLLER, request);
- } catch (ServiceException e) {
- throw convert(e);
- }
- }
-
- @Override
- public Messages.GetLiveComponentsResponseProto getLiveComponents(Messages.GetLiveComponentsRequestProto request) throws
- IOException {
- try {
- return endpoint.getLiveComponents(NULL_CONTROLLER, request);
- } catch (ServiceException e) {
- throw convert(e);
- }
- }
-
- @Override
- public Messages.ComponentInformationProto getLiveComponent(Messages.GetLiveComponentRequestProto request) throws
- IOException {
- try {
- return endpoint.getLiveComponent(NULL_CONTROLLER, request);
- } catch (ServiceException e) {
- throw convert(e);
- }
- }
-
- @Override
- public Messages.GetLiveNodesResponseProto getLiveNodes(Messages.GetLiveNodesRequestProto request)
- throws IOException {
- try {
- return endpoint.getLiveNodes(NULL_CONTROLLER, request);
- } catch (ServiceException e) {
- throw convert(e);
- }
- }
-
- @Override
- public Messages.NodeInformationProto getLiveNode(Messages.GetLiveNodeRequestProto request)
- throws IOException {
- try {
- return endpoint.getLiveNode(NULL_CONTROLLER, request);
- } catch (ServiceException e) {
- throw convert(e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bf581071/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/rpc/SliderIPCService.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/rpc/SliderIPCService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/rpc/SliderIPCService.java
deleted file mode 100644
index 22f9bc3..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/rpc/SliderIPCService.java
+++ /dev/null
@@ -1,406 +0,0 @@
-/*
- * 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.slider.server.appmaster.rpc;
-
-import com.google.common.base.Preconditions;
-import org.apache.hadoop.ipc.ProtocolSignature;
-import org.apache.hadoop.service.AbstractService;
-import org.apache.hadoop.yarn.api.records.FinalApplicationStatus;
-import org.apache.hadoop.yarn.exceptions.YarnException;
-import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
-import org.apache.slider.api.SliderClusterProtocol;
-import org.apache.slider.api.proto.Messages;
-import org.apache.slider.api.resource.Application;
-import org.apache.slider.api.types.ApplicationLivenessInformation;
-import org.apache.slider.api.types.ComponentInformation;
-import org.apache.slider.api.types.ContainerInformation;
-import org.apache.slider.api.types.NodeInformation;
-import org.apache.slider.api.types.NodeInformationList;
-import org.apache.slider.core.exceptions.ServiceNotReadyException;
-import org.apache.slider.core.main.LauncherExitCodes;
-import org.apache.slider.core.persist.JsonSerDeser;
-import org.apache.slider.server.appmaster.AppMasterActionOperations;
-import org.apache.slider.server.appmaster.actions.ActionFlexCluster;
-import org.apache.slider.server.appmaster.actions.ActionHalt;
-import org.apache.slider.server.appmaster.actions.ActionKillContainer;
-import org.apache.slider.server.appmaster.actions.ActionStopSlider;
-import org.apache.slider.server.appmaster.actions.ActionUpgradeContainers;
-import org.apache.slider.server.appmaster.actions.AsyncAction;
-import org.apache.slider.server.appmaster.actions.QueueAccess;
-import org.apache.slider.server.appmaster.management.MetricsAndMonitoring;
-import org.apache.slider.server.appmaster.state.RoleInstance;
-import org.apache.slider.server.appmaster.state.StateAccessForProviders;
-import org.apache.slider.server.appmaster.web.rest.application.resources.ContentCache;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-
-import static org.apache.slider.api.types.RestTypeMarshalling.marshall;
-import static org.apache.slider.server.appmaster.web.rest.RestPaths.*;
-
-/**
- * Implement the {@link SliderClusterProtocol}.
- */
-@SuppressWarnings("unchecked")
-
-public class SliderIPCService extends AbstractService
- implements SliderClusterProtocol {
-
- protected static final Logger log =
- LoggerFactory.getLogger(SliderIPCService.class);
-
- private final QueueAccess actionQueues;
- private final StateAccessForProviders state;
- private final MetricsAndMonitoring metricsAndMonitoring;
- private final AppMasterActionOperations amOperations;
- private final ContentCache cache;
- private static final JsonSerDeser<Application> jsonSerDeser =
- new JsonSerDeser<Application>(Application.class);
-
-
- /**
- * This is the prefix used for metrics
- */
- public static final String METRICS_PREFIX =
- "org.apache.slider.api.SliderIPCService.";
-
- /**
- * Constructor
- * @param amOperations access to any AM operations
- * @param state state view
- * @param actionQueues queues for actions
- * @param metricsAndMonitoring metrics
- * @param cache
- */
- public SliderIPCService(AppMasterActionOperations amOperations,
- StateAccessForProviders state, QueueAccess actionQueues,
- MetricsAndMonitoring metricsAndMonitoring, ContentCache cache) {
- super("SliderIPCService");
- Preconditions.checkArgument(amOperations != null, "null amOperations");
- Preconditions.checkArgument(state != null, "null appState");
- Preconditions.checkArgument(actionQueues != null, "null actionQueues");
- Preconditions.checkArgument(metricsAndMonitoring != null,
- "null metricsAndMonitoring");
- Preconditions.checkArgument(cache != null, "null cache");
- this.state = state;
- this.actionQueues = actionQueues;
- this.metricsAndMonitoring = metricsAndMonitoring;
- this.amOperations = amOperations;
- this.cache = cache;
- }
-
- @Override //SliderClusterProtocol
- public ProtocolSignature getProtocolSignature(String protocol,
- long clientVersion,
- int clientMethodsHash) throws IOException {
- return ProtocolSignature.getProtocolSignature(
- this, protocol, clientVersion, clientMethodsHash);
- }
-
-
- @Override //SliderClusterProtocol
- public long getProtocolVersion(String protocol, long clientVersion)
- throws IOException {
- return SliderClusterProtocol.versionID;
- }
-
- /**
- * General actions to perform on a slider RPC call coming in
- * @param operation operation to log
- * @throws IOException problems
- * @throws ServiceNotReadyException if the RPC service is constructed
- * but not fully initialized
- */
- protected void onRpcCall(String operation) throws IOException {
- log.debug("Received call to {}", operation);
- metricsAndMonitoring.markMeterAndCounter(METRICS_PREFIX + operation);
- }
-
- /**
- * Schedule an action
- * @param action for delayed execution
- */
- public void schedule(AsyncAction action) {
- actionQueues.schedule(action);
- }
-
- /**
- * Queue an action for immediate execution in the executor thread
- * @param action action to execute
- */
- public void queue(AsyncAction action) {
- actionQueues.put(action);
- }
-
- @Override //SliderClusterProtocol
- public Messages.StopClusterResponseProto stopCluster(Messages.StopClusterRequestProto request)
- throws IOException, YarnException {
- onRpcCall("stop");
- String message = request.getMessage();
- if (message == null) {
- message = "application stopped by client";
- }
- ActionStopSlider stopSlider =
- new ActionStopSlider(message,
- 1000, TimeUnit.MILLISECONDS,
- LauncherExitCodes.EXIT_SUCCESS,
- FinalApplicationStatus.SUCCEEDED,
- message);
- log.info("SliderAppMasterApi.stopCluster: {}", stopSlider);
- schedule(stopSlider);
- return Messages.StopClusterResponseProto.getDefaultInstance();
- }
-
- @Override //SliderClusterProtocol
- public Messages.UpgradeContainersResponseProto upgradeContainers(
- Messages.UpgradeContainersRequestProto request) throws IOException,
- YarnException {
- onRpcCall("upgrade");
- String message = request.getMessage();
- if (message == null) {
- message = "application containers upgraded by client";
- }
- ActionUpgradeContainers upgradeContainers =
- new ActionUpgradeContainers(
- "Upgrade containers",
- 1000, TimeUnit.MILLISECONDS,
- LauncherExitCodes.EXIT_SUCCESS,
- FinalApplicationStatus.SUCCEEDED,
- request.getContainerList(),
- request.getComponentList(),
- message);
- log.info("SliderAppMasterApi.upgradeContainers: {}", upgradeContainers);
- schedule(upgradeContainers);
- return Messages.UpgradeContainersResponseProto.getDefaultInstance();
- }
-
- @Override
- public Messages.FlexComponentsResponseProto flexComponents(
- Messages.FlexComponentsRequestProto request) throws IOException {
- onRpcCall("flex");
- schedule(new ActionFlexCluster("flex", 1, TimeUnit.MILLISECONDS, request));
- return Messages.FlexComponentsResponseProto.newBuilder().build();
- }
-
- @Override //SliderClusterProtocol
- public Messages.GetJSONClusterStatusResponseProto getJSONClusterStatus(
- Messages.GetJSONClusterStatusRequestProto request)
- throws IOException, YarnException {
- onRpcCall("getstatus");
- String result;
- //quick update
- //query and json-ify
- Application application = state.refreshClusterStatus();
- String stat = jsonSerDeser.toJson(application);
- return Messages.GetJSONClusterStatusResponseProto.newBuilder()
- .setClusterSpec(stat).build();
- }
-
- @Override //SliderClusterProtocol
- public Messages.ListNodeUUIDsByRoleResponseProto listNodeUUIDsByRole(Messages.ListNodeUUIDsByRoleRequestProto request)
- throws IOException, YarnException {
- onRpcCall("listnodes)");
- String role = request.getRole();
- Messages.ListNodeUUIDsByRoleResponseProto.Builder builder =
- Messages.ListNodeUUIDsByRoleResponseProto.newBuilder();
- List<RoleInstance> nodes = state.enumLiveInstancesInRole(role);
- for (RoleInstance node : nodes) {
- builder.addUuid(node.id);
- }
- return builder.build();
- }
-
- @Override //SliderClusterProtocol
- public Messages.GetNodeResponseProto getNode(Messages.GetNodeRequestProto request)
- throws IOException, YarnException {
- onRpcCall("getnode");
- RoleInstance instance = state.getLiveInstanceByContainerID(
- request.getUuid());
- return Messages.GetNodeResponseProto.newBuilder()
- .setClusterNode(instance.toProtobuf())
- .build();
- }
-
- @Override //SliderClusterProtocol
- public Messages.GetClusterNodesResponseProto getClusterNodes(
- Messages.GetClusterNodesRequestProto request)
- throws IOException, YarnException {
- onRpcCall("getclusternodes");
- List<RoleInstance>
- clusterNodes = state.getLiveInstancesByContainerIDs(
- request.getUuidList());
-
- Messages.GetClusterNodesResponseProto.Builder builder =
- Messages.GetClusterNodesResponseProto.newBuilder();
- for (RoleInstance node : clusterNodes) {
- builder.addClusterNode(node.toProtobuf());
- }
- //at this point: a possibly empty list of nodes
- return builder.build();
- }
-
- @Override
- public Messages.EchoResponseProto echo(Messages.EchoRequestProto request)
- throws IOException, YarnException {
- onRpcCall("echo");
- Messages.EchoResponseProto.Builder builder =
- Messages.EchoResponseProto.newBuilder();
- String text = request.getText();
- log.info("Echo request size ={}", text.length());
- log.info(text);
- //now return it
- builder.setText(text);
- return builder.build();
- }
-
- @Override
- public Messages.KillContainerResponseProto killContainer(Messages.KillContainerRequestProto request)
- throws IOException, YarnException {
- onRpcCall("killcontainer");
- String containerID = request.getId();
- log.info("Kill Container {}", containerID);
- //throws NoSuchNodeException if it is missing
- RoleInstance instance =
- state.getLiveInstanceByContainerID(containerID);
- queue(new ActionKillContainer(instance.getContainerId(), 0, TimeUnit.MILLISECONDS,
- amOperations));
- Messages.KillContainerResponseProto.Builder builder =
- Messages.KillContainerResponseProto.newBuilder();
- builder.setSuccess(true);
- return builder.build();
- }
-
-
- @Override
- public Messages.AMSuicideResponseProto amSuicide(
- Messages.AMSuicideRequestProto request)
- throws IOException {
- onRpcCall("amsuicide");
- int signal = request.getSignal();
- String text = request.getText();
- if (text == null) {
- text = "";
- }
- int delay = request.getDelay();
- log.info("AM Suicide with signal {}, message {} delay = {}", signal, text,
- delay);
- ActionHalt action = new ActionHalt(signal, text, delay,
- TimeUnit.MILLISECONDS);
- schedule(action);
- return Messages.AMSuicideResponseProto.getDefaultInstance();
- }
-
- @Override
- public Messages.ApplicationLivenessInformationProto getLivenessInformation(
- Messages.GetApplicationLivenessRequestProto request) throws IOException {
- ApplicationLivenessInformation info =
- state.getApplicationLivenessInformation();
- return marshall(info);
- }
-
- @Override
- public Messages.GetLiveContainersResponseProto getLiveContainers(
- Messages.GetLiveContainersRequestProto request)
- throws IOException {
- Map<String, ContainerInformation> infoMap =
- (Map<String, ContainerInformation>) cache.lookupWithIOE(LIVE_CONTAINERS);
- Messages.GetLiveContainersResponseProto.Builder builder =
- Messages.GetLiveContainersResponseProto.newBuilder();
-
- for (Map.Entry<String, ContainerInformation> entry : infoMap.entrySet()) {
- builder.addNames(entry.getKey());
- builder.addContainers(marshall(entry.getValue()));
- }
- return builder.build();
- }
-
- @Override
- public Messages.ContainerInformationProto getLiveContainer(Messages.GetLiveContainerRequestProto request)
- throws IOException {
- String containerId = request.getContainerId();
- RoleInstance id = state.getLiveInstanceByContainerID(containerId);
- ContainerInformation containerInformation = id.serialize();
- return marshall(containerInformation);
- }
-
- @Override
- public Messages.GetLiveComponentsResponseProto getLiveComponents(Messages.GetLiveComponentsRequestProto request)
- throws IOException {
- Map<String, ComponentInformation> infoMap =
- (Map<String, ComponentInformation>) cache.lookupWithIOE(LIVE_COMPONENTS);
- Messages.GetLiveComponentsResponseProto.Builder builder =
- Messages.GetLiveComponentsResponseProto.newBuilder();
-
- for (Map.Entry<String, ComponentInformation> entry : infoMap.entrySet()) {
- builder.addNames(entry.getKey());
- builder.addComponents(marshall(entry.getValue()));
- }
- return builder.build();
- }
-
-
- @Override
- public Messages.ComponentInformationProto getLiveComponent(Messages.GetLiveComponentRequestProto request)
- throws IOException {
- String name = request.getName();
- try {
- return marshall(state.getComponentInformation(name));
- } catch (YarnRuntimeException e) {
- throw new FileNotFoundException("Unknown component: " + name);
- }
- }
-
- @Override
- public Messages.GetLiveNodesResponseProto getLiveNodes(Messages.GetLiveNodesRequestProto request)
- throws IOException {
- NodeInformationList info = (NodeInformationList) cache.lookupWithIOE(LIVE_NODES);
- Messages.GetLiveNodesResponseProto.Builder builder =
- Messages.GetLiveNodesResponseProto.newBuilder();
-
- for (NodeInformation nodeInformation : info) {
- builder.addNodes(marshall(nodeInformation));
- }
- return builder.build();
- }
-
-
- @Override
- public Messages.NodeInformationProto getLiveNode(Messages.GetLiveNodeRequestProto request)
- throws IOException {
- String name = request.getName();
- NodeInformation nodeInformation = state.getNodeInformation(name);
- if (nodeInformation != null) {
- return marshall(nodeInformation);
- } else {
- throw new FileNotFoundException("Unknown host: " + name);
- }
- }
-
- private Messages.WrappedJsonProto wrap(String json) {
- Messages.WrappedJsonProto.Builder builder =
- Messages.WrappedJsonProto.newBuilder();
- builder.setJson(json);
- return builder.build();
- }
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bf581071/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/rpc/SliderRPCSecurityInfo.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/rpc/SliderRPCSecurityInfo.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/rpc/SliderRPCSecurityInfo.java
deleted file mode 100644
index 5b127b8..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/rpc/SliderRPCSecurityInfo.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
-* 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.slider.server.appmaster.rpc;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.security.KerberosInfo;
-import org.apache.hadoop.security.SecurityInfo;
-import org.apache.hadoop.security.token.TokenIdentifier;
-import org.apache.hadoop.security.token.TokenInfo;
-import org.apache.hadoop.security.token.TokenSelector;
-import org.apache.hadoop.yarn.security.client.ClientToAMTokenSelector;
-import org.apache.hadoop.yarn.service.conf.SliderXmlConfKeys;
-
-import java.lang.annotation.Annotation;
-
-/**
- * This is where security information goes.
- * It is referred to in the <code>META-INF/services/org.apache.hadoop.security.SecurityInfo</code>
- * resource of this JAR, which is used to find the binding info
- */
-public class SliderRPCSecurityInfo extends SecurityInfo {
-
- @Override
- public KerberosInfo getKerberosInfo(Class<?> protocol, Configuration conf) {
- if (!protocol.equals(SliderClusterProtocolPB.class)) {
- return null;
- }
- return new KerberosInfo() {
-
- @Override
- public Class<? extends Annotation> annotationType() {
- return null;
- }
-
- @Override
- public String serverPrincipal() {
- return SliderXmlConfKeys.KEY_KERBEROS_PRINCIPAL;
- }
-
- @Override
- public String clientPrincipal() {
- return null;
- }
- };
- }
-
- @Override
- public TokenInfo getTokenInfo(Class<?> protocol, Configuration conf) {
- if (!protocol.equals(SliderClusterProtocolPB.class)) {
- return null;
- }
- return new TokenInfo() {
-
- @Override
- public Class<? extends Annotation> annotationType() {
- return null;
- }
-
- @Override
- public Class<? extends TokenSelector<? extends TokenIdentifier>>
- value() {
- return ClientToAMTokenSelector.class;
- }
-
- @Override
- public String toString() {
- return "SliderClusterProtocolPB token info";
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bf581071/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/security/SecurityConfiguration.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/security/SecurityConfiguration.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/security/SecurityConfiguration.java
deleted file mode 100644
index 75eccd0..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/security/SecurityConfiguration.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * 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.slider.server.appmaster.security;
-
-import com.google.common.base.Preconditions;
-import org.apache.commons.lang.StringUtils;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.security.UserGroupInformation;
-import static org.apache.slider.core.main.LauncherExitCodes.EXIT_UNAUTHORIZED;
-
-import org.apache.slider.api.resource.Application;
-import org.apache.hadoop.yarn.service.conf.SliderKeys;
-import org.apache.hadoop.yarn.service.conf.SliderXmlConfKeys;
-import org.apache.slider.common.tools.SliderUtils;
-import org.apache.slider.core.exceptions.SliderException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.io.IOException;
-
-/**
- * Class keeping code security information
- */
-public class SecurityConfiguration {
-
- protected static final Logger log =
- LoggerFactory.getLogger(SecurityConfiguration.class);
- private final Configuration configuration;
- private final Application application;
- private String clusterName;
-
- public SecurityConfiguration(Configuration configuration,
- Application application,
- String clusterName) throws SliderException {
- Preconditions.checkNotNull(configuration);
- Preconditions.checkNotNull(application);
- Preconditions.checkNotNull(clusterName);
- this.configuration = configuration;
- this.application = application;
- this.clusterName = clusterName;
- validate();
- }
-
- private void validate() throws SliderException {
- if (isSecurityEnabled()) {
- // TODO use AM configuration rather than app configuration
- String principal = application.getConfiguration().getProperty(
- SliderXmlConfKeys.KEY_KEYTAB_PRINCIPAL);
- if(SliderUtils.isUnset(principal)) {
- // if no login identity is available, fail
- UserGroupInformation loginUser = null;
- try {
- loginUser = getLoginUser();
- } catch (IOException e) {
- throw new SliderException(EXIT_UNAUTHORIZED, e,
- "No principal configured for the application and "
- + "exception raised during retrieval of login user. "
- + "Unable to proceed with application "
- + "initialization. Please ensure a value "
- + "for %s exists in the application "
- + "configuration or the login issue is addressed",
- SliderXmlConfKeys.KEY_KEYTAB_PRINCIPAL);
- }
- if (loginUser == null) {
- throw new SliderException(EXIT_UNAUTHORIZED,
- "No principal configured for the application "
- + "and no login user found. "
- + "Unable to proceed with application "
- + "initialization. Please ensure a value "
- + "for %s exists in the application "
- + "configuration or the login issue is addressed",
- SliderXmlConfKeys.KEY_KEYTAB_PRINCIPAL);
- }
- }
- // ensure that either local or distributed keytab mechanism is enabled,
- // but not both
- String keytabFullPath = application.getConfiguration().getProperty(
- SliderXmlConfKeys.KEY_AM_KEYTAB_LOCAL_PATH);
- String keytabName = application.getConfiguration().getProperty(
- SliderXmlConfKeys.KEY_AM_LOGIN_KEYTAB_NAME);
- if (SliderUtils.isSet(keytabFullPath) && SliderUtils.isSet(keytabName)) {
- throw new SliderException(EXIT_UNAUTHORIZED,
- "Both a keytab on the cluster host (%s) and a"
- + " keytab to be retrieved from HDFS (%s) are"
- + " specified. Please configure only one keytab"
- + " retrieval mechanism.",
- SliderXmlConfKeys.KEY_AM_KEYTAB_LOCAL_PATH,
- SliderXmlConfKeys.KEY_AM_LOGIN_KEYTAB_NAME);
-
- }
- }
- }
-
- protected UserGroupInformation getLoginUser() throws IOException {
- return UserGroupInformation.getLoginUser();
- }
-
- public boolean isSecurityEnabled() {
- return SliderUtils.isHadoopClusterSecure(configuration);
- }
-
- public String getPrincipal() throws IOException {
- String principal = application.getConfiguration().getProperty(
- SliderXmlConfKeys.KEY_KEYTAB_PRINCIPAL);
- if (SliderUtils.isUnset(principal)) {
- principal = UserGroupInformation.getLoginUser().getShortUserName();
- log.info("No principal set in the slider configuration. Will use AM " +
- "login identity {} to attempt keytab-based login", principal);
- }
-
- return principal;
- }
-
- public boolean isKeytabProvided() {
- String keytabLocalPath = application.getConfiguration().getProperty(
- SliderXmlConfKeys.KEY_AM_KEYTAB_LOCAL_PATH);
- String keytabName = application.getConfiguration().getProperty(
- SliderXmlConfKeys.KEY_AM_LOGIN_KEYTAB_NAME);
- return StringUtils.isNotBlank(keytabLocalPath)
- || StringUtils.isNotBlank(keytabName);
-
- }
-
- public File getKeytabFile()
- throws SliderException, IOException {
- //TODO implement this for dash semantic
- String keytabFullPath = application.getConfiguration().getProperty(
- SliderXmlConfKeys.KEY_AM_KEYTAB_LOCAL_PATH);
- File localKeytabFile;
- if (SliderUtils.isUnset(keytabFullPath)) {
- // get the keytab
- String keytabName = application.getConfiguration().getProperty(
- SliderXmlConfKeys.KEY_AM_LOGIN_KEYTAB_NAME);
- log.info("No host keytab file path specified. Will attempt to retrieve"
- + " keytab file {} as a local resource for the container",
- keytabName);
- // download keytab to local, protected directory
- localKeytabFile = new File(SliderKeys.KEYTAB_DIR, keytabName);
- } else {
- log.info("Using host keytab file {} for login", keytabFullPath);
- localKeytabFile = new File(keytabFullPath);
- }
- return localKeytabFile;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/bf581071/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/state/AbstractClusterServices.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/state/AbstractClusterServices.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/state/AbstractClusterServices.java
deleted file mode 100644
index 54f384b..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-slider/hadoop-yarn-slider-core/src/main/java/org/apache/slider/server/appmaster/state/AbstractClusterServices.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.slider.server.appmaster.state;
-
-import com.google.common.base.Preconditions;
-import org.apache.hadoop.yarn.api.records.Resource;
-import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator;
-
-/**
- * Cluster services offered by the YARN infrastructure.
- */
-public abstract class AbstractClusterServices {
-
- private final DefaultResourceCalculator
- defaultResourceCalculator = new DefaultResourceCalculator();
-
- /**
- * Create a resource for requests
- * @return a resource which can be built up.
- */
- public abstract Resource newResource();
-
- public abstract Resource newResource(int memory, int cores);
-
- /**
- * Normalise memory, CPU and other resources according to the YARN AM-supplied
- * values and the resource calculator in use (currently hard-coded to the
- * {@link DefaultResourceCalculator}.
- * Those resources which aren't normalized (currently: CPU) are left
- * as is.
- * @param resource resource requirements of a role
- * @param minR minimum values of this queue
- * @param maxR max values of this queue
- * @return a normalized value.
- */
- public Resource normalize(Resource resource, Resource minR, Resource maxR) {
- Preconditions.checkArgument(resource != null, "null resource");
- Preconditions.checkArgument(minR != null, "null minR");
- Preconditions.checkArgument(maxR != null, "null maxR");
-
- Resource normalize = defaultResourceCalculator.normalize(resource, minR,
- maxR, minR);
- return newResource(normalize.getMemory(), resource.getVirtualCores());
- }
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org