Search in sources :

Example 1 with FeedNotFoundException

use of com.thinkbiganalytics.metadata.api.feed.FeedNotFoundException in project kylo by Teradata.

the class FeedManagerMetadataService method startFeed.

@Override
@SuppressWarnings("deprecation")
public FeedSummary startFeed(String feedId) {
    FeedMetadata feedMetadata = this.metadataAccess.read(() -> {
        this.accessController.checkPermission(AccessController.SERVICES, FeedServicesAccessControl.ADMIN_FEEDS);
        Feed.ID domainId = domainFeedProvider.resolveId(feedId);
        Feed domainFeed = domainFeedProvider.findById(domainId);
        if (domainFeed != null) {
            this.accessController.checkPermission(domainFeed, FeedAccessControl.START);
            return feedModelTransform.domainToFeedMetadata(domainFeed);
        } else {
            throw new FeedNotFoundException(domainId);
        }
    });
    Optional<ProcessorDTO> feedInputProcessor = nifiClient.processGroups().findByName("root", feedMetadata.getSystemCategoryName(), false, false).flatMap(categoryGroup -> nifiClient.processGroups().findByName(categoryGroup.getId(), feedMetadata.getSystemFeedName(), false, true)).map(feedGroup -> {
        List<ProcessorDTO> inputProcessors = this.nifiRestClient.getInputProcessors(feedGroup.getId());
        ProcessorDTO inputProcessor = NifiProcessUtil.findFirstProcessorsByTypeAndName(inputProcessors, feedMetadata.getInputProcessorType(), feedMetadata.getInputProcessorName());
        if (inputProcessor != null) {
            this.nifiClient.processors().wakeUp(inputProcessor);
        }
        return inputProcessor;
    });
    if (!feedInputProcessor.isPresent()) {
        log.error("Unable to start the feed {}.  Could not find the input processor to start.", feedMetadata.getCategoryAndFeedName());
        throw new RuntimeException("Unable to start Feed " + feedMetadata.getCategoryAndFeedName() + ".  Could not find the input processor to start the feed");
    }
    return new FeedSummary(feedMetadata);
}
Also used : Action(com.thinkbiganalytics.security.action.Action) HadoopAuthorizationService(com.thinkbiganalytics.datalake.authorization.service.HadoopAuthorizationService) CleanupTriggerEvent(com.thinkbiganalytics.metadata.api.event.feed.CleanupTriggerEvent) LoggerFactory(org.slf4j.LoggerFactory) ConnectionDTO(org.apache.nifi.web.api.dto.ConnectionDTO) Autowired(org.springframework.beans.factory.annotation.Autowired) NifiProcessUtil(com.thinkbiganalytics.nifi.rest.support.NifiProcessUtil) FeedModelTransform(com.thinkbiganalytics.feedmgr.service.feed.FeedModelTransform) NifiClientRuntimeException(com.thinkbiganalytics.nifi.rest.client.NifiClientRuntimeException) FeedProvider(com.thinkbiganalytics.metadata.api.feed.FeedProvider) ProcessGroupDTO(org.apache.nifi.web.api.dto.ProcessGroupDTO) FeedAccessControl(com.thinkbiganalytics.metadata.api.feed.security.FeedAccessControl) FeedManagerCategoryService(com.thinkbiganalytics.feedmgr.service.category.FeedManagerCategoryService) Map(java.util.Map) AccessController(com.thinkbiganalytics.security.AccessController) NifiFeed(com.thinkbiganalytics.feedmgr.rest.model.NifiFeed) NiFiRestClient(com.thinkbiganalytics.nifi.rest.client.NiFiRestClient) CategoryAccessControl(com.thinkbiganalytics.metadata.api.category.security.CategoryAccessControl) Pageable(org.springframework.data.domain.Pageable) FeedServicesAccessControl(com.thinkbiganalytics.feedmgr.security.FeedServicesAccessControl) MetadataAccess(com.thinkbiganalytics.metadata.api.MetadataAccess) FeedManagerTemplateService(com.thinkbiganalytics.feedmgr.service.template.FeedManagerTemplateService) FeedVersions(com.thinkbiganalytics.feedmgr.rest.model.FeedVersions) DeployResponseEntityVersion(com.thinkbiganalytics.feedmgr.rest.model.DeployResponseEntityVersion) MetadataEventListener(com.thinkbiganalytics.metadata.api.event.MetadataEventListener) NifiProperty(com.thinkbiganalytics.nifi.rest.model.NifiProperty) Collection(java.util.Collection) Set(java.util.Set) Page(org.springframework.data.domain.Page) EntityVersionDifference(com.thinkbiganalytics.feedmgr.rest.model.EntityVersionDifference) MetadataEventService(com.thinkbiganalytics.metadata.api.event.MetadataEventService) Collectors(java.util.stream.Collectors) NotFoundException(javax.ws.rs.NotFoundException) EntityVersion(com.thinkbiganalytics.feedmgr.rest.model.EntityVersion) FeedSummary(com.thinkbiganalytics.feedmgr.rest.model.FeedSummary) PortDTO(org.apache.nifi.web.api.dto.PortDTO) List(java.util.List) ProcessorDTO(org.apache.nifi.web.api.dto.ProcessorDTO) Optional(java.util.Optional) NiFiComponentState(com.thinkbiganalytics.nifi.rest.client.NiFiComponentState) InvalidOperationException(com.thinkbiganalytics.feedmgr.InvalidOperationException) FeedOperationStatusEvent(com.thinkbiganalytics.metadata.api.event.feed.FeedOperationStatusEvent) FeedManagerFeedService(com.thinkbiganalytics.feedmgr.service.feed.FeedManagerFeedService) Feed(com.thinkbiganalytics.metadata.api.feed.Feed) FeedMetadata(com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata) UserProperty(com.thinkbiganalytics.feedmgr.rest.model.UserProperty) ArrayList(java.util.ArrayList) FeedCategory(com.thinkbiganalytics.feedmgr.rest.model.FeedCategory) Value(org.springframework.beans.factory.annotation.Value) HashSet(java.util.HashSet) Inject(javax.inject.Inject) UIFeed(com.thinkbiganalytics.feedmgr.rest.model.UIFeed) ServiceLevelAgreementService(com.thinkbiganalytics.feedmgr.sla.ServiceLevelAgreementService) Qualifier(org.springframework.beans.factory.annotation.Qualifier) ProcessGroupFlowDTO(org.apache.nifi.web.api.dto.flow.ProcessGroupFlowDTO) RegisteredTemplate(com.thinkbiganalytics.feedmgr.rest.model.RegisteredTemplate) Nonnull(javax.annotation.Nonnull) NifiConstants(com.thinkbiganalytics.nifi.rest.support.NifiConstants) Nullable(javax.annotation.Nullable) FeedNotFoundException(com.thinkbiganalytics.metadata.api.feed.FeedNotFoundException) FeedOperation(com.thinkbiganalytics.metadata.api.op.FeedOperation) Logger(org.slf4j.Logger) UserFieldCollection(com.thinkbiganalytics.feedmgr.rest.model.UserFieldCollection) LegacyNifiRestClient(com.thinkbiganalytics.nifi.rest.client.LegacyNifiRestClient) NifiClientRuntimeException(com.thinkbiganalytics.nifi.rest.client.NifiClientRuntimeException) ProcessorDTO(org.apache.nifi.web.api.dto.ProcessorDTO) FeedMetadata(com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata) FeedNotFoundException(com.thinkbiganalytics.metadata.api.feed.FeedNotFoundException) NifiFeed(com.thinkbiganalytics.feedmgr.rest.model.NifiFeed) Feed(com.thinkbiganalytics.metadata.api.feed.Feed) UIFeed(com.thinkbiganalytics.feedmgr.rest.model.UIFeed) FeedSummary(com.thinkbiganalytics.feedmgr.rest.model.FeedSummary)

