Search in sources :

Example 51 with DestinationUID

use of com.sun.messaging.jmq.jmsserver.core.DestinationUID in project openmq by eclipse-ee4j.

the class TransactionLogReplayer method replayRemoteAcks.

public void replayRemoteAcks(TransactionAcknowledgement[] txnAcks, DestinationUID[] destIds, TransactionUID tid, HashSet dstLoadedSet) throws IOException, BrokerException {
    if (Store.getDEBUG()) {
        String msg = getPrefix() + " replayRemoteAcks ";
        logger.log(Logger.INFO, msg);
    }
    for (int i = 0; i < txnAcks.length; i++) {
        TransactionAcknowledgement txnAck = txnAcks[i];
        DestinationUID destId = destIds[i];
        SysMessageID mid = txnAck.getSysMessageID();
        ConsumerUID iid = txnAck.getStoredConsumerUID();
        // Destination dest = DestinationList.getDestination(msgStore.parent, destId);
        // make sure it is loaded
        int type = (destId.isQueue() ? DestType.DEST_TYPE_QUEUE : DestType.DEST_TYPE_TOPIC);
        Destination[] ds = DestinationList.getDestination(msgStore.parent, destId.getName(), type, true, true);
        Destination dest = ds[0];
        dest.load();
        PacketReference pr = dest.getMessage(mid);
        if (pr == null) {
            // could have been acknowledged already?
            // TO DO check this further
            String msg = " could not find packet for replayed message ack " + txnAck + " dest " + destId + " in transaction " + tid;
            logger.log(Logger.WARNING, msg);
        } else {
            if (msgStore.containsMessage(destId, mid)) {
                logger.log(logger.FORCE, BrokerResources.I_UPDATE_INT_STATE_TXNLOG, iid, mid);
                // use try using the correct value; see bug 6516160
                if (dest.isQueue() && iid.longValue() != 0) {
                    msgStore.updateInterestState(destId, mid, PacketReference.getQueueUID(), PartitionedStore.INTEREST_STATE_ACKNOWLEDGED, false);
                } else {
                    msgStore.updateInterestState(destId, mid, iid, PartitionedStore.INTEREST_STATE_ACKNOWLEDGED, false);
                }
                acknowledgeOnReplay(dest, mid, iid);
            } else {
                logger.log(logger.FORCE, BrokerResources.I_DISREGARD_INT_STATE_TXNLOG, iid, mid);
            }
        }
    }
}
Also used : Destination(com.sun.messaging.jmq.jmsserver.core.Destination) TransactionAcknowledgement(com.sun.messaging.jmq.jmsserver.data.TransactionAcknowledgement) DestinationUID(com.sun.messaging.jmq.jmsserver.core.DestinationUID) ConsumerUID(com.sun.messaging.jmq.jmsserver.core.ConsumerUID) PacketReference(com.sun.messaging.jmq.jmsserver.core.PacketReference) SysMessageID(com.sun.messaging.jmq.io.SysMessageID)

Example 52 with DestinationUID

use of com.sun.messaging.jmq.jmsserver.core.DestinationUID in project openmq by eclipse-ee4j.

the class FileStore method processTxnRecMsgPart.

private void processTxnRecMsgPart(DataInputStream dis, Set dstLoadedSet) throws IOException, BrokerException {
    // Number of msgs to process
    int msgCount = dis.readInt();
    for (int i = 0; i < msgCount; i++) {
        // Reconstruct the message
        Packet pkt = new Packet(false);
        pkt.generateTimestamp(false);
        pkt.generateSequenceNumber(false);
        pkt.readPacket(dis);
        SysMessageID mid = pkt.getSysMessageID();
        // Make sure dst exists; autocreate if possible
        Destination[] ds = Globals.getDestinationList().getDestination(this, pkt.getDestination(), pkt.getIsQueue() ? DestType.DEST_TYPE_QUEUE : DestType.DEST_TYPE_TOPIC, true, true);
        Destination dst = ds[0];
        DestinationUID did = dst.getDestinationUID();
        // Load all msgs inorder to verify if any msgs are missing
        if (!dstLoadedSet.contains(dst)) {
            dst.load();
            // Keep track of what has been loaded
            dstLoadedSet.add(dst);
        }
        // Check to see if the msg is in the store
        MsgStore msgStore = getMsgStore();
        if (msgStore.containsMessage(did, mid)) {
            logger.log(logger.FORCE, BrokerResources.I_REPLACE_MSG_TXNLOG, mid, did);
            msgStore.removeMessage(did, mid, false);
        } else {
            logger.log(logger.FORCE, BrokerResources.I_RECONSTRUCT_MSG_TXNLOG, mid, dst + "[load]");
        }
        PacketReference pr = PacketReference.createReferenceWithDestination(this, pkt, dst, null);
        try {
            dst.routeNewMessage(pr);
        } catch (SelectorFormatException e) {
            // shouldn't happens
            throw new BrokerException(br.getString(BrokerResources.E_ROUTE_RECONSTRUCTED_MSG_FAILED, mid), e);
        }
    }
}
Also used : SelectorFormatException(com.sun.messaging.jmq.util.selector.SelectorFormatException) Packet(com.sun.messaging.jmq.io.Packet) Destination(com.sun.messaging.jmq.jmsserver.core.Destination) DestinationUID(com.sun.messaging.jmq.jmsserver.core.DestinationUID) BrokerException(com.sun.messaging.jmq.jmsserver.util.BrokerException) PacketReference(com.sun.messaging.jmq.jmsserver.core.PacketReference) SysMessageID(com.sun.messaging.jmq.io.SysMessageID)

Example 53 with DestinationUID

use of com.sun.messaging.jmq.jmsserver.core.DestinationUID in project openmq by eclipse-ee4j.

the class FileStore method processTxnRecAckPart.

private void processTxnRecAckPart(DataInputStream dis, Set dstLoadedSet) throws IOException, BrokerException {
    // Number of acks
    int ackCount = dis.readInt();
    for (int i = 0; i < ackCount; i++) {
        // Destination ID
        String name = dis.readUTF();
        DestinationUID did = new DestinationUID(name);
        SysMessageID mid = new SysMessageID();
        // SysMessageID
        mid.readID(dis);
        // ConsumerUID
        ConsumerUID iid = new ConsumerUID(dis.readLong());
        // Make sure dst exists; autocreate if possible
        Destination[] ds = Globals.getDestinationList().getDestination(this, did.getName(), did.isQueue() ? DestType.DEST_TYPE_QUEUE : DestType.DEST_TYPE_TOPIC, true, true);
        Destination dst = ds[0];
        // Load all msgs inorder to update consumer states
        if (!dstLoadedSet.contains(dst)) {
            dst.load();
            // Keep track of what has been loaded
            dstLoadedSet.add(dst);
        }
        if (msgStore.containsMessage(did, mid)) {
            logger.log(logger.FORCE, BrokerResources.I_UPDATE_INT_STATE_TXNLOG, iid, mid);
            // use try using the correct value; see bug 6516160
            if (dst.isQueue() && iid.longValue() != 0) {
                msgStore.updateInterestState(did, mid, PacketReference.getQueueUID(), PartitionedStore.INTEREST_STATE_ACKNOWLEDGED, false);
            } else {
                msgStore.updateInterestState(did, mid, iid, PartitionedStore.INTEREST_STATE_ACKNOWLEDGED, false);
            }
        } else {
            logger.log(logger.FORCE, BrokerResources.I_DISREGARD_INT_STATE_TXNLOG, iid, mid);
        }
    }
}
Also used : Destination(com.sun.messaging.jmq.jmsserver.core.Destination) DestinationUID(com.sun.messaging.jmq.jmsserver.core.DestinationUID) ConsumerUID(com.sun.messaging.jmq.jmsserver.core.ConsumerUID) SysMessageID(com.sun.messaging.jmq.io.SysMessageID) SizeString(com.sun.messaging.jmq.util.SizeString)

Example 54 with DestinationUID

use of com.sun.messaging.jmq.jmsserver.core.DestinationUID in project openmq by eclipse-ee4j.

the class FileStore method getMessageStorageInfo.

/**
 * Return the number of persisted messages and total number of bytes for the given destination.
 *
 * @param dst the destination whose messages are to be counted
 * @return A HashMap of name value pair of information
 * @throws BrokerException if an error occurs while getting the data
 */
