called under cluster service lock
975682
private void retainSuspectedMembers(MemberMap memberMap) {
        Iterator<Address> it = suspectedMembers.iterator();
        while (it.hasNext()) {
            Address suspectedAddress = it.next();
            if (!memberMap.contains(suspectedAddress)) {
                if (logger.isFineEnabled()) {
                    logger.fine("Removing suspected address " + suspectedAddress + ", it's no longer a member.");
                }

                it.remove();
            }
        }
    }
1016911
public CmsLock getLock(CmsRequestContext context, CmsResource resource) throws CmsException {

        CmsDbContext dbc = m_dbContextFactory.getDbContext(context);
        CmsLock result = null;
        try {
            result = m_driverManager.getLock(dbc, resource);
        } catch (Exception e) {
            dbc.report(null, Messages.get().container(Messages.ERR_GET_LOCK_1, context.getSitePath(resource)), e);
        } finally {
            dbc.clear();
        }
        return result;
    }
775385
private void handleLockHeld(String taskId, ShardedJobStateImpl<T> jobState,
      IncrementalTaskState<T> taskState) {
    long currentTime = System.currentTimeMillis();
    int sliceTimeoutMillis = jobState.getSettings().getSliceTimeoutMillis();
    long lockExpiration = taskState.getLockInfo().lockedSince() + sliceTimeoutMillis;
    boolean wasRequestCompleted = wasRequestCompleted(taskState.getLockInfo().getRequestId());

    if (lockExpiration > currentTime && !wasRequestCompleted) {
      // if lock was not expired AND not abandon reschedule in 1 minute.
      long eta = Math.min(lockExpiration, currentTime + 60_000);
      scheduleWorkerTask(null, jobState.getSettings(), taskState, eta);
      log.info("Lock for " + taskId + " is being held. Will retry after " + (eta - currentTime));
    } else {
      ShardRetryState<T> retryState;
      if (wasRequestCompleted) {
        retryState = handleSliceFailure(jobState, taskState, new RuntimeException(
            "Resuming after abandon lock for " + taskId + " on slice: "
                + taskState.getSequenceNumber()), true);
      } else {
        retryState = handleShardFailure(jobState, taskState, new RuntimeException(
          "Lock for " + taskId + " expired on slice: " + taskState.getSequenceNumber()));
      }
      updateTask(jobState, taskState, retryState, false);
    }
  }
1245306
private void blockIfNecessary() {
        if (diskPermits == null || diskLimit == Long.MAX_VALUE)
            return;
        try {
            diskPermits.acquire();
        } catch (InterruptedException e) {
            // don't want to re-interrupt so it won't cause SDK stream to be
            // closed in case the thread is reused for a different request
            throw new AbortedException(e);
        }
    }
937589
private int restartTaskTracker(boolean forceFlag, int batchSize) throws IOException {
    // Get the current configuration
    CoronaConf conf = new CoronaConf(getConf());

    InetSocketAddress address = NetUtils.createSocketAddr(conf
        .getClusterManagerAddress());
    TFramedTransport transport = new TFramedTransport(
      new TSocket(address.getHostName(), address.getPort()));
    ClusterManagerService.Client client = new ClusterManagerService.Client(
        new TBinaryProtocol(transport));
    int restartBatch = (batchSize > 0) ? batchSize :
      conf.getCoronaNodeRestartBatch();

    try {
      transport.open();
      RestartNodesArgs restartNodeArgs = new RestartNodesArgs(
        forceFlag, restartBatch);
      client.restartNodes(restartNodeArgs);
    } catch (SafeModeException e) {
      System.err.println("ClusterManager is in Safe Mode");
    } catch (TException e) {
      throw new IOException(e);
    }

    return 0;
  }
1185787
@Override
  public void run() {
    long lastUpdate = -1L;
    // Start balancing the clusters
    while (running) {
      try {
        Thread.sleep(updateInterval / 10);
        long now = JobTracker.getClock().getTime();
        if (now - lastUpdate > updateInterval) {
          lastUpdate = now;
          doMoveSlots(clusters);
        }
      } catch (Exception e) {
        LOG.error("Exception while balancing cluster.", e);
      }
    }
  }
868251
protected void waitForServiceToBeUnbound() throws InterruptedException {
        Ln.d("Waiting for service to be unbound.");

        lockAcquireService.lock();
        try {
            while (spiceService != null) {
                conditionServiceUnbound.await();
            }
        } finally {
            lockAcquireService.unlock();
        }
    }
