use of org.apache.hadoop.yarn.server.sharedcachemanager.store.SharedCacheResourceReference in project hadoop by apache.
the class ClientProtocolService method use.
@Override
public UseSharedCacheResourceResponse use(UseSharedCacheResourceRequest request) throws YarnException, IOException {
UseSharedCacheResourceResponse response = recordFactory.newRecordInstance(UseSharedCacheResourceResponse.class);
UserGroupInformation callerUGI;
try {
callerUGI = UserGroupInformation.getCurrentUser();
} catch (IOException ie) {
LOG.info("Error getting UGI ", ie);
throw RPCUtil.getRemoteException(ie);
}
String fileName = this.store.addResourceReference(request.getResourceKey(), new SharedCacheResourceReference(request.getAppId(), callerUGI.getShortUserName()));
if (fileName != null) {
response.setPath(getCacheEntryFilePath(request.getResourceKey(), fileName));
this.metrics.incCacheHitCount();
} else {
this.metrics.incCacheMissCount();
}
return response;
}
use of org.apache.hadoop.yarn.server.sharedcachemanager.store.SharedCacheResourceReference in project hadoop by apache.
the class ClientProtocolService method release.
@Override
public ReleaseSharedCacheResourceResponse release(ReleaseSharedCacheResourceRequest request) throws YarnException, IOException {
ReleaseSharedCacheResourceResponse response = recordFactory.newRecordInstance(ReleaseSharedCacheResourceResponse.class);
UserGroupInformation callerUGI;
try {
callerUGI = UserGroupInformation.getCurrentUser();
} catch (IOException ie) {
LOG.info("Error getting UGI ", ie);
throw RPCUtil.getRemoteException(ie);
}
boolean removed = this.store.removeResourceReference(request.getResourceKey(), new SharedCacheResourceReference(request.getAppId(), callerUGI.getShortUserName()), true);
if (removed) {
this.metrics.incCacheRelease();
}
return response;
}
use of org.apache.hadoop.yarn.server.sharedcachemanager.store.SharedCacheResourceReference in project hadoop by apache.
the class TestClientSCMProtocolService method testRelease_ExistingEntry_NonExistantAppId.
@Test
public void testRelease_ExistingEntry_NonExistantAppId() 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 releases = ClientSCMMetrics.getInstance().getCacheReleases();
ReleaseSharedCacheResourceRequest request = recordFactory.newRecordInstance(ReleaseSharedCacheResourceRequest.class);
request.setResourceKey("key1");
request.setAppId(createAppId(2, 2L));
clientSCMProxy.release(request);
assertEquals(1, store.getResourceReferences("key1").size());
assertEquals("Client SCM metrics were updated when a release did not happen", 0, ClientSCMMetrics.getInstance().getCacheReleases() - releases);
}
use of org.apache.hadoop.yarn.server.sharedcachemanager.store.SharedCacheResourceReference 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.sharedcachemanager.store.SharedCacheResourceReference 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);
}
Aggregations