Claims a work unit pegged to this node, waiting for the ZNode to become available
(i.e., deleted by the node which previously owned it).
177686
protected void claimWorkPeggedToMe(String workUnit)
       throws InterruptedException {
       String path = cluster.workUnitClaimPath(workUnit);

       while (true) {
           if (ZKUtils.createEphemeral(cluster.zk, path, cluster.myNodeID) || cluster.znodeIsMe(path)) {
               cluster.startWork(workUnit);
               return;
           }
           LOG.warn("Attempting to establish ownership of {}. Retrying in one second...", workUnit);
           Thread.sleep(1000);
       }
   }
383760
private void removeExisted(NodeData sameUuidItem) throws RepositoryException, ConstraintViolationException,
      PathNotFoundException
   {

      if (!nodeTypeDataManager.isNodeType(Constants.MIX_REFERENCEABLE, sameUuidItem.getPrimaryTypeName(), sameUuidItem
         .getMixinTypeNames()))
      {
         throw new RepositoryException("An incoming referenceable node has the same "
            + " UUID as a identifier of non mix:referenceable" + " node already existing in the workspace!");
      }

      // If an incoming referenceable node has the same UUID as a node
      // already existing in the workspace then the already existing
      // node (and its subtree) is removed from wherever it may be in
      // the workspace before the incoming node is added. Note that this
      // can result in nodes disappearing from locations in the
      // workspace that are remote from the location to which the
      // incoming subtree is being written.
      // parentNodeData = (NodeData) sameUuidItem.getParent().getData();

      QPath sameUuidPath = sameUuidItem.getQPath();

      if (ancestorToSave.isDescendantOf(sameUuidPath) || ancestorToSave.equals(sameUuidPath))
      {
         throw new ConstraintViolationException("The imported document contains a element"
            + " with jcr:uuid attribute the same as the  parent of the import target.");
      }

      setAncestorToSave(QPath.getCommonAncestorPath(ancestorToSave, sameUuidPath));

      ItemDataRemoveVisitor visitor =
         new ItemDataRemoveVisitor(dataConsumer, getAncestorToSave(), nodeTypeDataManager, accessManager, userState);
      sameUuidItem.accept(visitor);

      changesLog.addAll(visitor.getRemovedStates());
      
      // Refresh the indexes if needed
      boolean reloadSNS =
         uuidBehavior == ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING
            || uuidBehavior == ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING;
      if (reloadSNS)
      {
         NodeData parentData = (NodeData)dataConsumer.getItemData(sameUuidItem.getParentIdentifier());
         ItemState lastState = getLastItemState(sameUuidItem.getParentIdentifier());

         if (sameUuidItem != null && (lastState == null || !lastState.isDeleted()))
         {
            InternalQName name =
               new InternalQName(sameUuidItem.getQPath().getName().getNamespace(), sameUuidItem.getQPath().getName()
                  .getName());
            List<ItemState> transientAddChilds = getItemStatesList(parentData, name, ItemState.ADDED, null);
            if (transientAddChilds.isEmpty())
               return;
            List<ItemState> statesToReLoad = new LinkedList<ItemState>();
            for (int i = 0, length = transientAddChilds.size(); i < length; i++)
            {
               ItemState state = transientAddChilds.get(i);
               if (sameUuidItem.getQPath().getIndex() < state.getData().getQPath().getIndex() && state.getData() instanceof ImportNodeData)
               {
                  statesToReLoad.add(state);
               }
            }
            if (statesToReLoad.isEmpty())
               return;
            for (ItemState state : statesToReLoad)
            {
               ImportNodeData node = (ImportNodeData)state.getData();
               reloadChangesInfoAfterUC(parentData, node, node.getIdentifier());
            }
         }
      }
   }
680541
Observable<LifecycleState> removeNode(final Node node) {
        LOGGER.debug("Got instructed to remove Node {}", node.hostname());
        nodes.remove(node);
        return node.disconnect();
    }
