Skip to content

Commit 002e9f7

Browse files
adding -wait_for_edit_lock to deployApps and updateDomain tools (#1129)
* adding -wait_for_edit_lock to deployApps and updateDomain tools * adding doc changes for new capabilities
1 parent 005f175 commit 002e9f7

File tree

13 files changed

+132
-47
lines changed

13 files changed

+132
-47
lines changed

core/src/main/python/deploy.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,19 @@ def __deploy_online(model, model_context, aliases):
118118
admin_user = model_context.get_admin_user()
119119
admin_pwd = model_context.get_admin_password()
120120
timeout = model_context.get_model_config().get_connect_timeout()
121+
skip_edit_session_check = model_context.is_discard_current_edit() or model_context.is_wait_for_edit_lock()
122+
edit_lock_acquire_timeout = model_context.get_model_config.get_wlst_edit_lock_acquire_timeout()
123+
edit_lock_release_timeout = model_context.get_model_config.get_wlst_edit_lock_release_timeout()
124+
edit_lock_exclusive = model_context.get_model_config().get_wlst_edit_lock_exclusive()
121125

122126
__logger.info("WLSDPLY-09005", admin_url, timeout, method_name=_method_name, class_name=_class_name)
123127

124128
__wlst_helper.connect(admin_user, admin_pwd, admin_url, timeout)
125-
deployer_utils.ensure_no_uncommitted_changes_or_edit_sessions(model_context.is_discard_current_edit())
129+
deployer_utils.ensure_no_uncommitted_changes_or_edit_sessions(skip_edit_session_check)
126130
__wlst_helper.edit()
127-
__wlst_helper.start_edit()
131+
__logger.fine("WLSDPLY-09019", edit_lock_acquire_timeout, edit_lock_release_timeout, edit_lock_exclusive)
132+
__wlst_helper.start_edit(acquire_timeout=edit_lock_acquire_timeout, release_timeout=edit_lock_release_timeout,
133+
exclusive=edit_lock_exclusive)
128134
if model_context.is_discard_current_edit():
129135
deployer_utils.discard_current_edit()
130136

core/src/main/python/update.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2020, Oracle Corporation and/or its affiliates.
2+
Copyright (c) 2017, 2022, Oracle Corporation and/or its affiliates.
33
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
55
The entry point for the updateDomain tool.
@@ -67,7 +67,8 @@
6767
CommandLineArgUtil.CANCEL_CHANGES_IF_RESTART_REQ_SWITCH,
6868
CommandLineArgUtil.OUTPUT_DIR_SWITCH,
6969
CommandLineArgUtil.UPDATE_RCU_SCHEMA_PASS_SWITCH,
70-
CommandLineArgUtil.DISCARD_CURRENT_EDIT_SWITCH
70+
CommandLineArgUtil.DISCARD_CURRENT_EDIT_SWITCH,
71+
CommandLineArgUtil.WAIT_FOR_EDIT_LOCK_SWITCH
7172
]
7273

7374

@@ -123,14 +124,20 @@ def __update_online(model, model_context, aliases):
123124
admin_user = model_context.get_admin_user()
124125
admin_pwd = model_context.get_admin_password()
125126
timeout = model_context.get_model_config().get_connect_timeout()
127+
skip_edit_session_check = model_context.is_discard_current_edit() or model_context.is_wait_for_edit_lock()
128+
edit_lock_acquire_timeout = model_context.get_model_config().get_wlst_edit_lock_acquire_timeout()
129+
edit_lock_release_timeout = model_context.get_model_config().get_wlst_edit_lock_release_timeout()
130+
edit_lock_exclusive = model_context.get_model_config().get_wlst_edit_lock_exclusive()
126131

127132
__logger.info("WLSDPLY-09005", admin_url, timeout, method_name=_method_name, class_name=_class_name)
128133

129134
try:
130135
__wlst_helper.connect(admin_user, admin_pwd, admin_url, timeout)
131-
deployer_utils.ensure_no_uncommitted_changes_or_edit_sessions(model_context.is_discard_current_edit())
136+
deployer_utils.ensure_no_uncommitted_changes_or_edit_sessions(skip_edit_session_check)
132137
__wlst_helper.edit()
133-
__wlst_helper.start_edit()
138+
__logger.fine("WLSDPLY-09019", edit_lock_acquire_timeout, edit_lock_release_timeout, edit_lock_exclusive)
139+
__wlst_helper.start_edit(acquire_timeout=edit_lock_acquire_timeout, release_timeout=edit_lock_release_timeout,
140+
exclusive=edit_lock_exclusive)
134141
if model_context.is_discard_current_edit():
135142
deployer_utils.discard_current_edit()
136143
except BundleAwareException, ex:

