1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943
|
/*___INFO__MARK_BEGIN__*/
/*************************************************************************
*
* The Contents of this file are made available subject to the terms of
* the Sun Industry Standards Source License Version 1.2
*
* Sun Microsystems Inc., March, 2001
*
*
* Sun Industry Standards Source License Version 1.2
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.2 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2001 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
************************************************************************/
/*___INFO__MARK_END__*/
#include <stdlib.h>
#include <sys/types.h>
#include <pthread.h>
#include <stdio.h>
#include <errno.h>
#include <signal.h>
#include <string.h>
#include "uti/sge_rmon.h"
#include "uti/sge_time.h"
#include "uti/sge_profiling.h"
#include "uti/sge_unistd.h"
#include "uti/sge_log.h"
#include "cull/cull_list.h"
#include "sgeobj/sge_event.h"
#include "sgeobj/sge_calendar.h"
#include "sgeobj/sge_ckpt.h"
#include "sgeobj/sge_conf.h"
#include "sgeobj/sge_host.h"
#include "sgeobj/sge_hgroup.h"
#include "sgeobj/sge_job.h"
#include "sgeobj/sge_ja_task.h"
#include "sgeobj/sge_pe_task.h"
#include "sgeobj/sge_manop.h"
#include "sgeobj/sge_pe.h"
#include "sgeobj/sge_schedd_conf.h"
#include "sgeobj/sge_sharetree.h"
#include "sgeobj/sge_cuser.h"
#include "sgeobj/sge_userprj.h"
#include "sgeobj/sge_userset.h"
#include "sgeobj/sge_answer.h"
#include "sgeobj/sge_hgroup.h"
#include "sgeobj/sge_host.h"
#include "evc/msg_evclib.h"
#include "mir/msg_mirlib.h"
#include "mir/sge_host_mirror.h"
#include "mir/sge_queue_mirror.h"
#include "mir/sge_job_mirror.h"
#include "mir/sge_ja_task_mirror.h"
#include "mir/sge_pe_task_mirror.h"
#include "mir/sge_sharetree_mirror.h"
#include "mir/sge_sched_conf_mirror.h"
#include "mir/sge_mirror.h"
#include "gdi/sge_gdi_ctx.h"
#include "sig_handlers.h"
/* Datastructure for internal storage of subscription information
* and callbacks.
*/
typedef struct {
sge_mirror_callback callback_before; /* callback before mirroring */
sge_mirror_callback callback_default; /* default mirroring function */
sge_mirror_callback callback_after; /* callback after mirroring */
void *clientdata; /* client data passed to callback */
} mirror_description;
static sge_mirror_error
sge_mirror_process_event_list_(sge_evc_class_t *evc, lList *event_list);
#ifdef SOLARIS
#pragma no_inline(sge_mirror_process_event_list,sge_mirror_process_event_list_)
#endif
static sge_mirror_error
_sge_mirror_subscribe(sge_evc_class_t *evc,
sge_object_type type, sge_mirror_callback callback_before,
sge_mirror_callback callback_after, void *clientdata,
const lCondition *where, const lEnumeration *what);
static sge_mirror_error
_sge_mirror_unsubscribe(sge_evc_class_t *evc, sge_object_type type);
static void
sge_mirror_free_list(sge_object_type type);
static sge_mirror_error
sge_mirror_process_event(sge_evc_class_t *evc,
mirror_description *mirror_base,
object_description *object_base,
sge_object_type type,
sge_event_action action,
lListElem *event);
static sge_callback_result
sge_mirror_process_shutdown(sge_evc_class_t *evc,
object_description *object_base,
sge_object_type type,
sge_event_action action,
lListElem *event,
void *clientdata);
static sge_callback_result
sge_mirror_process_mark4registration(sge_evc_class_t *evc,
object_description *object_base,
sge_object_type type,
sge_event_action action,
lListElem *event,
void *clientdata);
static sge_callback_result
generic_update_master_list(sge_evc_class_t *evc,
object_description *object_base,
sge_object_type type,
sge_event_action action,
lListElem *event,
void *clientdata);
static sge_callback_result
ar_update_master_list(sge_evc_class_t *evc, object_description *object_base, sge_object_type type,
sge_event_action action, lListElem *event, void *clientdata);
static
sge_mirror_error sge_mirror_update_master_list_ar_key(lList **list, const lDescr *list_descr,
int key_nm, const char *key,
sge_event_action action, lListElem *event);
/*
* One entry per event type, this is the basic definition.
* Each thread will have its own table based on this one.
*/
static const mirror_description dev_mirror_base[SGE_TYPE_ALL] = {
/*cbb cbd cba cd */
{ NULL, host_update_master_list, NULL, NULL },
{ NULL, generic_update_master_list, NULL, NULL },
{ NULL, generic_update_master_list, NULL, NULL },
{ NULL, generic_update_master_list, NULL, NULL },
{ NULL, NULL, NULL, NULL },
{ NULL, host_update_master_list, NULL, NULL },
{ NULL, ja_task_update_master_list, NULL, NULL },
{ NULL, pe_task_update_master_list, NULL, NULL },
{ NULL, job_update_master_list, NULL, NULL },
{ NULL, job_schedd_info_update_master_list, NULL, NULL },
{ NULL, generic_update_master_list, NULL, NULL },
{ NULL, generic_update_master_list, NULL, NULL },
{ NULL, sharetree_update_master_list, NULL, NULL },
{ NULL, generic_update_master_list, NULL, NULL },
{ NULL, generic_update_master_list, NULL, NULL },
{ NULL, cqueue_update_master_list, NULL, NULL },
{ NULL, qinstance_update_cqueue_list, NULL, NULL },
{ NULL, schedd_conf_update_master_list, NULL, NULL },
{ NULL, NULL, NULL, NULL },
{ NULL, sge_mirror_process_shutdown, NULL, NULL },
{ NULL, sge_mirror_process_mark4registration, NULL, NULL },
{ NULL, host_update_master_list, NULL, NULL },
{ NULL, generic_update_master_list, NULL, NULL },
{ NULL, generic_update_master_list, NULL, NULL },
{ NULL, host_update_master_list, NULL, NULL }, /*hgroup*/
{ NULL, generic_update_master_list, NULL, NULL },
{ NULL, generic_update_master_list, NULL, NULL }, /*zombie*/
{ NULL, generic_update_master_list, NULL, NULL }, /*suser*/
{ NULL, generic_update_master_list, NULL, NULL }, /*rqs*/
{ NULL, ar_update_master_list, NULL, NULL }, /*advance reservation*/
{ NULL, NULL, NULL, NULL }, /*jobscripts*/
#ifndef __SGE_NO_USERMAPPING__
{ NULL, NULL, NULL, NULL },
#endif
};
/*-------------------------*/
/* multithreading support. */
/*-------------------------*/
typedef struct {
bool produce_qmaster_alive_timeout; /* used to produce qmaster alive timeout when
* SGE_PRODUCE_ALIVE_TIMEOUT_ERROR environment
* variable is set. */
mirror_description mirror_base[SGE_TYPE_ALL]; /* subscription handlers */
} mir_state_t;
static pthread_key_t mir_state_key;
static pthread_once_t mir_once_control = PTHREAD_ONCE_INIT;
static void mir_state_init(mir_state_t* state)
{
int i;
/*
* if environment varialbe SGE_PRODUCE_ALIVE_TIMEOUT_ERROR
* is defined, the mirror event client will produce qmaster
* alive timeout errors and reconnect to qmaster
*/
if (getenv("SGE_PRODUCE_ALIVE_TIMEOUT_ERROR")) {
state->produce_qmaster_alive_timeout = true;
} else {
state->produce_qmaster_alive_timeout = false;
}
/* initialize mirroring data structures - only changeable fields */
for (i = 0; i < SGE_TYPE_ALL; i++) {
state->mirror_base[i].callback_before = NULL;
state->mirror_base[i].callback_after = NULL;
state->mirror_base[i].callback_default = dev_mirror_base[i].callback_default;
state->mirror_base[i].clientdata = NULL;
}
}
static void mir_state_destroy(void* state)
{
sge_free(&state);
}
static void mir_mt_init(void)
{
pthread_key_create(&mir_state_key, &mir_state_destroy);
}
static bool mir_get_produce_qmaster_alive_timeout(void)
{
GET_SPECIFIC(mir_state_t, mir_state, mir_state_init, mir_state_key, "mir_get_produce_qmaster_alive_timeout");
return mir_state->produce_qmaster_alive_timeout;
}
static mirror_description *mir_get_mirror_base(void)
{
GET_SPECIFIC(mir_state_t, mir_state, mir_state_init, mir_state_key, "mir_get_mirror_base");
return mir_state->mirror_base;
}
/*----------------------------*/
/* End multithreading support */
/*----------------------------*/
/****** Eventmirror/sge_mirror_initialize() ********************************************
* NAME
* sge_mirror_initialize() -- initialize a process local event mirror interface
*
* SYNOPSIS
* sge_mirror_error sge_mirror_initialize(ev_registration_id id,
* const char *name)
*
* FUNCTION
* Initializes internal data structures and registers with qmaster
* using the event client mechanisms.
*
* Events covering shutdown requests and qmaster shutdown notification
* are subscribed.
*
* INPUTS
* ev_registration_id id - id used to register with qmaster
* const char *name - name used to register with qmaster a
* bool use_global_date - if that to true, the implemenation is not thread
* save anymore. This setting is to ensure, that
* old code is still working, without beeing rewritten.
* if false is put inhere, the mirror interface is
* thread save. The current implementation has a limit,
* which is, that only one thread can work on the mirror
* data at a time, since it is stored as thread global.
* event_client_update_func_t - a function which knows on how to handle new events.
* The events are stored by this function and not send
* out.
*
* RESULT
* sge_mirror_error - SGE_EM_OK or an error code
*
* SEE ALSO
* Eventmirror/sge_mirror_shutdown()
* Eventclient/-ID-numbers
*******************************************************************************/
sge_mirror_error
sge_mirror_initialize(sge_evc_class_t *evc, ev_registration_id id, const char *name,
bool use_global_data, event_client_update_func_t update_func,
evm_mod_func_t mod_func, evm_add_func_t add_func,
evm_remove_func_t remove_func, evm_ack_func_t ack_func)
{
DENTER(TOP_LAYER, "sge_mirror_initialize");
evc->ec_local.update_func = update_func;
evc->ec_local.mod_func = mod_func;
evc->ec_local.add_func = add_func;
evc->ec_local.remove_func = remove_func;
evc->ec_local.ack_func = ack_func;
evc->ec_local.init = true;
pthread_once(&mir_once_control, mir_mt_init);
obj_init(use_global_data);
/* subscribe some events with default handling */
sge_mirror_subscribe(evc, SGE_TYPE_SHUTDOWN, NULL, NULL, NULL, NULL, NULL);
sge_mirror_subscribe(evc, SGE_TYPE_MARK_4_REGISTRATION, NULL, NULL, NULL, NULL, NULL);
/* register with qmaster */
evc->ec_commit(evc, NULL);
DRETURN(SGE_EM_OK);
}
/****** Eventmirror/sge_mirror_shutdown() ***************************************
* NAME
* sge_mirror_shutdown() -- shutdown mirroring
*
* SYNOPSIS
* sge_mirror_error sge_mirror_shutdown(void)
*
* FUNCTION
* Shuts down the event mirroring mechanism:
* Unsubscribes all events, deletes contents of the corresponding
* object lists and deregisteres from qmaster.
*
* RESULT
* sge_mirror_error - SGE_EM_OK or error code
*
* SEE ALSO
* Eventmirror/sge_mirror_initialize()
*******************************************************************************/
sge_mirror_error sge_mirror_shutdown(sge_evc_class_t *evc)
{
DENTER(TOP_LAYER, "sge_mirror_shutdown");
if (evc && evc->ec_is_initialized(evc)) {
sge_mirror_unsubscribe(evc, SGE_TYPE_ALL);
evc->ec_deregister(evc);
}
DRETURN(SGE_EM_OK);
}
/****** Eventmirror/sge_mirror_subscribe() **************************************
* NAME
* sge_mirror_subscribe() -- subscribe certain event types
*
* SYNOPSIS
* sge_mirror_error sge_mirror_subscribe(sge_object_type type,
* sge_mirror_callback callback_before,
* sge_mirror_callback callback_after,
* void *clientdata)
*
* FUNCTION
* Subscribe a certain event type.
* Callback functions can be specified, that can be executed before the
* mirroring action and/or after the mirroring action.
*
* The corresponding data structures are initialized,
* the events associated with the event type are subscribed with the
* event client interface.
*
* INPUTS
* lListElem *event client - event client to work with
* sge_object_type type - event type to subscribe or
* SGE_TYPE_ALL
* sge_mirror_callback callback_before - callback to be executed before
* mirroring
* sge_mirror_callback callback_after - callback to be executed after
* mirroring
* void *clientdata - clientdata to be passed to the
* callback functions
*
* RESULT
* sge_mirror_error - SGE_EM_OK or an error code
*
* SEE ALSO
* Eventmirror/-Eventmirror-Typedefs
* Eventclient/-Subscription
* Eventclient/-Events
* Eventmirror/sge_mirror_unsubscribe()
*******************************************************************************/
sge_mirror_error sge_mirror_subscribe(sge_evc_class_t *evc,
sge_object_type type,
sge_mirror_callback callback_before,
sge_mirror_callback callback_after,
void *clientdata,
const lCondition *where,
const lEnumeration *what)
{
sge_mirror_error ret = SGE_EM_OK;
DENTER(TOP_LAYER, "sge_mirror_subscribe");
if (type < 0 || type > SGE_TYPE_ALL) {
ERROR((SGE_EVENT, MSG_MIRROR_INVALID_OBJECT_TYPE_SI, SGE_FUNC, type));
DRETURN(SGE_EM_BAD_ARG);
}
if (type == SGE_TYPE_ALL) {
sge_object_type i;
for (i = SGE_TYPE_ADMINHOST; i < SGE_TYPE_ALL; i++) {
_sge_mirror_subscribe(evc, i, callback_before, callback_after, clientdata, NULL, NULL);
}
} else {
ret = _sge_mirror_subscribe(evc, type, callback_before, callback_after, clientdata, where, what);
}
DRETURN(ret);
}
static sge_mirror_error
_sge_mirror_subscribe(sge_evc_class_t *evc,
sge_object_type type,
sge_mirror_callback callback_before,
sge_mirror_callback callback_after,
void *clientdata,
const lCondition *where, const lEnumeration *what)
{
lListElem *what_el = lWhatToElem(what);
lListElem *where_el = lWhereToElem(where);
/* type already has been checked before */
switch (type) {
case SGE_TYPE_ADMINHOST:
evc->ec_subscribe(evc, sgeE_ADMINHOST_LIST);
evc->ec_subscribe(evc, sgeE_ADMINHOST_ADD);
evc->ec_subscribe(evc, sgeE_ADMINHOST_DEL);
evc->ec_subscribe(evc, sgeE_ADMINHOST_MOD);
if (what_el && where_el) {
evc->ec_mod_subscription_where(evc, sgeE_ADMINHOST_MOD, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_ADMINHOST_DEL, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_ADMINHOST_ADD, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_ADMINHOST_LIST, what_el, where_el);
}
break;
case SGE_TYPE_CALENDAR:
evc->ec_subscribe(evc, sgeE_CALENDAR_LIST);
evc->ec_subscribe(evc, sgeE_CALENDAR_ADD);
evc->ec_subscribe(evc, sgeE_CALENDAR_DEL);
evc->ec_subscribe(evc, sgeE_CALENDAR_MOD);
if (what_el && where_el) {
evc->ec_mod_subscription_where(evc, sgeE_CALENDAR_LIST, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_CALENDAR_ADD, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_CALENDAR_DEL, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_CALENDAR_MOD, what_el, where_el);
}
break;
case SGE_TYPE_CKPT:
evc->ec_subscribe(evc, sgeE_CKPT_LIST);
evc->ec_subscribe(evc, sgeE_CKPT_ADD);
evc->ec_subscribe(evc, sgeE_CKPT_DEL);
evc->ec_subscribe(evc, sgeE_CKPT_MOD);
if (what_el && where_el) {
evc->ec_mod_subscription_where(evc, sgeE_CKPT_LIST, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_CKPT_ADD, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_CKPT_DEL, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_CKPT_MOD, what_el, where_el);
}
break;
case SGE_TYPE_CENTRY:
evc->ec_subscribe(evc, sgeE_CENTRY_LIST);
evc->ec_subscribe(evc, sgeE_CENTRY_ADD);
evc->ec_subscribe(evc, sgeE_CENTRY_DEL);
evc->ec_subscribe(evc, sgeE_CENTRY_MOD);
if (what_el && where_el) {
evc->ec_mod_subscription_where(evc, sgeE_CENTRY_LIST, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_CENTRY_ADD, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_CENTRY_DEL, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_CENTRY_MOD, what_el, where_el);
}
break;
case SGE_TYPE_CONFIG:
evc->ec_subscribe(evc, sgeE_CONFIG_LIST);
evc->ec_subscribe(evc, sgeE_CONFIG_ADD);
evc->ec_subscribe(evc, sgeE_CONFIG_DEL);
evc->ec_subscribe(evc, sgeE_CONFIG_MOD);
if (what_el && where_el) {
evc->ec_mod_subscription_where(evc, sgeE_CONFIG_LIST, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_CONFIG_ADD, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_CONFIG_DEL, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_CONFIG_MOD, what_el, where_el);
}
break;
case SGE_TYPE_GLOBAL_CONFIG:
evc->ec_subscribe(evc, sgeE_GLOBAL_CONFIG);
/* regard it as a sort of trigger
* in fact this event is not needed!
* it doesn't even contain the config data!
* it is sent before the CONFIG_MOD event, so
* the receiver cannot even properly react to it!
*/
if (what_el && where_el) {
evc->ec_mod_subscription_where(evc, sgeE_GLOBAL_CONFIG, what_el, where_el);
}
break;
case SGE_TYPE_EXECHOST:
evc->ec_subscribe(evc, sgeE_EXECHOST_LIST);
evc->ec_subscribe(evc, sgeE_EXECHOST_ADD);
evc->ec_subscribe(evc, sgeE_EXECHOST_DEL);
evc->ec_subscribe(evc, sgeE_EXECHOST_MOD);
if (what_el && where_el) {
evc->ec_mod_subscription_where(evc, sgeE_EXECHOST_LIST, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_EXECHOST_ADD, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_EXECHOST_DEL, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_EXECHOST_MOD, what_el, where_el);
}
break;
case SGE_TYPE_JATASK:
evc->ec_subscribe(evc, sgeE_JATASK_ADD);
evc->ec_subscribe(evc, sgeE_JATASK_DEL);
evc->ec_subscribe(evc, sgeE_JATASK_MOD);
if (what_el && where_el) {
evc->ec_mod_subscription_where(evc, sgeE_JATASK_ADD, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_JATASK_DEL, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_JATASK_MOD, what_el, where_el);
}
break;
case SGE_TYPE_PETASK:
evc->ec_subscribe(evc, sgeE_PETASK_ADD);
evc->ec_subscribe(evc, sgeE_PETASK_DEL);
if (what_el && where_el) {
evc->ec_mod_subscription_where(evc, sgeE_PETASK_ADD, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_PETASK_DEL, what_el, where_el);
}
break;
case SGE_TYPE_JOB:
evc->ec_subscribe(evc, sgeE_JOB_LIST);
evc->ec_subscribe(evc, sgeE_JOB_ADD);
evc->ec_subscribe(evc, sgeE_JOB_DEL);
evc->ec_subscribe(evc, sgeE_JOB_MOD);
evc->ec_subscribe(evc, sgeE_JOB_MOD_SCHED_PRIORITY);
if (what_el && where_el) {
evc->ec_mod_subscription_where(evc, sgeE_JOB_LIST, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_JOB_ADD, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_JOB_DEL, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_JOB_MOD, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_JOB_MOD_SCHED_PRIORITY, what_el, where_el);
}
/* TODO: SG: what and where for usage */
evc->ec_subscribe(evc, sgeE_JOB_USAGE);
evc->ec_subscribe(evc, sgeE_JOB_FINAL_USAGE);
break;
case SGE_TYPE_JOB_SCHEDD_INFO:
evc->ec_subscribe(evc, sgeE_JOB_SCHEDD_INFO_LIST);
evc->ec_subscribe(evc, sgeE_JOB_SCHEDD_INFO_ADD);
evc->ec_subscribe(evc, sgeE_JOB_SCHEDD_INFO_DEL);
evc->ec_subscribe(evc, sgeE_JOB_SCHEDD_INFO_MOD);
if (what_el && where_el) {
evc->ec_mod_subscription_where(evc, sgeE_JOB_SCHEDD_INFO_LIST, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_JOB_SCHEDD_INFO_ADD, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_JOB_SCHEDD_INFO_DEL, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_JOB_SCHEDD_INFO_MOD, what_el, where_el);
}
break;
case SGE_TYPE_MANAGER:
evc->ec_subscribe(evc, sgeE_MANAGER_LIST);
evc->ec_subscribe(evc, sgeE_MANAGER_ADD);
evc->ec_subscribe(evc, sgeE_MANAGER_DEL);
evc->ec_subscribe(evc, sgeE_MANAGER_MOD);
if (what_el && where_el) {
evc->ec_mod_subscription_where(evc, sgeE_MANAGER_LIST, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_MANAGER_ADD, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_MANAGER_DEL, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_MANAGER_MOD, what_el, where_el);
}
break;
case SGE_TYPE_OPERATOR:
evc->ec_subscribe(evc, sgeE_OPERATOR_LIST);
evc->ec_subscribe(evc, sgeE_OPERATOR_ADD);
evc->ec_subscribe(evc, sgeE_OPERATOR_DEL);
evc->ec_subscribe(evc, sgeE_OPERATOR_MOD);
if (what_el && where_el) {
evc->ec_mod_subscription_where(evc, sgeE_OPERATOR_LIST, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_OPERATOR_ADD, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_OPERATOR_DEL, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_OPERATOR_MOD, what_el, where_el);
}
break;
case SGE_TYPE_SHARETREE:
evc->ec_subscribe(evc, sgeE_NEW_SHARETREE);
if (what_el && where_el) {
evc->ec_mod_subscription_where(evc, sgeE_NEW_SHARETREE, what_el, where_el);
}
break;
case SGE_TYPE_PE:
evc->ec_subscribe(evc, sgeE_PE_LIST);
evc->ec_subscribe(evc, sgeE_PE_ADD);
evc->ec_subscribe(evc, sgeE_PE_DEL);
evc->ec_subscribe(evc, sgeE_PE_MOD);
if (what_el && where_el) {
evc->ec_mod_subscription_where(evc, sgeE_PE_LIST, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_PE_ADD, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_PE_DEL, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_PE_MOD, what_el, where_el);
}
break;
case SGE_TYPE_PROJECT:
evc->ec_subscribe(evc, sgeE_PROJECT_LIST);
evc->ec_subscribe(evc, sgeE_PROJECT_ADD);
evc->ec_subscribe(evc, sgeE_PROJECT_DEL);
evc->ec_subscribe(evc, sgeE_PROJECT_MOD);
if (what_el && where_el) {
evc->ec_mod_subscription_where(evc, sgeE_PROJECT_LIST, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_PROJECT_ADD, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_PROJECT_DEL, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_PROJECT_MOD, what_el, where_el);
}
break;
case SGE_TYPE_CQUEUE:
evc->ec_subscribe(evc, sgeE_CQUEUE_LIST);
evc->ec_subscribe(evc, sgeE_CQUEUE_ADD);
evc->ec_subscribe(evc, sgeE_CQUEUE_DEL);
evc->ec_subscribe(evc, sgeE_CQUEUE_MOD);
if (what_el && where_el) {
evc->ec_mod_subscription_where(evc, sgeE_CQUEUE_LIST, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_CQUEUE_ADD, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_CQUEUE_DEL, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_CQUEUE_MOD, what_el, where_el);
}
break;
case SGE_TYPE_QINSTANCE:
evc->ec_subscribe(evc, sgeE_QINSTANCE_ADD);
evc->ec_subscribe(evc, sgeE_QINSTANCE_DEL);
evc->ec_subscribe(evc, sgeE_QINSTANCE_MOD);
evc->ec_subscribe(evc, sgeE_QINSTANCE_SOS);
evc->ec_subscribe(evc, sgeE_QINSTANCE_USOS);
if (what_el && where_el) {
evc->ec_mod_subscription_where(evc, sgeE_QINSTANCE_ADD, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_QINSTANCE_DEL, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_QINSTANCE_MOD, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_QINSTANCE_SOS, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_QINSTANCE_USOS, what_el, where_el);
}
break;
case SGE_TYPE_SCHEDD_CONF:
evc->ec_subscribe(evc, sgeE_SCHED_CONF);
if (what_el && where_el) {
evc->ec_mod_subscription_where(evc, sgeE_SCHED_CONF, what_el, where_el);
}
break;
case SGE_TYPE_SCHEDD_MONITOR:
evc->ec_subscribe(evc, sgeE_SCHEDDMONITOR);
if (what_el && where_el) {
evc->ec_mod_subscription_where(evc, sgeE_SCHEDDMONITOR, what_el, where_el);
}
break;
case SGE_TYPE_SHUTDOWN:
evc->ec_subscribe_flush(evc, sgeE_SHUTDOWN, 0);
if (what_el && where_el) {
evc->ec_mod_subscription_where(evc, sgeE_SHUTDOWN, what_el, where_el);
}
break;
case SGE_TYPE_MARK_4_REGISTRATION:
evc->ec_subscribe_flush(evc, sgeE_QMASTER_GOES_DOWN, 0);
evc->ec_subscribe_flush(evc, sgeE_ACK_TIMEOUT, 0);
if (what_el && where_el) {
evc->ec_mod_subscription_where(evc, sgeE_QMASTER_GOES_DOWN, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_ACK_TIMEOUT, what_el, where_el);
}
break;
case SGE_TYPE_SUBMITHOST:
evc->ec_subscribe(evc, sgeE_SUBMITHOST_LIST);
evc->ec_subscribe(evc, sgeE_SUBMITHOST_ADD);
evc->ec_subscribe(evc, sgeE_SUBMITHOST_DEL);
evc->ec_subscribe(evc, sgeE_SUBMITHOST_MOD);
if (what_el && where_el) {
evc->ec_mod_subscription_where(evc, sgeE_SUBMITHOST_LIST, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_SUBMITHOST_ADD, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_SUBMITHOST_DEL, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_SUBMITHOST_MOD, what_el, where_el);
}
break;
case SGE_TYPE_USER:
evc->ec_subscribe(evc, sgeE_USER_LIST);
evc->ec_subscribe(evc, sgeE_USER_ADD);
evc->ec_subscribe(evc, sgeE_USER_DEL);
evc->ec_subscribe(evc, sgeE_USER_MOD);
if (what_el && where_el) {
evc->ec_mod_subscription_where(evc, sgeE_USER_LIST, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_USER_ADD, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_USER_DEL, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_USER_MOD, what_el, where_el);
}
break;
case SGE_TYPE_USERSET:
evc->ec_subscribe(evc, sgeE_USERSET_LIST);
evc->ec_subscribe(evc, sgeE_USERSET_ADD);
evc->ec_subscribe(evc, sgeE_USERSET_DEL);
evc->ec_subscribe(evc, sgeE_USERSET_MOD);
if (what_el && where_el) {
evc->ec_mod_subscription_where(evc, sgeE_USERSET_LIST, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_USERSET_ADD, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_USERSET_DEL, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_USERSET_MOD, what_el, where_el);
}
break;
case SGE_TYPE_HGROUP:
evc->ec_subscribe(evc, sgeE_HGROUP_LIST);
evc->ec_subscribe(evc, sgeE_HGROUP_ADD);
evc->ec_subscribe(evc, sgeE_HGROUP_DEL);
evc->ec_subscribe(evc, sgeE_HGROUP_MOD);
if (what_el && where_el) {
evc->ec_mod_subscription_where(evc, sgeE_HGROUP_LIST, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_HGROUP_ADD, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_HGROUP_DEL, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_HGROUP_MOD, what_el, where_el);
}
break;
case SGE_TYPE_RQS:
evc->ec_subscribe(evc, sgeE_RQS_LIST);
evc->ec_subscribe(evc, sgeE_RQS_ADD);
evc->ec_subscribe(evc, sgeE_RQS_DEL);
evc->ec_subscribe(evc, sgeE_RQS_MOD);
if (what_el && where_el) {
evc->ec_mod_subscription_where(evc, sgeE_RQS_LIST, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_RQS_ADD, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_RQS_DEL, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_RQS_MOD, what_el, where_el);
}
break;
#ifndef __SGE_NO_USERMAPPING__
case SGE_TYPE_CUSER:
evc->ec_subscribe(evc, sgeE_CUSER_LIST);
evc->ec_subscribe(evc, sgeE_CUSER_ADD);
evc->ec_subscribe(evc, sgeE_CUSER_DEL);
evc->ec_subscribe(evc, sgeE_CUSER_MOD);
if (what_el && where_el) {
evc->ec_mod_subscription_where(evc, sgeE_CUSER_LIST, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_CUSER_ADD, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_CUSER_DEL, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_CUSER_MOD, what_el, where_el);
}
break;
#endif
case SGE_TYPE_ZOMBIE:
return SGE_EM_NOT_INITIALIZED;
case SGE_TYPE_SUSER:
return SGE_EM_NOT_INITIALIZED;
case SGE_TYPE_AR:
evc->ec_subscribe(evc, sgeE_AR_LIST);
evc->ec_subscribe(evc, sgeE_AR_ADD);
evc->ec_subscribe(evc, sgeE_AR_DEL);
evc->ec_subscribe(evc, sgeE_AR_MOD);
if (what_el && where_el) {
evc->ec_mod_subscription_where(evc, sgeE_AR_LIST, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_AR_ADD, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_AR_DEL, what_el, where_el);
evc->ec_mod_subscription_where(evc, sgeE_AR_MOD, what_el, where_el);
}
break;
case SGE_TYPE_JOBSCRIPT:
return SGE_EM_NOT_INITIALIZED;
default:
return SGE_EM_BAD_ARG;
}
{ /* install callback function */
mirror_description *mirror_base = mir_get_mirror_base();
mirror_base[type].callback_before = callback_before;
mirror_base[type].callback_after = callback_after;
mirror_base[type].clientdata = clientdata;
}
lFreeElem(&where_el);
lFreeElem(&what_el);
return SGE_EM_OK;
}
/****** Eventmirror/sge_mirror_unsubscribe() ************************************
* NAME
* sge_mirror_unsubscribe() -- unsubscribe event types
*
* SYNOPSIS
* sge_mirror_error sge_mirror_unsubscribe(sge_object_type type)
*
* FUNCTION
* Unsubscribes a certain event type or all if SGE_TYPE_ALL is given as type.
*
* Unsubscribes the corresponding events in the underlying event client
* interface and frees data stored in the corresponding mirrored list(s).
* INPUTS
* sge_object_type type - the event type to unsubscribe or SGE_TYPE_ALL
*
* RESULT
* sge_mirror_error - SGE_EM_OK or an error code
*
* SEE ALSO
* Eventmirror/-Eventmirror-Typedefs
* Eventclient/-Subscription
* Eventclient/-Events
* Eventmirror/sge_mirror_subscribe()
*******************************************************************************/
sge_mirror_error sge_mirror_unsubscribe(sge_evc_class_t *evc, sge_object_type type)
{
sge_mirror_error ret = SGE_EM_OK;
DENTER(TOP_LAYER, "sge_mirror_unsubscribe");
if (type < 0 || type > SGE_TYPE_ALL) {
ERROR((SGE_EVENT, MSG_MIRROR_INVALID_OBJECT_TYPE_SI, SGE_FUNC, type));
DRETURN(SGE_EM_BAD_ARG);
}
if (type == SGE_TYPE_ALL) {
sge_object_type i;
for (i = SGE_TYPE_ADMINHOST; i < SGE_TYPE_ALL; i++) {
if (i != SGE_TYPE_SHUTDOWN && i != SGE_TYPE_MARK_4_REGISTRATION) {
_sge_mirror_unsubscribe(evc, i);
}
}
} else {
ret = _sge_mirror_unsubscribe(evc, type);
}
DRETURN(ret);
}
static sge_mirror_error _sge_mirror_unsubscribe(sge_evc_class_t *evc, sge_object_type type)
{
mirror_description *mirror_base = mir_get_mirror_base();
DENTER(TOP_LAYER, "_sge_mirror_unsubscribe");
/* type has been checked in calling function - clear callback information */
mirror_base[type].callback_before = NULL;
mirror_base[type].callback_after = NULL;
mirror_base[type].clientdata = NULL;
switch (type) {
case SGE_TYPE_ADMINHOST:
evc->ec_unsubscribe(evc, sgeE_ADMINHOST_LIST);
evc->ec_unsubscribe(evc, sgeE_ADMINHOST_ADD);
evc->ec_unsubscribe(evc, sgeE_ADMINHOST_DEL);
evc->ec_unsubscribe(evc, sgeE_ADMINHOST_MOD);
break;
case SGE_TYPE_CALENDAR:
evc->ec_unsubscribe(evc, sgeE_CALENDAR_LIST);
evc->ec_unsubscribe(evc, sgeE_CALENDAR_ADD);
evc->ec_unsubscribe(evc, sgeE_CALENDAR_DEL);
evc->ec_unsubscribe(evc, sgeE_CALENDAR_MOD);
break;
case SGE_TYPE_CKPT:
evc->ec_unsubscribe(evc, sgeE_CKPT_LIST);
evc->ec_unsubscribe(evc, sgeE_CKPT_ADD);
evc->ec_unsubscribe(evc, sgeE_CKPT_DEL);
evc->ec_unsubscribe(evc, sgeE_CKPT_MOD);
break;
case SGE_TYPE_CENTRY:
evc->ec_unsubscribe(evc, sgeE_CENTRY_LIST);
evc->ec_unsubscribe(evc, sgeE_CENTRY_ADD);
evc->ec_unsubscribe(evc, sgeE_CENTRY_DEL);
evc->ec_unsubscribe(evc, sgeE_CENTRY_MOD);
break;
case SGE_TYPE_CONFIG:
evc->ec_unsubscribe(evc, sgeE_CONFIG_LIST);
evc->ec_unsubscribe(evc, sgeE_CONFIG_ADD);
evc->ec_unsubscribe(evc, sgeE_CONFIG_DEL);
evc->ec_unsubscribe(evc, sgeE_CONFIG_MOD);
break;
case SGE_TYPE_GLOBAL_CONFIG:
evc->ec_unsubscribe(evc, sgeE_GLOBAL_CONFIG);
break;
case SGE_TYPE_EXECHOST:
evc->ec_unsubscribe(evc, sgeE_EXECHOST_LIST);
evc->ec_unsubscribe(evc, sgeE_EXECHOST_ADD);
evc->ec_unsubscribe(evc, sgeE_EXECHOST_DEL);
evc->ec_unsubscribe(evc, sgeE_EXECHOST_MOD);
break;
case SGE_TYPE_JATASK:
evc->ec_unsubscribe(evc, sgeE_JATASK_ADD);
evc->ec_unsubscribe(evc, sgeE_JATASK_DEL);
evc->ec_unsubscribe(evc, sgeE_JATASK_MOD);
break;
case SGE_TYPE_PETASK:
evc->ec_unsubscribe(evc, sgeE_PETASK_ADD);
evc->ec_unsubscribe(evc, sgeE_PETASK_DEL);
break;
case SGE_TYPE_JOB:
evc->ec_unsubscribe(evc, sgeE_JOB_LIST);
evc->ec_unsubscribe(evc, sgeE_JOB_ADD);
evc->ec_unsubscribe(evc, sgeE_JOB_DEL);
evc->ec_unsubscribe(evc, sgeE_JOB_MOD);
evc->ec_unsubscribe(evc, sgeE_JOB_MOD_SCHED_PRIORITY);
evc->ec_unsubscribe(evc, sgeE_JOB_USAGE);
evc->ec_unsubscribe(evc, sgeE_JOB_FINAL_USAGE);
/* evc->ec_unsubscribe(evc, sgeE_JOB_FINISH); */
break;
case SGE_TYPE_JOB_SCHEDD_INFO:
evc->ec_unsubscribe(evc, sgeE_JOB_SCHEDD_INFO_LIST);
evc->ec_unsubscribe(evc, sgeE_JOB_SCHEDD_INFO_ADD);
evc->ec_unsubscribe(evc, sgeE_JOB_SCHEDD_INFO_DEL);
evc->ec_unsubscribe(evc, sgeE_JOB_SCHEDD_INFO_MOD);
break;
case SGE_TYPE_MANAGER:
evc->ec_unsubscribe(evc, sgeE_MANAGER_LIST);
evc->ec_unsubscribe(evc, sgeE_MANAGER_ADD);
evc->ec_unsubscribe(evc, sgeE_MANAGER_DEL);
evc->ec_unsubscribe(evc, sgeE_MANAGER_MOD);
break;
case SGE_TYPE_OPERATOR:
evc->ec_unsubscribe(evc, sgeE_OPERATOR_LIST);
evc->ec_unsubscribe(evc, sgeE_OPERATOR_ADD);
evc->ec_unsubscribe(evc, sgeE_OPERATOR_DEL);
evc->ec_unsubscribe(evc, sgeE_OPERATOR_MOD);
break;
case SGE_TYPE_SHARETREE:
evc->ec_unsubscribe(evc, sgeE_NEW_SHARETREE);
break;
case SGE_TYPE_PE:
evc->ec_unsubscribe(evc, sgeE_PE_LIST);
evc->ec_unsubscribe(evc, sgeE_PE_ADD);
evc->ec_unsubscribe(evc, sgeE_PE_DEL);
evc->ec_unsubscribe(evc, sgeE_PE_MOD);
break;
case SGE_TYPE_PROJECT:
evc->ec_unsubscribe(evc, sgeE_PROJECT_LIST);
evc->ec_unsubscribe(evc, sgeE_PROJECT_ADD);
evc->ec_unsubscribe(evc, sgeE_PROJECT_DEL);
evc->ec_unsubscribe(evc, sgeE_PROJECT_MOD);
break;
case SGE_TYPE_CQUEUE:
evc->ec_unsubscribe(evc, sgeE_CQUEUE_LIST);
evc->ec_unsubscribe(evc, sgeE_CQUEUE_ADD);
evc->ec_unsubscribe(evc, sgeE_CQUEUE_DEL);
evc->ec_unsubscribe(evc, sgeE_CQUEUE_MOD);
break;
case SGE_TYPE_QINSTANCE:
evc->ec_unsubscribe(evc, sgeE_QINSTANCE_ADD);
evc->ec_unsubscribe(evc, sgeE_QINSTANCE_DEL);
evc->ec_unsubscribe(evc, sgeE_QINSTANCE_MOD);
evc->ec_unsubscribe(evc, sgeE_QINSTANCE_SOS);
evc->ec_unsubscribe(evc, sgeE_QINSTANCE_USOS);
break;
case SGE_TYPE_SCHEDD_CONF:
evc->ec_unsubscribe(evc, sgeE_SCHED_CONF);
break;
case SGE_TYPE_SCHEDD_MONITOR:
evc->ec_unsubscribe(evc, sgeE_SCHEDDMONITOR);
break;
case SGE_TYPE_SHUTDOWN:
ERROR((SGE_EVENT, SFNMAX, MSG_EVENT_HAVETOHANDLEEVENTS));
break;
case SGE_TYPE_MARK_4_REGISTRATION:
ERROR((SGE_EVENT, SFNMAX, MSG_EVENT_HAVETOHANDLEEVENTS));
break;
case SGE_TYPE_SUBMITHOST:
evc->ec_unsubscribe(evc, sgeE_SUBMITHOST_LIST);
evc->ec_unsubscribe(evc, sgeE_SUBMITHOST_ADD);
evc->ec_unsubscribe(evc, sgeE_SUBMITHOST_DEL);
evc->ec_unsubscribe(evc, sgeE_SUBMITHOST_MOD);
break;
case SGE_TYPE_USER:
evc->ec_unsubscribe(evc, sgeE_USER_LIST);
evc->ec_unsubscribe(evc, sgeE_USER_ADD);
evc->ec_unsubscribe(evc, sgeE_USER_DEL);
evc->ec_unsubscribe(evc, sgeE_USER_MOD);
break;
case SGE_TYPE_USERSET:
evc->ec_unsubscribe(evc, sgeE_USERSET_LIST);
evc->ec_unsubscribe(evc, sgeE_USERSET_ADD);
evc->ec_unsubscribe(evc, sgeE_USERSET_DEL);
evc->ec_unsubscribe(evc, sgeE_USERSET_MOD);
break;
case SGE_TYPE_HGROUP:
evc->ec_unsubscribe(evc, sgeE_HGROUP_LIST);
evc->ec_unsubscribe(evc, sgeE_HGROUP_ADD);
evc->ec_unsubscribe(evc, sgeE_HGROUP_DEL);
evc->ec_unsubscribe(evc, sgeE_HGROUP_MOD);
break;
case SGE_TYPE_RQS:
evc->ec_unsubscribe(evc, sgeE_RQS_LIST);
evc->ec_unsubscribe(evc, sgeE_RQS_ADD);
evc->ec_unsubscribe(evc, sgeE_RQS_DEL);
evc->ec_unsubscribe(evc, sgeE_RQS_MOD);
break;
#ifndef __SGE_NO_USERMAPPING__
case SGE_TYPE_CUSER:
evc->ec_unsubscribe(evc, sgeE_CUSER_LIST);
evc->ec_unsubscribe(evc, sgeE_CUSER_ADD);
evc->ec_unsubscribe(evc, sgeE_CUSER_DEL);
evc->ec_unsubscribe(evc, sgeE_CUSER_MOD);
break;
#endif
case SGE_TYPE_ZOMBIE:
DRETURN(SGE_EM_NOT_INITIALIZED);
case SGE_TYPE_SUSER:
DRETURN(SGE_EM_NOT_INITIALIZED);
case SGE_TYPE_AR:
evc->ec_unsubscribe(evc, sgeE_AR_LIST);
evc->ec_unsubscribe(evc, sgeE_AR_ADD);
evc->ec_unsubscribe(evc, sgeE_AR_DEL);
evc->ec_unsubscribe(evc, sgeE_AR_MOD);
break;
case SGE_TYPE_JOBSCRIPT:
DRETURN(SGE_EM_NOT_INITIALIZED);
default:
ERROR((SGE_EVENT, "received invalid event group %d", type));
DRETURN(SGE_EM_BAD_ARG);
}
/* clear data */
sge_mirror_free_list(type);
DRETURN(SGE_EM_OK);
}
/****** Eventmirror/sge_mirror_process_events() *********************************
* NAME
* sge_mirror_process_events() -- retrieve and process events
*
* SYNOPSIS
* sge_mirror_error sge_mirror_process_events(void)
*
* FUNCTION
* Retrieves new events from qmaster.
* If new events have arrived from qmaster, they are processed,
* that means, for each event
* - if installed, a "before mirroring" callback is called
* - the event is mirrored into the corresponding master list
* - if installed, a "after mirroring" callback is called
*
* If retrieving new events from qmaster fails over a time period
* of 10 times the configured event delivery interval (see event
* client interface, function ec_get_edtime), a timeout warning
* is generated and a new registration of the event client is
* prepared.
*
* RESULT
* sge_mirror_error - SGE_EM_OK or an error code
*
* SEE ALSO
* Eventmirror/--Eventmirror
* Eventclient/Client/ec_get_edtime()
* Eventclient/Client/ec_set_edtime()
*******************************************************************************/
sge_mirror_error sge_mirror_process_events(sge_evc_class_t *evc)
{
lList *event_list = NULL;
sge_mirror_error ret = SGE_EM_OK;
static int test_debug = 0;
DENTER(TOP_LAYER, "sge_mirror_process_events");
if (evc && evc->ec_get(evc, &event_list, false)) {
if (event_list != NULL) {
ret = sge_mirror_process_event_list(evc, event_list);
lFreeList(&event_list);
}
} else {
WARNING((SGE_EVENT, SFNMAX, MSG_MIRROR_QMASTERALIVETIMEOUTEXPIRED));
evc->ec_mark4registration(evc);
ret = SGE_EM_TIMEOUT;
}
if (mir_get_produce_qmaster_alive_timeout()) {
test_debug++;
if (test_debug > 3) {
test_debug = 0;
WARNING((SGE_EVENT, SFNMAX, MSG_MIRROR_QMASTERALIVETIMEOUTEXPIRED));
evc->ec_mark4registration(evc);
ret = SGE_EM_TIMEOUT;
}
}
DRETURN(ret);
}
/****** Eventmirror/sge_mirror_strerror() ***************************************
* NAME
* sge_mirror_strerror() -- map errorcode to error message
*
* SYNOPSIS
* const char* sge_mirror_strerror(sge_mirror_error num)
*
* FUNCTION
* Returns a string describing a given error number.
* This function can be used to output error messages
* if a function of the event mirror interface fails.
*
* INPUTS
* sge_mirror_error num - error number
*
* RESULT
* const char* - corresponding error message
*
* SEE ALSO
* Eventmirror/-Eventmirror-Typedefs
*******************************************************************************/
const char *sge_mirror_strerror(sge_mirror_error num)
{
switch (num) {
case SGE_EM_OK:
return MSG_MIRROR_OK;
case SGE_EM_NOT_INITIALIZED:
return MSG_MIRROR_NOTINITIALIZED;
case SGE_EM_BAD_ARG:
return MSG_MIRROR_BADARG;
case SGE_EM_TIMEOUT:
return MSG_MIRROR_TIMEOUT;
case SGE_EM_DUPLICATE_KEY:
return MSG_MIRROR_DUPLICATEKEY;
case SGE_EM_KEY_NOT_FOUND:
return MSG_MIRROR_KEYNOTFOUND;
case SGE_EM_CALLBACK_FAILED:
return MSG_MIRROR_CALLBACKFAILED;
case SGE_EM_PROCESS_ERRORS:
return MSG_MIRROR_PROCESSERRORS;
default:
return "";
}
}
static void sge_mirror_free_list(sge_object_type type)
{
object_type_free_master_list(type);
}
static sge_mirror_error
sge_mirror_process_event_list_(sge_evc_class_t *evc, lList *event_list)
{
lListElem *event = NULL;
sge_mirror_error function_ret;
bool no_more_events=false;
int num_events = 0;
mirror_description *mirror_base = mir_get_mirror_base();
object_description *object_base = object_type_get_object_description();
DENTER(TOP_LAYER, "sge_mirror_process_event_list");
PROF_START_MEASUREMENT(SGE_PROF_MIRROR);
function_ret = SGE_EM_OK;
for_each(event, event_list) {
sge_mirror_error ret = SGE_EM_OK;
if (no_more_events) {
break;
}
num_events++;
switch (lGetUlong(event, ET_type)) {
case sgeE_ADMINHOST_LIST:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_ADMINHOST, SGE_EMA_LIST, event);
break;
case sgeE_ADMINHOST_ADD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_ADMINHOST, SGE_EMA_ADD, event);
break;
case sgeE_ADMINHOST_DEL:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_ADMINHOST, SGE_EMA_DEL, event);
break;
case sgeE_ADMINHOST_MOD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_ADMINHOST, SGE_EMA_MOD, event);
break;
case sgeE_CALENDAR_LIST:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_CALENDAR, SGE_EMA_LIST, event);
break;
case sgeE_CALENDAR_ADD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_CALENDAR, SGE_EMA_ADD, event);
break;
case sgeE_CALENDAR_DEL:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_CALENDAR, SGE_EMA_DEL, event);
break;
case sgeE_CALENDAR_MOD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_CALENDAR, SGE_EMA_MOD, event);
break;
case sgeE_CKPT_LIST:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_CKPT, SGE_EMA_LIST, event);
break;
case sgeE_CKPT_ADD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_CKPT, SGE_EMA_ADD, event);
break;
case sgeE_CKPT_DEL:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_CKPT, SGE_EMA_DEL, event);
break;
case sgeE_CKPT_MOD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_CKPT, SGE_EMA_MOD, event);
break;
case sgeE_CENTRY_LIST:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_CENTRY, SGE_EMA_LIST, event);
break;
case sgeE_CENTRY_ADD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_CENTRY, SGE_EMA_ADD, event);
break;
case sgeE_CENTRY_DEL:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_CENTRY, SGE_EMA_DEL, event);
break;
case sgeE_CENTRY_MOD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_CENTRY, SGE_EMA_MOD, event);
break;
case sgeE_CONFIG_LIST:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_CONFIG, SGE_EMA_LIST, event);
break;
case sgeE_CONFIG_ADD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_CONFIG, SGE_EMA_ADD, event);
break;
case sgeE_CONFIG_DEL:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_CONFIG, SGE_EMA_DEL, event);
break;
case sgeE_CONFIG_MOD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_CONFIG, SGE_EMA_MOD, event);
break;
case sgeE_EXECHOST_LIST:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_EXECHOST, SGE_EMA_LIST, event);
break;
case sgeE_EXECHOST_ADD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_EXECHOST, SGE_EMA_ADD, event);
break;
case sgeE_EXECHOST_DEL:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_EXECHOST, SGE_EMA_DEL, event);
break;
case sgeE_EXECHOST_MOD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_EXECHOST, SGE_EMA_MOD, event);
break;
case sgeE_GLOBAL_CONFIG:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_GLOBAL_CONFIG, SGE_EMA_MOD, event);
break;
case sgeE_JATASK_ADD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_JATASK, SGE_EMA_ADD, event);
break;
case sgeE_JATASK_DEL:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_JATASK, SGE_EMA_DEL, event);
break;
case sgeE_JATASK_MOD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_JATASK, SGE_EMA_MOD, event);
break;
case sgeE_PETASK_ADD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_PETASK, SGE_EMA_ADD, event);
break;
case sgeE_PETASK_DEL:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_PETASK, SGE_EMA_DEL, event);
break;
case sgeE_JOB_LIST:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_JOB, SGE_EMA_LIST, event);
break;
case sgeE_JOB_ADD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_JOB, SGE_EMA_ADD, event);
break;
case sgeE_JOB_DEL:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_JOB, SGE_EMA_DEL, event);
break;
case sgeE_JOB_MOD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_JOB, SGE_EMA_MOD, event);
break;
case sgeE_JOB_MOD_SCHED_PRIORITY:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_JOB, SGE_EMA_MOD, event);
break;
case sgeE_JOB_USAGE:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_JOB, SGE_EMA_MOD, event);
break;
case sgeE_JOB_FINAL_USAGE:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_JOB, SGE_EMA_MOD, event);
break;
#if 0
case sgeE_JOB_FINISH:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_JOB, SGE_EMA_MOD, event);
break;
#endif
case sgeE_JOB_SCHEDD_INFO_LIST:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_JOB_SCHEDD_INFO, SGE_EMA_LIST, event);
break;
case sgeE_JOB_SCHEDD_INFO_ADD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_JOB_SCHEDD_INFO, SGE_EMA_ADD, event);
break;
case sgeE_JOB_SCHEDD_INFO_DEL:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_JOB_SCHEDD_INFO, SGE_EMA_DEL, event);
break;
case sgeE_JOB_SCHEDD_INFO_MOD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_JOB_SCHEDD_INFO, SGE_EMA_MOD, event);
break;
case sgeE_MANAGER_LIST:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_MANAGER, SGE_EMA_LIST, event);
break;
case sgeE_MANAGER_ADD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_MANAGER, SGE_EMA_ADD, event);
break;
case sgeE_MANAGER_DEL:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_MANAGER, SGE_EMA_DEL, event);
break;
case sgeE_MANAGER_MOD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_MANAGER, SGE_EMA_MOD, event);
break;
case sgeE_OPERATOR_LIST:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_OPERATOR, SGE_EMA_LIST, event);
break;
case sgeE_OPERATOR_ADD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_OPERATOR, SGE_EMA_ADD, event);
break;
case sgeE_OPERATOR_DEL:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_OPERATOR, SGE_EMA_DEL, event);
break;
case sgeE_OPERATOR_MOD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_OPERATOR, SGE_EMA_MOD, event);
break;
case sgeE_NEW_SHARETREE:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_SHARETREE, SGE_EMA_LIST, event);
break;
case sgeE_PE_LIST:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_PE, SGE_EMA_LIST, event);
break;
case sgeE_PE_ADD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_PE, SGE_EMA_ADD, event);
break;
case sgeE_PE_DEL:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_PE, SGE_EMA_DEL, event);
break;
case sgeE_PE_MOD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_PE, SGE_EMA_MOD, event);
break;
case sgeE_PROJECT_LIST:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_PROJECT, SGE_EMA_LIST, event);
break;
case sgeE_PROJECT_ADD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_PROJECT, SGE_EMA_ADD, event);
break;
case sgeE_PROJECT_DEL:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_PROJECT, SGE_EMA_DEL, event);
break;
case sgeE_PROJECT_MOD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_PROJECT, SGE_EMA_MOD, event);
break;
case sgeE_QMASTER_GOES_DOWN:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_MARK_4_REGISTRATION, SGE_EMA_TRIGGER, event);
break;
case sgeE_ACK_TIMEOUT:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_MARK_4_REGISTRATION, SGE_EMA_TRIGGER, event);
break;
case sgeE_CQUEUE_LIST:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_CQUEUE, SGE_EMA_LIST, event);
break;
case sgeE_CQUEUE_ADD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_CQUEUE, SGE_EMA_ADD, event);
break;
case sgeE_CQUEUE_DEL:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_CQUEUE, SGE_EMA_DEL, event);
break;
case sgeE_CQUEUE_MOD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_CQUEUE, SGE_EMA_MOD, event);
break;
case sgeE_QINSTANCE_ADD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_QINSTANCE, SGE_EMA_ADD, event);
break;
case sgeE_QINSTANCE_DEL:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_QINSTANCE, SGE_EMA_DEL, event);
break;
case sgeE_QINSTANCE_MOD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_QINSTANCE, SGE_EMA_MOD, event);
break;
case sgeE_QINSTANCE_SOS:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_QINSTANCE, SGE_EMA_MOD, event);
break;
case sgeE_QINSTANCE_USOS:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_QINSTANCE, SGE_EMA_MOD, event);
break;
case sgeE_SCHED_CONF:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_SCHEDD_CONF, SGE_EMA_MOD, event);
break;
case sgeE_SCHEDDMONITOR:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_SCHEDD_MONITOR, SGE_EMA_TRIGGER, event);
break;
case sgeE_SHUTDOWN:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_SHUTDOWN, SGE_EMA_TRIGGER, event);
no_more_events = true;
break;
case sgeE_SUBMITHOST_LIST:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_SUBMITHOST, SGE_EMA_LIST, event);
break;
case sgeE_SUBMITHOST_ADD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_SUBMITHOST, SGE_EMA_ADD, event);
break;
case sgeE_SUBMITHOST_DEL:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_SUBMITHOST, SGE_EMA_DEL, event);
break;
case sgeE_SUBMITHOST_MOD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_SUBMITHOST, SGE_EMA_MOD, event);
break;
case sgeE_USER_LIST:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_USER, SGE_EMA_LIST, event);
break;
case sgeE_USER_ADD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_USER, SGE_EMA_ADD, event);
break;
case sgeE_USER_DEL:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_USER, SGE_EMA_DEL, event);
break;
case sgeE_USER_MOD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_USER, SGE_EMA_MOD, event);
break;
case sgeE_USERSET_LIST:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_USERSET, SGE_EMA_LIST, event);
break;
case sgeE_USERSET_ADD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_USERSET, SGE_EMA_ADD, event);
break;
case sgeE_USERSET_DEL:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_USERSET, SGE_EMA_DEL, event);
break;
case sgeE_USERSET_MOD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_USERSET, SGE_EMA_MOD, event);
break;
case sgeE_RQS_LIST:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_RQS, SGE_EMA_LIST, event);
break;
case sgeE_RQS_ADD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_RQS, SGE_EMA_ADD, event);
break;
case sgeE_RQS_DEL:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_RQS, SGE_EMA_DEL, event);
break;
case sgeE_RQS_MOD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_RQS, SGE_EMA_MOD, event);
break;
#ifndef __SGE_NO_USERMAPPING__
case sgeE_CUSER_LIST:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_CUSER, SGE_EMA_LIST, event);
break;
case sgeE_CUSER_ADD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_CUSER, SGE_EMA_ADD, event);
break;
case sgeE_CUSER_DEL:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_CUSER, SGE_EMA_DEL, event);
break;
case sgeE_CUSER_MOD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_CUSER, SGE_EMA_MOD, event);
break;
#endif
case sgeE_HGROUP_LIST:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_HGROUP, SGE_EMA_LIST, event);
break;
case sgeE_HGROUP_ADD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_HGROUP, SGE_EMA_ADD, event);
break;
case sgeE_HGROUP_DEL:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_HGROUP, SGE_EMA_DEL, event);
break;
case sgeE_HGROUP_MOD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_HGROUP, SGE_EMA_MOD, event);
break;
case sgeE_AR_LIST:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_AR, SGE_EMA_LIST, event);
break;
case sgeE_AR_ADD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_AR, SGE_EMA_ADD, event);
break;
case sgeE_AR_DEL:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_AR, SGE_EMA_DEL, event);
break;
case sgeE_AR_MOD:
ret = sge_mirror_process_event(evc, mirror_base, object_base, SGE_TYPE_AR, SGE_EMA_MOD, event);
break;
default:
break;
}
/*
* if processing of an event failed, return an error to the caller of
* this function, but continue processing.
*/
if (ret != SGE_EM_OK) {
function_ret = SGE_EM_PROCESS_ERRORS;
}
}
if (prof_is_active(SGE_PROF_MIRROR)) {
prof_stop_measurement(SGE_PROF_MIRROR, NULL);
PROFILING((SGE_EVENT, "PROF: sge_mirror processed %d events in %.3f s",
num_events, prof_get_measurement_wallclock(SGE_PROF_MIRROR,
false, NULL)));
}
DRETURN(function_ret);
}
/*
* need this wrapping as to workaround dtrace problems with
* pid providers when function pointers are used
*/
sge_mirror_error
sge_mirror_process_event_list(sge_evc_class_t *evc, lList *event_list)
{
return sge_mirror_process_event_list_(evc, event_list);
}
static sge_mirror_error
sge_mirror_process_event(sge_evc_class_t *evc, mirror_description *mirror_base, object_description *object_base,
sge_object_type type, sge_event_action action, lListElem *event)
{
sge_callback_result ret;
char buffer[1024];
dstring buffer_wrapper;
DENTER(TOP_LAYER, "sge_mirror_process_event");
sge_dstring_init(&buffer_wrapper, buffer, sizeof(buffer));
/* DEBUG */
#if 1
DPRINTF(("%s\n", event_text(event, &buffer_wrapper)));
#else
{
u_long32 number, type, intkey, intkey2;
const char *strkey, *strkey2;
number = lGetUlong(event, ET_number);
type = lGetUlong(event, ET_type);
intkey = lGetUlong(event, ET_intkey);
intkey2 = lGetUlong(event, ET_intkey2);
strkey = lGetString(event, ET_strkey);
strkey2 = lGetString(event, ET_strkey2);
DPRINTF(("\tEvent: %s intkey %d intkey2 %d strkey \"%s\" strkey2 \"%s\"\n",
event_text(event, &buffer_wrapper), intkey, intkey2,
strkey?strkey:"NULL", strkey2?strkey2:"NULL"));
}
#endif
if (mirror_base[type].callback_before != NULL) {
ret = mirror_base[type].callback_before(evc, object_base, type, action, event, mirror_base[type].clientdata);
if (ret == SGE_EMA_FAILURE) {
ERROR((SGE_EVENT, MSG_MIRROR_CALLBACKFAILED_S, event_text(event, &buffer_wrapper)));
DRETURN(SGE_EM_CALLBACK_FAILED);
} else if (ret == SGE_EMA_IGNORE) {
DRETURN(SGE_EM_OK);
}
}
if (mirror_base[type].callback_default != NULL) {
ret = mirror_base[type].callback_default(evc, object_base, type, action, event, NULL);
if (ret == SGE_EMA_FAILURE) {
ERROR((SGE_EVENT, MSG_MIRROR_CALLBACKFAILED_S, event_text(event, &buffer_wrapper)));
DRETURN(SGE_EM_CALLBACK_FAILED);
} else if (ret == SGE_EMA_IGNORE) {
DRETURN(SGE_EM_OK);
}
}
if (mirror_base[type].callback_after != NULL) {
ret = mirror_base[type].callback_after(evc, object_base, type, action, event, mirror_base[type].clientdata);
if (ret == SGE_EMA_FAILURE) {
ERROR((SGE_EVENT, MSG_MIRROR_CALLBACKFAILED_S, event_text(event, &buffer_wrapper)));
DRETURN(SGE_EM_CALLBACK_FAILED);
}
}
DRETURN(SGE_EM_OK);
}
static sge_callback_result
sge_mirror_process_shutdown(sge_evc_class_t *evc, object_description *object_base,sge_object_type type,
sge_event_action action, lListElem *event, void *clientdata)
{
DENTER(TOP_LAYER, "sge_mirror_process_shutdown");
DPRINTF(("shutting down sge mirror\n"));
sge_mirror_shutdown(evc);
shut_me_down = 1;
DRETURN(SGE_EMA_OK);
}
static sge_callback_result
sge_mirror_process_mark4registration(sge_evc_class_t *evc, object_description *object_base,
sge_object_type type,
sge_event_action action,
lListElem *event,
void *clientdata)
{
DENTER(TOP_LAYER, "sge_mirror_process_mark4registration");
DPRINTF(("mark4registration - this happens for ACK TIMEOUT or QMASTER GOES DOWN event\n"));
evc->ec_mark4registration(evc);
DRETURN(SGE_EMA_OK);
}
static sge_callback_result
generic_update_master_list(sge_evc_class_t *evc, object_description *object_base, sge_object_type type,
sge_event_action action, lListElem *event, void *clientdata)
{
lList **list = NULL;
const lDescr *list_descr;
int key_nm;
const char *key;
DENTER(TOP_LAYER, "generic_update_master_list");
list = sge_master_list(object_base, type);
list_descr = lGetListDescr(lGetList(event, ET_new_version));
key_nm = object_type_get_key_nm(type);
key = lGetString(event, ET_strkey);
if (sge_mirror_update_master_list_str_key(list, list_descr, key_nm, key, action, event) != SGE_EM_OK) {
DRETURN(SGE_EMA_FAILURE);
}
if (!object_type_commit_master_list(type, NULL)) {
DRETURN(SGE_EMA_FAILURE);
}
DRETURN(SGE_EMA_OK);
}
/****** Eventmirror/sge_mirror_update_master_list_str_key() *********************
* NAME
* sge_mirror_update_master_list_str_key() -- update a master list
*
* SYNOPSIS
* sge_mirror_error sge_mirror_update_master_list_str_key(lList **list,
* const lDescr *list_descr,
* int key_nm,
* const char *key,
* sge_event_action action,
* lListElem *event)
*
* FUNCTION
* Updates a certain element in a certain mirrored list.
* Which element to update is specified by a given string key.
*
* INPUTS
* lList **list - the master list to update
* lDescr *list_descr - descriptor of the master list
* int key_nm - field identifier of the key
* const char *key - value of the key
* sge_event_action action - action to perform on list
* lListElem *event - raw event element
*
* RESULT
* sge_mirror_error - SGE_EM_OK or an error code
*
* SEE ALSO
* Eventmirror/sge_mirror_update_master_list()
*******************************************************************************/
sge_mirror_error
sge_mirror_update_master_list_str_key(lList **list, const lDescr *list_descr,
int key_nm, const char *key,
sge_event_action action, lListElem *event)
{
lListElem *ep;
sge_mirror_error ret;
DENTER(TOP_LAYER, "sge_mirror_update_master_list_str_key");
#if 0
ep = lGetElemStr(*list, key_nm, key);
ret = sge_mirror_update_master_list(list, list_descr, ep, key, action, event);
#else
/* TODO: is the code above correct, do we always have list != NULL ??? */
if (list != NULL) {
ep = lGetElemStr(*list, key_nm, key);
ret = sge_mirror_update_master_list(list, list_descr, ep, key, action, event);
} else {
ret = SGE_EM_NOT_INITIALIZED;
}
#endif
DRETURN(ret);
}
/****** Eventmirror/sge_mirror_update_master_list_host_key() *********************
* NAME
* sge_mirror_update_master_list_host_key() -- update a master list
*
* SYNOPSIS
* sge_mirror_error sge_mirror_update_master_list_host_key(lList **list,
* const lDescr *list_descr,
* int key_nm,
* const char *key,
* sge_event_action action,
* lListElem *event)
*
* FUNCTION
* Updates a certain element in a certain mirrored list.
* Which element to update is specified by a given hostname.
*
* INPUTS
* lList **list - the master list to update
* lDescr *list_descr - descriptor of the master list
* int key_nm - field identifier of the key
* const char *key - value of the key (a hostname)
* sge_event_action action - action to perform on list
* lListElem *event - raw event element
*
* RESULT
* sge_mirror_error - SGE_EM_OK or an error code
*
* SEE ALSO
* Eventmirror/sge_mirror_update_master_list()
*******************************************************************************/
sge_mirror_error sge_mirror_update_master_list_host_key(lList **list, const lDescr *list_descr,
int key_nm, const char *key,
sge_event_action action, lListElem *event)
{
lListElem *ep;
sge_mirror_error ret;
DENTER(TOP_LAYER, "sge_mirror_update_master_list_host_key");
ep = lGetElemHost(*list, key_nm, key);
ret = sge_mirror_update_master_list(list, list_descr, ep, key, action, event);
DRETURN(ret);
}
/****** Eventmirror/sge_mirror_update_master_list() *****************************
* NAME
* sge_mirror_update_master_list() -- update a master list
*
* SYNOPSIS
* sge_mirror_error sge_mirror_update_master_list(lList **list,
* const lDescr *list_descr,
* lListElem *ep,
* const char *key,
* sge_event_action action,
* lListElem *event)
*
* FUNCTION
* Updates a given master list according to the given event information.
* The following actions are performed (depending on parameter action):
* - SGE_EMA_LIST: an existing mirrored list is completely replaced
* - SGE_EMA_ADD: a new element is added to the mirrored list
* - SGE_EMA_MOD: a given element is modified
* - SGE_EMA_DEL: a given element is deleted
*
* INPUTS
* lList **list - mirrored list to manipulate
* lDescr *list_descr - descriptor of mirrored list
* lListElem *ep - element to manipulate or NULL
* const char *key - key of an element to manipulate
* sge_event_action action - action to perform
* lListElem *event - raw event
*
* RESULT
* sge_mirror_error - SGE_EM_OK, or an error code
*
* SEE ALSO
* Eventmirror/sge_mirror_update_master_list_str_key()
* Eventmirror/sge_mirror_update_master_list_host_key()
*******************************************************************************/
sge_mirror_error
sge_mirror_update_master_list(lList **list, const lDescr *list_descr,
lListElem *ep, const char *key,
sge_event_action action, lListElem *event)
{
lList *data_list = NULL;
DENTER(TOP_LAYER, "sge_mirror_update_master_list");
switch (action) {
case SGE_EMA_LIST:
/* switch to new list */
lXchgList(event, ET_new_version, list);
break;
case SGE_EMA_ADD:
/* check for duplicate */
if (ep != NULL) {
ERROR((SGE_EVENT, "duplicate list element "SFQ"\n", (key != NULL) ?key:"NULL"));
DRETURN(SGE_EM_DUPLICATE_KEY);
}
/* if neccessary, create list */
if (*list == NULL) {
*list = lCreateList("", list_descr);
}
/* insert element */
data_list = lGetList(event, ET_new_version);
lAppendElem(*list, lDechainElem(data_list, lFirst(data_list)));
break;
case SGE_EMA_DEL:
/* check for existence */
if (ep == NULL) {
ERROR((SGE_EVENT, "element "SFQ" does not exist\n", (key != NULL) ?key:"NULL"));
DRETURN(SGE_EM_KEY_NOT_FOUND);
}
/* remove element */
lRemoveElem(*list, &ep);
break;
case SGE_EMA_MOD:
/* check for existence */
if (ep == NULL) {
ERROR((SGE_EVENT, "element "SFQ" does not exist\n", (key != NULL) ?key:"NULL"));
DRETURN(SGE_EM_KEY_NOT_FOUND);
}
lRemoveElem(*list, &ep);
data_list = lGetList(event, ET_new_version);
lAppendElem(*list, lDechainElem(data_list, lFirst(data_list)));
break;
default:
DRETURN(SGE_EM_BAD_ARG);
}
DRETURN(SGE_EM_OK);
}
static sge_callback_result
/****** sge_mirror/ar_update_master_list() *************************************
* NAME
* ar_update_master_list() -- update the master advance reservation list
*
* SYNOPSIS
* static sge_callback_result ar_update_master_list(sge_evc_class_t *evc,
* object_description *object_base, sge_object_type type, sge_event_action
* action, lListElem *event, void *clientdata)
*
* FUNCTION
* Updates the global master list of advance reservations based on an event.
* The function is called from the event mirroring interface.
*
* INPUTS
* sge_evc_class_t *evc - event client class
* object_description *object_base - object base of master lists
* sge_object_type type - event type
* sge_event_action action - action to perform
* lListElem *event - the raw event
* void *clientdata - client data
*
* RESULT
* static sge_callback_result - true, if update is successfull
* false if an error occured
*
* NOTES
* MT-NOTE: ar_update_master_list() is not MT safe
*******************************************************************************/
ar_update_master_list(sge_evc_class_t *evc, object_description *object_base, sge_object_type type,
sge_event_action action, lListElem *event, void *clientdata)
{
lList **list = NULL;
const lDescr *list_descr;
int key_nm;
const char *key;
DENTER(TOP_LAYER, "ar_update_master_list");
list = sge_master_list(object_base, type);
list_descr = lGetListDescr(lGetList(event, ET_new_version));
key_nm = object_type_get_key_nm(type);
key = lGetString(event, ET_strkey);
if (sge_mirror_update_master_list_ar_key(list, list_descr, key_nm, key, action, event) != SGE_EM_OK) {
DRETURN(SGE_EMA_FAILURE);
}
DRETURN(SGE_EMA_OK);
}
/****** sge_mirror/sge_mirror_update_master_list_ar_key() **********************
* NAME
* sge_mirror_update_master_list_ar_key() -- updates the advance reservation
* master list
*
* SYNOPSIS
* static sge_mirror_error sge_mirror_update_master_list_ar_key(lList
* **list, const lDescr *list_descr, int key_nm, const char *key,
* sge_event_action action, lListElem *event)
*
* FUNCTION
* Updates a certain element in the advance reservation mirrored list. Which
* element to update is specified by the given AR_id as string value
*
* INPUTS
* lList **list - the master list to update
* const lDescr *list_descr - descriptor of the master list (AR_Type)
* int key_nm - field identifies of the key (AR_name)
* const char *key - AR_id as string value
* sge_event_action action - action to perform on this list
* lListElem *event - raw event element
*
* RESULT
* static sge_mirror_error - SGE_EM_OK or an error code
*
* NOTES
* MT-NOTE: sge_mirror_update_master_list_ar_key() is MT safe, needs GLOBAL_LOCK
*******************************************************************************/
static sge_mirror_error sge_mirror_update_master_list_ar_key(lList **list, const lDescr *list_descr,
int key_nm, const char *key,
sge_event_action action, lListElem *event)
{
lListElem *ep = NULL;
sge_mirror_error ret;
DENTER(TOP_LAYER, "sge_mirror_update_master_list_ar_key");
if (list != NULL) {
if (key != NULL) {
ep = lGetElemUlong(*list, key_nm, atoi(key));
}
ret = sge_mirror_update_master_list(list, list_descr, ep, key, action, event);
} else {
ret = SGE_EM_NOT_INITIALIZED;
}
DRETURN(ret);
}
|