Search in sources :

Example 6 with MetadataStoreException

use of org.apache.bookkeeper.bookie.BookieException.MetadataStoreException in project bookkeeper by apache.

the class ZKRegistrationManager method removeCookie.

@Override
public void removeCookie(String bookieId, Version version) throws BookieException {
    String zkPath = getCookiePath(bookieId);
    try {
        zk.delete(zkPath, (int) ((LongVersion) version).getLongVersion());
    } catch (NoNodeException e) {
        throw new CookieNotFoundException(bookieId);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        throw new MetadataStoreException("Interrupted deleting cookie for bookie " + bookieId, e);
    } catch (KeeperException e) {
        throw new MetadataStoreException("Failed to delete cookie for bookie " + bookieId);
    }
    log.info("Removed cookie from {} for bookie {}.", cookiePath, bookieId);
}
Also used : MetadataStoreException(org.apache.bookkeeper.bookie.BookieException.MetadataStoreException) NoNodeException(org.apache.zookeeper.KeeperException.NoNodeException) LongVersion(org.apache.bookkeeper.versioning.LongVersion) CookieNotFoundException(org.apache.bookkeeper.bookie.BookieException.CookieNotFoundException) BKInterruptedException(org.apache.bookkeeper.client.BKException.BKInterruptedException) KeeperException(org.apache.zookeeper.KeeperException)

Example 7 with MetadataStoreException

use of org.apache.bookkeeper.bookie.BookieException.MetadataStoreException in project bookkeeper by apache.

the class ZKRegistrationManager method doRegisterBookie.

private void doRegisterBookie(String regPath) throws BookieException {
    // ZK ephemeral node for this Bookie.
    try {
        if (!checkRegNodeAndWaitExpired(regPath)) {
            // Create the ZK ephemeral node for this Bookie.
            zk.create(regPath, new byte[0], zkAcls, CreateMode.EPHEMERAL);
            zkRegManagerInitialized = true;
        }
    } catch (KeeperException ke) {
        log.error("ZK exception registering ephemeral Znode for Bookie!", ke);
        // exit here as this is a fatal error.
        throw new MetadataStoreException(ke);
    } catch (InterruptedException ie) {
        Thread.currentThread().interrupt();
        log.error("Interrupted exception registering ephemeral Znode for Bookie!", ie);
        // exit here as this is a fatal error.
        throw new MetadataStoreException(ie);
    } catch (IOException e) {
        throw new MetadataStoreException(e);
    }
}
Also used : MetadataStoreException(org.apache.bookkeeper.bookie.BookieException.MetadataStoreException) IOException(java.io.IOException) BKInterruptedException(org.apache.bookkeeper.client.BKException.BKInterruptedException) KeeperException(org.apache.zookeeper.KeeperException)

Example 8 with MetadataStoreException

use of org.apache.bookkeeper.bookie.BookieException.MetadataStoreException in project bookkeeper by apache.

the class ZKRegistrationManager method doRegisterReadOnlyBookie.

private void doRegisterReadOnlyBookie(String bookieId) throws BookieException {
    try {
        if (null == zk.exists(this.bookieReadonlyRegistrationPath, false)) {
            try {
                zk.create(this.bookieReadonlyRegistrationPath, new byte[0], zkAcls, CreateMode.PERSISTENT);
            } catch (NodeExistsException e) {
            // this node is just now created by someone.
            }
        }
        String regPath = bookieReadonlyRegistrationPath + "/" + bookieId;
        doRegisterBookie(regPath);
        // clear the write state
        regPath = bookieRegistrationPath + "/" + bookieId;
        try {
            // Clear the current registered node
            zk.delete(regPath, -1);
        } catch (KeeperException.NoNodeException nne) {
            log.warn("No writable bookie registered node {} when transitioning to readonly", regPath, nne);
        }
    } catch (KeeperException | InterruptedException e) {
        throw new MetadataStoreException(e);
    }
}
Also used : MetadataStoreException(org.apache.bookkeeper.bookie.BookieException.MetadataStoreException) NodeExistsException(org.apache.zookeeper.KeeperException.NodeExistsException) NoNodeException(org.apache.zookeeper.KeeperException.NoNodeException) BKInterruptedException(org.apache.bookkeeper.client.BKException.BKInterruptedException) KeeperException(org.apache.zookeeper.KeeperException)

Aggregations

MetadataStoreException (org.apache.bookkeeper.bookie.BookieException.MetadataStoreException)8 BKInterruptedException (org.apache.bookkeeper.client.BKException.BKInterruptedException)6 KeeperException (org.apache.zookeeper.KeeperException)6 NoNodeException (org.apache.zookeeper.KeeperException.NoNodeException)4 CookieNotFoundException (org.apache.bookkeeper.bookie.BookieException.CookieNotFoundException)2 MetadataBookieDriver (org.apache.bookkeeper.meta.MetadataBookieDriver)2 LongVersion (org.apache.bookkeeper.versioning.LongVersion)2 File (java.io.File)1 IOException (java.io.IOException)1 BookieIllegalOpException (org.apache.bookkeeper.bookie.BookieException.BookieIllegalOpException)1 ServerConfiguration (org.apache.bookkeeper.conf.ServerConfiguration)1 RegistrationManager (org.apache.bookkeeper.discover.RegistrationManager)1 MetadataException (org.apache.bookkeeper.meta.exceptions.MetadataException)1 ZKMetadataBookieDriver (org.apache.bookkeeper.meta.zk.ZKMetadataBookieDriver)1 BookieServer (org.apache.bookkeeper.proto.BookieServer)1 Versioned (org.apache.bookkeeper.versioning.Versioned)1 ConfigurationException (org.apache.commons.configuration.ConfigurationException)1 NodeExistsException (org.apache.zookeeper.KeeperException.NodeExistsException)1 Stat (org.apache.zookeeper.data.Stat)1 Test (org.junit.Test)1