Search in sources :

Example 16 with IZooReaderWriter

use of org.apache.accumulo.fate.zookeeper.IZooReaderWriter in project accumulo by apache.

the class MasterMetadataUtil method updateRootTabletDataFile.

/**
 * Update the data file for the root tablet
 */
private static void updateRootTabletDataFile(KeyExtent extent, FileRef path, FileRef mergeFile, DataFileValue dfv, String time, Set<FileRef> filesInUseByScans, String address, ZooLock zooLock, Set<String> unusedWalLogs, TServerInstance lastLocation, long flushId) {
    IZooReaderWriter zk = ZooReaderWriter.getInstance();
    String root = MetadataTableUtil.getZookeeperLogLocation();
    for (String entry : unusedWalLogs) {
        String[] parts = entry.split("/");
        String zpath = root + "/" + parts[parts.length - 1];
        while (true) {
            try {
                if (zk.exists(zpath)) {
                    log.debug("Removing WAL reference for root table {}", zpath);
                    zk.recursiveDelete(zpath, NodeMissingPolicy.SKIP);
                }
                break;
            } catch (KeeperException | InterruptedException e) {
                log.error("{}", e.getMessage(), e);
            }
            sleepUninterruptibly(1, TimeUnit.SECONDS);
        }
    }
}
Also used : IZooReaderWriter(org.apache.accumulo.fate.zookeeper.IZooReaderWriter) KeeperException(org.apache.zookeeper.KeeperException)

Example 17 with IZooReaderWriter

use of org.apache.accumulo.fate.zookeeper.IZooReaderWriter in project accumulo by apache.

the class MetadataTableUtil method getRootTabletDir.

public static String getRootTabletDir() throws IOException {
    IZooReaderWriter zoo = ZooReaderWriter.getInstance();
    String zpath = ZooUtil.getRoot(HdfsZooInstance.getInstance()) + RootTable.ZROOT_TABLET_PATH;
    try {
        return new String(zoo.getData(zpath, null), UTF_8);
    } catch (KeeperException e) {
        throw new IOException(e);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        throw new IOException(e);
    }
}
Also used : IZooReaderWriter(org.apache.accumulo.fate.zookeeper.IZooReaderWriter) IOException(java.io.IOException) KeeperException(org.apache.zookeeper.KeeperException)

Example 18 with IZooReaderWriter

use of org.apache.accumulo.fate.zookeeper.IZooReaderWriter in project accumulo by apache.

the class MetadataTableUtil method getRootLogEntries.

static void getRootLogEntries(final ArrayList<LogEntry> result) throws KeeperException, InterruptedException, IOException {
    IZooReaderWriter zoo = ZooReaderWriter.getInstance();
    String root = getZookeeperLogLocation();
    // the data. The log can be removed in between.
    while (true) {
        result.clear();
        for (String child : zoo.getChildren(root)) {
            try {
                LogEntry e = LogEntry.fromBytes(zoo.getData(root + "/" + child, null));
                // upgrade from !0;!0<< -> +r<<
                e = new LogEntry(RootTable.EXTENT, 0, e.server, e.filename);
                result.add(e);
            } catch (KeeperException.NoNodeException ex) {
                continue;
            }
        }
        break;
    }
}
Also used : IZooReaderWriter(org.apache.accumulo.fate.zookeeper.IZooReaderWriter) LogEntry(org.apache.accumulo.core.tabletserver.log.LogEntry) KeeperException(org.apache.zookeeper.KeeperException)

Example 19 with IZooReaderWriter

use of org.apache.accumulo.fate.zookeeper.IZooReaderWriter in project accumulo by apache.

the class CleanZookeeper method main.

/**
 * @param args
 *          must contain one element: the address of a zookeeper node a second parameter provides an additional authentication value
 * @throws IOException
 *           error connecting to accumulo or zookeeper
 */