1204867
def _wait_nodes_updated(self, cluster_member, new_nodes):
        '''
        '''
        while True:
            known_nodes = [n['name'] for n in cluster_member.nodes()]
            added_nodes = [n.name for n in new_nodes]
            if len(set(known_nodes) & set(added_nodes)) == len(added_nodes):
                break;
            logger.info('waiting for adding new nodes in `cluster nodes`')
            time.sleep(1)
738579
void ensureRequiredZnodesExist(ZooKeeper zookeeper, String znode) throws KeeperException, InterruptedException {
        mkdirp(zookeeper, znode);
        createIfNotThere(zookeeper, QUEUE_NODE);
        createIfNotThere(zookeeper, POOL_NODE);
    }
466286
def handle_available(node, snapshots)
      reconcile(node)

      # no-op if we already know about this node
      return if @master == node || (@master && @slaves.include?(node))
      logger.info("Handling available node: #{node}")

      if @master
        # master already exists, make a slave
        node.make_slave!(@master)
        @slaves << node
      else
        # no master exists, make this the new master
        promote_new_master(snapshots, node)
      end

      @unavailable.delete(node)
    end
448443
private void executeClaimedTask(ClaimedTask claimedTask) {
        // Check whether this claim was already abandoned due to late execution.
        if (!claimedTask.setStartTime(new Date())) {
            _log.info("Claimed task is overdue; range not scanned: {}", claimedTask.getTask());
            return;
        }

        ScanRangeTask task = claimedTask.getTask();
        boolean releaseTask = false;
        try {
            // Immediately renew the claim; future renewals will be handled asynchronously by the background renewal task.
            _scanWorkflow.renewScanRangeTasks(ImmutableList.of(task), QUEUE_RENEW_TTL);

            releaseTask = asyncRangeScan(task);
        } finally {
            unclaimTask(claimedTask, releaseTask);

            // Immediately try to claim a new scan when this one finishes
            _backgroundService.submit(_startScansIfAvailableRunnable);
        }
    }
202944
@GuardedBy("workerInfo")
  private void processWorkerRemovedBlocks(MasterWorkerInfo workerInfo,
      Collection<Long> removedBlockIds) {
    for (long removedBlockId : removedBlockIds) {
      try (LockResource lr = lockBlock(removedBlockId)) {
        Optional<BlockMeta> block = mBlockStore.getBlock(removedBlockId);
        if (block.isPresent()) {
          LOG.info("Block {} is removed on worker {}.", removedBlockId, workerInfo.getId());
          mBlockStore.removeLocation(removedBlockId, workerInfo.getId());
          if (mBlockStore.getLocations(removedBlockId).size() == 0) {
            mLostBlocks.add(removedBlockId);
          }
        }
        // Remove the block even if its metadata has been deleted already.
        workerInfo.removeBlock(removedBlockId);
      }
    }
  }
