int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); CORBA::Object_var object = orb->resolve_initial_references("CodecFactory"); IOP::CodecFactory_var codec_factory = IOP::CodecFactory::_narrow(object.in ()); IOP::Encoding e = {IOP::ENCODING_CDR_ENCAPS,1,2}; IOP::Codec_var codec = codec_factory->create_codec(e); CORBA::Any any_o; Value* value = new OBV_Value; any_o <<= &value; CORBA::OctetSeq_var bin = codec->encode(any_o); CORBA::Any_var any_n = codec->decode(bin.in ()); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Caught a CORBA exception\n"); return 1; } catch (...) { return 1; } return 0; }
void EDF_Scheduler::send_reply (PortableInterceptor::ServerRequestInfo_ptr ri) { int int_guid; RTScheduling::Current::IdType_var guid = this->current_->id (); ACE_OS::memcpy (&int_guid, guid->get_buffer (), guid->length ()); DSUI_EVENT_LOG (EDF_SCHED_FAM, ENTER_SEND_REPLY, int_guid, 0, 0); Kokyu::Svc_Ctxt_DSRT_QoS sc_qos; CORBA::String_var operation = ri->operation (); #ifdef KOKYU_DSRT_LOGGING ACE_DEBUG ((LM_DEBUG, "(%t|%T): send_reply from \"%s\"\n", ri->operation ())); #endif // Make the context to send the context to the target IOP::ServiceContext sc; sc.context_id = Server_Interceptor::SchedulingInfo; CORBA::Long importance; TimeBase::TimeT deadline; CORBA::Policy_var sched_policy = this->current_->scheduling_parameter(); if (CORBA::is_nil (sched_policy)) { #ifdef KOKYU_DSRT_LOGGING ACE_DEBUG ((LM_DEBUG, "(%t|%T): sched_policy nil.\n")); #endif //24 hrs from now - infinity ACE_Time_Value deadline_tv = ACE_OS::gettimeofday () + ACE_Time_Value (24*60*60,0); deadline = deadline_tv.sec ()*1000000 + deadline_tv.usec ()*10; //100s of nanoseconds for TimeBase::TimeT importance = 0; } else { #ifdef KOKYU_DSRT_LOGGING ACE_DEBUG ((LM_DEBUG, "(%t|%T):sched_policy not nil. ", "sched params set\n")); #endif EDF_Scheduling::SchedulingParameterPolicy_var sched_param_policy = EDF_Scheduling::SchedulingParameterPolicy::_narrow (sched_policy); EDF_Scheduling::SchedulingParameter_var sched_param = sched_param_policy->value (); sc_qos.guid.length (guid->length ()); guid_copy (sc_qos.guid, guid.in ()); deadline = sched_param->deadline; importance = sched_param->importance; sc_qos.deadline = deadline; sc_qos.importance = importance; CORBA::Any sc_qos_as_any; sc_qos_as_any <<= sc_qos; CORBA::OctetSeq_var cdtmp = codec_->encode (sc_qos_as_any); sc.context_data = cdtmp.in (); // Add this context to the service context list. ri->add_reply_service_context (sc, 1); #ifdef KOKYU_DSRT_LOGGING ACE_DEBUG ((LM_DEBUG, "(%t|%T):reply sc added\n")); #endif } kokyu_dispatcher_->update_schedule (guid.in (), Kokyu::BLOCK); DSUI_EVENT_LOG (EDF_SCHED_FAM, EXIT_SEND_REPLY, int_guid, 0, 0); #ifdef KOKYU_DSRT_LOGGING ACE_DEBUG ((LM_DEBUG, "(%t|%T): send_reply interceptor done\n")); #endif }
void EDF_Scheduler::send_request (PortableInterceptor::ClientRequestInfo_ptr ri) { int int_guid; RTScheduling::Current::IdType_var guid = this->current_->id (); ACE_OS::memcpy (&int_guid, guid->get_buffer (), guid->length ()); DSUI_EVENT_LOG (EDF_SCHED_FAM, ENTER_CLIENT_SCHED_TIME, int_guid, 0, 0); Kokyu::Svc_Ctxt_DSRT_QoS sc_qos; CORBA::String_var operation = ri->operation (); #ifdef KOKYU_DSRT_LOGGING ACE_DEBUG ((LM_DEBUG, "(%t|%T): send_request " "from \"%s\"\n", operation.in ())); #endif // Make the context to send the context to the target IOP::ServiceContext sc; sc.context_id = Client_Interceptor::SchedulingInfo; CORBA::Policy_var sched_policy = this->current_->scheduling_parameter(); CORBA::Long importance; TimeBase::TimeT deadline; TimeBase::TimeT period; int task_id=-1; if (CORBA::is_nil (sched_policy)) { //24 hrs from now - infinity ACE_Time_Value deadline_tv = ACE_OS::gettimeofday () + ACE_Time_Value (24*60*60,0); deadline = deadline_tv.sec () * 10000000 + deadline_tv.usec () * 10; //100s of nanoseconds for TimeBase::TimeT importance = 0; period = 0; //set period 0 as default. // task_id = ID_BEGIN ++; } else { EDF_Scheduling::SchedulingParameterPolicy_var sched_param_policy = EDF_Scheduling::SchedulingParameterPolicy::_narrow (sched_policy); EDF_Scheduling::SchedulingParameter_var sched_param = sched_param_policy->value (); deadline = sched_param->deadline; importance = sched_param->importance; period = sched_param->period; task_id = sched_param->task_id; #ifdef KOKYU_DSRT_LOGGING ACE_DEBUG ((LM_DEBUG, "(%t|%T): send_request guid = %d\n", int_guid)); #endif } //Fill the guid in the SC Qos struct sc_qos.guid.length (guid->length ()); guid_copy (sc_qos.guid, guid.in ()); sc_qos.deadline = deadline; sc_qos.importance = importance; sc_qos.task_id = task_id; sc_qos.period = period; CORBA::Any sc_qos_as_any; sc_qos_as_any <<= sc_qos; CORBA::OctetSeq_var cdtmp = codec_->encode (sc_qos_as_any); sc.context_data = cdtmp.in (); #ifdef KOKYU_DSRT_LOGGING ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t|%T): send_request : about to add sched SC\n"))); #endif // Add this context to the service context list. ri->add_request_service_context (sc, 0); #ifdef KOKYU_DSRT_LOGGING ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t|%T): send_request : ") ACE_TEXT ("about to call scheduler to inform block\n") )); #endif DSUI_EVENT_LOG (EDF_SCHED_FAM, CALL_KOKYU_DISPATCH_UPDATE_SCHEDULE, int_guid, 0, 0); kokyu_dispatcher_->update_schedule (guid.in (), Kokyu::BLOCK); DSUI_EVENT_LOG (EDF_SCHED_FAM, LEAVE_KOKYU_DISPATCH_UPDATE_SCHEDULE, int_guid,0,0); #ifdef KOKYU_DSRT_LOGGING ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t|%T): send_request interceptor done\n"))); #endif DSUI_EVENT_LOG (EDF_SCHED_FAM, LEAVE_CLIENT_SCHED_TIME, int_guid, 0, 0); }
void ReplicaController::send_reply ( PortableInterceptor::ServerRequestInfo_ptr ri) { FT::FTRequestServiceContext_var ftr ( extract_context (ri)); ACE_DEBUG ((LM_DEBUG, "(%P|%t) Sending reply for %s with rid %i\n", ftr->client_id.in (), ftr->retention_id)); // Prepare reply for logging. CORBA::Any_var result = ri->result (); TAO_OutputCDR cdr; result->impl ()->marshal_value (cdr); Dynamic::ParameterList_var pl = ri->arguments (); CORBA::ULong len = pl->length (); for (CORBA::ULong index = 0; index != len ; ++index) { //@@ No chance for PARAM_OUT if ((*pl)[index].mode == CORBA::PARAM_INOUT) { (*pl)[index].argument.impl ()->marshal_value (cdr); } } CORBA::OctetSeq_var reply; ACE_NEW (reply.out (), CORBA::OctetSeq (cdr.total_length ())); reply->length (cdr.total_length ()); CORBA::Octet* buf = reply->get_buffer (); // @@ What if this throws an exception?? We don't have any way to // check whether this succeeded for (ACE_Message_Block const* mb = cdr.begin (); mb != 0; mb = mb->cont ()) { ACE_OS::memcpy (buf, mb->rd_ptr (), mb->length ()); buf += mb->length (); } // Logging the reply and state update. // // First send message to members. // { // Extract state update. CORBA::OctetSeq_var oid = ri->object_id (); PortableInterceptor::AdapterName_var an = ri->adapter_name (); CORBA::Any_var state = ri->get_slot (state_slot_id ()); CORBA::TypeCode_var tc = state->type (); if (tc->kind () == CORBA::tk_null) { ACE_DEBUG ((LM_DEBUG, "Slot update is void\n")); PortableServer::POA_var poa = resolve_poa (an.in ()); PortableServer::ServantBase_var servant = poa->id_to_servant (oid.in ()); Checkpointable* target = dynamic_cast<Checkpointable*> (servant.in ()); if (target) { CORBA::Any_var tmp = target->get_state (); if (tmp.ptr () != 0) state = tmp._retn (); } } TAO_OutputCDR cdr; cdr << oid.in (); cdr << an.in (); cdr << ftr->client_id.in (); cdr << ftr->retention_id; cdr << reply.in (); cdr << state.in (); size_t size = cdr.total_length (); CORBA::OctetSeq_var msg; ACE_NEW (msg.out (), CORBA::OctetSeq (size)); msg->length (size); { CORBA::Octet* buf = msg->get_buffer (); for (ACE_Message_Block const* mb = cdr.begin (); mb != 0; mb = mb->cont ()) { ACE_OS::memcpy (buf, mb->rd_ptr (), mb->length ()); buf += mb->length (); } } CORBA::Octet* buf = msg->get_buffer (); // Crash point 1. // if (crash_point == 1 && ftr->retention_id > 2) ACE_OS::exit (1); try { while (true) { try { group_->send (buf, size); ACE_DEBUG ((LM_DEBUG, "Sent log record of length %i\n", size)); break; } catch (ACE_TMCast::Group::Aborted const&) { ACE_DEBUG ((LM_DEBUG, "Retrying to send log record.\n")); } } } catch (ACE_TMCast::Group::Failed const&) { ACE_DEBUG ((LM_DEBUG, "Group failure. Perhaps, I am alone in the group.\n")); } } // Now perform local logging. // RecordId rid (ftr->client_id.in (), ftr->retention_id); // This is slow but eh-safe ;-). // log_.insert (rid, reply); // Crash point 2. // if (crash_point == 2 && ftr->retention_id > 2) ACE_OS::exit (1); }
void MIF_Scheduler::send_reply (PortableInterceptor::ServerRequestInfo_ptr ri) { CORBA::Short importance = 0; Kokyu::Svc_Ctxt_DSRT_QoS sc_qos; CORBA::String_var operation = ri->operation (); #ifdef KOKYU_DSRT_LOGGING ACE_DEBUG ((LM_DEBUG, "(%t|%T): send_reply from \"%s\"\n", ri->operation ())); #endif // Make the context to send the context to the target IOP::ServiceContext sc; sc.context_id = Server_Interceptor::SchedulingInfo; CORBA::Policy_var sched_policy = this->current_->scheduling_parameter(); RTScheduling::Current::IdType_var guid = this->current_->id (); if (CORBA::is_nil (sched_policy.in ())) { #ifdef KOKYU_DSRT_LOGGING ACE_DEBUG ((LM_DEBUG, "(%t|%T): sched_policy nil. ", "importance not set in sched params\n")); #endif importance = 0; } else { #ifdef KOKYU_DSRT_LOGGING ACE_DEBUG ((LM_DEBUG, "(%t|%T):sched_policy not nil. ", "importance set in sched params\n")); #endif MIF_Scheduling::SchedulingParameterPolicy_var sched_param_policy = MIF_Scheduling::SchedulingParameterPolicy::_narrow (sched_policy.in ()); MIF_Scheduling::SchedulingParameter_var sched_param = sched_param_policy->value (); importance = sched_param->importance; //Fill the guid in the SC Qos struct sc_qos.guid.length (guid->length ()); guid_copy (sc_qos.guid, guid.in ()); sc_qos.importance = importance; CORBA::Any sc_qos_as_any; sc_qos_as_any <<= sc_qos; CORBA::OctetSeq_var cdtmp = codec_->encode (sc_qos_as_any); sc.context_data = cdtmp.in (); // Add this context to the service context list. ri->add_reply_service_context (sc, 1); #ifdef KOKYU_DSRT_LOGGING ACE_DEBUG ((LM_DEBUG, "(%t|%T):reply sc added\n")); #endif } kokyu_dispatcher_->update_schedule (guid.in (), Kokyu::BLOCK); #ifdef KOKYU_DSRT_LOGGING ACE_DEBUG ((LM_DEBUG, "(%t|%T): send_reply interceptor done\n")); #endif }
void MIF_Scheduler::send_request (PortableInterceptor::ClientRequestInfo_ptr ri) { Kokyu::Svc_Ctxt_DSRT_QoS sc_qos; CORBA::String_var operation = ri->operation (); #ifdef KOKYU_DSRT_LOGGING ACE_DEBUG ((LM_DEBUG, "(%t|%T): send_request " "from \"%s\"\n", operation.in ())); #endif // Make the context to send the context to the target IOP::ServiceContext sc; sc.context_id = Client_Interceptor::SchedulingInfo; CORBA::Policy_var sched_policy = this->current_->scheduling_parameter(); RTScheduling::Current::IdType_var guid = this->current_->id (); /* ACE_OS::memcpy (&guid, guid->get_buffer (), guid->length ()); */ CORBA::Short importance; if (CORBA::is_nil (sched_policy.in ())) { importance = 0; } else { MIF_Scheduling::SchedulingParameterPolicy_var sched_param_policy = MIF_Scheduling::SchedulingParameterPolicy::_narrow (sched_policy.in ()); MIF_Scheduling::SchedulingParameter_var sched_param = sched_param_policy->value (); importance = sched_param->importance; #ifdef KOKYU_DSRT_LOGGING int int_guid; ACE_OS::memcpy (&int_guid, guid->get_buffer (), guid->length ()); ACE_DEBUG ((LM_DEBUG, "(%t|%T): send_request importance from current = %d, guid = %d\n", importance, int_guid)); #endif //Fill the guid in the SC Qos struct sc_qos.guid.length (guid->length ()); guid_copy (sc_qos.guid, guid.in ()); sc_qos.importance = importance; CORBA::Any sc_qos_as_any; sc_qos_as_any <<= sc_qos; CORBA::OctetSeq_var cdtmp = codec_->encode (sc_qos_as_any); sc.context_data = cdtmp.in (); #ifdef KOKYU_DSRT_LOGGING ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t|%T): send_request : about to add sched SC\n"))); #endif // Add this context to the service context list. ri->add_request_service_context (sc, 0); } #ifdef KOKYU_DSRT_LOGGING ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t|%T): send_request : ") ACE_TEXT ("about to call scheduler to inform block\n") )); #endif kokyu_dispatcher_->update_schedule (guid.in (), Kokyu::BLOCK); #ifdef KOKYU_DSRT_LOGGING ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t|%T): send_request interceptor done\n"))); #endif }