Package org.apache.ambari.server.orm.entities

Examples of org.apache.ambari.server.orm.entities.ActionEntity


  }

  private ActionEntity createActionDefinition(
      String actionName, ActionType actionType, String inputs, String targetService, Role targetComponent,
      Short defaultTimeout, String description, TargetHostType targetType, Boolean addToDAO) throws Exception {
    ActionEntity actionDefinitionEntity = new ActionEntity();

    actionDefinitionEntity.setActionName(actionName);
    actionDefinitionEntity.setActionType(actionType);
    actionDefinitionEntity.setDefaultTimeout(defaultTimeout);
    actionDefinitionEntity.setDescription(description);
    actionDefinitionEntity.setInputs(inputs);
    actionDefinitionEntity.setTargetComponent(targetComponent.toString());
    actionDefinitionEntity.setTargetService(targetService);
    actionDefinitionEntity.setTargetType(targetType);

    if (addToDAO) {
      actionDefinitionDAO.create(actionDefinitionEntity);
    }
View Full Code Here


    createActionDefinition("c1", ActionType.SYSTEM, "fileName", Service.Type.HDFS.toString(), Role.DATANODE,
        Short.parseShort("10"), "a1", TargetHostType.ANY, true);
    createActionDefinition("c2", ActionType.SYSTEM, "fileName", Service.Type.HDFS.toString(), Role.DATANODE,
        Short.parseShort("10"), "a2", TargetHostType.ANY, true);

    ActionEntity actionDefinitionEntity = actionDefinitionDAO.findByPK("c1");

    Assert.assertNotNull(actionDefinitionEntity);
    Assert.assertEquals("c1", actionDefinitionEntity.getActionName());
  }
View Full Code Here

  @Test
  public void testUpdate() throws Exception {
    createActionDefinition("d1", ActionType.SYSTEM, "fileName", Service.Type.HDFS.toString(), Role.DATANODE,
        Short.parseShort("101"), "a1", TargetHostType.ANY, true);
    ActionEntity newOne = createActionDefinition("d1", ActionType.SYSTEM, "fileValue", Service.Type.HDFS.toString(),
        Role.DATANODE, Short.parseShort("101"), "a1", TargetHostType.ANY, false);
    actionDefinitionDAO.merge(newOne);
    ActionEntity actionDefinitionEntity = actionDefinitionDAO.findByPK("d1");
    Assert.assertEquals("fileValue", actionDefinitionEntity.getInputs());

    actionDefinitionDAO.remove(newOne);
    actionDefinitionEntity = actionDefinitionDAO.findByPK("d1");
    Assert.assertNull(actionDefinitionEntity);
  }
View Full Code Here

    Assert.assertNull(actionDefinitionEntity);
  }

  @Test
  public void testDeleteNonExistent() throws Exception {
    ActionEntity newOne = createActionDefinition("d1", ActionType.SYSTEM, "fileValue", Service.Type.HDFS.toString(),
        Role.DATANODE, Short.parseShort("101"), "a1", TargetHostType.ANY, false);
    actionDefinitionDAO.remove(newOne);
  }
View Full Code Here

   * @return
   * @throws AmbariException
   */
  @Override
  public ActionDefinition getActionDefinition(String actionName) {
    ActionEntity action =
        actionDefinitionDAO.findByPK(actionName);
    if (action != null) {
      return new ActionDefinition(action);
    }

View Full Code Here

                                     TargetHostType targetType, String serviceType, String componentType,
                                     Short defaultTimeout)
      throws AmbariException {
    validateCreateInput(actionName, actionType, inputs, description, defaultTimeout,
        targetType, serviceType, componentType);
    ActionEntity entity =
        actionDefinitionDAO.findByPK(actionName);
    if (entity == null) {
      entity = new ActionEntity();
      entity.setActionName(actionName);
      entity.setActionType(actionType);
      entity.setInputs(inputs);
      entity.setTargetService(serviceType);
      entity.setTargetComponent(componentType);
      entity.setDescription(description);
      entity.setTargetType(targetType);
      entity.setDefaultTimeout(defaultTimeout);
      actionDefinitionDAO.merge(entity);
    } else {
      throw new AmbariException("Action definition " + actionName + " already exists");
    }
  }
View Full Code Here

  @Override
  @Transactional
  public void updateActionDefinition(String actionName, ActionType actionType, String description,
                                     TargetHostType targetType, Short defaultTimeout)
      throws AmbariException {
    ActionEntity entity = actionDefinitionDAO.findByPK(actionName);
    if (entity != null) {
      if (actionType != null) {
        if (actionType == ActionType.SYSTEM_DISABLED) {
          throw new AmbariException("Action type cannot be " + actionType);
        }
        entity.setActionType(actionType);
      }
      if (description != null) {
        if (description.isEmpty()) {
          throw new AmbariException("Action description cannot be empty");
        }
        entity.setDescription(description);
      }
      if (targetType != null) {
        entity.setTargetType(targetType);
      }
      if (defaultTimeout != null) {
        if (defaultTimeout < MIN_TIMEOUT || defaultTimeout > MAX_TIMEOUT) {
          throw new AmbariException("Default timeout should be between " + MIN_TIMEOUT + " and " + MAX_TIMEOUT);
        }
        entity.setDefaultTimeout(defaultTimeout);
      }
      actionDefinitionDAO.merge(entity);
    } else {
      throw new AmbariException("Action definition " + actionName + " does not exist");
    }
View Full Code Here

TOP

Related Classes of org.apache.ambari.server.orm.entities.ActionEntity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.