@Override
public HashMap getMessageStorageInfo(Destination dst) throws BrokerException {
    if (Store.getDEBUG()) {
        logger.log(Logger.INFO, "FileStore.getMessageStorageInfo(Destination) called");
    }
    // make sure store is not closed then increment in progress count
    super.checkClosedAndSetInProgress();
    try {
        DestinationUID dstID = dst.getDestinationUID();
        HashMap data = new HashMap(2);
        data.put(DestMetricsCounters.CURRENT_MESSAGES, Integer.valueOf(msgStore.getMessageCount(dstID)));
        data.put(DestMetricsCounters.CURRENT_MESSAGE_BYTES, Long.valueOf(msgStore.getByteCount(dstID)));
        return data;
    } finally {
        // decrement in progress count
        super.setInProgress(false);
    }
}
Also used : DestinationUID(com.sun.messaging.jmq.jmsserver.core.DestinationUID) HashMap(java.util.HashMap)

Example 55 with DestinationUID

use of com.sun.messaging.jmq.jmsserver.core.DestinationUID in project openmq by eclipse-ee4j.

the class RemoteTransaction2PPrepareEvent method readFromBytes.

@Override
public void readFromBytes(byte[] data) throws IOException, BrokerException {
    ByteArrayInputStream bais = new ByteArrayInputStream(data);
    DataInputStream dis = new DataInputStream(bais);
    remoteTransaction = new RemoteTransaction();
    dis.skip(2);
    remoteTransaction.getTransactionDetails().readContent(dis);
    int objectBodySize = dis.readInt();
    byte[] objectBody = new byte[objectBodySize];
    dis.read(objectBody);
    ByteArrayInputStream bais2 = new ByteArrayInputStream(objectBody);
    ObjectInputStream ois = new FilteringObjectInputStream(bais2);
    try {
        remoteTransaction.setTransactionState((TransactionState) ois.readObject());
        remoteTransaction.setTxnHomeBroker((BrokerAddress) ois.readObject());
        remoteTransaction.setTxnAcks((TransactionAcknowledgement[]) ois.readObject());
        remoteTransaction.setDestIds((DestinationUID[]) ois.readObject());
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
    ois.close();
    bais2.close();
    dis.close();
    bais.close();
}
Also used : RemoteTransaction(com.sun.messaging.jmq.jmsserver.data.RemoteTransaction) TransactionAcknowledgement(com.sun.messaging.jmq.jmsserver.data.TransactionAcknowledgement) DestinationUID(com.sun.messaging.jmq.jmsserver.core.DestinationUID) ByteArrayInputStream(java.io.ByteArrayInputStream) FilteringObjectInputStream(com.sun.messaging.jmq.util.io.FilteringObjectInputStream) DataInputStream(java.io.DataInputStream) FilteringObjectInputStream(com.sun.messaging.jmq.util.io.FilteringObjectInputStream) ObjectInputStream(java.io.ObjectInputStream)

Aggregations

DestinationUID (com.sun.messaging.jmq.jmsserver.core.DestinationUID)61 Destination (com.sun.messaging.jmq.jmsserver.core.Destination)25 ConsumerUID (com.sun.messaging.jmq.jmsserver.core.ConsumerUID)20 BrokerException (com.sun.messaging.jmq.jmsserver.util.BrokerException)20 Iterator (java.util.Iterator)18 SysMessageID (com.sun.messaging.jmq.io.SysMessageID)16 Consumer (com.sun.messaging.jmq.jmsserver.core.Consumer)16 PacketReference (com.sun.messaging.jmq.jmsserver.core.PacketReference)10 Producer (com.sun.messaging.jmq.jmsserver.core.Producer)9 ArrayList (java.util.ArrayList)9 Packet (com.sun.messaging.jmq.io.Packet)8 SelectorFormatException (com.sun.messaging.jmq.util.selector.SelectorFormatException)8 IOException (java.io.IOException)8 ProducerUID (com.sun.messaging.jmq.jmsserver.core.ProducerUID)6 PartitionedStore (com.sun.messaging.jmq.jmsserver.persist.api.PartitionedStore)6 HashMap (java.util.HashMap)6 BrokerAddress (com.sun.messaging.jmq.jmsserver.core.BrokerAddress)5 DestinationList (com.sun.messaging.jmq.jmsserver.core.DestinationList)5 Session (com.sun.messaging.jmq.jmsserver.core.Session)5 SessionUID (com.sun.messaging.jmq.jmsserver.core.SessionUID)5