public static void main(String[] args) throws IOException {
    Opts opts = new Opts();
    opts.parseArgs(CleanZookeeper.class.getName(), args);
    String root = Constants.ZROOT;
    IZooReaderWriter zk = ZooReaderWriter.getInstance();
    if (opts.auth != null) {
        zk.getZooKeeper().addAuthInfo("digest", ("accumulo:" + opts.auth).getBytes(UTF_8));
    }
    try {
        for (String child : zk.getChildren(root)) {
            if (Constants.ZINSTANCES.equals("/" + child)) {
                for (String instanceName : zk.getChildren(root + Constants.ZINSTANCES)) {
                    String instanceNamePath = root + Constants.ZINSTANCES + "/" + instanceName;
                    byte[] id = zk.getData(instanceNamePath, null);
                    if (id != null && !new String(id, UTF_8).equals(HdfsZooInstance.getInstance().getInstanceID())) {
                        try {
                            zk.recursiveDelete(instanceNamePath, NodeMissingPolicy.SKIP);
                        } catch (KeeperException.NoAuthException ex) {
                            log.warn("Unable to delete {}", instanceNamePath);
                        }
                    }
                }
            } else if (!child.equals(HdfsZooInstance.getInstance().getInstanceID())) {
                String path = root + "/" + child;
                try {
                    zk.recursiveDelete(path, NodeMissingPolicy.SKIP);
                } catch (KeeperException.NoAuthException ex) {
                    log.warn("Unable to delete {}", path);
                }
            }
        }
    } catch (Exception ex) {
        System.out.println("Error Occurred: " + ex);
    }
}
Also used : IZooReaderWriter(org.apache.accumulo.fate.zookeeper.IZooReaderWriter) KeeperException(org.apache.zookeeper.KeeperException) KeeperException(org.apache.zookeeper.KeeperException) IOException(java.io.IOException)

Example 20 with IZooReaderWriter

use of org.apache.accumulo.fate.zookeeper.IZooReaderWriter in project accumulo by apache.

the class ZKAuthenticator method constructUser.

/**
 * Sets up the user in ZK for the provided user. No checking for existence is done here, it should be done before calling.
 */
private void constructUser(String user, byte[] pass) throws KeeperException, InterruptedException {
    synchronized (zooCache) {
        zooCache.clear();
        IZooReaderWriter zoo = ZooReaderWriter.getInstance();
        zoo.putPrivatePersistentData(ZKUserPath + "/" + user, pass, NodeExistsPolicy.FAIL);
    }
}
Also used : IZooReaderWriter(org.apache.accumulo.fate.zookeeper.IZooReaderWriter)

Aggregations

IZooReaderWriter (org.apache.accumulo.fate.zookeeper.IZooReaderWriter)57 KeeperException (org.apache.zookeeper.KeeperException)25 IOException (java.io.IOException)13 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)11 Instance (org.apache.accumulo.core.client.Instance)11 AcceptableThriftTableOperationException (org.apache.accumulo.core.client.impl.AcceptableThriftTableOperationException)8 Mutator (org.apache.accumulo.fate.zookeeper.IZooReaderWriter.Mutator)6 HdfsZooInstance (org.apache.accumulo.server.client.HdfsZooInstance)6 AccumuloException (org.apache.accumulo.core.client.AccumuloException)5 TException (org.apache.thrift.TException)5 NoNodeException (org.apache.zookeeper.KeeperException.NoNodeException)5 ArrayList (java.util.ArrayList)4 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)4 ZooReaderWriterFactory (org.apache.accumulo.server.zookeeper.ZooReaderWriterFactory)4 File (java.io.File)3 Entry (java.util.Map.Entry)3 Connector (org.apache.accumulo.core.client.Connector)3 Scanner (org.apache.accumulo.core.client.Scanner)3 AccumuloConfiguration (org.apache.accumulo.core.conf.AccumuloConfiguration)3 Key (org.apache.accumulo.core.data.Key)3