Package co.paralleluniverse.galaxy.core.Cache

Examples of co.paralleluniverse.galaxy.core.Cache.CacheLine


            currentBackupsLock.lock();
            try {
                assert !copyImmediately;
                for (Iterator<BackupEntry> it = oldMap.values().iterator(); it.hasNext();) {
                    final BackupEntry be = it.next();
                    final CacheLine line = cache.getLine(be.id);
                    assert line != null;
                    synchronized (line) {
                        Message.BACKUP backup = makeBackup(line, be.version);
                        if (backup != null) {
                            oldMap.remove(be.id);
                            if (LOG.isDebugEnabled())
                                LOG.debug("Copied {} ver {} for backup", hex(be.id), be.version);
                            currentBackups.put(be.id, backup);
                        } else {
                            if (LOG.isDebugEnabled())
                                LOG.debug("Matching version for {} ({}) not found", hex(be.id), be.version);
                            copyImmediately = true;
                        }
                    }
                    it.remove();
                }
            } finally {
                currentBackupsLock.unlock();
            }

            if (copyImmediately) { // backups incomplete
                LOG.debug("Incomplete backups. Completeing.");
                mapLock.writeLock().lock();
                currentBackupsLock.lock();
                try {
                    for (Iterator<BackupEntry> it = map.values().iterator(); it.hasNext();) {
                        final BackupEntry be = it.next();
                        final CacheLine line = cache.getLine(be.id);
                        assert line != null;
                        synchronized (line) {
                            Message.BACKUP backup = makeBackup(line, be.version);
                            if (backup != null) {
                                map.remove(be.id);
View Full Code Here


            currentBackupsLock.lock();
            try {
                assert !copyImmediately;
                for (Iterator<BackupEntry> it = oldMap.values().iterator(); it.hasNext();) {
                    final BackupEntry be = it.next();
                    final CacheLine line = cache.getLine(be.id);
                    assert line != null;
                    synchronized (line) {
                        Message.BACKUP backup = makeBackup(line, be.version);
                        if (backup != null) {
                            oldMap.remove(be.id);
                            if (LOG.isDebugEnabled())
                                LOG.debug("Copied {} ver {} for backup", hex(be.id), be.version);
                            currentBackups.put(be.id, backup);
                        } else {
                            if (LOG.isDebugEnabled())
                                LOG.debug("Matching version for {} ({}) not found", hex(be.id), be.version);
                            this.copyImmediately = true;
                        }
                    }
                    it.remove();
                }
            } finally {
                currentBackupsLock.unlock();
            }

            if (copyImmediately) { // backups incomplete
                LOG.debug("Incomplete backups. Completeing.");
                mapLock.writeLock().lock();
                currentBackupsLock.lock();
                try {
                    for (Iterator<BackupEntry> it = map.values().iterator(); it.hasNext();) {
                        final BackupEntry be = it.next();
                        final CacheLine line = cache.getLine(be.id);
                        assert line != null;
                        synchronized (line) {
                            Message.BACKUP backup = makeBackup(line, be.version);
                            if (backup != null) {
                                map.remove(be.id);
View Full Code Here

            currentBackupsLock.lock();
            try {
                assert !copyImmediately;
                for (Iterator<BackupEntry> it = oldMap.values().iterator(); it.hasNext();) {
                    final BackupEntry be = it.next();
                    final CacheLine line = cache.getLine(be.id);
                    assert line != null;
                    synchronized (line) {
                        Message.BACKUP backup = makeBackup(line, be.version);
                        if (backup != null) {
                            oldMap.remove(be.id);
                            if (LOG.isDebugEnabled())
                                LOG.debug("Copied {} ver {} for backup", hex(be.id), be.version);
                            currentBackups.put(be.id, backup);
                        } else {
                            if (LOG.isDebugEnabled())
                                LOG.debug("Matching version for {} ({}) not found", hex(be.id), be.version);
                            copyImmediately = true;
                        }
                    }
                    it.remove();
                }
            } finally {
                currentBackupsLock.unlock();
            }

            if (copyImmediately) { // backups incomplete
                LOG.debug("Incomplete backups. Completeing.");
                mapLock.writeLock().lock();
                currentBackupsLock.lock();
                try {
                    for (Iterator<BackupEntry> it = map.values().iterator(); it.hasNext();) {
                        final BackupEntry be = it.next();
                        final CacheLine line = cache.getLine(be.id);
                        assert line != null;
                        synchronized (line) {
                            Message.BACKUP backup = makeBackup(line, be.version);
                            if (backup != null) {
                                map.remove(be.id);
View Full Code Here

        } else
            return allocator.getRefAllocationsListeners().iterator().next();
    }

    void assertState(long id, State state, State nextState) {
        CacheLine line = cache.getLine(id);
        assertThat(line.getState(), is(state));
        assertThat(line.getNextState(), is(nextState));
    }
View Full Code Here

        assertThat(line.getState(), is(state));
        assertThat(line.getNextState(), is(nextState));
    }

    void assertOwner(long id, short node) {
        CacheLine line = cache.getLine(id);
        assertThat(line.getOwner(), is(node));
    }
View Full Code Here

        CacheLine line = cache.getLine(id);
        assertThat(line.getOwner(), is(node));
    }

    void assertVersion(long id, long version) {
        CacheLine line = cache.getLine(id);
        assertThat(line.getVersion(), is(version));
    }
View Full Code Here

        CacheLine line = cache.getLine(id);
        assertThat(line.getVersion(), is(version));
    }

    void assertLocked(long id, boolean value) {
        CacheLine line = cache.getLine(id);
        assertThat(line.isLocked(), is(value));
    }
View Full Code Here

        CacheLine line = cache.getLine(id);
        assertThat(line.isLocked(), is(value));
    }

    void assertModified(long id, boolean value) {
        CacheLine line = cache.getLine(id);
        assertThat(line.is(CacheLine.MODIFIED), is(value));
    }
View Full Code Here

        CacheLine line = cache.getLine(id);
        assertThat(line.is(CacheLine.MODIFIED), is(value));
    }

    void evict(long id, boolean invack) {
        CacheLine line = cache.getLine(id);
        cache.evictLine(line, invack);
    }
View Full Code Here

            currentBackupsLock.lock();
            try {
                assert !copyImmediately;
                for (Iterator<BackupEntry> it = oldMap.values().iterator(); it.hasNext();) {
                    final BackupEntry be = it.next();
                    final CacheLine line = cache.getLine(be.id);
                    assert line != null;
                    synchronized (line) {
                        final Message.BACKUP backup = makeBackup(line, be.version);
                        if (backup != null) {
                            oldMap.remove(be.id);
                            if (LOG.isDebugEnabled())
                                LOG.debug("Copied {} ver {} for backup", hex(be.id), be.version);
                            currentBackups.put(be.id, backup);
                        } else {
                            if (LOG.isDebugEnabled())
                                LOG.debug("Matching version for {} ({}) not found", hex(be.id), be.version);
                            this.copyImmediately = true;
                        }
                    }
                    it.remove();
                }
            } finally {
                currentBackupsLock.unlock();
            }

            if (copyImmediately) { // backups incomplete
                LOG.debug("Incomplete backups. Completeing.");
                mapLock.writeLock().lock();
                currentBackupsLock.lock();
                try {
                    for (Iterator<BackupEntry> it = map.values().iterator(); it.hasNext();) {
                        final BackupEntry be = it.next();
                        final CacheLine line = cache.getLine(be.id);
                        assert line != null;
                        synchronized (line) {
                            Message.BACKUP backup = makeBackup(line, be.version);
                            if (backup != null) {
                                map.remove(be.id);
View Full Code Here

TOP

Related Classes of co.paralleluniverse.galaxy.core.Cache.CacheLine

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.