YARN-3410. YARN admin should be able to remove individual application records from RMStateStore. (Rohith Sharmaks via wangda)
This commit is contained in:
parent
aa34aa5caa
commit
8a9599fb9e
|
@ -42,6 +42,9 @@ Release 2.8.0 - UNRELEASED
|
|||
YARN-3463. Integrate OrderingPolicy Framework with CapacityScheduler.
|
||||
(Craig Welch via wangda)
|
||||
|
||||
YARN-3410. YARN admin should be able to remove individual application
|
||||
records from RMStateStore. (Rohith Sharmaks via wangda)
|
||||
|
||||
IMPROVEMENTS
|
||||
|
||||
YARN-1880. Cleanup TestApplicationClientProtocolOnHA
|
||||
|
|
|
@ -69,8 +69,10 @@ function print_usage(){
|
|||
echo " CLASSNAME run the class named CLASSNAME"
|
||||
echo " or"
|
||||
echo " where COMMAND is one of:"
|
||||
echo " resourcemanager -format-state-store deletes the RMStateStore"
|
||||
echo " resourcemanager run the ResourceManager"
|
||||
echo " Use -format-state-store for deleting the RMStateStore."
|
||||
echo " Use -remove-application-from-state-store <appId> for "
|
||||
echo " removing application from RMStateStore."
|
||||
echo " nodemanager run a nodemanager on each slave"
|
||||
echo " timelineserver run the timeline server"
|
||||
echo " rmadmin admin tools"
|
||||
|
|
|
@ -93,6 +93,7 @@ import org.apache.hadoop.yarn.server.webproxy.AppReportFetcher;
|
|||
import org.apache.hadoop.yarn.server.webproxy.ProxyUriUtils;
|
||||
import org.apache.hadoop.yarn.server.webproxy.WebAppProxy;
|
||||
import org.apache.hadoop.yarn.server.webproxy.WebAppProxyServlet;
|
||||
import org.apache.hadoop.yarn.util.ConverterUtils;
|
||||
import org.apache.hadoop.yarn.webapp.WebApp;
|
||||
import org.apache.hadoop.yarn.webapp.WebApps;
|
||||
import org.apache.hadoop.yarn.webapp.WebApps.Builder;
|
||||
|
@ -100,6 +101,7 @@ import org.apache.hadoop.yarn.webapp.util.WebAppUtils;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.util.ArrayList;
|
||||
|
@ -1197,8 +1199,15 @@ public class ResourceManager extends CompositeService implements Recoverable {
|
|||
GenericOptionsParser hParser = new GenericOptionsParser(conf, argv);
|
||||
argv = hParser.getRemainingArgs();
|
||||
// If -format-state-store, then delete RMStateStore; else startup normally
|
||||
if (argv.length == 1 && argv[0].equals("-format-state-store")) {
|
||||
deleteRMStateStore(conf);
|
||||
if (argv.length >= 1) {
|
||||
if (argv[0].equals("-format-state-store")) {
|
||||
deleteRMStateStore(conf);
|
||||
} else if (argv[0].equals("-remove-application-from-state-store")
|
||||
&& argv.length == 2) {
|
||||
removeApplication(conf, argv[1]);
|
||||
} else {
|
||||
printUsage(System.err);
|
||||
}
|
||||
} else {
|
||||
ResourceManager resourceManager = new ResourceManager();
|
||||
ShutdownHookManager.get().addShutdownHook(
|
||||
|
@ -1275,4 +1284,25 @@ public class ResourceManager extends CompositeService implements Recoverable {
|
|||
rmStore.stop();
|
||||
}
|
||||
}
|
||||
|
||||
private static void removeApplication(Configuration conf, String applicationId)
|
||||
throws Exception {
|
||||
RMStateStore rmStore = RMStateStoreFactory.getStore(conf);
|
||||
rmStore.init(conf);
|
||||
rmStore.start();
|
||||
try {
|
||||
ApplicationId removeAppId = ConverterUtils.toApplicationId(applicationId);
|
||||
LOG.info("Deleting application " + removeAppId + " from state store");
|
||||
rmStore.removeApplication(removeAppId);
|
||||
LOG.info("Application is deleted from state store");
|
||||
} finally {
|
||||
rmStore.stop();
|
||||
}
|
||||
}
|
||||
|
||||
private static void printUsage(PrintStream out) {
|
||||
out.println("Usage: java ResourceManager [-format-state-store]");
|
||||
out.println(" "
|
||||
+ "[-remove-application-from-state-store <appId>]" + "\n");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -559,6 +559,15 @@ public class FileSystemRMStateStore extends RMStateStore {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void removeApplication(ApplicationId removeAppId)
|
||||
throws Exception {
|
||||
Path nodeRemovePath = getAppDir(rmAppRoot, removeAppId);
|
||||
if (existsWithRetries(nodeRemovePath)) {
|
||||
deleteFileWithRetries(nodeRemovePath);
|
||||
}
|
||||
}
|
||||
|
||||
private Path getAppDir(Path root, ApplicationId appId) {
|
||||
return getNodePath(root, appId.toString());
|
||||
}
|
||||
|
|
|
@ -659,6 +659,18 @@ public class LeveldbRMStateStore extends RMStateStore {
|
|||
fs.delete(root, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void removeApplication(ApplicationId removeAppId)
|
||||
throws IOException {
|
||||
String appKey = getApplicationNodeKey(removeAppId);
|
||||
LOG.info("Removing state for app " + removeAppId);
|
||||
try {
|
||||
db.delete(bytes(appKey));
|
||||
} catch (DBException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
int getNumEntriesInDatabase() throws IOException {
|
||||
int numEntries = 0;
|
||||
|
|
|
@ -251,4 +251,8 @@ public class MemoryRMStateStore extends RMStateStore {
|
|||
public void deleteStore() throws Exception {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeApplication(ApplicationId removeAppId) throws Exception {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -150,4 +150,9 @@ public class NullRMStateStore extends RMStateStore {
|
|||
// Do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeApplication(ApplicationId removeAppId) throws Exception {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -907,6 +907,15 @@ public abstract class RMStateStore extends AbstractService {
|
|||
*/
|
||||
public abstract void deleteStore() throws Exception;
|
||||
|
||||
/**
|
||||
* Derived classes must implement this method to remove application from the
|
||||
* state store
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public abstract void removeApplication(ApplicationId removeAppId)
|
||||
throws Exception;
|
||||
|
||||
public void setResourceManager(ResourceManager rm) {
|
||||
this.resourceManager = rm;
|
||||
}
|
||||
|
|
|
@ -823,6 +823,15 @@ public class ZKRMStateStore extends RMStateStore {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void removeApplication(ApplicationId removeAppId)
|
||||
throws Exception {
|
||||
String appIdRemovePath = getNodePath(rmAppRoot, removeAppId.toString());
|
||||
if (existsWithRetries(appIdRemovePath, true) != null) {
|
||||
deleteWithRetries(appIdRemovePath, true);
|
||||
}
|
||||
}
|
||||
|
||||
// ZK related code
|
||||
/**
|
||||
* Watcher implementation which forward events to the ZKRMStateStore This
|
||||
|
|
|
@ -591,6 +591,21 @@ public class RMStateStoreTestBase extends ClientBaseWithFixes{
|
|||
}
|
||||
}
|
||||
|
||||
public void testRemoveApplication(RMStateStoreHelper stateStoreHelper)
|
||||
throws Exception {
|
||||
RMStateStore store = stateStoreHelper.getRMStateStore();
|
||||
int noOfApps = 2;
|
||||
ArrayList<RMApp> appList =
|
||||
createAndStoreApps(stateStoreHelper, store, noOfApps);
|
||||
|
||||
RMApp rmApp1 = appList.get(0);
|
||||
store.removeApplication(rmApp1.getApplicationId());
|
||||
Assert.assertFalse(stateStoreHelper.appExists(rmApp1));
|
||||
|
||||
RMApp rmApp2 = appList.get(1);
|
||||
Assert.assertTrue(stateStoreHelper.appExists(rmApp2));
|
||||
}
|
||||
|
||||
protected void modifyAppState() throws Exception {
|
||||
|
||||
}
|
||||
|
|
|
@ -171,6 +171,7 @@ public class TestFSRMStateStore extends RMStateStoreTestBase {
|
|||
testEpoch(fsTester);
|
||||
testAppDeletion(fsTester);
|
||||
testDeleteStore(fsTester);
|
||||
testRemoveApplication(fsTester);
|
||||
testAMRMTokenSecretManagerStateStore(fsTester);
|
||||
} finally {
|
||||
cluster.shutdown();
|
||||
|
|
|
@ -90,6 +90,12 @@ public class TestLeveldbRMStateStore extends RMStateStoreTestBase {
|
|||
testDeleteStore(tester);
|
||||
}
|
||||
|
||||
@Test(timeout = 60000)
|
||||
public void testRemoveApplication() throws Exception {
|
||||
LeveldbStateStoreTester tester = new LeveldbStateStoreTester();
|
||||
testRemoveApplication(tester);
|
||||
}
|
||||
|
||||
@Test(timeout = 60000)
|
||||
public void testAMTokens() throws Exception {
|
||||
LeveldbStateStoreTester tester = new LeveldbStateStoreTester();
|
||||
|
|
|
@ -146,6 +146,7 @@ public class TestZKRMStateStore extends RMStateStoreTestBase {
|
|||
testEpoch(zkTester);
|
||||
testAppDeletion(zkTester);
|
||||
testDeleteStore(zkTester);
|
||||
testRemoveApplication(zkTester);
|
||||
testAMRMTokenSecretManagerStateStore(zkTester);
|
||||
}
|
||||
|
||||
|
|
|
@ -193,6 +193,7 @@ Usage: `yarn resourcemanager [-format-state-store]`
|
|||
| COMMAND\_OPTIONS | Description |
|
||||
|:---- |:---- |
|
||||
| -format-state-store | Formats the RMStateStore. This will clear the RMStateStore and is useful if past applications are no longer needed. This should be run only when the ResourceManager is not running. |
|
||||
| -remove-application-from-state-store <appId> | Remove the application from RMStateStore. This should be run only when the ResourceManager is not running. |
|
||||
|
||||
Start the ResourceManager
|
||||
|
||||
|
|
Loading…
Reference in New Issue