Search in sources :

Example 6 with ControllerServiceReferencingComponentEntity

use of org.apache.nifi.web.api.entity.ControllerServiceReferencingComponentEntity in project nifi by apache.

the class ControllerServiceReferenceEndpointMerger method merge.

@Override
public NodeResponse merge(URI uri, String method, Set<NodeResponse> successfulResponses, Set<NodeResponse> problematicResponses, NodeResponse clientResponse) {
    if (!canHandle(uri, method)) {
        throw new IllegalArgumentException("Cannot use Endpoint Mapper of type " + getClass().getSimpleName() + " to map responses for URI " + uri + ", HTTP Method " + method);
    }
    final ControllerServiceReferencingComponentsEntity responseEntity = clientResponse.getClientResponse().readEntity(ControllerServiceReferencingComponentsEntity.class);
    final Set<ControllerServiceReferencingComponentEntity> referencingComponents = responseEntity.getControllerServiceReferencingComponents();
    final Map<NodeIdentifier, Set<ControllerServiceReferencingComponentEntity>> resultsMap = new HashMap<>();
    for (final NodeResponse nodeResponse : successfulResponses) {
        final ControllerServiceReferencingComponentsEntity nodeResponseEntity = nodeResponse == clientResponse ? responseEntity : nodeResponse.getClientResponse().readEntity(ControllerServiceReferencingComponentsEntity.class);
        final Set<ControllerServiceReferencingComponentEntity> nodeReferencingComponents = nodeResponseEntity.getControllerServiceReferencingComponents();
        resultsMap.put(nodeResponse.getNodeId(), nodeReferencingComponents);
    }
    ControllerServiceEntityMerger.mergeControllerServiceReferences(referencingComponents, resultsMap);
    return new NodeResponse(clientResponse, responseEntity);
}
Also used : ControllerServiceReferencingComponentsEntity(org.apache.nifi.web.api.entity.ControllerServiceReferencingComponentsEntity) Set(java.util.Set) ControllerServiceReferencingComponentEntity(org.apache.nifi.web.api.entity.ControllerServiceReferencingComponentEntity) HashMap(java.util.HashMap) NodeIdentifier(org.apache.nifi.cluster.protocol.NodeIdentifier) NodeResponse(org.apache.nifi.cluster.manager.NodeResponse)

Example 7 with ControllerServiceReferencingComponentEntity

use of org.apache.nifi.web.api.entity.ControllerServiceReferencingComponentEntity in project nifi by apache.

the class EntityFactory method createControllerServiceReferencingComponentEntity.

public ControllerServiceReferencingComponentEntity createControllerServiceReferencingComponentEntity(final ControllerServiceReferencingComponentDTO dto, final RevisionDTO revision, final PermissionsDTO permissions) {
    final ControllerServiceReferencingComponentEntity entity = new ControllerServiceReferencingComponentEntity();
    entity.setRevision(revision);
    if (dto != null) {
        entity.setPermissions(permissions);
        entity.setId(dto.getId());
        if (permissions != null && permissions.getCanRead()) {
            entity.setComponent(dto);
        }
    }
    return entity;
}
Also used : ControllerServiceReferencingComponentEntity(org.apache.nifi.web.api.entity.ControllerServiceReferencingComponentEntity)

Aggregations

ControllerServiceReferencingComponentEntity (org.apache.nifi.web.api.entity.ControllerServiceReferencingComponentEntity)7 HashMap (java.util.HashMap)6 Set (java.util.Set)5 ControllerServiceReferencingComponentDTO (org.apache.nifi.web.api.dto.ControllerServiceReferencingComponentDTO)5 Map (java.util.Map)4 NodeIdentifier (org.apache.nifi.cluster.protocol.NodeIdentifier)4 PermissionsDTO (org.apache.nifi.web.api.dto.PermissionsDTO)4 Collection (java.util.Collection)3 ControllerServiceDTO (org.apache.nifi.web.api.dto.ControllerServiceDTO)3 ControllerServiceReferencingComponentsEntity (org.apache.nifi.web.api.entity.ControllerServiceReferencingComponentsEntity)3 ControllerServiceState (org.apache.nifi.controller.service.ControllerServiceState)2 PropertyDescriptorDTO (org.apache.nifi.web.api.dto.PropertyDescriptorDTO)2 RevisionDTO (org.apache.nifi.web.api.dto.RevisionDTO)2 ControllerServiceEntity (org.apache.nifi.web.api.entity.ControllerServiceEntity)2 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)1 Uninterruptibles (com.google.common.util.concurrent.Uninterruptibles)1 NifiConstants (com.thinkbiganalytics.nifi.rest.support.NifiConstants)1 NifiProcessUtil (com.thinkbiganalytics.nifi.rest.support.NifiProcessUtil)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1