Skip to content

Commit

Permalink
SOLR-14319: specify replica types in UI when creating a collection (#958
Browse files Browse the repository at this point in the history
)
  • Loading branch information
epugh committed Aug 2, 2022
1 parent 01c0598 commit ad031d6
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 8 deletions.
4 changes: 3 additions & 1 deletion solr/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ New Features

* SOLR-15853: Admin UI support for managing Paramsets and using in Queries. (Betul Ince, Eric Pugh)

* SOLR-16096: Support createNodeSet parameter when creating collecitons in Admin UI. (Eric Pugh)
* SOLR-16096: Support createNodeSet parameter when creating collections in Admin UI. (Eric Pugh)

* SOLR-14319: Add ability to specify replica types when creating collections in Admin UI. (Richard Goodman, Eric Pugh)


Improvements
Expand Down
9 changes: 9 additions & 0 deletions solr/webapp/web/css/angular/collections.css
Original file line number Diff line number Diff line change
Expand Up @@ -380,3 +380,12 @@ limitations under the License.
float: left;
width: 65%;
}

.replication-factor {
/* some style when the element is active */
}

.replication-factor[disabled] {
/* styles when the element is disabled */
color: #c0c0c0;
}
28 changes: 23 additions & 5 deletions solr/webapp/web/js/angular/controllers/collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ solrAdminApp.controller('CollectionsController',
routerName: "compositeId",
numShards: 1,
configName: "",
nrtReplicas: 0,
tlogReplicas: 0,
pullReplicas: 0,
replicationFactor: 1
};
};
Expand Down Expand Up @@ -154,18 +157,27 @@ solrAdminApp.controller('CollectionsController',
$scope.addMessage = "Please provide a core name";
} else if (false) { //@todo detect whether core exists
$scope.AddMessage = "A core with that name already exists";
} else if ( $scope.newCollection.pullReplicas > 0 && ($scope.newCollection.nrtReplicas + $scope.newCollection.tlogReplicas == 0))
{
$scope.addMessage = "A collection can't be made up of just PULL replicas";
} else {
var coll = $scope.newCollection;
var params = {
name: coll.name,
"router.name": coll.routerName,
numShards: coll.numShards,
"collection.configName": coll.configName,
replicationFactor: coll.replicationFactor
name: coll.name,
"router.name": coll.routerName,
numShards: coll.numShards,
"collection.configName": coll.configName
};
if (coll.shards) params.shards = coll.shards;
if (coll.routerField) params["router.field"] = coll.routerField;
if (coll.createNodeSet) params.createNodeSet = coll.createNodeSet.join(",");
if ($scope.replicaTypesChosen()) {
params["nrtReplicas"] = coll.nrtReplicas;
params["tlogReplicas"] = coll.tlogReplicas;
params["pullReplicas"] = coll.pullReplicas;
} else {
params["replicationFactor"] = coll.replicationFactor;
}
Collections.add(params, function(data) {
$scope.cancelAddCollection();
$scope.resetMenu("collections", Constants.IS_ROOT_PAGE);
Expand Down Expand Up @@ -283,6 +295,12 @@ solrAdminApp.controller('CollectionsController',
replica.show = !replica.show;
}

$scope.replicaTypesChosen = function () {
if ($scope.newCollection) {
return ( $scope.newCollection.nrtReplicas + $scope.newCollection.tlogReplicas + $scope.newCollection.pullReplicas > 0 );
}
}

$scope.refresh();
}
);
17 changes: 15 additions & 2 deletions solr/webapp/web/partials/collections.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,13 @@
<p class="clearfix"><label for="add_numShards">numShards:</label>
<input type="text" name="numShards" id="add_numShards" ng-model="newCollection.numShards"></p>

<p class="clearfix"><label for="add_replicationFactor">replicationFactor:</label>
<input type="text" name="replicationFactor" id="add_replicationFactor" ng-model="newCollection.replicationFactor"></p>
<p class="clearfix replication-factor" ng-disabled="replicaTypesChosen()"><label for="add_replicationFactor">replicationFactor:</label>
<input type="text" name="replicationFactor" id="add_replicationFactor"
ng-model="newCollection.replicationFactor"
ng-disabled="replicaTypesChosen()"
class="replication-factor"
>
</p>

<p class="clearfix"><a ng-click="showAdvanced=!showAdvanced">
<span id="add_advanced" ng-class="{open: showAdvanced}">Show advanced</span></a></p>
Expand Down Expand Up @@ -65,6 +70,14 @@
</select>
</p>

<p>Replica Types: </p>
<p class="clearfix"><Label for="add_nrtReplicas">nrt replicas:</Label>
<input type="text" name="nrtReplicas" id="add_nrtReplicas" ng-model="newCollection.nrtReplicas"></p>
<p class="clearfix"><Label for="add_tlogReplicas">tlog replicas:</Label>
<input type="text" name="tlogReplicas" id="add_tlogReplicas" ng-model="newCollection.tlogReplicas"></p>
<p class="clearfix"><Label for="add_pullReplicas">pull replicas:</Label>
<input type="text" name="pullReplicas" id="add_pullReplicas" ng-model="newCollection.pullReplicas"></p>

</div>
<p class="clearfix note error" ng-show="addMessage">
<span>{{addMessage}}</span>
Expand Down

0 comments on commit ad031d6

Please sign in to comment.