|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.codescore.managers.CompetitionManager
public class CompetitionManager
Manages a competition, providing methods to get competitions from the database, and facilities for processing submissions, such as a grading queue and accessor methods to the competition settings.
| Field Summary | |
|---|---|
private static CompetitionManager |
activeCompetition
Deprecated. |
private boolean |
compIsRunning
|
private Competition |
currentComp
|
private static DataContext |
dc
|
private ConcurrentHashMap<Submission,ExecutionResult> |
gradeResults
|
private ConcurrentLinkedQueue<Submission> |
gradingQueue
|
private List<GradingThread> |
gThreads
|
private ConcurrentLinkedQueue<Submission> |
judgingQueue
|
private org.apache.commons.logging.Log |
log
|
private static HashMap<Competition,CompetitionManager> |
managers
A map of linking a competition to its associated manager, used to prevent a competition from having more than one associated manager |
private int |
numGradingThreads
|
private ConcurrentLinkedQueue<Submission> |
practiceQueue
|
private Map<Team,TeamHome> |
teamHomes
|
private GradingThread |
testThread
|
| Constructor Summary | |
|---|---|
CompetitionManager(Competition c)
Create a new manager. |
|
| Method Summary | |
|---|---|
void |
addGradeResult(Submission s,
ExecutionResult er)
When a submission has been graded, the result of the Grader is returned here so that it can be reviewed by a judge. |
void |
addSubmissionToGradeQueue(Submission s)
Add a submission to the grading queue. If the queue already contains s, it will not be added again. |
void |
addSubmissionToPracticeQueue(Submission s)
Add a submission to the practice queue. If the queue already contains s, it will not be added again. |
void |
checkGThreads()
Removes dead graders from the list and ensures that the actual number of active grading threads matches the expected number. |
private void |
checkGThreads(boolean fix)
|
void |
debug()
Dump debugging information to the log |
protected void |
finalize()
We need to make sure that we stop the grading thread for this competition when we clean up this object, also deregisters the listeners. |
int |
getAliveGThreads()
Check for alive graders. |
static List<Competition> |
getAllComps()
|
static List<Competition> |
getAllComps(ObjectContext oc)
|
boolean |
getAutoCompileError()
|
boolean |
getAutoCorrect()
Check to see if the system will mark submissions correct when they match the expected output exactly. |
boolean |
getAutoRuntimeError()
|
Competition |
getCompetition()
|
static Competition |
getCompetitionByName(ObjectContext c,
String name)
|
static Competition |
getCompetitionByName(String name)
Uses the internal context to search for a competition |
int |
getCompile_error_status()
|
ProblemStatus |
getCompileError(ObjectContext oc)
|
int |
getCorrect_status()
|
ProblemStatus |
getCorrect(ObjectContext oc)
|
static CompetitionManager |
getCurrent()
Deprecated. |
static Competition |
getCurrent(ObjectContext oc)
Deprecated. |
static List<Competition> |
getCurrentComps()
Get all currently running competitions using the internal context |
static List<Competition> |
getCurrentComps(ObjectContext oc)
A list of all currently running competitions using the supplied context |
int |
getExeTimeout()
|
static CompetitionManager |
getManager(Competition c)
Get the associated manager for a competition. |
int |
getNumGraders()
|
List<Submission> |
getPendingSubs()
|
int |
getPresentation_error_status()
|
ProblemStatus |
getPresError(ObjectContext oc)
|
int |
getQueueLength()
|
ExecutionResult |
getResult(TeamSubmission s)
Returns the ExecutionResult for a given submission. |
int |
getRuntime_error_status()
|
ProblemStatus |
getRuntimeError(ObjectContext oc)
|
ScoringMode |
getScoringMode()
Get the scoring mode for this competition. Stored in the scoring_mode competition property |
static TeamSubmission |
getSubmission(ObjectContext c,
int sid)
Lookup a submission for a given submission id (sid) |
int |
getTest_status()
|
ProblemStatus |
getTestStatus(ObjectContext oc)
|
int |
getTimelimit_error_status()
|
ProblemStatus |
getTimelimitError(ObjectContext oc)
|
boolean |
getUseSecurity()
Tells the grading system if it should use the extra security precautions while executing a submission. This will cause the grader to fail currently as the security system has not been implemented |
int |
getWrong_output_status()
|
ProblemStatus |
getWrongOutput(ObjectContext oc)
|
private void |
initGThreads()
|
boolean |
isCompIsRunning()
True if the competition is 'running' which means teams can login and submit solutions. |
void |
onSubAdd(TeamSubmission s)
Callback for a new submission |
void |
onSubUpdate(TeamSubmission s)
Callback for an updated submission |
Submission |
pollGradeQueue()
Called by the grading thread to check if any submissions are waiting to be graded. |
Submission |
pollPracticeQueue()
Called by the grading thread to check if any submissions are waiting to be run. |
void |
registerTeamHome(TeamHome th)
Deprecated. |
void |
reGradeAllSubs()
Add ALL submissions for this competition to the grading queue. This method is used mainly for testing and has little real world use. |
void |
setAutoCompileError(boolean on)
Sets the auto_compile_error flag |
void |
setAutoCorrect(boolean autoOn)
Sets auto_correct flag for this competition. |
void |
setAutoRuntimeError(boolean on)
Sets the value of the auto_runtime_error flag |
void |
setCompile_error_status(int compile_error_status)
|
void |
setCompIsRunning(boolean compIsRunning)
|
void |
setCorrect_status(int correct_status)
|
void |
setCurrentComp(Competition currentComp)
Set this manager's competition |
void |
setExeTimeout(int tout)
Set the max time for an execution. |
void |
setNumGraders(int num)
Sets the number of grading threads for this competition. |
void |
setPresentation_error_status(int presentation_error_status)
|
void |
setRuntime_error_status(int runtime_error_status)
|
void |
setScoringMode(ScoringMode mode)
Set the scoring mode to be used by the competition |
void |
setTest_status(int test_status)
|
void |
setTimelimit_error_status(int timelimit_error_status)
|
void |
setUseSecurity(boolean on)
Set the use_security property. |
void |
setWrong_output_status(int wrong_output_status)
|
void |
unRegisterTeamHome(TeamHome th)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static CompetitionManager activeCompetition
private static DataContext dc
private static HashMap<Competition,CompetitionManager> managers
private volatile boolean compIsRunning
private Competition currentComp
private ConcurrentHashMap<Submission,ExecutionResult> gradeResults
private ConcurrentLinkedQueue<Submission> gradingQueue
private ConcurrentLinkedQueue<Submission> practiceQueue
private List<GradingThread> gThreads
private ConcurrentLinkedQueue<Submission> judgingQueue
private org.apache.commons.logging.Log log
private int numGradingThreads
private Map<Team,TeamHome> teamHomes
private GradingThread testThread
| Constructor Detail |
|---|
public CompetitionManager(Competition c)
c - The competition the manager is associated with
IllegalArgumentException - If a manager already exists for the competition. Use
getManager(Competition) to safely
get a manager for a competition| Method Detail |
|---|
public static List<Competition> getAllComps()
DataContextpublic static List<Competition> getAllComps(ObjectContext oc)
oc - The context used to execute the query
public static Competition getCompetitionByName(ObjectContext c,
String name)
c - The context used to search for the competitionname - The name of the competition
public static Competition getCompetitionByName(String name)
name - The name of the competition to lookup
public static CompetitionManager getCurrent()
public static Competition getCurrent(ObjectContext oc)
oc - The context used to lookup a competition
public static List<Competition> getCurrentComps()
public static List<Competition> getCurrentComps(ObjectContext oc)
oc - The context to use when executing the query
public static CompetitionManager getManager(Competition c)
c - The competition
public static TeamSubmission getSubmission(ObjectContext c,
int sid)
c - The context to use for executing the querysid - The sid of the submission
public void addGradeResult(Submission s,
ExecutionResult er)
s - The submission which was gradeder - The result of the gradingpublic void addSubmissionToGradeQueue(Submission s)
s - The submission to be added.ConcurrentLinkedQueuepublic void addSubmissionToPracticeQueue(Submission s)
s - The submission to be added.ConcurrentLinkedQueuepublic void checkGThreads()
public void debug()
public int getAliveGThreads()
public boolean getAutoCompileError()
public boolean getAutoCorrect()
public boolean getAutoRuntimeError()
public Competition getCompetition()
public int getCompile_error_status()
compile_error_status property of the
competition.getCompileError(ObjectContext)public ProblemStatus getCompileError(ObjectContext oc)
oc - The context used to get the ProblemStatus.
getCompile_error_status()public ProblemStatus getCorrect(ObjectContext oc)
oc - The context used to get the ProblemStatus.
getCorrect_status()public int getCorrect_status()
correct_status property of the competitiongetCorrect(ObjectContext)public int getExeTimeout()
public int getNumGraders()
public List<Submission> getPendingSubs()
public int getPresentation_error_status()
presentation_error_status property of the
competitiongetPresError(ObjectContext)public ProblemStatus getPresError(ObjectContext oc)
oc - The context used to get the ProblemStatus.
getPresentation_error_status()public int getQueueLength()
ConcurrentLinkedQueue.size()public ExecutionResult getResult(TeamSubmission s)
s - The submission you're looking for.
public int getRuntime_error_status()
runtime_error_status property of the
competition.getRuntimeError(ObjectContext)public ProblemStatus getRuntimeError(ObjectContext oc)
oc - The context used to get the ProblemStatus.
getRuntime_error_status()public ScoringMode getScoringMode()
scoring_mode competition property
public int getTest_status()
test_status property of the competition.getTestStatus(ObjectContext)public ProblemStatus getTestStatus(ObjectContext oc)
oc - The context used to get the ProblemStatus.
getTest_status()public int getTimelimit_error_status()
timelimit_error_status property of the
competition.getTimelimitError(ObjectContext)public ProblemStatus getTimelimitError(ObjectContext oc)
oc - The context used to get the ProblemStatus.
getTimelimit_error_status(),
getExeTimeout()public boolean getUseSecurity()
use_security property of the competitionpublic int getWrong_output_status()
wrong_output_status property of the
competitiongetWrongOutput(ObjectContext)public ProblemStatus getWrongOutput(ObjectContext oc)
oc - The context used to get the ProblemStatus.
getWrong_output_status()public boolean isCompIsRunning()
public void onSubAdd(TeamSubmission s)
SubUpdateListener
onSubAdd in interface SubUpdateListeners - The new submissionpublic void onSubUpdate(TeamSubmission s)
SubUpdateListener
onSubUpdate in interface SubUpdateListeners - The updated submissionpublic Submission pollGradeQueue()
public Submission pollPracticeQueue()
public void registerTeamHome(TeamHome th)
th - The team home to registerpublic void reGradeAllSubs()
public void setAutoCompileError(boolean on)
auto_compile_error flag
on - the new valuepublic void setAutoCorrect(boolean autoOn)
auto_correct flag for this competition.
autoOn - true if the system should mark submissions correct when they
match the expected output exactly.public void setAutoRuntimeError(boolean on)
auto_runtime_error flag
on - the new valuepublic void setCompile_error_status(int compile_error_status)
compile_error_status - the compile_error_status to setpublic void setCompIsRunning(boolean compIsRunning)
compIsRunning - The compIsRunning to setcompIsRunningpublic void setCorrect_status(int correct_status)
correct_status - the correct_status to setpublic void setCurrentComp(Competition currentComp)
currentComp - The new competitionpublic void setExeTimeout(int tout)
tout - public void setNumGraders(int num)
num - if num is greater than the current number of threads, new
threads are started. If num is less than the current number of
threads, the excess graders are stopped.public void setPresentation_error_status(int presentation_error_status)
presentation_error_status - the presentation_error_status to setpublic void setRuntime_error_status(int runtime_error_status)
runtime_error_status - the runtime_error_status to setpublic void setScoringMode(ScoringMode mode)
mode - The new scoring modepublic void setTest_status(int test_status)
test_status - the test_status to setpublic void setTimelimit_error_status(int timelimit_error_status)
timelimit_error_status - the timelimit_error_status to setpublic void setUseSecurity(boolean on)
use_security property.
on - getUseSecurity()public void setWrong_output_status(int wrong_output_status)
wrong_output_status - the wrong_output_status to setpublic void unRegisterTeamHome(TeamHome th)
private void checkGThreads(boolean fix)
private void initGThreads()
protected void finalize()
throws Throwable
finalize in class ObjectThrowable
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||