how to configure Connection timed out

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

how to configure Connection timed out

Mr_xushuai
This post was updated on .
Hi yan,

Sometimes,An error is surfaced when I call your rest Api to depoly and execute following glu script statement:(sometimes they worked and sometimes not.)
def download_war_info = rootShell.fetch("ftp://username:password@yum.xxxx.com/web.war","${params.tempDir}");
Throws exception info :
* org.linkedin.glu.agent.api.ScriptExecutionException: "script=AdpTomcatChangeWarGluScript [/home/pplive/web], action=install"
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) java.lang.reflect.Constructor.newInstance(Constructor.java:526) org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77) org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102) org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57) org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182) org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:202) org.linkedin.glu.agent.impl.script.ScriptWrapperImpl$_getAvailableActionsClosures_closure1_closure3_closure4.doCall(ScriptWrapperImpl.groovy:69) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:606) org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233) org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272) groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:906) org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:39) org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) org.linkedin.groovy.util.state.StateMachineImpl.doExecute(StateMachineImpl.groovy:385) org.linkedin.groovy.util.state.StateMachineImpl.this$2$doExecute(StateMachineImpl.groovy) org.linkedin.groovy.util.state.StateMachineImpl$this$2$doExecute.callCurrent(Unknown Source) org.linkedin.groovy.util.state.StateMachineImpl.executeAction(StateMachineImpl.groovy:320) org.linkedin.groovy.util.state.StateMachine$executeAction.call(Unknown Source) org.linkedin.glu.agent.impl.script.ScriptWrapperImpl$_getAvailableActionsClosures_closure1_closure3.doCall(ScriptWrapperImpl.groovy:60) sun.reflect.GeneratedMethodAccessor283.invoke(Unknown Source) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:606) org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233) org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272) groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:906) org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:39) org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120) org.linkedin.glu.agent.impl.script.ScriptWrapperImpl$__clinit__closure2_closure5_closure7.doCall(ScriptWrapperImpl.groovy:42) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:606) org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) org.codehaus.groovy.runtime.metaclass.ClosureMetaMethod.invoke(ClosureMetaMethod.java:80) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:606) org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSite.invoke(PojoMetaMethodSite.java:189) org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53) org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45) org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:55) org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120) org.linkedin.glu.groovy.utils.concurrent.Invocation.execute(Invocation.groovy:35) sun.reflect.GeneratedMethodAccessor281.invoke(Unknown Source) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:606) org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233) org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:361) groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:906) org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66) org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:137) org.linkedin.glu.groovy.utils.concurrent.FutureTaskExecution$_closure1.doCall(FutureTaskExecution.groovy:215) org.linkedin.glu.groovy.utils.concurrent.FutureTaskExecution$_closure1.doCall(FutureTaskExecution.groovy) sun.reflect.GeneratedMethodAccessor500.invoke(Unknown Source) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:606) org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233) org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272) groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:906) org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:39) org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112) org.linkedin.glu.groovy.utils.concurrent.GluGroovyConcurrentUtils$1.call(GluGroovyConcurrentUtils.groovy:40) java.util.concurrent.FutureTask.run(FutureTask.java:262) java_util_concurrent_RunnableFuture$run$2.call(Unknown Source) org.linkedin.glu.groovy.utils.concurrent.FutureTaskExecution.run(FutureTaskExecution.groovy:167) java_util_concurrent_RunnableFuture$run.call(Unknown Source) org.linkedin.glu.agent.impl.script.ScriptExecution$_closure2.doCall(ScriptExecution.groovy:591) org.linkedin.glu.agent.impl.script.ScriptExecution$_closure2.doCall(ScriptExecution.groovy) sun.reflect.GeneratedMethodAccessor390.invoke(Unknown Source) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:606) org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90) groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233) org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272) groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:906) groovy.lang.Closure.call(Closure.java:412) groovy.lang.Closure.call(Closure.java:406) groovy.lang.Closure.run(Closure.java:490) java.lang.Thread.run(Thread.java:744)
* org.linkedin.glu.agent.api.ScriptExecutionCauseException: "[java.net.ConnectException]: Connection timed out"
java.net.PlainSocketImpl.socketConnect(Native Method) java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) java.net.Socket.connect(Socket.java:579) java.net.Socket.connect(Socket.java:528) sun.net.ftp.impl.FtpClient.doConnect(FtpClient.java:958) sun.net.ftp.impl.FtpClient.tryConnect(FtpClient.java:918) sun.net.ftp.impl.FtpClient.connect(FtpClient.java:1013) sun.net.ftp.impl.FtpClient.connect(FtpClient.java:999) sun.net.www.protocol.ftp.FtpURLConnection.connect(FtpURLConnection.java:294) org.apache.tools.ant.taskdefs.Get$GetThread.openConnection(Get.java:660) org.apache.tools.ant.taskdefs.Get$GetThread.get(Get.java:579) org.apache.tools.ant.taskdefs.Get$GetThread.run(Get.java:569)

the following is agent log :

2014/11/05 10:37:32.221 INFO [/home/pplive/web] Downloading war file...
2014/11/05 10:37:39.067 INFO [/home/pplive/web] waitForState([state:installed, timeout:10s, mountPoint:/home/pplive/web]): false

I think it is a question of timeout, But I don't know how to config it.
 I saw your demonstration(-t 10s):
agent with-no-arguments
agent-cli.sh -s https://localhost:12906/ -m /geo/i001 -I <a href="http://host:port/glu/MyGluScript.groovy">http://host:port/glu/MyGluScript.groovy \
             -a "[skeleton:'ivy:/skeleton/jetty/1.0']" -t 10s

but I didn't use this way to install, I use call load static model rest API, create plan rest API and execute plan rest API.I can't think how you solved the problem.can you help me ?

Thanks
Best regard
Reply | Threaded
Open this post in threaded view
|

Re: how to configure Connection timed out

frenchyan
Administrator
There is no configuration timeout, because there is no way to know how long each "step" will take. So instead this is the way it works:

* most of the APIs are asynchronous, which means you run them and then exit right away with information on how to "come back" to check on the status (ex: executeAction https://github.com/pongasoft/glu/blob/master/agent/org.linkedin.glu.agent-api/src/main/groovy/org/linkedin/glu/agent/api/Agent.groovy#L80)

* then you call waitForState (with a timeOut) to check if the action that you executed has completed. The fact that you provide a timeOut to waitForState is so that YOU can manage how long you are willing to block until you block again. It is the exact same pattern as Object.wait in java.

In general the pattern is the following:

executeAction xxx
while action not complete
  waitForState(yyy)


This piece of code for example, shows that after waiting for some amount of time (default to 10s) if still pending, we check if the thread has been interrupted (which would happen if the user selected "abort" in the console) and if that is the case then we tell the agent to interrupt the action. In this case we are willing to wait up to 10s to do this... it is a client decision (hence providing the timeOut parameter vs configuring it).

Yan