當前位置: 首頁>>代碼示例>>Java>>正文


Java AsyncCallback.StringCallback方法代碼示例

本文整理匯總了Java中org.apache.zookeeper.AsyncCallback.StringCallback方法的典型用法代碼示例。如果您正苦於以下問題:Java AsyncCallback.StringCallback方法的具體用法?Java AsyncCallback.StringCallback怎麽用?Java AsyncCallback.StringCallback使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.zookeeper.AsyncCallback的用法示例。


在下文中一共展示了AsyncCallback.StringCallback方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: asyncSetOfflineInZooKeeper

import org.apache.zookeeper.AsyncCallback; //導入方法依賴的package包/類
/**
 * Set region as OFFLINED up in zookeeper asynchronously.
 * @param state
 * @return True if we succeeded, false otherwise (State was incorrect or failed
 * updating zk).
 */
private boolean asyncSetOfflineInZooKeeper(final RegionState state,
    final AsyncCallback.StringCallback cb, final ServerName destination) {
  if (!state.isClosed() && !state.isOffline()) {
    this.server.abort("Unexpected state trying to OFFLINE; " + state,
      new IllegalStateException());
    return false;
  }
  regionStates.updateRegionState(state.getRegion(), State.OFFLINE);
  try {
    ZKAssign.asyncCreateNodeOffline(watcher, state.getRegion(),
      destination, cb, state);
  } catch (KeeperException e) {
    if (e instanceof NodeExistsException) {
      LOG.warn("Node for " + state.getRegion() + " already exists");
    } else {
      server.abort("Unexpected ZK exception creating/setting node OFFLINE", e);
    }
    return false;
  }
  return true;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:28,代碼來源:AssignmentManager.java

示例2: asyncSetOfflineInZooKeeper

import org.apache.zookeeper.AsyncCallback; //導入方法依賴的package包/類
/**
 * Set region as OFFLINED up in zookeeper asynchronously.
 * @param state
 * @return True if we succeeded, false otherwise (State was incorrect or failed
 * updating zk).
 */
boolean asyncSetOfflineInZooKeeper(final RegionState state,
    final AsyncCallback.StringCallback cb, final Object ctx) {
  if (!state.isClosed() && !state.isOffline()) {
      new RuntimeException("Unexpected state trying to OFFLINE; " + state);
    this.master.abort("Unexpected state trying to OFFLINE; " + state,
      new IllegalStateException());
    return false;
  }
  state.update(RegionState.State.OFFLINE);
  try {
    ZKAssign.asyncCreateNodeOffline(master.getZooKeeper(), state.getRegion(),
      this.master.getServerName(), cb, ctx);
  } catch (KeeperException e) {
    // TODO: this error handling will never execute, as the callback is async.
    if (e instanceof NodeExistsException) {
      LOG.warn("Node for " + state.getRegion() + " already exists");
    } else { 
      master.abort("Unexpected ZK exception creating/setting node OFFLINE", e);
    }
    return false;
  }
  return true;
}
 
開發者ID:fengchen8086,項目名稱:LCIndex-HBase-0.94.16,代碼行數:30,代碼來源:AssignmentManager.java

示例3: asyncSetOfflineInZooKeeper

import org.apache.zookeeper.AsyncCallback; //導入方法依賴的package包/類
/**
 * Set region as OFFLINED up in zookeeper asynchronously.
 * @param state
 * @return True if we succeeded, false otherwise (State was incorrect or failed
 * updating zk).
 */
boolean asyncSetOfflineInZooKeeper(final RegionState state,
    final AsyncCallback.StringCallback cb, final Object ctx) {
  if (!state.isClosed() && !state.isOffline()) {
      new RuntimeException("Unexpected state trying to OFFLINE; " + state);
    this.master.abort("Unexpected state trying to OFFLINE; " + state,
      new IllegalStateException());
    return false;
  }
  state.update(RegionState.State.OFFLINE);
  try {
    ZKAssign.asyncCreateNodeOffline(master.getZooKeeper(), state.getRegion(),
      this.master.getServerName(), cb, ctx);
  } catch (KeeperException e) {
    master.abort("Unexpected ZK exception creating/setting node OFFLINE", e);
    return false;
  }
  return true;
}
 
開發者ID:lifeng5042,項目名稱:RStore,代碼行數:25,代碼來源:AssignmentManager.java

示例4: asyncSetOfflineInZooKeeper

import org.apache.zookeeper.AsyncCallback; //導入方法依賴的package包/類
/**
 * Set region as OFFLINED up in zookeeper asynchronously.
 * @param state
 * @return True if we succeeded, false otherwise (State was incorrect or failed
 * updating zk).
 */
private boolean asyncSetOfflineInZooKeeper(final RegionState state,
    final AsyncCallback.StringCallback cb, final ServerName destination) {
  if (!state.isClosed() && !state.isOffline()) {
    this.server.abort("Unexpected state trying to OFFLINE; " + state,
      new IllegalStateException());
    return false;
  }
  regionStates.updateRegionState(
    state.getRegion(), RegionState.State.OFFLINE);
  try {
    ZKAssign.asyncCreateNodeOffline(watcher, state.getRegion(),
      destination, cb, state);
  } catch (KeeperException e) {
    if (e instanceof NodeExistsException) {
      LOG.warn("Node for " + state.getRegion() + " already exists");
    } else {
      server.abort("Unexpected ZK exception creating/setting node OFFLINE", e);
    }
    return false;
  }
  return true;
}
 
開發者ID:daidong,項目名稱:DominoHBase,代碼行數:29,代碼來源:AssignmentManager.java

示例5: createAllocators

import org.apache.zookeeper.AsyncCallback; //導入方法依賴的package包/類
private void createAllocators(int numAllocators) throws InterruptedException, IOException {
    final AtomicInteger numPendings = new AtomicInteger(numAllocators);
    final AtomicInteger numFailures = new AtomicInteger(0);
    final CountDownLatch latch = new CountDownLatch(1);
    AsyncCallback.StringCallback createCallback = new AsyncCallback.StringCallback() {
        @Override
        public void processResult(int rc, String path, Object ctx, String name) {
            if (KeeperException.Code.OK.intValue() != rc) {
                numFailures.incrementAndGet();
                latch.countDown();
                return;
            }
            if (numPendings.decrementAndGet() == 0 && numFailures.get() == 0) {
                latch.countDown();
            }
        }
    };
    for (int i = 0; i < numAllocators; i++) {
        zkc.get().create(poolPath + "/A", new byte[0],
                         zkc.getDefaultACL(),
                         CreateMode.PERSISTENT_SEQUENTIAL,
                         createCallback, null);
    }
    latch.await();
    if (numFailures.get() > 0) {
        throw new IOException("Failed to create " + numAllocators + " allocators.");
    }
}
 
開發者ID:twitter,項目名稱:distributedlog,代碼行數:29,代碼來源:LedgerAllocatorPool.java

示例6: create

import org.apache.zookeeper.AsyncCallback; //導入方法依賴的package包/類
@Override
public void create(String path, byte[] data, List<ACL> acl, CreateMode createMode, AsyncCallback.StringCallback cb, Object ctx) {
    delegate.create(path, data, acl, createMode, cb, ctx);
}
 
開發者ID:NGDATA,項目名稱:hbase-indexer,代碼行數:5,代碼來源:ZooKeeperImpl.java

示例7: asyncCreateNodeOffline

import org.apache.zookeeper.AsyncCallback; //導入方法依賴的package包/類
/**
 * Creates an unassigned node in the OFFLINE state for the specified region.
 * <p>
 * Runs asynchronously.  Depends on no pre-existing znode.
 *
 * <p>Sets a watcher on the unassigned region node.
 *
 * @param zkw zk reference
 * @param region region to be created as offline
 * @param serverName server transition will happen on
 * @param cb
 * @param ctx
 * @throws KeeperException if unexpected zookeeper exception
 * @throws KeeperException.NodeExistsException if node already exists
 */
public static void asyncCreateNodeOffline(ZooKeeperWatcher zkw,
    HRegionInfo region, ServerName serverName,
    final AsyncCallback.StringCallback cb, final Object ctx)
throws KeeperException {
  LOG.debug(zkw.prefix("Async create of unassigned node " +
    region.getEncodedName() + " with OFFLINE state"));
  RegionTransition rt =
    RegionTransition.createRegionTransition(
        EventType.M_ZK_REGION_OFFLINE, region.getRegionName(), serverName);
  String node = getNodeName(zkw, region.getEncodedName());
  ZKUtil.asyncCreate(zkw, node, rt.toByteArray(), cb, ctx);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:28,代碼來源:ZKAssign.java

示例8: asyncCreate

import org.apache.zookeeper.AsyncCallback; //導入方法依賴的package包/類
/**
 * Async creates the specified node with the specified data.
 *
 * <p>Throws an exception if the node already exists.
 *
 * <p>The node created is persistent and open access.
 *
 * @param zkw zk reference
 * @param znode path of node to create
 * @param data data of node to create
 * @param cb
 * @param ctx
 */
public static void asyncCreate(ZooKeeperWatcher zkw,
    String znode, byte [] data, final AsyncCallback.StringCallback cb,
    final Object ctx) {
  zkw.getRecoverableZooKeeper().getZooKeeper().create(znode, data,
      createACL(zkw, znode), CreateMode.PERSISTENT, cb, ctx);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:20,代碼來源:ZKUtil.java

示例9: asyncCreateNodeOffline

import org.apache.zookeeper.AsyncCallback; //導入方法依賴的package包/類
/**
 * Creates an unassigned node in the OFFLINE state for the specified region.
 * <p>
 * Runs asynchronously.  Depends on no pre-existing znode.
 *
 * <p>Sets a watcher on the unassigned region node.
 *
 * @param zkw zk reference
 * @param region region to be created as offline
 * @param serverName server event originates from
 * @param cb
 * @param ctx
 * @throws KeeperException if unexpected zookeeper exception
 * @throws KeeperException.NodeExistsException if node already exists
 */
public static void asyncCreateNodeOffline(ZooKeeperWatcher zkw,
    HRegionInfo region, ServerName serverName,
    final AsyncCallback.StringCallback cb, final Object ctx)
throws KeeperException {
  LOG.debug(zkw.prefix("Async create of unassigned node for " +
    region.getEncodedName() + " with OFFLINE state"));
  RegionTransitionData data = new RegionTransitionData(
      EventType.M_ZK_REGION_OFFLINE, region.getRegionName(), serverName);
  String node = getNodeName(zkw, region.getEncodedName());
  ZKUtil.asyncCreate(zkw, node, data.getBytes(), cb, ctx);
}
 
開發者ID:fengchen8086,項目名稱:LCIndex-HBase-0.94.16,代碼行數:27,代碼來源:ZKAssign.java

示例10: asyncCreate

import org.apache.zookeeper.AsyncCallback; //導入方法依賴的package包/類
/**
 * Async creates the specified node with the specified data.
 *
 * <p>Throws an exception if the node already exists.
 *
 * <p>The node created is persistent and open access.
 *
 * @param zkw zk reference
 * @param znode path of node to create
 * @param data data of node to create
 * @param cb
 * @param ctx
 * @throws KeeperException if unexpected zookeeper exception
 * @throws KeeperException.NodeExistsException if node already exists
 */
public static void asyncCreate(ZooKeeperWatcher zkw,
    String znode, byte [] data, final AsyncCallback.StringCallback cb,
    final Object ctx) {
  zkw.getRecoverableZooKeeper().getZooKeeper().create(znode, data,
      createACL(zkw, znode), CreateMode.PERSISTENT, cb, ctx);
}
 
開發者ID:fengchen8086,項目名稱:LCIndex-HBase-0.94.16,代碼行數:22,代碼來源:ZKUtil.java

示例11: asyncCreate

import org.apache.zookeeper.AsyncCallback; //導入方法依賴的package包/類
/**
 * Async creates the specified node with the specified data.
 *
 * <p>Throws an exception if the node already exists.
 *
 * <p>The node created is persistent and open access.
 *
 * @param zkw zk reference
 * @param znode path of node to create
 * @param data data of node to create
 * @param cb the callback to use for the creation
 * @param ctx the context to use for the creation
 */
public static void asyncCreate(ZKWatcher zkw,
    String znode, byte [] data, final AsyncCallback.StringCallback cb,
    final Object ctx) {
  zkw.getRecoverableZooKeeper().getZooKeeper().create(znode, data,
      createACL(zkw, znode), CreateMode.PERSISTENT, cb, ctx);
}
 
開發者ID:apache,項目名稱:hbase,代碼行數:20,代碼來源:ZKUtil.java

示例12: asyncCreate

import org.apache.zookeeper.AsyncCallback; //導入方法依賴的package包/類
/**
 * Async creates the specified node with the specified data.
 *
 * <p>Throws an exception if the node already exists.
 *
 * <p>The node created is persistent and open access.
 *
 * @param zkw zk reference
 * @param znode path of node to create
 * @param data data of node to create
 * @param cb
 * @param ctx
 * @throws KeeperException if unexpected zookeeper exception
 * @throws KeeperException.NodeExistsException if node already exists
 */
public static void asyncCreate(ZooKeeperWatcher zkw,
    String znode, byte [] data, final AsyncCallback.StringCallback cb,
    final Object ctx) {
  try {
    waitForZKConnectionIfAuthenticating(zkw);
    zkw.getRecoverableZooKeeper().getZooKeeper().create(znode, data,
        createACL(zkw, znode), CreateMode.PERSISTENT, cb, ctx);
  } catch (InterruptedException e) {
    zkw.interruptedException(e);
  }
}
 
開發者ID:lifeng5042,項目名稱:RStore,代碼行數:27,代碼來源:ZKUtil.java

示例13: asyncCreateNodeOffline

import org.apache.zookeeper.AsyncCallback; //導入方法依賴的package包/類
/**
 * Creates an unassigned node in the OFFLINE state for the specified region.
 * <p>
 * Runs asynchronously.  Depends on no pre-existing znode.
 *
 * <p>Sets a watcher on the unassigned region node.
 *
 * @param zkw zk reference
 * @param region region to be created as offline
 * @param serverName server transition will happen on
 * @param cb
 * @param ctx
 * @throws KeeperException if unexpected zookeeper exception
 * @throws KeeperException.NodeExistsException if node already exists
 */
public static void asyncCreateNodeOffline(ZooKeeperWatcher zkw,
    HRegionInfo region, ServerName serverName,
    final AsyncCallback.StringCallback cb, final Object ctx)
throws KeeperException {
  LOG.debug(zkw.prefix("Async create of unassigned node for " +
    region.getEncodedName() + " with OFFLINE state"));
  RegionTransition rt =
    RegionTransition.createRegionTransition(
        EventType.M_ZK_REGION_OFFLINE, region.getRegionName(), serverName);
  String node = getNodeName(zkw, region.getEncodedName());
  ZKUtil.asyncCreate(zkw, node, rt.toByteArray(), cb, ctx);
}
 
開發者ID:daidong,項目名稱:DominoHBase,代碼行數:28,代碼來源:ZKAssign.java

示例14: create

import org.apache.zookeeper.AsyncCallback; //導入方法依賴的package包/類
void create(String path, byte[] data, List<ACL> acl, CreateMode createMode, AsyncCallback.StringCallback cb, Object ctx); 
開發者ID:NGDATA,項目名稱:hbase-indexer,代碼行數:2,代碼來源:ZooKeeperItf.java


注:本文中的org.apache.zookeeper.AsyncCallback.StringCallback方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。