mirror of https://github.com/apache/nifi.git
NIFI-115:
- Code clean up. - Showing an expiration icon on the connection label when appropriate. - Allowing the user to search for connections that have expiration and back pressure configured.
This commit is contained in:
parent
22596080c9
commit
bda9985d6a
|
@ -113,6 +113,7 @@ import org.apache.commons.collections4.CollectionUtils;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.nifi.admin.service.UserService;
|
||||
import org.apache.nifi.authorization.DownloadAuthorization;
|
||||
import org.apache.nifi.processor.DataUnit;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
|
@ -1255,6 +1256,28 @@ public class ControllerFacade implements ControllerServiceProvider {
|
|||
addIfAppropriate(searchStr, comparator.getClass().getName(), "Prioritizer", matches);
|
||||
}
|
||||
|
||||
// search expiration
|
||||
if (StringUtils.containsIgnoreCase("expires", searchStr) || StringUtils.containsIgnoreCase("expiration", searchStr)) {
|
||||
final int expirationMillis = connection.getFlowFileQueue().getFlowFileExpiration(TimeUnit.MILLISECONDS);
|
||||
if (expirationMillis > 0) {
|
||||
matches.add("FlowFile expiration: " + connection.getFlowFileQueue().getFlowFileExpiration());
|
||||
}
|
||||
}
|
||||
|
||||
// search back pressure
|
||||
if (StringUtils.containsIgnoreCase("back pressure", searchStr) || StringUtils.containsIgnoreCase("pressure", searchStr)) {
|
||||
final String backPressureDataSize = connection.getFlowFileQueue().getBackPressureDataSizeThreshold();
|
||||
final Double backPressureBytes = DataUnit.parseDataSize(backPressureDataSize, DataUnit.B);
|
||||
if (backPressureBytes > 0) {
|
||||
matches.add("Back pressure data size: " + backPressureDataSize);
|
||||
}
|
||||
|
||||
final long backPressureCount = connection.getFlowFileQueue().getBackPressureObjectThreshold();
|
||||
if (backPressureCount > 0) {
|
||||
matches.add("Back pressure count: " + backPressureCount);
|
||||
}
|
||||
}
|
||||
|
||||
// search the source
|
||||
final Connectable source = connection.getSource();
|
||||
addIfAppropriate(searchStr, source.getIdentifier(), "Source id", matches);
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
</div>
|
||||
<div class="setting">
|
||||
<div class="setting-name">
|
||||
File expiration
|
||||
FlowFile expiration
|
||||
<img class="setting-icon icon-info" src="images/iconInfo.png" alt="Info" title="The maximum amount of time an object may be in the flow before it will be automatically aged out of the flow."/>
|
||||
</div>
|
||||
<div class="setting-field">
|
||||
|
|
|
@ -75,7 +75,7 @@
|
|||
</div>
|
||||
<div class="setting">
|
||||
<div class="setting-name">
|
||||
File expiration
|
||||
FlowFile expiration
|
||||
<img class="setting-icon icon-info" src="images/iconInfo.png" alt="Info" title="The maximum amount of time an object may be in the flow before it will be automatically aged out of the flow."/>
|
||||
</div>
|
||||
<div class="setting-field">
|
||||
|
|
|
@ -312,6 +312,28 @@ nf.Canvas = (function () {
|
|||
'stop-color': '#ffffff'
|
||||
});
|
||||
|
||||
// define the gradient for the expiration icon
|
||||
var expirationBackground = defs.append('linearGradient')
|
||||
.attr({
|
||||
'id': 'expiration',
|
||||
'x1': '0%',
|
||||
'y1': '0%',
|
||||
'x2': '0%',
|
||||
'y2': '100%'
|
||||
});
|
||||
|
||||
expirationBackground.append('stop')
|
||||
.attr({
|
||||
'offset': '0%',
|
||||
'stop-color': '#aeafb1'
|
||||
});
|
||||
|
||||
expirationBackground.append('stop')
|
||||
.attr({
|
||||
'offset': '100%',
|
||||
'stop-color': '#87888a'
|
||||
});
|
||||
|
||||
// create the canvas element
|
||||
canvas = svg.append('g')
|
||||
.attr({
|
||||
|
@ -802,17 +824,21 @@ nf.Canvas = (function () {
|
|||
};
|
||||
|
||||
return {
|
||||
|
||||
CANVAS_OFFSET: 0,
|
||||
|
||||
/**
|
||||
* Determines if the current broswer supports SVG.
|
||||
*/
|
||||
SUPPORTS_SVG: !!document.createElementNS && !!document.createElementNS('http://www.w3.org/2000/svg', 'svg').createSVGRect,
|
||||
|
||||
/**
|
||||
* Hides the splash that is displayed while the application is loading.
|
||||
*/
|
||||
hideSplash: function () {
|
||||
$('#splash').fadeOut();
|
||||
},
|
||||
|
||||
/**
|
||||
* Stop polling for revision.
|
||||
*/
|
||||
|
@ -820,6 +846,7 @@ nf.Canvas = (function () {
|
|||
// set polling flag
|
||||
revisionPolling = false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Remove the status poller.
|
||||
*/
|
||||
|
@ -827,6 +854,7 @@ nf.Canvas = (function () {
|
|||
// set polling flag
|
||||
statusPolling = false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Reloads the flow from the server based on the currently specified group id.
|
||||
* To load another group, update nf.Canvas.setGroupId and call nf.Canvas.reload.
|
||||
|
@ -865,6 +893,7 @@ nf.Canvas = (function () {
|
|||
});
|
||||
}).promise();
|
||||
},
|
||||
|
||||
/**
|
||||
* Reloads the status.
|
||||
*/
|
||||
|
@ -878,6 +907,7 @@ nf.Canvas = (function () {
|
|||
});
|
||||
}).promise();
|
||||
},
|
||||
|
||||
/**
|
||||
* Initialize NiFi.
|
||||
*/
|
||||
|
@ -999,6 +1029,7 @@ nf.Canvas = (function () {
|
|||
}).fail(nf.Common.handleAjaxError);
|
||||
}).fail(nf.Common.handleAjaxError);
|
||||
},
|
||||
|
||||
/**
|
||||
* Defines the gradient colors used to render processors.
|
||||
*
|
||||
|
@ -1007,6 +1038,7 @@ nf.Canvas = (function () {
|
|||
defineProcessorColors: function (colors) {
|
||||
setColors(colors, 'processor');
|
||||
},
|
||||
|
||||
/**
|
||||
* Defines the gradient colors used to render label.
|
||||
*
|
||||
|
@ -1015,6 +1047,7 @@ nf.Canvas = (function () {
|
|||
defineLabelColors: function (colors) {
|
||||
setColors(colors, 'label');
|
||||
},
|
||||
|
||||
/**
|
||||
* Return whether this instance of NiFi is clustered.
|
||||
*
|
||||
|
@ -1023,12 +1056,14 @@ nf.Canvas = (function () {
|
|||
isClustered: function () {
|
||||
return clustered === true;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns whether site to site communications is secure.
|
||||
*/
|
||||
isSecureSiteToSite: function () {
|
||||
return secureSiteToSite;
|
||||
},
|
||||
|
||||
/**
|
||||
* Set the group id.
|
||||
*
|
||||
|
@ -1043,6 +1078,7 @@ nf.Canvas = (function () {
|
|||
getGroupId: function () {
|
||||
return groupId;
|
||||
},
|
||||
|
||||
/**
|
||||
* Set the group name.
|
||||
*
|
||||
|
@ -1051,12 +1087,14 @@ nf.Canvas = (function () {
|
|||
setGroupName: function (gn) {
|
||||
groupName = gn;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get the group name.
|
||||
*/
|
||||
getGroupName: function () {
|
||||
return groupName;
|
||||
},
|
||||
|
||||
/**
|
||||
* Set the parent group id.
|
||||
*
|
||||
|
@ -1065,13 +1103,16 @@ nf.Canvas = (function () {
|
|||
setParentGroupId: function (pgi) {
|
||||
parentGroupId = pgi;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get the parent group id.
|
||||
*/
|
||||
getParentGroupId: function () {
|
||||
return parentGroupId;
|
||||
},
|
||||
|
||||
View: (function () {
|
||||
|
||||
/**
|
||||
* Updates component visibility based on their proximity to the screen's viewport.
|
||||
*/
|
||||
|
|
|
@ -187,6 +187,24 @@ nf.Connection = (function () {
|
|||
return terminal.groupId !== nf.Canvas.getGroupId() && (isInputPortType(terminal.type) || isOutputPortType(terminal.type));
|
||||
};
|
||||
|
||||
/**
|
||||
* Determines whether expiration is configured for the specified connection.
|
||||
*
|
||||
* @param {object} connection
|
||||
* @return {boolean} Whether expiration is configured
|
||||
*/
|
||||
var isExpirationConfigured = function (connection) {
|
||||
if (nf.Common.isDefinedAndNotNull(connection.flowFileExpiration)) {
|
||||
var match = connection.flowFileExpiration.match(/^(\d+).*/);
|
||||
if (match !== null && match.length > 0) {
|
||||
if (parseInt(match[0], 10) > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Sorts the specified connections according to the z index.
|
||||
*
|
||||
|
@ -669,7 +687,7 @@ nf.Connection = (function () {
|
|||
|
||||
// update the label text
|
||||
connectionFrom.select('text.connection-from')
|
||||
.each(function (d) {
|
||||
.each(function () {
|
||||
var connectionFromLabel = d3.select(this);
|
||||
|
||||
// reset the label name to handle any previous state
|
||||
|
@ -677,7 +695,7 @@ nf.Connection = (function () {
|
|||
|
||||
// apply ellipsis to the label as necessary
|
||||
nf.CanvasUtils.ellipsis(connectionFromLabel, d.component.source.name);
|
||||
}).append('title').text(function (d) {
|
||||
}).append('title').text(function () {
|
||||
return d.component.source.name;
|
||||
});
|
||||
|
||||
|
@ -821,7 +839,7 @@ nf.Connection = (function () {
|
|||
|
||||
// update the connection name
|
||||
connectionName.select('text.connection-name')
|
||||
.each(function (d) {
|
||||
.each(function () {
|
||||
var connectionToLabel = d3.select(this);
|
||||
|
||||
// reset the label name to handle any previous state
|
||||
|
@ -829,7 +847,7 @@ nf.Connection = (function () {
|
|||
|
||||
// apply ellipsis to the label as necessary
|
||||
nf.CanvasUtils.ellipsis(connectionToLabel, connectionNameValue);
|
||||
}).append('title').text(function (d) {
|
||||
}).append('title').text(function () {
|
||||
return connectionNameValue;
|
||||
});
|
||||
} else {
|
||||
|
@ -866,6 +884,44 @@ nf.Connection = (function () {
|
|||
'x': 46,
|
||||
'y': 10
|
||||
});
|
||||
|
||||
var expiration = queued.append('g')
|
||||
.attr({
|
||||
'class': 'expiration-icon',
|
||||
'transform': 'translate(167, 2)'
|
||||
});
|
||||
|
||||
expiration.append('circle')
|
||||
.attr({
|
||||
'cx': 5,
|
||||
'cy': 5,
|
||||
'r': 4.75,
|
||||
'stroke-width': 0.5,
|
||||
'stroke': '#87888a',
|
||||
'fill': 'url(#expiration)'
|
||||
});
|
||||
|
||||
expiration.append('line')
|
||||
.attr({
|
||||
'x1': 6,
|
||||
'y1': 5,
|
||||
'x2': 3,
|
||||
'y2': 4,
|
||||
'stroke': '#fff',
|
||||
'stroke-width': 1
|
||||
});
|
||||
|
||||
expiration.append('line')
|
||||
.attr({
|
||||
'x1': 6,
|
||||
'y1': 5,
|
||||
'x2': 3,
|
||||
'y2': 7,
|
||||
'stroke': '#fff',
|
||||
'stroke-width': 1
|
||||
});
|
||||
|
||||
expiration.append('title');
|
||||
}
|
||||
|
||||
// update the queued vertical positioning as necessary
|
||||
|
@ -880,6 +936,15 @@ nf.Connection = (function () {
|
|||
return 5 + (15 * labelCount) + 3;
|
||||
});
|
||||
|
||||
// determine whether or not to show the expiration icon
|
||||
connectionLabelContainer.select('g.expiration-icon')
|
||||
.classed('hidden', function () {
|
||||
return !isExpirationConfigured(d.component);
|
||||
})
|
||||
.select('title').text(function () {
|
||||
return 'Expires FlowFiles older than ' + d.component.flowFileExpiration;
|
||||
});
|
||||
|
||||
if (nf.Common.isDFM()) {
|
||||
// only support dragging the label when appropriate
|
||||
connectionLabelContainer.call(labelDrag);
|
||||
|
|
Loading…
Reference in New Issue