Example 2 with FeedNotFoundException

use of com.thinkbiganalytics.metadata.api.feed.FeedNotFoundException in project kylo by Teradata.

the class FeedWaterMarkService method updateWaterMark.

public String updateWaterMark(String feedId, String waterMarkName, String value, boolean cancelActive) {
    com.thinkbiganalytics.metadata.api.feed.Feed.ID updId = this.metadata.commit(() -> {
        this.accessController.checkPermission(AccessController.SERVICES, FeedServicesAccessControl.EDIT_FEEDS);
        com.thinkbiganalytics.metadata.api.feed.Feed.ID id = feedProvider.resolveFeed(feedId);
        com.thinkbiganalytics.metadata.api.feed.Feed feed = feedProvider.getFeed(id);
        if (feed != null) {
            feed.setWaterMarkValue(waterMarkName, value);
            return id;
        } else {
            throw new FeedNotFoundException(id);
        }
    });
    if (cancelActive) {
        cancelActiveWaterMark(updId, waterMarkName);
    }
    return this.metadata.commit(() -> {
        com.thinkbiganalytics.metadata.api.feed.Feed feed = feedProvider.getFeed(updId);
        if (feed != null) {
            return feed.getWaterMarkValue(waterMarkName).orElseThrow(() -> new WaterMarkNotFoundExcepton(updId, waterMarkName));
        } else {
            throw new FeedNotFoundException(updId);
        }
    });
}
Also used : Feed(com.thinkbiganalytics.metadata.api.feed.Feed) FeedNotFoundException(com.thinkbiganalytics.metadata.api.feed.FeedNotFoundException) Feed(com.thinkbiganalytics.metadata.api.feed.Feed)

Example 3 with FeedNotFoundException

use of com.thinkbiganalytics.metadata.api.feed.FeedNotFoundException in project kylo by Teradata.

the class FeedWaterMarkService method getWaterMarks.

