bug 10322: arrival of the next generation Merovingians

This commit is contained in:
Alex Huang 2011-06-29 11:49:50 -07:00
parent 5134b44ff5
commit cbee5a6044
5 changed files with 20 additions and 16 deletions

View File

@ -69,6 +69,7 @@ import com.cloud.utils.component.ComponentLocator;
import com.cloud.utils.component.Inject;
import com.cloud.utils.concurrency.NamedThreadFactory;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.Merovingian2;
import com.cloud.utils.db.Transaction;
import com.cloud.utils.events.SubscriptionMgr;
import com.cloud.utils.exception.CloudRuntimeException;
@ -604,13 +605,14 @@ public class ClusterManagerImpl implements ClusterManager {
s_logger.error("Problem with the cluster heartbeat!", e);
}
}
};
};
}
private boolean isRootCauseConnectionRelated(Throwable e) {
while (e != null) {
if (e instanceof com.mysql.jdbc.CommunicationsException || e instanceof com.mysql.jdbc.exceptions.jdbc4.CommunicationsException)
if (e instanceof com.mysql.jdbc.CommunicationsException || e instanceof com.mysql.jdbc.exceptions.jdbc4.CommunicationsException) {
return true;
}
e = e.getCause();
}
@ -1029,6 +1031,9 @@ public class ClusterManagerImpl implements ClusterManager {
_agentLBEnabled = Boolean.valueOf(configDao.getValue(Config.AgentLbEnable.key()));
Merovingian2 m = Merovingian2.createLockMaster(this._msId);
m.clear();
checkConflicts();

View File

@ -311,7 +311,8 @@ CREATE TABLE `cloud`.`op_lock` (
`thread` varchar(255) NOT NULL COMMENT 'Thread that acquired this lock',
`acquired_on` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Time acquired',
`waiters` int NOT NULL DEFAULT 0 COMMENT 'How many have waited for this',
PRIMARY KEY (`key`)
PRIMARY KEY (`key`),
INDEX `i_op_lock__mac_ip_thread`(`mac`, `ip`, `thread`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `cloud`.`configuration` (

View File

@ -1268,7 +1268,7 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene
while (en.hasMoreElements()) {
pstmt = txn.prepareAutoCloseStatement(ec.insertSql);
if (ec.targetClass == Date.class) {
pstmt.setString(1, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), (Date)en.nextElement()));
pstmt.setString(1, DateUtil.getDateDisplayString(s_gmtTimeZone, (Date)en.nextElement()));
} else {
pstmt.setObject(1, en.nextElement());
}
@ -1347,11 +1347,11 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene
return;
}
if (attr.is(Attribute.Flag.Date)) {
pstmt.setString(j, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), date));
pstmt.setString(j, DateUtil.getDateDisplayString(s_gmtTimeZone, date));
} else if (attr.is(Attribute.Flag.TimeStamp)) {
pstmt.setString(j, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), date));
pstmt.setString(j, DateUtil.getDateDisplayString(s_gmtTimeZone, date));
} else if (attr.is(Attribute.Flag.Time)) {
pstmt.setString(j, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), date));
pstmt.setString(j, DateUtil.getDateDisplayString(s_gmtTimeZone, date));
}
} else if (attr.field.getType() == Calendar.class) {
final Calendar cal = (Calendar)value;
@ -1360,11 +1360,11 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene
return;
}
if (attr.is(Attribute.Flag.Date)) {
pstmt.setString(j, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), cal.getTime()));
pstmt.setString(j, DateUtil.getDateDisplayString(s_gmtTimeZone, cal.getTime()));
} else if (attr.is(Attribute.Flag.TimeStamp)) {
pstmt.setString(j, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), cal.getTime()));
pstmt.setString(j, DateUtil.getDateDisplayString(s_gmtTimeZone, cal.getTime()));
} else if (attr.is(Attribute.Flag.Time)) {
pstmt.setString(j, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), cal.getTime()));
pstmt.setString(j, DateUtil.getDateDisplayString(s_gmtTimeZone, cal.getTime()));
}
} else if (attr.field.getType().isEnum()) {
final Enumerated enumerated = attr.field.getAnnotation(Enumerated.class);

View File

@ -201,6 +201,7 @@ public class Transaction {
public static Connection getStandaloneConnectionWithException() throws SQLException {
Connection conn = s_ds.getConnection();
conn.setAutoCommit(true);
if (s_connLogger.isTraceEnabled()) {
s_connLogger.trace("Retrieving a standalone connection: dbconn" + System.identityHashCode(conn));
}
@ -209,13 +210,9 @@ public class Transaction {
public static Connection getStandaloneConnection() {
try {
Connection conn = s_ds.getConnection();
if (s_connLogger.isTraceEnabled()) {
s_connLogger.trace("Retrieving a standalone connection: dbconn" + System.identityHashCode(conn));
}
return conn;
return getStandaloneConnectionWithException();
} catch (SQLException e) {
s_logger.warn("Unexpected exception: ", e);
s_logger.error("Unexpected exception: ", e);
return null;
}
}

View File

@ -24,6 +24,7 @@ package com.cloud.utils.time;
public class InaccurateClock extends Thread {
static final InaccurateClock s_timer = new InaccurateClock();
static {
time = System.currentTimeMillis();
s_timer.start();
}