List of usage examples for java.util SortedMap clear
void clear();
From source file:org.apache.hadoop.hbase.replication.ReplicationZookeeper.java
/** * It "atomically" copies all the hlogs queues from another region server and returns them all * sorted per peer cluster (appended with the dead server's znode). * @param znode//from w w w. j av a 2 s . com * @return HLog queues sorted per peer cluster */ public SortedMap<String, SortedSet<String>> copyQueuesFromRSUsingMulti(String znode) { SortedMap<String, SortedSet<String>> queues = new TreeMap<String, SortedSet<String>>(); String deadRSZnodePath = ZKUtil.joinZNode(rsZNode, znode);// hbase/replication/rs/deadrs List<String> peerIdsToProcess = null; List<ZKUtilOp> listOfOps = new ArrayList<ZKUtil.ZKUtilOp>(); try { peerIdsToProcess = ZKUtil.listChildrenNoWatch(this.zookeeper, deadRSZnodePath); if (peerIdsToProcess == null) return queues; // node already processed for (String peerId : peerIdsToProcess) { String newPeerId = peerId + "-" + znode; String newPeerZnode = ZKUtil.joinZNode(this.rsServerNameZnode, newPeerId); // check the logs queue for the old peer cluster String oldClusterZnode = ZKUtil.joinZNode(deadRSZnodePath, peerId); List<String> hlogs = ZKUtil.listChildrenNoWatch(this.zookeeper, oldClusterZnode); if (hlogs == null || hlogs.size() == 0) continue; // empty log queue. // create the new cluster znode SortedSet<String> logQueue = new TreeSet<String>(); queues.put(newPeerId, logQueue); ZKUtilOp op = ZKUtilOp.createAndFailSilent(newPeerZnode, HConstants.EMPTY_BYTE_ARRAY); listOfOps.add(op); // get the offset of the logs and set it to new znodes for (String hlog : hlogs) { String oldHlogZnode = ZKUtil.joinZNode(oldClusterZnode, hlog); byte[] logOffset = ZKUtil.getData(this.zookeeper, oldHlogZnode); LOG.debug("Creating " + hlog + " with data " + Bytes.toString(logOffset)); String newLogZnode = ZKUtil.joinZNode(newPeerZnode, hlog); listOfOps.add(ZKUtilOp.createAndFailSilent(newLogZnode, logOffset)); // add ops for deleting listOfOps.add(ZKUtilOp.deleteNodeFailSilent(oldHlogZnode)); logQueue.add(hlog); } // add delete op for peer listOfOps.add(ZKUtilOp.deleteNodeFailSilent(oldClusterZnode)); } // add delete op for dead rs listOfOps.add(ZKUtilOp.deleteNodeFailSilent(deadRSZnodePath)); LOG.debug(" The multi list size is: " + listOfOps.size()); ZKUtil.multiOrSequential(this.zookeeper, listOfOps, false); LOG.info("Atomically moved the dead regionserver logs. "); } catch (KeeperException e) { // Multi call failed; it looks like some other regionserver took away the logs. LOG.warn("Got exception in copyQueuesFromRSUsingMulti: ", e); queues.clear(); } return queues; }
From source file:org.codehaus.mojo.license.LicenseMap.java
public SortedMap<MavenProject, String[]> toDependencyMap() { SortedMap<MavenProject, Set<String>> tmp = new TreeMap<MavenProject, Set<String>>( ArtifactHelper.getProjectComparator()); for (Map.Entry<String, SortedSet<MavenProject>> entry : entrySet()) { String license = entry.getKey(); SortedSet<MavenProject> set = entry.getValue(); for (MavenProject p : set) { Set<String> list = tmp.get(p); if (list == null) { list = new HashSet<String>(); tmp.put(p, list);/*from ww w.j ava2 s .co m*/ } list.add(license); } } SortedMap<MavenProject, String[]> result = new TreeMap<MavenProject, String[]>( ArtifactHelper.getProjectComparator()); for (Map.Entry<MavenProject, Set<String>> entry : tmp.entrySet()) { List<String> value = new ArrayList<String>(entry.getValue()); Collections.sort(value); result.put(entry.getKey(), value.toArray(new String[value.size()])); } tmp.clear(); return result; }
From source file:org.opencms.workplace.CmsWidgetDialogParameter.java
/** * Prepares this widget dialog parameter to be commited.<p> * /*from w ww . j a va2 s .co m*/ * This is required if the base type is mapped to a Collection object, * becasue the collection needs to be cleared before the new values are set.<p> */ public void prepareCommit() { if (m_baseCollection instanceof List) { List<?> list = (List<?>) m_baseCollection; list.clear(); } else if (m_baseCollection instanceof SortedMap) { SortedMap<?, ?> map = (SortedMap<?, ?>) m_baseCollection; map.clear(); } }