Source:
public void repartition(final EventType eventType, final int partitions) throws InternalNakadiException, NakadiRuntimeException { if (partitions > nakadiSettings.getMaxTopicPartitionCount()) { throw new InvalidEventTypeException("Number of partitions should not be more than " + nakadiSettings.getMaxTopicPartitionCount()); } EventTypeStatistics defaultStatistic = eventType.getDefaultStatistic(); if (defaultStatistic == null) { defaultStatistic = new EventTypeStatistics(1, 1); eventType.setDefaultStatistic(defaultStatistic); } final int currentPartitionsNumber = Math.max(defaultStatistic.getReadParallelism(), defaultStatistic.getWriteParallelism()); if (partitions < currentPartitionsNumber) { throw new InvalidEventTypeException("Number of partitions should be greater " + "than existing values."); } LOG.info("Start repartitioning for to partitions", eventType.getName(), partitions); Closeable closeable = null; try { closeable = timelineSync.workWithEventType(eventType.getName(), nakadiSettings.getTimelineWaitTimeoutMs()); timelineService.updateTimeLineForRepartition(eventType, partitions); updateSubscriptionsForRepartitioning(eventType, partitions); try { defaultStatistic.setReadParallelism(partitions); defaultStatistic.setWriteParallelism(partitions); eventTypeRepository.update(eventType); } catch (Exception e) { throw new NakadiBaseException(e.getMessage(), e); } } catch (final InterruptedException e) { Thread.currentThread().interrupt(); LOG.error("Failed to wait for timeline switch", e); throw new EventTypeUnavailableException("Event type " + eventType.getName() + " is currently in maintenance, please repeat request"); } catch (final TimeoutException e) { LOG.error("Failed to wait for timeline switch", e); throw new EventTypeUnavailableException("Event type " + eventType.getName() + " is currently in maintenance, please repeat request"); } catch (final InternalNakadiException | ServiceTemporarilyUnavailableException e) { LOG.error("Error deleting event type " + eventType.getName(), e); throw new EventTypeDeletionException("Failed to repartition event type " + eventType.getName()); } finally { try { if (closeable != null) { closeable.close(); } } catch (final IOException e) { LOG.error("Exception occurred when releasing usage of event-type", e); } } }

Target:
public void repartition(final EventType eventType, final int partitions) throws InternalNakadiException, NakadiRuntimeException { if (partitions > nakadiSettings.getMaxTopicPartitionCount()) { throw new InvalidEventTypeException("Number of partitions should not be more than " + nakadiSettings.getMaxTopicPartitionCount()); } EventTypeStatistics defaultStatistic = eventType.getDefaultStatistic(); if (defaultStatistic == null) { defaultStatistic = new EventTypeStatistics(1, 1); eventType.setDefaultStatistic(defaultStatistic); } final int currentPartitionsNumber = Math.max(defaultStatistic.getReadParallelism(), defaultStatistic.getWriteParallelism()); if (partitions < currentPartitionsNumber) { throw new InvalidEventTypeException("Number of partitions should be greater " + "than existing values."); } LOG.info("Start repartitioning for to partitions", eventType.getName(), partitions); Closeable closeable = null; try { closeable = timelineSync.workWithEventType(eventType.getName(), nakadiSettings.getTimelineWaitTimeoutMs()); timelineService.updateTimeLineForRepartition(eventType, partitions); updateSubscriptionsForRepartitioning(eventType, partitions); try { defaultStatistic.setReadParallelism(partitions); defaultStatistic.setWriteParallelism(partitions); eventTypeRepository.update(eventType); } catch (Exception e) { throw new NakadiBaseException(e.getMessage(), e); } } catch (final InterruptedException e) { Thread.currentThread().interrupt(); LOG.error("Failed to wait for timeline switch", e); throw new EventTypeUnavailableException("Event type " + eventType.getName() + " is currently in maintenance, please repeat request"); } catch (final TimeoutException e) { LOG.error("Failed to wait for timeline switch", e); throw new EventTypeUnavailableException("Event type " + eventType.getName() + " is currently in maintenance, please repeat request"); } finally { try { if (closeable != null) { closeable.close(); } } catch (final IOException e) { LOG.error("Exception occurred when releasing usage of event-type", e); } } }