Changeset 19092 for trunk/ippTools/src/stacktool.c
- Timestamp:
- Aug 16, 2008, 1:27:58 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippTools/src/stacktool.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippTools/src/stacktool.c
r19029 r19092 40 40 static bool sumskyfileMode(pxConfig *config); 41 41 static bool revertsumskyfileMode(pxConfig *config); 42 static bool pendingcleanuprunMode(pxConfig *config); 43 static bool pendingcleanupskyfileMode(pxConfig *config); 44 static bool donecleanupMode(pxConfig *config); 42 45 43 46 static bool setstackRunState(pxConfig *config, psS64 stack_id, const char *state); … … 61 64 62 65 switch (config->mode) { 63 MODECASE(STACKTOOL_MODE_DEFINEBYQUERY, definebyqueryMode); 64 MODECASE(STACKTOOL_MODE_DEFINERUN, definerunMode); 65 MODECASE(STACKTOOL_MODE_UPDATERUN, updaterunMode); 66 MODECASE(STACKTOOL_MODE_ADDINPUTSKYFILE, addinputskyfileMode); 67 MODECASE(STACKTOOL_MODE_INPUTSKYFILE, inputskyfileMode); 68 MODECASE(STACKTOOL_MODE_TOSUM, tosumMode); 69 MODECASE(STACKTOOL_MODE_ADDSUMSKYFILE, addsumskyfileMode); 70 MODECASE(STACKTOOL_MODE_SUMSKYFILE, sumskyfileMode); 71 MODECASE(STACKTOOL_MODE_REVERTSUMSKYFILE, revertsumskyfileMode); 66 MODECASE(STACKTOOL_MODE_DEFINEBYQUERY, definebyqueryMode); 67 MODECASE(STACKTOOL_MODE_DEFINERUN, definerunMode); 68 MODECASE(STACKTOOL_MODE_UPDATERUN, updaterunMode); 69 MODECASE(STACKTOOL_MODE_ADDINPUTSKYFILE, addinputskyfileMode); 70 MODECASE(STACKTOOL_MODE_INPUTSKYFILE, inputskyfileMode); 71 MODECASE(STACKTOOL_MODE_TOSUM, tosumMode); 72 MODECASE(STACKTOOL_MODE_ADDSUMSKYFILE, addsumskyfileMode); 73 MODECASE(STACKTOOL_MODE_SUMSKYFILE, sumskyfileMode); 74 MODECASE(STACKTOOL_MODE_REVERTSUMSKYFILE, revertsumskyfileMode); 75 MODECASE(STACKTOOL_MODE_PENDINGCLEANUPRUN, pendingcleanuprunMode); 76 MODECASE(STACKTOOL_MODE_PENDINGCLEANUPSKYFILE, pendingcleanupskyfileMode); 77 MODECASE(STACKTOOL_MODE_DONECLEANUP, donecleanupMode); 72 78 default: 73 79 psAbort("invalid option (this should not happen)"); … … 288 294 289 295 // create a new stackRun for this stack 290 stackRunRow *run = stackRunRowAlloc(0, "run", workdir, NULL, registered, skycell_id, tess_id, filter); 296 stackRunRow *run = stackRunRowAlloc( 297 0, // ID 298 "new", // state 299 workdir, 300 NULL, // workdir_state 301 registered, 302 skycell_id, 303 tess_id, 304 filter); 305 291 306 if (!stackRunInsertObject(config->dbh, run)) { 292 307 if (!psDBRollback(config->dbh)) { … … 343 358 if (!stackRunPrintObjects(stdout, list, !simple)) { 344 359 psError(PS_ERR_UNKNOWN, false, "failed to print object"); 345 return false;346 }347 360 psFree(list); 361 return false; 362 } 348 363 psFree(list); 349 350 364 return true; 351 365 } … … 374 388 } 375 389 376 stackRunRow *run = stackRunRowAlloc(0, "run", workdir, NULL, registered, skycell_id, tess_id, filter); 390 stackRunRow *run = stackRunRowAlloc( 391 0, // ID 392 "new", // state 393 workdir, 394 NULL, // workdir_state 395 registered, 396 skycell_id, 397 tess_id, 398 filter); 399 377 400 if (!run) { 378 401 psError(PS_ERR_UNKNOWN, false, "failed to alloc stackRun object"); … … 667 690 } 668 691 669 if (!setstackRunState(config, stack_id, " stop")) {692 if (!setstackRunState(config, stack_id, "full")) { 670 693 if (!psDBRollback(config->dbh)) { 671 694 psError(PS_ERR_UNKNOWN, false, "database error"); … … 869 892 870 893 // check that state is a valid string value 871 if (!( 872 (strncmp(state, "run", 4) == 0) 873 || (strncmp(state, "stop", 5) == 0) 874 || (strncmp(state, "reg", 4) == 0) 875 ) 876 ) { 877 psError(PS_ERR_UNKNOWN, false, 878 "invalid warpRun state: %s", state); 894 if (!pxIsValidState(state)) { 895 psError(PS_ERR_UNKNOWN, false, "invalid stackRun state: %s", state); 879 896 return false; 880 897 } … … 889 906 return true; 890 907 } 908 909 static bool pendingcleanuprunMode(pxConfig *config) 910 { 911 PS_ASSERT_PTR_NON_NULL(config, NULL); 912 913 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 914 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 915 916 psMetadata *where = psMetadataAlloc(); 917 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 918 919 psString query = pxDataGet("stacktool_pendingcleanuprun.sql"); 920 if (!query) { 921 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 922 return false; 923 } 924 925 if (where && psListLength(where->list)) { 926 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 927 psStringAppend(&query, " AND %s", whereClause); 928 psFree(whereClause); 929 } 930 psFree(where); 931 932 // treat limit == 0 as "no limit" 933 if (limit) { 934 psString limitString = psDBGenerateLimitSQL(limit); 935 psStringAppend(&query, " %s", limitString); 936 psFree(limitString); 937 } 938 939 if (!p_psDBRunQuery(config->dbh, query)) { 940 psError(PS_ERR_UNKNOWN, false, "database error"); 941 psFree(query); 942 return false; 943 } 944 psFree(query); 945 946 psArray *output = p_psDBFetchResult(config->dbh); 947 if (!output) { 948 psError(PS_ERR_UNKNOWN, false, "database error"); 949 return false; 950 } 951 if (!psArrayLength(output)) { 952 psTrace("stacktool", PS_LOG_INFO, "no rows found"); 953 psFree(output); 954 return true; 955 } 956 957 // negative simple so the default is true 958 if (!ippdbPrintMetadatas(stdout, output, "stackPendingCleanupRun", !simple)) { 959 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 960 psFree(output); 961 return false; 962 } 963 964 psFree(output); 965 966 return true; 967 } 968 969 static bool pendingcleanupskyfileMode(pxConfig *config) 970 { 971 PS_ASSERT_PTR_NON_NULL(config, NULL); 972 973 PXOPT_LOOKUP_S64(stack_id, config->args, "-stack_id", false, false); 974 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 975 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 976 977 psMetadata *where = psMetadataAlloc(); 978 if (stack_id) { 979 PXOPT_COPY_S64(config->args, where, "-stack_id", "stack_id", "=="); 980 } 981 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 982 983 psString query = pxDataGet("stacktool_pendingcleanupskyfile.sql"); 984 if (!query) { 985 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 986 return false; 987 } 988 989 if (where && psListLength(where->list)) { 990 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 991 psStringAppend(&query, " AND %s", whereClause); 992 psFree(whereClause); 993 } 994 psFree(where); 995 996 // treat limit == 0 as "no limit" 997 if (limit) { 998 psString limitString = psDBGenerateLimitSQL(limit); 999 psStringAppend(&query, " %s", limitString); 1000 psFree(limitString); 1001 } 1002 1003 if (!p_psDBRunQuery(config->dbh, query)) { 1004 psError(PS_ERR_UNKNOWN, false, "database error"); 1005 psFree(query); 1006 return false; 1007 } 1008 psFree(query); 1009 1010 psArray *output = p_psDBFetchResult(config->dbh); 1011 if (!output) { 1012 psError(PS_ERR_UNKNOWN, false, "database error"); 1013 return false; 1014 } 1015 if (!psArrayLength(output)) { 1016 psTrace("stacktool", PS_LOG_INFO, "no rows found"); 1017 psFree(output); 1018 return true; 1019 } 1020 1021 // negative simple so the default is true 1022 if (!ippdbPrintMetadatas(stdout, output, "stackPendingCleanupSkyfile", !simple)) { 1023 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1024 psFree(output); 1025 return false; 1026 } 1027 1028 psFree(output); 1029 1030 return true; 1031 } 1032 1033 1034 static bool donecleanupMode(pxConfig *config) 1035 { 1036 PS_ASSERT_PTR_NON_NULL(config, NULL); 1037 1038 PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false); 1039 PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); 1040 1041 psMetadata *where = psMetadataAlloc(); 1042 PXOPT_COPY_STR(config->args, where, "-label", "label", "=="); 1043 1044 psString query = pxDataGet("stacktool_donecleanup.sql"); 1045 if (!query) { 1046 psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); 1047 return false; 1048 } 1049 1050 if (where && psListLength(where->list)) { 1051 psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); 1052 psStringAppend(&query, " AND %s", whereClause); 1053 psFree(whereClause); 1054 } 1055 psFree(where); 1056 1057 // treat limit == 0 as "no limit" 1058 if (limit) { 1059 psString limitString = psDBGenerateLimitSQL(limit); 1060 psStringAppend(&query, " %s", limitString); 1061 psFree(limitString); 1062 } 1063 1064 if (!p_psDBRunQuery(config->dbh, query)) { 1065 psError(PS_ERR_UNKNOWN, false, "database error"); 1066 psFree(query); 1067 return false; 1068 } 1069 psFree(query); 1070 1071 psArray *output = p_psDBFetchResult(config->dbh); 1072 if (!output) { 1073 psError(PS_ERR_UNKNOWN, false, "database error"); 1074 return false; 1075 } 1076 if (!psArrayLength(output)) { 1077 psTrace("stacktool", PS_LOG_INFO, "no rows found"); 1078 psFree(output); 1079 return true; 1080 } 1081 1082 // negative simple so the default is true 1083 if (!ippdbPrintMetadatas(stdout, output, "stackDoneCleanup", !simple)) { 1084 psError(PS_ERR_UNKNOWN, false, "failed to print array"); 1085 psFree(output); 1086 return false; 1087 } 1088 1089 psFree(output); 1090 1091 return true; 1092 }
Note:
See TracChangeset
for help on using the changeset viewer.
