public static Cluster cloneCluster ( Cluster cluster ) { // Could add a better .clone() implementation that clones the derived // data structures. The constructor invoked by this clone implementation // can be slow for large numbers of partitions. Probably faster to copy // all the maps and stuff. return new Cluster ( cluster . getName ( ) , new ArrayList < Node > ( cluster . getNodes ( ) ) , new ArrayList < Zone > ( cluster . getZones ( ) ) ) ; /*- * Historic "clone" code being kept in case this, for some reason, was the "right" way to be doing this. ClusterMapper mapper = new ClusterMapper(); return mapper.readCluster(new StringReader(mapper.writeCluster(cluster))); */ }
Clones the cluster by constructing a new one with same name partition layout and nodes .