Search in sources :

Example 1 with SCMUploaderNotifyRequest

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());
    }
}
Also used : SCMUploaderNotifyRequest(org.apache.hadoop.yarn.server.api.protocolrecords.SCMUploaderNotifyRequest) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) IOException(java.io.IOException) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 2 with SCMUploaderNotifyRequest

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);
}
Also used : SCMUploaderNotifyRequest(org.apache.hadoop.yarn.server.api.protocolrecords.SCMUploaderNotifyRequest) SharedCacheResourceReference(org.apache.hadoop.yarn.server.sharedcachemanager.store.SharedCacheResourceReference) Test(org.junit.Test)

Example 3 with SCMUploaderNotifyRequest

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);
}
Also used : SCMUploaderNotifyRequest(org.apache.hadoop.yarn.server.api.protocolrecords.SCMUploaderNotifyRequest) SharedCacheResourceReference(org.apache.hadoop.yarn.server.sharedcachemanager.store.SharedCacheResourceReference) Test(org.junit.Test)

Example 4 with SCMUploaderNotifyRequest

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);
}
Also used : SCMUploaderNotifyRequest(org.apache.hadoop.yarn.server.api.protocolrecords.SCMUploaderNotifyRequest) SharedCacheResourceReference(org.apache.hadoop.yarn.server.sharedcachemanager.store.SharedCacheResourceReference) Test(org.junit.Test)

Aggregations

SCMUploaderNotifyRequest (org.apache.hadoop.yarn.server.api.protocolrecords.SCMUploaderNotifyRequest)4 SharedCacheResourceReference (org.apache.hadoop.yarn.server.sharedcachemanager.store.SharedCacheResourceReference)3 Test (org.junit.Test)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 IOException (java.io.IOException)1 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)1 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)1