Search in sources :

Example 6 with SharedCacheResourceReference

use of org.apache.hadoop.yarn.server.sharedcachemanager.store.SharedCacheResourceReference 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)

Example 7 with SharedCacheResourceReference

use of org.apache.hadoop.yarn.server.sharedcachemanager.store.SharedCacheResourceReference in project hadoop by apache.

the class TestClientSCMProtocolService method testUse_ExistingEntry_OneId.

@Test
public void testUse_ExistingEntry_OneId() throws Exception {
    // Pre-populate the SCM with one cache entry
    store.addResource("key1", "foo.jar");
    store.addResourceReference("key1", new SharedCacheResourceReference(createAppId(1, 1L), "user"));
    assertEquals(1, store.getResourceReferences("key1").size());
    long hits = ClientSCMMetrics.getInstance().getCacheHits();
    // Add a new distinct appId
    UseSharedCacheResourceRequest request = recordFactory.newRecordInstance(UseSharedCacheResourceRequest.class);
    request.setResourceKey("key1");
    request.setAppId(createAppId(2, 2L));
    // Expecting default depth of 3 under the shared cache root dir
    String expectedPath = testDir.getAbsolutePath() + "/k/e/y/key1/foo.jar";
    assertEquals(expectedPath, clientSCMProxy.use(request).getPath());
    assertEquals(2, store.getResourceReferences("key1").size());
    assertEquals("Client SCM metrics aren't updated.", 1, ClientSCMMetrics.getInstance().getCacheHits() - hits);
}
Also used : UseSharedCacheResourceRequest(org.apache.hadoop.yarn.api.protocolrecords.UseSharedCacheResourceRequest) SharedCacheResourceReference(org.apache.hadoop.yarn.server.sharedcachemanager.store.SharedCacheResourceReference) Test(org.junit.Test)

Example 8 with SharedCacheResourceReference

use of org.apache.hadoop.yarn.server.sharedcachemanager.store.SharedCacheResourceReference in project hadoop by apache.

the class TestClientSCMProtocolService method testRelease_ExistingEntry_WithAppId.

@Test
public void testRelease_ExistingEntry_WithAppId() throws Exception {
    // Pre-populate the SCM with one cache entry
    store.addResource("key1", "foo.jar");
    UserGroupInformation testUGI = UserGroupInformation.getCurrentUser();
    store.addResourceReference("key1", new SharedCacheResourceReference(createAppId(1, 1L), testUGI.getShortUserName()));
    assertEquals(1, store.getResourceReferences("key1").size());
    long releases = ClientSCMMetrics.getInstance().getCacheReleases();
    ReleaseSharedCacheResourceRequest request = recordFactory.newRecordInstance(ReleaseSharedCacheResourceRequest.class);
    request.setResourceKey("key1");
    request.setAppId(createAppId(1, 1L));
    clientSCMProxy.release(request);
    assertEquals(0, store.getResourceReferences("key1").size());
    assertEquals("Client SCM metrics aren't updated.", 1, ClientSCMMetrics.getInstance().getCacheReleases() - releases);
}
Also used : SharedCacheResourceReference(org.apache.hadoop.yarn.server.sharedcachemanager.store.SharedCacheResourceReference) ReleaseSharedCacheResourceRequest(org.apache.hadoop.yarn.api.protocolrecords.ReleaseSharedCacheResourceRequest) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation) Test(org.junit.Test)

Example 9 with SharedCacheResourceReference

use of org.apache.hadoop.yarn.server.sharedcachemanager.store.SharedCacheResourceReference in project hadoop by apache.

the class TestClientSCMProtocolService method testUse_ExistingEntry_DupId.

@Test
public void testUse_ExistingEntry_DupId() throws Exception {
    // Pre-populate the SCM with one cache entry
    store.addResource("key1", "foo.jar");
    UserGroupInformation testUGI = UserGroupInformation.getCurrentUser();
    store.addResourceReference("key1", new SharedCacheResourceReference(createAppId(1, 1L), testUGI.getShortUserName()));
    assertEquals(1, store.getResourceReferences("key1").size());
    long hits = ClientSCMMetrics.getInstance().getCacheHits();
    // Add a new duplicate appId
    UseSharedCacheResourceRequest request = recordFactory.newRecordInstance(UseSharedCacheResourceRequest.class);
    request.setResourceKey("key1");
    request.setAppId(createAppId(1, 1L));
    // Expecting default depth of 3 under the shared cache root dir
    String expectedPath = testDir.getAbsolutePath() + "/k/e/y/key1/foo.jar";
    assertEquals(expectedPath, clientSCMProxy.use(request).getPath());
    assertEquals(1, store.getResourceReferences("key1").size());
    assertEquals("Client SCM metrics aren't updated.", 1, ClientSCMMetrics.getInstance().getCacheHits() - hits);
}
Also used : UseSharedCacheResourceRequest(org.apache.hadoop.yarn.api.protocolrecords.UseSharedCacheResourceRequest) SharedCacheResourceReference(org.apache.hadoop.yarn.server.sharedcachemanager.store.SharedCacheResourceReference) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation) Test(org.junit.Test)

Aggregations

SharedCacheResourceReference (org.apache.hadoop.yarn.server.sharedcachemanager.store.SharedCacheResourceReference)9 Test (org.junit.Test)7 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)4 SCMUploaderNotifyRequest (org.apache.hadoop.yarn.server.api.protocolrecords.SCMUploaderNotifyRequest)3 IOException (java.io.IOException)2 ReleaseSharedCacheResourceRequest (org.apache.hadoop.yarn.api.protocolrecords.ReleaseSharedCacheResourceRequest)2 UseSharedCacheResourceRequest (org.apache.hadoop.yarn.api.protocolrecords.UseSharedCacheResourceRequest)2 ReleaseSharedCacheResourceResponse (org.apache.hadoop.yarn.api.protocolrecords.ReleaseSharedCacheResourceResponse)1 UseSharedCacheResourceResponse (org.apache.hadoop.yarn.api.protocolrecords.UseSharedCacheResourceResponse)1