Esempio n. 1
0
void
cmx_writerDataTypeAction(
    v_entity entity,
    c_voidp args)
{
    sd_serializer ser;
    sd_serializedData data;
    c_type type;
    struct cmx_writerTypeArg *arg;
    arg = (struct cmx_writerTypeArg *)args;
    
    type = NULL;
    
    switch(v_object(entity)->kind){
    case K_WRITER:
        type = v_topicDataType(v_writer(entity)->topic);      
    break;
    default:
        OS_REPORT(OS_ERROR, CM_XML_CONTEXT, 0, "Trying to resolve dataType of writer that is not a writer.\n");
        assert(FALSE);
    break;
    }
    
    if(type != NULL){
        ser = sd_serializerXMLMetadataNew(c_getBase(type));
        data = sd_serializerSerialize(ser, type);
        arg->result = sd_serializerToString(ser, data);
        sd_serializedDataFree(data);
        sd_serializerFree(ser);
    }
}
Esempio n. 2
0
void
v_publicDispose(
    v_public o)
{
    assert(C_TYPECHECK(o,v_public));

    if (o == NULL) {
        return;
    }
    switch(v_objectKind(o)) {
    case K_PARTICIPANT:    v_participantDeinit(v_participant(o));       break;
    case K_PUBLISHER:      v_publisherDeinit(v_publisher(o));           break;
    case K_SUBSCRIBER:     v_subscriberDeinit(v_subscriber(o));         break;
    case K_WRITER:         v_writerDeinit(v_writer(o));                 break;
    case K_DATAREADER:     v_dataReaderDeinit(v_dataReader(o));         break;
    case K_DELIVERYSERVICE:v_deliveryServiceDeinit(v_deliveryService(o)); break;
    case K_NETWORKREADER:  v_networkReaderDeinit(v_networkReader(o));   break;
    case K_READER:         v_readerDeinit(v_reader(o));                 break;
    case K_GROUPQUEUE:     v_groupQueueDeinit(v_groupQueue(o));         break;
    case K_TOPIC:          v_topicDeinit(v_topic(o));                   break;
    case K_ENTITY:                                                      break;
    case K_DOMAIN:         v_partitionDeinit(v_partition(o));           break;
    case K_GROUP:          v_groupDeinit(v_group(o));                   break;
    case K_SERVICEMANAGER: /* Is never freed! */                        break;
    case K_SPLICED:        v_splicedDeinit(v_spliced(o));               break;
    case K_NETWORKING:
    case K_DURABILITY:
    case K_CMSOAP:
    case K_SERVICE:        v_serviceDeinit(v_service(o));               break;
    case K_SERVICESTATE:   /* Is never freed! */                        break;
    case K_CONFIGURATION:                                               break;
    case K_QUERY:
        OS_REPORT(OS_ERROR, "v_publicDispose failure", 
                  0, "deinit of abstract class K_QUERY");
    break;
    case K_DATAREADERQUERY: 
        v_dataReaderQueryDeinit(v_dataReaderQuery(o));
    break;
    case K_DATAVIEWQUERY: 
        v_dataViewQueryDeinit(v_dataViewQuery(o));
    break;
    case K_DATAVIEW:       v_dataViewDeinit(v_dataView(o));             break;
    case K_WAITSET:        v_waitsetDeinit(v_waitset(o));               break;
    case K_WRITERINSTANCE:
        v_writerInstanceDeinit(v_writerInstance(o));
    break;
    case K_DATAREADERINSTANCE:
        v_dataReaderInstanceDeinit(v_dataReaderInstance(o));
    break;
    case K_DATAVIEWINSTANCE:
        v_dataViewInstanceDeinit(v_dataViewInstance(o));
    break;
    default:
        OS_REPORT_1(OS_ERROR,"v_publicDispose failed",0,
                    "illegal entity kind (%d) specified",v_objectKind(o));
        assert(FALSE);
    break;
    }
    c_free(o);
}
Esempio n. 3
0
void
cmx_writerSnapshotNewAction(
    v_entity e, 
    c_voidp args)
{
    v_writer writer;
    struct cmx_writerSnapshotArg* arg;
    
    arg = (struct cmx_writerSnapshotArg*)args;
    
    switch(v_object(e)->kind){
    case K_WRITER:
        arg->success = TRUE;
        arg->snapshot = cmx_writerSnapshot(os_malloc(C_SIZEOF(cmx_writerSnapshot)));
        arg->snapshot->samples = NULL;
        writer = v_writer(e);
        v_writerRead(writer, cmx_writerHistoryCopy, args);
        if(arg->serializer != NULL){
            sd_serializerFree(arg->serializer);
        }
    break;
    default:
    break;
    }
}
Esempio n. 4
0
c_char*
cmx_writerInit(
    v_writer entity)
{
    char buf[512];
    v_writer writer;
    
    writer = v_writer(entity);
    os_sprintf(buf, "<kind>WRITER</kind>");
    
    return (c_char*)(os_strdup(buf));
}
Esempio n. 5
0
void
d_publisherEnsureServicesAttached(
    v_entity entity,
    c_voidp args)
{
    v_writer writer;
    v_group group;
    d_durability durability;

    writer = v_writer(entity);
    durability = d_durability(args);
    group = writer->groupSet.firstGroup->group;
    d_durabilityWaitForAttachToGroup(durability, group);
}
Esempio n. 6
0
void
cmx_writerUnregisterCopy(
    v_entity entity,
    c_voidp args)
{
    v_writer kw;
    v_message message;
    void *to;
    sd_serializer ser;
    sd_serializedData data;
    sd_validationResult valResult;
    struct cmx_writerArg *arg;
    
    arg = (struct cmx_writerArg *)args;
    
    kw = v_writer(entity);
    message = v_topicMessageNew(kw->topic);
    to = C_DISPLACE(message,v_topicDataOffset(kw->topic));
    
    ser = sd_serializerXMLNewTyped(v_topicDataType(kw->topic));
    data = sd_serializerFromString(ser, arg->result);
    sd_serializerDeserializeIntoValidated(ser, data, to);
    valResult = sd_serializerLastValidationResult(ser);
        
    if(valResult != SD_VAL_SUCCESS){
        OS_REPORT_2(OS_ERROR, CM_XML_CONTEXT, 0, 
                    "Unregister of userdata failed.\nReason: %s\nError: %s\n",
                    sd_serializerLastValidationMessage(ser),
                    sd_serializerLastValidationLocation(ser));           
        arg->success = CMX_RESULT_FAILED;
    } else {
        arg->success = CMX_RESULT_OK;
    }
    sd_serializedDataFree(data);
    sd_serializerFree(ser);
    
    /* Note that the last param of v_writerWriteDispose is NULL,
       performance can be improved if the instance is provided. */    
    v_writerUnregister(kw,message,v_timeGet(),NULL);
    c_free(message);
}
Esempio n. 7
0
void
writerDeadlineMissed(
    v_leaseAction leaseAction,
    c_time now)
{
    v_object w;
    v_handleResult r;

    assert(leaseAction != NULL);
    assert(C_TYPECHECK(leaseAction, v_leaseAction));

    r = v_handleClaim(leaseAction->actionObject, &w);
    if (r == V_HANDLE_OK)
    {
        v_writerCheckDeadlineMissed(v_writer(w), now);
        r = v_handleRelease(leaseAction->actionObject);
        if(r != V_HANDLE_OK)
        {
            OS_REPORT_1(OS_WARNING, "v_leaseManager", 0,
                "Handle release failed with result code %d ", r);
        }
    }
}
Esempio n. 8
0
void
livelinessCheck(
    v_leaseManager _this,
    v_leaseAction leaseAction)
{
    v_object o;
    v_handleResult r;

    assert(leaseAction != NULL);
    assert(C_TYPECHECK(leaseAction, v_leaseAction));

    /* Liveliness lease expired, so the reader/writer must be notified! */
    r = v_handleClaim(leaseAction->actionObject, &o);
    if (r == V_HANDLE_OK)
    {
        v_writerNotifyLivelinessLost(v_writer(o));
        if (v_objectKind(o) != K_WRITER)
        {
            OS_REPORT_1(OS_WARNING, "v_lease", 0,
                        "entity %d has no liveliness policy",
                        v_objectKind(o));
        }
        r = v_handleRelease(leaseAction->actionObject);
        if(r != V_HANDLE_OK)
        {
            OS_REPORT_1(OS_WARNING, "v_leaseManager", 0,
                "Handle release failed with result code %d ", r);
        }
    } else
    {
        /* Corresponding reader/writer is already gone, so remove this lease
         * from its leasemanager.
         */
        v_leaseManagerDeregister(_this, leaseAction->lease);
    }
}