minor improvement

This commit is contained in:
Pearl Dsilva 2026-05-13 13:45:22 -04:00
parent 4584cb8bfa
commit c8c30e3617
2 changed files with 4 additions and 4 deletions

View File

@ -181,8 +181,7 @@ public class ClvmPoolManager implements Configurable {
Long clusterId = pool.getClusterId();
if (clusterId != null) {
hosts = _hostDao.findByClusterId(clusterId, Host.Type.Routing);
}
if ((hosts == null || hosts.isEmpty()) && pool.getDataCenterId() > 0) {
} else if (pool.getDataCenterId() > 0) {
hosts = _hostDao.findByDataCenterId(pool.getDataCenterId());
}
if (hosts == null || hosts.isEmpty()) {

View File

@ -46,6 +46,7 @@ import java.util.Collections;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@ -249,13 +250,13 @@ public class ClvmPoolManagerTest {
when(pool.getPath()).thenReturn(VG_NAME);
when(volsDetailsDao.findDetail(VOLUME_ID, ClvmPoolManager.CLVM_LOCK_HOST_ID)).thenReturn(null);
when(hostDao.findByClusterId(10L, Host.Type.Routing)).thenReturn(Collections.emptyList());
when(hostDao.findByDataCenterId(1L)).thenReturn(Collections.emptyList());
lenient().when(hostDao.findByDataCenterId(1L)).thenReturn(Collections.emptyList());
Long result = clvmPoolManager.queryCurrentLockHolder(VOLUME_ID, VOLUME_UUID, VOLUME_PATH, pool, false);
Assert.assertNull(result);
verify(hostDao, times(1)).findByClusterId(10L, Host.Type.Routing);
verify(hostDao, times(1)).findByDataCenterId(1L);
verify(hostDao, times(0)).findByDataCenterId(1L);
}
@Test