Search in sources :

Example 11 with ServiceLevelAgreement

use of com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement in project kylo by Teradata.

the class FeedSlaUpgradeAction method upgradeFeedSla.

private void upgradeFeedSla(ExtensibleType type) {
    List<ExtensibleEntity> slaRels = entityProvider.getEntities(SLA_REL_TYPE_NAME);
    for (ExtensibleEntity rel : slaRels) {
        ServiceLevelAgreement sla = JcrUtil.getJcrObject(rel.getProperty("sla"), JcrServiceLevelAgreement.class);
        Set<Feed> feeds = rel.getPropertyAsSet("feeds", Node.class).stream().map(JcrFeed::new).collect(Collectors.toSet());
        feedSlaProvider.relateFeeds(sla, feeds);
        entityProvider.deleteEntity(rel.getId());
    }
    this.typeProvider.deleteType(type.getId());
}
Also used : Node(javax.jcr.Node) JcrServiceLevelAgreement(com.thinkbiganalytics.metadata.modeshape.sla.JcrServiceLevelAgreement) ServiceLevelAgreement(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement) ExtensibleEntity(com.thinkbiganalytics.metadata.api.extension.ExtensibleEntity) Feed(com.thinkbiganalytics.metadata.api.feed.Feed) JcrFeed(com.thinkbiganalytics.metadata.modeshape.feed.JcrFeed)

Example 12 with ServiceLevelAgreement

use of com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement in project kylo by Teradata.

the class FeedDetails method getServiceLevelAgreements.

public List<ServiceLevelAgreement> getServiceLevelAgreements() {
    Set<Node> list = JcrPropertyUtil.getReferencedNodeSet(this.node, SLA);
    List<ServiceLevelAgreement> serviceLevelAgreements = new ArrayList<>();
    if (list != null) {
        for (Node n : list) {
            serviceLevelAgreements.add(JcrUtil.createJcrObject(n, JcrServiceLevelAgreement.class));
        }
    }
    return serviceLevelAgreements;
}
Also used : JcrServiceLevelAgreement(com.thinkbiganalytics.metadata.modeshape.sla.JcrServiceLevelAgreement) Node(javax.jcr.Node) ArrayList(java.util.ArrayList) ServiceLevelAgreement(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement) JcrServiceLevelAgreement(com.thinkbiganalytics.metadata.modeshape.sla.JcrServiceLevelAgreement)

Example 13 with ServiceLevelAgreement

use of com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement in project kylo by Teradata.

the class JcrFeedProvider method enableFeed.

// 
// @Override
// public com.thinkbiganalytics.metadata.api.feed.FeedSource.ID resolveSource(Serializable sid) {
// return new JcrFeedSource.FeedSourceId((sid));
// }
// 
// @Override
// public com.thinkbiganalytics.metadata.api.feed.FeedDestination.ID resolveDestination(Serializable sid) {
// return new JcrFeedDestination.FeedDestinationId(sid);
// }
@Override
public boolean enableFeed(Feed.ID id) {
    Feed feed = getFeed(id);
    if (accessController.isEntityAccessControlled()) {
        feed.getAllowedActions().checkPermission(FeedAccessControl.ENABLE_DISABLE);
    }
    if (!feed.getState().equals(Feed.State.ENABLED)) {
        feed.setState(Feed.State.ENABLED);
        // Enable any SLAs on this feed
        List<ServiceLevelAgreement> serviceLevelAgreements = feed.getServiceLevelAgreements();
        if (serviceLevelAgreements != null) {
            for (ServiceLevelAgreement sla : serviceLevelAgreements) {
                JcrServiceLevelAgreement jcrSla = (JcrServiceLevelAgreement) sla;
                jcrSla.enable();
            }
        }
        return true;
    }
    return false;
}
Also used : JcrServiceLevelAgreement(com.thinkbiganalytics.metadata.modeshape.sla.JcrServiceLevelAgreement) ServiceLevelAgreement(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement) JcrServiceLevelAgreement(com.thinkbiganalytics.metadata.modeshape.sla.JcrServiceLevelAgreement) Feed(com.thinkbiganalytics.metadata.api.feed.Feed)

