use of com.sun.messaging.jmq.jmsserver.persist.api.ChangeRecordInfo in project openmq by eclipse-ee4j.
the class ShareConfigRecordDAOImpl method getDebugInfo.
/**
* Get debug information about the store.
*
* @param conn database connection
* @return a HashMap of name value pair of information
*/
@Override
public HashMap getDebugInfo(Connection conn) {
HashMap map = new LinkedHashMap();
StringBuilder buf = new StringBuilder();
ArrayList<ChangeRecordInfo> records = null;
try {
records = getAllRecords(conn, null);
Iterator<ChangeRecordInfo> itr = records.iterator();
ChangeRecordInfo rec = null;
while (itr.hasNext()) {
rec = itr.next();
buf.append(rec).append('\n');
}
} catch (Exception e) {
logger.log(Logger.ERROR, e.getMessage(), e.getCause());
}
map.put("Cluster Config Change Records:\n", buf.toString());
if (records != null) {
map.put("Count", records.size());
}
return map;
}
use of com.sun.messaging.jmq.jmsserver.persist.api.ChangeRecordInfo in project openmq by eclipse-ee4j.
the class ClusterImpl method getFirstInfoPacket.
protected GPacket getFirstInfoPacket() {
if (!Globals.useSharedConfigRecord()) {
return null;
}
ChangeRecordInfo cri = cb.getLastStoredChangeRecord();
if (cri == null) {
return null;
}
ClusterFirstInfoInfo cii = ClusterFirstInfoInfo.newInstance();
cii.setLastStoredChangeRecord(cri);
cii.setBroadcast(false);
return cii.getGPacket();
}
use of com.sun.messaging.jmq.jmsserver.persist.api.ChangeRecordInfo in project openmq by eclipse-ee4j.
the class ClusterFirstInfoInfo method getLastStoredChangeRecord.
public ChangeRecordInfo getLastStoredChangeRecord() {
assert (pkt != null);
if (pkt.getProp("shareccLastStoredSeq") == null) {
return null;
}
ChangeRecordInfo cri = new ChangeRecordInfo();
cri.setSeq((Long) pkt.getProp("shareccLastStoredSeq"));
cri.setUUID((String) pkt.getProp("shareccLastStoredUUID"));
cri.setResetUUID((String) pkt.getProp("shareccLastStoredResetUUID"));
cri.setType(((Integer) pkt.getProp("shareccLastStoredType")).intValue());
return cri;
}
use of com.sun.messaging.jmq.jmsserver.persist.api.ChangeRecordInfo in project openmq by eclipse-ee4j.
the class ConfigRecordDAOImpl method getRecordsSince.
/**
* Get all records created since the specified timestamp.
*
* @param conn database connection
* @param timestamp the timestamp
* @return a List of records.
*/
@Override
public List<ChangeRecordInfo> getRecordsSince(Connection conn, long timestamp) throws BrokerException {
ArrayList records = new ArrayList();
boolean myConn = false;
PreparedStatement pstmt = null;
ResultSet rs = null;
Exception myex = null;
try {
// Get a connection
DBManager dbMgr = DBManager.getDBManager();
if (conn == null) {
conn = dbMgr.getConnection(true);
myConn = true;
}
pstmt = dbMgr.createPreparedStatement(conn, selectRecordsSinceSQL);
pstmt.setLong(1, timestamp);
rs = pstmt.executeQuery();
while (rs.next()) {
try {
byte[] buf = Util.readBytes(rs, 1);
records.add(new ChangeRecordInfo(buf, 0));
} catch (IOException e) {
// fail to load one record; just log the record TS
IOException ex = DBManager.wrapIOException("[" + selectRecordsSinceSQL + "]", e);
logger.logStack(Logger.ERROR, BrokerResources.X_PARSE_CONFIGRECORD_FAILED, rs.getString(2), ex);
}
}
} catch (Exception e) {
myex = e;
try {
if ((conn != null) && !conn.getAutoCommit()) {
conn.rollback();
}
} catch (SQLException rbe) {
logger.log(Logger.ERROR, BrokerResources.X_DB_ROLLBACK_FAILED, rbe);
}
Exception ex;
if (e instanceof BrokerException) {
throw (BrokerException) e;
} else if (e instanceof SQLException) {
ex = DBManager.wrapSQLException("[" + selectRecordsSinceSQL + "]", (SQLException) e);
} else {
ex = e;
}
throw new BrokerException(br.getKString(BrokerResources.X_LOAD_CONFIGRECORDS_FAILED), ex);
} finally {
if (myConn) {
Util.close(rs, pstmt, conn, myex);
} else {
Util.close(rs, pstmt, null, myex);
}
}
return records;
}
use of com.sun.messaging.jmq.jmsserver.persist.api.ChangeRecordInfo in project openmq by eclipse-ee4j.
the class ConfigRecordDAOImpl method getAllRecords.
/**
* Return all records together with their corresponding timestamps.
*
* @param conn database connection
* @return a list of ChangeRecordInfo
*/
@Override
public List<ChangeRecordInfo> getAllRecords(Connection conn) throws BrokerException {
ArrayList records = new ArrayList();
boolean myConn = false;
PreparedStatement pstmt = null;
ResultSet rs = null;
Exception myex = null;
try {
// Get a connection
DBManager dbMgr = DBManager.getDBManager();
if (conn == null) {
conn = dbMgr.getConnection(true);
myConn = true;
}
pstmt = dbMgr.createPreparedStatement(conn, selectAllSQL);
rs = pstmt.executeQuery();
while (rs.next()) {
long createdTS = -1;
try {
createdTS = rs.getLong(2);
byte[] buf = Util.readBytes(rs, 1);
records.add(new ChangeRecordInfo(buf, createdTS));
} catch (IOException e) {
// fail to load one record; just log the record TS
IOException ex = DBManager.wrapIOException("[" + selectAllSQL + "]", e);
logger.logStack(Logger.ERROR, BrokerResources.X_PARSE_CONFIGRECORD_FAILED, String.valueOf(createdTS), ex);
}
}
} catch (Exception e) {
myex = e;
try {
if ((conn != null) && !conn.getAutoCommit()) {
conn.rollback();
}
} catch (SQLException rbe) {
logger.log(Logger.ERROR, BrokerResources.X_DB_ROLLBACK_FAILED, rbe);
}
Exception ex;
if (e instanceof BrokerException) {
throw (BrokerException) e;
} else if (e instanceof SQLException) {
ex = DBManager.wrapSQLException("[" + selectAllSQL + "]", (SQLException) e);
} else {
ex = e;
}
throw new BrokerException(br.getKString(BrokerResources.X_LOAD_CONFIGRECORDS_FAILED), ex);
} finally {
if (myConn) {
Util.close(rs, pstmt, conn, myex);
} else {
Util.close(rs, pstmt, null, myex);
}
}
return records;
}
Aggregations