List of usage examples for java.util.concurrent PriorityBlockingQueue clear
public void clear()
From source file:org.apache.hadoop.hbase.replication.regionserver.RecoveredReplicationSource.java
public void locateRecoveredPaths(PriorityBlockingQueue<Path> queue) throws IOException { boolean hasPathChanged = false; PriorityBlockingQueue<Path> newPaths = new PriorityBlockingQueue<Path>(queueSizePerGroup, new LogsComparator()); pathsLoop: for (Path path : queue) { if (fs.exists(path)) { // still in same location, don't need to do anything newPaths.add(path);// www.java2 s.c o m continue; } // Path changed - try to find the right path. hasPathChanged = true; if (stopper instanceof ReplicationSyncUp.DummyServer) { // In the case of disaster/recovery, HMaster may be shutdown/crashed before flush data // from .logs to .oldlogs. Loop into .logs folders and check whether a match exists Path newPath = getReplSyncUpPath(path); newPaths.add(newPath); continue; } else { // See if Path exists in the dead RS folder (there could be a chain of failures // to look at) List<String> deadRegionServers = this.replicationQueueInfo.getDeadRegionServers(); LOG.info("NB dead servers : " + deadRegionServers.size()); final Path walDir = FSUtils.getWALRootDir(conf); for (String curDeadServerName : deadRegionServers) { final Path deadRsDirectory = new Path(walDir, AbstractFSWALProvider.getWALDirectoryName(curDeadServerName)); Path[] locs = new Path[] { new Path(deadRsDirectory, path.getName()), new Path(deadRsDirectory.suffix(AbstractFSWALProvider.SPLITTING_EXT), path.getName()) }; for (Path possibleLogLocation : locs) { LOG.info("Possible location " + possibleLogLocation.toUri().toString()); if (manager.getFs().exists(possibleLogLocation)) { // We found the right new location LOG.info("Log " + path + " still exists at " + possibleLogLocation); newPaths.add(possibleLogLocation); continue pathsLoop; } } } // didn't find a new location LOG.error(String.format("WAL Path %s doesn't exist and couldn't find its new location", path)); newPaths.add(path); } } if (hasPathChanged) { if (newPaths.size() != queue.size()) { // this shouldn't happen LOG.error("Recovery queue size is incorrect"); throw new IOException("Recovery queue size error"); } // put the correct locations in the queue // since this is a recovered queue with no new incoming logs, // there shouldn't be any concurrency issues queue.clear(); for (Path path : newPaths) { queue.add(path); } } }