YARN-3157. Refactor the exception handling in ConverterUtils#to*Id. Contributed by Bibin A Chundatt.
This commit is contained in:
parent
76e309ead0
commit
95a41bf35d
|
@ -269,6 +269,9 @@ Release 2.7.0 - UNRELEASED
|
||||||
YARN-1237. Description for yarn.nodemanager.aux-services in
|
YARN-1237. Description for yarn.nodemanager.aux-services in
|
||||||
yarn-default.xml is misleading. (Brahma Reddy Battula via ozawa)
|
yarn-default.xml is misleading. (Brahma Reddy Battula via ozawa)
|
||||||
|
|
||||||
|
YARN-3157. Refactor the exception handling in ConverterUtils#to*Id.
|
||||||
|
(Bibin A Chundatt via ozawa)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
YARN-2990. FairScheduler's delay-scheduling always waits for node-local and
|
YARN-2990. FairScheduler's delay-scheduling always waits for node-local and
|
||||||
|
|
|
@ -27,6 +27,7 @@ import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
import org.apache.hadoop.classification.InterfaceAudience.Private;
|
import org.apache.hadoop.classification.InterfaceAudience.Private;
|
||||||
import org.apache.hadoop.fs.Path;
|
import org.apache.hadoop.fs.Path;
|
||||||
|
@ -175,7 +176,12 @@ public class ConverterUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ContainerId toContainerId(String containerIdStr) {
|
public static ContainerId toContainerId(String containerIdStr) {
|
||||||
return ContainerId.fromString(containerIdStr);
|
try {
|
||||||
|
return ContainerId.fromString(containerIdStr);
|
||||||
|
} catch (NoSuchElementException e) {
|
||||||
|
throw new IllegalArgumentException("Invalid ContainerId: "
|
||||||
|
+ containerIdStr, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ApplicationAttemptId toApplicationAttemptId(
|
public static ApplicationAttemptId toApplicationAttemptId(
|
||||||
|
@ -190,6 +196,9 @@ public class ConverterUtils {
|
||||||
} catch (NumberFormatException n) {
|
} catch (NumberFormatException n) {
|
||||||
throw new IllegalArgumentException("Invalid AppAttemptId: "
|
throw new IllegalArgumentException("Invalid AppAttemptId: "
|
||||||
+ applicationAttmeptIdStr, n);
|
+ applicationAttmeptIdStr, n);
|
||||||
|
} catch (NoSuchElementException e){
|
||||||
|
throw new IllegalArgumentException("Invalid AppAttemptId: "
|
||||||
|
+ applicationAttmeptIdStr, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,6 +215,9 @@ public class ConverterUtils {
|
||||||
} catch (NumberFormatException n) {
|
} catch (NumberFormatException n) {
|
||||||
throw new IllegalArgumentException("Invalid ApplicationId: "
|
throw new IllegalArgumentException("Invalid ApplicationId: "
|
||||||
+ appIdStr, n);
|
+ appIdStr, n);
|
||||||
|
} catch (NoSuchElementException e){
|
||||||
|
throw new IllegalArgumentException("Invalid ApplicationId: "
|
||||||
|
+ appIdStr, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,4 +99,19 @@ public class TestConverterUtils {
|
||||||
assertEquals(nid.getPort(), 0);
|
assertEquals(nid.getPort(), 0);
|
||||||
assertEquals(nid.getHost(), "node");
|
assertEquals(nid.getHost(), "node");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(expected = IllegalArgumentException.class)
|
||||||
|
public void testInvalidContainerId() {
|
||||||
|
ConverterUtils.toContainerId("container_e20_1423221031460_0003_01");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = IllegalArgumentException.class)
|
||||||
|
public void testInvalidAppattemptId() {
|
||||||
|
ConverterUtils.toApplicationAttemptId("appattempt_1423221031460");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = IllegalArgumentException.class)
|
||||||
|
public void testApplicationId() {
|
||||||
|
ConverterUtils.toApplicationId("application_1423221031460");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue