Skip to content

Commit

Permalink
aggregated instances can be drag-n-dropped in "smart mode".
Browse files Browse the repository at this point in the history
pattern is sent via URI. It is possible that pattern exceeds max URI
length; this is not checked at this time.
  • Loading branch information
shlomi-noach committed Nov 26, 2015
1 parent 2cbdd1c commit 266ae04
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
set -e

RELEASE_VERSION="1.4.546"
RELEASE_VERSION="1.4.548"
TOPDIR=/tmp/orchestrator-release
export RELEASE_VERSION TOPDIR

Expand Down
17 changes: 14 additions & 3 deletions resources/public/js/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function Cluster() {
stop: instance_dragStop,
};

if (nodesMap[draggedNodeId].lastCheckInvalidProblem() || nodesMap[draggedNodeId].notRecentlyCheckedProblem() || nodesMap[draggedNodeId].isAggregate) {
if (nodesMap[draggedNodeId].lastCheckInvalidProblem() || nodesMap[draggedNodeId].notRecentlyCheckedProblem()) {
instanceEl.find("h3").click(function () {
openNodeModal(nodesMap[draggedNodeId]);
return false;
Expand Down Expand Up @@ -343,6 +343,12 @@ function Cluster() {
// Wrong direction!
return { accept: false };
}
if (node.isAggregate) {
if (shouldApply) {
relocateSlaves(node.masterNode, droppableNode, node.aggregatedInstancesPattern);
}
return { accept: "warning", type: "relocate ["+node.aggregatedInstances.length+"] < " + droppableTitle };
}
// the general case
if (shouldApply) {
relocate(node, droppableNode);
Expand Down Expand Up @@ -647,7 +653,8 @@ function Cluster() {
return executeMoveOperation(message, apiUrl);
}

function relocateSlaves(node, siblingNode) {
function relocateSlaves(node, siblingNode, pattern) {
pattern = pattern || "";
var message = "<h4>relocate-slaves</h4>Are you sure you wish to relocate slaves of <code><strong>" +
node.Key.Hostname + ":" + node.Key.Port +
"</strong></code> below <code><strong>" +
Expand All @@ -656,7 +663,7 @@ function Cluster() {
"<h4>Note</h4><p>Orchestrator will try and figure out the best relocation path. This may involve multiple steps. " +
"<p>In case multiple steps are involved, failure of one may leave some instances hanging in a different location than you expected, " +
"but they would still be in a <i>valid</i> state.";
var apiUrl = "/api/relocate-slaves/" + node.Key.Hostname + "/" + node.Key.Port + "/" + siblingNode.Key.Hostname + "/" + siblingNode.Key.Port;
var apiUrl = "/api/relocate-slaves/" + node.Key.Hostname + "/" + node.Key.Port + "/" + siblingNode.Key.Hostname + "/" + siblingNode.Key.Port + "?pattern="+encodeURIComponent(pattern);
return executeMoveOperation(message, apiUrl);
}

Expand Down Expand Up @@ -850,6 +857,7 @@ function Cluster() {
return parseInt(logFileTokens[logFileTokens.length - 1])
}

// compactInstances aggregates sibling instances of same DC such that they are visualized as a single box.
function compactInstances(instances, instancesMap) {
function aggregateInstances(parentInstance, dataCenter, instances) {
if (!instances) {
Expand All @@ -867,8 +875,10 @@ function Cluster() {
aggregatedProblems[problemType] = [title];
}
}
var instanceFullNames = [];
instances.forEach(function (instance) {
incrementProblems("", instance.title)
instanceFullNames.push(getInstanceTitle(instance.Key.Hostname, instance.Key.Port));
if (instance.inMaintenanceProblem()) {
incrementProblems("inMaintenanceProblem", instance.title)
}
Expand All @@ -891,6 +901,7 @@ function Cluster() {
aggergateInstance.canonicalTitle = aggergateInstance.title;
aggergateInstance.aggregatedInstances = instances; // includes itself
aggergateInstance.aggregatedProblems = aggregatedProblems;
aggergateInstance.aggregatedInstancesPattern = "("+instanceFullNames.join("|")+")";

instances.forEach(function (instance) {
if (!instance.isAggregate) {
Expand Down
6 changes: 5 additions & 1 deletion resources/public/js/orchestrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,11 @@ function reloadWithMessage(msg, details, hint) {
port = details.Port || port
}
hint = hint || "";
window.location.href = window.location.href.split("#")[0].split("?")[0] + "?orchestrator-msg="+ encodeURIComponent(msg)+"&hostname="+hostname+"&port="+port+"&hint="+hint;
var newUri = window.location.href.split("#")[0].split("?")[0] + "?orchestrator-msg="+ encodeURIComponent(msg)+"&hostname="+hostname+"&port="+port+"&hint="+hint;
if (isCompactDisplay && isCompactDisplay()) {
newUri += "&compact=true";
}
window.location.href = newUri;
}

function reloadWithOperationResult(operationResult, hint) {
Expand Down

0 comments on commit 266ae04

Please sign in to comment.