]> git.sur5r.net Git - bacula/bacula/commitdiff
Add Maximum Bandwidth parameter to File Daemon
authorEric Bollengier <eric@eb.homelinux.org>
Wed, 24 Nov 2010 20:45:46 +0000 (21:45 +0100)
committerEric Bollengier <eric@eb.homelinux.org>
Thu, 25 Nov 2010 14:21:58 +0000 (15:21 +0100)
bacula/src/filed/filed_conf.c
bacula/src/filed/filed_conf.h
bacula/src/filed/job.c

index 04dc2398179300fd59f9aa9722599d78a96d4282..4986f147334f44514b4397f3fba1fa64145ba8df 100644 (file)
@@ -118,6 +118,7 @@ static RES_ITEM cli_items[] = {
    {"tlscertificate",        store_dir,       ITEM(res_client.tls_certfile), 0, 0, 0},
    {"tlskey",                store_dir,       ITEM(res_client.tls_keyfile), 0, 0, 0},
    {"verid",                 store_str,       ITEM(res_client.verid), 0, 0, 0},
+   {"maximumbandwidth",      store_speed,     ITEM(res_client.max_bandwidth), 0, 0, 0},
    {NULL, NULL, {0}, 0, 0, 0}
 };
 
@@ -138,6 +139,7 @@ static RES_ITEM dir_items[] = {
    {"tlskey",               store_dir,       ITEM(res_dir.tls_keyfile), 0, 0, 0},
    {"tlsdhfile",            store_dir,       ITEM(res_dir.tls_dhfile), 0, 0, 0},
    {"tlsallowedcn",         store_alist_str, ITEM(res_dir.tls_allowed_cns), 0, 0, 0},
+   {"maximumbandwidth",     store_speed,     ITEM(res_dir.max_bandwidth), 0, 0, 0},
    {NULL, NULL, {0}, 0, 0, 0}
 };
 
index 2ad4593d6a5bfedb6f2622e2918655963fdfc9af..2200691f9bbc54d0865547b0509bf19ba2b04c8b 100644 (file)
@@ -69,7 +69,7 @@ struct DIRRES {
    char *tls_keyfile;                 /* TLS Server Key File */
    char *tls_dhfile;                  /* TLS Diffie-Hellman Parameters */
    alist *tls_allowed_cns;            /* TLS Allowed Clients */
-
+   uint64_t max_bandwidth;            /* Bandwidth limitation (per director) */
    TLS_CONTEXT *tls_ctx;              /* Shared TLS Context */
 };
 
@@ -105,6 +105,7 @@ struct CLIENT {
    alist *pki_recipients;             /* Shared PKI Recipients */
    TLS_CONTEXT *tls_ctx;              /* Shared TLS Context */
    char *verid;                       /* Custom Id to print in version command */
+   uint64_t max_bandwidth;            /* Bandwidth limitation (global) */
 };
 
 
index 7e9dfdb5a79561cd1ae6030606280a72cb12dec4..6453b81a922678f99fde883741b3f59b641f1a81 100644 (file)
@@ -1694,6 +1694,15 @@ static int storage_cmd(JCR *jcr)
    /* Try to connect for 1 hour at 10 second intervals */
 
    sd->set_source_address(me->FDsrc_addr);
+
+   /* TODO: see if we put limit on restore and backup... */
+   if (jcr->director->max_bandwidth) {
+      sd->set_bwlimit(jcr->director->max_bandwidth);
+
+   } else if (me->max_bandwidth) {
+      sd->set_bwlimit(me->max_bandwidth);
+   }
+
    if (!sd->connect(jcr, 10, (int)me->SDConnectTimeout, me->heartbeat_interval,
                 _("Storage daemon"), jcr->stored_addr, NULL, stored_port, 1)) {
      sd->destroy();