private void whitelistCandiateTopics(Set<String> candidateTopicsToWhitelist) { for (String topic : candidateTopicsToWhitelist) { TopicPartition tp = _srcKafkaTopicObserver.getTopicPartition(topic); if (tp == null) { LOGGER.error("Shouldn't hit here, don't know why topic {} is not in src Kafka cluster", topic); _numErrorTopics.inc(); } else { if (_helixMirrorMakerManager.isTopicExisted(topic)) { LOGGER.info("Trying to expand topic: {} with {} partitions", tp.getTopic(), tp.getPartition()); _helixMirrorMakerManager.expandTopicInMirrorMaker(tp); _numAutoExpandedTopics.inc(); } else { LOGGER.info("Trying to whitelist topic: {} with {} partitions", tp.getTopic(), tp.getPartition()); _helixMirrorMakerManager.addTopicToMirrorMaker(tp); _numWhitelistedTopics.inc(); } } } }
@Override @Delete public Representation delete() { final String topicName = (String) getRequest().getAttributes().get("topicName"); if (_autoTopicWhitelistingManager != null) { _autoTopicWhitelistingManager.addIntoBlacklist(topicName); } if (!_helixMirrorMakerManager.isTopicExisted(topicName)) { getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND); return new StringRepresentation( String.format("Failed to delete not existed topic: %s", topicName)); } try { _helixMirrorMakerManager.deleteTopicInMirrorMaker(topicName); return new StringRepresentation( String.format("Successfully finished delete topic: %s", topicName)); } catch (Exception e) { getResponse().setStatus(Status.SERVER_ERROR_INTERNAL); LOGGER.error("Failed to delete topic: {}, with exception: {}", topicName, e); return new StringRepresentation( String.format("Failed to delete topic: %s, with exception: %s", topicName, e)); } }
if (_helixMirrorMakerManager.isTopicExisted(topicName)) { IdealState idealStateForTopic = _helixMirrorMakerManager.getIdealStateForTopic(topicName);
@Override @Put("json") public Representation put(Representation entity) { try { String jsonRequest = entity.getText(); TopicPartition topicPartitionInfo = TopicPartition.init(jsonRequest); if (_autoTopicWhitelistingManager != null) { _autoTopicWhitelistingManager.removeFromBlacklist(topicPartitionInfo.getTopic()); } if (_helixMirrorMakerManager.isTopicExisted(topicPartitionInfo.getTopic())) { _helixMirrorMakerManager.expandTopicInMirrorMaker(topicPartitionInfo); return new StringRepresentation( String.format("Successfully expand topic: %s", topicPartitionInfo)); } else { getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND); return new StringRepresentation(String.format( "Failed to expand topic, topic: %s is not existed!", topicPartitionInfo.getTopic())); } } catch (IOException e) { LOGGER.error("Got error during processing Put request", e); getResponse().setStatus(Status.SERVER_ERROR_INTERNAL); return new StringRepresentation( String.format("Failed to expand topic, with exception: %s", e)); } }
_autoTopicWhitelistingManager.removeFromBlacklist(topicPartitionInfo.getTopic()); if (_helixMirrorMakerManager.isTopicExisted(topicPartitionInfo.getTopic())) { getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND); return new StringRepresentation(String.format(
private boolean handleTopicAssignmentOffline(String topic, String srcCluster, String dstCluster) { HelixMirrorMakerManager helixManager = _currentControllerInstance.getHelixResourceManager(); if (!helixManager.isTopicExisted(topic)) { LOGGER.warn("Topic {} does not exist from cluster {} to {}", topic, srcCluster, dstCluster); return false; } helixManager.deleteTopicInMirrorMaker(topic); LOGGER.info("Blacklisted topic {} from {} to {}", topic, srcCluster, dstCluster); return true; }
private boolean handleTopicAssignmentOnline(String topic, String srcCluster, String dstCluster) { HelixMirrorMakerManager helixManager = _currentControllerInstance.getHelixResourceManager(); if (helixManager.isTopicExisted(topic)) { LOGGER.warn("Topic {} already exists from cluster {} to {}", topic, srcCluster, dstCluster); return false; } TopicPartition topicPartitionInfo = null; KafkaBrokerTopicObserver topicObserver = _currentControllerInstance.getSourceKafkaTopicObserver(); if (topicObserver == null) { // no source partition information, use partitions=1 and depend on auto-expanding later topicPartitionInfo = new TopicPartition(topic, 1); } else { topicPartitionInfo = topicObserver.getTopicPartitionWithRefresh(topic); if (topicPartitionInfo == null) { String msg = String.format( "Failed to whitelist topic %s on controller because topic does not exists in src cluster %s", topic, srcCluster); LOGGER.error(msg); throw new IllegalArgumentException(msg); } } helixManager.addTopicToMirrorMaker(topicPartitionInfo); LOGGER.info("Whitelisted topic {} from cluster {} to {}", topic, srcCluster, dstCluster); return true; }
private void whitelistCandiateTopics(Set<String> candidateTopicsToWhitelist) { for (String topic : candidateTopicsToWhitelist) { TopicPartition tp = _srcKafkaTopicObserver.getTopicPartition(topic); if (tp == null) { LOGGER.error("Shouldn't hit here, don't know why topic {} is not in src Kafka cluster", topic); _numErrorTopics.inc(); } else { if (_helixMirrorMakerManager.isTopicExisted(topic)) { LOGGER.info("Trying to expand topic: {} with {} partitions", tp.getTopic(), tp.getPartition()); _helixMirrorMakerManager.expandTopicInMirrorMaker(tp); _numAutoExpandedTopics.inc(); } else { LOGGER.info("Trying to whitelist topic: {} with {} partitions", tp.getTopic(), tp.getPartition()); _helixMirrorMakerManager.addTopicToMirrorMaker(tp); _numWhitelistedTopics.inc(); } } } }
if (_helixMirrorMakerManager.isTopicExisted(topicName)) { IdealState idealStateForTopic = _helixMirrorMakerManager.getIdealStateForTopic(topicName);
@Override @Put("json") public Representation put(Representation entity) { try { String jsonRequest = entity.getText(); TopicPartition topicPartitionInfo = TopicPartition.init(jsonRequest); if (_autoTopicWhitelistingManager != null) { _autoTopicWhitelistingManager.removeFromBlacklist(topicPartitionInfo.getTopic()); } if (_helixMirrorMakerManager.isTopicExisted(topicPartitionInfo.getTopic())) { _helixMirrorMakerManager.expandTopicInMirrorMaker(topicPartitionInfo); return new StringRepresentation( String.format("Successfully expand topic: %s", topicPartitionInfo)); } else { getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND); return new StringRepresentation(String.format( "Failed to expand topic, topic: %s is not existed!", topicPartitionInfo.getTopic())); } } catch (Exception e) { LOGGER.error("Got error during processing Put request", e); getResponse().setStatus(Status.SERVER_ERROR_INTERNAL); return new StringRepresentation( String.format("Failed to expand topic, with exception: %s", e)); } }
_autoTopicWhitelistingManager.addIntoBlacklist(topicName); if (!_helixMirrorMakerManager.isTopicExisted(topicName)) { getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND); return new StringRepresentation(
_autoTopicWhitelistingManager.removeFromBlacklist(topicPartitionInfo.getTopic()); if (_helixMirrorMakerManager.isTopicExisted(topicPartitionInfo.getTopic())) { LOGGER.info("topic {} already on mm", topicName); getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);