Example #1
0
void BannerSubSubType(char *bundlename, char *type)
{
    if (strcmp(type, "processes") == 0)
    {

        /* Just parsed all local classes */

        CfOut(cf_verbose, "", "     ??? Local class context: \n");

        AlphaListIterator it = AlphaListIteratorInit(&VADDCLASSES);

        for (const Item *ip = AlphaListIteratorNext(&it); ip != NULL; ip = AlphaListIteratorNext(&it))
        {
            printf("       %s\n", ip->name);
        }

        CfOut(cf_verbose, "", "\n");
    }

    CfOut(cf_verbose, "", "\n");
    CfOut(cf_verbose, "", "      = = = = = = = = = = = = = = = = = = = = = = = = = = = = \n");
    CfOut(cf_verbose, "", "      %s in bundle %s\n", type, bundlename);
    CfOut(cf_verbose, "", "      = = = = = = = = = = = = = = = = = = = = = = = = = = = = \n");
    CfOut(cf_verbose, "", "\n");
}
Example #2
0
static void ClassBanner(enum typesequence type)
{
    const Item *ip;

    if (type != kp_interfaces)  /* Just parsed all local classes */
    {
        return;
    }

    CfOut(cf_verbose, "", "\n");
    CfOut(cf_verbose, "", "     +  Private classes augmented:\n");

    AlphaListIterator it = AlphaListIteratorInit(&VADDCLASSES);

    for (ip = AlphaListIteratorNext(&it); ip != NULL; ip = AlphaListIteratorNext(&it))
    {
        CfOut(cf_verbose, "", "     +       %s\n", ip->name);
    }

    CfOut(cf_verbose, "", "\n");

    CfOut(cf_verbose, "", "     -  Private classes diminished:\n");

    for (ip = VNEGHEAP; ip != NULL; ip = ip->next)
    {
        CfOut(cf_verbose, "", "     -       %s\n", ip->name);
    }

    CfOut(cf_verbose, "", "\n");

    CfDebug("     ?  Public class context:\n");

    it = AlphaListIteratorInit(&VHEAP);
    for (ip = AlphaListIteratorNext(&it); ip != NULL; ip = AlphaListIteratorNext(&it))
    {
        CfDebug("     ?       %s\n", ip->name);
    }

    CfOut(cf_verbose, "", "\n");
}
Example #3
0
static void ClassBanner(TypeSequence type)
{
    const Item *ip;

    if (type != TYPE_SEQUENCE_INTERFACES)  /* Just parsed all local classes */
    {
        return;
    }

    CfOut(OUTPUT_LEVEL_VERBOSE, "", "\n");
    CfOut(OUTPUT_LEVEL_VERBOSE, "", "     +  Private classes augmented:\n");

    AlphaListIterator it = AlphaListIteratorInit(&VADDCLASSES);

    for (ip = AlphaListIteratorNext(&it); ip != NULL; ip = AlphaListIteratorNext(&it))
    {
        CfOut(OUTPUT_LEVEL_VERBOSE, "", "     +       %s\n", ip->name);
    }

    CfOut(OUTPUT_LEVEL_VERBOSE, "", "\n");

    CfOut(OUTPUT_LEVEL_VERBOSE, "", "     -  Private classes diminished:\n");

    for (ip = VNEGHEAP; ip != NULL; ip = ip->next)
    {
        CfOut(OUTPUT_LEVEL_VERBOSE, "", "     -       %s\n", ip->name);
    }

    CfOut(OUTPUT_LEVEL_VERBOSE, "", "\n");

    CfDebug("     ?  Public class context:\n");

    it = AlphaListIteratorInit(&VHEAP);
    for (ip = AlphaListIteratorNext(&it); ip != NULL; ip = AlphaListIteratorNext(&it))
    {
        CfDebug("     ?       %s\n", ip->name);
    }

    CfOut(OUTPUT_LEVEL_VERBOSE, "", "\n");
}
Example #4
0
void NoteClassUsage(AlphaList baselist, int purge)
{
    CF_DB *dbp;
    CF_DBC *dbcp;
    void *stored;
    char *key;
    int ksize, vsize;
    Event e, entry, newe;
    double lsea = SECONDS_PER_WEEK * 52;        /* expire after (about) a year */
    time_t now = time(NULL);
    Item *list = NULL;
    const Item *ip;
    double lastseen;
    double vtrue = 1.0;         /* end with a rough probability */

/* Only do this for the default policy, too much "downgrading" otherwise */

    if (MINUSF)
    {
        return;
    }

    AlphaListIterator it = AlphaListIteratorInit(&baselist);

    for (ip = AlphaListIteratorNext(&it); ip != NULL; ip = AlphaListIteratorNext(&it))
    {
        if ((IGNORECLASS(ip->name)))
        {
            CfDebug("Ignoring class %s (not packing)", ip->name);
            continue;
        }

        IdempPrependItem(&list, ip->name, NULL);
    }

    if (!OpenDB(&dbp, dbid_classes))
    {
        return;
    }

/* First record the classes that are in use */

    for (ip = list; ip != NULL; ip = ip->next)
    {
        if (ReadDB(dbp, ip->name, &e, sizeof(e)))
        {
            CfDebug("FOUND %s with %lf\n", ip->name, e.Q.expect);
            lastseen = now - e.t;
            newe.t = now;

            newe.Q = QAverage(e.Q, vtrue, 0.7);
        }
        else
        {
            lastseen = 0.0;
            newe.t = now;
            /* With no data it's 50/50 what we can say */
            newe.Q = QDefinite(0.5 * vtrue);
        }

        if (lastseen > lsea)
        {
            CfDebug("Class usage record %s expired\n", ip->name);
            DeleteDB(dbp, ip->name);
        }
        else
        {
            WriteDB(dbp, ip->name, &newe, sizeof(newe));
        }
    }

/* Then update with zero the ones we know about that are not active */

    if (purge)
    {
/* Acquire a cursor for the database and downgrade classes that did not
 get defined this time*/

        if (!NewDBCursor(dbp, &dbcp))
        {
            CfOut(cf_inform, "", " !! Unable to scan class db");
            CloseDB(dbp);
            DeleteItemList(list);
            return;
        }

        memset(&entry, 0, sizeof(entry));

        while (NextDB(dbp, dbcp, &key, &ksize, &stored, &vsize))
        {
            time_t then;
            char eventname[CF_BUFSIZE];

            memset(eventname, 0, CF_BUFSIZE);
            strncpy(eventname, (char *) key, ksize);

            if (stored != NULL)
            {
                memcpy(&entry, stored, sizeof(entry));

                then = entry.t;
                lastseen = now - then;

                if (lastseen > lsea)
                {
                    CfDebug("Class usage record %s expired\n", eventname);
                    DBCursorDeleteEntry(dbcp);
                }
                else if (!IsItemIn(list, eventname))
                {
                    newe.t = then;

                    newe.Q = QAverage(entry.Q, 0, 0.5);

                    if (newe.Q.expect <= 0.0001)
                    {
                        CfDebug("Deleting class %s as %lf is zero\n", eventname, newe.Q.expect);
                        DBCursorDeleteEntry(dbcp);
                    }
                    else
                    {
                        CfDebug("Downgrading class %s from %lf to %lf\n", eventname, entry.Q.expect, newe.Q.expect);
                        DBCursorWriteEntry(dbcp, &newe, sizeof(newe));
                    }
                }
            }
        }

        DeleteDBCursor(dbp, dbcp);
    }

    CloseDB(dbp);
    DeleteItemList(list);
}