void Counter::async_save(framework::timer_manager* manager) { if( get_app().data_manager().async_save(m_data) !=0) { get_app().add_timer_after(&m_timer,10000) ; } }
corehost_init_t::corehost_init_t( const pal::string_t& host_command, const host_startup_info_t& host_info, const pal::string_t& deps_file, const pal::string_t& additional_deps_serialized, const std::vector<pal::string_t>& probe_paths, const host_mode_t mode, const fx_definition_vector_t& fx_definitions) : m_tfm(get_app(fx_definitions).get_runtime_config().get_tfm()) , m_deps_file(deps_file) , m_additional_deps_serialized(additional_deps_serialized) , m_is_framework_dependent(get_app(fx_definitions).get_runtime_config().get_is_framework_dependent()) , m_probe_paths(probe_paths) , m_host_mode(mode) , m_host_interface() , m_host_command(host_command) , m_host_info_host_path(host_info.host_path) , m_host_info_dotnet_root(host_info.dotnet_root) , m_host_info_app_path(host_info.app_path) { make_cstr_arr(m_probe_paths, &m_probe_paths_cstr); int fx_count = fx_definitions.size(); m_fx_names.reserve(fx_count); m_fx_dirs.reserve(fx_count); m_fx_requested_versions.reserve(fx_count); m_fx_found_versions.reserve(fx_count); std::unordered_map<pal::string_t, pal::string_t> combined_properties; for (auto& fx : fx_definitions) { fx->get_runtime_config().combine_properties(combined_properties); m_fx_names.push_back(fx->get_name()); m_fx_dirs.push_back(fx->get_dir()); m_fx_requested_versions.push_back(fx->get_requested_version()); m_fx_found_versions.push_back(fx->get_found_version()); } for (const auto& kv : combined_properties) { m_clr_keys.push_back(kv.first); m_clr_values.push_back(kv.second); } make_cstr_arr(m_fx_names, &m_fx_names_cstr); make_cstr_arr(m_fx_dirs, &m_fx_dirs_cstr); make_cstr_arr(m_fx_requested_versions, &m_fx_requested_versions_cstr); make_cstr_arr(m_fx_found_versions, &m_fx_found_versions_cstr); make_cstr_arr(m_clr_keys, &m_clr_keys_cstr); make_cstr_arr(m_clr_values, &m_clr_values_cstr); }
marathon_group::app_ptr_t mesos_state_t::add_or_replace_app(const std::string& app_id, const std::string& group_id, const std::string& task_id) { marathon_group::app_ptr_t app = get_app(app_id); if(!app) { app = std::make_shared<marathon_app>(app_id); g_logger.log("Created app [" + app_id + ']', sinsp_logger::SEV_DEBUG); } else { g_logger.log("Found app [" + app_id + ']', sinsp_logger::SEV_DEBUG); } if(!app) { g_logger.log("Could not find or create app [" + app_id + ']', sinsp_logger::SEV_ERROR); return 0; } if(!task_id.empty()) { g_logger.log("Adding task [" + task_id + "] to app [" + app_id + ']', sinsp_logger::SEV_DEBUG); add_task_to_app(app, task_id); } marathon_group::ptr_t group = get_group(group_id); if(group) { g_logger.log("Adding app [" + app_id + "] to group [" + group_id + ']', sinsp_logger::SEV_DEBUG); group->add_or_replace_app(app); } return app; }
int Counter::generate_counter() { Rule* rule = get_app().get_rule(m_data.rule_name) ; if(rule == NULL || rule->config.offset != m_data.node_offset ) return -1 ; RuleConfig& config = rule->config ; m_data.counter += config.step ; int now = generate_time() ; if( (!framework::is_same_cycle(m_data.update_time,now,config.reset_seconds)) || (m_data.counter > config.max_counter) ) { m_data.counter = config.min_counter + config.offset ; m_data.saved_counter = m_data.counter ; } m_data.update_time = now ; if(m_data.counter >= m_data.saved_counter) { m_data.saved_counter = m_data.counter + config.step * config.batch_save ; async_save() ; } return m_data.counter ; }
void job_description::set_args (std::vector <std::string> args) { char ** c_args = NULL; if ( args.size () > 0 ) { c_args = (char**) calloc (args.size (), sizeof (char*)); for ( unsigned int i = 0; i < args.size (); i++ ) { c_args[i] = ::strdup (args[i].c_str ()); } } get_app ()->num_args = args.size (); get_app ()->Argument = c_args; }
marathon_group::ptr_t mesos_state_t::add_group(const Json::Value& group, marathon_group::ptr_t to_group, const std::string& framework_id) { Json::Value group_id = group["id"]; if(!group_id.isNull()) { std::string id = group_id.asString(); std::ostringstream os; os << "Adding Marathon group [" + id + ']'; if(to_group) { os << " to group [" + to_group->get_id() << ']'; } g_logger.log(os.str(), sinsp_logger::SEV_INFO); marathon_group::ptr_t pg(new marathon_group(id)); marathon_group::ptr_t p_group = add_or_replace_group(pg, to_group); if(!framework_id.empty()) { Json::Value apps = group["apps"]; if(!apps.isNull()) { for(const auto& app : apps) { Json::Value app_id = app["id"]; if(!app_id.isNull()) { marathon_app::ptr_t p_app = get_app(app_id.asString()); if(!p_app) { p_app = add_app(app, framework_id); } if(p_app) { p_group->add_or_replace_app(p_app); for(const auto& task : get_tasks(framework_id)) { if(task.second->get_marathon_app_id() == app_id.asString()) { add_task_to_app(p_app, task.first); } } } else { g_logger.log("An error occured adding app [" + app_id.asString() + "] to group [" + id + ']', sinsp_logger::SEV_ERROR); } } } } } return p_group; } return 0; }
//insertion & removal void insert_app (App eqn) {//inserts an app in rep and parse trees LOG_DEBUG1( "O: inserting app Ob" ) Ob app = get_app(eqn); Assert3(!isDepricated(app), "insert_app: bad app"); Ob lhs = get_lhs(eqn); Assert3(!isDepricated(lhs), "insert_app: bad lhs"); Ob rhs = get_rhs(eqn); Assert3(!isDepricated(rhs), "insert_app: bad rhs"); //update bool properties app(BOOL_PROPERTIES) |= STRUCTURAL & lhs(BOOL_PROPERTIES) & rhs(BOOL_PROPERTIES); }
Context::Context() : app_(nullptr) { #ifdef KLAYGE_PLATFORM_ANDROID state_ = get_app(); #endif #ifdef KLAYGE_COMPILER_MSVC #ifdef KLAYGE_DEBUG _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); #endif #endif gtp_instance_ = MakeSharedPtr<thread_pool>(1, 16); }
void bugone_loop() { uint8_t *bufcontents; uint8_t i; // RFM12 managment rfm12_tick(); if (rfm12_rx_status() == STATUS_COMPLETE) { bufcontents=rfm12_rx_buffer(); recv(bufcontents); } // Every minutes if (seconds > 20) { struct packet_t *packet = get_tx_packet(); application_t *application; int8_t len; uart_putstr_P(PSTR("\r\n")); i=0; while ( (application = get_app(i)) != NULL) { i++; uart_putstr_P(PSTR("#")); if (application->get == NULL) { continue; } set_devices(packet,i,0x29); len=application->get(packet); if (len > 0) { //data.remaining_len-=len; //data.buf+=len; } } send(0xFF,6,packet); seconds=0; } // Asynchronous events if (wake_me_up > 0) { struct packet_t *packet = get_tx_packet(); int8_t len; uart_putstr_P(PSTR("\r\n")); set_devices(packet,wake_me_up,42); len=applications[wake_me_up].get(packet); send(0xFF,VALUE,packet); wake_me_up = 0; } }
void deps_resolver_t::get_app_fx_definition_range(fx_definition_vector_t::iterator *begin, fx_definition_vector_t::iterator *end) const { assert(begin != nullptr && end != nullptr); auto begin_iter = m_fx_definitions.begin(); auto end_iter = m_fx_definitions.end(); if (m_host_mode == host_mode_t::libhost && begin_iter != end_iter) { // In a libhost scenario the app definition shouldn't be // included in the creation of the application. assert(begin_iter->get() == &get_app(m_fx_definitions)); ++begin_iter; } *begin = begin_iter; *end = end_iter; }
void dont_advertise_dcbx_all(char *ifname, bool ad) { int i, is_pfc; pfc_attribs pfc_data; pg_attribs pg_data; app_attribs app_data; llink_attribs llink_data; u32 event_flag = 0; is_pfc = get_pfc(ifname, &pfc_data); if (get_pg(ifname, &pg_data) == cmd_success) { pg_data.protocol.Advertise = ad; put_pg(ifname, &pg_data, &pfc_data); event_flag |= DCB_LOCAL_CHANGE_PG; } if (is_pfc == cmd_success) { pfc_data.protocol.Advertise = ad; put_pfc(ifname, &pfc_data); event_flag |= DCB_LOCAL_CHANGE_PFC; } for (i = 0; i < DCB_MAX_APPTLV ; i++) { if (get_app(ifname, (u32)i, &app_data) == cmd_success) { app_data.protocol.Advertise = ad; put_app(ifname, (u32)i, &app_data); event_flag |= DCB_LOCAL_CHANGE_APPTLV(i); } } for (i = 0; i < DCB_MAX_LLKTLV ; i++) { if (get_llink(ifname, (u32)i, &llink_data) == cmd_success) { llink_data.protocol.Advertise = ad; put_llink(ifname, (u32)i, &llink_data); event_flag |= DCB_LOCAL_CHANGE_LLINK; } } }
int Counter::generate_counter() { Rule* rule = get_app().get_rule(m_data.rule_name) ; if(rule == NULL || rule->config.offset != m_data.node_offset ) return -1 ; m_data.counter += rule->config.step ; int now = generate_time() ; int reset_seconds = rule->config.reset_seconds ; if( ( reset_seconds>0 && (!framework::is_same_cycle(m_data.update_time,now,reset_seconds) ) )|| (m_data.counter > rule->config.max_counter) ) { m_data.counter = rule->config.min_counter + rule->config.offset ; } m_data.update_time = now ; async_save() ; return m_data.counter ; }
int dcbx_clif_cmd(UNUSED void *data, UNUSED struct sockaddr_un *from, UNUSED socklen_t fromlen, char *ibuf, int ilen, char *rbuf, int rlen) { u8 status = cmd_success; u8 cmd; u8 feature; u8 subtype; u8 plen; char port_id[MAX_U8_BUF]; pg_attribs pg_data; pfc_attribs pfc_data; app_attribs app_data; llink_attribs llink_data; struct dcbx_tlvs *dcbx; int dcb_enable; if (hexstr2bin(ibuf+DCB_CMD_OFF, &cmd, sizeof(cmd)) || hexstr2bin(ibuf+DCB_FEATURE_OFF, &feature, sizeof(feature))) return cmd_invalid; if (feature == FEATURE_DCBX) return handle_dcbx_cmd(cmd, feature, ibuf, ilen, rbuf); if (hexstr2bin(ibuf+DCB_SUBTYPE_OFF, &subtype, sizeof(subtype)) || hexstr2bin(ibuf+DCB_PORTLEN_OFF, &plen, sizeof(plen))) return cmd_invalid; if (ilen < DCB_PORT_OFF) return cmd_invalid; if (ibuf[DCB_VER_OFF] < (CLIF_DCBMSG_VERSION | 0x30)) { printf("unsupported client interface message version %x %x\n", ibuf[DCB_VER_OFF], CLIF_DCBMSG_VERSION | 0x30); return cmd_ctrl_vers_not_compatible; } if (ilen < DCB_PORT_OFF+plen) { printf("command too short\n"); return cmd_invalid; } /* append standard dcb command response content */ snprintf(rbuf , rlen, "%*.*s", DCB_PORT_OFF+plen, DCB_PORT_OFF+plen, ibuf); memcpy(port_id, ibuf+DCB_PORT_OFF, plen); port_id[plen] = '\0'; if (get_hw_state(port_id, &dcb_enable) < 0) return cmd_not_capable; dcbx = dcbx_data(port_id); /* OPER and PEER cmd not applicable while in IEEE-DCBX modes */ if ((!dcbx || dcbx->active == 0) && (cmd == CMD_GET_PEER || cmd == CMD_GET_OPER)) return cmd_not_applicable; switch(feature) { case FEATURE_DCB: if (cmd == CMD_SET_CONFIG) status = set_dcb_state(port_id, ibuf, ilen); else if (cmd == CMD_GET_CONFIG) status = get_dcb_state(port_id, rbuf+strlen(rbuf)); else status = cmd_invalid; break; case FEATURE_PG: if (cmd == CMD_GET_PEER) { status = get_peer_pg(port_id, &pg_data); } else { status = get_pg(port_id, &pg_data); } if (status != cmd_success) { printf("error[%d] getting PG data for %s\n", status, port_id); return status; } if (cmd == CMD_SET_CONFIG) { if (ilen < (DCB_PORT_OFF + plen + CFG_LEN)) { printf("set command too short\n"); status = cmd_invalid; } else { set_protocol_data(&pg_data.protocol, port_id, ibuf, plen, NEAREST_BRIDGE); status = set_pg_config(&pg_data, port_id, ibuf, ilen); } } else { status = get_cmd_protocol_data(&pg_data.protocol, cmd, rbuf+strlen(rbuf)); if (status == cmd_success) status = get_pg_data(&pg_data, cmd, port_id, pg_data.protocol.dcbx_st, rbuf+strlen(rbuf)); } break; case FEATURE_PFC: if (cmd == CMD_GET_PEER) { status = get_peer_pfc(port_id, &pfc_data); } else { status = get_pfc(port_id, &pfc_data); } if (status != cmd_success) { printf("error[%d] getting PFC data for %s\n", status, port_id); return status; } if (cmd == CMD_SET_CONFIG) { if (ilen < (DCB_PORT_OFF + plen + CFG_LEN)) { printf("set command too short\n"); status = cmd_failed; } else { set_protocol_data(&pfc_data.protocol, port_id, ibuf, plen, NEAREST_BRIDGE); status = set_pfc_config(&pfc_data, port_id, ibuf, ilen); } } else { status = get_cmd_protocol_data(&pfc_data.protocol, cmd, rbuf+strlen(rbuf)); if (status == cmd_success) status = get_pfc_data(&pfc_data, cmd, port_id, pfc_data.protocol.dcbx_st, rbuf+strlen(rbuf)); } break; case FEATURE_APP: if (cmd == CMD_GET_PEER) { status = get_peer_app(port_id, (u32)subtype, &app_data); } else { status = get_app(port_id, (u32)subtype, &app_data); } if (status != cmd_success) { printf("error[%d] getting APP data for %s\n", status, port_id); return status; } if (cmd == CMD_SET_CONFIG) { if (ilen < (DCB_PORT_OFF + plen + CFG_LEN)) { printf("set command too short\n"); status = cmd_failed; } else { set_app_protocol_data(port_id, ibuf, plen, ilen, subtype, NEAREST_BRIDGE); } } else { status = get_cmd_protocol_data(&app_data.protocol, cmd, rbuf+strlen(rbuf)); if (status == cmd_success) status = get_app_data(&app_data, cmd, port_id, subtype, rbuf + strlen(rbuf)); } break; case FEATURE_LLINK: if (cmd == CMD_GET_PEER) { status = get_peer_llink(port_id, (u32)subtype, &llink_data); } else { status = get_llink(port_id, (u32)subtype, &llink_data); } if (status != cmd_success) { printf("error[%d] getting APP data for %s\n", status, port_id); return status; } if (cmd == CMD_SET_CONFIG) { if (ilen < (DCB_PORT_OFF + plen + CFG_LEN)) { printf("set command too short\n"); status = cmd_failed; } else { set_protocol_data(&llink_data.protocol, port_id, ibuf, plen, NEAREST_BRIDGE); status = set_llink_config(&llink_data, port_id, (u32)subtype, ibuf, ilen); } } else { status = get_cmd_protocol_data(&llink_data.protocol, cmd, rbuf+strlen(rbuf)); if (status == cmd_success) status = get_llink_data(&llink_data, cmd, port_id, subtype, rbuf + strlen(rbuf)); } break; case FEATURE_PG_DESC: if (cmd == CMD_GET_CONFIG) { status = get_bwg_desc(port_id, ibuf, ilen, rbuf+strlen(rbuf)); if (status != cmd_success) { printf("error[%d] getting BWG desc for %s\n", status, port_id); return status; } } else if (cmd == CMD_SET_CONFIG) { status = set_bwg_desc(port_id, ibuf, ilen); } break; default: break; } return status; }
void job_description::set_working_directory (std::string s) { get_app ()->WorkingDirectory = ::strdup (s.c_str ()); }
void job_description::set_error (std::string s) { get_app ()->Error = ::strdup (s.c_str ()); }
void job_description::set_output (std::string s) { get_app ()->Output = ::strdup (s.c_str ()); }
void job_description::set_executable (std::string s) { get_app ()->Executable = ::strdup (s.c_str ()); }
int main (int argc, char *argv[]) { struct GNUNET_gstData *gst; GstBus *bus; GstMessage *msg; GstElement *gnunetsrc, *gnunetsink, *source, *sink, *encoder, *decoder; // audio_message = GNUNET_malloc (UINT16_MAX); //audio_message->header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO); //GstPipeline *pipeline; gst = (GNUNET_gstData*)malloc(sizeof(struct GNUNET_gstData)); //gst->audio_message.header.type = htons (GNUNET_MESSAGE_TYPE_CONVERSATION_AUDIO); gg_load_configuration(gst); /* gst->audiobackend = JACK; gst->dropsilence = TRUE; gst->usertp = FALSE; */ /* Initialize GStreamer */ gst_init (&argc, &argv); gst->pipeline = GST_PIPELINE(gst_pipeline_new ("gnunet-media-helper")); #ifdef IS_SPEAKER int type = SPEAKER; printf("this is the speaker \n"); #endif #ifdef IS_MIC int type = MICROPHONE; printf("this is the microphone \n"); #endif if ( type == SPEAKER) { gnunetsrc = GST_ELEMENT(get_app(gst, SOURCE)); sink = GST_ELEMENT(get_audiobin(gst, SINK)); decoder = GST_ELEMENT(get_coder(gst, DECODER)); gst_bin_add_many( GST_BIN(gst->pipeline), gnunetsrc, decoder, sink, NULL); gst_element_link_many( gnunetsrc, decoder, sink , NULL); } if ( type == MICROPHONE ) { source = GST_ELEMENT(get_audiobin(gst, SOURCE)); encoder = GST_ELEMENT(get_coder(gst, ENCODER)); gnunetsink = GST_ELEMENT(get_app(gst, SINK)); gst_bin_add_many( GST_BIN(gst->pipeline), source, encoder, gnunetsink, NULL); gst_element_link_many( source, encoder, gnunetsink , NULL); } /* gst_bin_add_many( GST_BIN(gst->pipeline), appsource, appsink, source, encoder, decoder, sink, NULL); gst_element_link_many( source, encoder, decoder, sink , NULL); */ pl_graph(gst->pipeline); /* Start playing */ gst_element_set_state (GST_ELEMENT(gst->pipeline), GST_STATE_PLAYING); //pl_graph(gst->pipeline); /* Wait until error or EOS */ //bus = gst_element_get_bus (GST_ELEMENT(gst->pipeline)); //bus_watch_id = gst_bus_add_watch (bus, gnunet_gst_bus_call, pipeline); gg_setup_gst_bus(gst); // g_print ("Running...\n"); // start pushing buffers if ( type == MICROPHONE ) { GMainLoop *loop; loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (loop); /* while ( 1 ) { GstFlowReturn flow; flow = on_appsink_new_sample (gst->appsink, gst); } */ } if ( type == SPEAKER ) { while ( 1 ) { // printf("read.. \n"); gnunet_read(gst); } } g_print ("Returned, stopping playback\n"); gst_object_unref (bus); gst_element_set_state (GST_ELEMENT(gst->pipeline), GST_STATE_NULL); gst_object_unref (gst->pipeline); return 0; }
void Counter::async_save() { get_app().data_manager().async_update(m_data) ; }
Counter::~Counter() { get_app().del_timer(&m_timer) ; }
static void set_app_protocol_data(char *ifname, char *ibuf, int plen, int ilen, int subtype, int agenttype) { u8 aflag, eflag, wflag; int status, last, i; app_attribs app_data; feature_protocol_attribs *protocol; status = get_app(ifname, (u32)subtype, &app_data); if (status != cmd_success) { printf("%s %s: error[%d] getting APP data.\n", __func__, ifname, status); return; } protocol = &app_data.protocol; last = protocol->Advertise; aflag = *(ibuf+DCB_PORT_OFF+plen+CFG_ADVERTISE); if (aflag == '0' || aflag == '1') protocol->Advertise = aflag & 0x01; status = set_app_config(&app_data, ifname, (u32)subtype, ibuf, ilen); if (status != cmd_success) printf("%s %s: error[%d] set_app_config failed\n", __func__, ifname, status); if (last != protocol->Advertise && protocol->Advertise) { tlv_enabletx(ifname, agenttype, (OUI_CEE_DCBX << 8) | protocol->dcbx_st); } eflag = *(ibuf+DCB_PORT_OFF+plen+CFG_ENABLE); wflag = *(ibuf+DCB_PORT_OFF+plen+CFG_WILLING); for (i = 0; i < DCB_MAX_APPTLV; i++) { status = get_app(ifname, (u32)i, &app_data); if (status != cmd_success) continue; protocol = &app_data.protocol; if (eflag == '0' || eflag == '1') protocol->Enable = eflag & 0x01; if (wflag == '0' || wflag == '1') protocol->Willing = wflag & 0x01; status = put_app(ifname, i, &app_data); if (status != cmd_success) printf("%s %s: error[%d] set_app_config failed\n", __func__, ifname, status); } somethingChangedLocal(ifname, agenttype); }