Search in sources :

Example 1 with SharedCacheResourceReference

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;
}
Also used : SharedCacheResourceReference(org.apache.hadoop.yarn.server.sharedcachemanager.store.SharedCacheResourceReference) UseSharedCacheResourceResponse(org.apache.hadoop.yarn.api.protocolrecords.UseSharedCacheResourceResponse) IOException(java.io.IOException) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation)

Example 2 with SharedCacheResourceReference

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;
}
Also used : ReleaseSharedCacheResourceResponse(org.apache.hadoop.yarn.api.protocolrecords.ReleaseSharedCacheResourceResponse) SharedCacheResourceReference(org.apache.hadoop.yarn.server.sharedcachemanager.store.SharedCacheResourceReference) IOException(java.io.IOException) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation)

Example 3 with SharedCacheResourceReference

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

Example 4 with SharedCacheResourceReference

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);
}
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 5 with SharedCacheResourceReference

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

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