1258363
public synchronized void waitForAllNodesRegistered(int timeoutMs)
      throws TimeoutException, InterruptedException {
    MetaMasterClient metaMasterClient = getMetaMasterClient();
    CommonUtils.waitFor("all nodes registered", () -> {
      try {
        MasterInfo masterInfo = metaMasterClient.getMasterInfo(Collections.emptySet());
        int liveNodeNum = masterInfo.getMasterAddressesList().size()
            + masterInfo.getWorkerAddressesList().size();
        if (liveNodeNum == (mNumMasters + mNumWorkers)) {
          return true;
        } else {
          LOG.info("Master addresses: {}. Worker addresses: {}",
              masterInfo.getMasterAddressesList(), masterInfo.getWorkerAddressesList());
          return false;
        }
      } catch (UnavailableException e) {
        return false;
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }, WaitForOptions.defaults().setInterval(200).setTimeoutMs(timeoutMs));
  }
36402
private CompletionStage<Void> prepareOnOtherNode(Node node) {
    LOG.trace("[{}] Repreparing on {}", logPrefix, node);
    DriverChannel channel = session.getChannel(node, logPrefix);
    if (channel == null) {
      LOG.trace("[{}] Could not get a channel to reprepare on {}, skipping", logPrefix, node);
      return CompletableFuture.completedFuture(null);
    } else {
      ThrottledAdminRequestHandler handler =
          new ThrottledAdminRequestHandler(
              channel,
              message,
              request.getCustomPayload(),
              timeout,
              throttler,
              session.getMetricUpdater(),
              logPrefix,
              message.toString());
      return handler
          .start()
          .handle(
              (result, error) -> {
                if (error == null) {
                  LOG.trace("[{}] Successfully reprepared on {}", logPrefix, node);
                } else {
                  Loggers.warnWithException(
                      LOG, "[{}] Error while repreparing on {}", node, logPrefix, error);
                }
                return null;
              });
    }
  }
59030
public static ResourceClaim claim(ZooKeeperConnection zooKeeperConnection, int poolSize, String znode) throws IOException {
        return new ResourceClaim(zooKeeperConnection, poolSize, znode);
    }
449957
public void waitForRestart() {
    if (standbyThread != null) {
      try {
        // if this is the standby avatarnode, then wait for the Standby to exit
        standbyThread.join();
      } catch (InterruptedException ie) {
        //eat it up
      }
      standbyThread = null;
      LOG.info("waitForRestart: Standby thread exited.");

      InjectionHandler.processEvent(InjectionEvent.AVATARNODE_WAIT_FOR_RESTART);
      while (failoverState == FailoverState.START_FAILOVER
          || failoverState == FailoverState.AWAIT_FAILOVER) {
        LOG.info("Current state : " + failoverState
            + ". Waiting for failover ....");
        try {
          Thread.sleep(1000);
        } catch (InterruptedException ie) {
          throw new RuntimeException("waitForRestart() interrupted");
        }
      }

      // if we are still in standbymode, that means we need to restart from
      // scratch.
      if (getAvatar() == Avatar.STANDBY) {
        runInfo.isRunning = false;
        LOG.info("waitForRestart Stopping encapsulated namenode.");
        super.stop(); // terminate encapsulated namenode
        super.join(); // wait for encapsulated namenode to exit
        shutdownStandby();
        LOG.info("waitForRestart exiting");
        return;
      }
    }
    super.join();            // wait for encapsulated namenode
  }
100256
function(cb0) {
            try {
                if (nodeId) {
                    $._.$[ns].renewNodeLease(privateNodeId, leaseTimeout, cb0);
                } else {
                    cb0(null);
                }
            } catch (err) {
                cb0(err);
            }
        }
420549
public void claimWork() throws InterruptedException {
        if (state.get() == NodeState.Started && !waitInProgress.get() && connected.get()) {
            balancingPolicy.claimWork();
        }
    }
837858
def wait_until_gone(self, timeout=0, *args, **selectors):
        
        return self.device(**selectors).wait.gone(timeout=timeout)
1166313
public synchronized boolean seekToNewSource(long targetPos,
      boolean throwWhenNotFound) throws IOException {
    boolean markedDead = deadNodes.containsKey(currentNode);
    addToDeadNodes(currentNode);
    DatanodeInfo oldNode = currentNode;
    DatanodeInfo newNode = blockSeekTo(targetPos, throwWhenNotFound);
    if (!markedDead) {
      /* remove it from deadNodes. blockSeekTo could have cleared
       * deadNodes and added currentNode again. Thats ok. */
      deadNodes.remove(oldNode);
    }
    if (!oldNode.getStorageID().equals(newNode.getStorageID())) {
      currentNode = newNode;
      return true;
    } else {
      return false;
    }
  }
1241282
private void doNodeJoined(final Node node) {
    tasks.runTask(new Handler<Task>() {
      @Override
      public void handle(final Task task) {
        if (currentContext != null) {
          log.info(String.format("%s - %s joined the cluster. Uploading components to new node", NetworkManager.this, node.address()));
          installModules(node, currentContext, new Handler<AsyncResult<Void>>() {
            @Override
            public void handle(AsyncResult<Void> result) {
              if (result.failed()) {
                log.error(result.cause());
              } else {
                log.info(String.format("%s - Successfully uploaded components to %s", NetworkManager.this, node.address()));
              }
              task.complete();
            }
          });
        } else {
          task.complete();
        }
      }
    });
  }