use of com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement in project kylo by Teradata.
the class ServiceLevelAgreementModelTransform method toModel.
/**
* Transforms the specified domain objects to REST objects.
*
* @param domain the SLA domain object
* @param feeds the feed domain objects
* @param deep {@code true} to include action configurations
* @return the SLA REST object
*/
public FeedServiceLevelAgreement toModel(ServiceLevelAgreement domain, Set<com.thinkbiganalytics.metadata.api.feed.Feed> feeds, boolean deep) {
com.thinkbiganalytics.metadata.rest.model.sla.ServiceLevelAgreement slaModel = toModel(domain, deep);
FeedServiceLevelAgreement feedServiceLevelAgreement = new FeedServiceLevelAgreement(slaModel);
boolean canEdit = false;
boolean canView = true;
if (feeds != null && !feeds.isEmpty()) {
final Set<Feed> feedModels = feeds.stream().filter(feed -> feed != null).map(model::domainToFeed).collect(Collectors.toSet());
feedServiceLevelAgreement.setFeeds(feedModels);
if (accessController.isEntityAccessControlled()) {
// set the flag on the sla edit to true only if the user has access to edit the feeds assigned to this sla
canEdit = feeds.stream().allMatch(feed -> feed.getAllowedActions().hasPermission(FeedAccessControl.EDIT_DETAILS));
// can view
canView = feeds.stream().allMatch(feed -> feed.getAllowedActions().hasPermission(FeedAccessControl.ACCESS_FEED));
} else {
canEdit = this.accessController.hasPermission(AccessController.SERVICES, FeedServicesAccessControl.EDIT_SERVICE_LEVEL_AGREEMENTS);
}
} else {
canEdit = this.accessController.hasPermission(AccessController.SERVICES, FeedServicesAccessControl.EDIT_SERVICE_LEVEL_AGREEMENTS);
}
slaModel.setCanEdit(canEdit);
if (feedServiceLevelAgreement.getFeeds() == null) {
feedServiceLevelAgreement.setFeeds(new HashSet<>());
}
feedServiceLevelAgreement.setCanEdit(canEdit);
return feedServiceLevelAgreement;
}
use of com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement in project kylo by Teradata.
the class DefaultServiceLevelAgreementScheduler method enableServiceLevelAgreement.
/**
* Used to enable the schedule of the SLA, so that once again executes after a being disabled
*
* @param sla The SLA to enable
*/
public void enableServiceLevelAgreement(ServiceLevelAgreement sla) {
ServiceLevelAgreement.ID slaId = sla.getId();
JobIdentifier scheduledJobId = null;
if (scheduledJobNames.containsKey(slaId)) {
scheduledJobId = jobIdentifierForName(scheduledJobNames.get(slaId));
} else {
scheduledJobId = jobIdentifierForName(sla.getName());
}
QuartzScheduler scheduler = (QuartzScheduler) jobScheduler;
if (scheduledJobId != null && scheduler.jobExists(scheduledJobId)) {
try {
jobScheduler.resumeTriggersOnJob(scheduledJobId);
} catch (JobSchedulerException e) {
log.error("Unable to resume the schedule for the SLA {} ", sla.getName());
}
} else {
log.info("Unable to resume the SLA job {} . The Job does not exist", sla.getName());
}
}
use of com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement in project kylo by Teradata.
the class DefaultServiceLevelAgreementScheduler method run.
/**
* Called on startup as part of the PostMetadataConfigAction.
*/
@Override
public void run() {
log.info("PostMetadataConfigAction called for DefaultServiceLevelAgreementScheduler. About to schedule the SLA's ");
metadataAccess.read(() -> {
List<? extends ServiceLevelAgreement> agreements = slaProvider.getAgreements();
if (agreements != null) {
log.info("About to schedule {} SLA's", agreements.size());
for (ServiceLevelAgreement agreement : agreements) {
JobIdentifier jobIdentifier = slaJobName(agreement);
QuartzScheduler scheduler = (QuartzScheduler) jobScheduler;
if (!scheduler.jobExists(jobIdentifier)) {
scheduleServiceLevelAgreement(agreement);
} else {
scheduledJobNames.put(agreement.getId(), jobIdentifier.getName());
}
}
} else {
log.info("No SLA's found to schedule.");
}
return null;
}, MetadataAccess.SERVICE);
}
use of com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement in project kylo by Teradata.
the class DefaultServiceLevelAgreementScheduler method disableServiceLevelAgreement.
/**
* Used to disable the schedule of the SLA, so that it no longer executes until subsequently re-enabled
*
* @param sla The SLA to disable
*/
public void disableServiceLevelAgreement(ServiceLevelAgreement sla) {
ServiceLevelAgreement.ID slaId = sla.getId();
JobIdentifier scheduledJobId = null;
if (scheduledJobNames.containsKey(slaId)) {
scheduledJobId = jobIdentifierForName(scheduledJobNames.get(slaId));
} else {
scheduledJobId = jobIdentifierForName(sla.getName());
}
QuartzScheduler scheduler = (QuartzScheduler) jobScheduler;
if (scheduledJobId != null && scheduler.jobExists(scheduledJobId)) {
try {
jobScheduler.pauseTriggersOnJob(scheduledJobId);
} catch (JobSchedulerException e) {
log.error("Unable to pause the schedule for the disabled SLA {} ", sla.getName());
}
} else {
log.info("Unable to pause the SLA job {} . The Job does not exist", sla.getName());
}
}
use of com.thinkbiganalytics.metadata.sla.api.ServiceLevelAgreement in project kylo by Teradata.
the class DefaultServiceLevelAgreementScheduler method scheduleServiceLevelAgreement.
/**
* Schedules an SLA to be run
*
* @param sla The SLA to schedule
*/
public void scheduleServiceLevelAgreement(ServiceLevelAgreement sla) {
if (scheduledJobNames.containsKey(sla.getId())) {
unscheduleServiceLevelAgreement(sla);
}
JobIdentifier jobIdentifier = slaJobName(sla);
ServiceLevelAgreement.ID slaId = sla.getId();
// schedule the job
scheduleSlaJob(jobIdentifier, slaId);
log.info("Schedule sla job " + jobIdentifier.getName());
scheduledJobNames.put(sla.getId(), jobIdentifier.getName());
// notify the other schedulers in the cluster of the scheduled job name
if (clusterService.isClustered()) {
clusterService.sendMessageToOthers(QTZ_JOB_SCHEDULED_MESSAGE_TYPE, new ScheduledServiceLevelAgreementClusterMessage(slaId, jobIdentifier));
}
if (!sla.isEnabled()) {
disableServiceLevelAgreement(sla);
}
}
Aggregations