Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* 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.api;

import java.io.IOException;

import org.apache.hadoop.yarn.api.protocolrecords.SetMaintenanceModeRequest;
import org.apache.hadoop.yarn.api.protocolrecords.SetMaintenanceModeResponse;
import org.apache.hadoop.yarn.exceptions.YarnException;

/**
* Set the maintenance mode of the node, and returns the number of running
* containers on the node.
*/
public interface MaintenanceTracker {
SetMaintenanceModeResponse setMaintenanceMode(
SetMaintenanceModeRequest request) throws YarnException, IOException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* 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.api.protocolrecords;

import org.apache.hadoop.yarn.util.Records;

/**
* This is used by DecommissioningProviders to set a node into Maintenance Mode.
* This class is used by the interface MaintenanceTracker.
*/
public abstract class SetMaintenanceModeRequest {
/**
* Instantiates new SetMaintenanceModeRequest which accepts maintenance flag.
*
* @param maintenance
* @param minimumMaintenanceTime
* @return
*/
public static SetMaintenanceModeRequest newInstance(boolean maintenance,
long minimumMaintenanceTime) {
SetMaintenanceModeRequest request =
Records.newRecord(SetMaintenanceModeRequest.class);
request.setMaintenance(maintenance);
request.setMinimumMaintenanceTime(minimumMaintenanceTime);
return request;
}

/**
* Returns maintenance state, returns true if ON else false.
*
* @return
*/
public abstract boolean isMaintenance();

public abstract void setMaintenance(boolean maintenance);

/**
* Gets minimum maintenance time if set in request or default
* value is returned.
*
* @return
*/
public abstract long getMinimumMaintenanceTime();

public abstract void setMinimumMaintenanceTime(long value);
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* 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.api.protocolrecords;

import org.apache.hadoop.yarn.util.Records;

/**
* The response the services get when request is sent to put a node into
* maintenance ON/OFF.
*/
public abstract class SetMaintenanceModeResponse {
public static SetMaintenanceModeResponse newInstance(
long runningContainersCount,
long elapsedTimeSinceLastRetentionInMilliseconds) {
SetMaintenanceModeResponse response =
Records.newRecord(SetMaintenanceModeResponse.class);
response.setRunningContainersCount(runningContainersCount);
response.setElapsedTimeSinceLastRetentionInMilliseconds(
elapsedTimeSinceLastRetentionInMilliseconds);
return response;
}

/**
* Gets the running containers on the node.
*
* @return
*/
public abstract long getRunningContainersCount();

public abstract void setRunningContainersCount(long value);

public abstract long getElapsedTimeSinceLastRetentionInMilliseconds();

public abstract void setElapsedTimeSinceLastRetentionInMilliseconds(
long value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4620,6 +4620,28 @@ public static boolean areNodeLabelsEnabled(
public static final String DEFAULT_YARN_WORKFLOW_ID_TAG_PREFIX =
"workflowid:";

/** Maintenance tracker ports and host name properties */
public static final int DEFAULT_NM_MAINTENANCE_TRACKER_PORT = 9034;
public static final String DEFAULT_NM_MAINTENANCE_TRACKER_ADDRESS =
"0.0.0.0:" + DEFAULT_NM_MAINTENANCE_TRACKER_PORT;

/** Timeout for a Node to react to the maintenance command. */
public static final String MAINTENANCE_COMMAND_TIMEOUT =
YarnConfiguration.YARN_PREFIX + "rpc.maintenance-command-timeout";

public static final int DEFAULT_MAINTENANCE_COMMAND_TIMEOUT_MS = 60000;

public static final String NM_MAINTENANCE_MODE_PROVIDER_CLASSNAMES =
YarnConfiguration.NM_PREFIX + "maintenance.mode.provider.classnames";
public static final String NM_MAINTENANCE_MODE_CONSUMER_CLASSNAMES =
YarnConfiguration.NM_PREFIX + "maintenance.mode.consumer.classnames";

/**
* All required NM Services classes need to be added in config for it to
* be started.
*/
public static final String YARNPP_NM_SERVICES = "yarnpp.nm.services";

public YarnConfiguration() {
super();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* 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.
*/

/**
* These .proto interfaces are public and stable.
* Please see http://wiki.apache.org/hadoop/Compatibility
* for what changes are allowed for a *stable* .proto interface.
*/

option java_package = "org.apache.hadoop.yarn.proto";
option java_outer_classname = "MaintenanceTracker";
option java_generic_services = true;
option java_generate_equals_and_hash = true;
package hadoop.yarn;

import "yarn_service_protos.proto";

service MaintenanceTrackerService {
rpc setMaintenanceMode(SetMaintenanceModeRequestProto) returns (SetMaintenanceModeResponseProto);
}
Original file line number Diff line number Diff line change
Expand Up @@ -573,3 +573,15 @@ message ContainerLocalizationStatusesProto {
optional ContainerIdProto container_id = 1;
repeated LocalizationStatusProto localization_statuses = 2;
}

/////// MaintenanceTracker protos /////////////////
//////////////////////////////////////////////////////
message SetMaintenanceModeRequestProto {
optional bool maintenance = 1;
optional int64 minimum_maintenance_time = 2;
}

message SetMaintenanceModeResponseProto {
optional int64 running_containers_count = 1;
optional int64 elapsed_time_since_last_retention_in_milliseconds = 2 [default = 18000000];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* 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.api;

import org.apache.hadoop.classification.InterfaceAudience.Private;
import org.apache.hadoop.classification.InterfaceStability.Unstable;
import org.apache.hadoop.ipc.ProtocolInfo;
import org.apache.hadoop.yarn.proto.MaintenanceTracker.MaintenanceTrackerService;

@Private
@Unstable
@ProtocolInfo(
protocolName = "org.apache.hadoop.yarn.api.MaintenanceTrackerPB",
protocolVersion = 1)
public interface MaintenanceTrackerPB extends
MaintenanceTrackerService.BlockingInterface {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/**
* 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.api.impl.pb.client;

import java.io.Closeable;
import java.io.IOException;
import java.net.InetSocketAddress;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.ipc.ProtobufRpcEngine2;
import org.apache.hadoop.ipc.RPC;
import org.apache.hadoop.net.NetUtils;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.yarn.api.MaintenanceTracker;
import org.apache.hadoop.yarn.api.MaintenanceTrackerPB;
import org.apache.hadoop.yarn.api.protocolrecords.SetMaintenanceModeRequest;
import org.apache.hadoop.yarn.api.protocolrecords.SetMaintenanceModeResponse;
import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.SetMaintenanceModeRequestPBImpl;
import org.apache.hadoop.yarn.api.protocolrecords.impl.pb.SetMaintenanceModeResponsePBImpl;
import org.apache.hadoop.yarn.conf.YarnConfiguration;
import org.apache.hadoop.yarn.exceptions.YarnException;
import org.apache.hadoop.yarn.ipc.RPCUtil;
import org.apache.hadoop.yarn.proto.YarnServiceProtos.SetMaintenanceModeRequestProto;

import org.apache.hadoop.thirdparty.protobuf.ServiceException;

/**
* Client to set a node into Decommissioning mode.
*/
public class MaintenanceTrackerPBClientImpl
implements MaintenanceTracker, Closeable {
private MaintenanceTrackerPB proxy;

public MaintenanceTrackerPBClientImpl(long clientVersion,
InetSocketAddress addr, Configuration conf) throws IOException {
RPC.setProtocolEngine(conf, MaintenanceTrackerPB.class,
ProtobufRpcEngine2.class);
UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
this.proxy = (MaintenanceTrackerPB) RPC
.getProxy(MaintenanceTrackerPB.class, clientVersion, addr, ugi, conf,
NetUtils.getDefaultSocketFactory(conf),
conf.getInt(YarnConfiguration.MAINTENANCE_COMMAND_TIMEOUT,
YarnConfiguration.DEFAULT_MAINTENANCE_COMMAND_TIMEOUT_MS));
}

@Override public void close() throws IOException {
if (this.proxy != null) {
RPC.stopProxy(this.proxy);
}
}

@Override public SetMaintenanceModeResponse setMaintenanceMode(
SetMaintenanceModeRequest request) throws YarnException, IOException {
SetMaintenanceModeRequestProto protoRequest =
((SetMaintenanceModeRequestPBImpl) request).getProto();
try {
return new SetMaintenanceModeResponsePBImpl(
this.proxy.setMaintenanceMode(null, protoRequest));
} catch (ServiceException e) {
RPCUtil.unwrapAndThrowException(e);
return null;
}
}
}
Loading