547877
def do_restart_service(self, service):
        
        if not self.has_cluster():
            return None

        if self.service_action(service=service, action="restart"):
            print("%s is being restarted" % (service))
        else:
            print("Error restarting service")
            return None
51522
public synchronized void unlock()
  {
    if (tc.isEntryEnabled())
      SibTr.entry(tc, "unlock", this);

    // If the subscription locks are down to zero then notify the threads waiting
    // for the subscriptionTable lock.
    synchronized (iMutex)
    {
      if (readLockCount == 0)
      {
        if (tc.isEntryEnabled()) 
          SibTr.exit(tc, "unlock", "SIErrorException");
        
        SibTr.error(tc, "INTERNAL_MESSAGING_ERROR_CWSIP0001",
          new Object[] {
            "com.ibm.ws.sib.processor.utils.AdvancedLockManager",
            "1:237:1.3" });
          
        throw new SIErrorException(
          nls.getFormattedMessage(
            "INTERNAL_MESSAGING_ERROR_CWSIP0001",
            new Object[] {
              "com.ibm.ws.sib.processor.utils.AdvancedLockManager",
              "1:244:1.3" },
            null));
      }
      
      decrementThreadLockCount();
      // Decrement the lock count and notify the other threads if no 
      // one holds the lock any more.
      if (readLockCount == 0)
        notifyAll();        
    }

    if (tc.isEntryEnabled())
      SibTr.exit(tc, "unlock");
  }
600587
private ILockableEntityGroup ifindLockableGroup(String key, String lockOwner)
            throws GroupsException {
        return compositeGroupService.findGroupWithLock(key, lockOwner);
    }
724317
def handle_cluster_request(self, tsn, command_id, args):
        """"""
        if command_id == 0:
            if self._timer_handle:
                self._timer_handle.cancel()
            loop = asyncio.get_event_loop()
            self._timer_handle = loop.call_later(30, self._turn_off)
733653
static void lockCloud() {
    if( _cloudLocked ) return; // Fast-path cutout
    synchronized(Paxos.class) {
      while( !_commonKnowledge )
        try { Paxos.class.wait(); } catch( InterruptedException ie ) { }
      _cloudLocked = true;
    }
  }
292320
def cluster_meet(self, ip, port):
        """"""
        fut = self.execute(b'CLUSTER', b'MEET', ip, port)
        return wait_ok(fut)
1019889
public void lock()
    {
        log.info("Elasticsearch has started and the maven process has been blocked. Press CTRL+C to stop the process.");

        synchronized (lock)
        {
            try
            {
                lock.wait();
            }
            catch (InterruptedException exception)
            {
                log.warn("RunElasticsearchNodeMojo interrupted");
            }
        }
    }
899877
@Override
  public void notifyForeignWatch(byte[] key, String serverId)
  {
    ClusterServiceKraken proxy = _podKraken.getProxy(serverId);
    
    if (proxy != null) {
      proxy.notifyLocalWatch(_table.getKey(), key);
    }
  }
1219533
def update_cluster(cluster_ref, cluster_spec):
    '''
    
    '''
    cluster_name = get_managed_object_name(cluster_ref)
    log.trace('Updating cluster \'%s\'', cluster_name)
    try:
        task = cluster_ref.ReconfigureComputeResource_Task(cluster_spec,
                                                           modify=True)
    except vim.fault.NoPermission as exc:
        log.exception(exc)
        raise salt.exceptions.VMwareApiError(
            'Not enough permissions. Required privilege: '
            '{}'.format(exc.privilegeId))
    except vim.fault.VimFault as exc:
        log.exception(exc)
        raise salt.exceptions.VMwareApiError(exc.msg)
    except vmodl.RuntimeFault as exc:
        log.exception(exc)
        raise salt.exceptions.VMwareRuntimeError(exc.msg)
    wait_for_task(task, cluster_name, 'ClusterUpdateTask')
1073811
def wait_for_any_cluster(contexts):
    
    try:
        earliest_retry_at = min(ctx.retry_at for ctx in contexts.values()
                                if not ctx.failed)
    except ValueError:  # can't take min() of empty sequence
        raise AllClustersFailedException(
            "Could not find appropriate cluster for worker build."
        )

    time_until_next = earliest_retry_at - dt.datetime.now()
    time.sleep(max(timedelta(seconds=0), time_until_next).seconds)