Search in sources :

Example 1 with JarActionHandlerConfig

use of org.apache.flink.runtime.webmonitor.handlers.JarActionHandler.JarActionHandlerConfig in project flink by apache.

the class JarActionHandlerTest method testSavepointRestoreSettings.

/**
	 * Test that the savepoint settings are correctly parsed.
	 */
@Test
public void testSavepointRestoreSettings() throws Exception {
    Map<String, String> pathParams = new HashMap<>();
    // required
    pathParams.put("jarid", "required");
    // the following should be ignored, because they are parsed from the query params
    pathParams.put("savepointPath", "ignored");
    pathParams.put("allowNonRestoredState", "ignored");
    // <-- everything goes here
    Map<String, String> queryParams = new HashMap<>();
    // Nothing configured
    JarActionHandlerConfig config = JarActionHandlerConfig.fromParams(pathParams, queryParams);
    assertEquals(SavepointRestoreSettings.none(), config.getSavepointRestoreSettings());
    // Set path
    queryParams.put("savepointPath", "the-savepoint-path");
    queryParams.put("allowNonRestoredState", "");
    SavepointRestoreSettings expected = SavepointRestoreSettings.forPath("the-savepoint-path", false);
    config = JarActionHandlerConfig.fromParams(pathParams, queryParams);
    assertEquals(expected, config.getSavepointRestoreSettings());
    // Set flag
    queryParams.put("allowNonRestoredState", "true");
    expected = SavepointRestoreSettings.forPath("the-savepoint-path", true);
    config = JarActionHandlerConfig.fromParams(pathParams, queryParams);
    assertEquals(expected, config.getSavepointRestoreSettings());
}
Also used : HashMap(java.util.HashMap) JarActionHandlerConfig(org.apache.flink.runtime.webmonitor.handlers.JarActionHandler.JarActionHandlerConfig) SavepointRestoreSettings(org.apache.flink.runtime.jobgraph.SavepointRestoreSettings) Test(org.junit.Test)

Example 2 with JarActionHandlerConfig

use of org.apache.flink.runtime.webmonitor.handlers.JarActionHandler.JarActionHandlerConfig in project flink by apache.

the class JarActionHandlerTest method testEmptyStringParams.

/**
	 * Tests that empty String params are handled ignored.
	 */
@Test
public void testEmptyStringParams() throws Exception {
    Map<String, String> pathParams = new HashMap<>();
    // required
    pathParams.put("jarid", "required");
    Map<String, String> queryParams = new HashMap<>();
    queryParams.put("program-args", "");
    queryParams.put("entry-class", "");
    queryParams.put("parallelism", "");
    queryParams.put("savepointPath", "");
    queryParams.put("allowNonRestoredState", "");
    // Nothing configured
    JarActionHandlerConfig config = JarActionHandlerConfig.fromParams(pathParams, queryParams);
    assertEquals(0, config.getProgramArgs().length);
    assertNull(config.getEntryClass());
    assertEquals(1, config.getParallelism());
    assertEquals(SavepointRestoreSettings.none(), config.getSavepointRestoreSettings());
}
Also used : HashMap(java.util.HashMap) JarActionHandlerConfig(org.apache.flink.runtime.webmonitor.handlers.JarActionHandler.JarActionHandlerConfig) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)2 JarActionHandlerConfig (org.apache.flink.runtime.webmonitor.handlers.JarActionHandler.JarActionHandlerConfig)2 Test (org.junit.Test)2 SavepointRestoreSettings (org.apache.flink.runtime.jobgraph.SavepointRestoreSettings)1