amfsi.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /** @file amfsi.c
  2. *
  3. * Copyright (c) 2006 Ericsson AB.
  4. * Author: Hans Feldt
  5. * - Refactoring of code into several AMF files
  6. * Author: Anders Eriksson
  7. *
  8. * All rights reserved.
  9. *
  10. *
  11. * This software licensed under BSD license, the text of which follows:
  12. *
  13. * Redistribution and use in source and binary forms, with or without
  14. * modification, are permitted provided that the following conditions are met:
  15. *
  16. * - Redistributions of source code must retain the above copyright notice,
  17. * this list of conditions and the following disclaimer.
  18. * - Redistributions in binary form must reproduce the above copyright notice,
  19. * this list of conditions and the following disclaimer in the documentation
  20. * and/or other materials provided with the distribution.
  21. * - Neither the name of the MontaVista Software, Inc. nor the names of its
  22. * contributors may be used to endorse or promote products derived from this
  23. * software without specific prior written permission.
  24. *
  25. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  26. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  27. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  28. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  29. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  30. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  31. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  32. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  33. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  34. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  35. * THE POSSIBILITY OF SUCH DAMAGE.
  36. *
  37. * AMF Workload related classes Implementation
  38. *
  39. * This file contains functions for handling :
  40. * - AMF service instances(SI)
  41. * - AMF SI Dependency
  42. * - AMF SI Ranked SU
  43. * - AMF SI Assignment
  44. * - AMF component service instances (CSI)
  45. * - AMF CSI Assignment
  46. * - AMF CSI Type
  47. * - AMF CSI Attribute
  48. * The file can be viewed as the implementation of the classes listed above
  49. * as described in SAI-Overview-B.02.01. The SA Forum specification
  50. * SAI-AIS-AMF-B.02.01 has been used as specification of the behaviour
  51. * and is referred to as 'the spec' below.
  52. *
  53. * The functions in this file are responsible for:
  54. * - calculating and storing an SI_dependency_level integer per SI
  55. * - calculating and storing a csi_dependency_level integer per CSI
  56. * - on request change HA state of an SI or CSI in such a way that the
  57. * requirements regarding SI -> SI dependencies (paragraphs 3.9.1.1 and
  58. * 3.9.1.2) and CSI -> CSI dependencies (paragraph 3.9.1.3) are fully
  59. * respected
  60. *
  61. * The si_dependency_level is an attribute calculated at init (in the future
  62. * also at reconfiguration) which indicates dependencies between SIs as
  63. * an integer. The si_dependency level indicates to which extent an SI depends
  64. * on other SIs such that an SI that depends on no other SI is on
  65. * si_dependecy_level == 1, an SI that depends only on an SI on
  66. * si_dependency_level == 1 is on si_dependency-level == 2.
  67. * An SI that depends on several SIs gets a si_dependency_level that is one
  68. * unit higher than the SI with the highest si_dependency_level it depends on.
  69. *
  70. * The csi_dependency_level attribute works the same way.
  71. *
  72. * According to paragraph 3.9.1 of the spec, a change to or from the ACTIVE
  73. * HA state is not always allowed without first deactivate dependent SI and CSI
  74. * assignments. Dependencies between CSIs are absolute while an SI that depends
  75. * on another SI may tolerate that the SI on which it depends is inactive for a
  76. * configurable time (the tolerance time). The consequence of this is that a
  77. * request to change the SI state may require a sequence of requests to
  78. * components to assume a new HA state for a CSI-assignment and to guarantee
  79. * the dependency rules, the active response from the component has to be
  80. * awaited before next HA state can be set.
  81. *
  82. * This file implements an SI state machine that fully implements these rules.
  83. * This state machine is called SI Dependency Control State Machine (dcsm)
  84. * and has the following states:
  85. * - DEACTIVATED (there is no SI-assignment with active HA state)
  86. * - ACTIVATING (a request to set the ACTIVE HA state has been received and
  87. * setting ACTIVE HA states to the appropriate components are
  88. * in progress)
  89. * - ACTIVATED (there is at least one SI-assignment with the ACTIVE HA-state)
  90. * - DEACTIVATING (a request to de-activate an SI or only a specific CSI
  91. * within an SI has been received and setting the QUISCED
  92. * HA states to the appropriate components are in progress)
  93. * - DEPENDENCY_DEACTIVATING (the SI-SI dependency tolerance timer has expired
  94. * and setting the QUISCED HA states to the
  95. * appropriate components are in progress)
  96. * - DEPENDENCY_DEACTIVATED (as state DEACTIVATED but will automatically
  97. * transition to state ACTIVATING when the
  98. * dependency problem is solved, i.e. the SI on
  99. * which it depends has re-assumed the ACTIVE HA
  100. * state)
  101. * - SETTING (a request to change the HA state when neither the existing
  102. * nor the requested state is ACTIVE)
  103. *
  104. * This file also implements:
  105. * - SI: Assignment state (for report purposes)
  106. * - SI Assignment: HA state
  107. * - CSI Assignment: HA state
  108. *
  109. */
  110. #include <assert.h>
  111. #include <stdio.h>
  112. #include "amf.h"
  113. #include "print.h"
  114. char *amf_csi_dn_make (struct amf_csi *csi, SaNameT *name)
  115. {
  116. int i = snprintf((char*) name->value, SA_MAX_NAME_LENGTH,
  117. "safCsi=%s,safSi=%s,safApp=%s",
  118. csi->name.value, csi->si->name.value,
  119. csi->si->application->name.value);
  120. assert (i <= SA_MAX_NAME_LENGTH);
  121. name->length = i;
  122. return (char *)name->value;
  123. }
  124. void amf_si_init (void)
  125. {
  126. log_init ("AMF");
  127. }