int generate_service(char *name, int force);
void do_hosts(char *service);
-int dcm_send_file(char *service, char *host, char *target);
+int dcm_send_file(char *service, int type, char *host, char *target);
int dcm_execute(char *service, char *host, char *script);
void dbmserr(void);
char whobuf[256], *whoami = whobuf, *db = "moira";
+enum { UNIQUE, DISTRIBUTED, REPLICATED };
+
int main(int argc, char **argv)
{
int i;
void do_hosts(char *service)
{
EXEC SQL BEGIN DECLARE SECTION;
- char type[SERVERS_TYPE_SIZE], host[MACHINE_NAME_SIZE], *name;
+ char server_type[SERVERS_TYPE_SIZE], host[MACHINE_NAME_SIZE], *name;
char target[SERVERS_TARGET_FILE_SIZE], script[SERVERS_SCRIPT_SIZE];
const char *errmsg;
- int status = 0, dfgen, replicated, mid;
+ int status = 0, dfgen, type, mid;
time_t now;
EXEC SQL END DECLARE SECTION;
struct save_queue *sq;
EXEC SQL CONNECT :db IDENTIFIED BY :db;
EXEC SQL SELECT dfgen, type, target_file, script
- INTO :dfgen, :type, :target, :script
+ INTO :dfgen, :server_type, :target, :script
FROM servers WHERE name = UPPER(:service);
- replicated = !strncmp(type, "REPLICAT", 8);
+ if (!strncmp(strtrim(server_type), "REPLICAT", 8))
+ type = REPLICATED;
+ else if (!strncmp(server_type, "DISTRIB", 8))
+ type = DISTRIBUTED;
+ else
+ type = UNIQUE;
strtrim(target);
strtrim(script);
EXEC SQL UPDATE serverhosts SET inprogress = 1
WHERE service = UPPER(:service) AND mach_id = :mid;
EXEC SQL COMMIT;
- status = dcm_send_file(service, name, target);
+ status = dcm_send_file(service, type, name, target);
if (status)
{
errmsg = error_message(status);
}
EXEC SQL COMMIT;
- if (replicated)
+ if (type == REPLICATED)
break;
}
}
sq_destroy(sq);
- if (status == MR_SUCCESS || !replicated)
+ if (status == MR_SUCCESS || type != REPLICATED)
{
EXEC SQL DECLARE csr_hst2 CURSOR FOR
SELECT m.name, m.mach_id FROM machine m, serverhosts sh
service, name, errmsg);
}
- if (replicated)
+ if (type == REPLICATED)
{
/* We're giving up, so clear the inprogress flag on
any hosts in this service we haven't gotten to yet */
}
EXEC SQL WHENEVER SQLERROR DO dbmserr();
- if (status && !SOFT_FAIL(status) && replicated)
+ if (status && !SOFT_FAIL(status) && type == REPLICATED)
{
EXEC SQL UPDATE servers SET harderror = :status, errmsg = :errmsg
WHERE name = UPPER(:service);
EXEC SQL UPDATE serverhosts SET inprogress = 0, success = 0, ltt = :now,
hosterror = MR_INTERNAL, hosterrmsg = 'DBMS Internal Error'
WHERE service = UPPER(:service) AND mach_id = :mid;
- if (replicated)
+ if (type == REPLICATED)
{
EXEC SQL UPDATE servers SET harderror = MR_INTERNAL,
errmsg = 'DBMS Internal Error' WHERE name = UPPER(:service);
}
}
-int dcm_send_file(char *service, char *host, char *target)
+int dcm_send_file(char *service, int type, char *host, char *target)
{
char data[MAXPATHLEN];
int code, conn;
goto done;
}
- sprintf(data, "%s/%s.out", DCM_DIR, service);
+ if (type == DISTRIBUTED)
+ sprintf(data, "%s/%s/%s", DCM_DIR, service, host);
+ else
+ sprintf(data, "%s/%s.out", DCM_DIR, service);
code = send_file(conn, data, target, 0);
if (code)
com_err(whoami, code, "sending data to %s", host);