Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature for scheduling preferred replica leader election #630

Merged
merged 5 commits into from
Mar 3, 2020

Conversation

akki
Copy link
Contributor

@akki akki commented Apr 4, 2019

We recently worked on adding a feature (new tab & REST APIs) to Kafka Manager which would allow users to schedule the replica leader election. We thought it might be helpful for other users as well so would like to share it here and preferably merge it upstream (yahoo/kafka-manager).

I am quite new to Scala/Akka so I would appreciate if you could let me know what changes you'd like to see in this patch and how it can be best used to improve Kafka Manager.

@akki akki force-pushed the election-scheduler branch from e71d249 to 843191b Compare April 4, 2019 08:41
val jsonData = toJson(schedule)

ZkUtils.updatePersistentPath(curator, ZkUtils.SchedulePreferredLeaderElectionPath, jsonData)
logger.info("Updating ZK scheduler with %s".format(jsonData))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might throw error format(jsonData)

}

def handleScheduleRunElection(c: String) = Action.async { implicit request =>
var status_string: String = ""

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!!

@@ -226,6 +227,9 @@ class KafkaManagerActor(kafkaManagerConfig: KafkaManagerActorConfig)
case KMGetAllClusters =>
sender ! KMClusterList(clusterConfigMap.values.toIndexedSeq, pendingClusterConfigMap.values.toIndexedSeq)

case KSGetScheduleLeaderElection =>
sender ! ZkUtils.readDataMaybeNull(curator, ZkUtils.SchedulePreferredLeaderElectionPath)._1.getOrElse("{}")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"{}" try to declare it separately depends on how base code structures

private def writeScheduleLeaderElectionToZk(schedule: Map[String, Int]) = {
implicit val ec = longRunningExecutionContext

log.info("Updating schedule for preferred leader election")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try to put more context to messages some uniqueness maybe of possible

Copy link

@sandeepjindal sandeepjindal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small comments made

@patelh
Copy link
Collaborator

patelh commented Apr 9, 2019

Please rebase off master.

@akki akki force-pushed the election-scheduler branch from 7dad013 to fd5517e Compare April 16, 2019 16:11
@akki
Copy link
Contributor Author

akki commented May 6, 2019

Thanks for all the suggestions everyone.

@kumarankit01 @sandeepjindal I have tried to resolve as per your suggestions as much as possible according to current codebase structure.
@patelh Rebased and resolved all conflicts with master. Do you have any other suggestions on how we can merge this to master?

@linehrr
Copy link

linehrr commented Jun 3, 2019

it would be very nice to update the README.md to include the description of those API endpoints we added here so other ppl can use them easily if we want to expose them as RestAPIs, if not then it's fine:

GET    /clusters/:c/leader/schedule                         
POST   /clusters/:c/leader/schedule                         
GET    /clusters/:c/leader/schedule/cancel                  
POST   /clusters/:c/leader/schedule/cancel                  
...

@akki
Copy link
Contributor Author

akki commented Jun 12, 2019

@linehrr These are not JSON REST endpoints, rather they return HTML content. We did add REST endpoints as well for this feature in our internal code - we would be happy to send another PR to open-source them if the project maintainers see value in having them (and this feature, in general). Those APIs use some code components of this PR.

Thanks for the suggestion - appreciate your time & feedback. 🙏

@patelh patelh merged commit 03f2868 into yahoo:master Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants