pstmt = conn.prepareStatement( updateHeartbeatAndCheckStateSQL );
pstmt.setLong( 1, heartbeat );
pstmt.setString( 2, id );
pstmt.setLong( 3, lastHeartbeat );
if ( pstmt.executeUpdate() == 0 ) {
HABrokerInfo bkrInfo = getBrokerInfo( conn, id );
if ( bkrInfo == null ) {
String errorMsg = br.getKString(
BrokerResources.E_BROKERINFO_NOT_FOUND_IN_STORE, id );
throw new BrokerException( br.getKString(
BrokerResources.X_UPDATE_HEARTBEAT_TS_2_FAILED, id, errorMsg ) );
}
// Verify if persistent store is being taken over
String takeoverBroker = bkrInfo.getTakeoverBrokerID();
int state = bkrInfo.getState();
if ( takeoverBroker != null && takeoverBroker.length() > 0 &&
( state == BrokerState.I_FAILOVER_PENDING ||
state == BrokerState.I_FAILOVER_STARTED ||
state == BrokerState.I_FAILOVER_COMPLETE ||
state == BrokerState.I_FAILOVER_FAILED ) ) {
BrokerException be = new StoreBeingTakenOverException(
br.getKString( BrokerResources.E_STORE_BEING_TAKEN_OVER ) );
logger.log( Logger.ERROR, br.getKString(
BrokerResources.X_UPDATE_HEARTBEAT_TS_2_FAILED, id,
bkrInfo.toString() ), be );
throw be;
}
} else {
newheartbeat = new Long( heartbeat );
}