core/src/main/python/wlsdeploy/tool/util/wlst_helper.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -839,16 +839,21 @@ def edit(self):
839839
raise pwe
840840
self.__logger.exiting(class_name=self.__class_name, method_name=_method_name)
841841

842-
def start_edit(self):
842+
def start_edit(self, acquire_timeout=0, release_timeout=-1, exclusive='false'):
843843
"""
844844
Start an edit session with the WebLogic Server for the currently connected user.
845+
:param acquire_timeout: Time (in milliseconds) that WLST waits until it gets a lock, in the event that another user has a lock.
846+
:param release_timeout: Timeout (in milliseconds) that WLST waits to release the edit lock (-1 means edit session never expires).
847+
:param exclusive: Whether to request an exclusive lock or not
845848
:raises: Exception for the specified tool type: if a WLST error occurs
846849
"""
850+
"""
851+
"""
847852
_method_name = 'start_edit'
848-
self.__logger.entering(class_name=self.__class_name, method_name=_method_name)
853+
self.__logger.entering(acquire_timeout, release_timeout, exclusive, class_name=self.__class_name, method_name=_method_name)
849854

850855
try:
851-
self.__load_global('startEdit')()
856+
self.__load_global('startEdit')(waitTimeInMillis=acquire_timeout, timeOutInMillis=release_timeout, exclusive=exclusive)
852857
except self.__load_global('WLSTException'), e:
853858
pwe = exception_helper.create_exception(self.__exception_type, 'WLSDPLY-00050',
854859
_format_exception(e), error=e)

core/src/main/python/wlsdeploy/util/cla_utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class CommandLineArgUtil(object):
9797
# extractDomainResource output file
9898
DOMAIN_RESOURCE_FILE_SWITCH = '-domain_resource_file'
9999
OUTPUT_DIR_SWITCH = "-output_dir"
100-
100+
WAIT_FOR_EDIT_LOCK_SWITCH = "-wait_for_edit_lock"
101101
TARGET_SWITCH = '-target'
102102

103103

@@ -112,7 +112,8 @@ class CommandLineArgUtil(object):
112112
RUN_RCU_SWITCH,
113113
UPDATE_RCU_SCHEMA_PASS_SWITCH,
114114
DISCARD_CURRENT_EDIT_SWITCH,
115-
USE_ENCRYPTION_SWITCH
115+
USE_ENCRYPTION_SWITCH,
116+
WAIT_FOR_EDIT_LOCK_SWITCH
116117
]
117118

118119
# a slot to stash the parsed domain typedef dictionary

core/src/main/python/wlsdeploy/util/model_config.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
"""
2-
Copyright (c) 2020, Oracle Corporation and/or its affiliates.
2+
Copyright (c) 2020, 2022, Oracle Corporation and/or its affiliates.
33
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
"""
55

66
from java.io import IOException
77
from java.lang import Long
88
from java.lang import NumberFormatException
9+
from java.lang import System
910

10-
from wlsdeploy.exception import exception_helper
1111
from wlsdeploy.logging.platform_logger import PlatformLogger
1212
from wlsdeploy.util import path_utils
1313
from wlsdeploy.util import string_utils
@@ -36,6 +36,15 @@
3636
STOP_APP_TIMEOUT_DEFAULT = '180000'
3737
SET_SERVER_GRPS_TIMEOUT_PROP = 'set.server.groups.timeout'
3838
SET_SERVER_GRPS_TIMEOUT_DEFAULT = '30000'
39+
WLST_EDIT_LOCK_ACQUIRE_TIMEOUT_PROP = 'wlst.edit.lock.acquire.timeout'
40+
WLST_EDIT_LOCK_ACQUIRE_TIMEOUT_DEFAULT = '0'
41+
WLST_EDIT_LOCK_RELEASE_TIMEOUT_PROP = 'wlst.edit.lock.release.timeout'
42+
WLST_EDIT_LOCK_RELEASE_TIMEOUT_DEFAULT = '-1'
43+
WLST_EDIT_LOCK_EXCLUSIVE_PROP = 'wlst.edit.lock.exclusive'
44+
WLST_EDIT_LOCK_EXCLUSIVE_DEFAULT = 'false'
45+
46+
# System Property overrides for WLST timeout properties
47+
SYS_PROP_PREFIX = 'wdt.config.'
3948

