YARN-6544. Add Null check RegistryDNS service while parsing registry records. Contributed by Karam Singh
This commit is contained in:
parent
02d68c4bcf
commit
a22256bd40
@ -1393,19 +1393,28 @@ private void op(String path, ServiceRecord record, RegistryCommand command)
|
|||||||
throws IOException {
|
throws IOException {
|
||||||
ServiceRecordProcessor processor;
|
ServiceRecordProcessor processor;
|
||||||
try {
|
try {
|
||||||
if (record.get(YarnRegistryAttributes.YARN_PERSISTENCE)
|
String yarnPersistanceValue = record.get(
|
||||||
.equals(CONTAINER)) {
|
YarnRegistryAttributes.YARN_PERSISTENCE);
|
||||||
|
if (yarnPersistanceValue != null) {
|
||||||
|
if (yarnPersistanceValue.equals(CONTAINER)) {
|
||||||
// container registration. the logic to identify and create the
|
// container registration. the logic to identify and create the
|
||||||
// container entry needs to be enhanced/more accurate and associate to
|
// container entry needs to be enhanced/more accurate and associate
|
||||||
// correct host
|
// to correct host
|
||||||
processor =
|
processor =
|
||||||
new ContainerServiceRecordProcessor(record, path, domainName, this);
|
new ContainerServiceRecordProcessor(record, path, domainName,
|
||||||
|
this);
|
||||||
} else {
|
} else {
|
||||||
|
LOG.debug("Creating ApplicationServiceRecordProcessor for {}",
|
||||||
|
yarnPersistanceValue);
|
||||||
processor =
|
processor =
|
||||||
new ApplicationServiceRecordProcessor(record, path, domainName,
|
new ApplicationServiceRecordProcessor(record, path, domainName,
|
||||||
this);
|
this);
|
||||||
}
|
}
|
||||||
processor.manageDNSRecords(command);
|
processor.manageDNSRecords(command);
|
||||||
|
} else {
|
||||||
|
LOG.warn("Yarn Resgistry record {} does not contain {} attribute ",
|
||||||
|
record.toString(), YarnRegistryAttributes.YARN_PERSISTENCE);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new IOException(e);
|
throw new IOException(e);
|
||||||
}
|
}
|
||||||
|
@ -129,6 +129,16 @@ public class TestRegistryDNS extends Assert {
|
|||||||
+ " \"yarn:persistence\" : \"container\"\n"
|
+ " \"yarn:persistence\" : \"container\"\n"
|
||||||
+ "}\n";
|
+ "}\n";
|
||||||
|
|
||||||
|
private static final String CONTAINER_RECORD_YARN_PERSISTANCE_ABSENT = "{\n"
|
||||||
|
+ " \"type\" : \"JSONServiceRecord\",\n"
|
||||||
|
+ " \"description\" : \"YCLOUD\",\n"
|
||||||
|
+ " \"external\" : [ ],\n"
|
||||||
|
+ " \"internal\" : [ ],\n"
|
||||||
|
+ " \"yarn:id\" : \"container_e50_1451931954322_0016_01_000003\",\n"
|
||||||
|
+ " \"yarn:ip\" : \"172.17.0.19\",\n"
|
||||||
|
+ " \"yarn:hostname\" : \"0a134d6329bb\"\n"
|
||||||
|
+ "}\n";
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void initialize() throws Exception {
|
public void initialize() throws Exception {
|
||||||
setRegistryDNS(new RegistryDNS("TestRegistry"));
|
setRegistryDNS(new RegistryDNS("TestRegistry"));
|
||||||
@ -219,6 +229,25 @@ public void testContainerRegistration() throws Exception {
|
|||||||
assertTrue("not an ARecord", recs[0] instanceof ARecord);
|
assertTrue("not an ARecord", recs[0] instanceof ARecord);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testContainerRegistrationPersistanceAbsent() throws Exception {
|
||||||
|
ServiceRecord record = marshal.fromBytes("somepath",
|
||||||
|
CONTAINER_RECORD_YARN_PERSISTANCE_ABSENT.getBytes());
|
||||||
|
registryDNS.register(
|
||||||
|
"/registry/users/root/services/org-apache-slider/test1/components/"
|
||||||
|
+ "container-e50-1451931954322-0016-01-000003",
|
||||||
|
record);
|
||||||
|
|
||||||
|
Name name =
|
||||||
|
Name.fromString("ctr-e50-1451931954322-0016-01-000002.hwx.test.");
|
||||||
|
Record question = Record.newRecord(name, Type.A, DClass.IN);
|
||||||
|
Message query = Message.newQuery(question);
|
||||||
|
byte[] responseBytes = registryDNS.generateReply(query, null);
|
||||||
|
Message response = new Message(responseBytes);
|
||||||
|
assertEquals("Excepting NXDOMAIN as Record must not have regsisterd wrong",
|
||||||
|
Rcode.NXDOMAIN, response.getRcode());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRecordTTL() throws Exception {
|
public void testRecordTTL() throws Exception {
|
||||||
ServiceRecord record = getMarshal().fromBytes("somepath",
|
ServiceRecord record = getMarshal().fromBytes("somepath",
|
||||||
|
Loading…
Reference in New Issue
Block a user