@Test public void testIsDead() { DeadServer ds = new DeadServer(); ds.add(hostname123); ds.notifyServer(hostname123); assertTrue(ds.areDeadServersInProgress()); ds.finish(hostname123); assertFalse(ds.areDeadServersInProgress()); ds.add(hostname1234); ds.notifyServer(hostname1234); assertTrue(ds.areDeadServersInProgress()); ds.finish(hostname1234); assertFalse(ds.areDeadServersInProgress()); ds.add(hostname12345); ds.notifyServer(hostname12345); assertTrue(ds.areDeadServersInProgress()); ds.finish(hostname12345); assertFalse(ds.areDeadServersInProgress()); assertFalse(ds.cleanPreviousInstance(deadServer)); ds.add(deadServer); assertTrue(ds.isDeadServer(deadServer)); Set<ServerName> deadServerNames = ds.copyServerNames(); for (ServerName eachDeadServer : deadServerNames) { Assert.assertNotNull(ds.getTimeOfDeath(eachDeadServer)); assertTrue(ds.cleanPreviousInstance(deadServerHostComingAlive)); assertFalse(ds.isDeadServer(deadServer)); assertFalse(ds.cleanPreviousInstance(deadServerHostComingAlive));
/** * Get the servers which died since a given timestamp. * protected because it can be subclassed by the tests. */ protected List<Pair<ServerName, Long>> getDeadServers(long since) { if (master.getServerManager() == null) { return Collections.emptyList(); } return master.getServerManager().getDeadServers().copyDeadServersSince(since); }
@Test public void testClearDeadServer(){ DeadServer d = new DeadServer(); d.add(hostname123); d.add(hostname1234); Assert.assertEquals(2, d.size()); d.finish(hostname123); d.removeDeadServer(hostname123); Assert.assertEquals(1, d.size()); d.finish(hostname1234); d.removeDeadServer(hostname1234); Assert.assertTrue(d.isEmpty()); d.add(hostname1234); Assert.assertFalse(d.removeDeadServer(hostname123_2)); Assert.assertEquals(1, d.size()); d.finish(hostname1234); Assert.assertTrue(d.removeDeadServer(hostname1234)); Assert.assertTrue(d.isEmpty()); } }
/** * If this server is on the dead list, reject it with a YouAreDeadException. * If it was dead but came back with a new start code, remove the old entry * from the dead list. * @param what START or REPORT */ private void checkIsDead(final ServerName serverName, final String what) throws YouAreDeadException { if (this.deadservers.isDeadServer(serverName)) { // host name, port and start code all match with existing one of the // dead servers. So, this server must be dead. String message = "Server " + what + " rejected; currently processing " + serverName + " as dead server"; LOG.debug(message); throw new YouAreDeadException(message); } // remove dead server with same hostname and port of newly checking in rs after master // initialization.See HBASE-5916 for more information. if ((this.master == null || this.master.isInitialized()) && this.deadservers.cleanPreviousInstance(serverName)) { // This server has now become alive after we marked it as dead. // We removed it's previous entry from the dead list to reflect it. LOG.debug(what + ":" + " Server " + serverName + " came back up," + " removed it from the dead servers list"); } }
@Test public void testClean(){ DeadServer d = new DeadServer(); d.add(hostname123); d.cleanPreviousInstance(hostname12345); Assert.assertFalse(d.isEmpty()); d.cleanPreviousInstance(hostname1234); Assert.assertFalse(d.isEmpty()); d.cleanPreviousInstance(hostname123_2); Assert.assertTrue(d.isEmpty()); }
@Override public String getDeadRegionServers() { ServerManager serverManager = this.master.getServerManager(); if (serverManager == null) { return ""; } return StringUtils.join(serverManager.getDeadServers().copyServerNames(), ";"); }
@Test public void testSortExtract(){ ManualEnvironmentEdge mee = new ManualEnvironmentEdge(); EnvironmentEdgeManager.injectEdge(mee); mee.setValue(1); DeadServer d = new DeadServer(); d.add(hostname123); mee.incValue(1); d.add(hostname1234); mee.incValue(1); d.add(hostname12345); List<Pair<ServerName, Long>> copy = d.copyDeadServersSince(2L); Assert.assertEquals(2, copy.size()); Assert.assertEquals(hostname1234, copy.get(0).getFirst()); Assert.assertEquals(new Long(2L), copy.get(0).getSecond()); Assert.assertEquals(hostname12345, copy.get(1).getFirst()); Assert.assertEquals(new Long(3L), copy.get(1).getSecond()); EnvironmentEdgeManager.reset(); }
/** * Check if a server is known to be dead. A server can be online, * or known to be dead, or unknown to this manager (i.e, not online, * not known to be dead either. it is simply not tracked by the * master any more, for example, a very old previous instance). */ public synchronized boolean isServerDead(ServerName serverName) { return serverName == null || deadservers.isDeadServer(serverName); }
services.getServerManager().getDeadServers().notifyServer(serverName); notifiedDeadServer = true; LOG.info("removed crashed server {} after splitting done", serverName); services.getAssignmentManager().getRegionStates().removeServer(serverName); services.getServerManager().getDeadServers().finish(serverName); updateProgress(true); return Flow.NO_MORE_STATE;
this.deadServers.add(serverName); throw new IOException("failed log splitting for " + serverName + ", will retry", ioe); this.services.getExecutorService().submit(new ServerShutdownHandler( this.server, this.services, this.deadServers, serverName, false)); this.deadServers.add(serverName); return; + " have been re-assigned."); } finally { this.deadServers.finish(serverName);
/** * Checks if any dead servers are currently in progress. * @return true if any RS are being processed as dead, false if not */ public boolean areDeadServersInProgress() { return this.deadservers.areDeadServersInProgress(); }
@VisibleForTesting public void moveFromOnlineToDeadServers(final ServerName sn) { synchronized (onlineServers) { if (!this.onlineServers.containsKey(sn)) { LOG.trace("Expiration of {} but server not online", sn); } // Remove the server from the known servers lists and update load info BUT // add to deadservers first; do this so it'll show in dead servers list if // not in online servers list. this.deadservers.add(sn); this.onlineServers.remove(sn); onlineServers.notifyAll(); } this.rsAdmins.remove(sn); }
/** * Extract all the servers dead since a given time, and sort them. * @param ts the time, 0 for all * @return a sorted array list, by death time, lowest values first. */ public synchronized List<Pair<ServerName, Long>> copyDeadServersSince(long ts){ List<Pair<ServerName, Long>> res = new ArrayList<>(size()); for (Map.Entry<ServerName, Long> entry:deadServers.entrySet()){ if (entry.getValue() >= ts){ res.add(new Pair<>(entry.getKey(), entry.getValue())); } } Collections.sort(res, ServerNameDeathDateComparator); return res; }
org.jamon.escaping.Escaping.NONE.write(org.jamon.emit.StandardEmitter.valueOf(deadServerUtil.getTimeOfDeath(deadServerName)), jamonWriter);
@Test public void testClean(){ DeadServer d = new DeadServer(); d.add(hostname123); d.cleanPreviousInstance(hostname12345); Assert.assertFalse(d.isEmpty()); d.cleanPreviousInstance(hostname1234); Assert.assertFalse(d.isEmpty()); d.cleanPreviousInstance(hostname123_2); Assert.assertTrue(d.isEmpty()); }
for(ServerName server: master.getServerManager().getDeadServers().copyServerNames()) { deadServers.add(server.getAddress());
/** * If this server is on the dead list, reject it with a YouAreDeadException. * If it was dead but came back with a new start code, remove the old entry * from the dead list. * @param serverName * @param what START or REPORT * @throws YouAreDeadException */ private void checkIsDead(final ServerName serverName, final String what) throws YouAreDeadException { if (this.deadservers.isDeadServer(serverName)) { // host name, port and start code all match with existing one of the // dead servers. So, this server must be dead. String message = "Server " + what + " rejected; currently processing " + serverName + " as dead server"; LOG.debug(message); throw new YouAreDeadException(message); } // remove dead server with same hostname and port of newly checking in rs after master // initialization.See HBASE-5916 for more information. if ((this.services == null || ((HMaster) this.services).isInitialized()) && this.deadservers.cleanPreviousInstance(serverName)) { // This server has now become alive after we marked it as dead. // We removed it's previous entry from the dead list to reflect it. LOG.debug(what + ":" + " Server " + serverName + " came back up," + " removed it from the dead servers list"); } }
@Test public void testSortExtract(){ ManualEnvironmentEdge mee = new ManualEnvironmentEdge(); EnvironmentEdgeManager.injectEdge(mee); mee.setValue(1); DeadServer d = new DeadServer(); d.add(hostname123); mee.incValue(1); d.add(hostname1234); mee.incValue(1); d.add(hostname12345); List<Pair<ServerName, Long>> copy = d.copyDeadServersSince(2L); Assert.assertEquals(2, copy.size()); Assert.assertEquals(hostname1234, copy.get(0).getFirst()); Assert.assertEquals(new Long(2L), copy.get(0).getSecond()); Assert.assertEquals(hostname12345, copy.get(1).getFirst()); Assert.assertEquals(new Long(3L), copy.get(1).getSecond()); EnvironmentEdgeManager.reset(); }
private void waitForRSShutdownToStartAndFinish(JVMClusterUtil.MasterThread activeMaster, ServerName serverName) throws InterruptedException { ServerManager sm = activeMaster.getMaster().getServerManager(); // First wait for it to be in dead list while (!sm.getDeadServers().isDeadServer(serverName)) { LOG.debug("Waiting for [" + serverName + "] to be listed as dead in master"); Thread.sleep(SLEEP_TIME); } LOG.debug("Server [" + serverName + "] marked as dead, waiting for it to " + "finish dead processing"); while (sm.areDeadServersInProgress()) { LOG.debug("Server [" + serverName + "] still being processed, waiting"); Thread.sleep(SLEEP_TIME); } LOG.debug("Server [" + serverName + "] done with server shutdown processing"); } }