Example 14 with ServiceLevelAgreement

use of com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement in project kylo by Teradata.

the class JcrServiceLevelAgreementProvider method getAgreements.

/* (non-Javadoc)
     * @see com.thinkbiganalytics.metadata.sla.spi.ServiceLevelAgreementProvider#getAgreements()
     */
@Override
public /**
 * Find all Agreements that are not Preconditions
 */
List<ServiceLevelAgreement> getAgreements() {
    try {
        Session session = getSession();
        Node slasNode = session.getNode(EntityUtil.pathForSla());
        @SuppressWarnings("unchecked") Iterator<Node> itr = (Iterator<Node>) slasNode.getNodes("sla-*");
        return Lists.newArrayList(Iterators.transform(itr, (slaNode) -> {
            return JcrUtil.createJcrObject(slaNode, JcrServiceLevelAgreement.class);
        }));
    } catch (RepositoryException e) {
        throw new MetadataRepositoryException("Failed to retrieve the ServiceLevelAgreements", e);
    }
}
Also used : EntityUtil(com.thinkbiganalytics.metadata.modeshape.common.EntityUtil) Metric(com.thinkbiganalytics.metadata.sla.api.Metric) JcrTools(org.modeshape.jcr.api.JcrTools) SlaId(com.thinkbiganalytics.metadata.modeshape.sla.JcrServiceLevelAgreement.SlaId) ServiceLevelAgreementActionConfiguration(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementActionConfiguration) QueryResult(javax.jcr.query.QueryResult) Obligation(com.thinkbiganalytics.metadata.sla.api.Obligation) JcrPropertyConstants(com.thinkbiganalytics.metadata.modeshape.common.JcrPropertyConstants) JcrQueryUtil(com.thinkbiganalytics.metadata.modeshape.support.JcrQueryUtil) SecurityContextHolder(org.springframework.security.core.context.SecurityContextHolder) ServiceLevelAgreement(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement) ServiceLevelAgreementChange(com.thinkbiganalytics.metadata.api.event.sla.ServiceLevelAgreementChange) JcrPropertyUtil(com.thinkbiganalytics.metadata.modeshape.support.JcrPropertyUtil) ImmutableMap(com.google.common.collect.ImmutableMap) Session(javax.jcr.Session) Collection(java.util.Collection) Set(java.util.Set) UUID(java.util.UUID) MetadataEventService(com.thinkbiganalytics.metadata.api.event.MetadataEventService) ItemNotFoundException(javax.jcr.ItemNotFoundException) Serializable(java.io.Serializable) List(java.util.List) Principal(java.security.Principal) FeedServiceLevelAgreementProvider(com.thinkbiganalytics.metadata.api.sla.FeedServiceLevelAgreementProvider) ServiceLevelAgreementEvent(com.thinkbiganalytics.metadata.api.event.sla.ServiceLevelAgreementEvent) BaseJcrProvider(com.thinkbiganalytics.metadata.modeshape.BaseJcrProvider) JcrMetadataAccess(com.thinkbiganalytics.metadata.modeshape.JcrMetadataAccess) JcrEntity(com.thinkbiganalytics.metadata.modeshape.common.JcrEntity) MetadataRepositoryException(com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException) ServiceLevelAgreementBuilder(com.thinkbiganalytics.metadata.sla.spi.ServiceLevelAgreementBuilder) Iterators(com.google.common.collect.Iterators) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) Lists(com.google.common.collect.Lists) ObligationGroupBuilder(com.thinkbiganalytics.metadata.sla.spi.ObligationGroupBuilder) RepositoryException(javax.jcr.RepositoryException) Node(javax.jcr.Node) ServiceLevelAgreementCheckBuilder(com.thinkbiganalytics.metadata.sla.spi.ServiceLevelAgreementCheckBuilder) MetadataChange(com.thinkbiganalytics.metadata.api.event.MetadataChange) JcrFeedPrecondition(com.thinkbiganalytics.metadata.modeshape.feed.JcrFeedPrecondition) ID(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement.ID) Iterator(java.util.Iterator) DateTime(org.joda.time.DateTime) ServiceLevelAgreementActionConfig(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreementActionConfig) ServiceLevelAgreementProvider(com.thinkbiganalytics.metadata.sla.spi.ServiceLevelAgreementProvider) ServiceLevelAgreementCheck(com.thinkbiganalytics.metadata.sla.spi.ServiceLevelAgreementCheck) Consumer(java.util.function.Consumer) Condition(com.thinkbiganalytics.metadata.sla.api.ObligationGroup.Condition) JcrUtil(com.thinkbiganalytics.metadata.modeshape.support.JcrUtil) ObligationBuilder(com.thinkbiganalytics.metadata.sla.spi.ObligationBuilder) MetadataRepositoryException(com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException) Node(javax.jcr.Node) Iterator(java.util.Iterator) MetadataRepositoryException(com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException) RepositoryException(javax.jcr.RepositoryException) Session(javax.jcr.Session)

