Package org.apache.kahadb.journal

Examples of org.apache.kahadb.journal.Location


            if (loaded.get()) {
                this.store.getPageFile().tx().execute(new Transaction.Closure<IOException>() {
                    public void execute(Transaction tx) throws IOException {
                        Iterator<Map.Entry<String,Location>> iterator = iterator(tx);
                        while (iterator.hasNext()) {
                            Location location = iterator.next().getValue();
                            candidates.remove(location.getDataFileId());
                        }
                    }
                });
            }
        }
View Full Code Here


        LOG.info("Stopped KahaDB");
        super.doStop(stopper);
    }

    void incrementRedeliveryAndReWrite(final String key, final KahaDestination destination) throws IOException {
        Location location;
        this.indexLock.writeLock().lock();
        try {
              location = findMessageLocation(key, destination);
        } finally {
            this.indexLock.writeLock().unlock();
        }

        if (location != null) {
            KahaAddMessageCommand addMessage = (KahaAddMessageCommand) load(location);
            Message message = (Message) wireFormat.unmarshal(new DataInputStream(addMessage.getMessage().newInput()));

            message.incrementRedeliveryCounter();
            if (LOG.isTraceEnabled()) {
                LOG.trace("rewriting: " + key + " with deliveryCount: " + message.getRedeliveryCounter());
            }
            org.apache.activemq.util.ByteSequence packet = wireFormat.marshal(message);
            addMessage.setMessage(new Buffer(packet.getData(), packet.getOffset(), packet.getLength()));

            final Location rewriteLocation = journal.write(toByteSequence(addMessage), true);

            this.indexLock.writeLock().lock();
            try {
                pageFile.tx().execute(new Transaction.Closure<IOException>() {
                    public void execute(Transaction tx) throws IOException {
View Full Code Here

            final String key = identity.toString();

            // Hopefully one day the page file supports concurrent read
            // operations... but for now we must
            // externally synchronize...
            Location location;
            indexLock.writeLock().lock();
            try {
                location = findMessageLocation(key, dest);
            }finally {
                indexLock.writeLock().unlock();
View Full Code Here

public class LocationMarshaller implements Marshaller<Location> {
    public final static LocationMarshaller INSTANCE = new LocationMarshaller();

    public Location readPayload(DataInput dataIn) throws IOException {
        Location rc = new Location();
        rc.setDataFileId(dataIn.readInt());
        rc.setOffset(dataIn.readInt());
        return rc;
    }
View Full Code Here

    public int getFixedSize() {
        return 8;
    }

    public Location deepCopy(Location source) {
        return new Location(source);
    }
View Full Code Here

    public void readExternal(DataInput in) throws IOException {
        this.id = in.readUTF();
        this.prev = in.readLong();
        this.next = in.readLong();
        if (this.location == null) {
            this.location = new Location();
        }
        this.location.readExternal(in);
    }
View Full Code Here

    public void writeExternal(DataOutput out) throws IOException {
        out.writeUTF(this.id);
        out.writeLong(this.prev);
        out.writeLong(this.next);
        if (this.location == null) {
            this.location = new Location();
        }
        this.location.writeExternal(out);
    }
View Full Code Here

            this.size=0;
        }
    }

    synchronized public void addLast(final String id, final ByteSequence bs) throws IOException {
        final Location location = this.store.write(bs, false);
        synchronized (indexLock) {
            this.store.getPageFile().tx().execute(new Transaction.Closure<IOException>() {
                public void execute(Transaction tx) throws IOException {
                    addLast(tx, id, bs, location);
                }
View Full Code Here

        this.lastId = entry.getPage().getPageId();
        this.size++;
    }

    synchronized public void addFirst(final String id, final ByteSequence bs) throws IOException {
        final Location location = this.store.write(bs, false);
        synchronized (indexLock) {
            this.store.getPageFile().tx().execute(new Transaction.Closure<IOException>() {
                public void execute(Transaction tx) throws IOException {
                    addFirst(tx, id, bs, location);
                }
View Full Code Here

            final String key = identity.toString();

            // Hopefully one day the page file supports concurrent read
            // operations... but for now we must
            // externally synchronize...
            Location location;
            indexLock.readLock().lock();
            try {
                location = pageFile.tx().execute(new Transaction.CallableClosure<Location, IOException>() {
                    public Location execute(Transaction tx) throws IOException {
                        StoredDestination sd = getStoredDestination(dest, tx);
View Full Code Here

TOP

Related Classes of org.apache.kahadb.journal.Location

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.