Package org.apache.helix

Examples of org.apache.helix.HelixException


  public static String getAggregatorStr(String expression)
      throws HelixException
  {
    if (!expression.contains("("))
    {
      throw new HelixException(expression
          + " does not contain a valid aggregator.  No parentheses found");
    }
    String aggName = expression.substring(0, expression.indexOf("("));
    if (!aggregatorMap.containsKey(aggName.toUpperCase()))
    {
      throw new HelixException("aggregator <" + aggName + "> is unknown type");
    }
    return aggName;
  }
View Full Code Here


    // verify correct number of args
    int requiredNumArgs = aggregatorMap.get(aggregator.toUpperCase())
        .getRequiredNumArgs();
    if (numArgs != requiredNumArgs)
    {
      throw new HelixException(expression + " contains " + args.length
          + " arguments, but requires " + requiredNumArgs);
    }
    return args;
  }
View Full Code Here

          expression.lastIndexOf(")")));
    }
    String[] statList = justStats.split(argDelim);
    if (statList.length < 1)
    {
      throw new HelixException(expression
          + " does not contain any aggregator stats");
    }
    return statList;
  }
View Full Code Here

      throws HelixException
  {
    String[] stats = getAggregatorStats(expression);
    if (stats.length > 1)
    {
      throw new HelixException(expression + " contains more than 1 stat");
    }
    return stats[0];
  }
View Full Code Here

    for (String op : ops)
    {
      logger.debug("op: " + op);
      if (!operatorMap.containsKey(op.toUpperCase()))
      {
        throw new HelixException("<" + op + "> is not a valid operator type");
      }
      Operator currOpType = operatorMap.get(op.toUpperCase());
      if (currNumTuples < currOpType.minInputTupleLists
          || currNumTuples > currOpType.maxInputTupleLists)
      {
        throw new HelixException("<" + op + "> cannot process " + currNumTuples
            + " input tuples");
      }
      // reset num tuples to this op's output size
      if (!currOpType.inputOutputTupleListsCountsEqual)
      { // if equal, this number does not change
        currNumTuples = currOpType.numOutputTupleLists;
      }
    }
    if (currNumTuples != 1)
    {
      throw new HelixException(expression
          + " does not terminate in a single tuple set");
    }
    return ops;
  }
View Full Code Here

  public static Operator getOperator(String opName) throws HelixException
  {
    if (!operatorMap.containsKey(opName))
    {
      throw new HelixException(opName + " is unknown op type");
    }
    return operatorMap.get(opName);
  }
View Full Code Here

 
  public static AlertComparator getComparator(String compName)
  {
    compName = compName.replaceAll("\\s+", ""); //remove white space
    if (!comparatorMap.containsKey(compName)) {
      throw new HelixException("Comparator type <"+compName+"> unknown");
    }
    return comparatorMap.get(compName);
  }
View Full Code Here

                                           StateModelFactory<? extends StateModel> factory,
                                           String factoryName)
  {
    if (stateModelName == null || factory == null || factoryName == null)
    {
      throw new HelixException("stateModelDef|stateModelFactory|factoryName cannot be null");
    }

    logger.info("Register state model factory for state model " + stateModelName
        + " using factory name " + factoryName + " with " + factory);
View Full Code Here

  public static String getComponent(String component, String alert) throws HelixException
  {
    //find EXP and keep going until paren are closed
    int expStartPos = alert.indexOf(component);
    if (expStartPos < 0) {
      throw new HelixException(alert+" does not contain component "+component);
    }
    expStartPos += (component.length()+1); //advance length of string and one for open paren
    int expEndPos = expStartPos;
    int openParenCount = 1;
    while (openParenCount > 0) {
      if (alert.charAt(expEndPos) == '(') {
        openParenCount++;
      }
      else if (alert.charAt(expEndPos) == ')') {
        openParenCount--;
      }
      expEndPos++;
    }
    if (openParenCount != 0) {
      throw new HelixException(alert+" does not contain valid "+component+" component, " +
          "parentheses do not close");
    }
    //return what is in between paren
    return alert.substring(expStartPos, expEndPos-1);
  }
View Full Code Here

  {
    String type = message.getMsgType();

    if (!type.equals(MessageType.STATE_TRANSITION.toString()))
    {
      throw new HelixException("Unexpected msg type for message " + message.getMsgId()
          + " type:" + message.getMsgType());
    }

    String partitionKey = message.getPartitionName();
    String stateModelName = message.getStateModelDef();
    String resourceName = message.getResourceName();
    String sessionId = message.getTgtSessionId();
    int bucketSize = message.getBucketSize();

    if (stateModelName == null)
    {
      logger.error("message does not contain stateModelDef");
      return null;
    }

    String factoryName = message.getStateModelFactoryName();
    if (factoryName == null)
    {
      factoryName = HelixConstants.DEFAULT_STATE_MODEL_FACTORY;
    }

    StateModelFactory stateModelFactory =
        getStateModelFactory(stateModelName, factoryName);
    if (stateModelFactory == null)
    {
      logger.warn("Cannot find stateModelFactory for model:" + stateModelName
          + " using factoryName:" + factoryName + " for resourceGroup:" + resourceName);
      return null;
    }

    // check if the state model definition exists and cache it
    if (!_stateModelDefs.containsKey(stateModelName))
    {
      HelixDataAccessor accessor = _manager.getHelixDataAccessor();
      Builder keyBuilder = accessor.keyBuilder();
      StateModelDefinition stateModelDef =
          accessor.getProperty(keyBuilder.stateModelDef(stateModelName));
      if (stateModelDef == null)
      {
        throw new HelixException("stateModelDef for " + stateModelName
            + " does NOT exists");
      }
      _stateModelDefs.put(stateModelName, stateModelDef);
    }
View Full Code Here

TOP

Related Classes of org.apache.helix.HelixException

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.