Search in sources :

Example 1 with ConnectionStatusSnapshotDTO

use of org.apache.nifi.web.api.dto.status.ConnectionStatusSnapshotDTO in project nifi by apache.

the class DtoFactory method createConnectionStatusDto.

public ConnectionStatusDTO createConnectionStatusDto(final ConnectionStatus connectionStatus) {
    final ConnectionStatusDTO connectionStatusDto = new ConnectionStatusDTO();
    connectionStatusDto.setGroupId(connectionStatus.getGroupId());
    connectionStatusDto.setId(connectionStatus.getId());
    connectionStatusDto.setName(connectionStatus.getName());
    connectionStatusDto.setSourceId(connectionStatus.getSourceId());
    connectionStatusDto.setSourceName(connectionStatus.getSourceName());
    connectionStatusDto.setDestinationId(connectionStatus.getDestinationId());
    connectionStatusDto.setDestinationName(connectionStatus.getDestinationName());
    connectionStatusDto.setStatsLastRefreshed(new Date());
    final ConnectionStatusSnapshotDTO snapshot = new ConnectionStatusSnapshotDTO();
    connectionStatusDto.setAggregateSnapshot(snapshot);
    snapshot.setId(connectionStatus.getId());
    snapshot.setGroupId(connectionStatus.getGroupId());
    snapshot.setName(connectionStatus.getName());
    snapshot.setSourceName(connectionStatus.getSourceName());
    snapshot.setDestinationName(connectionStatus.getDestinationName());
    snapshot.setFlowFilesQueued(connectionStatus.getQueuedCount());
    snapshot.setBytesQueued(connectionStatus.getQueuedBytes());
    snapshot.setFlowFilesIn(connectionStatus.getInputCount());
    snapshot.setBytesIn(connectionStatus.getInputBytes());
    snapshot.setFlowFilesOut(connectionStatus.getOutputCount());
    snapshot.setBytesOut(connectionStatus.getOutputBytes());
    if (connectionStatus.getBackPressureObjectThreshold() > 0) {
        snapshot.setPercentUseCount(Math.min(100, StatusMerger.getUtilization(connectionStatus.getQueuedCount(), connectionStatus.getBackPressureObjectThreshold())));
    }
    if (connectionStatus.getBackPressureBytesThreshold() > 0) {
        snapshot.setPercentUseBytes(Math.min(100, StatusMerger.getUtilization(connectionStatus.getQueuedBytes(), connectionStatus.getBackPressureBytesThreshold())));
    }
    StatusMerger.updatePrettyPrintedFields(snapshot);
    return connectionStatusDto;
}
Also used : ConnectionStatusDTO(org.apache.nifi.web.api.dto.status.ConnectionStatusDTO) ConnectionStatusSnapshotDTO(org.apache.nifi.web.api.dto.status.ConnectionStatusSnapshotDTO) Date(java.util.Date)

Aggregations

Date (java.util.Date)1 ConnectionStatusDTO (org.apache.nifi.web.api.dto.status.ConnectionStatusDTO)1 ConnectionStatusSnapshotDTO (org.apache.nifi.web.api.dto.status.ConnectionStatusSnapshotDTO)1