Skip to content

Commit 26b684a

Browse files
rakillenddsharpe
authored andcommitted
Use Jython directly in validateModel for faster performance (#506)
* Initial check-in, read alias files, find folders for paths * Set system property to avoid warning in JDK 11 * Remove wlst.silence(), not needed for Jython * Move non-WLST methods to model helper * Move non-WLST methods to model helper * Revised scripts to use Jython directly * Remove wlst.silence(), not needed in Jython * Remove Java UsagePrinter * Set python console to empty for 14.1.1
1 parent f4b782f commit 26b684a

File tree

10 files changed

+115
-57
lines changed

10 files changed

+115
-57
lines changed

core/src/main/python/validate.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2019, Oracle Corporation and/or its affiliates. All rights reserved.
2+
Copyright (c) 2017, 2020, Oracle Corporation and/or its affiliates. All rights reserved.
33
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
55
The WLS Deploy tooling entry point for the validateModel tool.
@@ -25,7 +25,6 @@
2525
from wlsdeploy.tool.validate.validator import Validator
2626
from wlsdeploy.util import cla_helper
2727
from wlsdeploy.util import tool_exit
28-
from wlsdeploy.util import wlst_helper
2928
from wlsdeploy.util.cla_utils import CommandLineArgUtil
3029
from wlsdeploy.util.weblogic_helper import WebLogicHelper
3130

@@ -202,8 +201,6 @@ def main(args):
202201
for index, arg in enumerate(args):
203202
__logger.finer('sys.argv[{0}] = {1}', str(index), arg, class_name=_class_name, method_name=_method_name)
204203

205-
wlst_helper.silence()
206-
207204
exit_code = CommandLineArgUtil.PROG_OK_EXIT_CODE
208205

209206
try:

core/src/main/python/wlsdeploy/tool/create/creator.py

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

@@ -14,6 +14,7 @@
1414
from wlsdeploy.tool.util.alias_helper import AliasHelper
1515
from wlsdeploy.tool.util.attribute_setter import AttributeSetter
1616
from wlsdeploy.util import dictionary_utils
17+
from wlsdeploy.util import model_helper
1718
from wlsdeploy.tool.util.wlst_helper import WlstHelper
1819
from wlsdeploy.util.model import Model
1920
from wlsdeploy.util.weblogic_helper import WebLogicHelper
@@ -71,7 +72,7 @@ def _create_named_mbeans(self, type_name, model_nodes, base_location, log_create
7172
existing_folder_names = self._get_existing_folders(list_path)
7273
for model_name in model_nodes.keys():
7374
name = self.wlst_helper.get_quoted_name_for_wlst(model_name)
74-
if deployer_utils.is_delete_name(name):
75+
if model_helper.is_delete_name(name):
7576
deployer_utils.delete_named_element(location, name, existing_folder_names, self.alias_helper)
7677
continue
7778

core/src/main/python/wlsdeploy/tool/deploy/deployer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from wlsdeploy.exception.expection_types import ExceptionType
1515
from wlsdeploy.logging.platform_logger import PlatformLogger
1616
from wlsdeploy.tool.deploy import deployer_utils
17+
from wlsdeploy.util import model_helper
1718
from wlsdeploy.tool.deploy import log_helper
1819
from wlsdeploy.tool.util.alias_helper import AliasHelper
1920
from wlsdeploy.tool.util.archive_helper import ArchiveHelper
@@ -80,7 +81,7 @@ def _add_named_elements(self, type_name, model_nodes, location):
8081

8182
token = self.alias_helper.get_name_token(location)
8283
for name in model_nodes:
83-
if deployer_utils.is_delete_name(name):
84+
if model_helper.is_delete_name(name):
8485
deployer_utils.delete_named_element(location, name, existing_names, self.alias_helper)
8586
continue
8687

core/src/main/python/wlsdeploy/tool/deploy/deployer_utils.py

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2019, Oracle Corporation and/or its affiliates. All rights reserved.
2+
Copyright (c) 2017, 2020, Oracle Corporation and/or its affiliates. All rights reserved.
33
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
"""
55
from sets import Set
@@ -15,6 +15,7 @@
1515
from wlsdeploy.exception import exception_helper
1616
from wlsdeploy.exception.expection_types import ExceptionType
1717
from wlsdeploy.logging import platform_logger
18+
from wlsdeploy.util import model_helper
1819
from wlsdeploy.tool.util.wlst_helper import WlstHelper
1920

2021
from wlsdeploy.aliases.model_constants import RESOURCE_GROUP
@@ -177,32 +178,6 @@ def merge_lists(existing_list, model_list, separator=',', return_as_string=True)
177178
return result
178179

179180

180-
def is_delete_name(name):
181-
"""
182-
Determines if the specified name is flagged for deletion with the "!" prefix.
183-
:param name: the name to be checked
184-
:return: True if the name is prefixed, false otherwise
185-
"""
186-
return name.startswith("!")
187-
188-
189-
def get_delete_item_name(name):
190-
"""
191-
Returns the WLST name of the item to be deleted.
192-
Removes the "!" prefix from the name. An exception is thrown if the name is not prefixed.
193-
:param name: the prefixed model name of the item to be deleted
194-
:return: the model name of the item to be deleted
195-
"""
196-
_method_name = 'get_delete_item_name'
197-
198-
if is_delete_name(name):
199-
return name[1:]
200-
201-
ex = exception_helper.create_deploy_exception('WLSDPLY-09111', name)
202-
_logger.throwing(ex, class_name=_class_name, method_name=_method_name)
203-
raise ex
204-
205-
206181
def delete_named_element(location, delete_name, existing_names, alias_helper):
207182
"""
208183
Delete the specified named element if present. If the name is not present, log a warning and return.
@@ -213,7 +188,7 @@ def delete_named_element(location, delete_name, existing_names, alias_helper):
213188
"""
214189
_method_name = 'delete_named_element'
215190

216-
name = get_delete_item_name(delete_name)
191+
name = model_helper.get_delete_item_name(delete_name)
217192
type_name = alias_helper.get_wlst_mbean_type(location)
218193

219194
if name not in existing_names:

core/src/main/python/wlsdeploy/tool/deploy/jms_resources_deployer.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2017, 2019, Oracle Corporation and/or its affiliates. All rights reserved.
2+
Copyright (c) 2017, 2020, Oracle Corporation and/or its affiliates. All rights reserved.
33
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
"""
55
import oracle.weblogic.deploy.util.PyOrderedDict as OrderedDict
@@ -28,6 +28,7 @@
2828
from wlsdeploy.aliases.model_constants import UNIFORM_DISTRIBUTED_TOPIC
2929
from wlsdeploy.aliases.wlst_modes import WlstModes
3030
from wlsdeploy.tool.deploy import deployer_utils
31+
from wlsdeploy.util import model_helper
3132
from wlsdeploy.tool.deploy import log_helper
3233
from wlsdeploy.tool.deploy.deployer import Deployer
3334

@@ -155,8 +156,8 @@ def _add_jndi_properties(self, property_name_nodes, location):
155156
mbean_type = self.alias_helper.get_wlst_mbean_type(properties_location)
156157

157158
for property_name in property_name_nodes:
158-
if deployer_utils.is_delete_name(property_name):
159-
name = deployer_utils.get_delete_item_name(property_name)
159+
if model_helper.is_delete_name(property_name):
160+
name = model_helper.get_delete_item_name(property_name)
160161
self._delete_mapped_mbean(properties_location, properties_token, mbean_type, name_attribute, name)
161162
del remaining_name_nodes[property_name]
162163

@@ -209,9 +210,9 @@ def _add_group_params(self, group_name_nodes, location):
209210
mbean_type = self.alias_helper.get_wlst_mbean_type(groups_location)
210211

211212
for group_name in group_name_nodes:
212-
if deployer_utils.is_delete_name(group_name):
213+
if model_helper.is_delete_name(group_name):
213214
group_nodes = group_name_nodes[group_name]
214-
name = deployer_utils.get_delete_item_name(group_name)
215+
name = model_helper.get_delete_item_name(group_name)
215216
sub_name = self._get_subdeployment_name(group_nodes, name)
216217
self._delete_mapped_mbean(groups_location, groups_token, mbean_type, name_attribute, sub_name)
217218
del remaining_name_nodes[group_name]

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

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

6-
import oracle.weblogic.deploy.util.StringUtils as StringUtils
7-
86
import wlsdeploy.tool.deploy.deployer_utils as deployer_utils
97
import wlsdeploy.util.dictionary_utils as dictionary_utils
108
from oracle.weblogic.deploy.util import WLSDeployArchive
@@ -17,6 +15,7 @@
1715
from wlsdeploy.aliases.model_constants import NM_PROPERTIES
1816
from wlsdeploy.aliases.model_constants import SERVER
1917
from wlsdeploy.aliases.model_constants import SERVER_TEMPLATE
18+
from wlsdeploy.util import model_helper
2019
from wlsdeploy.tool.util.alias_helper import AliasHelper
2120
from wlsdeploy.tool.util.wlst_helper import WlstHelper
2221

@@ -113,7 +112,7 @@ def create_placeholder_named_elements(self, location, model_type, model_nodes):
113112

114113
name_nodes = dictionary_utils.get_dictionary_element(model_nodes, model_type)
115114
for name in name_nodes.keys():
116-
if deployer_utils.is_delete_name(name):
115+
if model_helper.is_delete_name(name):
117116
# don't create placeholder for delete names
118117
continue
119118

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
Copyright (c) 2019, Oracle Corporation and/or its affiliates. All rights reserved.
2+
Copyright (c) 2019, 2020, Oracle Corporation and/or its affiliates. All rights reserved.
33
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
44
55
Utility CLS methods shared by multiple tools.
@@ -9,9 +9,9 @@
99

1010
from wlsdeploy.exception import exception_helper
1111
from wlsdeploy.logging.platform_logger import PlatformLogger
12-
from wlsdeploy.tool.deploy import deployer_utils
1312
from wlsdeploy.tool.util.archive_helper import ArchiveHelper
1413
from wlsdeploy.util import cla_utils
14+
from wlsdeploy.util import model_helper
1515
from wlsdeploy.util import variables
1616
from wlsdeploy.util.cla_utils import CommandLineArgUtil
1717
from wlsdeploy.util.model_translator import FileToPython
@@ -166,7 +166,7 @@ def _merge_dictionaries(dictionary, new_dictionary, variable_map):
166166
# the new key should replace the existing one - delete the existing key and add the new one
167167
elif replace_key:
168168
del dictionary[dictionary_key]
169-
if not deployer_utils.is_delete_name(new_key):
169+
if not model_helper.is_delete_name(new_key):
170170
dictionary[new_key] = new_value
171171

172172
# the key is in both dictionaries - merge if the values are dictionaries, otherwise replace the value
@@ -192,11 +192,11 @@ def _find_dictionary_merge_key(dictionary, new_key, variable_map):
192192
if new_key in dictionary:
193193
return new_key, False
194194

195-
new_is_delete = deployer_utils.is_delete_name(new_key)
195+
new_is_delete = model_helper.is_delete_name(new_key)
196196
match_new_key = _get_merge_match_key(new_key, variable_map)
197197

198198
for dictionary_key in dictionary.keys():
199-
dictionary_is_delete = deployer_utils.is_delete_name(dictionary_key)
199+
dictionary_is_delete = model_helper.is_delete_name(dictionary_key)
200200
match_dictionary_key = _get_merge_match_key(dictionary_key, variable_map)
201201
if match_dictionary_key == match_new_key:
202202
replace_key = new_is_delete != dictionary_is_delete
@@ -218,6 +218,6 @@ def _get_merge_match_key(key, variable_map):
218218
else:
219219
match_key = key
220220

221-
if deployer_utils.is_delete_name(match_key):
222-
match_key = deployer_utils.get_delete_item_name(match_key)
221+
if model_helper.is_delete_name(match_key):
222+
match_key = model_helper.get_delete_item_name(match_key)
223223
return match_key
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""
2+
Copyright (c) 2019, 2020, Oracle Corporation and/or its affiliates. All rights reserved.
3+
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4+
"""
5+
6+
from wlsdeploy.exception import exception_helper
7+
from wlsdeploy.logging import platform_logger
8+
9+
_class_name = "model_helper"
10+
_logger = platform_logger.PlatformLogger('wlsdeploy.model.helper')
11+
12+
# Helper methods for WDT model (Jython-compatible)
13+
14+
15+
def is_delete_name(name):
16+
"""
17+
Determines if the specified name is flagged for deletion with the "!" prefix.
18+
:param name: the name to be checked
19+
:return: True if the name is prefixed, false otherwise
20+
"""
21+
return name.startswith("!")
22+
23+
24+
def get_delete_item_name(name):
25+
"""
26+
Returns the WLST name of the item to be deleted.
27+
Removes the "!" prefix from the name. An exception is thrown if the name is not prefixed.
28+
:param name: the prefixed model name of the item to be deleted
29+
:return: the model name of the item to be deleted
30+
"""
31+
_method_name = 'get_delete_item_name'
32+
33+
if is_delete_name(name):
34+
return name[1:]
35+
36+
ex = exception_helper.create_deploy_exception('WLSDPLY-09111', name)
37+
_logger.throwing(ex, class_name=_class_name, method_name=_method_name)
38+
raise ex

installer/src/main/bin/validateModel.cmd

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
@rem **************************************************************************
33
@rem validateModel.cmd
44
@rem
5-
@rem Copyright (c) 2017, 2019, Oracle Corporation and/or its affiliates. All rights reserved.
5+
@rem Copyright (c) 2017, 2020, Oracle Corporation and/or its affiliates. All rights reserved.
66
@rem Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
77
@rem
88
@rem NAME
@@ -279,10 +279,24 @@ IF NOT EXIST "%WLST%" (
279279
)
280280
:found_wlst
281281

282+
SET ORACLE_SERVER_DIR=
283+
284+
IF EXIST "%ORACLE_HOME%\wlserver_10.3" (
285+
SET ORACLE_SERVER_DIR=%ORACLE_HOME%\wlserver_10.3"
286+
GOTO found_wlst
287+
) ELSE IF EXIST "%ORACLE_HOME%\wlserver_12.1" (
288+
SET ORACLE_SERVER_DIR=%ORACLE_HOME%\wlserver_12.1"
289+
) ELSE (
290+
SET ORACLE_SERVER_DIR=%ORACLE_HOME%\wlserver
291+
)
292+
282293
SET LOG_CONFIG_CLASS=oracle.weblogic.deploy.logging.WLSDeployCustomizeLoggingConfig
283294
SET WLSDEPLOY_LOG_HANDLER=oracle.weblogic.deploy.logging.SummaryHandler
284295
SET WLST_PROPERTIES=-Dcom.oracle.cie.script.throwException=true
285296
SET "WLST_PROPERTIES=-Djava.util.logging.config.class=%LOG_CONFIG_CLASS% %WLST_PROPERTIES%"
297+
SET "WLST_PROPERTIES=-Dpython.cachedir.skip=true %WLST_PROPERTIES%"
298+
SET "WLST_PROPERTIES=-Dpython.path=%ORACLE_SERVER_DIR%/common/wlst/modules/jython-modules.jar/Lib %WLST_PROPERTIES%"
299+
SET "WLST_PROPERTIES=-Dpython.console= %WLST_PROPERTIES%"
286300
SET "WLST_PROPERTIES=%WLST_PROPERTIES% %WLSDEPLOY_PROPERTIES%"
287301

288302
IF NOT DEFINED WLSDEPLOY_LOG_PROPERTIES (
@@ -295,15 +309,25 @@ IF NOT DEFINED WLSDEPLOY_LOG_HANDLERS (
295309
SET WLSDEPLOY_LOG_HANDLERS=%WLSDEPLOY_LOG_HANDLER%
296310
)
297311

312+
set CLASSPATH=%CLASSPATH%;%ORACLE_SERVER_DIR%\server\lib\weblogic.jar
313+
298314
ECHO JAVA_HOME = %JAVA_HOME%
299315
ECHO WLST_EXT_CLASSPATH = %WLST_EXT_CLASSPATH%
300316
ECHO CLASSPATH = %CLASSPATH%
301317
ECHO WLST_PROPERTIES = %WLST_PROPERTIES%
302318

303319
SET PY_SCRIPTS_PATH=%WLSDEPLOY_HOME%\lib\python
304-
ECHO %WLST% %PY_SCRIPTS_PATH%\validate.py %SCRIPT_ARGS%
305320

306-
"%WLST%" "%PY_SCRIPTS_PATH%\validate.py" %SCRIPT_ARGS%
321+
ECHO ^
322+
%JAVA_HOME%/bin/java -cp %CLASSPATH% ^
323+
%WLST_PROPERTIES% ^
324+
org.python.util.jython ^
325+
"%PY_SCRIPTS_PATH%\validate.py" %SCRIPT_ARGS%
326+
327+
%JAVA_HOME%/bin/java -cp %CLASSPATH% ^
328+
%WLST_PROPERTIES% ^
329+
org.python.util.jython ^
330+
"%PY_SCRIPTS_PATH%\validate.py" %SCRIPT_ARGS%
307331

308332
SET RETURN_CODE=%ERRORLEVEL%
309333
IF "%RETURN_CODE%" == "100" (

installer/src/main/bin/validateModel.sh

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# *****************************************************************************
33
# validateModel.sh
44
#
5-
# Copyright (c) 2017, 2019, Oracle Corporation and/or its affiliates. All rights reserved.
5+
# Copyright (c) 2017, 2020, Oracle Corporation and/or its affiliates. All rights reserved.
66
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
77
#
88
# NAME
@@ -265,10 +265,23 @@ else
265265
fi
266266
fi
267267

268+
ORACLE_SERVER_DIR=
269+
270+
if [ -x ${ORACLE_HOME}/wlserver_10.3 ]; then
271+
ORACLE_SERVER_DIR=${ORACLE_HOME}/wlserver_10.3
272+
elif [ -x ${ORACLE_HOME}/wlserver_12.1 ]; then
273+
ORACLE_SERVER_DIR=${ORACLE_HOME}/wlserver_12.1
274+
else
275+
ORACLE_SERVER_DIR=${ORACLE_HOME}/wlserver
276+
fi
277+
268278
LOG_CONFIG_CLASS=oracle.weblogic.deploy.logging.WLSDeployCustomizeLoggingConfig
269279
WLSDEPLOY_LOG_HANDLER=oracle.weblogic.deploy.logging.SummaryHandler
270280
WLST_PROPERTIES=-Dcom.oracle.cie.script.throwException=true
271281
WLST_PROPERTIES="-Djava.util.logging.config.class=${LOG_CONFIG_CLASS} ${WLST_PROPERTIES} ${WLSDEPLOY_PROPERTIES}"
282+
WLST_PROPERTIES="-Dpython.cachedir.skip=true ${WLST_PROPERTIES}"
283+
WLST_PROPERTIES="-Dpython.path=${ORACLE_SERVER_DIR}/common/wlst/modules/jython-modules.jar/Lib ${WLST_PROPERTIES}"
284+
WLST_PROPERTIES="-Dpython.console= ${WLST_PROPERTIES}"
272285
export WLST_PROPERTIES
273286

274287
if [ -z "${WLSDEPLOY_LOG_PROPERTIES}" ]; then
@@ -283,15 +296,24 @@ if [ -z "${WLSDEPLOY_LOG_HANDLERS}" ]; then
283296
WLSDEPLOY_LOG_HANDLERS=${WLSDEPLOY_LOG_HANDLER}; export WLSDEPLOY_LOG_HANDLERS
284297
fi
285298

299+
CLASSPATH=${CLASSPATH}:${ORACLE_SERVER_DIR}/server/lib/weblogic.jar
300+
286301
echo "JAVA_HOME = ${JAVA_HOME}"
287302
echo "WLST_EXT_CLASSPATH = ${WLST_EXT_CLASSPATH}"
288303
echo "CLASSPATH = ${CLASSPATH}"
289304
echo "WLST_PROPERTIES = ${WLST_PROPERTIES}"
290305

291306
PY_SCRIPTS_PATH=${WLSDEPLOY_HOME}/lib/python
292-
echo "${WLST} ${PY_SCRIPTS_PATH}/validate.py ${SCRIPT_ARGS}"
307+
echo \
308+
${JAVA_HOME}/bin/java -cp ${CLASSPATH} \
309+
${WLST_PROPERTIES} \
310+
org.python.util.jython \
311+
"${PY_SCRIPTS_PATH}/validate.py" ${SCRIPT_ARGS}
293312

294-
"${WLST}" "${PY_SCRIPTS_PATH}/validate.py" ${SCRIPT_ARGS}
313+
${JAVA_HOME}/bin/java -cp ${CLASSPATH} \
314+
${WLST_PROPERTIES} \
315+
org.python.util.jython \
316+
"${PY_SCRIPTS_PATH}/validate.py" ${SCRIPT_ARGS}
295317

296318
RETURN_CODE=$?
297319
if [ ${RETURN_CODE} -eq 100 ]; then

0 commit comments

Comments
 (0)