Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cuebot] Redirect transaction #1628

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.imageworks.spcue.DispatchHost;
import com.imageworks.spcue.GroupInterface;
Expand Down Expand Up @@ -276,10 +278,9 @@ public boolean addRedirect(VirtualProc proc, GroupInterface group, boolean kill,
* @param proc
* @return
*/
@Transactional(propagation = Propagation.REQUIRED)
public boolean redirect(VirtualProc proc) {

try {

Redirect r = redirectService.remove(proc.getProcId());
if (r == null) {
logger.info("Failed to find redirect for proc " + proc);
Expand Down Expand Up @@ -307,36 +308,22 @@ public boolean redirect(VirtualProc proc) {
DispatchHost host = hostManager.getDispatchHost(proc.getHostId());

switch (r.getType()) {

case JOB_REDIRECT:
logger.info("attempting a job redirect to " + r.getDestinationId());
JobInterface job = jobDao.getJob(r.getDestinationId());
logger.info("redirecting proc " + proc + " to job " + job.getName());

if (dispatcher.isTestMode()) {
dispatcher.dispatchHost(host, job);
} else {
bookingQueue.execute(new DispatchBookHost(host, job, dispatcher, env));
}
dispatcher.dispatchHost(host, job);
return true;

case GROUP_REDIRECT:
logger.info("attempting a group redirect to " + r.getDestinationId());
GroupInterface group = groupDao.getGroup(r.getDestinationId());
logger.info("redirecting group " + proc + " to job " + group.getName());

if (dispatcher.isTestMode()) {
dispatcher.dispatchHost(host, group);
} else {
bookingQueue.execute(new DispatchBookHost(host, group, dispatcher, env));
}
dispatcher.dispatchHost(host, group);
return true;

default:
logger.info("redirect failed, invalid redirect type: " + r.getType());
return false;
}

} catch (Exception e) {
/*
* If anything fails the redirect fails, so just return false after logging.
Expand Down