Examples of ActionDefinition


Examples of com.getperka.flatpack.policy.pst.ActionDefinition

    return;
  }

  void resolveSecurityAction(Ident<SecurityAction> x) {
    // Are we declaring a verb?
    ActionDefinition currentVerb = currentLocation(ActionDefinition.class);
    if (currentVerb != null) {
      SecurityAction a = SecurityAction.of(
          currentVerb.getName().getSimpleName(), x.getSimpleName());
      x.setReferent(a);
      return;
    }

    // Otherwise, it must be a verb reference
    if (x.isCompound()) {
      // *.*, Foo.*, or Foo.bar
      Ident<ActionDefinition> verbIdent = x.getCompoundName().get(0).cast(ActionDefinition.class);

      if (verbIdent.isWildcard()) {
        // Parser shouldn't allow *.foo, so we can ignore the second part
        x.setReferent(SecurityAction.all());
        return;
      }

      ActionDefinition verb = scope().get(verbIdent);
      if (verb == null) {
        error("Unknown verb: " + verbIdent.getSimpleName());
        return;
      }
      verbIdent.setReferent(verb);

      Ident<SecurityAction> actionIdent = x.getCompoundName().get(1).cast(SecurityAction.class);
      if (actionIdent.isWildcard()) {
        // Foo.*
        SecurityAction action = SecurityAction.of(verbIdent.getSimpleName(), "*");
        actionIdent.setReferent(action);
        x.setReferent(action);
      } else {
        // Find matching verb declaration, e.g. Foo.bar
        for (Ident<SecurityAction> action : verb.getActions()) {
          if (action.equals(x.getCompoundName().get(1))) {
            actionIdent.setReferent(action.getReferent());
            x.setReferent(action.getReferent());
            return;
          }
View Full Code Here

Examples of org.alfresco.service.cmr.action.ActionDefinition

        public void doWith(final Method method) throws IllegalArgumentException, IllegalAccessException {
          final ActionMethod actionMethod = AnnotationUtils.findAnnotation(method, ActionMethod.class);
          if (actionMethod != null) {
            final ActionExecuter actionExecuter = createActionExecuter(beanFactory.getBean(beanName),
                method, actionMethod);
            final ActionDefinition actionDefinition = actionExecuter.getActionDefinition();
            final String name = actionDefinition.getName();
            if (getActionExecuterRegistry().hasActionExecuter(name) == false) {
              if (logger.isDebugEnabled()) {
                logger.debug("Registering ActionExecuter {}.", name);
              }
              getActionExecuterRegistry().registerActionExecuter(actionExecuter);
View Full Code Here

Examples of org.apache.ambari.server.actionmanager.ActionDefinition

      throws AmbariException {
    if (actionRequest.getActionName() == null || actionRequest.getActionName().isEmpty()) {
      throw new AmbariException("Action name must be specified");
    }

    ActionDefinition actionDef = actionManager.getActionDefinition(actionRequest.getActionName());
    if (actionDef == null) {
      throw new AmbariException("Action " + actionRequest.getActionName() + " does not exist");
    }

    StackId stackId = cluster.getCurrentStackVersion();
    String expectedService = actionDef.getTargetService() == null ? "" : actionDef.getTargetService();
    String actualService = actionRequest.getServiceName() == null ? "" : actionRequest.getServiceName();
    if (!expectedService.isEmpty() && !actualService.isEmpty() && !expectedService.equals(actualService)) {
      throw new AmbariException("Action " + actionRequest.getActionName() + " targets service " + actualService +
          " that does not match with expected " + expectedService);
    }

    String targetService = expectedService;
    if (targetService == null || targetService.isEmpty()) {
      targetService = actualService;
    }

    if (targetService != null && !targetService.isEmpty()) {
      ServiceInfo serviceInfo;
      try {
        serviceInfo = ambariMetaInfo.getService(stackId.getStackName(), stackId.getStackVersion(),
            targetService);
      } catch (StackAccessException se) {
        serviceInfo = null;
      }

      if (serviceInfo == null) {
        throw new AmbariException("Action " + actionRequest.getActionName() + " targets service " + targetService +
            " that does not exist.");
      }
    }

    String expectedComponent = actionDef.getTargetComponent() == null ? "" : actionDef.getTargetComponent();
    String actualComponent = actionRequest.getComponentName() == null ? "" : actionRequest.getComponentName();
    if (!expectedComponent.isEmpty() && !actualComponent.isEmpty() && !expectedComponent.equals(actualComponent)) {
      throw new AmbariException("Action " + actionRequest.getActionName() + " targets component " + actualComponent +
          " that does not match with expected " + expectedComponent);
    }

    String targetComponent = expectedComponent;
    if (targetComponent == null || targetComponent.isEmpty()) {
      targetComponent = actualComponent;
    }

    if (!targetComponent.isEmpty() && targetService.isEmpty()) {
      throw new AmbariException("Action " + actionRequest.getActionName() + " targets component " + targetComponent +
          " without specifying the target service.");
    }

    if (targetComponent != null && !targetComponent.isEmpty()) {
      ComponentInfo compInfo;
      try {
        compInfo = ambariMetaInfo.getComponent(stackId.getStackName(), stackId.getStackVersion(),
            targetService, targetComponent);
      } catch (StackAccessException se) {
        compInfo = null;
      }

      if (compInfo == null) {
        throw new AmbariException("Action " + actionRequest.getActionName() + " targets component " + targetComponent +
            " that does not exist.");
      }
    }

    if (actionDef.getInputs() != null) {
      String[] inputs = actionDef.getInputs().split(",");
      for (String input : inputs) {
        if (!input.trim().isEmpty() && !actionRequest.getParameters().containsKey(input.trim())) {
          throw new AmbariException("Action " + actionRequest.getActionName() + " requires input '" +
              input.trim() + "' that is not provided.");
        }
      }
    }

    if (actionDef.getTargetType() == TargetHostType.SPECIFIC
        || (targetService.isEmpty() && targetService.isEmpty())) {
      if (actionRequest.getHosts().size() == 0) {
        throw new AmbariException("Action " + actionRequest.getActionName() + " requires explicit target host(s)" +
            " that is not provided.");
      }
    }

    LOG.info("Received action execution request"
        + ", clusterName=" + actionRequest.getClusterName()
        + ", request=" + actionRequest.toString());

    ActionExecutionContext actionExecutionContext = new ActionExecutionContext(
        actionRequest.getClusterName(), actionRequest.getActionName(), targetService, targetComponent,
        actionRequest.getHosts(), actionRequest.getParameters(), actionDef.getTargetType(),
        actionDef.getDefaultTimeout());

    return actionExecutionContext;
  }
View Full Code Here

Examples of org.apache.ambari.server.customactions.ActionDefinition

      return new ActionExecutionContext(actionRequest.getClusterName(),
        actionRequest.getCommandName(), actionRequest.getResourceFilters(),
        actionRequest.getParameters());
    } else {

    ActionDefinition actionDef = ambariMetaInfo.getActionDefinition(actionRequest.getActionName());

    if (actionDef == null) {
      throw new AmbariException("Action " + actionRequest.getActionName() + " does not exist");
    }

    return new ActionExecutionContext(actionRequest.getClusterName(),
      actionRequest.getActionName(), actionRequest.getResourceFilters(),
      actionRequest.getParameters(), actionDef.getTargetType(),
      actionDef.getDefaultTimeout(), actionDef.getTargetService(),
      actionDef.getTargetComponent());

    }
  }
View Full Code Here

Examples of org.apache.ambari.server.customactions.ActionDefinition

    hdfs.getServiceComponent(Role.HDFS_CLIENT.name()).addServiceComponentHost("h1").persist();
    hdfs.getServiceComponent(Role.NAMENODE.name()).addServiceComponentHost("h1").persist();
    hdfs.getServiceComponent(Role.DATANODE.name()).addServiceComponentHost("h1").persist();
    hdfs.getServiceComponent(Role.DATANODE.name()).addServiceComponentHost("h2").persist();

    controller.getAmbariMetaInfo().addActionDefinition(new ActionDefinition(
        "a1", ActionType.SYSTEM, "test,[optional1]", "", "", "Does file exist",
        TargetHostType.SPECIFIC, Short.valueOf("100")));

    controller.getAmbariMetaInfo().addActionDefinition(new ActionDefinition(
        "a2", ActionType.SYSTEM, "", "HDFS", "DATANODE", "Does file exist",
        TargetHostType.ALL, Short.valueOf("100")));

    Map<String, String> params = new HashMap<String, String>() {{
      put("test", "test");
View Full Code Here

Examples of org.apache.ambari.server.customactions.ActionDefinition

    }};
    actionRequest = new ExecuteActionRequest("c1", "DECOMMISSION", null, resourceFilters, params2);
    expectActionCreationErrorWithMessage(actionRequest, requestProperties,
        "mark_draining_only is not a valid parameter for NAMENODE");

    controller.getAmbariMetaInfo().addActionDefinition(new ActionDefinition(
        "a1", ActionType.SYSTEM, "test,dirName", "", "", "Does file exist",
        TargetHostType.SPECIFIC, Short.valueOf("100")));

    controller.getAmbariMetaInfo().addActionDefinition(new ActionDefinition(
        "a2", ActionType.SYSTEM, "", "HDFS", "DATANODE", "Does file exist",
        TargetHostType.ANY, Short.valueOf("100")));

    controller.getAmbariMetaInfo().addActionDefinition(new ActionDefinition(
        "a3", ActionType.SYSTEM, "", "MAPREDUCE", "MAPREDUCE_CLIENT", "Does file exist",
        TargetHostType.ANY, Short.valueOf("100")));

    controller.getAmbariMetaInfo().addActionDefinition(new ActionDefinition(
        "a4", ActionType.SYSTEM, "", "HIVE", "", "Does file exist",
        TargetHostType.ANY, Short.valueOf("100")));

    actionRequest = new ExecuteActionRequest("c1", null, "a1", null, null);
    expectActionCreationErrorWithMessage(actionRequest, requestProperties,
View Full Code Here

Examples of org.apache.ambari.server.customactions.ActionDefinition

    hdfs.getServiceComponent(Role.HDFS_CLIENT.name()).addServiceComponentHost("h1").persist();
    hdfs.getServiceComponent(Role.NAMENODE.name()).addServiceComponentHost("h1").persist();
    hdfs.getServiceComponent(Role.DATANODE.name()).addServiceComponentHost("h1").persist();
    hdfs.getServiceComponent(Role.DATANODE.name()).addServiceComponentHost("h2").persist();

    controller.getAmbariMetaInfo().addActionDefinition(new ActionDefinition(
      "a1", ActionType.SYSTEM, "", "HDFS", "", "Some custom action.",
      TargetHostType.ALL, Short.valueOf("100")));

    Map<String, String> params = new HashMap<String, String>() {{
      put("test", "test");
View Full Code Here

Examples of org.apache.ambari.server.customactions.ActionDefinition

    hdfs.getServiceComponent(Role.HDFS_CLIENT.name()).addServiceComponentHost("h1").persist();
    hdfs.getServiceComponent(Role.NAMENODE.name()).addServiceComponentHost("h1").persist();
    hdfs.getServiceComponent(Role.DATANODE.name()).addServiceComponentHost("h1").persist();
    hdfs.getServiceComponent(Role.DATANODE.name()).addServiceComponentHost("h2").persist();

    controller.getAmbariMetaInfo().addActionDefinition(new ActionDefinition(
        "a1", ActionType.SYSTEM, "test,[optional1]", "", "", "Does file exist",
        TargetHostType.SPECIFIC, Short.valueOf("100")));

    controller.getAmbariMetaInfo().addActionDefinition(new ActionDefinition(
        "a2", ActionType.SYSTEM, "", "HDFS", "DATANODE", "Does file exist",
        TargetHostType.ALL, Short.valueOf("100")));

    Map<String, String> params = new HashMap<String, String>() {{
      put("test", "test");
View Full Code Here

Examples of org.apache.ambari.server.customactions.ActionDefinition

    }};
    actionRequest = new ExecuteActionRequest("c1", "DECOMMISSION", null, resourceFilters, null, params2);
    expectActionCreationErrorWithMessage(actionRequest, requestProperties,
        "mark_draining_only is not a valid parameter for NAMENODE");

    controller.getAmbariMetaInfo().addActionDefinition(new ActionDefinition(
        "a1", ActionType.SYSTEM, "test,dirName", "", "", "Does file exist",
        TargetHostType.SPECIFIC, Short.valueOf("100")));

    controller.getAmbariMetaInfo().addActionDefinition(new ActionDefinition(
        "a2", ActionType.SYSTEM, "", "HDFS", "DATANODE", "Does file exist",
        TargetHostType.ANY, Short.valueOf("100")));

    controller.getAmbariMetaInfo().addActionDefinition(new ActionDefinition(
        "a3", ActionType.SYSTEM, "", "MAPREDUCE", "MAPREDUCE_CLIENT", "Does file exist",
        TargetHostType.ANY, Short.valueOf("100")));

    controller.getAmbariMetaInfo().addActionDefinition(new ActionDefinition(
        "a4", ActionType.SYSTEM, "", "HIVE", "", "Does file exist",
        TargetHostType.ANY, Short.valueOf("100")));

    actionRequest = new ExecuteActionRequest("c1", null, "a1", null, null, null);
    expectActionCreationErrorWithMessage(actionRequest, requestProperties,
View Full Code Here

Examples of org.apache.ambari.server.customactions.ActionDefinition

    hdfs.getServiceComponent(Role.HDFS_CLIENT.name()).addServiceComponentHost("h1").persist();
    hdfs.getServiceComponent(Role.NAMENODE.name()).addServiceComponentHost("h1").persist();
    hdfs.getServiceComponent(Role.DATANODE.name()).addServiceComponentHost("h1").persist();
    hdfs.getServiceComponent(Role.DATANODE.name()).addServiceComponentHost("h2").persist();

    controller.getAmbariMetaInfo().addActionDefinition(new ActionDefinition(
      "a1", ActionType.SYSTEM, "", "HDFS", "", "Some custom action.",
      TargetHostType.ALL, Short.valueOf("100")));

    Map<String, String> params = new HashMap<String, String>() {{
      put("test", "test");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.