@Override
 public boolean connectHostToDomainsInActiveOrUnknownStatus(VDS vds) {
   StoragePool sp = storagePoolDao.get(vds.getStoragePoolId());
   ConnectHostToStoragePoolServersParameters params =
       new ConnectHostToStoragePoolServersParameters(sp, vds, false);
   return backend
       .runInternalAction(VdcActionType.ConnectHostToStoragePoolServers, params)
       .getSucceeded();
 }
 /**
  * The following method will clear a cache for problematic domains, which were reported by vds
  *
  * @param vds
  */
 private void clearDomainCache(final VDS vds) {
   eventQueue.submitEventSync(
       new Event(vds.getStoragePoolId(), null, vds.getId(), EventType.VDSCLEARCACHE, ""),
       new Callable<EventResult>() {
         @Override
         public EventResult call() {
           IrsBrokerCommand.clearVdsFromCache(vds.getStoragePoolId(), vds.getId(), vds.getName());
           return new EventResult(true, EventType.VDSCLEARCACHE);
         }
       });
 }
  private void processStorageOnVdsInactive(final VDS vds) {

    // Clear the problematic timers since the VDS is in maintenance so it doesn't make sense to
    // check it
    // anymore.
    if (!Guid.Empty.equals(vds.getStoragePoolId())) {
      // when vds is being moved to maintenance, this is the part in which we disconnect it from the
      // pool
      // and the storage server. it should be synced with the host autorecovery mechanism to try to
      // avoid
      // leaving the host with storage/pool connection when it's on maintenance.
      EngineLock lock =
          new EngineLock(
              Collections.singletonMap(
                  vds.getId().toString(),
                  new Pair<>(
                      LockingGroup.VDS_POOL_AND_STORAGE_CONNECTIONS.toString(),
                      EngineMessage.ACTION_TYPE_FAILED_OBJECT_LOCKED.toString())),
              null);
      try {
        LockManagerFactory.getLockManager().acquireLockWait(lock);
        clearDomainCache(vds);
        stopGlusterServices(vds);
        StoragePool storage_pool = storagePoolDao.get(vds.getStoragePoolId());
        if (StoragePoolStatus.Uninitialized != storage_pool.getStatus()) {
          vdsBroker.runVdsCommand(
              VDSCommandType.DisconnectStoragePool,
              new DisconnectStoragePoolVDSCommandParameters(
                  vds.getId(), vds.getStoragePoolId(), vds.getVdsSpmId()));
          HostStoragePoolParametersBase params =
              new HostStoragePoolParametersBase(storage_pool, vds);
          backend.runInternalAction(VdcActionType.DisconnectHostFromStoragePoolServers, params);
        }
      } finally {
        LockManagerFactory.getLockManager().releaseLock(lock);
      }
    }
  }