Exemple #1
0
d_storeResult
d_groupInfoDeleteHistoricalData(
    d_groupInfo _this,
    const d_store store,
    const v_groupAction action)
{
    c_bool success;
    d_storeResult result;

    assert(_this);
    assert(action);

    if(_this && action){
        success = c_tableWalk(_this->instances, removeHistoricalData, action);

        if(success){
            result = D_STORE_RESULT_OK;
        } else {
            result = D_STORE_RESULT_ERROR;
        }
    } else {
        result = D_STORE_RESULT_ILL_PARAM;
    }
    return result;
}
Exemple #2
0
c_bool
v_indexWalk(
    v_index _this,
    c_action action,
    c_voidp arg)
{
    v_reader reader;
    c_bool result;
    assert(C_TYPECHECK(_this,v_index));

    reader = v_reader(_this->reader);
    if (reader->qos->userKey.v.enable) {
        result = c_tableWalk(_this->notEmptyList, action, arg);
    } else {
        result = c_tableWalk(_this->objects, action, arg);
    }
    return result;
}
c_bool
v_partitionAdminFitsInterest(
    v_partitionAdmin da,
    v_partition d)
{
    c_bool result;

    c_mutexLock(&da->mutex);
    result = !c_tableWalk(da->partitionInterests, checkPartitionInterest, d);
    c_mutexUnlock(&da->mutex);

    return result;
}
void
v_rnrStorageStatisticsReset(
    v_rnrStorageStatistics _this,
    c_string fieldName)
{
    assert(_this);
    assert(C_TYPECHECK(_this, v_rnrStorageStatistics));

    if (fieldName) {
        /* TODO Reset individual group statistic ('part.topic' matching 'fieldName') */
        /*  v_statisticsResetField(v_statistics(_this), fieldName); */
    } else {
        /* Reset all group statistics */
        /* Todo use fieldname to reset a specific statistic? */
        c_tableWalk(_this->topics, resetGroupStatistic, NULL);
    }
}
Exemple #5
0
c_bool
v_entryGroupExists(
    v_entry entry,
    v_group group)
{
    c_bool r;
    struct groupExistsArg arg;

    assert(entry != NULL);
    assert(C_TYPECHECK(entry,v_entry));
    assert(group != NULL);
    assert(C_TYPECHECK(group,v_group));

    arg.exists = FALSE;
    arg.proxy = v_proxyNew(v_objectKernel(group),
                       v_publicHandle(v_public(group)), NULL);
    r = c_tableWalk(entry->groups, groupExists, &arg);
    c_free(arg.proxy);
    return arg.exists;
}
Exemple #6
0
d_storeResult
d_groupInfoDataInject(
    d_groupInfo _this,
    const d_store store,
    d_group group)
{
    d_storeResult result;
    struct d_instanceInjectArg inject;
    c_type mmfMessageType;
    c_char* typeName;

    if(_this && group){
        inject.vgroup = d_groupGetKernelGroup(group);

        mmfMessageType = d_topicInfoGetMessageType(_this->topic);
        typeName = c_metaScopedName(c_metaObject(mmfMessageType));

        inject.messageType = c_type(c_metaResolveType(
                c_metaObject(c_getBase(inject.vgroup)), typeName));

        if(inject.messageType){
            inject.result = D_STORE_RESULT_OK;

            c_tableWalk(_this->instances, d_instanceInject, &inject);

            c_free(inject.messageType);
            result = inject.result;
        } else {
            result = D_STORE_RESULT_PRECONDITION_NOT_MET;
        }
        c_free(inject.vgroup);
        c_free(mmfMessageType);
        os_free(typeName);
    } else {
        result = D_STORE_RESULT_ILL_PARAM;
    }
    return result;
}
c_bool
v_partitionAdminSet(
    v_partitionAdmin da,
    v_partitionPolicy partitionExpr,
    c_iter *addedPartitions,
    c_iter *removedPartitions)
{
    c_iter                   dexpressions;    /* iterator of partition expressions */
    c_char                   *dexpr;          /* partition expression */
    v_partitionInterest         di;
    struct resolvePartitionsArg resolveArg;
    struct updatePartitionsArg  updateArg;

    assert(C_TYPECHECK(da, v_partitionAdmin));
    assert(removedPartitions != NULL);
    assert(addedPartitions != NULL);

    *removedPartitions = NULL;
    *addedPartitions = NULL;

    resolveArg.kernel = v_objectKernel(da);

    c_mutexLock(&da->mutex);
    /*
     * The absolute partition names will be added at the end of
     * the algorithm.
     * The partition expressions in the parameter of partitionExpr,
     * replace the existing in da->partitionInterests.
     */
    c_free(da->partitionInterests);
    da->partitionInterests = c_tableNew(v_kernelType(resolveArg.kernel, K_DOMAININTEREST),
                                        "expression");
    assert(c_count(da->partitionInterests) == 0);
    dexpressions = v_partitionPolicySplit(partitionExpr);
    if (dexpressions == NULL) {
        /* switch to default */
        *addedPartitions = c_iterInsert(*addedPartitions, v_partitionNew(resolveArg.kernel, "", NULL));
    } else {
        dexpr = (c_char *)c_iterTakeFirst(dexpressions);
        while (dexpr != NULL) {
            if (v_partitionExpressionIsAbsolute(dexpr)) {
                *addedPartitions = c_iterInsert(*addedPartitions,
                                                v_partitionNew(resolveArg.kernel, dexpr, NULL));
                /* ref transferred to addedPartitions */
            } else {
                di = v_partitionInterestNew(resolveArg.kernel, (const c_char *)dexpr);
                c_tableInsert(da->partitionInterests, di);
                c_free(di);
            }
            os_free(dexpr);
            dexpr = (c_char *)c_iterTakeFirst(dexpressions);
        }
        c_iterFree(dexpressions);
    }

    /*
     * The given expressions are now divided across
     * 'addedpartitions' and 'da->partitionInterests'.
     * Now first add partitions to 'addedpartitions' that fit the
     * expressions in 'da->partitionInterests'.
     */
    resolveArg.partitions = addedPartitions;
    c_tableWalk(da->partitionInterests, resolvePartitions, (c_voidp)&resolveArg);

    /*
     * Now 'addedpartitions' contains all partitions to be added
     * by the publisher/subscriber.
     * 'da->partitions' contains the old set of partitions.
     * We must check whether those partitions must remain in
     * the set or must be removed.
     * For every partition in 'da->partitions' do
     *    if partition in 'addedpartitions' then remove from 'addedpartitions'
     *    else add to 'removedpartitions'
     * For every partition in 'removedpartitions' remove from 'da->partitions'.
     */
    updateArg.addPartitions = addedPartitions;
    updateArg.removePartitions = removedPartitions;
    c_tableWalk(da->partitions, updatePartitions, (c_voidp)&updateArg);

    c_iterWalk(*removedPartitions, removePartition, (c_voidp)da->partitions);

    /*
     * The da->partitions now contains partitions that still comply to new
     * partitionPolicy. So all partitions in added partitions, must be added
     * to da->partitions, so it reflects all connected partitions.
     */
    c_iterWalk(*addedPartitions, addPartition, (c_voidp)da->partitions);
    c_mutexUnlock(&da->mutex);

    return TRUE;
}