public List<String> getWaterMarks(String feedId) {
    return this.metadata.read(() -> {
        this.accessController.checkPermission(AccessController.SERVICES, FeedServicesAccessControl.ACCESS_FEEDS);
        com.thinkbiganalytics.metadata.api.feed.Feed.ID id = feedProvider.resolveFeed(feedId);
        com.thinkbiganalytics.metadata.api.feed.Feed feed = feedProvider.getFeed(id);
        if (feed != null) {
            List<String> list = feed.getWaterMarkNames().stream().collect(Collectors.toList());
            Collections.sort(list);
            return list;
        } else {
            throw new FeedNotFoundException(id);
        }
    });
}
Also used : Feed(com.thinkbiganalytics.metadata.api.feed.Feed) FeedNotFoundException(com.thinkbiganalytics.metadata.api.feed.FeedNotFoundException) Feed(com.thinkbiganalytics.metadata.api.feed.Feed)

Example 4 with FeedNotFoundException

use of com.thinkbiganalytics.metadata.api.feed.FeedNotFoundException in project kylo by Teradata.

the class FeedWaterMarkService method cancelActiveWaterMark.

public void cancelActiveWaterMark(String feedId, String waterMarkName) {
    com.thinkbiganalytics.metadata.api.feed.Feed.ID updId = this.metadata.read(() -> {
        this.accessController.checkPermission(AccessController.SERVICES, FeedServicesAccessControl.EDIT_FEEDS);
        com.thinkbiganalytics.metadata.api.feed.Feed.ID id = feedProvider.resolveFeed(feedId);
        com.thinkbiganalytics.metadata.api.feed.Feed feed = feedProvider.getFeed(id);
        if (feed != null) {
            return feed.getId();
        } else {
            throw new FeedNotFoundException(id);
        }
    });
    cancelActiveWaterMark(updId, waterMarkName);
}
Also used : Feed(com.thinkbiganalytics.metadata.api.feed.Feed) FeedNotFoundException(com.thinkbiganalytics.metadata.api.feed.FeedNotFoundException) Feed(com.thinkbiganalytics.metadata.api.feed.Feed)

Example 5 with FeedNotFoundException

use of com.thinkbiganalytics.metadata.api.feed.FeedNotFoundException in project kylo by Teradata.

the class FeedWaterMarkService method getWaterMark.

public Optional<String> getWaterMark(String feedId, String waterMarkName) {
    return this.metadata.read(() -> {
        this.accessController.checkPermission(AccessController.SERVICES, FeedServicesAccessControl.ACCESS_FEEDS);
        com.thinkbiganalytics.metadata.api.feed.Feed.ID id = feedProvider.resolveFeed(feedId);
        com.thinkbiganalytics.metadata.api.feed.Feed feed = feedProvider.getFeed(id);
        if (feed != null) {
            return feed.getWaterMarkValue(waterMarkName);
        } else {
            throw new FeedNotFoundException(id);
        }
    });
}
Also used : Feed(com.thinkbiganalytics.metadata.api.feed.Feed) FeedNotFoundException(com.thinkbiganalytics.metadata.api.feed.FeedNotFoundException) Feed(com.thinkbiganalytics.metadata.api.feed.Feed)

Aggregations

FeedNotFoundException (com.thinkbiganalytics.metadata.api.feed.FeedNotFoundException)12 Feed (com.thinkbiganalytics.metadata.api.feed.Feed)9 DeployResponseEntityVersion (com.thinkbiganalytics.feedmgr.rest.model.DeployResponseEntityVersion)3 EntityVersion (com.thinkbiganalytics.feedmgr.rest.model.EntityVersion)3 NifiFeed (com.thinkbiganalytics.feedmgr.rest.model.NifiFeed)3 UIFeed (com.thinkbiganalytics.feedmgr.rest.model.UIFeed)3 Node (javax.jcr.Node)3 HadoopAuthorizationService (com.thinkbiganalytics.datalake.authorization.service.HadoopAuthorizationService)2 EntityVersionDifference (com.thinkbiganalytics.feedmgr.rest.model.EntityVersionDifference)2 FeedMetadata (com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata)2 FeedSummary (com.thinkbiganalytics.feedmgr.rest.model.FeedSummary)2 FeedVersions (com.thinkbiganalytics.feedmgr.rest.model.FeedVersions)2 RegisteredTemplate (com.thinkbiganalytics.feedmgr.rest.model.RegisteredTemplate)2 UserProperty (com.thinkbiganalytics.feedmgr.rest.model.UserProperty)2 FeedServicesAccessControl (com.thinkbiganalytics.feedmgr.security.FeedServicesAccessControl)2 JcrEntityVersion (com.thinkbiganalytics.metadata.modeshape.versioning.JcrEntityVersion)2 ActionGroup (com.thinkbiganalytics.security.rest.model.ActionGroup)2 AbstractMap (java.util.AbstractMap)2 HashMap (java.util.HashMap)2 NotFoundException (javax.ws.rs.NotFoundException)2