Search in sources :

Example 16 with GlusterAsyncTask

use of org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask in project ovirt-engine by oVirt.

the class GlusterBrickDaoTest method testReplaceBrick.

@Test
public void testReplaceBrick() {
    GlusterBrickEntity firstBrick = dao.getById(FixturesTool.GLUSTER_BRICK_UUID1);
    assertNotNull(firstBrick);
    GlusterBrickEntity newBrick = new GlusterBrickEntity();
    newBrick.setVolumeId(FixturesTool.GLUSTER_VOLUME_UUID1);
    newBrick.setServerId(FixturesTool.GLUSTER_SERVER_UUID3);
    newBrick.setServerName(FixturesTool.GLUSTER_SERVER_NAME3);
    newBrick.setBrickDirectory(BRICK_EXPORT_DIR);
    GlusterAsyncTask asyncTask = new GlusterAsyncTask();
    asyncTask.setTaskId(FixturesTool.GLUSTER_ASYNC_TASK_ID1);
    newBrick.setAsyncTask(asyncTask);
    newBrick.setStatus(GlusterStatus.UP);
    newBrick.setBrickOrder(0);
    assertNull(dao.getById(newBrick.getId()));
    dao.replaceBrick(firstBrick, newBrick);
    assertNull(dao.getById(FixturesTool.GLUSTER_BRICK_UUID1));
    GlusterBrickEntity retrievedBrick = dao.getById(newBrick.getId());
    assertNotNull(retrievedBrick);
    assertEquals(newBrick, retrievedBrick);
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterAsyncTask(org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask) Test(org.junit.Test)

Example 17 with GlusterAsyncTask

use of org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask in project ovirt-engine by oVirt.

the class GlusterBrickDaoTest method testUpdateAllBrickTasksByHostIdBrickDir.

@Test
public void testUpdateAllBrickTasksByHostIdBrickDir() {
    GlusterBrickEntity existingBrick = dao.getById(FixturesTool.GLUSTER_BRICK_UUID1);
    GlusterBrickEntity existingBrick2 = dao.getById(FixturesTool.GLUSTER_BRICK_UUID2);
    GlusterAsyncTask asyncTask = new GlusterAsyncTask();
    asyncTask.setTaskId(FixturesTool.GLUSTER_ASYNC_TASK_ID1);
    GlusterBrickEntity updateBrick = new GlusterBrickEntity();
    updateBrick.setBrickDirectory(existingBrick.getBrickDirectory());
    updateBrick.setServerId(existingBrick.getServerId());
    updateBrick.setAsyncTask(asyncTask);
    GlusterBrickEntity updateBrick2 = new GlusterBrickEntity();
    updateBrick2.setBrickDirectory(existingBrick2.getBrickDirectory());
    updateBrick2.setServerId(existingBrick2.getServerId());
    updateBrick2.setAsyncTask(asyncTask);
    List<GlusterBrickEntity> bricks = new ArrayList<>();
    bricks.add(updateBrick);
    bricks.add(updateBrick2);
    dao.updateAllBrickTasksByHostIdBrickDirInBatch(bricks);
    GlusterBrickEntity newEntity1 = dao.getById(FixturesTool.GLUSTER_BRICK_UUID1);
    GlusterBrickEntity newEntity2 = dao.getById(FixturesTool.GLUSTER_BRICK_UUID1);
    assertEquals(FixturesTool.GLUSTER_ASYNC_TASK_ID1, newEntity1.getAsyncTask().getTaskId());
    assertEquals(FixturesTool.GLUSTER_ASYNC_TASK_ID1, newEntity2.getAsyncTask().getTaskId());
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterAsyncTask(org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 18 with GlusterAsyncTask

use of org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask in project ovirt-engine by oVirt.

the class GlusterBrickDaoTest method testUpdateBrickTasksInBatch.

@Test
public void testUpdateBrickTasksInBatch() {
    GlusterBrickEntity existingBrick1 = dao.getById(FixturesTool.GLUSTER_BRICK_UUID1);
    GlusterBrickEntity existingBrick2 = dao.getById(FixturesTool.GLUSTER_BRICK_UUID2);
    GlusterAsyncTask asyncTask = new GlusterAsyncTask();
    asyncTask.setTaskId(FixturesTool.GLUSTER_ASYNC_TASK_ID1);
    assertNotNull(existingBrick1);
    assertNotNull(existingBrick2);
    assertEquals(GlusterStatus.UP, existingBrick1.getStatus());
    assertEquals(GlusterStatus.UP, existingBrick2.getStatus());
    existingBrick1.setAsyncTask(asyncTask);
    existingBrick2.setAsyncTask(asyncTask);
    List<GlusterBrickEntity> bricks = new ArrayList<>();
    bricks.add(existingBrick1);
    bricks.add(existingBrick2);
    dao.updateBrickTasksInBatch(bricks);
    GlusterBrickEntity newEnity1 = dao.getById(FixturesTool.GLUSTER_BRICK_UUID1);
    GlusterBrickEntity newEnity2 = dao.getById(FixturesTool.GLUSTER_BRICK_UUID2);
    assertEquals(FixturesTool.GLUSTER_ASYNC_TASK_ID1, newEnity1.getAsyncTask().getTaskId());
    assertEquals(FixturesTool.GLUSTER_ASYNC_TASK_ID1, newEnity2.getAsyncTask().getTaskId());
}
Also used : GlusterBrickEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity) GlusterAsyncTask(org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 19 with GlusterAsyncTask

use of org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask in project ovirt-engine by oVirt.

the class GlusterTestHelper method getVolumeEntity.

protected GlusterVolumeEntity getVolumeEntity(int index) {
    List<GlusterVolumeEntity> volumesList = new ArrayList<>();
    GlusterVolumeEntity entity1 = mock(GlusterVolumeEntity.class);
    when(entity1.getId()).thenReturn(volumeId);
    when(entity1.getName()).thenReturn(volumeName);
    when(entity1.getClusterId()).thenReturn(clusterId);
    volumesList.add(entity1);
    GlusterAsyncTask task = new GlusterAsyncTask();
    task.setType(GlusterTaskType.REMOVE_BRICK);
    task.setStatus(JobExecutionStatus.FINISHED);
    task.setTaskId(GUIDS[2]);
    GlusterVolumeEntity entity2 = mock(GlusterVolumeEntity.class);
    when(entity2.getId()).thenReturn(volumeId);
    when(entity2.getName()).thenReturn(volumeName);
    when(entity2.getClusterId()).thenReturn(clusterId);
    when(entity2.getAsyncTask()).thenReturn(task);
    volumesList.add(entity2);
    return volumesList.get(index);
}
Also used : GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity) GlusterAsyncTask(org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask) ArrayList(java.util.ArrayList)

Example 20 with GlusterAsyncTask

use of org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask in project ovirt-engine by oVirt.

the class GetGlusterVolumeRemoveBricksStatusQuery method fetchTaskStatusDetails.

@Override
protected GlusterVolumeTaskStatusEntity fetchTaskStatusDetails() {
    VDSReturnValue returnValue = runVdsCommand(VDSCommandType.GetGlusterVolumeRemoveBricksStatus, new GlusterVolumeRemoveBricksVDSParameters(getUpServerId(clusterId), volume.getName(), getParameters().getBricks(), volume.getReplicaCount()));
    GlusterVolumeTaskStatusEntity entity = (GlusterVolumeTaskStatusEntity) returnValue.getReturnValue();
    // Update the latest status details
    GlusterAsyncTask asyncTask = volume.getAsyncTask();
    if (asyncTask != null) {
        // take a copy of the task status with engine for further use
        JobExecutionStatus jobStatusWithEngine = volume.getAsyncTask().getStatus();
        // update the status entity with required details
        updateStatusEntity(entity);
        // be set to aborted. This is required only in case of remove bricks
        if (jobStatusWithEngine == JobExecutionStatus.ABORTED) {
            entity.getStatusSummary().setStatus(JobExecutionStatus.ABORTED);
        }
    }
    return entity;
}
Also used : JobExecutionStatus(org.ovirt.engine.core.common.job.JobExecutionStatus) GlusterAsyncTask(org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask) GlusterVolumeRemoveBricksVDSParameters(org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeRemoveBricksVDSParameters) GlusterVolumeTaskStatusEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeTaskStatusEntity) VDSReturnValue(org.ovirt.engine.core.common.vdscommands.VDSReturnValue)

Aggregations

GlusterAsyncTask (org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask)30 GlusterBrickEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity)11 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)10 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)5 GlusterTaskParameters (org.ovirt.engine.core.common.asynctasks.gluster.GlusterTaskParameters)4 Step (org.ovirt.engine.core.common.job.Step)4 VDSReturnValue (org.ovirt.engine.core.common.vdscommands.VDSReturnValue)4 Guid (org.ovirt.engine.core.compat.Guid)4 EngineException (org.ovirt.engine.core.common.errors.EngineException)3 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)3 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 List (java.util.List)2 JobExecutionStatus (org.ovirt.engine.core.common.job.JobExecutionStatus)2 GlusterVolumeRemoveBricksVDSParameters (org.ovirt.engine.core.common.vdscommands.gluster.GlusterVolumeRemoveBricksVDSParameters)2 Collection (java.util.Collection)1 Date (java.util.Date)1 Map (java.util.Map)1