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);
}
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);
}
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);
}
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);
}
Aggregations