~ubuntu-branches/ubuntu/raring/gdis/raring-proposed

« back to all changes in this revision

Viewing changes to job.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Leidert (dale)
  • Date: 2009-04-06 17:12:18 UTC
  • mfrom: (3.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090406171218-uizoe126jrq09ytt
Tags: 0.90-1
* New upstream release 0.90.
* Acknowledge NMU (closes: #492994). Thanks to Neil Williams.

* makefile.debian: Upstream doesn't provide a Makefile to edit - so created
  our own.
* debian/compat: Added and set to be 5.
* debian/control: Added Homepage, Vcs* and DM-Upload-Allowed fields.
  (Maintainer): Set to the debichem team with approval by Noèl.
  (Uploaders): Added myself.
  (Build-Depends): Increased debhelper version to 5. Removed glutg3-dev.
  Added dpatch.
  (Standards-Version): Bumped to 3.8.1.
  (Description): Removed homepage. Fixed a typo.
* debian/copyright: Updated, completed and adjusted.
* debian/dirs: Dropped useless file.
* debian/docs: Renamed to debian/gdis.docs.
* debian/menu: Renamed to debian/gdis.menu.
  (section): Fixed accordingly to policy.
* debian/gdis.1: Just some formatting changes.
* debian/gdis.desktop: Added file (with small fixes) provided by Phill Bull
  (LP: #111353).
* debian/gdis.install: Added.
* debian/rules: Cleaned. Installation is now done by dh_install. Make sure,
  the CVS directory is not copied. Added dh_desktop call.
* debian/source.lintian-overrides: makefile.debian is created for Debian but
  lives outside debian/.
* debian/watch: Added.
* debian/README.build: Dropped.
* debian/README.source: Added to be compliant to the policy v3.8.
* debian/patches/Debian_make.dpatch: Added.
  - gdis.h (ELEM_FILE): Moved fix for gdis.elemts path (#399132) to this
    patch.
* debian/patches/00list: Added.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Copyright (C) 2003 by Sean David Fleming
 
3
 
 
4
sean@ivec.org
 
5
 
 
6
This program is free software; you can redistribute it and/or
 
7
modify it under the terms of the GNU General Public License
 
8
as published by the Free Software Foundation; either version 2
 
9
of the License, or (at your option) any later version.
 
10
 
 
11
This program is distributed in the hope that it will be useful,
 
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
GNU General Public License for more details.
 
15
 
 
16
You should have received a copy of the GNU General Public License
 
17
along with this program; if not, write to the Free Software
 
18
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
19
 
 
20
The GNU GPL can also be found at http://www.gnu.org
 
21
*/
 
22
 
 
23
#ifndef _WIN32
 
24
 
 
25
#include <stdio.h>
 
26
#include <stdlib.h>
 
27
#include <string.h>
 
28
#include <unistd.h>
 
29
 
 
30
#include "gdis.h"
 
31
#include "file.h"
 
32
#include "host.h"
 
33
#include "job.h"
 
34
 
 
35
/* top level data structure */
 
36
extern struct sysenv_pak sysenv;
 
37
 
 
38
/* the essential aim of the job structure is simply to establish a link between 
 
39
input/ouput file pairs (local <-> remote) so that jobs can be tracked/updated.
 
40
NB: Place each remotely executed job in its own directory ( job1 job2 etc ) and give
 
41
the user an option to copy ALL files in that directory back to the local machine 
 
42
(by default copy only the output file) This way we get addition data
 
43
such as e density and anything else copied back if desired ... possible refinements
 
44
include a list of all files with size and type that user can check/uncheck as 
 
45
transaction transfers ... binary files may be a problem */
 
46
 
 
47
struct job_pak 
 
48
{
 
49
gint id;
 
50
gint type;
 
51
gint count;
 
52
gint status;
 
53
 
 
54
gchar *local_dir;
 
55
gchar *local_input;
 
56
gchar *local_output;
 
57
 
 
58
gchar *remote_dir;
 
59
gchar *remote_input;
 
60
gchar *remote_output;
 
61
 
 
62
gpointer host;
 
63
};
 
64
 
 
65
/**********************/
 
66
/* free job structure */
 
67
/**********************/
 
68
void job_free(struct job_pak *job)
 
69
{
 
70
g_free(job->local_dir);
 
71
g_free(job->local_input);
 
72
g_free(job->local_output);
 
73
g_free(job->remote_dir);
 
74
g_free(job->remote_input);
 
75
g_free(job->remote_output);
 
76
g_free(job);
 
77
}
 
78
 
 
79
/******************************/
 
80
/* initialize a job structure */
 
81
/******************************/
 
82
gpointer job_setup(const gchar *name, struct model_pak *model)
 
83
{
 
84
static gint count=0;
 
85
struct job_pak *job;
 
86
 
 
87
job = g_malloc(sizeof(struct job_pak));
 
88
 
 
89
/* use this to give unique job names (within cwd of an ssh session) */
 
90
/* since the cwd is date/time based we wont get overwrites */
 
91
job->count = count++;
 
92
job->host = NULL;
 
93
job->local_dir = NULL;
 
94
job->local_input = NULL;
 
95
job->local_output = NULL;
 
96
job->remote_dir = NULL;
 
97
job->remote_input = NULL;
 
98
job->remote_output = NULL;
 
99
 
 
100
if (g_ascii_strncasecmp("gulp", name, 4) == 0)
 
101
  job->type = JOB_GULP;
 
102
 
 
103
switch (job->type)
 
104
  {
 
105
  case JOB_GULP:
 
106
    job->local_dir = g_strdup(sysenv.cwd);
 
107
    job->local_input = g_strdup(model->gulp.temp_file);
 
108
    job->local_output = g_strdup(model->gulp.out_file);
 
109
 
 
110
/* FIXME - filename is not the full path name ... which strictly it should be */
 
111
/* however - job->local_input is expected to contain only the filename (without */
 
112
/* the path) by the subsequent job_start() call */
 
113
write_gulp(job->local_input, model);
 
114
 
 
115
    break;
 
116
 
 
117
  default:
 
118
    printf("Error: unknown job type: %s\n", name);
 
119
    g_free(job);
 
120
    job = NULL;
 
121
  }
 
122
 
 
123
return(job);
 
124
}
 
125
 
 
126
/********************************/
 
127
/* begin the execution of a job */
 
128
/********************************/
 
129
#define DEBUG_JOB_START 1
 
130
void job_start(gpointer host, gpointer data)
 
131
{
 
132
gchar *tmp;
 
133
struct job_pak *job = data;
 
134
 
 
135
/* assign host to job, and initialize */
 
136
job->host = host;
 
137
job->remote_dir = g_strdup(host_cwd(host));
 
138
 
 
139
/* build full path remote names */
 
140
job->remote_input = g_build_filename(job->remote_dir, job->local_input, NULL);
 
141
job->remote_output = g_build_filename(job->remote_dir, job->local_output, NULL);
 
142
 
 
143
/* convert local names to full path names */
 
144
tmp = g_build_filename(job->local_dir, job->local_input, NULL);
 
145
g_free(job->local_input);
 
146
job->local_input = tmp;
 
147
 
 
148
tmp = g_build_filename(job->local_dir, job->local_output, NULL);
 
149
g_free(job->local_output);
 
150
job->local_output = tmp;
 
151
 
 
152
#if DEBUG_JOB_START
 
153
printf("local dir: %s\n", job->local_dir);
 
154
printf("local inp: %s\n", job->local_input);
 
155
printf("local out: %s\n", job->local_output);
 
156
printf("remote dir: %s\n", job->remote_dir);
 
157
printf("remote inp: %s\n", job->remote_input);
 
158
printf("remote out: %s\n", job->remote_output);
 
159
#endif
 
160
 
 
161
host_file_write(host, job->local_input, job->remote_input);
 
162
 
 
163
 
 
164
/* TODO - execute ... bg or queued ... on remote host */
 
165
 
 
166
 
 
167
}
 
168
 
 
169
/***************************/
 
170
/* create a new job object */
 
171
/***************************/
 
172
gint job_new(const gchar *name, struct model_pak *model)
 
173
{
 
174
gpointer host, service, job;
 
175
 
 
176
if (!sysenv.host_list)
 
177
  {
 
178
  printf("No active connections.\n");
 
179
  return(FALSE);
 
180
  }
 
181
host = sysenv.host_list->data;
 
182
 
 
183
service = host_service_get(host, name);
 
184
if (!service)
 
185
  {
 
186
  printf("Unknown service: %s.\n", name);
 
187
  return(FALSE);
 
188
  }
 
189
 
 
190
if (!host_service_available(service))
 
191
  {
 
192
  printf("Service: %s not available on active host.\n", name);
 
193
  return(FALSE);
 
194
  }
 
195
 
 
196
printf("Requesting service: %s on host %s\n", name, host_name(host));
 
197
 
 
198
job = job_setup(name, model);
 
199
 
 
200
/* TODO - put elsewhere (some sort of scheduler decides the host part?) */
 
201
job_start(host, job);
 
202
 
 
203
 
 
204
/* TODO - this'll get placed in job cleanup when jobs are actually run */
 
205
job_free(job);
 
206
 
 
207
 
 
208
return(TRUE);
 
209
}
 
210
 
 
211
/********************************/
 
212
/* check on the status of a job */
 
213
/********************************/
 
214
void job_status_get(gpointer data)
 
215
{
 
216
struct job_pak *job = data;
 
217
 
 
218
g_assert(job != NULL);
 
219
 
 
220
/* TODO - more than one way of doing this ... eg could have qstat for queued jobs */
 
221
/* etc ... scanning output is more portable ... but wont determine if a job has crashed */
 
222
 
 
223
/* could record the last time the output file had new stuff added ... */
 
224
 
 
225
/* get output file */
 
226
host_file_read(job->host, job->local_output, job->remote_output);
 
227
 
 
228
/* scan output */
 
229
 
 
230
 
 
231
}
 
232
 
 
233
/************************************/
 
234
/* eg use to kill/stop/restart jobs */
 
235
/************************************/
 
236
void job_status_set()
 
237
{
 
238
}
 
239
 
 
240
#endif
 
241