mirror of https://github.com/BOINC/boinc.git
- API: add boinc_network_usage();
lets an application report its network usage to BOINC, and hence take it into account with monthly limits etc. - API: get rid of deprecated boinc_ops_per_cpu_sec(), boinc_ops_cumulative(), and boinc_set_credit_claim(); - admin web: update manage_apps.php; add the ability to set homogeneous app version svn path=/trunk/boinc/; revision=25700
This commit is contained in:
parent
27138f6e75
commit
13f51d42e5
|
@ -141,12 +141,10 @@ static volatile int interrupt_count = 0;
|
|||
static volatile int running_interrupt_count = 0;
|
||||
// number of timer interrupts while not suspended.
|
||||
// Used to compute elapsed time
|
||||
static double fpops_per_cpu_sec = 0;
|
||||
static double fpops_cumulative = 0;
|
||||
static double intops_per_cpu_sec = 0;
|
||||
static double intops_cumulative = 0;
|
||||
static int want_network = 0;
|
||||
static int have_network = 1;
|
||||
static double bytes_sent = 0;
|
||||
static double bytes_received = 0;
|
||||
bool g_sleep = false;
|
||||
// simulate unresponsive app by setting to true (debugging)
|
||||
static FUNC_PTR timer_callback = 0;
|
||||
|
@ -336,21 +334,13 @@ static bool update_app_progress(double cpu_t, double cp_cpu_t) {
|
|||
sprintf(buf, "<fraction_done>%e</fraction_done>\n", fdone);
|
||||
strlcat(msg_buf, buf, MSG_CHANNEL_SIZE);
|
||||
}
|
||||
if (fpops_per_cpu_sec) {
|
||||
sprintf(buf, "<fpops_per_cpu_sec>%e</fpops_per_cpu_sec>\n", fpops_per_cpu_sec);
|
||||
strlcat(msg_buf, buf, MSG_CHANNEL_SIZE);
|
||||
if (bytes_sent) {
|
||||
sprintf(buf, "<bytes_sent>%f</bytes_sent>\n", bytes_sent);
|
||||
strcat(msg_buf, buf);
|
||||
}
|
||||
if (fpops_cumulative) {
|
||||
sprintf(buf, "<fpops_cumulative>%e</fpops_cumulative>\n", fpops_cumulative);
|
||||
strlcat(msg_buf, buf, MSG_CHANNEL_SIZE);
|
||||
}
|
||||
if (intops_per_cpu_sec) {
|
||||
sprintf(buf, "<intops_per_cpu_sec>%e</intops_per_cpu_sec>\n", intops_per_cpu_sec);
|
||||
strlcat(msg_buf, buf, MSG_CHANNEL_SIZE);
|
||||
}
|
||||
if (intops_cumulative) {
|
||||
sprintf(buf, "<intops_cumulative>%e</intops_cumulative>\n", intops_cumulative);
|
||||
strlcat(msg_buf, buf, MSG_CHANNEL_SIZE);
|
||||
if (bytes_received) {
|
||||
sprintf(buf, "<bytes_received>%f</bytes_received>\n", bytes_received);
|
||||
strcat(msg_buf, buf);
|
||||
}
|
||||
return app_client_shm->shm->app_status.send_msg(msg_buf);
|
||||
}
|
||||
|
@ -684,6 +674,11 @@ void boinc_exit(int status) {
|
|||
#endif
|
||||
}
|
||||
|
||||
void boinc_network_usage(double sent, double received) {
|
||||
bytes_sent = sent;
|
||||
bytes_received = received;
|
||||
}
|
||||
|
||||
int boinc_is_standalone() {
|
||||
if (standalone) return 1;
|
||||
return 0;
|
||||
|
@ -754,8 +749,8 @@ int boinc_report_app_status_aux(
|
|||
double checkpoint_cpu_time,
|
||||
double _fraction_done,
|
||||
int other_pid,
|
||||
double bytes_sent,
|
||||
double bytes_received
|
||||
double _bytes_sent,
|
||||
double _bytes_received
|
||||
) {
|
||||
char msg_buf[MSG_CHANNEL_SIZE], buf[256];
|
||||
if (standalone) return 0;
|
||||
|
@ -772,12 +767,12 @@ int boinc_report_app_status_aux(
|
|||
sprintf(buf, "<other_pid>%d</other_pid>\n", other_pid);
|
||||
strcat(msg_buf, buf);
|
||||
}
|
||||
if (bytes_sent) {
|
||||
sprintf(buf, "<bytes_sent>%f</bytes_sent>\n", bytes_sent);
|
||||
if (_bytes_sent) {
|
||||
sprintf(buf, "<bytes_sent>%f</bytes_sent>\n", _bytes_sent);
|
||||
strcat(msg_buf, buf);
|
||||
}
|
||||
if (bytes_received) {
|
||||
sprintf(buf, "<bytes_received>%f</bytes_received>\n", bytes_received);
|
||||
if (_bytes_received) {
|
||||
sprintf(buf, "<bytes_received>%f</bytes_received>\n", _bytes_received);
|
||||
strcat(msg_buf, buf);
|
||||
}
|
||||
if (app_client_shm->shm->app_status.send_msg(msg_buf)) {
|
||||
|
@ -1433,20 +1428,6 @@ int boinc_upload_status(std::string& name) {
|
|||
return ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
void boinc_ops_per_cpu_sec(double fp, double i) {
|
||||
fpops_per_cpu_sec = fp;
|
||||
intops_per_cpu_sec = i;
|
||||
}
|
||||
|
||||
void boinc_ops_cumulative(double fp, double i) {
|
||||
fpops_cumulative = fp;
|
||||
intops_cumulative = i;
|
||||
}
|
||||
|
||||
void boinc_set_credit_claim(double credit) {
|
||||
boinc_ops_cumulative(credit*8.64000e+11, 0);
|
||||
}
|
||||
|
||||
void boinc_need_network() {
|
||||
want_network = 1;
|
||||
have_network = 0;
|
||||
|
|
|
@ -100,6 +100,7 @@ extern void boinc_end_critical_section();
|
|||
extern void boinc_need_network();
|
||||
extern int boinc_network_poll();
|
||||
extern void boinc_network_done();
|
||||
extern void boinc_network_usage(double sent, double received);
|
||||
extern int boinc_is_standalone(void);
|
||||
extern void boinc_ops_per_cpu_sec(double fp, double integer);
|
||||
extern void boinc_ops_cumulative(double fp, double integer);
|
||||
|
|
|
@ -3958,3 +3958,18 @@ Rom 18 May 2012
|
|||
AccountManagerInfoPage.cpp
|
||||
clientgui/
|
||||
ProjectListCtrl.cpp, .h
|
||||
|
||||
David 20 May 2012
|
||||
- API: add boinc_network_usage();
|
||||
lets an application report its network usage to BOINC,
|
||||
and hence take it into account with monthly limits etc.
|
||||
- API: get rid of deprecated boinc_ops_per_cpu_sec(),
|
||||
boinc_ops_cumulative(), and
|
||||
boinc_set_credit_claim();
|
||||
- admin web: update manage_apps.php;
|
||||
add the ability to set homogeneous app version
|
||||
|
||||
html/ops/
|
||||
manage_apps.php
|
||||
api/
|
||||
boinc_api.cpp,h
|
||||
|
|
|
@ -18,15 +18,13 @@
|
|||
|
||||
|
||||
|
||||
/***********************************************************************\
|
||||
* Display and Manage BOINC Application Versions
|
||||
*
|
||||
* This page presents a form with information about application versions.
|
||||
* Some of the fields can be changed.
|
||||
*
|
||||
* Eric Myers <myers@spy-hill.net> - 4 June 2006
|
||||
* @(#) $Id$
|
||||
\***********************************************************************/
|
||||
// Display and Manage BOINC Application Versions
|
||||
//
|
||||
// This page presents a form with information about application versions.
|
||||
// Some of the fields can be changed.
|
||||
//
|
||||
// Eric Myers <myers@spy-hill.net> - 4 June 2006
|
||||
// @(#) $Id$
|
||||
|
||||
// TODO - code cleanup and use new DB interface
|
||||
|
||||
|
@ -36,217 +34,190 @@ db_init();
|
|||
|
||||
$commands = "";
|
||||
|
||||
// Platform and application labels (are better than numbers)
|
||||
// process form input for changes
|
||||
//
|
||||
function do_updates() {
|
||||
$apps = BoincApp::enum("");
|
||||
|
||||
$result = mysql_query("SELECT * FROM platform");
|
||||
$Nplatform = mysql_num_rows($result);
|
||||
for($i=0;$i<$Nplatform;$i++){
|
||||
$item=mysql_fetch_object($result);
|
||||
$id=$item->id;
|
||||
$plat_off[$id]=$item->deprecated;
|
||||
$platform[$id]=$item->user_friendly_name;
|
||||
}
|
||||
mysql_free_result($result);
|
||||
foreach ($apps as $app) {
|
||||
$id = $app->id;
|
||||
|
||||
/***************************************************\
|
||||
* Action: process form input for changes
|
||||
\***************************************************/
|
||||
|
||||
if( !empty($_POST) ) {
|
||||
|
||||
/* Changing properties of existing applications */
|
||||
|
||||
$result = mysql_query("SELECT * FROM app");
|
||||
$Nrow=mysql_num_rows($result);
|
||||
|
||||
for($j=1;$j<=$Nrow;$j++){ // test/update each row in DB
|
||||
$item=mysql_fetch_object($result);
|
||||
$id=$item->id;
|
||||
|
||||
/* Change deprecated status? */
|
||||
$field="deprecated_".$id;
|
||||
$new_v= (post_str($field, true)=='on') ? 1 : 0;
|
||||
$old_v=$item->deprecated;
|
||||
if($new_v != $old_v ) {
|
||||
$cmd = "UPDATE app SET deprecated=$new_v WHERE id=$id";
|
||||
$commands .= "<P><pre>$cmd</pre>\n";
|
||||
mysql_query($cmd);
|
||||
// Change deprecated status?
|
||||
//
|
||||
$field = "deprecated_".$id;
|
||||
$new_v = (post_str($field, true)=='on') ? 1 : 0;
|
||||
$old_v = $app->deprecated;
|
||||
if ($new_v != $old_v ) {
|
||||
$app->update("deprecated=$new_v");
|
||||
}
|
||||
|
||||
/* Minimum version limit */
|
||||
$field="min_version_".$id;
|
||||
$new_v= $_POST[$field] + 0;
|
||||
$old_v=$item->min_version;
|
||||
if( $new_v != $old_v ) {
|
||||
$cmd = "UPDATE app SET min_version=$new_v WHERE id=$id";
|
||||
$commands .= "<P><pre>$cmd</pre>\n";
|
||||
mysql_query($cmd);
|
||||
$field = "weight_".$id;
|
||||
$new_v = $_POST[$field] + 0;
|
||||
$old_v = $app->weight;
|
||||
if ($new_v != $old_v ) {
|
||||
$app->update("weight=$new_v");
|
||||
}
|
||||
|
||||
|
||||
$field="weight_".$id;
|
||||
$new_v= $_POST[$field] + 0;
|
||||
$old_v=$item->weight;
|
||||
if( $new_v != $old_v ) {
|
||||
$cmd = "UPDATE app SET weight=$new_v WHERE id=$id";
|
||||
$commands .= "<P><pre>$cmd</pre>\n";
|
||||
mysql_query($cmd);
|
||||
$field = "homogeneous_redundancy_".$id;
|
||||
$new_v = $_POST[$field];
|
||||
$old_v = $app->homogeneous_redundancy;
|
||||
if ($new_v != $old_v ) {
|
||||
$app->update("homogeneous_redundancy=$new_v");
|
||||
}
|
||||
|
||||
/* Homogendous redundancy restriction (same platform for all WU's) */
|
||||
$field="homogeneous_redundancy_".$id;
|
||||
$new_v= $_POST[$field];
|
||||
$old_v=$item->homogeneous_redundancy;
|
||||
if( $new_v != $old_v ) {
|
||||
$cmd = "UPDATE app SET homogeneous_redundancy=$new_v WHERE id=$id";
|
||||
$commands .= "<P><pre>$cmd</pre>\n";
|
||||
mysql_query($cmd);
|
||||
$field = "homogeneous_app_version".$id;
|
||||
$new_v = (post_str($field, true)=='on') ? 1 : 0;
|
||||
$old_v = $app->homogeneous_app_version;
|
||||
if ($new_v != $old_v ) {
|
||||
$app->update("homogeneous_app_version=$new_v");
|
||||
}
|
||||
}
|
||||
|
||||
/* Adding a new application */
|
||||
// Adding a new application
|
||||
|
||||
if(post_str('add_app', true)) {
|
||||
$name= mysql_real_escape_string($_POST['add_name']);
|
||||
$user_friendly_name=mysql_real_escape_string($_POST['add_user_friendly_name']);
|
||||
if( empty($name) || empty($user_friendly_name) ) {
|
||||
if (post_str('add_app', true)) {
|
||||
$name = mysql_real_escape_string($_POST['add_name']);
|
||||
$user_friendly_name = mysql_real_escape_string($_POST['add_user_friendly_name']);
|
||||
if (empty($name) || empty($user_friendly_name) ) {
|
||||
$commands .= "<p><font color='red'>
|
||||
To add a new application please supply both a brief name and a
|
||||
longer 'user-friendly' name.</font></p>\n";
|
||||
}
|
||||
else {
|
||||
$now=time();
|
||||
To add a new application please supply both a brief name and a
|
||||
longer 'user-friendly' name.</font></p>
|
||||
";
|
||||
} else {
|
||||
$now = time();
|
||||
$cmd = "INSERT INTO app (name,user_friendly_name,create_time) ".
|
||||
"VALUES ('$name', '$user_friendly_name',$now)";
|
||||
$commands .= "<P><pre>$cmd</pre>\n";
|
||||
mysql_query($cmd);
|
||||
}
|
||||
}
|
||||
}//$_POST
|
||||
|
||||
|
||||
/***************************************************\
|
||||
* Display the DB contents in a form
|
||||
\***************************************************/
|
||||
|
||||
admin_page_head("Manage Applications");
|
||||
|
||||
if (strlen($commands)) {
|
||||
echo "The following updates were done: $commands
|
||||
<p>
|
||||
<b>You must stop and restart the project
|
||||
for these changes to take effect</b>.
|
||||
";
|
||||
}
|
||||
|
||||
|
||||
$self=$_SERVER['PHP_SELF'];
|
||||
echo "<form action='$self' method='POST'>\n";
|
||||
function show_form($updated) {
|
||||
admin_page_head("Manage Applications");
|
||||
|
||||
|
||||
start_table();
|
||||
echo "<TR><TH>ID #</TH>
|
||||
<TH>Name and description<br><span class=note>Click for details</span></TH>
|
||||
<TH>Created</TH>
|
||||
<TH>minimum app version for HR</th>
|
||||
<TH>weight</TH>
|
||||
<TH>homogeneous redundancy type (0=none)</TH>
|
||||
<TH>deprecated?</TH>
|
||||
</TR>\n";
|
||||
|
||||
$total_weight = mysql_query('SELECT SUM(weight) AS total_weight FROM app WHERE deprecated=0');
|
||||
$total_weight = mysql_fetch_assoc($total_weight);
|
||||
$total_weight = $total_weight['total_weight'];
|
||||
|
||||
$q="SELECT * FROM app ORDER BY id";
|
||||
$result = mysql_query($q);
|
||||
$Nrow=mysql_num_rows($result);
|
||||
for ($j=1; $j<=$Nrow; $j++){
|
||||
$item = mysql_fetch_object($result);
|
||||
$id = $item->id;
|
||||
|
||||
// grey-out deprecated versions
|
||||
$f1=$f2='';
|
||||
if($item->deprecated==1) {
|
||||
$f1="<font color='GREY'>";
|
||||
$f2="</font>";
|
||||
if ($updated) {
|
||||
echo "Updates were done.
|
||||
<p>
|
||||
<b>You must stop and restart the project
|
||||
for these changes to take effect</b>.
|
||||
";
|
||||
}
|
||||
echo "<tr> ";
|
||||
echo " <TD align='center'>$f1 $id $f2</TD>\n";
|
||||
|
||||
$name=$item->name;
|
||||
$full_name=$item->user_friendly_name;
|
||||
echo " <TD align='left'>$f1<a href=app_details.php?appid=$id>$name</a><br> $full_name $f2</TD>\n";
|
||||
|
||||
$time=$item->create_time;
|
||||
echo " <TD align='center'>$f1 " .date_str($time)."$f2</TD>\n";
|
||||
|
||||
$field="min_version_".$id;
|
||||
$v=$item->min_version;
|
||||
echo " <TD align='center'>
|
||||
<input type='text' size='4' name='$field' value='$v'></TD>\n";
|
||||
|
||||
$field="weight_".$id;
|
||||
$v=$item->weight;
|
||||
echo " <TD align='center'>
|
||||
<input type='text' size='4' name='$field' value='$v'></TD>\n";
|
||||
|
||||
$field="homogeneous_redundancy_".$id;
|
||||
$v = $item->homogeneous_redundancy;
|
||||
echo " <TD align='center'>
|
||||
<input name='$field' value='$v'></TD>
|
||||
$self=$_SERVER['PHP_SELF'];
|
||||
echo "
|
||||
<h2>Edit applications</h2>
|
||||
<form action='$self' method='POST'>
|
||||
";
|
||||
|
||||
$field="deprecated_".$id;
|
||||
$v='';
|
||||
if($item->deprecated) $v=' CHECKED ';
|
||||
echo " <TD align='center'>
|
||||
<input name='$field' type='checkbox' $v></TD>\n";
|
||||
start_table();
|
||||
table_header(
|
||||
"ID",
|
||||
"Name and description<br><span class=note>Click for details</span>",
|
||||
"Created",
|
||||
"weight<br><a href=http://boinc.berkeley.edu/trac/wiki/BackendPrograms#feeder>details</a>",
|
||||
"homogeneous redundancy type<br><a href=http://boinc.berkeley.edu/trac/wiki/HomogeneousRedundancy>details</a>",
|
||||
"homogeneous app version?<br><a href=http://boinc.berkeley.edu/trac/wiki/HomogeneousAppVersion>details</a>",
|
||||
"deprecated?"
|
||||
);
|
||||
|
||||
echo "</tr> ";
|
||||
}
|
||||
mysql_free_result($result);
|
||||
$total_weight = mysql_query('SELECT SUM(weight) AS total_weight FROM app WHERE deprecated=0');
|
||||
$total_weight = mysql_fetch_assoc($total_weight);
|
||||
$total_weight = $total_weight['total_weight'];
|
||||
|
||||
echo "<tr><td colspan=6></td>
|
||||
<td align='center' colspan=2>
|
||||
<input type='submit' name='update' value='Update'></td>
|
||||
</tr>\n";
|
||||
$q="SELECT * FROM app ORDER BY id";
|
||||
$result = mysql_query($q);
|
||||
$Nrow=mysql_num_rows($result);
|
||||
for ($j=1; $j<=$Nrow; $j++){
|
||||
$item = mysql_fetch_object($result);
|
||||
$id = $item->id;
|
||||
|
||||
end_table();
|
||||
// grey-out deprecated versions
|
||||
$f1=$f2='';
|
||||
if($item->deprecated==1) {
|
||||
$f1 = "<font color='GREY'>";
|
||||
$f2 = "</font>";
|
||||
}
|
||||
echo "<tr> ";
|
||||
echo " <TD align='center'>$f1 $id $f2</TD>\n";
|
||||
|
||||
$name = $item->name;
|
||||
$full_name = $item->user_friendly_name;
|
||||
echo " <TD align='left'>$f1<a href=app_details.php?appid=$id>$name</a><br> $full_name $f2</TD>\n";
|
||||
|
||||
$time = $item->create_time;
|
||||
echo " <TD align='center'>$f1 " .date_str($time)."$f2</TD>\n";
|
||||
|
||||
$field = "weight_".$id;
|
||||
$v = $item->weight;
|
||||
echo " <TD align='center'>
|
||||
<input type='text' size='4' name='$field' value='$v'></TD>\n";
|
||||
|
||||
$field = "homogeneous_redundancy_".$id;
|
||||
$v = $item->homogeneous_redundancy;
|
||||
echo " <TD align='center'>
|
||||
<input name='$field' value='$v'></TD>
|
||||
";
|
||||
|
||||
$field = "homogeneous_app_version_".$id;
|
||||
$v = '';
|
||||
if ($item->homogeneous_app_version) $v=' CHECKED ';
|
||||
echo " <TD align='center'>
|
||||
<input name='$field' type='checkbox' $v></TD>
|
||||
";
|
||||
|
||||
$field = "deprecated_".$id;
|
||||
$v = '';
|
||||
if ($item->deprecated) $v = ' CHECKED ';
|
||||
echo " <TD align='center'>
|
||||
<input name='$field' type='checkbox' $v></TD>
|
||||
";
|
||||
|
||||
echo "</tr> ";
|
||||
}
|
||||
mysql_free_result($result);
|
||||
echo "<tr><td colspan=6></td><td><input type='submit' name='update' value='Update'></td></tr>";
|
||||
|
||||
end_table();
|
||||
|
||||
|
||||
/**
|
||||
* Entry form to create a new application
|
||||
*/
|
||||
// Entry form to create a new application
|
||||
//
|
||||
|
||||
echo"<P>
|
||||
<h2>Add an Application</h2>
|
||||
To add an application to the project enter the short name and description
|
||||
('user friendly name') below. You can then control the version limits and
|
||||
turn on homogeneous redundancy (if desired) when the application appears
|
||||
in the table above.
|
||||
</p>\n";
|
||||
echo"<P>
|
||||
<h2>Add an application</h2>
|
||||
To add an application enter the short name and description
|
||||
('user friendly name') below. You can then edit the
|
||||
application when it appears in the table above.
|
||||
</p>\n";
|
||||
|
||||
start_table("align='center' ");
|
||||
start_table("align='center' ");
|
||||
|
||||
echo "<TR><TH>Name</TH>
|
||||
<TH>Description</TH>
|
||||
<TH> </TH>
|
||||
</TR>\n";
|
||||
echo "<TR><TH>Name</TH>
|
||||
<TH>Description</TH>
|
||||
<TH> </TH>
|
||||
</TR>\n";
|
||||
|
||||
|
||||
echo "<TR>
|
||||
<TD> <input type='text' size='12' name='add_name' value=''></TD>
|
||||
<TD> <input type='text' size='35' name='add_user_friendly_name' value=''></TD>
|
||||
<TD align='center' >
|
||||
<input type='submit' name='add_app' value='Add Application'></TD>
|
||||
</TR>\n";
|
||||
echo "<TR>
|
||||
<TD> <input type='text' size='12' name='add_name' value=''></TD>
|
||||
<TD> <input type='text' size='35' name='add_user_friendly_name' value=''></TD>
|
||||
<TD align='center' >
|
||||
<input type='submit' name='add_app' value='Add Application'></TD>
|
||||
</TR>\n";
|
||||
|
||||
end_table();
|
||||
end_table();
|
||||
echo "</form><p>\n";
|
||||
admin_page_tail();
|
||||
}
|
||||
|
||||
echo "</form><p>\n";
|
||||
|
||||
admin_page_tail();
|
||||
if( !empty($_POST) ) {
|
||||
do_updates();
|
||||
show_form(true);
|
||||
} else {
|
||||
show_form(false);
|
||||
}
|
||||
|
||||
//Generated automatically - do not edit
|
||||
$cvs_version_tracker[]="\$Id$";
|
||||
|
|
Loading…
Reference in New Issue