Examples of WriteLock


Examples of org.apache.hcatalog.hbase.snapshot.lock.WriteLock

     */
    public void abortWriteTransaction(Transaction transaction) throws IOException {

        refreshTransactionList(transaction.getTableName());
        String lockPath = prepareLockNode(transaction.getTableName());
        WriteLock wLock = new WriteLock(zkUtil.getSession(), lockPath,
            Ids.OPEN_ACL_UNSAFE);
        RMLockListener myLockListener = new RMLockListener();
        wLock.setLockListener(myLockListener);
        try {
            boolean lockGrabbed = wLock.lock();
            if (lockGrabbed == false) {
                //TO DO : Let this request queue up and try obtaining lock.
                throw new IOException(
                    "Unable to obtain lock while aborting transaction. "
                        + transaction.toString());
            } else {
                String tableName = transaction.getTableName();
                List<String> colFamilies = transaction.getColumnFamilies();
                FamilyRevision revisionData = transaction
                    .getFamilyRevisionInfo();
                for (String cfamily : colFamilies) {
                    String path = PathUtil.getRunningTxnInfoPath(
                        baseDir, tableName, cfamily);
                    zkUtil.updateData(path, revisionData,
                        ZKUtil.UpdateMode.REMOVE);
                    path = PathUtil.getAbortInformationPath(baseDir,
                        tableName, cfamily);
                    zkUtil.updateData(path, revisionData,
                        ZKUtil.UpdateMode.APPEND);
                }

            }
        } catch (KeeperException e) {
            throw new IOException("Exception while obtaining lock.", e);
        } catch (InterruptedException e) {
            throw new IOException("Exception while obtaining lock.", e);
        } finally {
            wLock.unlock();
        }
        LOG.info("Write Transaction aborted: " + transaction.toString());
    }
View Full Code Here

Examples of org.apache.hcatalog.hbase.snapshot.lock.WriteLock

        throws IOException {

        refreshTransactionList(transaction.getTableName());
        transaction.keepAliveTransaction();
        String lockPath = prepareLockNode(transaction.getTableName());
        WriteLock wLock = new WriteLock(zkUtil.getSession(), lockPath,
            Ids.OPEN_ACL_UNSAFE);
        RMLockListener myLockListener = new RMLockListener();
        wLock.setLockListener(myLockListener);
        try {
            boolean lockGrabbed = wLock.lock();
            if (lockGrabbed == false) {
                //TO DO : Let this request queue up and try obtaining lock.
                throw new IOException(
                    "Unable to obtain lock for keep alive of transaction. "
                        + transaction.toString());
            } else {
                String tableName = transaction.getTableName();
                List<String> colFamilies = transaction.getColumnFamilies();
                FamilyRevision revisionData = transaction.getFamilyRevisionInfo();
                for (String cfamily : colFamilies) {
                    String path = PathUtil.getRunningTxnInfoPath(
                        baseDir, tableName, cfamily);
                    zkUtil.updateData(path, revisionData,
                        ZKUtil.UpdateMode.KEEP_ALIVE);
                }

            }
        } catch (KeeperException e) {
            throw new IOException("Exception while obtaining lock.", e);
        } catch (InterruptedException e) {
            throw new IOException("Exception while obtaining lock.", e);
        } finally {
            wLock.unlock();
        }

    }
View Full Code Here

Examples of org.apache.hcatalog.hbase.snapshot.lock.WriteLock

        return zkUtil.getTransactionList(path);
    }

    private void refreshTransactionList(String tableName) throws IOException {
        String lockPath = prepareLockNode(tableName);
        WriteLock wLock = new WriteLock(zkUtil.getSession(), lockPath,
            Ids.OPEN_ACL_UNSAFE);
        RMLockListener myLockListener = new RMLockListener();
        wLock.setLockListener(myLockListener);
        try {
            boolean lockGrabbed = wLock.lock();
            if (lockGrabbed == false) {
                //TO DO : Let this request queue up and try obtaining lock.
                throw new IOException(
                    "Unable to obtain lock while refreshing transactions of table "
                        + tableName + ".");
            } else {
                List<String> cfPaths = zkUtil
                    .getColumnFamiliesOfTable(tableName);
                for (String cf : cfPaths) {
                    String runningDataPath = PathUtil.getRunningTxnInfoPath(
                        baseDir, tableName, cf);
                    zkUtil.refreshTransactions(runningDataPath);
                }

            }
        } catch (KeeperException e) {
            throw new IOException("Exception while obtaining lock.", e);
        } catch (InterruptedException e) {
            throw new IOException("Exception while obtaining lock.", e);
        } finally {
            wLock.unlock();
        }

    }