4049

4150
class ModelConfiguration(object):
@@ -107,12 +116,34 @@ def get_set_server_grps_timeout(self):
107116
"""
108117
return self._get_from_dict_as_long(SET_SERVER_GRPS_TIMEOUT_PROP, SET_SERVER_GRPS_TIMEOUT_DEFAULT)
109118

119+
def get_wlst_edit_lock_acquire_timeout(self):
120+
"""
121+
Return the waitTimeInMillis for startEdit from tool properties
122+
:return: wlst edit lock acquire timeout
123+
"""
124+
return self._get_from_dict_as_long(WLST_EDIT_LOCK_ACQUIRE_TIMEOUT_PROP, WLST_EDIT_LOCK_ACQUIRE_TIMEOUT_DEFAULT)
125+
126+
def get_wlst_edit_lock_release_timeout(self):
127+
"""
128+
Return the timeOutInMillis for startEdit from tool properties
129+
:return: wlst edit lock release timeout
130+
"""
131+
return self._get_from_dict_as_long(WLST_EDIT_LOCK_RELEASE_TIMEOUT_PROP, WLST_EDIT_LOCK_RELEASE_TIMEOUT_DEFAULT)
132+
133+
def get_wlst_edit_lock_exclusive(self):
134+
"""
135+
Returns the exclusive value for startEdit from tool properties
136+
:return: the string 'true' or 'false' (default)
137+
"""
138+
return self._get_from_dict(WLST_EDIT_LOCK_EXCLUSIVE_PROP, WLST_EDIT_LOCK_EXCLUSIVE_DEFAULT)
139+
110140
def _get_from_dict(self, name, default_value=None):
111141
_method_name = '_get_from_dict'
112142
_logger.entering(name, default_value, class_name=_class_name, method_name=_method_name)
113143
result = default_value
114144
if name in self.__config_dict:
115145
result = self.__config_dict[name]
146+
result = System.getProperty(SYS_PROP_PREFIX + name, result)
116147
_logger.exiting(result=result, class_name=_class_name, method_name=_method_name)
117148
return result
118149

core/src/main/python/wlsdeploy/util/model_context.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ def __init__(self, program_name, arg_map):
9898
self._variable_properties_file = None
9999
self._rcu_db_user = self.DB_USER_DEFAULT
100100
self._discard_current_edit = False
101+
self._wait_for_edit_lock = False
101102
self._model_config = None
102103

103104
self._trailing_args = []
@@ -153,6 +154,9 @@ def __copy_from_args(self, arg_map):
153154
if CommandLineArgUtil.DISCARD_CURRENT_EDIT_SWITCH in arg_map:
154155
self._discard_current_edit = arg_map[CommandLineArgUtil.DISCARD_CURRENT_EDIT_SWITCH]
155156

157+
if CommandLineArgUtil.WAIT_FOR_EDIT_LOCK_SWITCH in arg_map:
158+
self._wait_for_edit_lock = arg_map[CommandLineArgUtil.WAIT_FOR_EDIT_LOCK_SWITCH]
159+
156160
if CommandLineArgUtil.PREVIOUS_MODEL_FILE_SWITCH in arg_map:
157161
self._previous_model_file = arg_map[CommandLineArgUtil.PREVIOUS_MODEL_FILE_SWITCH]
158162

@@ -289,6 +293,8 @@ def __copy__(self):
289293
arg_map[CommandLineArgUtil.RUN_RCU_SWITCH] = self._run_rcu
290294
if self._discard_current_edit is not None:
291295
arg_map[CommandLineArgUtil.DISCARD_CURRENT_EDIT_SWITCH] = self._discard_current_edit
296+
if self._wait_for_edit_lock is not None:
297+
arg_map[CommandLineArgUtil.WAIT_FOR_EDIT_LOCK_SWITCH] = self._wait_for_edit_lock
292298
if self._rcu_database is not None:
293299
arg_map[CommandLineArgUtil.RCU_DB_SWITCH] = self._rcu_database
294300
if self._rcu_prefix is not None:
@@ -474,6 +480,13 @@ def is_discard_current_edit(self):
474480
"""
475481
return self._discard_current_edit
476482

