Package org.apache.zookeeper.data

Examples of org.apache.zookeeper.data.Stat


    if (!secureZKAvailable) {
      return;
    }

    List<ACL> acls = zkw.getRecoverableZooKeeper().getZooKeeper()
        .getACL("/hbase/root-region-server", new Stat());
    assertEquals(acls.size(),2);

    boolean foundWorldReadableAcl = false;
    boolean foundHBaseOwnerAcl = false;
    for(int i = 0; i < 2; i++) {
View Full Code Here


    if (!secureZKAvailable) {
      return;
    }

    List<ACL> acls = zkw.getRecoverableZooKeeper().getZooKeeper()
        .getACL("/hbase/master", new Stat());
    assertEquals(acls.size(),2);

    boolean foundWorldReadableAcl = false;
    boolean foundHBaseOwnerAcl = false;
    for(int i = 0; i < 2; i++) {
View Full Code Here

    if (!secureZKAvailable) {
      return;
    }

    List<ACL> acls = zkw.getRecoverableZooKeeper().getZooKeeper()
        .getACL("/hbase/hbaseid", new Stat());
    assertEquals(acls.size(),2);

    boolean foundWorldReadableAcl = false;
    boolean foundHBaseOwnerAcl = false;
    for(int i = 0; i < 2; i++) {
View Full Code Here

      return;
    }

    ZKUtil.createWithParents(zkw, "/testACLNode");
    List<ACL> acls = zkw.getRecoverableZooKeeper().getZooKeeper()
        .getACL("/testACLNode", new Stat());
    assertEquals(acls.size(),1);
    assertEquals(acls.get(0).getId().getScheme(),"sasl");
    assertEquals(acls.get(0).getId().getId(),"hbase");
    assertEquals(acls.get(0).getPerms(), ZooDefs.Perms.ALL);
  }
View Full Code Here

   * @throws KeeperException if unexpected zookeeper exception
   */
  public static boolean watchAndCheckExists(ZooKeeperWatcher zkw, String znode)
  throws KeeperException {
    try {
      Stat s = zkw.getRecoverableZooKeeper().exists(znode, zkw);
      boolean exists = s != null ? true : false;
      if (exists) {
        LOG.debug(zkw.prefix("Set watcher on existing znode " + znode));
      } else {
        LOG.debug(zkw.prefix(znode+" does not exist. Watcher is set."));
View Full Code Here

   * @throws KeeperException if unexpected zookeeper exception
   */
  public static int checkExists(ZooKeeperWatcher zkw, String znode)
  throws KeeperException {
    try {
      Stat s = zkw.getRecoverableZooKeeper().exists(znode, null);
      return s != null ? s.getVersion() : -1;
    } catch (KeeperException e) {
      LOG.warn(zkw.prefix("Unable to set watcher on znode (" + znode + ")"), e);
      zkw.keeperException(e);
      return -1;
    } catch (InterruptedException e) {
View Full Code Here

   * @throws KeeperException if unexpected zookeeper exception
   */
  public static int getNumberOfChildren(ZooKeeperWatcher zkw, String znode)
  throws KeeperException {
    try {
      Stat stat = zkw.getRecoverableZooKeeper().exists(znode, null);
      return stat == null ? 0 : stat.getNumChildren();
    } catch(KeeperException e) {
      LOG.warn(zkw.prefix("Unable to get children of node " + znode));
      zkw.keeperException(e);
    } catch(InterruptedException e) {
      zkw.interruptedException(e);
View Full Code Here

            try
            {
              T merged = null;

              Stat readStat = new Stat();
              try
              {
                // accessor will fallback to zk if not found in cache
                merged = accessor.get(mergedKey, readStat, options);
              }
              catch (ZkNoNodeException e)
              {
                // OK.
              }

              // updater should handler merged == null
              // merged = first._updater.update(merged);

              // iterate over processed if we are retrying
              Iterator<Entry<T>> it = processed.iterator();
              while (it.hasNext())
              {
                Entry<T> ent = it.next();
                if (!ent._key.equals(mergedKey))
                {
                  continue;
                }
                merged = ent._updater.update(merged);
                // System.out.println("After merging:" + merged);
              }

              // iterate over queue._pending for newly coming requests
              it = queue._pending.iterator();
              while (it.hasNext())
              {
                Entry<T> ent = it.next();
                if (!ent._key.equals(mergedKey))
                {
                  continue;
                }
                processed.add(ent);
                merged = ent._updater.update(merged);
                // System.out.println("After merging:" + merged);
                it.remove();
              }
              // System.out.println("size:"+ processed.size());
              accessor.set(mergedKey, merged, null, null, readStat.getVersion(), options);
            }
            catch (ZkBadVersionException e)
            {
              retry = true;
            }
View Full Code Here

    long backoffTime = 20; // ms
    for (int i = 0; i < 3; i++)
    {
      try
      {
        Stat stat = new Stat();
        ZNRecord record = zkClient.<ZNRecord> readDataAndStat(path, stat, true);

        if (isValueExpected(record, type, key, expect, diff))
        {
          if (arg._operation.compareTo("+") == 0)
          {
            if (record == null)
            {
              record = new ZNRecord("default");
            }
            ZnodeModValueType valueType = getValueType(arg._propertyType, arg._key);
            switch (valueType)
            {
            case SINGLE_VALUE:
              setSingleValue(record,
                             arg._propertyType,
                             arg._key,
                             arg._updateValue._singleValue);
              break;
            case LIST_VALUE:
              setListValue(record, arg._key, arg._updateValue._listValue);
              break;
            case MAP_VALUE:
              setMapValue(record, arg._key, arg._updateValue._mapValue);
              break;
            case ZNODE_VALUE:
              // deep copy
              record =
                  ZNRECORD_SERIALIZER.deserialize(ZNRECORD_SERIALIZER.serialize(arg._updateValue._znodeValue));
              break;
            case INVALID:
              break;
            default:
              break;
            }
          }
          else if (arg._operation.compareTo("-") == 0)
          {
            ZnodeModValueType valueType = getValueType(arg._propertyType, arg._key);
            switch (valueType)
            {
            case SINGLE_VALUE:
              removeSingleValue(record, arg._propertyType, arg._key);
              break;
            case LIST_VALUE:
              removeListValue(record, arg._key);
              break;
            case MAP_VALUE:
              removeMapValue(record, arg._key);
              break;
            case ZNODE_VALUE:
              record = null;
              break;
            case INVALID:
              break;
            default:
              break;
            }
          }
          else
          {
            logger.warn("fail to execute (unsupport operation): " + arg._operation);
            success = false;
          }

          if (success == true)
          {
            if (record == null)
            {
              zkClient.delete(path);
            }
            else
            {
              try
              {
                zkClient.createPersistent(path, true);
              }
              catch (ZkNodeExistsException e)
              {
                // OK
              }
              zkClient.writeData(path, record, stat.getVersion());
            }
            return true;
          }
          else
          {
View Full Code Here

    if (cache != null)
    {
      try
      {
        cache.lockWrite();
        Stat setStat = new Stat();
        List<String> pathsCreated = new ArrayList<String>();
        boolean success =
            _baseAccessor.set(serverPath, data, pathsCreated, setStat, -1, options);

        updateCache(cache, pathsCreated, success, serverPath, data, setStat);
View Full Code Here

TOP

Related Classes of org.apache.zookeeper.data.Stat

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.