server: parse product_name in scheduler request, store in DB

This will let projects see what kind of device each Android host is,
possibly helping with app debugging.
This commit is contained in:
David Anderson 2013-05-23 23:30:42 -07:00
parent a132fcba02
commit cde42fcbcc
6 changed files with 22 additions and 2 deletions

View File

@ -470,6 +470,7 @@ void DB_HOST::db_print(char* buf){
ESCAPE(p_model);
ESCAPE(os_name);
ESCAPE(os_version);
ESCAPE(product_name);
sprintf(buf,
"create_time=%d, userid=%d, "
"rpc_seqno=%d, rpc_time=%d, "
@ -490,7 +491,8 @@ void DB_HOST::db_print(char* buf){
"venue='%s', nresults_today=%d, "
"avg_turnaround=%.15e, "
"host_cpid='%s', external_ip_addr='%s', max_results_day=%d, "
"error_rate=%.15e ",
"error_rate=%.15e, "
"product_name='%s' ",
create_time, userid,
rpc_seqno, rpc_time,
total_credit, expavg_credit, expavg_time,
@ -509,7 +511,8 @@ void DB_HOST::db_print(char* buf){
venue, nresults_today,
avg_turnaround,
host_cpid, external_ip_addr, _max_results_day,
_error_rate
_error_rate,
product_name
);
UNESCAPE(domain_name);
UNESCAPE(serialnum);
@ -519,6 +522,7 @@ void DB_HOST::db_print(char* buf){
UNESCAPE(os_name);
UNESCAPE(os_version);
UNESCAPE(host_cpid);
UNESCAPE(product_name);
}
void DB_HOST::db_parse(MYSQL_ROW &r) {
@ -568,6 +572,7 @@ void DB_HOST::db_parse(MYSQL_ROW &r) {
strcpy2(external_ip_addr, r[i++]);
_max_results_day = atoi(r[i++]);
_error_rate = atof(r[i++]);
strcpy2(product_name, r[i++]);
}
int DB_HOST::update_diff_validator(HOST& h) {
@ -783,6 +788,12 @@ int DB_HOST::update_diff_sched(HOST& h) {
strcat(updates, buf);
}
#endif
if (strcmp(product_name, h.product_name)) {
escape_string(product_name, sizeof(product_name));
sprintf(buf, " product_name='%s',", product_name);
unescape_string(product_name, sizeof(product_name));
strcat(updates, buf);
}
int n = strlen(updates);
if (n == 0) return 0;

View File

@ -333,6 +333,7 @@ struct HOST {
// dynamic estimate of fraction of results
// that fail validation
// DEPRECATED
char product_name[256];
// the following not in DB
char p_features[1024];

View File

@ -185,6 +185,7 @@ create table host (
external_ip_addr varchar(254),
max_results_day integer not null,
error_rate double not null default 0,
product_name varchar(254) not null,
primary key (id)
) engine=InnoDB;

View File

@ -849,6 +849,10 @@ function update_4_26_2013() {
do_query("alter table result add size_class smallint not null default -1");
}
function update_5_23_2013() {
do_query("alter table host add product_name varchar(254) not null");
}
// Updates are done automatically if you use "upgrade".
//
// If you need to do updates manually,
@ -882,6 +886,7 @@ $db_updates = array (
array(26062, "update_8_26_2012"),
array(27000, "update_11_25_2012"),
array(27001, "update_4_26_2013"),
array(27002, "update_5_23_2013"),
);
?>

View File

@ -550,6 +550,7 @@ static int modify_host_struct(HOST& host) {
if (strlen(g_request->host.host_cpid)) {
strcpy(host.host_cpid, g_request->host.host_cpid);
}
strncpy(host.product_name, g_request->host.product_name, sizeof(host.product_name));
host.fix_nans();
return 0;

View File

@ -1206,6 +1206,7 @@ int HOST::parse(XML_PARSER& xp) {
if (xp.parse_double("p_membw", p_membw)) continue;
if (xp.parse_str("os_name", os_name, sizeof(os_name))) continue;
if (xp.parse_str("os_version", os_version, sizeof(os_version))) continue;
if (xp.parse_str("product_name", product_name, sizeof(product_name))) continue;
if (xp.parse_double("m_nbytes", m_nbytes)) continue;
if (xp.parse_double("m_cache", m_cache)) continue;
if (xp.parse_double("m_swap", m_swap)) continue;