public void mockFileInSharedCache(Path localFile, URL remoteFile) throws YarnException, IOException { // when the resource is referenced, simply return the remote path to the // caller when(mockscClient.use(any(ApplicationId.class), eq(scClient.getFileChecksum(localFile)))).thenReturn(remoteFile); }
MyFileUploader(FileSystem submitFs, Configuration conf) throws IOException { super(submitFs, false); // Initialize the real client, but don't start it. We don't need or want // to create an actual proxy because we only use this for mocking out the // getFileChecksum method. scClient.init(conf); when(mockscClient.getFileChecksum(any(Path.class))).thenAnswer( new Answer<String>() { @Override public String answer(InvocationOnMock invocation) throws Throwable { Path file = (Path) invocation.getArguments()[0]; // Use the real scClient to generate the checksum. We use an // answer/mock combination to avoid having to spy on a real // SharedCacheClient object. return scClient.getFileChecksum(file); } }); }
@Override protected void serviceStop() throws Exception { stopClientProxy(); super.serviceStop(); }
@Override protected void serviceInit(Configuration conf) throws Exception { if (this.scmAddress == null) { this.scmAddress = getScmAddress(conf); } this.conf = conf; this.checksum = SharedCacheChecksumFactory.getChecksum(conf); super.serviceInit(conf); }
@Override protected void serviceStart() throws Exception { this.scmClient = createClientProxy(); if (LOG.isDebugEnabled()) { LOG.debug("Connecting to Shared Cache Manager at " + this.scmAddress); } super.serviceStart(); }
@Override public String answer(InvocationOnMock invocation) throws Throwable { Path file = (Path) invocation.getArguments()[0]; // Use the real scClient to generate the checksum. We use an // answer/mock combination to avoid having to spy on a real // SharedCacheClient object. return scClient.getFileChecksum(file); } });
verify(fileUploader.mockscClient, times(useCallCountExpected)).use( any(ApplicationId.class), anyString());
@Override protected void serviceStop() throws Exception { stopClientProxy(); super.serviceStop(); }
@Override protected void serviceInit(Configuration conf) throws Exception { if (this.scmAddress == null) { this.scmAddress = getScmAddress(conf); } this.conf = conf; this.checksum = SharedCacheChecksumFactory.getChecksum(conf); super.serviceInit(conf); }
@Override protected void serviceStart() throws Exception { this.scmClient = createClientProxy(); if (LOG.isDebugEnabled()) { LOG.debug("Connecting to Shared Cache Manager at " + this.scmAddress); } super.serviceStart(); }
@Override protected void serviceStop() throws Exception { stopClientProxy(); super.serviceStop(); }
@Override protected void serviceInit(Configuration conf) throws Exception { if (this.scmAddress == null) { this.scmAddress = getScmAddress(conf); } this.conf = conf; this.checksum = SharedCacheChecksumFactory.getChecksum(conf); super.serviceInit(conf); }
@Override protected void serviceStart() throws Exception { this.scmClient = createClientProxy(); if (LOG.isDebugEnabled()) { LOG.debug("Connecting to Shared Cache Manager at " + this.scmAddress); } super.serviceStart(); }
@Override protected void serviceStop() throws Exception { stopClientProxy(); super.serviceStop(); }
@Override protected void serviceInit(Configuration conf) throws Exception { if (this.scmAddress == null) { this.scmAddress = getScmAddress(conf); } this.conf = conf; this.checksum = SharedCacheChecksumFactory.getChecksum(conf); super.serviceInit(conf); }
@Override protected void serviceStart() throws Exception { this.scmClient = createClientProxy(); if (LOG.isDebugEnabled()) { LOG.debug("Connecting to Shared Cache Manager at " + this.scmAddress); } super.serviceStart(); }