You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by ka...@apache.org on 2013/12/04 23:22:33 UTC

git commit: [HELIX-22] Remove dependency on josql, rb=16017

Updated Branches:
  refs/heads/master 992bca8a0 -> b33e0b5ad


[HELIX-22] Remove dependency on josql, rb=16017


Project: http://git-wip-us.apache.org/repos/asf/incubator-helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-helix/commit/b33e0b5a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-helix/tree/b33e0b5a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-helix/diff/b33e0b5a

Branch: refs/heads/master
Commit: b33e0b5ad0f4b688bf897323ca3d0f197ab2ffd1
Parents: 992bca8
Author: Kanak Biscuitwala <ka...@apache.org>
Authored: Wed Dec 4 13:00:20 2013 -0800
Committer: Kanak Biscuitwala <ka...@apache.org>
Committed: Wed Dec 4 14:22:03 2013 -0800

----------------------------------------------------------------------
 helix-core/pom.xml                              |   6 -
 .../main/java/org/apache/helix/Criteria.java    |  12 +-
 .../helix/josql/ClusterJosqlQueryProcessor.java | 278 -------------------
 .../josql/ZNRecordJosqlFunctionHandler.java     |  78 ------
 .../org/apache/helix/josql/ZNRecordRow.java     | 174 ------------
 .../org/apache/helix/josql/package-info.java    |  23 --
 .../helix/messaging/CriteriaEvaluator.java      | 156 +++++++----
 .../org/apache/helix/messaging/ZNRecordRow.java | 193 +++++++++++++
 .../josql/TestClusterJosqlQueryProcessor.java   |  98 -------
 .../apache/helix/josql/TestJosqlProcessor.java  | 223 ---------------
 .../messaging/TestDefaultMessagingService.java  |  39 ++-
 pom.xml                                         |   5 -
 12 files changed, 335 insertions(+), 950 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/b33e0b5a/helix-core/pom.xml
----------------------------------------------------------------------
diff --git a/helix-core/pom.xml b/helix-core/pom.xml
index 6f2aeb9..f30abac 100644
--- a/helix-core/pom.xml
+++ b/helix-core/pom.xml
@@ -45,7 +45,6 @@ under the License.
       org.apache.zookeeper.txn*;resolution:=optional,
       org.apache.zookeeper*;version="[3.3,4)",
       org.codehaus.jackson*;version="[1.8,2)",
-      org.josql*;version="[1.5,2)",
       org.restlet;version="[2.1.4,3]",
       *
     </osgi.import>
@@ -116,11 +115,6 @@ under the License.
       <version>0.1</version>
     </dependency>
     <dependency>
-      <groupId>org.apache.camel</groupId>
-      <artifactId>camel-josql</artifactId>
-      <version>2.12.1</version>
-    </dependency>
-    <dependency>
       <groupId>org.testng</groupId>
       <artifactId>testng</artifactId>
       <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/b33e0b5a/helix-core/src/main/java/org/apache/helix/Criteria.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/Criteria.java b/helix-core/src/main/java/org/apache/helix/Criteria.java