Example 15 with ServiceLevelAgreement

use of com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement in project kylo by Teradata.

the class InMemoryFeedProvider method createPrecondition.

@Override
public Feed createPrecondition(Feed.ID feedId, String descr, List<Metric> metrics) {
    BaseFeed feed = (BaseFeed) this.feeds.get(feedId);
    if (feed != null) {
        // Remove the old one if any
        FeedPreconditionImpl precond = (FeedPreconditionImpl) feed.getPrecondition();
        if (precond != null) {
            this.slaProvider.removeAgreement(precond.getAgreement().getId());
        }
        ServiceLevelAgreement sla = this.slaProvider.builder().name("Precondition for feed " + feed.getName() + " (" + feed.getId() + ")").description(descr).obligationBuilder(Condition.REQUIRED).metric(metrics).build().build();
        return setupPrecondition(feed, sla);
    } else {
        throw new FeedCreateException("A feed with the given ID does not exists: " + feedId);
    }
}
Also used : FeedPreconditionImpl(com.thinkbiganalytics.metadata.core.feed.BaseFeed.FeedPreconditionImpl) ServiceLevelAgreement(com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement)

Aggregations

ServiceLevelAgreement (com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement)44 Test (org.junit.Test)20 ServiceLevelAssessment (com.thinkbiganalytics.metadata.sla.api.ServiceLevelAssessment)19 JcrServiceLevelAgreement (com.thinkbiganalytics.metadata.modeshape.sla.JcrServiceLevelAgreement)8 ArrayList (java.util.ArrayList)6 Feed (com.thinkbiganalytics.metadata.api.feed.Feed)5 Obligation (com.thinkbiganalytics.metadata.sla.api.Obligation)5 Node (javax.jcr.Node)5 JobIdentifier (com.thinkbiganalytics.scheduler.JobIdentifier)4 DefaultJobIdentifier (com.thinkbiganalytics.scheduler.model.DefaultJobIdentifier)4 List (java.util.List)4 Set (java.util.Set)4 Lists (com.google.common.collect.Lists)3 FeedServiceLevelAgreement (com.thinkbiganalytics.metadata.api.sla.FeedServiceLevelAgreement)3 FeedServiceLevelAgreementProvider (com.thinkbiganalytics.metadata.api.sla.FeedServiceLevelAgreementProvider)3 FeedServiceLevelAgreementRelationship (com.thinkbiganalytics.metadata.api.sla.FeedServiceLevelAgreementRelationship)3 JcrMetadataAccess (com.thinkbiganalytics.metadata.modeshape.JcrMetadataAccess)3 MetadataRepositoryException (com.thinkbiganalytics.metadata.modeshape.MetadataRepositoryException)3 JcrFeed (com.thinkbiganalytics.metadata.modeshape.feed.JcrFeed)3 JcrPropertyUtil (com.thinkbiganalytics.metadata.modeshape.support.JcrPropertyUtil)3