Skip to content

Commit 68959ae

Browse files
authoredNov 5, 2020
Restore cluster dynamic size after setServerGroups reset value (#775)
1 parent 77f4fda commit 68959ae

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed
 

‎core/src/main/python/wlsdeploy/tool/util/target_helper.py

+64
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@
66
import copy
77

88
import oracle.weblogic.deploy.util.PyOrderedDict as OrderedDict
9+
from oracle.weblogic.deploy.exception import BundleAwareException
10+
911
import wlsdeploy.util.dictionary_utils as dictionary_utils
1012

1113
from wlsdeploy.aliases.location_context import LocationContext
1214
from wlsdeploy.aliases.model_constants import ADMIN_SERVER_NAME
1315
from wlsdeploy.aliases.model_constants import CLUSTER
1416
from wlsdeploy.aliases.model_constants import DYNAMIC_CLUSTER_SERVER_GROUP_TARGETING_LIMITS
17+
from wlsdeploy.aliases.model_constants import DYNAMIC_CLUSTER_SIZE
1518
from wlsdeploy.aliases.model_constants import DYNAMIC_SERVERS
1619
from wlsdeploy.aliases.model_constants import DEFAULT_ADMIN_SERVER_NAME
1720
from wlsdeploy.aliases.model_constants import MODEL_LIST_DELIMITER
@@ -248,9 +251,13 @@ def target_dynamic_server_groups(self, dynamic_cluster_assigns):
248251
if len(dynamic_cluster_assigns) > 0:
249252
# assign server group resources to cluster based on the version of WebLogic server version.
250253
if self.wls_helper.is_dynamic_cluster_server_groups_supported():
254+
bug_map = self.save_dyn_size(dynamic_cluster_assigns)
251255
self.target_server_groups(dynamic_cluster_assigns)
256+
self.restore_dyn_size(bug_map)
252257
elif self.wls_helper.is_dynamic_cluster_server_group_supported():
258+
bug_map = self.save_dyn_size(dynamic_cluster_assigns)
253259
self.target_dynamic_clusters(dynamic_cluster_assigns)
260+
self.restore_dyn_size(bug_map)
254261
else:
255262
self.logger.warning('WLSDPLY-12238', domain_typedef.get_domain_type(),
256263
class_name=self.__class_name, method_name=_method_name)
@@ -571,3 +578,60 @@ def __get_server_groups_for_entity(self, entity_name, sg_targeting_limits):
571578
self.logger.fine('WLSDPLY-12243', entity_name, result, class_name=self.__class_name,
572579
method_name=_method_name)
573580
return result
581+
582+
def save_dyn_size(self, cluster_map):
583+
"""
584+
Collect the before attribute of dynamic cluster size for each dynamic cluster. When
585+
setting dynamic clusters to server groups, the parameter dynamic cluster size is reset
586+
based on the parameters in the template server group WSM-CACHE-DYN-CLUSTER. A bug
587+
was opened 32075458, but probably will be seen as not a bug.
588+
:param cluster_map: cluster, server groups map
589+
:return: map of cluster and attribute_value
590+
"""
591+
_method_name = 'save_dyn_size'
592+
bug_map = dict()
593+
for cluster in cluster_map.iterkeys():
594+
wlst_attribute = self.__locate_dynamic_attribute(cluster)
595+
bug_map[cluster] = self.wlst_helper.get(wlst_attribute)
596+
self.logger.finer('WLSDPLY-12560', cluster, bug_map[cluster],
597+
class_name=self.__class_name, method_name=_method_name)
598+
return bug_map
599+
600+
def restore_dyn_size(self, bug_map):
601+
"""
602+
The setServerGroups reset the dynamic cluster size. Reset to original value.
603+
:param bug_map: map with cluster, dynamic cluster size
604+
"""
605+
_method_name = 'restore_dyn_size'
606+
self.__put_back_in_edit()
607+
for cluster, attribute_value in bug_map.iteritems():
608+
if attribute_value is not None:
609+
wlst_attribute = self.__locate_dynamic_attribute(cluster)
610+
self.wlst_helper.set(wlst_attribute, attribute_value)
611+
self.logger.finer('WLSDPLY-12561', cluster, wlst_attribute,
612+
class_name=self.__class_name, method_name=_method_name)
613+
614+
def __put_back_in_edit(self):
615+
"""
616+
setServerGroups throws you out of edit. Put it back in.
617+
"""
618+
if self.model_context.is_wlst_online():
619+
try:
620+
self.wlst_helper.edit()
621+
self.wlst_helper.start_edit()
622+
except BundleAwareException, ex:
623+
raise ex
624+
625+
def __locate_dynamic_attribute(self, cluster):
626+
627+
location = LocationContext()
628+
location.append_location(CLUSTER)
629+
location.add_name_token(self.aliases.get_name_token(location), cluster)
630+
location.append_location(DYNAMIC_SERVERS)
631+
list_path = self.aliases.get_wlst_list_path(location)
632+
existing_names = self.wlst_helper.get_existing_object_list(list_path)
633+
location.add_name_token(self.aliases.get_name_token(location), existing_names[0])
634+
attributes_path = self.aliases.get_wlst_attributes_path(location)
635+
self.wlst_helper.cd(attributes_path)
636+
wlst_attribute = self.aliases.get_wlst_attribute_name(location, DYNAMIC_CLUSTER_SIZE)
637+
return wlst_attribute

‎core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties

+2
Original file line numberDiff line numberDiff line change
@@ -1281,6 +1281,8 @@ WLSDPLY-12257=No server group found for dynamic cluster {0}. Versions of WebLogi
12811281
do not support targeting more than one server group to a dynamic cluster. Server group not defined in domain typedef
12821282
WLSDPLY-12258=RCU {0} file {1} is invalid : {2}
12831283
WLSDPLY-12259=Error creating directory {0} to extract RCU {1} file {2}
1284+
WLSDPLY-12560=Dynamic cluster {0} has size of {1}
1285+
WLSDPLY-12561=Dynamic cluster {0} set to size of {1}
12841286

12851287
# domain_typedef.py
12861288
WLSDPLY-12300={0} got the domain type {1} but the domain type definition file {2} was not valid: {3}

0 commit comments

Comments
 (0)
Please sign in to comment.