use of cz.metacentrum.perun.taskslib.model.Task in project perun by CESNET.
the class TaskSchedulerImpl method processPool.
@Override
public void processPool() throws InternalErrorException {
for (Task task : schedulingPool.getNewTasks()) {
if (task.isPropagationForced()) {
// this can happen only as a race between this thread and thread created for force-scheduled task
log.info("Found force-scheduled task {} during normal schedule cycle, resetting force flag", task.getId());
// may not be the best behavior...
task.setPropagationForced(false);
}
log.debug("Propagating task {}, ExecService:Facility : " + task.getExecServiceId() + ":" + task.getFacilityId(), task.getId());
propagateService(task, new Date(System.currentTimeMillis()));
}
}
use of cz.metacentrum.perun.taskslib.model.Task in project perun by CESNET.
the class EngineManagerImpl method switchUnfinishedTasksToERROR.
@Override
public void switchUnfinishedTasksToERROR() {
log.info("I am going to switched all unfinished tasks to ERROR and finished GEN tasks which data wasn't send to ERROR as well");
/* we set everything found to error to report it back to dispatcher */
for (Task task : schedulingPool.getDoneTasks()) {
ExecService execService = task.getExecService();
if (execService.getExecServiceType().equals(ExecServiceType.GENERATE)) {
log.debug("Setting task " + task.toString() + " to ERROR");
schedulingPool.setTaskStatus(task, TaskStatus.ERROR);
}
}
for (Task task : schedulingPool.getProcessingTasks()) {
log.debug("Setting task " + task.toString() + " to ERROR");
schedulingPool.setTaskStatus(task, TaskStatus.ERROR);
}
for (Task task : schedulingPool.getPlannedTasks()) {
log.debug("Setting task " + task.toString() + " to ERROR");
schedulingPool.setTaskStatus(task, TaskStatus.ERROR);
}
log.info("I'm done with it.");
}
use of cz.metacentrum.perun.taskslib.model.Task in project perun by CESNET.
the class ExecutorEngineWorkerImplTest method runGenTest.
@Test
public void runGenTest() throws Exception {
System.out.println("ExecutorEngineWorkerImpl.runGenTest");
ExecutorEngineWorker worker = (ExecutorEngineWorker) beanFactory.getBean("executorEngineWorker");
log.debug("task " + task_gen.toString());
schedulingPool.addToPool(task_gen);
for (Task task : taskManager.listAllTasks(engineId)) {
log.debug("task in db " + ((task == null) ? "null" : task.toString()));
}
count = 0;
// for test there is no send subfolder, let's fake root
((ExecutorEngineWorkerImpl) worker).setGenDirectory(new File("/"));
worker.setTask(task_gen);
worker.setExecService(task_gen.getExecService());
worker.setFacility(task_gen.getFacility());
worker.setDestination(destination1);
worker.setResultListener(this);
worker.run();
Assert.isTrue(count == 1, "count 1");
}
use of cz.metacentrum.perun.taskslib.model.Task in project perun by CESNET.
the class ExecutorEngineWorkerImplTest method runSendTest.
@Test
public void runSendTest() throws Exception {
System.out.println("ExecutorEngineWorkerImpl.runSendTest");
ExecutorEngineWorker worker = (ExecutorEngineWorker) beanFactory.getBean("executorEngineWorker");
log.debug("task " + task1.toString());
// add task to local db
schedulingPool.addToPool(task1);
for (Task task : taskManager.listAllTasks(engineId)) {
log.debug("task in db " + ((task == null) ? "null" : task.toString()));
}
count = 0;
// for test there is no send subfolder, let's fake root
((ExecutorEngineWorkerImpl) worker).setSendDirectory(new File("/"));
worker.setTask(task1);
worker.setExecService(task1.getExecService());
worker.setFacility(task1.getFacility());
worker.setDestination(destination1);
worker.setResultListener(this);
worker.run();
Assert.isTrue(count == 1, "count 1");
}
use of cz.metacentrum.perun.taskslib.model.Task in project perun by CESNET.
the class FacilitiesManagerBlImpl method deleteFacility.
@Override
public void deleteFacility(PerunSession sess, Facility facility, Boolean force) throws RelationExistsException, FacilityAlreadyRemovedException, HostAlreadyRemovedException, ResourceAlreadyRemovedException, GroupAlreadyRemovedFromResourceException {
if (force) {
List<Resource> resources = this.getAssignedResources(sess, facility);
for (Resource resource : resources) {
getPerunBl().getResourcesManagerBl().deleteResource(sess, resource);
}
List<Task> tasks = perunBl.getTasksManagerBl().listAllTasksForFacility(sess, facility.getId());
for (Task task : tasks) {
perunBl.getTasksManagerBl().deleteTaskResults(sess, task.getId());
perunBl.getTasksManagerBl().removeTask(sess, task.getId());
}
} else {
if (getFacilitiesManagerImpl().getAssignedResources(sess, facility).size() > 0) {
throw new RelationExistsException("Facility is still used as a resource");
}
}
// remove admins of this facility
List<Group> adminGroups = getFacilitiesManagerImpl().getAdminGroups(sess, facility);
for (Group adminGroup : adminGroups) {
try {
AuthzResolverBlImpl.unsetRole(sess, adminGroup, facility, Role.FACILITYADMIN);
} catch (GroupNotAdminException e) {
log.warn("When trying to unsetRole FacilityAdmin for group {} in the facility {} the exception was thrown {}", adminGroup, facility, e);
// skip and log as warning
} catch (RoleCannotBeManagedException e) {
throw new InternalErrorException(e);
}
}
List<User> adminUsers = getFacilitiesManagerImpl().getAdmins(sess, facility);
for (User adminUser : adminUsers) {
try {
AuthzResolverBlImpl.unsetRole(sess, adminUser, facility, Role.FACILITYADMIN);
} catch (UserNotAdminException e) {
log.warn("When trying to unsetRole FacilityAdmin for user {} in the facility {} the exception was thrown {}", adminUser, facility, e);
// skip and log as warning
} catch (RoleCannotBeManagedException e) {
throw new InternalErrorException(e);
}
}
// remove hosts
List<Host> hosts = this.getHosts(sess, facility);
for (Host host : hosts) {
this.removeHost(sess, host, facility);
}
// remove destinations
getPerunBl().getServicesManagerBl().removeAllDestinations(sess, facility);
// remove assigned security teams
List<SecurityTeam> teams = getAssignedSecurityTeams(sess, facility);
for (SecurityTeam team : teams) {
removeSecurityTeam(sess, facility, team);
}
// remove associated attributes
try {
getPerunBl().getAttributesManagerBl().removeAllAttributes(sess, facility);
} catch (WrongAttributeValueException | WrongReferenceAttributeValueException e) {
throw new InternalErrorException(e);
}
// Remove all facility bans
List<BanOnFacility> bansOnFacility = this.getBansForFacility(sess, facility.getId());
for (BanOnFacility banOnFacility : bansOnFacility) {
try {
this.removeBan(sess, banOnFacility.getId());
} catch (BanNotExistsException ex) {
// it is ok, we just want to remove it anyway
}
}
// Remove all service denials
getFacilitiesManagerImpl().removeAllServiceDenials(facility.getId());
// delete facility
getFacilitiesManagerImpl().deleteFacilityOwners(sess, facility);
getFacilitiesManagerImpl().deleteFacility(sess, facility);
getPerunBl().getAuditer().log(sess, new FacilityDeleted(facility));
}
Aggregations