static void getSomething(Dict* args, struct RouteGen_admin_Ctx* ctx, String* txid, struct Allocator* requestAlloc, Dict* genRoutes) { int page = getIntVal(args, String_CONST("page")); List* routes; if (getIntVal(args, String_CONST("ip6"))) { routes = Dict_getList(genRoutes, String_CONST("ipv6")); } else { routes = Dict_getList(genRoutes, String_CONST("ipv4")); } Assert_true(routes); List* outList = List_new(requestAlloc); bool more = false; for (int i = page * ROUTES_PER_PAGE, j = 0; i < List_size(routes) && j < ROUTES_PER_PAGE; j++) { String* route = List_getString(routes, i); Assert_true(route); List_addString(outList, route, requestAlloc); if (++i >= List_size(routes)) { more = false; break; } more = true; } Dict* out = Dict_new(requestAlloc); if (more) { Dict_putInt(out, String_new("more", requestAlloc), 1, requestAlloc); } Dict_putList(out, String_new("routes", requestAlloc), outList, requestAlloc); Admin_sendMessage(out, txid, ctx->admin); }
void modifyBoardSize() { char command = 'Z'; do { printf("\n\t----- Editing board -----\n\n"); printf("\tr)\tChange (R)ows (currently %d)\n", boardrows); printf("\tc)\tChange (C)olumns (currently %d)\n\n", boardcols); printf("\tb)\tGo (B)ack to previous screen\n\n"); printf("Please select an option: "); command = toupper(GetMyChar()); switch (command) { case 'R': getIntVal(&boardrows); command = 'Z'; break; case 'C': getIntVal(&boardcols); command = 'Z'; break; case 'B': return; default: printf("\nI don't understand %c - please choose another option.\n", command); command = 'Z'; } } while (1); }
double Func_ceil::getDoubleVal(Row& row, FunctionParm& parm, bool& isNull, CalpontSystemCatalog::ColType& op_ct) { double ret = 0.0; if (op_ct.colDataType == CalpontSystemCatalog::DOUBLE || op_ct.colDataType == CalpontSystemCatalog::UDOUBLE || op_ct.colDataType == CalpontSystemCatalog::FLOAT || op_ct.colDataType == CalpontSystemCatalog::UFLOAT) { ret = ceil(parm[0]->data()->getDoubleVal(row, isNull)); } else if (op_ct.colDataType == CalpontSystemCatalog::VARCHAR || op_ct.colDataType == CalpontSystemCatalog::CHAR) { const string& str = parm[0]->data()->getStrVal(row, isNull); if (!isNull) ret = ceil(strtod(str.c_str(), 0)); } else { if (isUnsigned(op_ct.colDataType)) { ret = (double) getUintVal(row, parm, isNull, op_ct); } else { ret = (double) getIntVal(row, parm, isNull, op_ct); } } return ret; }
string Func_div::getStrVal(rowgroup::Row& row, FunctionParm& parm, bool& isNull, erydbSystemCatalog::ColType& ct) { return intToString(getIntVal(row, parm, isNull, ct)); }
double Func_div::getDoubleVal(rowgroup::Row& row, FunctionParm& parm, bool& isNull, execplan::erydbSystemCatalog::ColType& ct) { return getIntVal(row, parm, isNull, ct); }
void configureSwapRule() { char command = 'Z'; do { printf("\n\t----- Configuring Swaprule -----\n\n"); printf("\tSwapmode is currently \"Swap %s\"\n\n", swapmodeToString(swapmode)); printf("\tt)\tChange (T)urn when swap is offered (currently %d)\n\n", swapturn+1); if(swapmode != SWAP_BOTH) printf("\ta)\tChange mode to \"Swap direction (A)nd color\"\n"); if(swapmode != SWAP_DIRECTION) printf("\td)\tChange mode to \"Swap (D)irection only\"\n"); if(swapmode != SWAP_COLOR) printf("\tc)\tChange mode to \"Swap (C)olor only\"\n"); if(swapmode != SWAP_NONE) printf("\tn)\tChange mode to \"No swaprule\"\n\n"); printf("\tb)\tGo (B)ack to previous screen\n\n"); printf("Please select an option: "); command = toupper(GetMyChar()); switch(command) { case 'T': getIntVal(&swapturn); swapturn--; command = 'Z'; break; case 'A': swapmode = SWAP_BOTH; command = 'Z'; break; case 'D': swapmode = SWAP_DIRECTION; command = 'Z'; break; case 'C': swapmode = SWAP_COLOR; command = 'Z'; break; case 'B': return; default: printf("\nI don't understand %c - please choose another option.\n", command); command = 'Z'; break; } } while(1); }
void sigShutdownHandler(int cookie) { if (getIntVal("EnableCLI")) { // Wait for command line interface to shut down cliShutdown(); } jvmPipeDestroy(); printf("Jem/JVM is shutdown.\n"); exit(0); }
string Func_ceil::getStrVal(Row& row, FunctionParm& parm, bool& isNull, CalpontSystemCatalog::ColType& op_ct) { char tmp[512] = {'\0'}; if (op_ct.colDataType == CalpontSystemCatalog::DOUBLE || op_ct.colDataType == CalpontSystemCatalog::UDOUBLE || op_ct.colDataType == CalpontSystemCatalog::FLOAT || op_ct.colDataType == CalpontSystemCatalog::UFLOAT || op_ct.colDataType == CalpontSystemCatalog::VARCHAR || op_ct.colDataType == CalpontSystemCatalog::CHAR) { snprintf(tmp, 511, "%f", getDoubleVal(row, parm, isNull, op_ct)); // remove the decimals in the oss string. char *d = tmp; while ((*d != '.') && (*d != '\0')) d++; *d = '\0'; } else if (isUnsigned(op_ct.colDataType)) { #ifndef __LP64__ snprintf(tmp, 511, "%llu", getUintVal(row, parm, isNull, op_ct)); #else snprintf(tmp, 511, "%lu", getUintVal(row, parm, isNull, op_ct)); #endif } else { #ifndef __LP64__ snprintf(tmp, 511, "%lld", getIntVal(row, parm, isNull, op_ct)); #else snprintf(tmp, 511, "%ld", getIntVal(row, parm, isNull, op_ct)); #endif } return string(tmp); }
std::string Func_strcmp::getStrVal(rowgroup::Row& row, FunctionParm& fp, bool& isNull, execplan::erydbSystemCatalog::ColType& op_ct) { uint64_t val = getIntVal(row, fp, isNull, op_ct); if (val > 0) return string("1"); else if (val < 0) return string("-1"); else return string("0"); }
string Func_sign::getStrVal(rowgroup::Row& row, FunctionParm& parm, bool& isNull, CalpontSystemCatalog::ColType& op_ct) { int64_t sign = getIntVal(row, parm, isNull, op_ct); if (sign > 0) return string("1"); else if (sign < 0) return string("-1"); else return string("0"); }
int ResourceManager::getEmPriority() const { int temp = getIntVal(fExeMgrStr, "Priority", defaultEMPriority); // config file priority is 40..1 (highest..lowest) // convert to -20..19 (highest..lowest, defaults to -1) int val; // @Bug3385 - the ExeMgr priority was being set backwards with 1 being the highest instead of the lowest. if (temp < 1) val = 19; else if (temp > 40) val = -20; else val = 20 - temp; return val; }
int jemCLIinit(void) { int on = 1; cli = cli_init(); cli_set_banner(cli, "Jem/JVM Command Line Interface"); cli_set_hostname(cli, "Jem/JVM"); cli_register_command(cli, NULL, "uptime", cmdUptime, PRIVILEGE_UNPRIVILEGED, MODE_EXEC, "Display uptime."); if ((socketFD = socket(AF_INET, SOCK_STREAM, 0)) < 0) { printf("Socket creation error for CLI, result=%d.\n", errno); return errno; } setsockopt(socketFD, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); memset(&serverAddr, 0, sizeof(serverAddr)); serverAddr.sin_family = AF_INET; serverAddr.sin_addr.s_addr = htonl(INADDR_ANY); int cliPort = getIntVal((char *) "CLIPORT"); if (cliPort == 0) cliPort = 8181; serverAddr.sin_port = htons(cliPort); if (bind(socketFD, (struct sockaddr *)&serverAddr, sizeof(serverAddr)) < 0) { printf("Socket bind error for CLI, result=%d.\n", errno); return errno; } if (listen(socketFD, 50) < 0) { printf("Socket listen error for CLI, result=%d.\n", errno); return errno; } int result = rt_task_create(&cliTask,"cliTask",0,1,T_FPU|T_JOINABLE); if (result) { printf("Failed to create cli task, code=%d \n", result); return -1; } result = rt_task_start(&cliTask,&commandTask,NULL); if (result) { printf("Failed to start cli task, code=%d \n", result); return -1; } return 0; }
int main (int argc, char *argv[]) { sigset_t set, oldset; int result; printf("Jem/JVM version %1d.%1d.%1d, built on: %s, by: %s\n", VERSION_NUM, REVISION_NUM, BUILD_NUM, BUILD_DATE, USER_HOST); printf("Copyright (C) 2007, Sombrio Systems Inc.\n"); sigemptyset(&set); sigaddset(&set, SIGALRM); sigprocmask(SIG_BLOCK, &set, &oldset); signal(SIGQUIT, sigShutdownHandler); signal(SIGINT, sigShutdownHandler); mlockall(MCL_CURRENT|MCL_FUTURE); // Load run time configuration values jvmConfig(); if (getIntVal("EnableCLI")) { // Intialize the command line interface if (jemCLIinit()) { printf("CLI is not enabled, use Ctrl-C to quit.\n"); } else { printf("CLI is enabled, use Ctrl-C to quit.\n"); } } else { printf("CLI is not enabled, use Ctrl-C to quit.\n"); } // Initialize the message queue if (jvmPipeInit()) { sigShutdownHandler(0); exit(1); } printf("Jem/JVM ready.\n"); for (;;) { sleep(SLEEPINTVL); upTime += SLEEPINTVL; } }
ResourceManager::ResourceManager(bool runningInExeMgr) : fExeMgrStr("ExeMgr1"), fSystemConfigStr("SystemConfig"), fDMLProcStr("DMLProc"), fBatchInsertStr("BatchInsert"), fConfig(Config::makeConfig()), fNumCores(8), fHjNumThreads(defaultNumThreads), fJlProcessorThreadsPerScan(defaultProcessorThreadsPerScan), fJlNumScanReceiveThreads(defaultScanReceiveThreads), fTwNumThreads(defaultNumThreads), fHJUmMaxMemorySmallSideDistributor(fHashJoinStr, "UmMaxMemorySmallSide", getUintVal(fHashJoinStr, "TotalUmMaxMemorySmallSide", defaultTotalUmMemory), getUintVal(fHashJoinStr, "UmMaxMemorySmallSide", defaultHJUmMaxMemorySmallSide), 0), fHJPmMaxMemorySmallSideSessionMap( getUintVal(fHashJoinStr, "PmMaxMemorySmallSide", defaultHJPmMaxMemorySmallSide)), isExeMgr(runningInExeMgr) { int temp; int configNumCores = -1; fTraceFlags = 0; //See if we want to override the calculated #cores temp = getIntVal(fJobListStr, "NumCores", -1); if (temp > 0) configNumCores = temp; if (configNumCores <= 0) { //count the actual #cores utils::CGroupConfigurator cg; fNumCores = cg.getNumCores(); if (fNumCores <= 0) fNumCores = 8; } else fNumCores = configNumCores; //based on the #cores, calculate some thread parms if (fNumCores > 0) { fHjNumThreads = fNumCores; fJlNumScanReceiveThreads = fNumCores; fTwNumThreads = fNumCores; } //possibly override any calculated values temp = getIntVal(fHashJoinStr, "NumThreads", -1); if (temp > 0) fHjNumThreads = temp; temp = getIntVal(fJobListStr, "ProcessorThreadsPerScan", -1); if (temp > 0) fJlProcessorThreadsPerScan = temp; temp = getIntVal(fJobListStr, "NumScanReceiveThreads", -1); if (temp > 0) fJlNumScanReceiveThreads = temp; temp = getIntVal(fTupleWSDLStr, "NumThreads", -1); if (temp > 0) fTwNumThreads = temp; pmJoinMemLimit = getIntVal(fHashJoinStr, "PmMaxMemorySmallSide", defaultHJPmMaxMemorySmallSide); // Need to use different limits if this instance isn't running on the UM, // or if it's an ExeMgr running on a PM node if (!isExeMgr) totalUmMemLimit = pmJoinMemLimit; else { string whichLimit = "TotalUmMemory"; string pmWithUM = fConfig->getConfig("Installation", "PMwithUM"); if (pmWithUM == "y" || pmWithUM == "Y") { oam::Oam OAM; oam::oamModuleInfo_t moduleInfo = OAM.getModuleInfo(); string &moduleType = boost::get<1>(moduleInfo); if (moduleType == "pm" || moduleType == "PM") { string doesItExist = fConfig->getConfig(fHashJoinStr, "TotalPmUmMemory"); if (!doesItExist.empty()) whichLimit = "TotalPmUmMemory"; } } string umtxt = fConfig->getConfig(fHashJoinStr, whichLimit); if (umtxt.empty()) totalUmMemLimit = defaultTotalUmMemory; else { // is it an absolute or a percentage? if (umtxt.find('%') != string::npos) { utils::CGroupConfigurator cg; uint64_t totalMem = cg.getTotalMemory(); totalUmMemLimit = atoll(umtxt.c_str())/100.0 * (double) totalMem; if (totalUmMemLimit == 0 || totalUmMemLimit == LLONG_MIN || totalUmMemLimit == LLONG_MAX) // some garbage in the xml entry totalUmMemLimit = defaultTotalUmMemory; } else { // an absolute; use the existing converter totalUmMemLimit = getIntVal(fHashJoinStr, whichLimit, defaultTotalUmMemory); } } } configuredUmMemLimit = totalUmMemLimit; //cout << "RM: total UM memory = " << totalUmMemLimit << endl; // multi-thread aggregate string nt, nb, nr; nt = fConfig->getConfig("RowAggregation", "RowAggrThreads"); if (nt.empty()) fAggNumThreads = numCores(); else fAggNumThreads = fConfig->uFromText(nt); nb = fConfig->getConfig("RowAggregation","RowAggrBuckets"); if (nb.empty()) fAggNumBuckets = fAggNumThreads * 4; else fAggNumBuckets = fConfig->uFromText(nb); nr = fConfig->getConfig("RowAggregation", "RowAggrRowGroupsPerThread"); if (nr.empty()) fAggNumRowGroups = 20; else fAggNumRowGroups = fConfig->uFromText(nr); // window function string wt = fConfig->getConfig("WindowFunction", "WorkThreads"); if (wt.empty()) fWindowFunctionThreads = numCores(); else fWindowFunctionThreads = fConfig->uFromText(wt); // hdfs info string hdfs = fConfig->getConfig("SystemConfig", "DataFilePlugin"); if ( hdfs.find("hdfs") != string::npos) fUseHdfs = true; else fUseHdfs = false; }