Source:
private void repartitionEventType( final EventType original, final EventType newEventType) throws InvalidEventTypeException { final EventTypeStatistics existingStatistics = original.getDefaultStatistic(); final EventTypeStatistics newStatistics = newEventType.getDefaultStatistic(); if (newStatistics == null) { return; } if (existingStatistics == null) { updateNumberOfPartitions(original, newEventType, Math.max(newStatistics.getReadParallelism(), newStatistics.getWriteParallelism())); return; } if (existingStatistics.getReadParallelism().equals(newStatistics.getReadParallelism()) && existingStatistics.getWriteParallelism().equals(newStatistics.getWriteParallelism())) { return; } final int newMaxPartitions = Math.max(newStatistics.getReadParallelism(), newStatistics.getWriteParallelism()); final int oldMaxPartitions = Math.max(existingStatistics.getReadParallelism(), existingStatistics.getWriteParallelism()); if (newMaxPartitions > nakadiSettings.getMaxTopicPartitionCount()) { throw new InvalidEventTypeException("Number of partitions should not be more than " + nakadiSettings.getMaxTopicPartitionCount()); } if (newMaxPartitions < oldMaxPartitions) { throw new InvalidEventTypeException("Read and write parallelism should be greater " + "than existing values."); } if (newMaxPartitions == oldMaxPartitions) { if ((existingStatistics.getReadParallelism() != newStatistics.getReadParallelism()) || (existingStatistics.getWriteParallelism() != newStatistics.getWriteParallelism())) { throw new InvalidEventTypeException("Read and write parallelism can be changed only to change" + "the number of partition (max of read and write parallelism)"); } } updateNumberOfPartitions(original, newEventType, newMaxPartitions); }

Target:
private void repartitionEventType( final EventType original, final EventType newEventType) throws InvalidEventTypeException { final EventTypeStatistics existingStatistics = original.getDefaultStatistic(); final EventTypeStatistics newStatistics = newEventType.getDefaultStatistic(); if (newStatistics == null) { return; } if (existingStatistics == null) { if (getMaxPartitions(newStatistics) == 1) { return; } else { updateNumberOfPartitions(original, newEventType, getMaxPartitions(newStatistics)); return; } } if (existingStatistics.equals(newStatistics)) { return; } final int newMaxPartitions = getMaxPartitions(newStatistics); final int oldMaxPartitions = getMaxPartitions(existingStatistics); if (newMaxPartitions > nakadiSettings.getMaxTopicPartitionCount()) { throw new InvalidEventTypeException("Number of partitions should not be more than " + nakadiSettings.getMaxTopicPartitionCount()); } if (newMaxPartitions < oldMaxPartitions) { throw new InvalidEventTypeException("Read and write parallelism should be greater " + "than existing values."); } if (newMaxPartitions == oldMaxPartitions) { if ((existingStatistics.getReadParallelism() != newStatistics.getReadParallelism()) || (existingStatistics.getWriteParallelism() != newStatistics.getWriteParallelism())) { throw new InvalidEventTypeException("Read and write parallelism can be changed only to change" + "the number of partition (max of read and write parallelism)"); } } updateNumberOfPartitions(original, newEventType, newMaxPartitions); }