483+
def is_wait_for_edit_lock(self):
484+
"""
485+
Get the wait for edit lock value.
486+
:return: true or false
487+
"""
488+
return self._wait_for_edit_lock
489+
477490
def get_opss_wallet(self):
478491
"""
479492
Get the opss wallet.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,7 @@ WLSDPLY-09016=There are outstanding changes but -discard_current_edit has been s
10521052
discarded before processing update.
10531053
WLSDPLY-09017=NOT USED
10541054
WLSDPLY-09018=Online update has been canceled because the flag cancel_changes_if_restart_required is set and the update requires restart: {0}
1055+
WLSDPLY-09019=Acquiring online edit lock with acquire timeout value of {0}, release timeout value of {1}, and exclusive value of {2}
10551056

10561057
# wlsdeploy/tool/deploy/deployer_utils.py
10571058
WLSDPLY-09100=Existing object names are {0}

documentation/2.0/content/userguide/tools-config/tool_prop.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,18 @@ weight: 4
1010

1111
If a property is removed from the file, or a property value is incorrectly formatted, a `WARNING` message is logged and an internal default value used instead of the missing or bad value.
1212

13-
| Property | Description |
14-
| -------- | ----- |
15-
| `connect.timeout` | The number of milliseconds that WLST waits for the online `connect` command to complete. A value of 0 means the operation will not timeout. |
16-
| `activate.timeout` | The number of milliseconds that WLST waits for the activation of configuration changes to complete. A value of -1 means the operation will not timeout. |
17-
| `deploy.timeout` | The number of milliseconds that WLST waits for the undeployment process to complete. A value of 0 means the operation will not timeout. |
18-
| `redeploy.timeout` | The number of milliseconds that WLST waits for the redeployment process to complete. A value of 0 means the operation will not timeout. |
19-
| `start.application.timeout` | The number of milliseconds that WLST waits for the start application process to complete. A value of 0 means the operation will not timeout. |
20-
| `stop.application.timeout` | The number of milliseconds that WLST waits for the stop application process to complete. A value of 0 means the operation will not timeout. |
21-
| `set.server.groups.timeout` | Specifies the amount of time the set server groups connection can be inactive before the connection times out. |
13+
| Property | Description |
14+
|----------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
15+
| `connect.timeout` | The number of milliseconds that WLST waits for the online `connect` command to complete. A value of 0 means the operation will not timeout. |
16+
| `activate.timeout` | The number of milliseconds that WLST waits for the activation of configuration changes to complete. A value of -1 means the operation will not timeout. |
17+
| `deploy.timeout` | The number of milliseconds that WLST waits for the undeployment process to complete. A value of 0 means the operation will not timeout. |
18+
| `redeploy.timeout` | The number of milliseconds that WLST waits for the redeployment process to complete. A value of 0 means the operation will not timeout. |
19+
| `start.application.timeout` | The number of milliseconds that WLST waits for the start application process to complete. A value of 0 means the operation will not timeout. |
20+
| `stop.application.timeout` | The number of milliseconds that WLST waits for the stop application process to complete. A value of 0 means the operation will not timeout. |
21+
| `set.server.groups.timeout` | Specifies the amount of time the set server groups connection can be inactive before the connection times out. |
22+
| `wlst.edit.lock.acquire.timeout` | Specifies the amount of time in milliseconds the WLST online `startEdit` command will wait trying to acquire the edit lock before it times out. |
23+
| `wlst.edit.lock.release.timeout` | Specifies the amount of time in milliseconds the WLST online `startEdit` command will wait for the edit lock to be released before releasing it automatically. |
24+
| `wlst.edit.lock.exclusive` | Specifies whether the edit lock acquired by `startEdit` should be exclusive or shared (default is shared). |
25+
26+
You can override the value of a single property using a Java System property with the name `wdt.config.<tool-property-name>`.
27+
For example, adding `-Dwdt.config.connect.timeout=5000` will set the effective `connect.timeout` property to 5000 milliseconds, regardless of what the value in the tool.properties file might be.

documentation/2.0/content/userguide/tools/deploy.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,4 @@ The Deploy Applications Tool supports the use of multiple models, as described i
6161
| `-passphrase_file` | An alternative to entering the encryption passphrase at a prompt. The value is the name of a file with a string value which WDT will read to retrieve the passphrase. | |
6262
| `-use_encryption` | One or more of the passwords in the model or variables file(s) are encrypted and must be decrypted. Java 8 or later is required for this feature. | |
6363
| `-variable_file` | The location of the property file containing the values for variables used in the model. This can also be specified as a comma-separated list of property files, where each successive set of properties layers on top of the previous ones. | |
64+
| `-wait_for_edit_lock` | Skip checks for active edit sessions and pending changes before trying to acquire the WLST online edit lock to modify domain configuration. | |

0 commit comments

Comments
 (0)