jni_result jni_writerWrite( jni_writer wri, const c_char* xmlUserData) { jni_result r; jni_writerCopyArg copyArg; sd_validationResult valResult; if( (wri == NULL) || (xmlUserData == NULL) || (wri->uwriter == NULL) || (xmlUserData == NULL)){ r = JNI_RESULT_BAD_PARAMETER; } else{ copyArg = os_malloc(C_SIZEOF(jni_writerCopyArg)); copyArg->writer = wri; copyArg->xmlData = xmlUserData; r = jni_convertResult(u_writerWrite(wri->uwriter, copyArg, u_timeGet(), U_INSTANCEHANDLE_NIL)); valResult = sd_serializerLastValidationResult(wri->deserializer); if(valResult != SD_VAL_SUCCESS){ OS_REPORT_2(OS_ERROR, CONT_DCPSJNI, 0, "Write of userdata failed.\nReason: %s\nError: %s\n", sd_serializerLastValidationMessage(wri->deserializer), sd_serializerLastValidationLocation(wri->deserializer)); r = JNI_RESULT_ERROR; } os_free(copyArg); } return r; }
gapi_returnCode_t gapi_fooDataWriter_write_w_timestamp ( gapi_fooDataWriter _this, const gapi_foo *instance_data, const gapi_instanceHandle_t handle, const gapi_time_t *source_timestamp) { _DataWriter datawriter; gapi_returnCode_t result = GAPI_RETCODE_BAD_PARAMETER; writerInfo data; u_result r; c_time timestamp; if ( instance_data != NULL ) { result = kernelCopyInTime(source_timestamp, ×tamp); if ( result == GAPI_RETCODE_OK ) { datawriter = gapi_dataWriterReadClaim(_this, &result); if ( datawriter != NULL ) { data.writer = datawriter; data.data = (void *)instance_data; r = u_writerWrite (U_WRITER_GET(datawriter), &data, timestamp, handle); _EntityReadRelease(datawriter); result = kernelResultToApiResult(r); } } } return result; }
gapi_returnCode_t gapi_fooDataWriter_write ( gapi_fooDataWriter _this, const gapi_foo *instance_data, const gapi_instanceHandle_t handle) { _DataWriter datawriter; gapi_returnCode_t result = GAPI_RETCODE_BAD_PARAMETER; writerInfo data; u_result r; if ( instance_data != NULL ) { datawriter = gapi_dataWriterReadClaim(_this, &result); if ( datawriter != NULL ) { data.writer = datawriter; data.data = (void *)instance_data; r = u_writerWrite (U_WRITER_GET(datawriter), &data, C_TIME_INVALID, handle); _EntityReadRelease(datawriter); result = kernelResultToApiResult(r); } } return result; }
u_result nb_topicObjectWrite( u_writer writer, nb_topicObject _this) { u_result result = U_RESULT_UNSUPPORTED; os_timeW timestamp; assert(writer); nb_objectIsValid(_this); timestamp = _this->writeTime; if(v_stateTest(_this->state, L_REGISTER)){ result = u_writerRegisterInstance( writer, nb_topicObjectCopyIn, _this, timestamp, U_INSTANCEHANDLE_NIL); } else if(v_stateTest(_this->state, L_WRITE) && v_stateTest(_this->state, L_DISPOSED)){ result = u_writerWriteDispose( writer, nb_topicObjectCopyIn, _this, timestamp, U_INSTANCEHANDLE_NIL); } else if(v_stateTest(_this->state, L_WRITE)) { result = u_writerWrite( writer, nb_topicObjectCopyIn, _this, timestamp, U_INSTANCEHANDLE_NIL); } else if(v_stateTest(_this->state, L_DISPOSED)) { result = u_writerDispose( writer, nb_topicObjectCopyIn, _this, timestamp, U_INSTANCEHANDLE_NIL); } return result; }
c_bool d_publisherDeleteDataWrite( d_publisher publisher, d_deleteData message, d_networkAddress addressee) { c_bool result; u_result ur; int resendCount; c_bool terminate; d_durability durability; OS_UNUSED_ARG(addressee); result = FALSE; assert(d_objectIsValid(d_object(publisher), D_PUBLISHER) == TRUE); if(publisher){ if(publisher->enabled == TRUE){ terminate = FALSE; resendCount = 0; durability = d_adminGetDurability(publisher->admin); d_publisherInitMessage(publisher, d_message(message)); d_message(message)->sequenceNumber = publisher->deleteDataNumber++; while((!result) && (!terminate)){ ur = u_writerWrite(publisher->deleteDataWriter, message, v_timeGet(), U_INSTANCEHANDLE_NIL); if(ur == U_RESULT_OK){ result = TRUE; } else if(ur == U_RESULT_TIMEOUT) { terminate = d_durabilityMustTerminate(durability); resendCount++; if(terminate){ d_printTimedEvent(durability, D_LEVEL_SEVERE, D_THREAD_UNSPECIFIED, "Failed to resend d_deleteData message, because durability is terminating.\n"); OS_REPORT(OS_WARNING, D_CONTEXT_DURABILITY, 0, "Failed to send d_deleteData message, because durability is terminating."); } else if((resendCount == 1) || ((resendCount % 5) == 0)){ d_printTimedEvent(durability, D_LEVEL_WARNING, D_THREAD_UNSPECIFIED, "Already tried to resend d_deleteData message '%d' times.\n", resendCount); if(resendCount != 1){ OS_REPORT_1(OS_WARNING, D_CONTEXT_DURABILITY, 0, "Already tried to resend d_deleteData message '%d' times.", resendCount); } } } else { d_printTimedEvent(durability, D_LEVEL_SEVERE, D_THREAD_UNSPECIFIED, "Write of d_deleteData message FAILED with result %d.\n", ur); OS_REPORT_1(OS_ERROR, D_CONTEXT_DURABILITY, 0, "Write of d_deleteData message FAILED with result %d.", ur); d_durabilityTerminate(durability, TRUE); terminate = d_durabilityMustTerminate(durability); } } } } return result; }
c_bool d_publisherStatusWrite( d_publisher publisher, d_status message, d_networkAddress addressee) { c_bool result; u_result ur; int resendCount; c_bool terminate; d_durability durability; OS_UNUSED_ARG(addressee); result = FALSE; assert(d_objectIsValid(d_object(publisher), D_PUBLISHER) == TRUE); if(publisher){ if(publisher->enabled == TRUE){ terminate = FALSE; resendCount = 0; durability = d_adminGetDurability(publisher->admin); d_publisherInitMessage(publisher, d_message(message)); d_message(message)->sequenceNumber = publisher->statusNumber++; while((!result) && (!terminate)){ ur = u_writerWrite(publisher->statusWriter, message, v_timeGet(), U_INSTANCEHANDLE_NIL); if(ur == U_RESULT_OK){ result = TRUE; } else if(ur == U_RESULT_TIMEOUT) { terminate = d_durabilityMustTerminate(durability); if(!terminate && d_message(message)->senderState == D_STATE_TERMINATING){ /* ES 21 - okt - 2011: * if durability is not yet terminating, but the message being written * does indicate that termination of durability is imminent, then we have * to prevent durability from constantly retrying in the case of a TIMEOUT * of the datawriter. The standard timeout provided to the write will ensure * the write is tried during the period of the timeout. But once that timeout is * exceeded then it is fruitless to continue try to write the terminating message * Without this specific code, durability will hang when terminating is caused * by splice daemon terminating. */ terminate = TRUE; } resendCount++; if(terminate){ d_printTimedEvent(durability, D_LEVEL_SEVERE, D_THREAD_UNSPECIFIED, "Failed to resend d_status message, because durability is terminating.\n"); OS_REPORT(OS_WARNING, D_CONTEXT_DURABILITY, 0, "Failed to send d_status message, because durability is terminating."); } else if((resendCount == 1) || ((resendCount % 5) == 0)){ d_printTimedEvent(durability, D_LEVEL_WARNING, D_THREAD_UNSPECIFIED, "Already tried to resend d_status message '%d' times.\n", resendCount); if(resendCount != 1){ OS_REPORT_1(OS_WARNING, D_CONTEXT_DURABILITY, 0, "Already tried to resend d_status message '%d' times.", resendCount); } } } else { d_printTimedEvent(durability, D_LEVEL_SEVERE, D_THREAD_UNSPECIFIED, "Write of d_status message FAILED with result %d.\n", ur); OS_REPORT_1(OS_ERROR, D_CONTEXT_DURABILITY, 0, "Write of d_status message FAILED with result %d.", ur); d_durabilityTerminate(durability, TRUE); terminate = d_durabilityMustTerminate(durability); } } } } return result; }