Beispiel #1
0
d_storeResult
d_storeMMFKernelIsNameSpaceComplete(
    d_storeMMFKernel kernel,
    const d_nameSpace nameSpace,
    c_bool* isComplete)
{
    d_nameSpaceInfo nsInfo;
    c_char* name;
    d_storeResult result;
    c_value keyValues[1];

    if(kernel && nameSpace){
        name = d_nameSpaceGetName(nameSpace);
        keyValues[0] = c_stringValue((c_string)name);
        nsInfo = c_tableFind(kernel->nameSpaces, keyValues);

        if(nsInfo){
            *isComplete = nsInfo->complete;
            result = D_STORE_RESULT_OK;
        } else {
            *isComplete = FALSE;
            result = D_STORE_RESULT_OK;
        }
    } else {
        result = D_STORE_RESULT_ILL_PARAM;
    }
    return result;
}
Beispiel #2
0
static d_topicInfo
d_storeMMFKernelGetTopicInfo(
    d_storeMMFKernel _this,
    const char* topic)
{
    d_topicInfo result;
    c_value keyValue;

    keyValue = c_stringValue((c_string)topic);
    result = c_tableFind(_this->topics, &keyValue); /* c_tableFind already performs keep. */

    return result;
}
Beispiel #3
0
static d_topicInfo
d_storeMMFKernelGetTopicInfo(
    d_storeMMFKernel _this,
    const char* topic)
{
    d_topicInfo result;
    c_value keyValue;

    keyValue = c_stringValue((c_string)topic);
    result = c_tableFind(_this->topics, &keyValue);

    return c_keep(result);
}
Beispiel #4
0
d_groupInfo
d_storeMMFKernelGetGroupInfo(
    d_storeMMFKernel _this,
    const char *partition,
    const char *topic )
{
    d_groupInfo result;
    c_value keyValues[2];

    keyValues[0] = c_stringValue((c_string)partition);
    keyValues[1] = c_stringValue((c_string)topic);
    result = c_tableFind(_this->groups, keyValues); /* c_tableFind already performs keep. */

    return result;
}
Beispiel #5
0
d_storeResult
d_storeMMFKernelMarkNameSpaceComplete(
    d_storeMMFKernel kernel,
    const d_nameSpace nameSpace,
    const c_bool isComplete)
{
    d_nameSpaceInfo nsInfo;
    c_type type;
    c_char* name;
    c_value keyValues[1];
    d_storeResult result;

    if(kernel && nameSpace){
        name = d_nameSpaceGetName(nameSpace);
        keyValues[0] = c_stringValue((c_string)name);
        nsInfo = c_tableFind(kernel->nameSpaces, keyValues);

        if(nsInfo){
            nsInfo->complete = isComplete;
            result = D_STORE_RESULT_OK;
        } else {
            type = c_resolve(c_getBase(kernel),
                    "durabilityModule2::d_nameSpaceInfo");
            nsInfo = (d_nameSpaceInfo)c_new(type);
            c_free(type);

            if (nsInfo) {
                nsInfo->name = c_stringNew(c_getBase(kernel), name);
                nsInfo->complete = isComplete;
                c_tableInsert(kernel->nameSpaces, nsInfo);
                c_free(nsInfo);
                result = D_STORE_RESULT_OK;
            } else {
                OS_REPORT(OS_ERROR,
                      "d_storeMMFKernelMarkNameSpaceComplete",0,
                      "Failed to allocate nameSpaceInfo.");
                result = D_STORE_RESULT_OUT_OF_RESOURCES;
            }
        }
    } else {
        result = D_STORE_RESULT_ILL_PARAM;
    }
    return result;
}
Beispiel #6
0
static d_instance
d_groupInfoLookupInstance (
    d_groupInfo _this,
    const v_groupAction action)
{
    c_long i, nrOfKeys;
    c_value keyValues[32];
    d_instance instance;
    c_array messageKeyList;

    assert(C_TYPECHECK(action->message,v_message));

    messageKeyList = v_topicMessageKeyList(action->group->topic);
    nrOfKeys = c_arraySize(messageKeyList);

    if (nrOfKeys > 32) {
        OS_REPORT_1(OS_ERROR,
                    "d_groupInfoGetInstance",0,
                    "too many keys %d exceeds limit of 32",
                    nrOfKeys);
        instance = NULL;
    } else {
        for (i=0;i<nrOfKeys;i++) {
            keyValues[i] = c_fieldValue(messageKeyList[i],action->message);
        }
        instance = c_tableFind(_this->instances, &keyValues[0]);
        c_keep(instance);



        for (i=0;i<nrOfKeys;i++) {
            c_valueFreeRef(keyValues[i]);
        }
    }
    return instance;
}