Skip to content

Commit 266ae04

Browse files
committed
aggregated instances can be drag-n-dropped in "smart mode".
pattern is sent via URI. It is possible that pattern exceeds max URI length; this is not checked at this time.
1 parent 2cbdd1c commit 266ae04

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#
77
set -e
88

9-
RELEASE_VERSION="1.4.546"
9+
RELEASE_VERSION="1.4.548"
1010
TOPDIR=/tmp/orchestrator-release
1111
export RELEASE_VERSION TOPDIR
1212

resources/public/js/cluster.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ function Cluster() {
127127
stop: instance_dragStop,
128128
};
129129

130-
if (nodesMap[draggedNodeId].lastCheckInvalidProblem() || nodesMap[draggedNodeId].notRecentlyCheckedProblem() || nodesMap[draggedNodeId].isAggregate) {
130+
if (nodesMap[draggedNodeId].lastCheckInvalidProblem() || nodesMap[draggedNodeId].notRecentlyCheckedProblem()) {
131131
instanceEl.find("h3").click(function () {
132132
openNodeModal(nodesMap[draggedNodeId]);
133133
return false;
@@ -343,6 +343,12 @@ function Cluster() {
343343
// Wrong direction!
344344
return { accept: false };
345345
}
346+
if (node.isAggregate) {
347+
if (shouldApply) {
348+
relocateSlaves(node.masterNode, droppableNode, node.aggregatedInstancesPattern);
349+
}
350+
return { accept: "warning", type: "relocate ["+node.aggregatedInstances.length+"] < " + droppableTitle };
351+
}
346352
// the general case
347353
if (shouldApply) {
348354
relocate(node, droppableNode);
@@ -647,7 +653,8 @@ function Cluster() {
647653
return executeMoveOperation(message, apiUrl);
648654
}
649655

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

@@ -850,6 +857,7 @@ function Cluster() {
850857
return parseInt(logFileTokens[logFileTokens.length - 1])
851858
}
852859

860+
// compactInstances aggregates sibling instances of same DC such that they are visualized as a single box.
853861
function compactInstances(instances, instancesMap) {
854862
function aggregateInstances(parentInstance, dataCenter, instances) {
855863
if (!instances) {
@@ -867,8 +875,10 @@ function Cluster() {
867875
aggregatedProblems[problemType] = [title];
868876
}
869877
}
878+
var instanceFullNames = [];
870879
instances.forEach(function (instance) {
871880
incrementProblems("", instance.title)
881+
instanceFullNames.push(getInstanceTitle(instance.Key.Hostname, instance.Key.Port));
872882
if (instance.inMaintenanceProblem()) {
873883
incrementProblems("inMaintenanceProblem", instance.title)
874884
}
@@ -891,6 +901,7 @@ function Cluster() {
891901
aggergateInstance.canonicalTitle = aggergateInstance.title;
892902
aggergateInstance.aggregatedInstances = instances; // includes itself
893903
aggergateInstance.aggregatedProblems = aggregatedProblems;
904+
aggergateInstance.aggregatedInstancesPattern = "("+instanceFullNames.join("|")+")";
894905

895906
instances.forEach(function (instance) {
896907
if (!instance.isAggregate) {

resources/public/js/orchestrator.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,11 @@ function reloadWithMessage(msg, details, hint) {
181181
port = details.Port || port
182182
}
183183
hint = hint || "";
184-
window.location.href = window.location.href.split("#")[0].split("?")[0] + "?orchestrator-msg="+ encodeURIComponent(msg)+"&hostname="+hostname+"&port="+port+"&hint="+hint;
184+
var newUri = window.location.href.split("#")[0].split("?")[0] + "?orchestrator-msg="+ encodeURIComponent(msg)+"&hostname="+hostname+"&port="+port+"&hint="+hint;
185+
if (isCompactDisplay && isCompactDisplay()) {
186+
newUri += "&compact=true";
187+
}
188+
window.location.href = newUri;
185189
}
186190

187191
function reloadWithOperationResult(operationResult, hint) {

0 commit comments

Comments
 (0)