@Test public void testUpdateResources() throws Exception { StageResourceProvider provider = new StageResourceProvider(managementController); Request request = createNiceMock(Request.class); Predicate predicate = createNiceMock(Predicate.class); expect(clusters.getClusterById(anyLong())).andReturn(cluster).anyTimes(); expect(request.getProperties()).andReturn(Collections.<Map<String,Object>>emptySet()); replay(clusters, cluster, request, predicate); provider.updateResources(request, predicate); verify(clusters, cluster); }
@Override public RequestStatus updateResources(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException { Iterator<Map<String,Object>> iterator = request.getProperties().iterator(); if (iterator.hasNext()) { Map<String,Object> updateProperties = iterator.next(); List<StageEntity> entities = dao.findAll(request, predicate); for (StageEntity entity : entities) { String stageStatus = (String) updateProperties.get(STAGE_STATUS); if (stageStatus != null) { HostRoleStatus desiredStatus = HostRoleStatus.valueOf(stageStatus); dao.updateStageStatus(entity, desiredStatus, getManagementController().getActionManager()); } } } notifyUpdate(Resource.Type.Stage, request, predicate); return getRequestStatus(null); }
StageResourceProvider extends AbstractControllerResourceProvider implements ExtendedResourceProvider { @Override public RequestStatus updateResources(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException { Iterator<Map<String,Object>> iterator = request.getProperties().iterator(); if (iterator.hasNext()) { Map<String,Object> updateProperties = iterator.next(); List<StageEntity> entities = dao.findAll(request, predicate); for (StageEntity entity : entities) { String stageStatus = (String) updateProperties.get(STAGE_STATUS); if (stageStatus != null) { HostRoleStatus desiredStatus = HostRoleStatus.valueOf(stageStatus); dao.updateStageStatus(entity, desiredStatus, getManagementController().getActionManager()); } } } notifyUpdate(Resource.Type.Stage, request, predicate); return getRequestStatus(null); } }
StageResourceProvider extends AbstractControllerResourceProvider implements ExtendedResourceProvider { @Override public RequestStatus updateResources(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException { Iterator<Map<String,Object>> iterator = request.getProperties().iterator(); if (iterator.hasNext()) { Map<String,Object> updateProperties = iterator.next(); List<StageEntity> entities = dao.findAll(request, predicate); for (StageEntity entity : entities) { String stageStatus = (String) updateProperties.get(STAGE_STATUS); if (stageStatus != null) { HostRoleStatus desiredStatus = HostRoleStatus.valueOf(stageStatus); dao.updateStageStatus(entity, desiredStatus, getManagementController().getActionManager()); } } } notifyUpdate(Resource.Type.Stage, request, predicate); return getRequestStatus(null); } StageResourceProvider(AmbariManagementController managementController); }
StageResourceProvider extends AbstractControllerResourceProvider implements ExtendedResourceProvider { @Override public RequestStatus updateResources(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException { Iterator<Map<String,Object>> iterator = request.getProperties().iterator(); if (iterator.hasNext()) { Map<String,Object> updateProperties = iterator.next(); List<StageEntity> entities = dao.findAll(request, predicate); for (StageEntity entity : entities) { String stageStatus = (String) updateProperties.get(STAGE_STATUS); if (stageStatus != null) { HostRoleStatus desiredStatus = HostRoleStatus.valueOf(stageStatus); dao.updateStageStatus(entity, desiredStatus, getManagementController().getActionManager()); } } } notifyUpdate(Resource.Type.Stage, request, predicate); return getRequestStatus(null); } StageResourceProvider(AmbariManagementController managementController); @Override RequestStatus createResources(Request request); @Override RequestStatus updateResources(Request request, Predicate predicate); @Override RequestStatus deleteResources(Request request, Predicate predicate); @Override Set<Resource> getResources(Request request, Predicate predicate); @Override QueryResponse queryForResources(Request request, Predicate predicate); }
StageResourceProvider extends AbstractControllerResourceProvider implements ExtendedResourceProvider { @Override public RequestStatus updateResources(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException { Iterator<Map<String,Object>> iterator = request.getProperties().iterator(); if (iterator.hasNext()) { Map<String,Object> updateProperties = iterator.next(); List<StageEntity> entities = dao.findAll(request, predicate); for (StageEntity entity : entities) { String stageStatus = (String) updateProperties.get(STAGE_STATUS); if (stageStatus != null) { HostRoleStatus desiredStatus = HostRoleStatus.valueOf(stageStatus); dao.updateStageStatus(entity, desiredStatus, getManagementController().getActionManager()); } } } notifyUpdate(Resource.Type.Stage, request, predicate); return getRequestStatus(null); } StageResourceProvider(AmbariManagementController managementController); @Override RequestStatus createResources(Request request); @Override RequestStatus updateResources(Request request, Predicate predicate); @Override RequestStatus deleteResources(Request request, Predicate predicate); @Override Set<Resource> getResources(Request request, Predicate predicate); @Override QueryResponse queryForResources(Request request, Predicate predicate); static final String STAGE_STAGE_ID; static final String STAGE_CLUSTER_NAME; static final String STAGE_REQUEST_ID; static final String STAGE_LOG_INFO; static final String STAGE_CONTEXT; static final String STAGE_CLUSTER_HOST_INFO; static final String STAGE_COMMAND_PARAMS; static final String STAGE_HOST_PARAMS; static final String STAGE_SKIPPABLE; static final String STAGE_PROGRESS_PERCENT; static final String STAGE_STATUS; static final String STAGE_DISPLAY_STATUS; static final String STAGE_START_TIME; static final String STAGE_END_TIME; }