index da2b36e..75781e1 100644
--- a/helix-core/src/main/java/org/apache/helix/Criteria.java
+++ b/helix-core/src/main/java/org/apache/helix/Criteria.java
@@ -39,16 +39,16 @@ public class Criteria {
    */
   boolean sessionSpecific;
   /**
-   * applicable only in case PARTICIPANT use * to broadcast to all instances
+   * applicable only in case PARTICIPANT use % to broadcast to all instances
    */
   String instanceName = "";
   /**
-   * Name of the resource. Use * to send message to all resources
+   * Name of the resource. Use % to send message to all resources
    * owned by an instance.
    */
   String resourceName = "";
   /**
-   * Resource partition. Use * to send message to all partitions of a given
+   * Resource partition. Use % to send message to all partitions of a given
    * resource
    */
   String partitionName = "";
@@ -140,7 +140,7 @@ public class Criteria {
 
   /**
    * Set the name of the destination instance (PARTICIPANT only)
-   * @param instanceName the instance name or * for all instances
+   * @param instanceName the instance name or % for all instances
    */
   public void setInstanceName(String instanceName) {
     this.instanceName = instanceName;
@@ -156,7 +156,7 @@ public class Criteria {
 
   /**
    * Set the destination resource name
-   * @param resourceName the resource name or * for all resources
+   * @param resourceName the resource name or % for all resources
    */
   public void setResource(String resourceName) {
     this.resourceName = resourceName;
@@ -172,7 +172,7 @@ public class Criteria {
 
   /**
    * Set the destination partition name
-   * @param partitionName the partition name, or * for all partitions of a resource
+   * @param partitionName the partition name, or % for all partitions of a resource
    */
   public void setPartition(String partitionName) {
     this.partitionName = partitionName;

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/b33e0b5a/helix-core/src/main/java/org/apache/helix/josql/ClusterJosqlQueryProcessor.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/josql/ClusterJosqlQueryProcessor.java b/helix-core/src/main/java/org/apache/helix/josql/ClusterJosqlQueryProcessor.java
deleted file mode 100644
index bac2b15..0000000
--- a/helix-core/src/main/java/org/apache/helix/josql/ClusterJosqlQueryProcessor.java
+++ /dev/null
@@ -1,278 +0,0 @@
-package org.apache.helix.josql;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.helix.HelixDataAccessor;
-import org.apache.helix.HelixException;
-import org.apache.helix.HelixManager;
-import org.apache.helix.HelixProperty;
-import org.apache.helix.PropertyKey.Builder;
-import org.apache.helix.PropertyType;
-import org.apache.helix.ZNRecord;
-import org.apache.helix.model.HelixConfigScope.ConfigScopeProperty;
-import org.apache.helix.model.LiveInstance.LiveInstanceProperty;
-import org.apache.log4j.Logger;
-import org.josql.Query;
-import org.josql.QueryExecutionException;
-import org.josql.QueryParseException;
-import org.josql.QueryResults;
-
-public class ClusterJosqlQueryProcessor {
-  public static final String PARTITIONS = "PARTITIONS";
-  public static final String FLATTABLE = ".Table";
-
-  HelixManager _manager;
-  private static Logger _logger = Logger.getLogger(ClusterJosqlQueryProcessor.class);
-
-  public ClusterJosqlQueryProcessor(HelixManager manager) {
-    _manager = manager;
-  }
-
-  String parseFromTarget(String sql) {
-    // We need to find out the "FROM" target, and replace it with liveInstances
-    // / partitions etc
-    int fromIndex = sql.indexOf("FROM");
-    if (fromIndex == -1) {
-      throw new HelixException("Query must contain FROM target. Query: " + sql);
-    }
-    // Per JoSql, select FROM <target> the target must be a object class that
-    // corresponds to a "table row"
-    // In out case, the row is always a ZNRecord
-
-    int nextSpace = sql.indexOf(" ", fromIndex);
-    while (sql.charAt(nextSpace) == ' ') {
-      nextSpace++;
-    }
-    int nextnextSpace = sql.indexOf(" ", nextSpace);
-    if (nextnextSpace == -1) {
-      nextnextSpace = sql.length();
-    }
-    String fromTarget = sql.substring(nextSpace, nextnextSpace).trim();
-
-    if (fromTarget.length() == 0) {
-      throw new HelixException("FROM target in the query cannot be empty. Query: " + sql);
-    }
-    return fromTarget;
-  }
-
-  public List<Object> runJoSqlQuery(String josql, Map<String, Object> bindVariables,
-      List<Object> additionalFunctionHandlers, List queryTarget) throws QueryParseException,
-      QueryExecutionException {
-    Query josqlQuery = prepareQuery(bindVariables, additionalFunctionHandlers);
-
-    josqlQuery.parse(josql);
-    QueryResults qr = josqlQuery.execute(queryTarget);
-
-    return qr.getResults();
-  }
-
-  Query prepareQuery(Map<String, Object> bindVariables, List<Object> additionalFunctionHandlers) {
-    // DataAccessor accessor = _manager.getDataAccessor();
-    HelixDataAccessor accessor = _manager.getHelixDataAccessor();
-
-    // Get all the ZNRecords in the cluster and set them as bind variables
-    Builder keyBuilder = accessor.keyBuilder();
-    // List<ZNRecord> instanceConfigs = accessor.getChildValues(PropertyType.CONFIGS,
-    // ConfigScopeProperty.PARTICIPANT.toString());
-
-    List<ZNRecord> instanceConfigs =
-        HelixProperty.convertToList(accessor.getChildValues(keyBuilder.instanceConfigs()));
-
-    List<ZNRecord> liveInstances =
-        HelixProperty.convertToList(accessor.getChildValues(keyBuilder.liveInstances()));
-    List<ZNRecord> stateModelDefs =
-        HelixProperty.convertToList(accessor.getChildValues(keyBuilder.stateModelDefs()));
-
-    // Idealstates are stored in a map from resource name to idealState ZNRecord
-    List<ZNRecord> idealStateList =
-        HelixProperty.convertToList(accessor.getChildValues(keyBuilder.idealStates()));
-
-    Map<String, ZNRecord> idealStatesMap = new HashMap<String, ZNRecord>();
-    for (ZNRecord idealState : idealStateList) {
-      idealStatesMap.put(idealState.getId(), idealState);
-    }
-    // Make up the partition list: for selecting partitions
-    List<ZNRecord> partitions = new ArrayList<ZNRecord>();
-    for (ZNRecord idealState : idealStateList) {
-      for (String partitionName : idealState.getMapFields().keySet()) {
-        partitions.add(new ZNRecord(partitionName));
-      }
-    }
-
-    List<ZNRecord> externalViewList =
-        HelixProperty.convertToList(accessor.getChildValues(keyBuilder.externalViews()));
-    // ExternalViews are stored in a map from resource name to idealState
-    // ZNRecord
-    Map<String, ZNRecord> externalViewMap = new HashMap<String, ZNRecord>();
-    for (ZNRecord externalView : externalViewList) {
-      externalViewMap.put(externalView.getId(), externalView);
-    }
-    // Map from instance name to a map from resource to current state ZNRecord
-    Map<String, Map<String, ZNRecord>> currentStatesMap =
-        new HashMap<String, Map<String, ZNRecord>>();
-    // Map from instance name to a list of combined flat ZNRecordRow
-    Map<String, List<ZNRecordRow>> flatCurrentStateMap = new HashMap<String, List<ZNRecordRow>>();
-
-    for (ZNRecord instance : liveInstances) {
-      String host = instance.getId();
-      String sessionId = instance.getSimpleField(LiveInstanceProperty.SESSION_ID.toString());
-      Map<String, ZNRecord> currentStates = new HashMap<String, ZNRecord>();
-      List<ZNRecord> instanceCurrentStateList = new ArrayList<ZNRecord>();
-      for (ZNRecord idealState : idealStateList) {
-        String resourceName = idealState.getId();
-
-        HelixProperty property =
-            accessor.getProperty(keyBuilder.currentState(host, sessionId, resourceName));
-        ZNRecord currentState = null;
-        if (property == null) {
-          _logger.warn("Resource " + resourceName + " has null currentState");
-          currentState = new ZNRecord(resourceName);
-        } else {
-          currentState = property.getRecord();
-        }
-        currentStates.put(resourceName, currentState);
-        instanceCurrentStateList.add(currentState);
-      }
-      currentStatesMap.put(host, currentStates);
-      flatCurrentStateMap.put(host, ZNRecordRow.flatten(instanceCurrentStateList));
-    }
-    Query josqlQuery = new Query();
-
-    // Set the default bind variables
-    josqlQuery.setVariable(
-        PropertyType.CONFIGS.toString() + "/" + ConfigScopeProperty.PARTICIPANT.toString(),
-        instanceConfigs);
-    josqlQuery.setVariable(PropertyType.IDEALSTATES.toString(), idealStatesMap);
-    josqlQuery.setVariable(PropertyType.LIVEINSTANCES.toString(), liveInstances);
-    josqlQuery.setVariable(PropertyType.STATEMODELDEFS.toString(), stateModelDefs);
-    josqlQuery.setVariable(PropertyType.EXTERNALVIEW.toString(), externalViewMap);
-    josqlQuery.setVariable(PropertyType.CURRENTSTATES.toString(), currentStatesMap);
-    josqlQuery.setVariable(PARTITIONS, partitions);
-
-    // Flat version of ZNRecords
-    josqlQuery.setVariable(
-        PropertyType.CONFIGS.toString() + "/" + ConfigScopeProperty.PARTICIPANT.toString()
-            + FLATTABLE, ZNRecordRow.flatten(instanceConfigs));
-    josqlQuery.setVariable(PropertyType.IDEALSTATES.toString() + FLATTABLE,
-        ZNRecordRow.flatten(idealStateList));
-    josqlQuery.setVariable(PropertyType.LIVEINSTANCES.toString() + FLATTABLE,
-        ZNRecordRow.flatten(liveInstances));
-    josqlQuery.setVariable(PropertyType.STATEMODELDEFS.toString() + FLATTABLE,
-        ZNRecordRow.flatten(stateModelDefs));
-    josqlQuery.setVariable(PropertyType.EXTERNALVIEW.toString() + FLATTABLE,
-        ZNRecordRow.flatten(externalViewList));
-    josqlQuery.setVariable(PropertyType.CURRENTSTATES.toString() + FLATTABLE,
-        flatCurrentStateMap.values());
-    josqlQuery.setVariable(PARTITIONS + FLATTABLE, ZNRecordRow.flatten(partitions));
-    // Set additional bind variables
-    if (bindVariables != null) {
-      for (String key : bindVariables.keySet()) {
-        josqlQuery.setVariable(key, bindVariables.get(key));
-      }
-    }
-
-    josqlQuery.addFunctionHandler(new ZNRecordJosqlFunctionHandler());
-    josqlQuery.addFunctionHandler(new ZNRecordRow());
-    josqlQuery.addFunctionHandler(new Integer(0));
-    if (additionalFunctionHandlers != null) {
-      for (Object functionHandler : additionalFunctionHandlers) {
-        josqlQuery.addFunctionHandler(functionHandler);
-      }
-    }
-    return josqlQuery;
-  }
-
-  public List<Object> runJoSqlQuery(String josql, Map<String, Object> bindVariables,
-      List<Object> additionalFunctionHandlers) throws QueryParseException, QueryExecutionException {
-    Query josqlQuery = prepareQuery(bindVariables, additionalFunctionHandlers);
-
-    // Per JoSql, select FROM <target> the target must be a object class that
-    // corresponds to a "table row",
-    // while the table (list of Objects) are put in the query by
-    // query.execute(List<Object>). In the input,
-    // In out case, the row is always a ZNRecord. But in SQL, the from target is
-    // a "table name".
-
-    String fromTargetString = parseFromTarget(josql);
-
-    List fromTargetList = null;
-    Object fromTarget = null;
-    if (fromTargetString.equalsIgnoreCase(PARTITIONS)) {
-      fromTarget = josqlQuery.getVariable(PARTITIONS.toString());
-    } else if (fromTargetString.equalsIgnoreCase(PropertyType.LIVEINSTANCES.toString())) {
-      fromTarget = josqlQuery.getVariable(PropertyType.LIVEINSTANCES.toString());
-    } else if (fromTargetString.equalsIgnoreCase(PropertyType.CONFIGS.toString() + "/"
-        + ConfigScopeProperty.PARTICIPANT.toString())) {
-      fromTarget =
-          josqlQuery.getVariable(PropertyType.CONFIGS.toString() + "/"
-              + ConfigScopeProperty.PARTICIPANT.toString());
-    } else if (fromTargetString.equalsIgnoreCase(PropertyType.STATEMODELDEFS.toString())) {
-      fromTarget = josqlQuery.getVariable(PropertyType.STATEMODELDEFS.toString());
-    } else if (fromTargetString.equalsIgnoreCase(PropertyType.EXTERNALVIEW.toString())) {
-      fromTarget = josqlQuery.getVariable(PropertyType.EXTERNALVIEW.toString());
-    } else if (fromTargetString.equalsIgnoreCase(PropertyType.IDEALSTATES.toString())) {
-      fromTarget = josqlQuery.getVariable(PropertyType.IDEALSTATES.toString());
-    }
-
-    else if (fromTargetString.equalsIgnoreCase(PARTITIONS + FLATTABLE)) {
-      fromTarget = josqlQuery.getVariable(PARTITIONS.toString() + FLATTABLE);
-    } else if (fromTargetString.equalsIgnoreCase(PropertyType.LIVEINSTANCES.toString() + FLATTABLE)) {
-      fromTarget = josqlQuery.getVariable(PropertyType.LIVEINSTANCES.toString() + FLATTABLE);
-    } else if (fromTargetString.equalsIgnoreCase(PropertyType.CONFIGS.toString() + "/"
-        + ConfigScopeProperty.PARTICIPANT.toString() + FLATTABLE)) {
-      fromTarget =
-          josqlQuery.getVariable(PropertyType.CONFIGS.toString() + "/"
-              + ConfigScopeProperty.PARTICIPANT.toString() + FLATTABLE);
-    } else if (fromTargetString
-        .equalsIgnoreCase(PropertyType.STATEMODELDEFS.toString() + FLATTABLE)) {
-      fromTarget = josqlQuery.getVariable(PropertyType.STATEMODELDEFS.toString() + FLATTABLE);
-    } else if (fromTargetString.equalsIgnoreCase(PropertyType.EXTERNALVIEW.toString() + FLATTABLE)) {
-      fromTarget = josqlQuery.getVariable(PropertyType.EXTERNALVIEW.toString() + FLATTABLE);
-    } else if (fromTargetString.equalsIgnoreCase(PropertyType.IDEALSTATES.toString() + FLATTABLE)) {
-      fromTarget = josqlQuery.getVariable(PropertyType.IDEALSTATES.toString() + FLATTABLE);
-    } else {
-      throw new HelixException(
-          "Unknown query target "
-              + fromTargetString
-              + ". Target should be PARTITIONS, LIVEINSTANCES, CONFIGS, STATEMODELDEFS, IDEALSTATES, EXTERNALVIEW, and corresponding flat Tables");
-    }
-
-    fromTargetList =
-        fromTargetString.endsWith(FLATTABLE) ? ((List<ZNRecordRow>) fromTarget)
-            : ((List<ZNRecord>) fromTarget);
-
-    // Per JoSql, select FROM <target> the target must be a object class that
-    // corresponds to a "table row"
-    // In out case, the row is always a ZNRecord
-    josql =
-        josql.replaceFirst(
-            fromTargetString,
-            fromTargetString.endsWith(FLATTABLE) ? ZNRecordRow.class.getName() : ZNRecord.class
-                .getName());
-    josqlQuery.parse(josql);
-    QueryResults qr = josqlQuery.execute(fromTargetList);
-    return qr.getResults();
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/b33e0b5a/helix-core/src/main/java/org/apache/helix/josql/ZNRecordJosqlFunctionHandler.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/josql/ZNRecordJosqlFunctionHandler.java b/helix-core/src/main/java/org/apache/helix/josql/ZNRecordJosqlFunctionHandler.java
deleted file mode 100644
index f2fbddb..0000000
--- a/helix-core/src/main/java/org/apache/helix/josql/ZNRecordJosqlFunctionHandler.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package org.apache.helix.josql;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Map;
-
-import org.apache.helix.ZNRecord;
-import org.josql.functions.AbstractFunctionHandler;
-
-public class ZNRecordJosqlFunctionHandler extends AbstractFunctionHandler {
-  public boolean hasSimpleField(ZNRecord record, String fieldName, String field) {
-    if (!record.getSimpleFields().containsKey(fieldName)) {
-      return false;
-    }
-    return field.equals(record.getSimpleField(fieldName));
-  }
-
-  public boolean hasListField(ZNRecord record, String fieldName, String field) {
-    if (!record.getListFields().containsKey(fieldName)) {
-      return false;
-    }
-    return record.getListField(fieldName).contains(field);
-  }
-
-  public boolean hasMapFieldValue(ZNRecord record, String fieldName, String mapKey, String mapValue) {
-    if (!record.getMapFields().containsKey(fieldName)) {
-      return false;
-    }
-    if (record.getMapField(fieldName).containsKey(mapKey)) {
-      return record.getMapField(fieldName).get(mapKey).equals(mapValue);
-    }
-    return false;
-  }
-
-  public boolean hasMapFieldKey(ZNRecord record, String fieldName, String mapKey) {
-    if (!record.getMapFields().containsKey(fieldName)) {
-      return false;
-    }
-    return record.getMapField(fieldName).containsKey(mapKey);
-  }
-
-  public String getMapFieldValue(ZNRecord record, String fieldName, String mapKey) {
-    if (record.getMapFields().containsKey(fieldName)) {
-      return record.getMapField(fieldName).get(mapKey);
-    }
-    return null;
-  }
-
-  public String getSimpleFieldValue(ZNRecord record, String key) {
-    return record.getSimpleField(key);
-  }
-
-  public ZNRecord getZNRecordFromMap(Map<String, ZNRecord> recordMap, String key) {
-    return recordMap.get(key);
-  }
-
-  public ZNRecord getZNRecordFromMap(Map<String, Map<String, ZNRecord>> recordMap, String key,
-      String subKey) {
-    return recordMap.get(key).get(subKey);
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/b33e0b5a/helix-core/src/main/java/org/apache/helix/josql/ZNRecordRow.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/josql/ZNRecordRow.java b/helix-core/src/main/java/org/apache/helix/josql/ZNRecordRow.java
deleted file mode 100644
index 108596f..0000000
--- a/helix-core/src/main/java/org/apache/helix/josql/ZNRecordRow.java
+++ /dev/null
@@ -1,174 +0,0 @@
-package org.apache.helix.josql;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.helix.ZNRecord;
-
-/**
- * A Normalized form of ZNRecord
- */
-public class ZNRecordRow {
-  // "Field names" in the flattened ZNRecord
-  public static final String SIMPLE_KEY = "simpleKey";
-  public static final String SIMPLE_VALUE = "simpleValue";
-
-  public static final String LIST_KEY = "listKey";
-  public static final String LIST_VALUE = "listValue";
-  public static final String LIST_VALUE_INDEX = "listValueIndex";
-
-  public static final String MAP_KEY = "mapKey";
-  public static final String MAP_SUBKEY = "mapSubKey";
-  public static final String MAP_VALUE = "mapValue";
-  public static final String ZNRECORD_ID = "recordId";
-  // ZNRECORD path ?
-
-  final Map<String, String> _rowDataMap = new HashMap<String, String>();
-
-  public ZNRecordRow() {
-    _rowDataMap.put(SIMPLE_KEY, "");
-    _rowDataMap.put(SIMPLE_VALUE, "");
-    _rowDataMap.put(LIST_KEY, "");
-    _rowDataMap.put(LIST_VALUE, "");
-    _rowDataMap.put(LIST_VALUE_INDEX, "");
-    _rowDataMap.put(MAP_KEY, "");
-    _rowDataMap.put(MAP_SUBKEY, "");
-    _rowDataMap.put(MAP_VALUE, "");
-    _rowDataMap.put(ZNRECORD_ID, "");
-  }
-
-  public String getField(String rowField) {
-    return _rowDataMap.get(rowField);
-  }
-
-  public void putField(String fieldName, String fieldValue) {
-    _rowDataMap.put(fieldName, fieldValue);
-  }
-
-  public String getListValueIndex() {
-    return getField(LIST_VALUE_INDEX);
-  }
-
-  public String getSimpleKey() {
-    return getField(SIMPLE_KEY);
-  }
-
-  public String getSimpleValue() {
-    return getField(SIMPLE_VALUE);
-  }
-
-  public String getListKey() {
-    return getField(LIST_KEY);
-  }
-
-  public String getListValue() {
-    return getField(LIST_VALUE);
-  }
-
-  public String getMapKey() {
-    return getField(MAP_KEY);
-  }
-
-  public String getMapSubKey() {
-    return getField(MAP_SUBKEY);
-  }
-
-  public String getMapValue() {
-    return getField(MAP_VALUE);
-  }
-
-  public String getRecordId() {
-    return getField(ZNRECORD_ID);
-  }
-
-  /* Josql function handlers */
-  public static String getField(ZNRecordRow row, String rowField) {
-    return row.getField(rowField);
-  }
-
-  public static List<ZNRecordRow> convertSimpleFields(ZNRecord record) {
-    List<ZNRecordRow> result = new ArrayList<ZNRecordRow>();
-    for (String key : record.getSimpleFields().keySet()) {
-      ZNRecordRow row = new ZNRecordRow();
-      row.putField(ZNRECORD_ID, record.getId());
-      row.putField(SIMPLE_KEY, key);
-      row.putField(SIMPLE_VALUE, record.getSimpleField(key));
-      result.add(row);
-    }
-    return result;
-  }
-
-  public static List<ZNRecordRow> convertListFields(ZNRecord record) {
-    List<ZNRecordRow> result = new ArrayList<ZNRecordRow>();
-    for (String key : record.getListFields().keySet()) {
-      int order = 0;
-      for (String value : record.getListField(key)) {
-        ZNRecordRow row = new ZNRecordRow();
-        row.putField(ZNRECORD_ID, record.getId());
-        row.putField(LIST_KEY, key);
-        row.putField(LIST_VALUE, record.getSimpleField(key));
-        row.putField(LIST_VALUE_INDEX, "" + order);
-        order++;
-        result.add(row);
-      }
-    }
-    return result;
-  }
-
-  public static List<ZNRecordRow> convertMapFields(ZNRecord record) {
-    List<ZNRecordRow> result = new ArrayList<ZNRecordRow>();
-    for (String key0 : record.getMapFields().keySet()) {
-      for (String key1 : record.getMapField(key0).keySet()) {
-        ZNRecordRow row = new ZNRecordRow();
-        row.putField(ZNRECORD_ID, record.getId());
-        row.putField(MAP_KEY, key0);
-        row.putField(MAP_SUBKEY, key1);
-        row.putField(MAP_VALUE, record.getMapField(key0).get(key1));
-        result.add(row);
-      }
-    }
-    return result;
-  }
-
-  public static List<ZNRecordRow> flatten(ZNRecord record) {
-    List<ZNRecordRow> result = convertMapFields(record);
-    result.addAll(convertListFields(record));
-    result.addAll(convertSimpleFields(record));
-    return result;
-  }
-
-  public static List<ZNRecordRow> flatten(Collection<ZNRecord> recordList) {
-    List<ZNRecordRow> result = new ArrayList<ZNRecordRow>();
-    for (ZNRecord record : recordList) {
-      result.addAll(flatten(record));
-    }
-    return result;
-  }
-
-  public static List<ZNRecordRow> getRowListFromMap(Map<String, List<ZNRecordRow>> rowMap,
-      String key) {
-    return rowMap.get(key);
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/b33e0b5a/helix-core/src/main/java/org/apache/helix/josql/package-info.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/josql/package-info.java b/helix-core/src/main/java/org/apache/helix/josql/package-info.java
deleted file mode 100644
index 550d569..0000000
--- a/helix-core/src/main/java/org/apache/helix/josql/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/**
- * Jsql processor for Helix
- * 
- */
-package org.apache.helix.josql;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/b33e0b5a/helix-core/src/main/java/org/apache/helix/messaging/CriteriaEvaluator.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/messaging/CriteriaEvaluator.java b/helix-core/src/main/java/org/apache/helix/messaging/CriteriaEvaluator.java
index 3d2569e..9ca20af 100644
--- a/helix-core/src/main/java/org/apache/helix/messaging/CriteriaEvaluator.java
+++ b/helix-core/src/main/java/org/apache/helix/messaging/CriteriaEvaluator.java
@@ -19,80 +19,124 @@ package org.apache.helix.messaging;
  * under the License.
  */
 
-import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
+import java.util.regex.Pattern;
 
 import org.apache.helix.Criteria;
+import org.apache.helix.Criteria.DataSource;
+import org.apache.helix.HelixDataAccessor;
 import org.apache.helix.HelixManager;
-import org.apache.helix.josql.ClusterJosqlQueryProcessor;
-import org.apache.helix.josql.ZNRecordRow;
+import org.apache.helix.HelixProperty;
+import org.apache.helix.PropertyKey;
 import org.apache.log4j.Logger;
 
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+
 public class CriteriaEvaluator {
   private static Logger logger = Logger.getLogger(CriteriaEvaluator.class);
 
+  /**
+   * Examine persisted data to match wildcards in {@link Criteria}
+   * @param recipientCriteria Criteria specifying the message destinations
+   * @param manager connection to the persisted data
+   * @return map of evaluated criteria
+   */
   public List<Map<String, String>> evaluateCriteria(Criteria recipientCriteria, HelixManager manager) {
-    List<Map<String, String>> selected = new ArrayList<Map<String, String>>();
-
-    String queryFields =
-        (!recipientCriteria.getInstanceName().equals("") ? " " + ZNRecordRow.MAP_SUBKEY : " ''")
-            + ","
-            + (!recipientCriteria.getResource().equals("") ? " " + ZNRecordRow.ZNRECORD_ID : " ''")
-            + ","
-            + (!recipientCriteria.getPartition().equals("") ? " " + ZNRecordRow.MAP_KEY : " ''")
-            + ","
-            + (!recipientCriteria.getPartitionState().equals("") ? " " + ZNRecordRow.MAP_VALUE
-                : " '' ");
-
-    String matchCondition =
-        ZNRecordRow.MAP_SUBKEY
-            + " LIKE '"
-            + (!recipientCriteria.getInstanceName().equals("") ? (recipientCriteria
-                .getInstanceName() + "'") : "%' ")
-            + " AND "
-            + ZNRecordRow.ZNRECORD_ID
-            + " LIKE '"
-            + (!recipientCriteria.getResource().equals("") ? (recipientCriteria.getResource() + "'")
-                : "%' ")
-            + " AND "
-            + ZNRecordRow.MAP_KEY
-            + " LIKE '"
-            + (!recipientCriteria.getPartition().equals("") ? (recipientCriteria.getPartition() + "'")
-                : "%' ")
-            + " AND "
-            + ZNRecordRow.MAP_VALUE
-            + " LIKE '"
-            + (!recipientCriteria.getPartitionState().equals("") ? (recipientCriteria
-                .getPartitionState() + "'") : "%' ") + " AND " + ZNRecordRow.MAP_SUBKEY
-            + " IN ((SELECT [*]id FROM :LIVEINSTANCES))";
+    // get the data
+    HelixDataAccessor accessor = manager.getHelixDataAccessor();
+    PropertyKey.Builder keyBuilder = accessor.keyBuilder();
+    Set<Map<String, String>> selected = Sets.newHashSet();
+    List<HelixProperty> properties;
+    if (recipientCriteria.getDataSource() == DataSource.EXTERNALVIEW) {
+      properties = accessor.getChildValues(keyBuilder.externalViews());
+    } else if (recipientCriteria.getDataSource() == DataSource.IDEALSTATES) {
+      properties = accessor.getChildValues(keyBuilder.idealStates());
+    } else {
+      return Collections.emptyList();
+    }
 
-    String queryTarget =
-        recipientCriteria.getDataSource().toString() + ClusterJosqlQueryProcessor.FLATTABLE;
+    // flatten the data
+    List<ZNRecordRow> allRows = ZNRecordRow.flatten(HelixProperty.convertToList(properties));
 
-    String josql =
-        "SELECT DISTINCT " + queryFields + " FROM " + queryTarget + " WHERE " + matchCondition;
-    ClusterJosqlQueryProcessor p = new ClusterJosqlQueryProcessor(manager);
-    List<Object> result = new ArrayList<Object>();
-    try {
-      logger.info("JOSQL query: " + josql);
-      result = p.runJoSqlQuery(josql, null, null);
-    } catch (Exception e) {
-      logger.error("", e);
-      return selected;
+    // save the matches
+    Set<String> liveParticipants = accessor.getChildValuesMap(keyBuilder.liveInstances()).keySet();
+    List<ZNRecordRow> result = Lists.newArrayList();
+    for (ZNRecordRow row : allRows) {
+      if (rowMatches(recipientCriteria, row) && liveParticipants.contains(row.getMapSubKey())) {
+        result.add(row);
+      }
     }
 
-    for (Object o : result) {
+    // deduplicate and convert the matches into the required format
+    for (ZNRecordRow row : result) {
       Map<String, String> resultRow = new HashMap<String, String>();
-      List<Object> row = (List<Object>) o;
-      resultRow.put("instanceName", (String) (row.get(0)));
-      resultRow.put("resourceName", (String) (row.get(1)));
-      resultRow.put("partitionName", (String) (row.get(2)));
-      resultRow.put("partitionState", (String) (row.get(3)));
+      resultRow.put("instanceName",
+          !recipientCriteria.getInstanceName().equals("") ? row.getMapSubKey() : "");
+      resultRow.put("resourceName", !recipientCriteria.getResource().equals("") ? row.getRecordId()
+          : "");
+      resultRow.put("partitionName", !recipientCriteria.getPartition().equals("") ? row.getMapKey()
+          : "");
+      resultRow.put("partitionState",
+          !recipientCriteria.getPartitionState().equals("") ? row.getMapValue() : "");
       selected.add(resultRow);
     }
-    logger.info("JOSQL query return " + selected.size() + " rows");
-    return selected;
+    logger.info("Query returned " + selected.size() + " rows");
+    return Lists.newArrayList(selected);
+  }
+
+  /**
+   * Check if a given row matches the specified criteria
+   * @param criteria the criteria
+   * @param row row of currently persisted data
+   * @return true if it matches, false otherwise
+   */
+  private boolean rowMatches(Criteria criteria, ZNRecordRow row) {
+    String instanceName = normalizePattern(criteria.getInstanceName());
+    String resourceName = normalizePattern(criteria.getResource());
+    String partitionName = normalizePattern(criteria.getPartition());
+    String partitionState = normalizePattern(criteria.getPartitionState());
+    return stringMatches(instanceName, row.getMapSubKey())
+        && stringMatches(resourceName, row.getRecordId())
+        && stringMatches(partitionName, row.getMapKey())
+        && stringMatches(partitionState, row.getMapValue());
+  }
+
+  /**
+   * Convert an SQL like expression into a Java matches expression
+   * @param pattern SQL like match pattern (i.e. contains '%'s and '_'s)
+   * @return Java matches expression (i.e. contains ".*?"s and '.'s)
+   */
+  private String normalizePattern(String pattern) {
+    if (pattern == null || pattern.equals("") || pattern.equals("*")) {
+      pattern = "%";
+    }
+    StringBuilder builder = new StringBuilder();
+    for (int i = 0; i < pattern.length(); i++) {
+      char ch = pattern.charAt(i);
+      if ("[](){}.*+?$^|#\\".indexOf(ch) != -1) {
+        // escape any reserved characters
+        builder.append("\\");
+      }
+      // append the character
+      builder.append(ch);
+    }
+    pattern = builder.toString().toLowerCase().replace("_", ".").replace("%", ".*?");
+    return pattern;
+  }
+
+  /**
+   * Check if a string matches a pattern
+   * @param pattern pattern allowed by Java regex matching
+   * @param value the string to check
+   * @return true if they match, false otherwise
+   */
+  private boolean stringMatches(String pattern, String value) {
+    Pattern p = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
+    return p.matcher(value).matches();
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/b33e0b5a/helix-core/src/main/java/org/apache/helix/messaging/ZNRecordRow.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/messaging/ZNRecordRow.java b/helix-core/src/main/java/org/apache/helix/messaging/ZNRecordRow.java
new file mode 100644
index 0000000..5a2effd
--- /dev/null
+++ b/helix-core/src/main/java/org/apache/helix/messaging/ZNRecordRow.java
@@ -0,0 +1,193 @@
+package org.apache.helix.messaging;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.helix.ZNRecord;
+
+/**
+ * A Normalized form of ZNRecord
+ */
+public class ZNRecordRow {
+  // "Field names" in the flattened ZNRecord
+  public static final String SIMPLE_KEY = "simpleKey";
+  public static final String SIMPLE_VALUE = "simpleValue";
+
+  public static final String LIST_KEY = "listKey";
+  public static final String LIST_VALUE = "listValue";
+  public static final String LIST_VALUE_INDEX = "listValueIndex";
+
+  public static final String MAP_KEY = "mapKey";
+  public static final String MAP_SUBKEY = "mapSubKey";
+  public static final String MAP_VALUE = "mapValue";
+  public static final String ZNRECORD_ID = "recordId";
+  // ZNRECORD path ?
+
+  final Map<String, String> _rowDataMap = new HashMap<String, String>();
+
+  public ZNRecordRow() {
+    _rowDataMap.put(SIMPLE_KEY, "");
+    _rowDataMap.put(SIMPLE_VALUE, "");
+    _rowDataMap.put(LIST_KEY, "");
+    _rowDataMap.put(LIST_VALUE, "");
+    _rowDataMap.put(LIST_VALUE_INDEX, "");
+    _rowDataMap.put(MAP_KEY, "");
+    _rowDataMap.put(MAP_SUBKEY, "");
+    _rowDataMap.put(MAP_VALUE, "");
+    _rowDataMap.put(ZNRECORD_ID, "");
+  }
+
+  public String getField(String rowField) {
+    return _rowDataMap.get(rowField);
+  }
+
+  public void putField(String fieldName, String fieldValue) {
+    _rowDataMap.put(fieldName, fieldValue);
+  }
+
+  public String getListValueIndex() {
+    return getField(LIST_VALUE_INDEX);
+  }
+
+  public String getSimpleKey() {
+    return getField(SIMPLE_KEY);
+  }
+
+  public String getSimpleValue() {
+    return getField(SIMPLE_VALUE);
+  }
+
+  public String getListKey() {
+    return getField(LIST_KEY);
+  }
+
+  public String getListValue() {
+    return getField(LIST_VALUE);
+  }
+
+  public String getMapKey() {
+    return getField(MAP_KEY);
+  }
+
+  public String getMapSubKey() {
+    return getField(MAP_SUBKEY);
+  }
+
+  public String getMapValue() {
+    return getField(MAP_VALUE);
+  }
+
+  public String getRecordId() {
+    return getField(ZNRECORD_ID);
+  }
+
+  /* Josql function handlers */
+  public static String getField(ZNRecordRow row, String rowField) {
+    return row.getField(rowField);
+  }
+
+  public static List<ZNRecordRow> convertSimpleFields(ZNRecord record) {
+    List<ZNRecordRow> result = new ArrayList<ZNRecordRow>();
+    for (String key : record.getSimpleFields().keySet()) {
+      ZNRecordRow row = new ZNRecordRow();
+      row.putField(ZNRECORD_ID, record.getId());
+      row.putField(SIMPLE_KEY, key);
+      row.putField(SIMPLE_VALUE, record.getSimpleField(key));
+      result.add(row);
+    }
+    return result;
+  }
+
+  public static List<ZNRecordRow> convertListFields(ZNRecord record) {
+    List<ZNRecordRow> result = new ArrayList<ZNRecordRow>();
+    for (String key : record.getListFields().keySet()) {
+      int order = 0;
+      for (String value : record.getListField(key)) {
+        ZNRecordRow row = new ZNRecordRow();
+        row.putField(ZNRECORD_ID, record.getId());
+        row.putField(LIST_KEY, key);
+        row.putField(LIST_VALUE, record.getSimpleField(key));
+        row.putField(LIST_VALUE_INDEX, "" + order);
+        order++;
+        result.add(row);
+      }
+    }
+    return result;
+  }
+
+  public static List<ZNRecordRow> convertMapFields(ZNRecord record) {
+    List<ZNRecordRow> result = new ArrayList<ZNRecordRow>();
+    for (String key0 : record.getMapFields().keySet()) {
+      for (String key1 : record.getMapField(key0).keySet()) {
+        ZNRecordRow row = new ZNRecordRow();
+        row.putField(ZNRECORD_ID, record.getId());
+        row.putField(MAP_KEY, key0);
+        row.putField(MAP_SUBKEY, key1);
+        row.putField(MAP_VALUE, record.getMapField(key0).get(key1));
+        result.add(row);
+      }
+    }
+    return result;
+  }
+
+  public static List<ZNRecordRow> flatten(ZNRecord record) {
+    List<ZNRecordRow> result = convertMapFields(record);
+    result.addAll(convertListFields(record));
+    result.addAll(convertSimpleFields(record));
+    return result;
+  }
+
+  public static List<ZNRecordRow> flatten(Collection<ZNRecord> recordList) {
+    List<ZNRecordRow> result = new ArrayList<ZNRecordRow>();
+    for (ZNRecord record : recordList) {
+      result.addAll(flatten(record));
+    }
+    return result;
+  }
+
+  public static List<ZNRecordRow> getRowListFromMap(Map<String, List<ZNRecordRow>> rowMap,
+      String key) {
+    return rowMap.get(key);
+  }
+
+  @Override
+  public String toString() {
+    return _rowDataMap.toString();
+  }
+
+  @Override
+  public boolean equals(Object other) {
+    if (other instanceof ZNRecordRow) {
+      ZNRecordRow that = (ZNRecordRow) other;
+      return this._rowDataMap.equals(that._rowDataMap);
+    }
+    return false;
+  }
+
+  @Override
+  public int hashCode() {
+    return _rowDataMap.hashCode();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/b33e0b5a/helix-core/src/test/java/org/apache/helix/josql/TestClusterJosqlQueryProcessor.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/josql/TestClusterJosqlQueryProcessor.java b/helix-core/src/test/java/org/apache/helix/josql/TestClusterJosqlQueryProcessor.java
deleted file mode 100644
index 30c23fb..0000000
--- a/helix-core/src/test/java/org/apache/helix/josql/TestClusterJosqlQueryProcessor.java
+++ /dev/null
@@ -1,98 +0,0 @@
-package org.apache.helix.josql;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import org.apache.helix.Criteria;
-import org.apache.helix.InstanceType;
-import org.apache.helix.ZNRecord;
-import org.apache.helix.controller.strategy.DefaultTwoStateStrategy;
-import org.apache.helix.model.LiveInstance.LiveInstanceProperty;
-import org.josql.Query;
-import org.josql.QueryExecutionException;
-import org.josql.QueryParseException;
-import org.josql.QueryResults;
-import org.testng.annotations.Test;
-
-public class TestClusterJosqlQueryProcessor {
-  @Test(groups = {
-    "unitTest"
-  })
-  public void queryClusterDataSample() {
-    List<ZNRecord> liveInstances = new ArrayList<ZNRecord>();
-    Map<String, ZNRecord> liveInstanceMap = new HashMap<String, ZNRecord>();
-    List<String> instances = new ArrayList<String>();
-    for (int i = 0; i < 5; i++) {
-      String instance = "localhost_" + (12918 + i);
-      instances.add(instance);
-      ZNRecord metaData = new ZNRecord(instance);
-      metaData.setSimpleField(LiveInstanceProperty.SESSION_ID.toString(), UUID.randomUUID()
-          .toString());
-      metaData.setSimpleField("SCN", "" + (10 - i));
-      liveInstances.add(metaData);
-      liveInstanceMap.put(instance, metaData);
-    }
-
-    // liveInstances.remove(0);
-    ZNRecord externalView =
-        DefaultTwoStateStrategy.calculateIdealState(instances, 21, 3, "TestDB", "MASTER", "SLAVE");
-    Criteria criteria = new Criteria();
-    criteria.setInstanceName("%");
-    criteria.setResource("TestDB");
-    criteria.setRecipientInstanceType(InstanceType.PARTICIPANT);
-    criteria.setPartition("TestDB_2%");
-    criteria.setPartitionState("SLAVE");
-
-    String josql =
-        " SELECT DISTINCT mapSubKey AS 'subkey', mapValue AS 'mapValue' , getSimpleFieldValue(getZNRecordFromMap(:LIVEINSTANCESMAP, mapSubKey), 'SCN') AS 'SCN'"
-            + " FROM org.apache.helix.josql.ZNRecordRow "
-            + " WHERE mapKey LIKE 'TestDB_2%' "
-            + " AND mapSubKey LIKE '%' "
-            + " AND mapValue LIKE 'SLAVE' "
-            + " AND mapSubKey IN ((SELECT [*]id FROM :LIVEINSTANCES)) "
-            + " ORDER BY parseInt(getSimpleFieldValue(getZNRecordFromMap(:LIVEINSTANCESMAP, mapSubKey), 'SCN'))";
-
-    Query josqlQuery = new Query();
-    josqlQuery.setVariable("LIVEINSTANCES", liveInstances);
-    josqlQuery.setVariable("LIVEINSTANCESMAP", liveInstanceMap);
-    josqlQuery.addFunctionHandler(new ZNRecordRow());
-    josqlQuery.addFunctionHandler(new ZNRecordJosqlFunctionHandler());
-    josqlQuery.addFunctionHandler(new Integer(0));
-    try {
-      josqlQuery.parse(josql);
-      QueryResults qr = josqlQuery.execute(ZNRecordRow.convertMapFields(externalView));
-      @SuppressWarnings({
-          "unchecked", "unused"
-      })
-      List<Object> result = qr.getResults();
-
-    } catch (QueryParseException e) {
-      e.printStackTrace();
-    } catch (QueryExecutionException e) {
-      e.printStackTrace();
-    }
-
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/b33e0b5a/helix-core/src/test/java/org/apache/helix/josql/TestJosqlProcessor.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/josql/TestJosqlProcessor.java b/helix-core/src/test/java/org/apache/helix/josql/TestJosqlProcessor.java
deleted file mode 100644
index 2aa4544..0000000
--- a/helix-core/src/test/java/org/apache/helix/josql/TestJosqlProcessor.java
+++ /dev/null
@@ -1,223 +0,0 @@
-package org.apache.helix.josql;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-
-import org.apache.helix.HelixException;
-import org.apache.helix.HelixManager;
-import org.apache.helix.TestHelper;
-import org.apache.helix.ZNRecord;
-import org.apache.helix.integration.ZkStandAloneCMTestBase;
-import org.apache.helix.model.LiveInstance.LiveInstanceProperty;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-public class TestJosqlProcessor extends ZkStandAloneCMTestBase {
-  @Test(groups = {
-    "integrationTest"
-  })
-  public void testJosqlQuery() throws Exception {
-    HelixManager manager = _participants[0];
-    // ((TestHelper.StartCMResult) (_startCMResultMap.values().toArray()[0]))._manager;
-
-    // Find the instance name that contains partition TestDB_2 and state is 'MASTER'
-    String SQL =
-        "SELECT id  "
-            + "FROM LIVEINSTANCES "
-            + "WHERE getMapFieldValue( getZNRecordFromMap(:IDEALSTATES , 'TestDB'), :partitionName, :_currObj.id)='MASTER'";
-    Map<String, Object> bindVariables = new HashMap<String, Object>();
-    bindVariables.put("partitionName", "TestDB_2");
-
-    ClusterJosqlQueryProcessor p = new ClusterJosqlQueryProcessor(manager);
-    List<Object> result = p.runJoSqlQuery(SQL, bindVariables, null);
-
-    Assert.assertEquals(result.size(), 1);
-    List<Object> firstList = (List<Object>) result.get(0);
-    Assert.assertTrue(((String) (firstList.get(0))).equalsIgnoreCase("localhost_12921"));
-
-    // Find the live instances names that hosts Partition TestDB_10 according to idealstate
-
-    SQL =
-        "SELECT id  "
-            + "FROM LIVEINSTANCES "
-            + "WHERE hasMapFieldKey( getZNRecordFromMap(:IDEALSTATES, 'TestDB'), :partitionName, :_currObj.id)='true'";
-    p = new ClusterJosqlQueryProcessor(manager);
-    bindVariables.put("partitionName", "TestDB_10");
-    result = p.runJoSqlQuery(SQL, bindVariables, null);
-
-    Assert.assertEquals(result.size(), 3);
-    Set<String> hosts = new HashSet<String>();
-    for (Object o : result) {
-      String val = (String) ((List<Object>) o).get(0);
-      hosts.add(val);
-    }
-    Assert.assertTrue(hosts.contains("localhost_12918"));
-    Assert.assertTrue(hosts.contains("localhost_12920"));
-    Assert.assertTrue(hosts.contains("localhost_12921"));
-
-    // Find the partitions on host localhost_12919 and is on MASTER state
-    SQL =
-        "SELECT id  "
-            + "FROM PARTITIONS "
-            + "WHERE getMapFieldValue( getZNRecordFromMap(:EXTERNALVIEW, 'TestDB'), id, :instanceName)='MASTER'";
-    p = new ClusterJosqlQueryProcessor(manager);
-    bindVariables.clear();
-    bindVariables.put("instanceName", "localhost_12919");
-    result = p.runJoSqlQuery(SQL, bindVariables, null);
-
-    Assert.assertEquals(result.size(), 4);
-    Set<String> partitions = new HashSet<String>();
-    for (Object o : result) {
-      String val = (String) ((List<Object>) o).get(0);
-      partitions.add(val);
-    }
-    Assert.assertTrue(partitions.contains("TestDB_6"));
-    Assert.assertTrue(partitions.contains("TestDB_7"));
-    Assert.assertTrue(partitions.contains("TestDB_9"));
-    Assert.assertTrue(partitions.contains("TestDB_14"));
-
-    // Find the partitions on host localhost_12919 and is on MASTER state
-    // Same as above but according to currentstates
-    SQL =
-        "SELECT id  "
-            + "FROM PARTITIONS "
-            + "WHERE getMapFieldValue( getZNRecordFromMap(:CURRENTSTATES, :instanceName, 'TestDB'), :_currObj.id, :mapFieldKey)=:partitionState";
-
-    p = new ClusterJosqlQueryProcessor(manager);
-    bindVariables.clear();
-    bindVariables.put("instanceName", "localhost_12919");
-    bindVariables.put("mapFieldKey", "CURRENT_STATE");
-    bindVariables.put("partitionState", "MASTER");
-
-    result = p.runJoSqlQuery(SQL, bindVariables, null);
-
-    Assert.assertEquals(result.size(), 4);
-    partitions.clear();
-    partitions = new HashSet<String>();
-    for (Object o : result) {
-      String val = (String) ((List<Object>) o).get(0);
-      partitions.add(val);
-    }
-    Assert.assertTrue(partitions.contains("TestDB_6"));
-    Assert.assertTrue(partitions.contains("TestDB_7"));
-    Assert.assertTrue(partitions.contains("TestDB_9"));
-    Assert.assertTrue(partitions.contains("TestDB_14"));
-
-    // get node name that hosts a certain partition with certain state
-
-    SQL =
-        "SELECT id  "
-            + "FROM LIVEINSTANCES "
-            + "WHERE getMapFieldValue( getZNRecordFromMap(:CURRENTSTATES, id, 'TestDB'), :partitionName, :mapFieldKey)=:partitionState";
-
-    p = new ClusterJosqlQueryProcessor(manager);
-    bindVariables.clear();
-    bindVariables.put("partitionName", "TestDB_8");
-    bindVariables.put("mapFieldKey", "CURRENT_STATE");
-    bindVariables.put("partitionState", "SLAVE");
-
-    result = p.runJoSqlQuery(SQL, bindVariables, null);
-
-    Assert.assertEquals(result.size(), 2);
-    partitions.clear();
-    partitions = new HashSet<String>();
-    for (Object o : result) {
-      String val = (String) ((List<Object>) o).get(0);
-      partitions.add(val);
-    }
-    Assert.assertTrue(partitions.contains("localhost_12918"));
-    Assert.assertTrue(partitions.contains("localhost_12922"));
-  }
-
-  @Test(groups = {
-    "unitTest"
-  })
-  public void parseFromTarget() {
-    ClusterJosqlQueryProcessor p = new ClusterJosqlQueryProcessor(null);
-    String sql = "SELECT id  " + "FROM LIVEINSTANCES ";
-    String from = p.parseFromTarget(sql);
-    Assert.assertTrue(from.equals("LIVEINSTANCES"));
-
-    sql = "SELECT id      " + "FROM    LIVEINSTANCES  WHERE 1=2";
-
-    from = p.parseFromTarget(sql);
-    Assert.assertTrue(from.equals("LIVEINSTANCES"));
-
-    sql = "SELECT id      " + "FROM LIVEINSTANCES";
-
-    from = p.parseFromTarget(sql);
-    Assert.assertTrue(from.equals("LIVEINSTANCES"));
-
-    sql = "SELECT id      " + " LIVEINSTANCES where tt=00";
-    boolean exceptionThrown = false;
-    try {
-      from = p.parseFromTarget(sql);
-    } catch (HelixException e) {
-      exceptionThrown = true;
-    }
-    Assert.assertTrue(exceptionThrown);
-  }
-
-  @Test(groups = ("unitTest"))
-  public void testOrderby() throws Exception {
-    HelixManager manager = _participants[0];
-    // ((TestHelper.StartCMResult) (_startCMResultMap.values().toArray()[0]))._manager;
-
-    Map<String, ZNRecord> scnMap = new HashMap<String, ZNRecord>();
-    for (int i = 0; i < NODE_NR; i++) {
-      String instance = "localhost_" + (12918 + i);
-      ZNRecord metaData = new ZNRecord(instance);
-      metaData.setSimpleField(LiveInstanceProperty.SESSION_ID.toString(), UUID.randomUUID()
-          .toString());
-      metaData.setMapField("SCN", new HashMap<String, String>());
-      for (int j = 0; j < _PARTITIONS; j++) {
-        metaData.getMapField("SCN").put(TEST_DB + "_" + j, "" + i);
-      }
-      scnMap.put(instance, metaData);
-    }
-    Map<String, Object> bindVariables = new HashMap<String, Object>();
-    bindVariables.put("scnMap", scnMap);
-    String SQL =
-        " SELECT DISTINCT mapSubKey AS 'subkey', mapValue AS 'mapValue' , getMapFieldValue(getZNRecordFromMap(:scnMap, mapSubKey), 'SCN', mapKey) AS 'SCN'"
-            + " FROM EXTERNALVIEW.Table "
-            + " WHERE mapKey LIKE 'TestDB_1' "
-            + " AND mapSubKey LIKE '%' "
-            + " AND mapValue LIKE 'SLAVE' "
-            + " AND mapSubKey IN ((SELECT [*]id FROM :LIVEINSTANCES)) "
-            + " ORDER BY parseInt(getMapFieldValue(getZNRecordFromMap(:scnMap, mapSubKey), 'SCN', mapKey))";
-
-    ClusterJosqlQueryProcessor p = new ClusterJosqlQueryProcessor(manager);
-    List<Object> result = p.runJoSqlQuery(SQL, bindVariables, null);
-    int prevSCN = -1;
-    for (Object row : result) {
-      List<String> stringRow = (List<String>) row;
-      Assert.assertTrue(stringRow.get(1).equals("SLAVE"));
-      int scn = Integer.parseInt(stringRow.get(2));
-      Assert.assertTrue(scn > prevSCN);
-      prevSCN = scn;
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/b33e0b5a/helix-core/src/test/java/org/apache/helix/messaging/TestDefaultMessagingService.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/messaging/TestDefaultMessagingService.java b/helix-core/src/test/java/org/apache/helix/messaging/TestDefaultMessagingService.java
index 11bdeb5..e82a4a8 100644
--- a/helix-core/src/test/java/org/apache/helix/messaging/TestDefaultMessagingService.java
+++ b/helix-core/src/test/java/org/apache/helix/messaging/TestDefaultMessagingService.java
@@ -181,30 +181,63 @@ public class TestDefaultMessagingService {
     recipientCriteria.setSelfExcluded(false);
     AssertJUnit.assertEquals(1, svc.send(recipientCriteria, template));
 
+    // all instances, all partitions
     recipientCriteria.setSelfExcluded(false);
     recipientCriteria.setInstanceName("%");
     recipientCriteria.setResource("DB");
     recipientCriteria.setPartition("%");
     AssertJUnit.assertEquals(200, svc.send(recipientCriteria, template));
 
-    recipientCriteria.setSelfExcluded(true);
-    recipientCriteria.setInstanceName("%");
+    // all instances, all partitions, use * instead of %
+    recipientCriteria.setSelfExcluded(false);
+    recipientCriteria.setInstanceName("*");
+    recipientCriteria.setResource("DB");
+    recipientCriteria.setPartition("*");
+    AssertJUnit.assertEquals(200, svc.send(recipientCriteria, template));
+
+    // tail pattern
+    recipientCriteria.setSelfExcluded(false);
+    recipientCriteria.setInstanceName("localhost%");
     recipientCriteria.setResource("DB");
     recipientCriteria.setPartition("%");
-    AssertJUnit.assertEquals(159, svc.send(recipientCriteria, template));
+    AssertJUnit.assertEquals(200, svc.send(recipientCriteria, template));
 
+    // exclude this instance, send to all others for all partitions
     recipientCriteria.setSelfExcluded(true);
     recipientCriteria.setInstanceName("%");
     recipientCriteria.setResource("DB");
     recipientCriteria.setPartition("%");
     AssertJUnit.assertEquals(159, svc.send(recipientCriteria, template));
 
+    // single instance, all partitions
     recipientCriteria.setSelfExcluded(true);
     recipientCriteria.setInstanceName("localhost_12920");
     recipientCriteria.setResource("DB");
     recipientCriteria.setPartition("%");
     AssertJUnit.assertEquals(39, svc.send(recipientCriteria, template));
 
+    // single character wildcards
+    recipientCriteria.setSelfExcluded(true);
+    recipientCriteria.setInstanceName("l_calhost_12_20");
+    recipientCriteria.setResource("DB");
+    recipientCriteria.setPartition("%");
+    AssertJUnit.assertEquals(39, svc.send(recipientCriteria, template));
+
+    // head pattern
+    recipientCriteria.setSelfExcluded(true);
+    recipientCriteria.setInstanceName("%12920");
+    recipientCriteria.setResource("DB");
+    recipientCriteria.setPartition("%");
+    AssertJUnit.assertEquals(39, svc.send(recipientCriteria, template));
+
+    // middle pattern
+    recipientCriteria.setSelfExcluded(true);
+    recipientCriteria.setInstanceName("l%_12920");
+    recipientCriteria.setResource("DB");
+    recipientCriteria.setPartition("%");
+    AssertJUnit.assertEquals(39, svc.send(recipientCriteria, template));
+
+    // send to a controller
     recipientCriteria.setSelfExcluded(true);
     recipientCriteria.setInstanceName("localhost_12920");
     recipientCriteria.setRecipientInstanceType(InstanceType.CONTROLLER);

http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/b33e0b5a/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 010023c..5c17bd1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -251,11 +251,6 @@ under the License.
       <name>SnakeYAML repository</name>
       <url>http://oss.sonatype.org/content/groups/public/</url>
     </repository>
-    <repository>
-      <id>jboss-fs-public</id>
-      <name>JBoss FuseSource repository</name>
-      <url>http://repository.jboss.org/nexus/content/groups/fs-public/</url>
-    </repository>
   </repositories>