]> git.sur5r.net Git - openldap/commitdiff
Add task names to runqueue entries. Display running tasks under
authorHoward Chu <hyc@openldap.org>
Sat, 23 Apr 2005 00:28:43 +0000 (00:28 +0000)
committerHoward Chu <hyc@openldap.org>
Sat, 23 Apr 2005 00:28:43 +0000 (00:28 +0000)
cn=Runqueue,cn=Threads,cn=Monitor

servers/slapd/back-bdb/config.c
servers/slapd/back-ldbm/init.c
servers/slapd/back-monitor/thread.c
servers/slapd/overlays/pcache.c
servers/slapd/syncrepl.c

index e1c9e23f27b0972d622118683fc68f2a007f3d75..fcee27c978c579aecb46973cce10a8df5ab02921 100644 (file)
@@ -470,7 +470,8 @@ bdb_cf_gen(ConfigArgs *c)
                                re->interval.tv_sec = bdb->bi_txn_cp_min * 60;
                        else
                                bdb->bi_txn_cp_task = ldap_pvt_runqueue_insert( &slapd_rq,
-                                       bdb->bi_txn_cp_min * 60, bdb_checkpoint, bdb );
+                                       bdb->bi_txn_cp_min * 60, bdb_checkpoint, bdb,
+                                       "bdb_checkpoint", c->be->be_suffix[0].bv_val );
                }
                break;
 
@@ -548,7 +549,8 @@ bdb_cf_gen(ConfigArgs *c)
                if ( bdb->bi_flags & BDB_IS_OPEN ) {
                        /* Start the task as soon as we finish here */
                        ldap_pvt_runqueue_insert( &slapd_rq, 60,
-                               bdb_online_index, c->be );
+                               bdb_online_index, c->be,
+                               "bdb_online_index", c->be->be_suffix[0].bv_val );
                }
                break;
 
index feb88ddc70fca9126f5eb9317cc112ac63ba549e..b8a6831ce5d4609d521d475ee66cc5fd59e4893f 100644 (file)
@@ -205,7 +205,8 @@ ldbm_back_db_open(
        {
                ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
                ldap_pvt_runqueue_insert( &slapd_rq, li->li_dbsyncfreq,
-                       ldbm_cache_sync_daemon, be );
+                       ldbm_cache_sync_daemon, be,
+                       "ldbm_cache_sync", be->be_suffix[0].bv_val );
                ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
        }
 
index 83ba5ce522c99f8ee54c50ed3c7ebad6f29e6709..99c36b760e1a4e5460718dcd22b0fb0ae7c0b499 100644 (file)
@@ -27,6 +27,8 @@
 #include "slap.h"
 #include "back-monitor.h"
 
+#include <ldap_rq.h>
+
 /*
 *  * initializes log subentry
 *   */
