private void stopCommonServices() { if(rpcServer != null) rpcServer.stop(); if(namesystem != null) namesystem.close(); if (pauseMonitor != null) pauseMonitor.stop(); if (plugins != null) { for (ServicePlugin p : plugins) { try { p.stop(); } catch (Throwable t) { LOG.warn("ServicePlugin " + p + " could not be stopped", t); } } } stopHttpServer(); }
} finally { if (fsn != null) fsn.close();
/** * FSNamesystem constructor. */ FSNamesystem(NameNode nn, Configuration conf) throws IOException { try { initialize(nn, conf); } catch(IOException e) { LOG.error(getClass().getSimpleName() + " initialization failed.", e); close(); throw e; } }
/** * Cleans the resources and closes the instance of FSNamesystem * @throws IOException if an error occurred */ @After public void tearDown() throws IOException { if (fsn != null) { try { fsn.close(); } catch(Exception e) { LOG.error("Cannot close: ", e); } finally { File dir = new File(NAME_DIR); if (dir != null) assertTrue("Cannot delete name-node dirs", FileUtil.fullyDelete(dir)); } } }
/** * FSNamesystem constructor. */ FSNamesystem(NameNode nn, Configuration conf) throws IOException { super(conf); try { clusterMap = new NetworkTopology(conf); initialize(nn, getConf()); pathValidator = new PathValidator(conf); } catch (IOException e) { LOG.error(getClass().getSimpleName() + " initialization failed.", e); close(); throw e; } }
/** * Stop all NameNode threads and wait for all to finish. */ public void stop() { if (stopRequested) return; stopRequested = true; if(namesystem != null) namesystem.close(); if(emptier != null) emptier.interrupt(); if(server != null) server.stop(); if (myMetrics != null) { myMetrics.shutdown(); } if (namesystem != null) { namesystem.shutdown(); } }
private void stopCommonServices() { if(rpcServer != null) rpcServer.stop(); if(namesystem != null) namesystem.close(); if (pauseMonitor != null) pauseMonitor.stop(); if (plugins != null) { for (ServicePlugin p : plugins) { try { p.stop(); } catch (Throwable t) { LOG.warn("ServicePlugin " + p + " could not be stopped", t); } } } stopHttpServer(); }
/** * Stop all NameNode threads and wait for all to finish. */ public void stop() { if (stopRequested) return; stopRequested = true; try { if (httpServer != null) httpServer.stop(); } catch (Exception e) { LOG.error(StringUtils.stringifyException(e)); } if(namesystem != null) namesystem.close(); if(emptier != null) emptier.interrupt(); if(server != null) server.stop(); if (dnProtocolServer != null) dnProtocolServer.stop(); if (myMetrics != null) { myMetrics.shutdown(); } if (namesystem != null) { namesystem.shutdown(); } }
private void stopCommonServices() { if(rpcServer != null) rpcServer.stop(); if(namesystem != null) namesystem.close(); if (pauseMonitor != null) pauseMonitor.stop(); if (plugins != null) { for (ServicePlugin p : plugins) { try { p.stop(); } catch (Throwable t) { LOG.warn("ServicePlugin " + p + " could not be stopped", t); } } } stopHttpServer(); }
} finally { if (fsn != null) fsn.close();
@Test(timeout = 30000) public void testGetBlockLocationsRacingWithDelete() throws IOException { FSNamesystem fsn = spy(setupFileSystem()); final FSDirectory fsd = fsn.getFSDirectory(); FSEditLog editlog = fsn.getEditLog(); doAnswer(new Answer<Void>() { @Override public Void answer(InvocationOnMock invocation) throws Throwable { INodesInPath iip = fsd.getINodesInPath(FILE_PATH, true); FSDirDeleteOp.delete(fsd, iip, new INode.BlocksMapUpdateInfo(), new ArrayList<INode>(), now()); invocation.callRealMethod(); return null; } }).when(fsn).writeLock(); fsn.getBlockLocations("dummy", RESERVED_PATH, 0, 1024); verify(editlog, never()).logTimes(anyString(), anyLong(), anyLong()); fsn.close(); }
@Test(timeout = 30000) public void testResolveReservedPath() throws IOException { FSNamesystem fsn = setupFileSystem(); FSEditLog editlog = fsn.getEditLog(); fsn.getBlockLocations("dummy", RESERVED_PATH, 0, 1024); verify(editlog).logTimes(eq(FILE_PATH), anyLong(), anyLong()); fsn.close(); }
@Test(timeout = 30000) public void testGetBlockLocationsRacingWithRename() throws IOException { FSNamesystem fsn = spy(setupFileSystem()); final FSDirectory fsd = fsn.getFSDirectory(); FSEditLog editlog = fsn.getEditLog(); final String DST_PATH = "/bar"; final boolean[] renamed = new boolean[1]; doAnswer(new Answer<Void>() { @Override public Void answer(InvocationOnMock invocation) throws Throwable { invocation.callRealMethod(); if (!renamed[0]) { FSDirRenameOp.renameTo(fsd, fsd.getPermissionChecker(), FILE_PATH, DST_PATH, new INode.BlocksMapUpdateInfo(), false); renamed[0] = true; } return null; } }).when(fsn).writeLock(); fsn.getBlockLocations("dummy", RESERVED_PATH, 0, 1024); verify(editlog).logTimes(eq(DST_PATH), anyLong(), anyLong()); fsn.close(); }
@Test public void testRetryCacheMetrics() throws IOException { checkMetrics(0, 0, 0); // DFS_CLIENT_TEST_DROP_NAMENODE_RESPONSE_NUM_KEY is 2 , // so 2 requests are dropped at first. // After that, 1 request will reach NameNode correctly. trySaveNamespace(); checkMetrics(2, 0, 1); // RetryCache will be cleared after Namesystem#close() namesystem.close(); checkMetrics(2, 1, 1); }
} finally { if (fsn != null) fsn.close();