amfapp.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /** @file amfapp.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 Application Class implementation
  38. *
  39. * This file contains functions for handling the AMF applications. It can
  40. * be viewed as the implementation of the AMF Application class
  41. * as described in SAI-Overview-B.02.01. The SA Forum specification
  42. * SAI-AIS-AMF-B.02.01 has been used as specification of the behaviour
  43. * and is referred to as 'the spec' below.
  44. *
  45. * The functions in this file are responsible for:
  46. * - on request start the service groups it contains
  47. * - on request order the service groups to assign workload to all
  48. * service units contained in the service group, level by level
  49. * - to handle administrative operation support for the application (FUTURE)
  50. *
  51. * The cluster class contains the following state machines:
  52. * - administrative state machine (ADSM)
  53. * - availability control state machine (ACSM)
  54. *
  55. * The administrative state machine will be implemented in the future.
  56. *
  57. * ACSM handles initial start of an application. In the future it will also
  58. * handle administrative commands on the application as described in paragraph
  59. * 7.4 of the spec. ACSM includes two stable states (UNINSTANTIATED and
  60. * STARTED) and a number of states to control the transition between the
  61. * stable states.
  62. *
  63. * The application is in state UNINSTANTIATED when the application starts.
  64. * (In the future this state will also be assumed after the LOCK_INSTANTIATION
  65. * administrative command.)
  66. *
  67. * State STARTED is assumed when the application has been initially started and
  68. * will in the future be re-assumed after the administrative command RESTART
  69. * have been executed.
  70. *
  71. */
  72. #include "amf.h"
  73. #include "print.h"
  74. int amf_application_si_count_get (struct amf_application *app)
  75. {
  76. struct amf_si *si;
  77. int answer = 0;
  78. for (si = app->si_head; si != NULL; si = si->next) {
  79. answer += 1;
  80. }
  81. return (answer);
  82. }
  83. void amf_application_start (
  84. struct amf_application *app, struct amf_node *node)
  85. {
  86. struct amf_sg *sg;
  87. ENTER ("'%s'", app->name.value);
  88. for (sg = app->sg_head; sg != NULL; sg = sg->next) {
  89. amf_sg_start (sg, node);
  90. }
  91. }
  92. void amf_application_assign_workload (
  93. struct amf_application *app, struct amf_node *node)
  94. {
  95. struct amf_sg *sg;
  96. for (sg = app->sg_head; sg != NULL; sg = sg->next) {
  97. amf_sg_assign_si (sg, 0);
  98. }
  99. }
  100. void amf_application_init (void)
  101. {
  102. log_init ("AMF");
  103. }