mcgilman commented on a change in pull request #3281: NIFI-5986 Adding "Stop & 
Configure" button functionality to Processor…
URL: https://github.com/apache/nifi/pull/3281#discussion_r252844963
 
 

 ##########
 File path: 
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-processor-details.js
 ##########
 @@ -274,6 +280,82 @@
                     }
                 }];
 
+                // determine if we should show the Stop & Configure  button
+                if (top === window &&
+                        nfCommon.isDefinedAndNotNull(processor.state) &&
+                        nfCommon.isDefinedAndNotNull(processorResponse.uri) &&
+                        nfCommon.isDefinedAndNotNull(nfProcessor) &&
+                        nfCommon.isDefinedAndNotNull(nfProcessorConfiguration) 
) {
+
+                    //Add in the Stop & Configure button
+                    buttons.splice(1,0,{
+                         buttonText: ' Stop & Configure',
+                         clazz: 'fa fa-stop button-icon auto-width',
+                         color: {
+                             base: '#E3E8EB',
+                             hover: '#C7D2D7',
+                             text: '#813131'
+                         },
+                         disabled : function(){
+                           return !( processor.state == "RUNNING" &&
+                                     (processorResponse.permissions.canWrite ||
+                                         
processorResponse.operatePermissions.canWrite) );
+                         },
+                         handler: {
+                             click: function () {
+
+                                
$(this).find('.fa-stop').addClass('disabled-button'); //disable the Stop & 
Configure button
+
+                                var showConfig = function(data) {
+                                    
nfProcessorConfiguration.showConfiguration({
+                                        datum : function(){return data},
+                                        classed : function(t){return 
(t=='processor')}
+                                    });
+                                    
setTimeout(function(){$('#processor-details').modal('hide');},100);
+                                }
+
+                                $.ajax({
+                                  type: 'PUT',
+                                  url: processorResponse.uri + '/run-status',
+                                  data: JSON.stringify({
+                                         'revision': 
processorResponse.revision,
+                                         'state': 'STOPPED'
+                                  }),
+                                  dataType: 'json',
+                                  contentType: 'application/json'
+                                }).done(function (data) {
+
+                                    nfProcessor.set(data);
+                                    
if(data.status.aggregateSnapshot.activeThreadCount > 0) {
+                                        nfDialog.showYesNoDialog({
+                                            headerText: 'Terminate active 
threads?',
+                                            dialogContent: 'There are 
currently active threads '+
+                                                'present for this processor, 
do you wish to terminate them?',
+                                            noHandler: function () {
+                                                //close the dialog
+                                            },
+                                            yesHandler: function () {
+
+                                                //send the terminate call
+                                                $.ajax({
+                                                      type: 'DELETE',
+                                                      url: data.uri + 
'/threads',
+                                                      dataType: 'json',
+                                                      contentType: 
'application/json'
+                                                 }).done(function (data) {
+                                                    showConfig(data);
+                                                 
}).fail(nfErrorHandler.handleAjaxError);
 
 Review comment:
   I don't think we should jump to terminate threads so quickly. Based on the 
commentary here already, I think you guys are on the same page. We should 
promote graceful stopping of the processors. The thread termination is in place 
for situations where a Processor is not relinquishing a thread which is 
preventing subsequent modifications. The solution here should unschedule the 
processor and then wait for the executing threads to complete. I could get 
behind something that would offer the terminate option only when the threads 
are not completing on their own.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to