View Full Code Here

Examples of org.apache.hcatalog.hbase.snapshot.lock.WriteLock

     *
     * @return revision ID
     * @throws IOException
     */
    public long obtainID() throws IOException {
        WriteLock wLock = new WriteLock(zookeeper, zNodeLockBasePath, Ids.OPEN_ACL_UNSAFE);
        wLock.setLockListener(this);
        try {
            boolean lockGrabbed = wLock.lock();
            if (lockGrabbed == false) {
                //TO DO : Let this request queue up and try obtaining lock.
                throw new IOException("Unable to obtain lock to obtain id.");
            } else {
                id = incrementAndReadCounter();
            }
        } catch (KeeperException e) {
            LOG.warn("Exception while obtaining lock for ID.", e);
            throw new IOException("Exception while obtaining lock for ID.", e);
        } catch (InterruptedException e) {
            LOG.warn("Exception while obtaining lock for ID.", e);
            throw new IOException("Exception while obtaining lock for ID.", e);
        } finally {
            wLock.unlock();
        }
        return id;
    }
View Full Code Here

Examples of org.apache.jackrabbit.core.state.ISMLocking.WriteLock

     * @throws InterruptedException on interruption; this will err the test
     */
    public void testIntersectingWrites() throws InterruptedException {
        ChangeLog cl = new ChangeLog();
        cl.added(state);
        WriteLock wLock = locking.acquireWriteLock(cl);
        for (Iterator it = logs.iterator(); it.hasNext();) {
            ChangeLog changeLog = (ChangeLog) it.next();
            verifyBlocked(startWriterThread(locking, changeLog));
        }
        wLock.release();
    }
View Full Code Here

Examples of org.apache.jackrabbit.core.state.ISMLocking.WriteLock

     * @throws InterruptedException on interruption; this will err the test
     */
    public void testDowngrade() throws InterruptedException {
        for (Iterator it = logs.iterator(); it.hasNext();) {
            ChangeLog changeLog = (ChangeLog) it.next();
            WriteLock wLock = locking.acquireWriteLock(changeLog);
            verifyBlocked(startReaderThread(locking, state.getId()));
            ReadLock rLock = wLock.downgrade();
            verifyNotBlocked(startReaderThread(locking, state.getId()));
            rLock.release();
        }
    }
View Full Code Here

Examples of org.apache.jackrabbit.core.state.ISMLocking.WriteLock

     * @throws InterruptedException on interruption; this will err the test
     */
    public void testWriteBlocksRead() throws InterruptedException {
        for (Iterator it = logs.iterator(); it.hasNext();) {
            ChangeLog changeLog = (ChangeLog) it.next();
            WriteLock wLock = locking.acquireWriteLock(changeLog);
            verifyBlocked(startReaderThread(locking, state.getId()));
            wLock.release();
        }
    }
View Full Code Here

Examples of org.apache.jackrabbit.core.state.ISMLocking.WriteLock

            final ChangeLog changeLog = (ChangeLog) it.next();
            Thread t = new Thread(new Runnable() {

                public void run() {
                    try {
                        WriteLock wLock = locking.acquireWriteLock(changeLog);
                        locking.acquireReadLock(state.getId()).release();
                        wLock.release();
                    } catch (InterruptedException e) {
                    }
                }
            });
            t.start();
View Full Code Here

Examples of org.apache.jackrabbit.core.state.ISMLocking.WriteLock

     * @return write operation helper
     * @throws RepositoryException if the write operation could not be started
     */
    private WriteOperation startWriteOperation() throws RepositoryException {
        boolean success = false;
        WriteLock lock = acquireWriteLock();
        try {
            stateMgr.edit();
            success = true;
            return new WriteOperation(lock);
        } catch (IllegalStateException e) {
            throw new RepositoryException("Unable to start edit operation.", e);
        } finally {
            if (!success) {
                lock.release();
            }
        }
    }
View Full Code Here

Examples of org.apache.jackrabbit.core.state.ISMLocking.WriteLock

     * @return write operation helper
     * @throws RepositoryException if the write operation could not be started
     */
    private WriteOperation startWriteOperation() throws RepositoryException {
        boolean success = false;
        WriteLock lock = acquireWriteLock();
        try {
            stateMgr.edit();
            success = true;
            return new WriteOperation(lock);
        } catch (IllegalStateException e) {
            throw new RepositoryException("Unable to start edit operation.", e);
        } finally {
            if (!success) {
                lock.release();
            }
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.