public static Cluster dropZone ( Cluster intermediateCluster , int dropZoneId ) { // Filter out nodes that don't belong to the zone being dropped Set < Node > survivingNodes = new HashSet < Node > ( ) ; for ( int nodeId : intermediateCluster . getNodeIds ( ) ) { if ( intermediateCluster . getNodeById ( nodeId ) . getZoneId ( ) != dropZoneId ) { survivingNodes . add ( intermediateCluster . getNodeById ( nodeId ) ) ; } } // Filter out dropZoneId from all zones Set < Zone > zones = new HashSet < Zone > ( ) ; for ( int zoneId : intermediateCluster . getZoneIds ( ) ) { if ( zoneId == dropZoneId ) { continue ; } List < Integer > proximityList = intermediateCluster . getZoneById ( zoneId ) . getProximityList ( ) ; proximityList . remove ( new Integer ( dropZoneId ) ) ; zones . add ( new Zone ( zoneId , proximityList ) ) ; } return new Cluster ( intermediateCluster . getName ( ) , Utils . asSortedList ( survivingNodes ) , Utils . asSortedList ( zones ) ) ; }
Given a interim cluster with a previously vacated zone constructs a new cluster object with the drop zone completely removed