summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorPreston Cody <codeman@gentoo.org>2007-12-31 06:51:28 +0000
committerPreston Cody <codeman@gentoo.org>2007-12-31 06:51:28 +0000
commit2390fb8ef38add48854d201cc21c0c9c9a8aad81 (patch)
tree99143181f6ee14a90248ebdc6c353e78cefe7a5a /server
parentadding a check for existence of logfile in the config (diff)
downloadscire-2390fb8ef38add48854d201cc21c0c9c9a8aad81.tar.gz
scire-2390fb8ef38add48854d201cc21c0c9c9a8aad81.tar.bz2
scire-2390fb8ef38add48854d201cc21c0c9c9a8aad81.zip
added global for clientid, added to identify query.
toss existing jobs concept for get_jobs. fleshed out get_jobs and get_job a bit. fixed some rough DBI. svn path=/branches/new-fu/; revision=287
Diffstat (limited to 'server')
-rwxr-xr-xserver/scireserver.pl63
1 files changed, 40 insertions, 23 deletions
diff --git a/server/scireserver.pl b/server/scireserver.pl
index ef3933e..dfff449 100755
--- a/server/scireserver.pl
+++ b/server/scireserver.pl
@@ -16,6 +16,7 @@ read_config_file($conf_file);
Dumper(\%conf);
my $identified = 0; #Global variable to determine if already identified or not.
+my $client_id = 0; #Clobal variable for the client id.
# Somehow this feels insecure.
sub logger {
@@ -70,8 +71,7 @@ while(<>) {
}
if ($command eq "GET_JOBS") {
- my @existing_jobs = @args;
- get_jobs(@existing_jobs);
+ get_jobs();
} elsif ($command eq "GET_JOB") {
my $job = $args[0];
@@ -117,9 +117,8 @@ sub register_client {
$query = 'SELECT statusid FROM client_status WHERE statusname = "Pending"';
debug("Query is $query");
$status_id = "4"; #db.conn.GetRow($query)
- #$sth = $dbh->prepare($query);
- #my @result = $sth->fetchrow_array();
- #$status_id = $result[0];
+ #$sth = $dbh->prepare($query);
+ #$status_id = $sth->fetchrow_hashref->{'statusid'};
};
($@) and print "ERROR Could not get status id: $DBI::errstr\n";
@@ -132,8 +131,7 @@ sub register_client {
debug("Query is $query");
$id = "56"; #execute $query
#$sth = $dbh->prepare($query);
- #my @result = $sth->fetchrow_array();
- #$id = $result[0];
+ #$id = $sth->fetchrow_hashref->{'id'};
$query = 'UPDATE `gacl_axo_seq` SET id=?';
debug("Query is $query");
@@ -173,37 +171,56 @@ sub identify_client {
$fingerprint =~ s/"//g; #Clear the quotes.
$fingerprint =~ /^[A-Za-z0-9]+$/ or print "ERROR invalid fingerprint!\n";
- my $query = 'SELECT client_status.statusname FROM clients JOIN client_status on (clients.status = client_status.statusid) WHERE clients.digest=?';
+ my $query = 'SELECT client_status.statusname, clients.clientid FROM clients JOIN client_status on (clients.status = client_status.statusid) WHERE clients.digest=?';
debug("Query is $query");
#$sth = $dbh->prepare($query);
- #$sth->execute($fingerprint);
+ #$sth->execute($digest);
+ #my $status_name = $sth->fetchrow_hashref->{'client_status.statusname'};
+ #$client_id = $sth->fetchrow_hashref->{'clients.clientid'};
$identified = 1;
print "OK\n";
+
}
+
+
sub get_jobs {
- my (@existing_jobs) = (@_);
- #Validate your inputs!
- foreach my $jobid (@existing_jobs) {
- unless($jobid =~ /^\d$/) {
- print "ERROR Invalid jobid given as input $jobid\n";
- return undef;
- }
- }
- my $query = <<'EndOfQuery'
- SELECT jobs.jobid, jobs.priority, job_conditions.job_dependency, job_conditions.deploy_time, job_conditions.expiration_time, job_history.statusid
+ my $query = <<' EndOfQuery'
+ SELECT jobs.jobid
FROM jobs NATURAL JOIN jobs_clients NATURAL JOIN job_conditions NATURAL JOIN job_history
- WHERE jobs_clients.clientid = %s
+ WHERE jobs_clients.clientid = ?
AND jobs.jobid = jobs_clients.jobid
AND (job_conditions.deploy_time < now())
AND (job_conditions.expiration_time > now())
- AND job_history.statusid = '%s'
+ AND job_history.statusid = '?'
ORDER BY jobs.priority,jobs.created
-EndOfQuery
+ EndOfQuery
+
+ debug("Query is $query");
+ #$sth = $dbh->prepare($query);
+ #$sth->execute($client_id,$status_id);
+ #my $jobs_ref = $sth->fetchall_arrayref();
+ #return $jobs_ref;
}
sub get_job {
- my $job = shift;
+ my $jobid = shift;
#Validate your inputs!
+ my $query = 'SELECT * FROM jobs LEFT JOIN job_conditions on (jobs.jobid) WHERE jobs.jobid = ?';
+ debug("Query is $query");
+ #my $sth = $dbh->prepare($query);
+ #$sth->execute($jobid);
+ #my $job = $sth->fetchrow_hashref();
+ #my $scriptid = $job{'script'};
+
+ $query = 'SELECT * FROM scripts WHERE scriptid=?';
+ debug("Query is $query");
+ #$sth = $dbh->prepare($query);
+ #$sth->execute($scriptid);
+ #$job{'script'} = $sth->fetchrow_hashref();
+
+ #Write the job w/ all data to a jobfile with the following path /JOBDIR/CLIENT_ID/queue/JOBID.job
+ my $filename = "$conf{job_dir}/$client_id/queue/$jobid.job";
+ return "OK $filename\n";
}
sub set_job_status {
my ($jobid,$status) = @_;