All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ui.static.topic.management.reAssignTopicPartitionReplicas.js Maven / Gradle / Ivy

There is a newer version: 0.8.0
Show newest version
$(document).ready(function () {
    $("#apply-re-assignments-btn").click(applyReAssignments);
    $("#apply-bulk-re-assignments-btn").click(applyBulkReAssignments);
});

function applyReAssignments() {
    let button = $(this);
    let topicName = button.attr("data-topic-name");
    let clusterIdentifier = button.attr("data-cluster-identifier");
    let throttleBytesPerSec = getThrottleBytesPerSec();
    showOpProgress("Applying re-assignments...");
    let assignments = getAssignmentsData(topicName);
    console.log("New assignments: " + JSON.stringify(assignments));
    console.log(assignments);
    $
        .ajax("api/management/apply-topic-partitions-reassignment" +
            "?topicName=" + encodeURI(topicName) +
            "&clusterIdentifier=" + encodeURI(clusterIdentifier) +
            "&throttleBytesPerSec=" + throttleBytesPerSec,
            {
                method: "POST",
                contentType: "application/json; charset=utf-8",
                data: JSON.stringify(assignments)
            }
        )
        .done(function () {
            showOpSuccess("New partition assignments applied with success");
        })
        .fail(function (error) {
            let errorMsg = extractErrMsg(error);
            showOpError("Partition re-assignment failed:", errorMsg);
        });
}

function applyBulkReAssignments() {
    let button = $(this);
    let clusterIdentifier = button.attr("data-cluster-identifier");
    let throttleBytesPerSec = getThrottleBytesPerSec();
    showOpProgress("Applying re-assignments...");

    let topicsAssignmentData = {};
    $(".topic-assignment-data").map(function () {
        let topicName = $(this).attr("data-topic-name");
        topicsAssignmentData[topicName] = getAssignmentsData(topicName);
    });

    console.log("New assignments: " + JSON.stringify(topicsAssignmentData));
    console.log(topicsAssignmentData);

    $
        .ajax("api/clusters-management/apply-topics-bulk-re-assignments" +
            "?clusterIdentifier=" + encodeURI(clusterIdentifier) +
            "&throttleBytesPerSec=" + throttleBytesPerSec,
            {
                method: "POST",
                contentType: "application/json; charset=utf-8",
                data: JSON.stringify(topicsAssignmentData)
            }
        )
        .done(function () {
            showOpSuccess("New partitions assignments applied with success");
        })
        .fail(function (error) {
            let errorMsg = extractErrMsg(error);
            showOpError("Partition re-assignment failed:", errorMsg);
        });
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy