From: <jma...@rh...> - 2009-07-28 04:34:40
|
<!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] [4605] [RHQ-2262] - the server executing the clustered-quartz CloudManager job should not set itself to down; </title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>4605</dd> <dt>Author</dt> <dd>jmarques</dd> <dt>Date</dt> <dd>2009-07-27 23:34:23 -0500 (Mon, 27 Jul 2009)</dd> </dl> <h3>Log Message</h3> <pre>[RHQ-2262] - the server executing the clustered-quartz CloudManager job should not set itself to down; by virtue of being about to communicate with the db to execute this query, it implicitly means that it is NOT down; </pre> <h3>Modified Paths</h3> <ul> <li><a href="#rhqtrunkmodulescoredomainsrcmainjavaorgrhqcoredomaincloudServerjava">rhq/trunk/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/Server.java</a></li> <li><a href="#rhqtrunkmodulesenterpriseserverjarsrcmainjavaorgrhqenterpriseservercloudCloudManagerBeanjava">rhq/trunk/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/CloudManagerBean.java</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="rhqtrunkmodulescoredomainsrcmainjavaorgrhqcoredomaincloudServerjava"></a> <div class="modfile"><h4>Modified: rhq/trunk/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/Server.java (4604 => 4605)</h4> <pre class="diff"> <span class="info">--- rhq/trunk/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/Server.java 2009-07-28 03:36:41 UTC (rev 4604) +++ rhq/trunk/modules/core/domain/src/main/java/org/rhq/core/domain/cloud/Server.java 2009-07-28 04:34:23 UTC (rev 4605) </span><span class="lines">@@ -83,7 +83,8 @@ </span><span class="cx"> + "UPDATE Server s " // + " SET s.operationMode = :downMode " // + " WHERE s.operationMode = :normalMode " // </span><span class="rem">- + " AND s.mtime < :staleTime "), // </span><span class="add">+ + " AND s.mtime < :staleTime " // + + " AND s.id <> :thisServerId "), // </span><span class="cx"> @NamedQuery(name = Server.QUERY_UPDATE_STATUS_BY_NAME, query = "" // + " UPDATE Server s " // + " SET s.status = -1 " // negative numbers so that bitmask strat does not conflict with this one </span></pre></div> <a id="rhqtrunkmodulesenterpriseserverjarsrcmainjavaorgrhqenterpriseservercloudCloudManagerBeanjava"></a> <div class="modfile"><h4>Modified: rhq/trunk/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/CloudManagerBean.java (4604 => 4605)</h4> <pre class="diff"> <span class="info">--- rhq/trunk/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/CloudManagerBean.java 2009-07-28 03:36:41 UTC (rev 4604) +++ rhq/trunk/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/CloudManagerBean.java 2009-07-28 04:34:23 UTC (rev 4605) </span><span class="lines">@@ -30,6 +30,8 @@ </span><span class="cx"> import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; </span><span class="add">+import org.jboss.annotation.IgnoreDependency; + </span><span class="cx"> import org.rhq.core.domain.auth.Subject; import org.rhq.core.domain.authz.Permission; import org.rhq.core.domain.cloud.FailoverListDetails; </span><span class="lines">@@ -43,6 +45,7 @@ </span><span class="cx"> import org.rhq.enterprise.server.RHQConstants; import org.rhq.enterprise.server.authz.AuthorizationManagerLocal; import org.rhq.enterprise.server.authz.RequiredPermission; </span><span class="add">+import org.rhq.enterprise.server.cloud.instance.ServerManagerLocal; </span><span class="cx"> import org.rhq.enterprise.server.util.LookupUtil; /** </span><span class="lines">@@ -75,6 +78,10 @@ </span><span class="cx"> @EJB private AuthorizationManagerLocal authorizationManager; </span><span class="add">+ @EJB + @IgnoreDependency + private ServerManagerLocal serverManager; + </span><span class="cx"> public List<Agent> getAgentsByServerName(String serverName) { Server server = cloudManager.getServerByName(serverName); List<Agent> agents = server.getAgents(); </span><span class="lines">@@ -250,12 +257,27 @@ </span><span class="cx"> long staleTime = System.currentTimeMillis() - SERVER_DOWN_INTERVAL; </span><span class="add">+ int serverId = 0; + try { + Server server = serverManager.getServer(); + if (log.isDebugEnabled()) { + log.debug(server.toString() + " is marking stale servers DOWN"); + } + serverId = server.getId(); + } catch (Exception e) { + log.error("Could not determine which instance is marking stale servers DOWN"); + } </span><span class="cx"> Query query = entityManager.createNamedQuery(Server.QUERY_UPDATE_SET_STALE_DOWN); query.setParameter("downMode", Server.OperationMode.DOWN); query.setParameter("normalMode", Server.OperationMode.NORMAL); query.setParameter("staleTime", staleTime); </span><span class="rem">- query.executeUpdate(); </span><span class="add">+ query.setParameter("thisServerId", serverId); + int resultCount = query.executeUpdate(); </span><span class="cx"> </span><span class="add">+ if (log.isDebugEnabled()) { + log.debug(String.valueOf(resultCount) + " stale servers were marked DOWN"); + } + </span><span class="cx"> // Perform requested partition events. Note that we only need to execute one cloud partition // regardless of the number of pending requests, as the work would be duplicated. partitionEventManager.processRequestedPartitionEvents(); </span> </pre> </div> </div> </body> </html> |