use of org.apache.hadoop.yarn.server.api.protocolrecords.SCMUploaderNotifyRequest in project hadoop by apache.
the class SharedCacheUploader method notifySharedCacheManager.
@VisibleForTesting
boolean notifySharedCacheManager(String checksumVal, String fileName) throws IOException {
try {
SCMUploaderNotifyRequest request = recordFactory.newRecordInstance(SCMUploaderNotifyRequest.class);
request.setResourceKey(checksumVal);
request.setFilename(fileName);
return scmClient.notify(request).getAccepted();
} catch (YarnException e) {
throw new IOException(e);
} catch (UndeclaredThrowableException e) {
// retrieve the cause of the exception and throw it as an IOException
throw new IOException(e.getCause() == null ? e : e.getCause());
}
}
use of org.apache.hadoop.yarn.server.api.protocolrecords.SCMUploaderNotifyRequest in project hadoop by apache.
the class TestSharedCacheUploaderService method testNotify_entryExists_differentName.
@Test
public void testNotify_entryExists_differentName() throws Exception {
long rejected = SharedCacheUploaderMetrics.getInstance().getRejectUploads();
store.addResource("key1", "foo.jar");
SCMUploaderNotifyRequest request = recordFactory.newRecordInstance(SCMUploaderNotifyRequest.class);
request.setResourceKey("key1");
request.setFilename("foobar.jar");
assertFalse(proxy.notify(request).getAccepted());
Collection<SharedCacheResourceReference> set = store.getResourceReferences("key1");
assertNotNull(set);
assertEquals(0, set.size());
assertEquals("NM upload metrics aren't updated.", 1, SharedCacheUploaderMetrics.getInstance().getRejectUploads() - rejected);
}
use of org.apache.hadoop.yarn.server.api.protocolrecords.SCMUploaderNotifyRequest in project hadoop by apache.
the class TestSharedCacheUploaderService method testNotify_noEntry.
@Test
public void testNotify_noEntry() throws Exception {
long accepted = SharedCacheUploaderMetrics.getInstance().getAcceptedUploads();
SCMUploaderNotifyRequest request = recordFactory.newRecordInstance(SCMUploaderNotifyRequest.class);
request.setResourceKey("key1");
request.setFilename("foo.jar");
assertTrue(proxy.notify(request).getAccepted());
Collection<SharedCacheResourceReference> set = store.getResourceReferences("key1");
assertNotNull(set);
assertEquals(0, set.size());
assertEquals("NM upload metrics aren't updated.", 1, SharedCacheUploaderMetrics.getInstance().getAcceptedUploads() - accepted);
}
use of org.apache.hadoop.yarn.server.api.protocolrecords.SCMUploaderNotifyRequest in project hadoop by apache.
the class TestSharedCacheUploaderService method testNotify_entryExists_sameName.
@Test
public void testNotify_entryExists_sameName() throws Exception {
long accepted = SharedCacheUploaderMetrics.getInstance().getAcceptedUploads();
store.addResource("key1", "foo.jar");
SCMUploaderNotifyRequest request = recordFactory.newRecordInstance(SCMUploaderNotifyRequest.class);
request.setResourceKey("key1");
request.setFilename("foo.jar");
assertTrue(proxy.notify(request).getAccepted());
Collection<SharedCacheResourceReference> set = store.getResourceReferences("key1");
assertNotNull(set);
assertEquals(0, set.size());
assertEquals("NM upload metrics aren't updated.", 1, SharedCacheUploaderMetrics.getInstance().getAcceptedUploads() - accepted);
}
Aggregations