我有一个基本的groovy脚本执行时间长的问题:
cas.propierties:
cas.authn.attribute-repository.groovy[0].location=file:/etc/cas/config/custom-attr.groovy
字符串
custom-attr.groovy:
import java.util.*
import java.text.SimpleDateFormat
import groovy.transform.Field
import javax.naming.directory.*
import java.util.Hashtable
import javax.naming.*
@Field File file = new File("/etc/cas/config/groovy_logs.txt")
def run(final Object... args) {
def (username,attributes,logger,properties,appContext) = args
logger.debug("[{}]: The received uid is [{}]", this.class.simpleName, username)
file.append "\n login: "+args[0]+" cas-id:"+args[1]['principal']+"\n"
file.append "\n version groove: "+GroovySystem.version+"\n"
// All attribute values must be defined as a collection wrapped in []
return [username:[username], likes:["6cheese", "7food"], id:[1234,2,3,4,5], another:["attribute"] ]
println GroovySystem.version
}
型
开机后显示系统CAS参数:
CAS Version: 7.0.0-RC9
CAS Branch: master
CAS Commit Id: xxxxxxxxxxx
CAS Build Date/Time: 2023-11-25T07:12:15.881468Z
Spring Boot Version: 3.2.0
Spring Version: 6.1.0
Java Home: /usr/lib/jvm/zulu21-ca-amd64
Java Vendor: Azul Systems, Inc.
Java Version: 21.0.1
Servlet Version: 6.0.0
JVM Free Memory: 345 MB
JVM Maximum Memory: 4 GB
JVM Total Memory: 512 MB
OS Architecture: amd64
OS Name: Linux
OS Version: 5.4.0-167-generic
OS Date/Time: 2023-12-12T10:35:50.786113719
OS Temp Directory: /tmp
型
:
2023-12-12 10:41:41,731 DEBUG [org.apereo.cas.authentication.attribute.PrincipalAttributeRepositoryFetcher] - <Fetching person attributes for query [{principal=xxxxxx data xxxxxxx}]>
no activity in the log (just waiting )
2023-12-12 10:41:55,497 DEBUG [org.apereo.cas.authentication.principal.resolvers.InternalGroovyScriptDao] - <[custom-attr]: The received uid is [christmas_banny]>
2023-12-12 10:41:55,497 DEBUG [org.apereo.cas.authentication.principal.resolvers.InternalGroovyScriptDao] - <Groovy-based attributes found are [{username=[christmas_banny], likes=[6cheese, 7food], id=[1234, 2, 3, 4, 5], another=[attribute]}]>
型
这个问题只发生在我们附加了groovy而没有groovy身份验证的情况下。Groovy很慢或者等待,但是在15sek返回额外的元数据之后。15sek超时的问题是什么或者在哪里找到解决方案?
为了消除15sek。
1条答案
按热度按时间dgiusagp1#
这是第一次还是一直都是?对于contenerized cas,它总是超过10秒,对于非contenerized cas,它总是超过5秒。5秒或10秒太多了。它应该是ms。对于这个基本脚本,我们与其他服务没有任何连接
我在cas.properties中设置的TRACE模式下进行了dipper挖掘,发现问题可能是“* 创建groovy对象示例 *”
cas日志:
2023-12-13 11:03:36,183 TRACE [org.apereo.cas.util.scripting.ScriptingUtils] - <从类[/etc/cas/config/custom-attr.groovy]创建groovy对象示例>
字符串
2023-12-13 11:03:TRACE [org.apereo.cas.util.scripting.ScriptingUtils] - <执行groovy脚本的[run]方法,参数为test,{principal=[test],credentialId=[test],credentialClass=[UsernamePasswordCredential],username=[test]},org.apache.logging.slf4j.Log4jLogger@3e812f4a,org.apereo.cas.configuration.CasablationPropertys@646427f7,org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@2e6d76 ba,于2023年12月13日星期三10:55:27 GMT+01:00开始,家长:org.springframework.context.annotation.AnnotationConfigApplicationContext@30af7377> 2023-12-13 11:03:50,897 DEBUG [org.apereo.cas.authentication.principal.resolvers.InternalGroovyScriptDao] - <[custom-attr]:接收到的uid是[test]> 2023-12-13 11:03:50,898 DEBUG [org.apereo.cas.authentication.principal.resolvers.InternalGroovyScriptDao]