@@ -158,6 +160,57 @@ monitor_subsys_thread_init(
        *ep = e;
        ep = &mp->mp_next;
 
+       /*
+        * Runqueue runners
+        */
+       snprintf( buf, sizeof( buf ),
+                       "dn: cn=Runqueue,%s\n"
+                       "objectClass: %s\n"
+                       "structuralObjectClass: %s\n"
+                       "cn: Runqueue\n"
+                       "%s: 0\n"
+                       "creatorsName: %s\n"
+                       "modifiersName: %s\n"
+                       "createTimestamp: %s\n"
+                       "modifyTimestamp: %s\n",
+                       ms->mss_dn.bv_val,
+                       mi->mi_oc_monitoredObject->soc_cname.bv_val,
+                       mi->mi_oc_monitoredObject->soc_cname.bv_val,
+                       mi->mi_ad_monitoredInfo->ad_cname.bv_val,
+                       mi->mi_creatorsName.bv_val,
+                       mi->mi_creatorsName.bv_val,
+                       mi->mi_startTime.bv_val,
+                       mi->mi_startTime.bv_val );
+
+       e = str2entry( buf );
+       if ( e == NULL ) {
+               Debug( LDAP_DEBUG_ANY,
+                       "monitor_subsys_thread_init: "
+                       "unable to create entry \"cn=Runqueue,%s\"\n",
+                       ms->mss_ndn.bv_val, 0, 0 );
+               return( -1 );
+       }
+
+       mp = monitor_entrypriv_create();
+       if ( mp == NULL ) {
+               return -1;
+       }
+       e->e_private = ( void * )mp;
+       mp->mp_info = ms;
+       mp->mp_flags = ms->mss_flags \
+               | MONITOR_F_SUB | MONITOR_F_PERSISTENT;
+
+       if ( monitor_cache_add( mi, e ) ) {
+               Debug( LDAP_DEBUG_ANY,
+                       "monitor_subsys_thread_init: "
+                       "unable to add entry \"cn=Runqueue,%s\"\n",
+                       ms->mss_ndn.bv_val, 0, 0 );
+               return( -1 );
+       }
+       
+       *ep = e;
+       ep = &mp->mp_next;
+
        monitor_cache_release( mi, e_thread );
 
        return( 0 );
@@ -173,29 +226,49 @@ monitor_subsys_thread_update(
        Attribute               *a;
        char                    buf[ BACKMONITOR_BUFSIZE ];
        static struct berval    backload_bv = BER_BVC( "cn=backload" );
-       struct berval           rdn;
+       static struct berval    runqueue_bv = BER_BVC( "cn=runqueue" );
+       struct berval           rdn, bv;
        ber_len_t               len;
+       int which = 0;
+       struct re_s *re;
 
        assert( mi != NULL );
 
        dnRdn( &e->e_nname, &rdn );
-       if ( !dn_match( &rdn, &backload_bv ) ) {
+       if ( dn_match( &rdn, &backload_bv ))
+               which = 1;
+       else if ( dn_match( &rdn, &runqueue_bv ))
+               which = 2;
+       else
                return 0;
-       }
-
-       a = attr_find( e->e_attrs, mi->mi_ad_monitoredInfo );
-       if ( a == NULL ) {
-               return -1;
-       }
 
-       snprintf( buf, sizeof( buf ), "%d", 
+       switch( which ) {
+       case 1:
+               a = attr_find( e->e_attrs, mi->mi_ad_monitoredInfo );
+               if ( a == NULL ) {
+                       return -1;
+               }
+               snprintf( buf, sizeof( buf ), "%d", 
                        ldap_pvt_thread_pool_backload( &connection_pool ) );
-       len = strlen( buf );
-       if ( len > a->a_vals[ 0 ].bv_len ) {
-               a->a_vals[ 0 ].bv_val = ber_memrealloc( a->a_vals[ 0 ].bv_val, len + 1 );
+               len = strlen( buf );
+               if ( len > a->a_vals[ 0 ].bv_len ) {
+                       a->a_vals[ 0 ].bv_val = ber_memrealloc( a->a_vals[ 0 ].bv_val, len + 1 );
+               }
+               a->a_vals[ 0 ].bv_len = len;
+               AC_MEMCPY( a->a_vals[ 0 ].bv_val, buf, len + 1 );
+               break;
+       case 2:
+               attr_delete( &e->e_attrs, mi->mi_ad_monitoredInfo );
+               bv.bv_val = buf;
+               ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
+               LDAP_STAILQ_FOREACH( re, &slapd_rq.run_list, rnext ) {
+                       bv.bv_len = snprintf( buf, sizeof( buf ), "%s(%s)",
+                               re->tname, re->tspec );
+                       attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo, &bv, NULL );
+               }
+               ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
+               break;
        }
-       a->a_vals[ 0 ].bv_len = len;
-       AC_MEMCPY( a->a_vals[ 0 ].bv_val, buf, len + 1 );
 
        /* FIXME: touch modifyTimestamp? */
 
index 88268f141e02002b0da37f9d313015270e11ed88..8b9a479632e81a5037f90c367003648a312fdca8 100644 (file)
@@ -1741,7 +1741,8 @@ proxy_cache_open(
        if ( slapMode & SLAP_SERVER_MODE ) {
                ldap_pvt_thread_mutex_lock( &slapd_rq.rq_mutex );
                ldap_pvt_runqueue_insert( &slapd_rq, cm->cc_period,
-                       consistency_check, on );
+                       consistency_check, on,
+                       "pcache_consistency", be->be_suffix[0].bv_val );
                ldap_pvt_thread_mutex_unlock( &slapd_rq.rq_mutex );
 
                /* Cached database must have the rootdn */
index a5a5a3cad1401b20772aa971817da2064fecf4aa..006cfd1bc002c55b0740581a97f6f7b84e45e3e6 100644 (file)
@@ -2628,7 +2628,7 @@ add_syncrepl(
                si->si_be = be;
                init_syncrepl( si );
                si->si_re = ldap_pvt_runqueue_insert( &slapd_rq, si->si_interval,
-                       do_syncrepl, si );
+                       do_syncrepl, si, "do_syncrepl", be->be_suffix[0].bv_val );
                if ( !si->si_re )
                        rc = -1;
        }