<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><style type="text/css"><!-- #msg DL { border : 1px #006 solid; background-color : #369; padding : 6px; color : #fff; } #msg DT { float : left; width : 6em; font-weight : bold; } #msg DL, #msg DT, #msg UL, #msg LI { font-family : arial,helvetica,sans-serif; font-size : 10pt; } h3 { font-family : arial,helvetica,sans-serif; font-size : 10pt; font-weight : bold; } #msg PRE { overflow : auto; white-space : normal; background-color : #ffc; border : 1px #fc0 solid; padding : 6px; } #msg UL, PRE, .diff { overflow : auto; } #patch h4 { font-family : arial,helvetica,sans-serif; font-size : 10pt; } #patch h4 { padding: 8px; background : #369; color : #fff; margin : 0; } #patch .propset h4, #patch .binary h4 {margin: 0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {background:#eeeeee;padding: 0 0 10px 0;} #patch .propset .diff, #patch .binary .diff {padding: 10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch .add {background:#ddffdd;} #patch .rem {background:#ffdddd;} #patch .lines, .info {color:#888888;background:#ffffff;} .diff { width : 100%; } #msg DL { border : 1px #006 solid; background-color : #369; padding : 6px; color : #fff; } #msg DT { float : left; width : 6em; font-weight : bold; } #msg DL, #msg DT, #msg UL, #msg LI { font-family : arial,helvetica,sans-serif; font-size : 10pt; } h3 { font-family : arial,helvetica,sans-serif; font-size : 10pt; font-weight : bold; } #msg PRE { overflow : auto; white-space : normal; background-color : #ffc; border : 1px #fc0 solid; padding : 6px; } #msg UL, PRE, .diff { overflow : auto; } #patch h4 { font-family : arial,helvetica,sans-serif; font-size : 10pt; } #patch h4 { padding: 8px; background : #369; color : #fff; margin : 0; } #patch .propset h4, #patch .binary h4 {margin: 0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {background:#eeeeee;padding: 0 0 10px 0;} #patch .propset .diff, #patch .binary .diff {padding: 10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch .add {background:#ddffdd;} #patch .rem {background:#ffdddd;} #patch .lines, .info {color:#888888;background:#ffffff;} .diff { width : 100%; } --></style> <title>[rhq-project.org rhq] [1721] [RHQ-929] ensure the connectAgent message gets sent during times when a server is temporarily not permitted messages due to concurrency limits getting hit</title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>1721</dd> <dt>Author</dt> <dd>mazz</dd> <dt>Date</dt> <dd>2008-10-08 10:39:20 -0500 (Wed, 08 Oct 2008)</dd> </dl> <h3>Log Message</h3> <pre>[RHQ-929] ensure the connectAgent message gets sent during times when a server is temporarily not permitted messages due to concurrency limits getting hit</pre> <h3>Modified Paths</h3> <ul> <li><a href="#rhqtrunkmodulesenterpriseagentsrcmainjavaorgrhqenterpriseagentAgentMainjava">rhq/trunk/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java</a></li> <li><a href="#rhqtrunkmodulesenterprisecommsrcmainjavaorgrhqenterprisecommunicationscommandclientClientCommandSenderTaskjava">rhq/trunk/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/ClientCommandSenderTask.java</a></li> <li><a href="#rhqtrunkmodulesenterprisecommsrcmainjavaorgrhqenterprisecommunicationscommandclientJBossRemotingRemoteCommunicatorjava">rhq/trunk/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="rhqtrunkmodulesenterpriseagentsrcmainjavaorgrhqenterpriseagentAgentMainjava"></a> <div class="modfile"><h4>Modified: rhq/trunk/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java (1720 => 1721)</h4> <pre class="diff"> <span class="info">--- rhq/trunk/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java 2008-10-08 15:12:50 UTC (rev 1720) +++ rhq/trunk/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java 2008-10-08 15:39:20 UTC (rev 1721) </span><span class="lines">@@ -1458,6 +1458,12 @@ </span><span class="cx"> sendConnectRequestToServer(comm, false); } catch (Throwable t) { LOG.warn(AgentI18NResourceKeys.FAILOVER_FAILED, t); </span><span class="add">+ // TODO: I am unsure if this causes deadlocks or other problems, but consider + // disconnecting the comm object here to force the initialize callback to be triggered again. + // This will ensure we attempt to send the connect request again. I left this commented out + // because I don't know what happens if we are called in a thread that is already currently + // attempting to send a connect request. + // comm.disconnect(); </span><span class="cx"> return; } </span></pre></div> <a id="rhqtrunkmodulesenterprisecommsrcmainjavaorgrhqenterprisecommunicationscommandclientClientCommandSenderTaskjava"></a> <div class="modfile"><h4>Modified: rhq/trunk/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/ClientCommandSenderTask.java (1720 => 1721)</h4> <pre class="diff"> <span class="info">--- rhq/trunk/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/ClientCommandSenderTask.java 2008-10-08 15:12:50 UTC (rev 1720) +++ rhq/trunk/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/ClientCommandSenderTask.java 2008-10-08 15:39:20 UTC (rev 1721) </span><span class="lines">@@ -39,7 +39,6 @@ </span><span class="cx"> import org.rhq.enterprise.communications.command.impl.remotepojo.RemotePojoInvocationCommand; import org.rhq.enterprise.communications.i18n.CommI18NFactory; import org.rhq.enterprise.communications.i18n.CommI18NResourceKeys; </span><span class="rem">-import org.rhq.enterprise.communications.util.NotPermittedException; </span><span class="cx"> /** * This is runnable task that will be queued in the executor pool within the {@link ClientCommandSender}. It is a </span><span class="lines">@@ -105,20 +104,7 @@ </span><span class="cx"> CommandResponse response; try { </span><span class="rem">- boolean retry; - do { - retry = false; - - response = send(m_sender, m_cnc); - - Throwable exception = response.getException(); - if ((exception != null) && (exception instanceof NotPermittedException)) { - long pause = ((NotPermittedException) exception).getSleepBeforeRetry(); - LOG.debug(CommI18NResourceKeys.COMMAND_NOT_PERMITTED, m_cnc.getCommand(), pause); - retry = true; - Thread.sleep(pause); - } - } while (retry); </span><span class="add">+ response = send(m_sender, m_cnc); </span><span class="cx"> } catch (Exception e) { throw e; } catch (Throwable t) { </span></pre></div> <a id="rhqtrunkmodulesenterprisecommsrcmainjavaorgrhqenterprisecommunicationscommandclientJBossRemotingRemoteCommunicatorjava"></a> <div class="modfile"><h4>Modified: rhq/trunk/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java (1720 => 1721)</h4> <pre class="diff"> <span class="info">--- rhq/trunk/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java 2008-10-08 15:12:50 UTC (rev 1720) +++ rhq/trunk/modules/enterprise/comm/src/main/java/org/rhq/enterprise/communications/command/client/JBossRemotingRemoteCommunicator.java 2008-10-08 15:39:20 UTC (rev 1721) </span><span class="lines">@@ -34,6 +34,7 @@ </span><span class="cx"> import org.rhq.enterprise.communications.command.impl.generic.GenericCommandResponse; import org.rhq.enterprise.communications.i18n.CommI18NFactory; import org.rhq.enterprise.communications.i18n.CommI18NResourceKeys; </span><span class="add">+import org.rhq.enterprise.communications.util.NotPermittedException; </span><span class="cx"> /** * Provides basic functionality to all command clients that want to use JBoss/Remoting as the remoting framework. </span><span class="lines">@@ -416,73 +417,44 @@ </span><span class="cx"> } public CommandResponse sendWithoutCallbacks(Command command) throws Throwable { </span><span class="rem">- Object ret_response; </span><span class="add">+ // handle NotPermittedException in here + CommandResponse ret_response = null; + boolean retry; + do { + retry = false; + ret_response = rawSend(command); + Throwable exception = ret_response.getException(); + if ((exception != null) && (exception instanceof NotPermittedException)) { + long pause = ((NotPermittedException) exception).getSleepBeforeRetry(); + LOG.debug(CommI18NResourceKeys.COMMAND_NOT_PERMITTED, command, pause); + retry = true; + Thread.sleep(pause); + } + } while (retry); </span><span class="cx"> </span><span class="rem">- try { - ret_response = getRemotingClient().invoke(command, null); - } catch (ServerInvoker.InvalidStateException serverDown) { - // see comments in #send for why this is here - ret_response = getRemotingClient().invoke(command, null); - } - - // this is to support http(s) transport - those transports will return Exception objects when errors occur - if (ret_response instanceof Exception) { - throw (Exception) ret_response; - } - - try { - return (CommandResponse) ret_response; - } catch (Exception e) { - // see comments in #send for why this is here - LOG.error(CommI18NResourceKeys.COMM_CCE, ret_response); - return new GenericCommandResponse(command, false, ret_response, e); - } </span><span class="add">+ return ret_response; </span><span class="cx"> } public CommandResponse sendWithoutInitializeCallback(Command command) throws Throwable { </span><span class="rem">- Object ret_response = null; </span><span class="add">+ CommandResponse ret_response = null; </span><span class="cx"> boolean retry = false; do { try { </span><span class="rem">- try { - ret_response = getRemotingClient().invoke(command, null); - } catch (ServerInvoker.InvalidStateException serverDown) { - // see comments in #send for why this is here - ret_response = getRemotingClient().invoke(command, null); - } - - // this is to support http(s) transport - those transports will return Exception objects when errors occur - if (ret_response instanceof Exception) { - throw (Exception) ret_response; - } - - retry = invokeFailureCallbackIfNeeded(command, - (ret_response instanceof CommandResponse) ? (CommandResponse) ret_response : null, null); - </span><span class="add">+ ret_response = sendWithoutCallbacks(command); + retry = invokeFailureCallbackIfNeeded(command, ret_response, null); </span><span class="cx"> } catch (Throwable t) { </span><span class="rem">- retry = invokeFailureCallbackIfNeeded(command, - (ret_response instanceof CommandResponse) ? (CommandResponse) ret_response : null, t); - </span><span class="add">+ retry = invokeFailureCallbackIfNeeded(command, ret_response, t); </span><span class="cx"> if (!retry) { throw t; } } } while (retry); </span><span class="rem">- try { - return (CommandResponse) ret_response; - } catch (Exception e) { - // see comments in #send for why this is here - LOG.error(CommI18NResourceKeys.COMM_CCE, ret_response); - return new GenericCommandResponse(command, false, ret_response, e); - } </span><span class="add">+ return ret_response; </span><span class="cx"> } public CommandResponse send(Command command) throws Throwable { </span><span class="rem">- Object ret_response = null; - boolean retry = false; - </span><span class="cx"> // invoke our initialize callback - if our method returns a response, it means // the initialize callback had an error and we need to abort the sending of this command CommandResponse initializeErrorResponse = invokeInitializeCallbackIfNeeded(command); </span><span class="lines">@@ -490,36 +462,35 @@ </span><span class="cx"> return initializeErrorResponse; } </span><span class="rem">- do { - try { </span><span class="add">+ return sendWithoutInitializeCallback(command); + } </span><span class="cx"> </span><span class="rem">- try { - ret_response = getRemotingClient().invoke(command, null); - } catch (ServerInvoker.InvalidStateException serverDown) { - // under rare condition, a bug in remoting 2.2 causes this when the server restarted - // try it one more time, this will get a new server thread on the server side (JBREM-745) - // once JBREM-745 is fixed, we can probably get rid of this catch block - ret_response = getRemotingClient().invoke(command, null); - } </span><span class="add">+ /** + * The code that sends the command via the remote client. + * + * @param command the command to send + * + * @return the command response + * + * @throws Throwable if a low-level, unhandled exception occurred + */ + private CommandResponse rawSend(Command command) throws Throwable { + Object ret_response; </span><span class="cx"> </span><span class="rem">- // this is to support http(s) transport - those transports will return Exception objects when errors occur - if (ret_response instanceof Exception) { - throw (Exception) ret_response; - } </span><span class="add">+ try { + ret_response = getRemotingClient().invoke(command, null); + } catch (ServerInvoker.InvalidStateException serverDown) { + // under rare condition, a bug in remoting 2.2 causes this when the server restarted + // try it one more time, this will get a new server thread on the server side (JBREM-745) + // once JBREM-745 is fixed, we can probably get rid of this catch block + ret_response = getRemotingClient().invoke(command, null); + } </span><span class="cx"> </span><span class="rem">- retry = invokeFailureCallbackIfNeeded(command, - (ret_response instanceof CommandResponse) ? (CommandResponse) ret_response : null, null); </span><span class="add">+ // this is to support http(s) transport - those transports will return Exception objects when errors occur + if (ret_response instanceof Exception) { + throw (Exception) ret_response; + } </span><span class="cx"> </span><span class="rem">- } catch (Throwable t) { - retry = invokeFailureCallbackIfNeeded(command, - (ret_response instanceof CommandResponse) ? (CommandResponse) ret_response : null, t); - - if (!retry) { - throw t; - } - } - } while (retry); - </span><span class="cx"> try { return (CommandResponse) ret_response; } catch (Exception e) { </span> </pre> </div> </div> </body> </html> |