public class DBController
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone() |
static byte[] |
compressBytes(java.lang.String data)
Compresses the data to be stored in the database.
|
static boolean |
connect(java.lang.String url,
java.lang.String username,
java.lang.String password)
Connect to the database.
|
void |
createJob(java.lang.String sessionName,
Tournament t)
Creates a job by storing the tournament in the database, and
splitting all sessions into smaller groups.
|
boolean |
existsSessionName(java.lang.String sessionName)
Returns if a sessionname exists.
|
static java.lang.String |
extractBytes(byte[] input)
Decompress a compressed string.
|
static java.lang.String |
getDistributedTutorial() |
static DBController |
getInstance() |
Job |
getJob(int jobID,
java.util.ArrayList<Protocol> sessions)
Gets a group of sessions to run.
|
int |
getJobID(java.lang.String sessionname)
Returns the last issued job with the given session name.
|
int |
getMatchesPerSession(int jobID)
Returns the amount of matches per session.
|
int |
getRunningSessions(int jobID)
Get the amount of jobs which are currently executed by
other instances of Genius or need to be processed.
|
Tournament |
getTournament(int jobID)
Given the jobID of the tournament, the tournament is requested from
the database and stored as a Tournament object.
|
static boolean |
reconnect()
Reconnect to the database.
|
void |
reconstructLog(int jobID)
Reconstructs the full log of outcomes by gluing all separate outcomes
of the job together.
|
void |
resetJobs(int jobID)
Resets all sessions which were busy.
|
void |
storeResult(int sessionID,
java.lang.String outcome)
Store the result of the group of sessions in the DB.
|
public static DBController getInstance()
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
public static boolean connect(java.lang.String url, java.lang.String username, java.lang.String password)
url
- with port (also supports properties: http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-configuration-properties.html)username
- of the database accountpassword
- of the database accountpublic static boolean reconnect()
public void createJob(java.lang.String sessionName, Tournament t)
sessionName
- name of the session given to the tournamentt
- tournament from which the jobs are derived.public int getJobID(java.lang.String sessionname)
sessionname
- name of the session.public Tournament getTournament(int jobID)
jobID
- of the tournament to be retrievedpublic Job getJob(int jobID, java.util.ArrayList<Protocol> sessions)
jobID
- id of the main job.sessions
- array of all jobs of the tournament.public void storeResult(int sessionID, java.lang.String outcome)
sessionID
- ID of the groupoutcome
- outcome for the grouppublic int getRunningSessions(int jobID)
jobID
- ID of the high-level jobpublic boolean existsSessionName(java.lang.String sessionName)
sessionName
- name of the tournament.public void resetJobs(int jobID)
jobID
- ID of the high-level jobpublic void reconstructLog(int jobID)
jobID
- ID of the jobpublic int getMatchesPerSession(int jobID)
jobID
- ID of the high-level jobpublic static java.lang.String getDistributedTutorial()
public static byte[] compressBytes(java.lang.String data) throws java.io.UnsupportedEncodingException, java.io.IOException
data
- to be compressed.java.io.UnsupportedEncodingException
- if UTF-8 encoding is not supported.java.io.IOException
- if there is a problem reading the string.public static java.lang.String extractBytes(byte[] input) throws java.io.UnsupportedEncodingException, java.io.IOException, java.util.zip.DataFormatException
input
- compressed byte array which needs to be decompressed.java.io.UnsupportedEncodingException
- if UTF-8 encoding is not supported.java.io.IOException
- if there is a problem reading the byte array.java.util.zip.DataFormatException
- should not happen.