/[eiffelstudio]/trunk/Src/web/eiffel-cloud/modules/es_cloud/kernel/es_cloud_plan.e
ViewVC logotype

Contents of /trunk/Src/web/eiffel-cloud/modules/es_cloud/kernel/es_cloud_plan.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 103675 - (show annotations)
Tue Nov 12 12:35:53 2019 UTC (2 months, 1 week ago) by jfiat
File size: 3069 byte(s)
Added webapi to access the plans.
1 note
2 description: "Summary description for {ES_CLOUD_PLAN}."
3 date: "$Date$"
4 revision: "$Revision$"
5
6 class
7 ES_CLOUD_PLAN
8
9 create
10 make,
11 make_with_id_and_name
12
13 feature {NONE} -- Creation
14
15 make (a_name: READABLE_STRING_8)
16 do
17 create name.make_from_string (a_name)
18 end
19
20 make_with_id_and_name (a_pid: INTEGER; a_name: READABLE_STRING_8)
21 do
22 id := a_pid
23 make (a_name)
24 end
25
26 feature -- Access
27
28 has_id: BOOLEAN
29 do
30 Result := id > 0
31 end
32
33 id: INTEGER
34
35 name: IMMUTABLE_STRING_8
36
37 title: detachable IMMUTABLE_STRING_32
38
39 description: detachable IMMUTABLE_STRING_32
40
41 installations_limit: NATURAL
42 -- Maximum number of installation for the same plan.
43 -- `0` means no limit
44
45 concurrent_sessions_limit: NATURAL
46 -- Maximum number of concurrent sessions for the same plan.
47 -- `0` means no limit
48
49 feature -- Access: private
50
51 heartbeat: NATURAL
52 -- Delay between each ping in seconds
53 -- `0` means no constraint.
54
55 weight: INTEGER
56 -- Weight of Current plan among other plans
57 -- used to sort list of plans.
58
59 data: detachable IMMUTABLE_STRING_32
60 local
61 mi,ms: NATURAL
62 do
63 mi := installations_limit
64 ms := concurrent_sessions_limit
65 Result := "install.limit=" + mi.out + ";session.limit=" + ms.out + ";session.heartbeat=" + heartbeat.out + ";order.weight=" + weight.out
66 end
67
68 feature -- Status report
69
70 same_plan (pl: detachable ES_CLOUD_PLAN): BOOLEAN
71 -- Is Current same plan as `pl`?
72 do
73 if pl /= Void then
74 if has_id then
75 Result := id = pl.id
76 else
77 Result := name.same_string (pl.name)
78 end
79 end
80 end
81
82 feature -- Query
83
84 title_or_name: READABLE_STRING_32
85 do
86 if attached title as t then
87 Result := t
88 else
89 Result := name.as_string_32
90 end
91 end
92
93 feature -- Element change
94
95 set_data (a_data: detachable READABLE_STRING_GENERAL)
96 local
97 sess,inst,l_heartbeat: NATURAL
98 l_weight: INTEGER
99 s: READABLE_STRING_GENERAL
100 do
101 sess := 0
102 inst := 0
103 l_heartbeat := 0
104 l_weight := 0
105 if a_data /= Void then
106 across
107 a_data.split (';') as ic
108 loop
109 s := ic.item
110 if s.starts_with ("install.limit=") then
111 inst := s.substring (s.index_of ('=', 1) + 1, s.count).to_natural
112 elseif s.starts_with ("session.limit=") then
113 sess := s.substring (s.index_of ('=', 1) + 1, s.count).to_natural
114 elseif s.starts_with ("session.heartbeat=") then
115 l_heartbeat := s.substring (s.index_of ('=', 1) + 1, s.count).to_natural
116 elseif s.starts_with ("order.weight=") then
117 l_weight := s.substring (s.index_of ('=', 1) + 1, s.count).to_integer
118 end
119 end
120 end
121 installations_limit := inst
122 concurrent_sessions_limit := sess
123 heartbeat := l_heartbeat
124 weight := l_weight
125 end
126
127 set_title (s: detachable READABLE_STRING_GENERAL)
128 do
129 if s = Void then
130 title := Void
131 else
132 create title.make_from_string_general (s)
133 end
134 end
135
136 set_description (d: detachable READABLE_STRING_GENERAL)
137 do
138 if d = Void then
139 description := Void
140 else
141 create description.make_from_string_general (d)
142 end
143 end
144
145 end

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23