void exec_command(vp_command *i_com) { switch (i_com->command) { case TIMER: exec_timer(&(i_com->params.timer)); break; case PWROF: exec_shutdown(); break; } }
/** * Execute a parse tree and return the result set or runtime error * * @param dcb The DCB that connects to the client * @param tree The parse tree for the query */ void maxinfo_execute(DCB *dcb, MAXINFO_TREE *tree) { switch (tree->op) { case MAXOP_SHOW: exec_show(dcb, tree); break; case MAXOP_SELECT: exec_select(dcb, tree); break; case MAXOP_FLUSH: exec_flush(dcb, tree); break; case MAXOP_SET: exec_set(dcb, tree); break; case MAXOP_CLEAR: exec_clear(dcb, tree); break; case MAXOP_SHUTDOWN: exec_shutdown(dcb, tree); break; case MAXOP_RESTART: exec_restart(dcb, tree); break; case MAXOP_TABLE: case MAXOP_COLUMNS: case MAXOP_LITERAL: case MAXOP_PREDICATE: case MAXOP_LIKE: case MAXOP_EQUAL: default: maxinfo_send_error(dcb, 0, "Unexpected operator in parse tree"); } }
int main() { dispatch_msg *msg; timing_init(); //Initiate the process grid pgrid_init(); while(1) { //Receive the dispatch message from the master-process dispatch_reset(); dispatch_recv(&msg); //Handle the message switch(msg->type) { case BH_CLUSTER_DISPATCH_INIT: { char *name = msg->payload; check_error(exec_init(name),__FILE__,__LINE__); break; } case BH_CLUSTER_DISPATCH_SHUTDOWN: { check_error(exec_shutdown(),__FILE__,__LINE__); return 0; } case BH_CLUSTER_DISPATCH_EXTMETHOD: { bh_opcode opcode = *((bh_opcode *)msg->payload); char *name = msg->payload+sizeof(bh_opcode); check_error(exec_extmethod(name, opcode),__FILE__,__LINE__); break; } case BH_CLUSTER_DISPATCH_EXEC: { //Get the size of the the serialized BhIR bh_intp bhir_size = *((bh_intp*) msg->payload); //Deserialize the BhIR bh_ir bhir = bh_ir(((char*)msg->payload)+sizeof(bh_intp), bhir_size); //The number of new arrays bh_intp *noa = (bh_intp *)(((char*)msg->payload)+sizeof(bh_intp)+bhir_size); //The list of new arrays dispatch_array *darys = (dispatch_array*)(noa+1); //number of new arrays //Insert the new array into the array store and the array maps std::stack<bh_base*> base_darys; for(bh_intp i=0; i < *noa; ++i) { bh_base *ary = dispatch_new_slave_array(&darys[i].ary, darys[i].id); base_darys.push(ary); } //Receive the dispatched array-data from the master-process dispatch_array_data(base_darys); //Update all instruction to reference local arrays for(uint64_t i=0; i < bhir.instr_list.size(); ++i) { bh_instruction *inst = &bhir.instr_list[i]; int nop = bh_noperands(inst->opcode); bh_view *ops = bh_inst_operands(inst); //Convert all instructon operands for(bh_intp j=0; j<nop; ++j) { if(bh_is_constant(&ops[j])) continue; bh_base *base = bh_base_array(&ops[j]); assert(dispatch_slave_exist((bh_intp)base)); bh_base_array(&ops[j]) = dispatch_master2slave((bh_intp)base); } } check_error(exec_execute(&bhir),__FILE__,__LINE__); break; } default: fprintf(stderr, "[VEM-CLUSTER] Slave (rank %d) " "received unknown message type\n", pgrid_myrank); MPI_Abort(MPI_COMM_WORLD,BH_ERROR); } } timing_finalize(); return BH_SUCCESS; }