/** * Check whether there are ongoing partition reassignments and wait for the reassignments to finish. * * @param zkUtils the ZkUtils class used to check ongoing partition reassignments. * @return Whether there are no ongoing partition reassignments. */ public static boolean ensureNoPartitionUnderPartitionReassignment(ZkUtils zkUtils) { int attempt = 0; while (zkUtils.getPartitionsBeingReassigned().size() > 0) { try { sleep(1000 << attempt); } catch (InterruptedException e) { // Let it go. } if (++attempt == 10) { return false; } } return true; } }
/** * Check whether the topic has partitions undergoing partition reassignment and wait for the reassignments to finish. * * @param zkUtils the ZkUtils class used to check ongoing partition reassignments. * @return Whether there are no ongoing partition reassignments. */ public static boolean ensureTopicNotUnderPartitionReassignment(ZkUtils zkUtils, String topic) { int attempt = 0; while (JavaConversions.asJavaCollection(zkUtils.getPartitionsBeingReassigned().keys()).stream() .anyMatch(tp -> tp.topic().equals(topic))) { try { sleep(1000 << attempt); } catch (InterruptedException e) { // Let it go. } if (++attempt == 10) { return false; } } return true; }
JavaConverters.mapAsJavaMapConverter(zkUtils.getPartitionsBeingReassigned()) .asJava() .entrySet()
scalaTpMap = zkUtils.getPartitionsBeingReassigned();
scalaTpMap = zkUtils.getPartitionsBeingReassigned();