Search in sources :

Example 31 with ChangeRecordInfo

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;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ChangeRecordInfo(com.sun.messaging.jmq.jmsserver.persist.api.ChangeRecordInfo) IOException(java.io.IOException) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) LinkedHashMap(java.util.LinkedHashMap)

Example 32 with ChangeRecordInfo

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();
}
Also used : ChangeRecordInfo(com.sun.messaging.jmq.jmsserver.persist.api.ChangeRecordInfo) ClusterFirstInfoInfo(com.sun.messaging.jmq.jmsserver.multibroker.raptor.ClusterFirstInfoInfo)

Example 33 with ChangeRecordInfo

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;
}
Also used : ChangeRecordInfo(com.sun.messaging.jmq.jmsserver.persist.api.ChangeRecordInfo)

Example 34 with ChangeRecordInfo

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;
}
Also used : ChangeRecordInfo(com.sun.messaging.jmq.jmsserver.persist.api.ChangeRecordInfo) IOException(java.io.IOException) IOException(java.io.IOException)

Example 35 with ChangeRecordInfo

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;
}
Also used : ChangeRecordInfo(com.sun.messaging.jmq.jmsserver.persist.api.ChangeRecordInfo) IOException(java.io.IOException) IOException(java.io.IOException)

Aggregations

ChangeRecordInfo (com.sun.messaging.jmq.jmsserver.persist.api.ChangeRecordInfo)35 BrokerException (com.sun.messaging.jmq.jmsserver.util.BrokerException)11 GPacket (com.sun.messaging.jmq.io.GPacket)9 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)4 SysMessageID (com.sun.messaging.jmq.io.SysMessageID)3 Consumer (com.sun.messaging.jmq.jmsserver.core.Consumer)3 TransactionUID (com.sun.messaging.jmq.jmsserver.data.TransactionUID)3 JMSBridgeStore (com.sun.messaging.bridge.api.JMSBridgeStore)2 Packet (com.sun.messaging.jmq.io.Packet)2 ClusterManager (com.sun.messaging.jmq.jmsserver.cluster.api.ClusterManager)2 ConsumerUID (com.sun.messaging.jmq.jmsserver.core.ConsumerUID)2 Destination (com.sun.messaging.jmq.jmsserver.core.Destination)2 DestinationUID (com.sun.messaging.jmq.jmsserver.core.DestinationUID)2 TransactionAcknowledgement (com.sun.messaging.jmq.jmsserver.data.TransactionAcknowledgement)2 ChangeRecord (com.sun.messaging.jmq.jmsserver.multibroker.ChangeRecord)2 ClusterDestInfo (com.sun.messaging.jmq.jmsserver.multibroker.raptor.ClusterDestInfo)2 ClusterFirstInfoInfo (com.sun.messaging.jmq.jmsserver.multibroker.raptor.ClusterFirstInfoInfo)2 ClusterSubscriptionInfo (com.sun.messaging.jmq.jmsserver.multibroker.raptor.ClusterSubscriptionInfo)2 HABrokerInfo (com.sun.messaging.jmq.jmsserver.persist.api.HABrokerInfo)2