You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by yu...@apache.org on 2013/03/20 21:44:50 UTC

svn commit: r1459041 [4/18] - in /incubator/ambari/branches/branch-1.2: ./ ambari-agent/ ambari-agent/conf/unix/ ambari-agent/src/main/puppet/modules/hdp-ganglia/files/ ambari-agent/src/main/puppet/modules/hdp-ganglia/manifests/ ambari-agent/src/main/p...

Added: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/EqualsOperator.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/EqualsOperator.java?rev=1459041&view=auto
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/EqualsOperator.java (added)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/EqualsOperator.java Wed Mar 20 20:44:43 2013
@@ -0,0 +1,50 @@
+/**
+ * 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.
+ */
+
+package org.apache.ambari.server.api.predicate.operators;
+
+import org.apache.ambari.server.controller.predicate.EqualsPredicate;
+import org.apache.ambari.server.controller.spi.Predicate;
+
+/**
+ * Equals operator implementation.
+ */
+public class EqualsOperator extends AbstractOperator implements RelationalOperator {
+
+  /**
+   * Constructor.
+   */
+  public EqualsOperator() {
+    super(0);
+  }
+
+  @Override
+  public TYPE getType() {
+    return TYPE.EQUAL;
+  }
+
+  @Override
+  public Predicate toPredicate(String prop, String val) {
+    return new EqualsPredicate<String>(prop, val);
+  }
+
+  @Override
+  public String getName() {
+    return "EqualsOperator";
+  }
+}

Added: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/GreaterEqualsOperator.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/GreaterEqualsOperator.java?rev=1459041&view=auto
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/GreaterEqualsOperator.java (added)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/GreaterEqualsOperator.java Wed Mar 20 20:44:43 2013
@@ -0,0 +1,50 @@
+/**
+ * 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.
+ */
+
+package org.apache.ambari.server.api.predicate.operators;
+
+import org.apache.ambari.server.controller.predicate.GreaterEqualsPredicate;
+import org.apache.ambari.server.controller.spi.Predicate;
+
+/**
+ * Greater Than Or Equals operator implementation.
+ */
+public class GreaterEqualsOperator extends AbstractOperator implements RelationalOperator {
+
+  /**
+   * Constructor.
+   */
+  public GreaterEqualsOperator() {
+    super(0);
+  }
+
+  @Override
+  public TYPE getType() {
+    return TYPE.GREATER_EQUAL;
+  }
+
+  @Override
+  public Predicate toPredicate(String prop, String val) {
+    return new GreaterEqualsPredicate<String>(prop, val);
+  }
+
+  @Override
+  public String getName() {
+    return "GreaterEqualsOperator";
+  }
+}

Added: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/GreaterOperator.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/GreaterOperator.java?rev=1459041&view=auto
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/GreaterOperator.java (added)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/GreaterOperator.java Wed Mar 20 20:44:43 2013
@@ -0,0 +1,50 @@
+/**
+ * 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.
+ */
+
+package org.apache.ambari.server.api.predicate.operators;
+
+import org.apache.ambari.server.controller.predicate.GreaterPredicate;
+import org.apache.ambari.server.controller.spi.Predicate;
+
+/**
+ * Greater Than operator implementation.
+ */
+public class GreaterOperator extends AbstractOperator implements RelationalOperator {
+
+  /**
+   * Constructor.
+   */
+  public GreaterOperator() {
+    super(0);
+  }
+
+  @Override
+  public TYPE getType() {
+    return TYPE.GREATER;
+  }
+
+  @Override
+  public Predicate toPredicate(String prop, String val) {
+    return new GreaterPredicate<String>(prop, val);
+  }
+
+  @Override
+  public String getName() {
+    return "GreaterOperator";
+  }
+}

Added: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/InOperator.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/InOperator.java?rev=1459041&view=auto
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/InOperator.java (added)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/InOperator.java Wed Mar 20 20:44:43 2013
@@ -0,0 +1,54 @@
+package org.apache.ambari.server.api.predicate.operators;
+
+import org.apache.ambari.server.api.predicate.InvalidQueryException;
+import org.apache.ambari.server.controller.predicate.BasePredicate;
+import org.apache.ambari.server.controller.predicate.EqualsPredicate;
+import org.apache.ambari.server.controller.predicate.OrPredicate;
+import org.apache.ambari.server.controller.spi.Predicate;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * IN relational operator.
+ * This is a binary operator which takes a comma delimited right operand and
+ * creates equals predicates with the left operand and each right operand token.
+ * The equals predicates are combined with an OR predicate.
+ *
+ */
+public class InOperator extends AbstractOperator implements RelationalOperator {
+
+  public InOperator() {
+    super(0);
+  }
+
+  @Override
+  public String getName() {
+    return "InOperator";
+  }
+
+  @Override
+  public Predicate toPredicate(String prop, String val) throws InvalidQueryException {
+
+    if (val == null) {
+      throw new InvalidQueryException("IN operator is missing a required right operand.");
+    }
+
+    String[] tokens = val.split(",");
+    List<EqualsPredicate> listPredicates = new ArrayList<EqualsPredicate>();
+    for (String token : tokens) {
+      listPredicates.add(new EqualsPredicate(prop, token.trim()));
+    }
+    return listPredicates.size() == 1 ? listPredicates.get(0) :
+        buildOrPredicate(listPredicates);
+  }
+
+  private OrPredicate buildOrPredicate(List<EqualsPredicate> listPredicates) {
+    return new OrPredicate(listPredicates.toArray(new BasePredicate[listPredicates.size()]));
+  }
+
+  @Override
+  public TYPE getType() {
+    return TYPE.IN;
+  }
+}

Added: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/IsEmptyOperator.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/IsEmptyOperator.java?rev=1459041&view=auto
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/IsEmptyOperator.java (added)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/IsEmptyOperator.java Wed Mar 20 20:44:43 2013
@@ -0,0 +1,51 @@
+/**
+ * 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.
+ */
+
+package org.apache.ambari.server.api.predicate.operators;
+
+import org.apache.ambari.server.api.predicate.InvalidQueryException;
+import org.apache.ambari.server.controller.predicate.CategoryIsEmptyPredicate;
+import org.apache.ambari.server.controller.spi.Predicate;
+
+/**
+ * Operator that is used to determine if a category is empty, meaning that it doesn't
+ * contain any properties.
+ */
+public class IsEmptyOperator extends AbstractOperator implements RelationalOperator {
+  public IsEmptyOperator() {
+    super(0);
+  }
+
+  @Override
+  public String getName() {
+    return "IsEmptyOperator";
+  }
+
+  @Override
+  public Predicate toPredicate(String prop, String val) throws InvalidQueryException {
+    if (val != null) {
+      throw new InvalidQueryException("'isEmpty' operator shouldn't have a right operand but one exists: " + val);
+    }
+    return new CategoryIsEmptyPredicate(prop);
+  }
+
+  @Override
+  public TYPE getType() {
+    return TYPE.IS_EMPTY;
+  }
+}

Added: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/LessEqualsOperator.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/LessEqualsOperator.java?rev=1459041&view=auto
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/LessEqualsOperator.java (added)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/LessEqualsOperator.java Wed Mar 20 20:44:43 2013
@@ -0,0 +1,50 @@
+/**
+ * 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.
+ */
+
+package org.apache.ambari.server.api.predicate.operators;
+
+import org.apache.ambari.server.controller.predicate.LessEqualsPredicate;
+import org.apache.ambari.server.controller.spi.Predicate;
+
+/**
+ * Less Than or Equals operator implementation.
+ */
+public class LessEqualsOperator extends AbstractOperator implements RelationalOperator {
+
+  /**
+   * Constructor.
+   */
+  public LessEqualsOperator() {
+    super(0);
+  }
+
+  @Override
+  public TYPE getType() {
+    return TYPE.LESS_EQUAL;
+  }
+
+  @Override
+  public Predicate toPredicate(String prop, String val) {
+    return new LessEqualsPredicate<String>(prop, val);
+  }
+
+  @Override
+  public String getName() {
+    return "LessEqualsOperator";
+  }
+}

Added: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/LessOperator.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/LessOperator.java?rev=1459041&view=auto
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/LessOperator.java (added)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/LessOperator.java Wed Mar 20 20:44:43 2013
@@ -0,0 +1,50 @@
+/**
+ * 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.
+ */
+
+package org.apache.ambari.server.api.predicate.operators;
+
+import org.apache.ambari.server.controller.predicate.LessPredicate;
+import org.apache.ambari.server.controller.spi.Predicate;
+
+/**
+ * Less Than operator implementation.
+ */
+public class LessOperator extends AbstractOperator implements RelationalOperator {
+
+  /**
+   * Constructor.
+   */
+  public LessOperator() {
+    super(0);
+  }
+
+  @Override
+  public TYPE getType() {
+    return TYPE.LESS;
+  }
+
+  @Override
+  public Predicate toPredicate(String prop, String val) {
+    return new LessPredicate<String>(prop, val);
+  }
+
+  @Override
+  public String getName() {
+    return "LessOperator";
+  }
+}

Added: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/LogicalOperator.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/LogicalOperator.java?rev=1459041&view=auto
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/LogicalOperator.java (added)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/LogicalOperator.java Wed Mar 20 20:44:43 2013
@@ -0,0 +1,35 @@
+/**
+ * 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.
+ */
+
+package org.apache.ambari.server.api.predicate.operators;
+
+import org.apache.ambari.server.controller.spi.Predicate;
+
+/**
+ * Logical operator external representation.
+ */
+public interface LogicalOperator extends Operator {
+  /**
+   * Create a predicate for this logical operator.
+   *
+   * @param left   left operand
+   * @param right  right operand
+   * @return a predicate instance for this operator
+   */
+  public Predicate toPredicate(Predicate left, Predicate right);
+}

Added: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/LogicalOperatorFactory.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/LogicalOperatorFactory.java?rev=1459041&view=auto
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/LogicalOperatorFactory.java (added)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/LogicalOperatorFactory.java Wed Mar 20 20:44:43 2013
@@ -0,0 +1,48 @@
+/**
+ * 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.
+ */
+
+package org.apache.ambari.server.api.predicate.operators;
+
+import org.apache.ambari.server.api.predicate.InvalidQueryException;
+
+/**
+ * Factory of Logical Operators.
+ */
+public class LogicalOperatorFactory {
+  /**
+   * Creates a logical operator based on the operator token.
+   *
+   * @param operator      string representation of operator
+   * @param ctxPrecedence precedence value of current context
+   *
+   * @return a logical operator instance
+   * @throws InvalidQueryException if the operator string is invalid
+   */
+  public static LogicalOperator createOperator(String operator, int ctxPrecedence)
+      throws InvalidQueryException {
+    if ("&".equals(operator)) {
+      return new AndOperator(ctxPrecedence);
+    } else if ("|".equals(operator)) {
+      return new OrOperator(ctxPrecedence);
+    } else if ("!".equals(operator)) {
+      return new NotOperator(ctxPrecedence);
+    } else {
+      throw new RuntimeException("Invalid Logical Operator Type: " + operator);
+    }
+  }
+}

Added: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/NotEqualsOperator.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/NotEqualsOperator.java?rev=1459041&view=auto
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/NotEqualsOperator.java (added)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/NotEqualsOperator.java Wed Mar 20 20:44:43 2013
@@ -0,0 +1,51 @@
+/**
+ * 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.
+ */
+
+package org.apache.ambari.server.api.predicate.operators;
+
+import org.apache.ambari.server.controller.predicate.EqualsPredicate;
+import org.apache.ambari.server.controller.predicate.NotPredicate;
+import org.apache.ambari.server.controller.spi.Predicate;
+
+/**
+ * Not Equals relational operator implementation.
+ */
+public class NotEqualsOperator extends AbstractOperator implements RelationalOperator {
+
+  /**
+   * Constructor.
+   */
+  public NotEqualsOperator() {
+    super(0);
+  }
+
+  @Override
+  public TYPE getType() {
+    return TYPE.NOT_EQUAL;
+  }
+
+  @Override
+  public Predicate toPredicate(String prop, String val) {
+    return new NotPredicate(new EqualsPredicate<String>(prop, val));
+  }
+
+  @Override
+  public String getName() {
+    return "NotEqualsOperator";
+  }
+}

Added: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/NotOperator.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/NotOperator.java?rev=1459041&view=auto
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/NotOperator.java (added)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/NotOperator.java Wed Mar 20 20:44:43 2013
@@ -0,0 +1,63 @@
+/**
+ * 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.
+ */
+
+package org.apache.ambari.server.api.predicate.operators;
+
+import org.apache.ambari.server.controller.predicate.BasePredicate;
+import org.apache.ambari.server.controller.predicate.NotPredicate;
+import org.apache.ambari.server.controller.spi.Predicate;
+
+/**
+ * Not unary operator implementation.
+ */
+public class NotOperator extends AbstractOperator implements LogicalOperator {
+
+  /**
+   * Constructor.
+   *
+   * @param ctxPrecedence  the precedence value of the current context
+   */
+  public NotOperator(int ctxPrecedence) {
+    super(ctxPrecedence);
+  }
+
+  @Override
+  public TYPE getType() {
+    return TYPE.NOT;
+  }
+
+  @Override
+  public String getName() {
+    return "NotOperator";
+  }
+
+  @Override
+  public int getBasePrecedence() {
+    return 3;
+  }
+
+  @Override
+  public Predicate toPredicate(Predicate left, Predicate right) {
+    return new NotPredicate((BasePredicate) right);
+  }
+
+  @Override
+  public String toString() {
+    return getName() + "[precedence=" + getPrecedence() + "]";
+  }
+}

Added: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/Operator.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/Operator.java?rev=1459041&view=auto
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/Operator.java (added)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/Operator.java Wed Mar 20 20:44:43 2013
@@ -0,0 +1,63 @@
+/**
+ * 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.
+ */
+
+package org.apache.ambari.server.api.predicate.operators;
+
+/**
+ * Operator representation.
+ */
+public interface Operator {
+
+  /**
+   * Operator types.
+   */
+  public enum TYPE {
+    LESS,
+    LESS_EQUAL,
+    GREATER,
+    GREATER_EQUAL,
+    EQUAL,
+    NOT_EQUAL,
+    AND,
+    OR,
+    NOT,
+    IN,
+    IS_EMPTY
+  }
+
+  /**
+   * The highest base operator precedence level.
+   */
+  public static final int MAX_OP_PRECEDENCE = 3;
+
+  /**
+   * Get the operator type.
+   *
+   * @return the operator type
+   */
+  public TYPE getType();
+
+  /**
+   * Obtain the precedence of the operator.
+   * This value is calculated based on the operators base precedence and the context of the
+   * surrounding expressions.  Higher precedence values have higher precedence.
+   *
+   * @return  the precedence of this operator in it's current context
+   */
+  public int getPrecedence();
+}

Added: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/OrOperator.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/OrOperator.java?rev=1459041&view=auto
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/OrOperator.java (added)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/OrOperator.java Wed Mar 20 20:44:43 2013
@@ -0,0 +1,64 @@
+/**
+ * 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.
+ */
+
+package org.apache.ambari.server.api.predicate.operators;
+
+import org.apache.ambari.server.controller.predicate.BasePredicate;
+import org.apache.ambari.server.controller.predicate.OrPredicate;
+import org.apache.ambari.server.controller.spi.Predicate;
+
+/**
+ * Or operator implementation.
+ */
+public class OrOperator extends AbstractOperator implements LogicalOperator {
+
+  /**
+   * Constructor.
+   *
+   * @param ctxPrecedence  precedence value for the current context
+   */
+  public OrOperator(int ctxPrecedence) {
+    super(ctxPrecedence);
+  }
+
+  @Override
+  public TYPE getType() {
+    return TYPE.OR;
+  }
+
+  @Override
+  public String getName() {
+    return "OrOperator";
+  }
+
+  @Override
+  public int getBasePrecedence() {
+    return 1;
+  }
+
+  @Override
+  public Predicate toPredicate(Predicate left, Predicate right) {
+    //todo: refactor to remove down casts
+    return new OrPredicate((BasePredicate) left, (BasePredicate) right);
+  }
+
+  @Override
+  public String toString() {
+    return getName() + "[precedence=" + getPrecedence() + "]";
+  }
+}

Added: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/RelationalOperator.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/RelationalOperator.java?rev=1459041&view=auto
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/RelationalOperator.java (added)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/RelationalOperator.java Wed Mar 20 20:44:43 2013
@@ -0,0 +1,37 @@
+/**
+ * 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.
+ */
+
+package org.apache.ambari.server.api.predicate.operators;
+
+import org.apache.ambari.server.api.predicate.InvalidQueryException;
+import org.apache.ambari.server.controller.spi.Predicate;
+
+/**
+ * Relational operator external representation.
+ */
+public interface RelationalOperator extends Operator {
+  /**
+   * Create a predicate for this relational operator.
+   *
+   * @param prop  left operand
+   * @param val   right operand
+   * @return  a predicate instance for this operator.
+   * @throws  InvalidQueryException if unable to build the predicate because of invalid operands
+   */
+  public Predicate toPredicate(String prop, String val) throws InvalidQueryException;
+}

Added: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/RelationalOperatorFactory.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/RelationalOperatorFactory.java?rev=1459041&view=auto
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/RelationalOperatorFactory.java (added)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/predicate/operators/RelationalOperatorFactory.java Wed Mar 20 20:44:43 2013
@@ -0,0 +1,57 @@
+/**
+ * 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.
+ */
+
+package org.apache.ambari.server.api.predicate.operators;
+
+import org.apache.ambari.server.api.predicate.InvalidQueryException;
+
+/**
+ * Factory of relational operators.
+ */
+public class RelationalOperatorFactory {
+  /**
+   * Create a relational operator based on the string representation
+   * of the operator.
+   *
+   * @param operator  the string representation of the operator
+   *
+   * @return relational operator for the given string
+   * @throws InvalidQueryException if an invalid operator is passed in
+   */
+  public static RelationalOperator createOperator(String operator) throws InvalidQueryException {
+    if ("!=".equals(operator)) {
+      return new NotEqualsOperator();
+    } else if ("=".equals(operator)) {
+      return new EqualsOperator();
+    } else if ("<=".equals(operator)) {
+      return new LessEqualsOperator();
+    } else if ("<".equals(operator)) {
+      return new LessOperator();
+    } else if (">=".equals(operator)) {
+      return new GreaterEqualsOperator();
+    } else if (">".equals(operator)) {
+      return new GreaterOperator();
+    } else if (".in(".equals(operator)) {
+      return new InOperator();
+    } else if (".isEmpty(".equals(operator)) {
+      return new IsEmptyOperator();
+    } else {
+      throw new RuntimeException("Invalid Operator Type: " + operator);
+    }
+  }
+}

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/query/Query.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/query/Query.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/query/Query.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/query/Query.java Wed Mar 20 20:44:43 2013
@@ -21,7 +21,6 @@ package org.apache.ambari.server.api.que
 import org.apache.ambari.server.api.services.Result;
 import org.apache.ambari.server.controller.spi.*;
 
-import java.util.Map;
 import java.util.Set;
 
 
@@ -41,13 +40,13 @@ public interface Query {
   public void addProperty(String group, String property, TemporalInfo temporalInfo);
 
   /**
-   * Add a property to the query.
+   * Add a local (not sub-resource) property to the query.
    * This is the select portion of the query.
    *
    * @param property the property id which contains the group, property name
    *                 and whether the property is temporal
    */
-  public void addProperty(String property);
+  public void addLocalProperty(String property);
 
   /**
    * Obtain the properties of the query.
@@ -56,7 +55,7 @@ public interface Query {
    *
    * @return the query properties
    */
-  public Map<String, Set<String>> getProperties();
+  public Set<String> getProperties();
 
   /**
    * Execute the query.

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/query/QueryImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/query/QueryImpl.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/query/QueryImpl.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/query/QueryImpl.java Wed Mar 20 20:44:43 2013
@@ -20,7 +20,6 @@ package org.apache.ambari.server.api.que
 
 import org.apache.ambari.server.api.resources.ResourceInstance;
 import org.apache.ambari.server.api.services.ResultImpl;
-import org.apache.ambari.server.api.util.TreeNodeImpl;
 import org.apache.ambari.server.controller.utilities.ClusterControllerHelper;
 import org.apache.ambari.server.controller.utilities.PropertyHelper;
 import org.apache.ambari.server.controller.predicate.AndPredicate;
@@ -47,7 +46,12 @@ public class QueryImpl implements Query 
   /**
    * Properties of the query which make up the select portion of the query.
    */
-  private Map<String, Set<String>> m_mapQueryProperties = new HashMap<String, Set<String>>();
+  private Set<String> m_setQueryProperties = new HashSet<String>();
+
+  /**
+   * Indicates that the query should include all available properties.
+   */
+  private boolean allProperties = false;
 
   /**
    * Map that associates each property set on the query to temporal data.
@@ -60,16 +64,6 @@ public class QueryImpl implements Query 
   private Map<String, TemporalInfo> m_mapCategoryTemporalInfo = new HashMap<String, TemporalInfo>();
 
   /**
-   * All properties that are available for the resource.
-   */
-  private Map<String, Set<String>> m_mapAllProperties;
-
-  /**
-   * Tree index of m_mapAllProperties.  Used to match sub-categories.
-   */
-  TreeNode<Set<String>> m_treeAllProperties = new TreeNodeImpl<Set<String>>(null, new HashSet<String>(), null);
-
-  /**
    * Sub-resources of the resource which is being operated on.
    */
   private Map<String, ResourceInstance> m_mapSubResources = new HashMap<String, ResourceInstance>();
@@ -92,43 +86,27 @@ public class QueryImpl implements Query 
    */
   public QueryImpl(ResourceInstance resource) {
     m_resource = resource;
-    m_mapAllProperties = Collections.unmodifiableMap(getClusterController().
-        getSchema(resource.getResourceDefinition().getType()).getCategoryProperties());
-    buildAllPropertiesTree();
   }
 
   @Override
-  //todo: consider requiring a path and a property.  For categories the property name '*' could be used.
-  public void addProperty(String category, String property, TemporalInfo temporalInfo) {    
-    if (category == null && property.equals("*")) {
+  public void addProperty(String category, String name, TemporalInfo temporalInfo) {
+    if (category == null && name.equals("*")) {
       // wildcard
       addAllProperties(temporalInfo);
-    } else if (m_mapAllProperties.containsKey(category) && m_mapAllProperties.get(category).contains(property)) {
-      // local property
-      Set<String> setProps = m_mapQueryProperties.get(category);
-      if (setProps == null) {
-        setProps = new HashSet<String>();
-        m_mapQueryProperties.put(category, setProps);
-      }
-      setProps.add(property);
-      if (temporalInfo != null) {
-        m_mapPropertyTemporalInfo.put(PropertyHelper.getPropertyId(category, property), temporalInfo);
-      }
-    } else if (! addCategory(category, property, temporalInfo)){
-      // not a local category/property
-      boolean success = addPropertyToSubResource(category, property, temporalInfo);
-      if (!success) {
-        //TODO.  Remove when handled by back end
-        String propString = category == null ? property : property == null ? category : category + '/' + property;
-        throw new IllegalArgumentException("An invalid resource property was requested.  Resource: " +
-            m_resource.getResourceDefinition().getType() + ", Property: " + propString);
+    } else{
+      if (!addPropertyToSubResource(category, name, temporalInfo)){
+        String propertyId = PropertyHelper.getPropertyId(category, name.equals("*") ? null : name);
+        addLocalProperty(propertyId);
+        if (temporalInfo != null) {
+          m_mapCategoryTemporalInfo.put(propertyId, temporalInfo);
+        }
       }
     }
   }
 
   @Override
-  public void addProperty(String property) {
-    addProperty(PropertyHelper.getPropertyCategory(property), PropertyHelper.getPropertyName(property), null);
+  public void addLocalProperty(String property) {
+    m_setQueryProperties.add(property);
   }
 
   @Override
@@ -142,7 +120,7 @@ public class QueryImpl implements Query 
       result.getResultTree().setProperty("isCollection", "true");
     }
 
-    if (m_mapQueryProperties.isEmpty() && m_mapSubResources.isEmpty()) {
+    if (m_setQueryProperties.isEmpty() && m_mapSubResources.isEmpty()) {
       //Add sub resource properties for default case where no fields are specified.
       m_mapSubResources.putAll(m_resource.getSubResources());
     }
@@ -184,8 +162,8 @@ public class QueryImpl implements Query 
   }
 
   @Override
-  public Map<String, Set<String>> getProperties() {
-    return Collections.unmodifiableMap(m_mapQueryProperties);
+  public Set<String> getProperties() {
+    return Collections.unmodifiableSet(m_setQueryProperties);
   }
 
   @Override
@@ -200,7 +178,8 @@ public class QueryImpl implements Query 
   private void addCollectionProperties(Resource.Type resourceType) {
     Schema schema = getClusterController().getSchema(resourceType);
     // add pk
-    addProperty(schema.getKeyPropertyId(resourceType));
+    String property = schema.getKeyPropertyId(resourceType);
+    addProperty(PropertyHelper.getPropertyCategory(property), PropertyHelper.getPropertyName(property), null);
 
     for (Resource.Type type : m_resource.getIds().keySet()) {
       // add fk's
@@ -209,21 +188,15 @@ public class QueryImpl implements Query 
       //todo: component sub-resources.  Component will not have host fk.
       //todo: refactor so that null check is not required.
       if (keyPropertyId != null) {
-        addProperty(keyPropertyId);
+        addProperty(PropertyHelper.getPropertyCategory(keyPropertyId), PropertyHelper.getPropertyName(keyPropertyId), null);
       }
     }
   }
 
   private void addAllProperties(TemporalInfo temporalInfo) {
-    if (temporalInfo == null) {
-      m_mapQueryProperties.putAll(m_mapAllProperties);
-    } else {
-      for (Map.Entry<String, Set<String>> entry : m_mapAllProperties.entrySet()) {
-        String path = entry.getKey();
-        Set<String> setProps = entry.getValue();
-        m_mapQueryProperties.put(path, setProps);
-        m_mapCategoryTemporalInfo.put(path, temporalInfo);
-      }
+    allProperties = true;
+    if (temporalInfo != null) {
+      m_mapCategoryTemporalInfo.put(null, temporalInfo);
     }
 
     for (Map.Entry<String, ResourceInstance> entry : m_resource.getSubResources().entrySet()) {
@@ -234,39 +207,6 @@ public class QueryImpl implements Query 
     }
   }
 
-  private boolean addCategory(String category, String name, TemporalInfo temporalInfo) {
-    if (category != null) {
-      if (name != null && ! name.isEmpty()) {
-        name = category + '/' + name;
-      } else  {
-        name = category;
-      }
-    }
-    TreeNode<Set<String>> node = m_treeAllProperties.getChild(name);
-    if (node == null) {
-      return false;
-    }
-
-    addCategory(node, name, temporalInfo);
-    return true;
-  }
-
-  private void addCategory(TreeNode<Set<String>> node, String category, TemporalInfo temporalInfo) {
-    if (node != null) {
-      Set<String> setProps = m_mapQueryProperties.get(category);
-      if (setProps == null) {
-        setProps = new HashSet<String>();
-        m_mapQueryProperties.put(category, setProps);
-      }
-      setProps.addAll(node.getObject());
-      m_mapCategoryTemporalInfo.put(category, temporalInfo);
-
-      for (TreeNode<Set<String>> child : node.getChildren()) {
-        addCategory(child, category + '/' + child.getName(), temporalInfo);
-      }
-    }
-  }
-
   private boolean addPropertyToSubResource(String path, String property, TemporalInfo temporalInfo) {
     // cases:
     // - path is null, property is path (all sub-resource props will have a path)
@@ -336,51 +276,23 @@ public class QueryImpl implements Query 
     return predicate;
   }
 
-  private void buildAllPropertiesTree() {
-    // build index
-    for (String category : m_mapAllProperties.keySet()) {
-      TreeNode<Set<String>> node = m_treeAllProperties.getChild(category);
-      if (node == null) {
-        if (category == null) {
-          node = m_treeAllProperties.addChild(new HashSet<String>(), null);
-        } else {
-          String[] tokens = category.split("/");
-          node = m_treeAllProperties;
-          for (String t : tokens) {
-            TreeNode<Set<String>> child = node.getChild(t);
-            if (child == null) {
-              child = node.addChild(new HashSet<String>(), t);
-            }
-            node = child;
-          }
-        }
-      }
-      node.getObject().addAll(m_mapAllProperties.get(category));
-    }
-  }
-
   private Request createRequest() {
     Set<String> setProperties = new HashSet<String>();
 
-    Map<String, TemporalInfo> mapTemporalInfo = new HashMap<String, TemporalInfo>();
+    Map<String, TemporalInfo> mapTemporalInfo    = new HashMap<String, TemporalInfo>();
+    TemporalInfo              globalTemporalInfo = m_mapCategoryTemporalInfo.get(null);
 
-    for (Map.Entry<String, Set<String>> entry : m_mapQueryProperties.entrySet()) {
-      String group = entry.getKey();
-      for (String property : entry.getValue()) {
-        String propertyId = PropertyHelper.getPropertyId(group, property);
-
-        TemporalInfo temporalInfo = m_mapCategoryTemporalInfo.get(group);
-        if (temporalInfo == null) {
-          temporalInfo = m_mapPropertyTemporalInfo.get(propertyId);
-        }
-        if (temporalInfo != null) {
-          mapTemporalInfo.put(propertyId, temporalInfo);
-        }
-        setProperties.add(propertyId);
+    for (String group : m_setQueryProperties) {
+      TemporalInfo temporalInfo = m_mapCategoryTemporalInfo.get(group);
+      if (temporalInfo != null) {
+        mapTemporalInfo.put(group, temporalInfo);
+      } else if (globalTemporalInfo != null) {
+        mapTemporalInfo.put(group, globalTemporalInfo);
       }
+      setProperties.add(group);
     }
 
-    return PropertyHelper.getReadRequest(setProperties, mapTemporalInfo);
+    return PropertyHelper.getReadRequest(allProperties ? Collections.<String>emptySet() : setProperties, mapTemporalInfo);
   }
 
   private void setParentIdsOnSubResource(Resource resource, ResourceInstance r) {
@@ -416,10 +328,9 @@ public class QueryImpl implements Query 
 
     QueryImpl that = (QueryImpl) o;
 
-    return m_mapAllProperties.equals(that.m_mapAllProperties) &&
-           m_mapCategoryTemporalInfo.equals(that.m_mapCategoryTemporalInfo) &&
+    return m_mapCategoryTemporalInfo.equals(that.m_mapCategoryTemporalInfo) &&
            m_mapPropertyTemporalInfo.equals(that.m_mapPropertyTemporalInfo) &&
-           m_mapQueryProperties.equals(that.m_mapQueryProperties) &&
+           m_setQueryProperties.equals(that.m_setQueryProperties) &&
            m_mapSubResources.equals(that.m_mapSubResources) &&
            m_resource.equals(that.m_resource) &&
            m_userPredicate == null ? that.m_userPredicate == null : m_userPredicate.equals(that.m_userPredicate);
@@ -428,10 +339,9 @@ public class QueryImpl implements Query 
   @Override
   public int hashCode() {
     int result = m_resource.hashCode();
-    result = 31 * result + m_mapQueryProperties.hashCode();
+    result = 31 * result + m_setQueryProperties.hashCode();
     result = 31 * result + m_mapPropertyTemporalInfo.hashCode();
     result = 31 * result + m_mapCategoryTemporalInfo.hashCode();
-    result = 31 * result + m_mapAllProperties.hashCode();
     result = 31 * result + m_mapSubResources.hashCode();
     result = 31 * result + (m_userPredicate != null ? m_userPredicate.hashCode() : 0);
     return result;

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceImpl.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceImpl.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/resources/ResourceInstanceImpl.java Wed Mar 20 20:44:43 2013
@@ -110,11 +110,11 @@ public class ResourceInstanceImpl implem
         ResourceInstance resource = m_resourceFactory.createResource(subResDef.getType(), getIds());
 
         // ensure pk is returned
-        resource.getQuery().addProperty(m_controller.getSchema(
+        resource.getQuery().addLocalProperty(m_controller.getSchema(
             subResDef.getType()).getKeyPropertyId(subResDef.getType()));
         // add additionally required fk properties
         for (Resource.Type fkType : subResDef.getAdditionalForeignKeys()) {
-          resource.getQuery().addProperty(m_controller.getSchema(subResDef.getType()).getKeyPropertyId(fkType));
+          resource.getQuery().addLocalProperty(m_controller.getSchema(subResDef.getType()).getKeyPropertyId(fkType));
         }
 
         String subResourceName = subResDef.isCollection() ? resource.getResourceDefinition().getPluralName() :

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/services/BaseRequest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/services/BaseRequest.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/services/BaseRequest.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/services/BaseRequest.java Wed Mar 20 20:44:43 2013
@@ -18,13 +18,14 @@
 
 package org.apache.ambari.server.api.services;
 
+import org.apache.ambari.server.api.predicate.InvalidQueryException;
+import org.apache.ambari.server.api.predicate.PredicateCompiler;
 import org.apache.ambari.server.api.resources.*;
 import org.apache.ambari.server.api.services.parsers.JsonPropertyParser;
 import org.apache.ambari.server.api.services.parsers.RequestBodyParser;
 import org.apache.ambari.server.api.services.serializers.JsonSerializer;
 import org.apache.ambari.server.api.services.serializers.ResultSerializer;
 import org.apache.ambari.server.controller.internal.TemporalInfoImpl;
-import org.apache.ambari.server.controller.predicate.*;
 import org.apache.ambari.server.controller.spi.Predicate;
 import org.apache.ambari.server.controller.spi.TemporalInfo;
 
@@ -58,11 +59,6 @@ public abstract class BaseRequest implem
 
 
   /**
-   * Predicate operators.
-   */
-  private Pattern m_pattern = Pattern.compile("!=|>=|<=|=|>|<");
-
-  /**
    * Associated resource definition
    */
   private ResourceInstance m_resource;
@@ -104,37 +100,12 @@ public abstract class BaseRequest implem
   }
 
   @Override
-  public Predicate getQueryPredicate() {
-    //todo: parse during init
-    //not using getQueryParameters because it assumes '=' operator
-    String uri = getURI();
-    int qsBegin = uri.indexOf("?");
-
-    if (qsBegin == -1) return null;
-
-    String[] tokens = uri.substring(qsBegin + 1).split("&");
-
-    Set<BasePredicate> setPredicates = new HashSet<BasePredicate>();
-    for (String outerToken : tokens) {
-      if (outerToken.startsWith("_=")) {
-        // NOTE: This is to enable UI to pass a _= parameter for unique query 
-        // string even though the backend doesnt need it.
-        continue;
-      }
-      
-      if (outerToken != null &&  !outerToken.startsWith("fields")) {
-        setPredicates.add(outerToken.contains("|") ?
-            handleOrPredicate(outerToken) : createPredicate(outerToken));
-      }
-    }
+  public Predicate getQueryPredicate() throws InvalidQueryException {
+    String uri     = getURI();
+    int    qsBegin = uri.indexOf("?");
 
-    if (setPredicates.size() == 1) {
-      return setPredicates.iterator().next();
-    } else if (setPredicates.size() > 1) {
-      return new AndPredicate(setPredicates.toArray(new BasePredicate[setPredicates.size()]));
-    } else {
-      return null;
-    }
+    return (qsBegin == -1) ? null :
+        getPredicateCompiler().compile(uri.substring(qsBegin + 1));
   }
 
   @Override
@@ -205,43 +176,11 @@ public abstract class BaseRequest implem
     return new ResultPostProcessorImpl(this);
   }
 
-  private BasePredicate createPredicate(String token) {
-
-    Matcher m = m_pattern.matcher(token);
-    m.find();
-
-    String propertyId = token.substring(0, m.start());
-    String     value      = token.substring(m.end());
-    String     operator   = m.group();
-
-    if (operator.equals("=")) {
-      return new EqualsPredicate<String>(propertyId, value);
-    } else if (operator.equals("!=")) {
-      return new NotPredicate(new EqualsPredicate<String>(propertyId, value));
-    } else if (operator.equals("<")) {
-      return new LessPredicate<String>(propertyId, value);
-    } else if (operator.equals(">"))  {
-      return new GreaterPredicate<String>(propertyId, value);
-    } else if (operator.equals("<=")) {
-      return new LessEqualsPredicate<String>(propertyId, value);
-    } else if (operator.equals(">=")) {
-      return new GreaterEqualsPredicate<String>(propertyId, value);
-    } else {
-      throw new RuntimeException("Unknown operator provided in predicate: " + operator);
-    }
-  }
-
-  private BasePredicate handleOrPredicate(String predicate) {
-    Set<BasePredicate> setPredicates = new HashSet<BasePredicate>();
-    String[] tokens = predicate.split("\\|");
-    for (String tok : tokens) {
-      setPredicates.add(createPredicate(tok));
-    }
-
-    return new OrPredicate(setPredicates.toArray(new BasePredicate[setPredicates.size()]));
-  }
-
   protected RequestBodyParser getHttpBodyParser() {
     return new JsonPropertyParser();
   }
+
+  protected PredicateCompiler getPredicateCompiler() {
+    return new PredicateCompiler();
+  }
 }

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/services/Request.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/services/Request.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/services/Request.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/api/services/Request.java Wed Mar 20 20:44:43 2013
@@ -18,6 +18,7 @@
 
 package org.apache.ambari.server.api.services;
 
+import org.apache.ambari.server.api.predicate.InvalidQueryException;
 import org.apache.ambari.server.api.resources.ResourceDefinition;
 import org.apache.ambari.server.api.resources.ResourceInstance;
 import org.apache.ambari.server.api.services.serializers.ResultSerializer;
@@ -79,8 +80,9 @@ public interface Request {
    * such as 'AND'.
    *
    * @return the user defined predicate
+   * @throws InvalidQueryException if the query syntax is invalid
    */
-  public Predicate getQueryPredicate();
+  public Predicate getQueryPredicate() throws InvalidQueryException;
 
   /**
    * Obtain the partial response fields and associated temporal information which were provided

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java Wed Mar 20 20:44:43 2013
@@ -109,6 +109,10 @@ public class Configuration {
   public static final String SRVR_HOSTS_MAPPING = 
       "server.hosts.mapping";
 
+  public static final String SSL_TRUSTSTORE_PATH_KEY = "ssl.trustStore.path";
+  public static final String SSL_TRUSTSTORE_PASSWORD_KEY = "ssl.trustStore.password";
+  public static final String SSL_TRUSTSTORE_TYPE_KEY = "ssl.trustStore.type";
+
   private static final String SRVR_KSTR_DIR_DEFAULT = ".";
   public static final String SRVR_CRT_NAME_DEFAULT = "ca.crt";
   public static final String SRVR_KEY_NAME_DEFAULT = "ca.key";
@@ -209,6 +213,23 @@ public class Configuration {
       }
     }
     configsMap.put(SRVR_CRT_PASS_KEY, randStr);
+
+    loadSSLParams();
+  }
+
+  /**
+   * Loads trusted certificates store properties
+   */
+  private void loadSSLParams(){
+    if (properties.getProperty(SSL_TRUSTSTORE_PATH_KEY) != null) {
+      System.setProperty("javax.net.ssl.trustStore", properties.getProperty(SSL_TRUSTSTORE_PATH_KEY));
+    }
+    if (properties.getProperty(SSL_TRUSTSTORE_PASSWORD_KEY) != null) {
+      System.setProperty("javax.net.ssl.trustStorePassword", properties.getProperty(SSL_TRUSTSTORE_PASSWORD_KEY));
+    }
+    if (properties.getProperty(SSL_TRUSTSTORE_TYPE_KEY) != null) {
+      System.setProperty("javax.net.ssl.trustStoreType", properties.getProperty(SSL_TRUSTSTORE_TYPE_KEY));
+    }
   }
 
 

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java Wed Mar 20 20:44:43 2013
@@ -1151,7 +1151,12 @@ public class AmbariManagementControllerI
       hosts = clusters.getHosts();
     } else {
       hosts = new ArrayList<Host>();
-      hosts.add(clusters.getHost(request.getHostname()));
+      try {
+        hosts.add(clusters.getHost(request.getHostname()));
+      } catch (HostNotFoundException e) {
+        // add cluster name
+        throw new HostNotFoundException(clusterName, hostName);
+      }
     }
 
     for (Host h : hosts) {
@@ -1161,7 +1166,7 @@ public class AmbariManagementControllerI
           r.setClusterName(clusterName);
           response.add(r);
         } else if (hostName != null) {
-          throw new HostNotFoundException(hostName);
+          throw new HostNotFoundException(clusterName, hostName);
         }
       } else {
         HostResponse r = h.convertToResponse();

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java Wed Mar 20 20:44:43 2013
@@ -214,7 +214,8 @@ public class AmbariServer {
       // sslConnectorOneWay.setNeedClientAuth(false);
       SslSelectChannelConnector sslConnectorOneWay = new SslSelectChannelConnector(contextFactory);
       sslConnectorOneWay.setPort(AGENT_ONE_WAY_AUTH);
-
+      sslConnectorOneWay.setAcceptors(2);
+      sslConnectorTwoWay.setAcceptors(2);
       serverForAgent.setConnectors(new Connector[]{ sslConnectorOneWay, sslConnectorTwoWay});
 
       ServletHolder sh = new ServletHolder(ServletContainer.class);

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java Wed Mar 20 20:44:43 2013
@@ -17,17 +17,15 @@
  */
 
 package org.apache.ambari.server.controller;
+
 import com.google.gson.Gson;
 import com.google.inject.Scopes;
 import com.google.inject.assistedinject.FactoryModuleBuilder;
-import com.google.inject.matcher.Matchers;
-import com.google.inject.persist.Transactional;
 import com.google.inject.persist.jpa.JpaPersistModule;
 import org.apache.ambari.server.actionmanager.*;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.configuration.Configuration;
 import org.apache.ambari.server.orm.PersistenceType;
-import org.apache.ambari.server.orm.dao.ClearEntityManagerInterceptor;
 import org.apache.ambari.server.state.*;
 import org.apache.ambari.server.state.cluster.ClusterFactory;
 import org.apache.ambari.server.state.cluster.ClusterImpl;
@@ -45,14 +43,13 @@ import java.util.Properties;
 
 /**
  * Used for injection purposes.
- *
  */
 public class ControllerModule extends AbstractModule {
 
   private final Configuration configuration;
   private final AmbariMetaInfo ambariMetaInfo;
   private final HostsMap hostsMap;
-  
+
   public ControllerModule() throws Exception {
     configuration = new Configuration();
     ambariMetaInfo = new AmbariMetaInfo(configuration);
@@ -67,13 +64,11 @@ public class ControllerModule extends Ab
 
   @Override
   protected void configure() {
-    bindInterceptors();
     installFactories();
 
     bind(Configuration.class).toInstance(configuration);
     bind(AmbariMetaInfo.class).toInstance(ambariMetaInfo);
     bind(HostsMap.class).toInstance(hostsMap);
-    
     bind(PasswordEncoder.class).toInstance(new StandardPasswordEncoder());
 
     JpaPersistModule jpaPersistModule = new JpaPersistModule(configuration.getPersistenceType().getUnitName());
@@ -115,10 +110,4 @@ public class ControllerModule extends Ab
     install(new FactoryModuleBuilder().build(HostRoleCommandFactory.class));
   }
 
-  private void bindInterceptors() {
-    ClearEntityManagerInterceptor clearEntityManagerInterceptor = new ClearEntityManagerInterceptor();
-    requestInjection(clearEntityManagerInterceptor);
-    bindInterceptor(Matchers.any(), Matchers.annotatedWith(Transactional.class), clearEntityManagerInterceptor);
-
-  }
 }

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/ganglia/GangliaHostPropertyProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/ganglia/GangliaHostPropertyProvider.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/ganglia/GangliaHostPropertyProvider.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/ganglia/GangliaHostPropertyProvider.java Wed Mar 20 20:44:43 2013
@@ -22,6 +22,7 @@ import org.apache.ambari.server.controll
 import org.apache.ambari.server.controller.spi.Resource;
 import org.apache.ambari.server.controller.utilities.StreamProvider;
 
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
@@ -30,17 +31,18 @@ import java.util.Set;
  * Ganglia property provider implementation for host resources.
  */
 public class GangliaHostPropertyProvider extends GangliaPropertyProvider{
+
   /**
    * Set of Ganglia cluster names.
    */
- private static final Set<String> GANGLIA_CLUSTER_NAMES = new HashSet<String>();
+  private static final Set<String> GANGLIA_CLUSTER_NAMES = new HashSet<String>();
 
- static {
-   GANGLIA_CLUSTER_NAMES.add("HDPNameNode");
-   GANGLIA_CLUSTER_NAMES.add("HDPSlaves");
-   GANGLIA_CLUSTER_NAMES.add("HDPJobTracker");
-   GANGLIA_CLUSTER_NAMES.add("HDPHBaseMaster");
- }
+  static {
+    GANGLIA_CLUSTER_NAMES.add("HDPNameNode");
+    GANGLIA_CLUSTER_NAMES.add("HDPSlaves");
+    GANGLIA_CLUSTER_NAMES.add("HDPJobTracker");
+    GANGLIA_CLUSTER_NAMES.add("HDPHBaseMaster");
+  }
 
   // ----- Constructors ------------------------------------------------------
 

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/ganglia/GangliaPropertyProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/ganglia/GangliaPropertyProvider.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/ganglia/GangliaPropertyProvider.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/ganglia/GangliaPropertyProvider.java Wed Mar 20 20:44:43 2013
@@ -18,9 +18,9 @@
 
 package org.apache.ambari.server.controller.ganglia;
 
+import org.apache.ambari.server.controller.internal.AbstractPropertyProvider;
 import org.apache.ambari.server.controller.internal.PropertyInfo;
 import org.apache.ambari.server.controller.spi.*;
-import org.apache.ambari.server.controller.utilities.PropertyHelper;
 import org.apache.ambari.server.controller.utilities.StreamProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -33,14 +33,7 @@ import java.util.*;
 /**
  * Abstract property provider implementation for a Ganglia source.
  */
-public abstract class GangliaPropertyProvider implements PropertyProvider {
-
-  /**
-   * Set of property ids supported by this provider.
-   */
-  private final Set<String> propertyIds;
-
-  private final Map<String, Map<String, PropertyInfo>> componentPropertyInfoMap;
+public abstract class GangliaPropertyProvider extends AbstractPropertyProvider {
 
   private final StreamProvider streamProvider;
 
@@ -52,20 +45,18 @@ public abstract class GangliaPropertyPro
 
   private final String componentNamePropertyId;
 
-
-
   /**
    * Map of Ganglia cluster names keyed by component type.
    */
   public static final Map<String, String> GANGLIA_CLUSTER_NAME_MAP = new HashMap<String, String>();
 
   static {
-    GANGLIA_CLUSTER_NAME_MAP.put("NAMENODE",           "HDPNameNode");
-    GANGLIA_CLUSTER_NAME_MAP.put("DATANODE",           "HDPSlaves");
-    GANGLIA_CLUSTER_NAME_MAP.put("JOBTRACKER",         "HDPJobTracker");
-    GANGLIA_CLUSTER_NAME_MAP.put("TASKTRACKER",        "HDPSlaves");
-    GANGLIA_CLUSTER_NAME_MAP.put("HBASE_MASTER",       "HDPHBaseMaster");
-    GANGLIA_CLUSTER_NAME_MAP.put("HBASE_CLIENT",       "HDPSlaves");
+    GANGLIA_CLUSTER_NAME_MAP.put("NAMENODE", "HDPNameNode");
+    GANGLIA_CLUSTER_NAME_MAP.put("DATANODE", "HDPSlaves");
+    GANGLIA_CLUSTER_NAME_MAP.put("JOBTRACKER", "HDPJobTracker");
+    GANGLIA_CLUSTER_NAME_MAP.put("TASKTRACKER", "HDPSlaves");
+    GANGLIA_CLUSTER_NAME_MAP.put("HBASE_MASTER", "HDPHBaseMaster");
+    GANGLIA_CLUSTER_NAME_MAP.put("HBASE_CLIENT", "HDPSlaves");
     GANGLIA_CLUSTER_NAME_MAP.put("HBASE_REGIONSERVER", "HDPSlaves");
   }
 
@@ -80,18 +71,14 @@ public abstract class GangliaPropertyPro
                                  String clusterNamePropertyId,
                                  String hostNamePropertyId,
                                  String componentNamePropertyId) {
-    this.componentPropertyInfoMap = componentPropertyInfoMap;
+
+    super(componentPropertyInfoMap);
+
     this.streamProvider           = streamProvider;
     this.hostProvider             = hostProvider;
     this.clusterNamePropertyId    = clusterNamePropertyId;
     this.hostNamePropertyId       = hostNamePropertyId;
     this.componentNamePropertyId  = componentNamePropertyId;
-
-    propertyIds  = new HashSet<String>();
-
-    for (Map.Entry<String, Map<String, PropertyInfo>> entry : componentPropertyInfoMap.entrySet()) {
-      propertyIds.addAll(entry.getValue().keySet());
-    }
   }
 
 
@@ -101,7 +88,7 @@ public abstract class GangliaPropertyPro
   public Set<Resource> populateResources(Set<Resource> resources, Request request, Predicate predicate)
       throws SystemException {
 
-    Set<String> ids = PropertyHelper.getRequestPropertyIds(propertyIds, request, predicate);
+    Set<String> ids = getRequestPropertyIds(request, predicate);
     if (ids.isEmpty()) {
       return resources;
     }
@@ -122,21 +109,6 @@ public abstract class GangliaPropertyPro
     return resources;
   }
 
-  @Override
-  public Set<String> getPropertyIds() {
-    return propertyIds;
-  }
-
-  @Override
-  public Set<String> checkPropertyIds(Set<String> propertyIds) {
-    if (!this.propertyIds.containsAll(propertyIds)) {
-      Set<String> unsupportedPropertyIds = new HashSet<String>(propertyIds);
-      unsupportedPropertyIds.removeAll(this.propertyIds);
-      return unsupportedPropertyIds;
-    }
-    return Collections.emptySet();
-  }
-
 
   // ----- GangliaPropertyProvider -------------------------------------------
 
@@ -161,6 +133,7 @@ public abstract class GangliaPropertyPro
   /**
    * Get the ganglia cluster name for the given resource.
    *
+   *
    * @param resource  the resource
    *
    * @return the ganglia cluster name
@@ -225,27 +198,29 @@ public abstract class GangliaPropertyPro
         requestMap.put(clusterName, requests);
       }
 
-      for (String gangliaClusterName : getGangliaClusterNames(resource, clusterName)) {
+      Set<String> gangliaClusterNames = getGangliaClusterNames(resource, clusterName);
+
+      for (String gangliaClusterName : gangliaClusterNames) {
         ResourceKey key =
             new ResourceKey(getHostName(resource), gangliaClusterName);
 
-        Map<String, PropertyInfo> metrics = componentPropertyInfoMap.get(getComponentName(resource));
+        for (String id : ids) {
+          Map<String, PropertyInfo> propertyInfoMap = getPropertyInfoMap(getComponentName(resource), id);
 
-        if (metrics != null) {
-          for (String propertyId : ids) {
-            PropertyInfo propertyInfo = metrics.get(propertyId);
-            if (propertyInfo != null) {
-              TemporalInfo temporalInfo = request.getTemporalInfo(propertyId);
-
-              if ((temporalInfo == null && propertyInfo.isPointInTime()) || (temporalInfo != null && propertyInfo.isTemporal())) {
-                RRDRequest rrdRequest = requests.get(temporalInfo);
-                if (rrdRequest == null) {
-                  rrdRequest = new RRDRequest(clusterName, temporalInfo);
-                  requests.put(temporalInfo, rrdRequest);
-                }
-                rrdRequest.putResource(key, resource);
-                rrdRequest.putPropertyId(propertyInfo.getPropertyId(), propertyId);
+          for (Map.Entry<String, PropertyInfo> entry : propertyInfoMap.entrySet()) {
+            String propertyId = entry.getKey();
+            PropertyInfo propertyInfo = entry.getValue();
+
+            TemporalInfo temporalInfo = request.getTemporalInfo(id);
+
+            if ((temporalInfo == null && propertyInfo.isPointInTime()) || (temporalInfo != null && propertyInfo.isTemporal())) {
+              RRDRequest rrdRequest = requests.get(temporalInfo);
+              if (rrdRequest == null) {
+                rrdRequest = new RRDRequest(clusterName, temporalInfo);
+                requests.put(temporalInfo, rrdRequest);
               }
+              rrdRequest.putResource(key, resource);
+              rrdRequest.putPropertyId(propertyInfo.getPropertyId(), propertyId);
             }
           }
         }
@@ -275,7 +250,7 @@ public abstract class GangliaPropertyPro
                          TemporalInfo temporalInfo) throws SystemException {
 
     String clusters = getSetString(clusterSet, -1);
-    String hosts    = getSetString(hostSet, -1);
+    String hosts    = getSetString(hostSet, 100);
     String metrics  = getSetString(metricSet, 50);
 
     StringBuilder sb = new StringBuilder();
@@ -496,7 +471,7 @@ public abstract class GangliaPropertyPro
     private void populateResource(Resource resource, GangliaMetric gangliaMetric) {
       Set<String> propertyIdSet = metrics.get(gangliaMetric.getMetric_name());
       if (propertyIdSet != null) {
-        Map<String, PropertyInfo> metricsMap = componentPropertyInfoMap.get(getComponentName(resource));
+        Map<String, PropertyInfo> metricsMap = getComponentMetrics().get(getComponentName(resource));
         if (metricsMap != null) {
           for (String propertyId : propertyIdSet) {
             if (propertyId != null) {

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/ganglia/GangliaReportPropertyProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/ganglia/GangliaReportPropertyProvider.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/ganglia/GangliaReportPropertyProvider.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/ganglia/GangliaReportPropertyProvider.java Wed Mar 20 20:44:43 2013
@@ -18,9 +18,9 @@
 
 package org.apache.ambari.server.controller.ganglia;
 
+import org.apache.ambari.server.controller.internal.AbstractPropertyProvider;
 import org.apache.ambari.server.controller.internal.PropertyInfo;
 import org.apache.ambari.server.controller.spi.*;
-import org.apache.ambari.server.controller.utilities.PropertyHelper;
 import org.apache.ambari.server.controller.utilities.StreamProvider;
 import org.codehaus.jackson.map.ObjectMapper;
 import org.codehaus.jackson.type.TypeReference;
@@ -28,7 +28,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -39,14 +38,7 @@ import java.util.Set;
  * Property provider implementation for a Ganglia source. This provider is specialized
  * to pull metrics from existing Ganglia reports.
  */
-public class GangliaReportPropertyProvider implements PropertyProvider {
-
-  /**
-   * Set of property ids supported by this provider.
-   */
-  private final Set<String> propertyIds;
-
-  private final Map<String, PropertyInfo> componentMetrics;
+public class GangliaReportPropertyProvider extends AbstractPropertyProvider {
 
   private final StreamProvider streamProvider;
 
@@ -65,17 +57,15 @@ public class GangliaReportPropertyProvid
 
   // ----- Constructors ------------------------------------------------------
 
-  public GangliaReportPropertyProvider(Map<String, PropertyInfo> componentMetrics,
+  public GangliaReportPropertyProvider(Map<String, Map<String, PropertyInfo>> componentPropertyInfoMap,
                                        StreamProvider streamProvider,
                                        GangliaHostProvider hostProvider,
                                        String clusterNamePropertyId) {
+    super(componentPropertyInfoMap);
 
-    this.componentMetrics      = componentMetrics;
     this.streamProvider        = streamProvider;
     this.hostProvider          = hostProvider;
     this.clusterNamePropertyId = clusterNamePropertyId;
-
-    propertyIds = new HashSet<String>(componentMetrics.keySet());
   }
 
 
@@ -94,21 +84,6 @@ public class GangliaReportPropertyProvid
     return keepers;
   }
 
-  @Override
-  public Set<String> getPropertyIds() {
-    return propertyIds;
-  }
-
-  @Override
-  public Set<String> checkPropertyIds(Set<String> propertyIds) {
-    if (!this.propertyIds.containsAll(propertyIds)) {
-      Set<String> unsupportedPropertyIds = new HashSet<String>(propertyIds);
-      unsupportedPropertyIds.removeAll(this.propertyIds);
-      return unsupportedPropertyIds;
-    }
-    return Collections.emptySet();
-  }
-
 
   // ----- helper methods ----------------------------------------------------
 
@@ -126,6 +101,8 @@ public class GangliaReportPropertyProvid
   private boolean populateResource(Resource resource, Request request, Predicate predicate)
       throws SystemException {
 
+    Set<String> propertyIds = getPropertyIds();
+
     if (propertyIds.isEmpty()) {
       return true;
     }
@@ -139,8 +116,7 @@ public class GangliaReportPropertyProvid
       return true;
     }
 
-    setProperties(resource, clusterName, request,
-        PropertyHelper.getRequestPropertyIds(propertyIds, request, predicate));
+    setProperties(resource, clusterName, request, getRequestPropertyIds(request, predicate));
 
     return true;
   }
@@ -170,8 +146,8 @@ public class GangliaReportPropertyProvid
           }
         }
       } catch (IOException e) {
-        if (LOG.isDebugEnabled()) {
-          LOG.debug("Caught exception getting Ganglia metrics : " + e + " : spec=" + spec);
+        if (LOG.isErrorEnabled()) {
+          LOG.error("Caught exception getting Ganglia metrics : " + e + " : spec=" + spec);
         }
         return false;
       }
@@ -179,16 +155,17 @@ public class GangliaReportPropertyProvid
     return true;
   }
 
-
   private Map<String, Map<String, String>> getPropertyIdMaps(Request request, Set<String> ids) {
     Map<String, Map<String, String>> propertyMap = new HashMap<String, Map<String, String>>();
 
-    for (String propertyId : ids) {
-      PropertyInfo propertyInfo = componentMetrics.get(propertyId);
+    for (String id : ids) {
+      Map<String, PropertyInfo> propertyInfoMap = getPropertyInfoMap("*", id);
 
-      if (propertyInfo != null) {
+      for (Map.Entry<String, PropertyInfo> entry : propertyInfoMap.entrySet()) {
+        String propertyId = entry.getKey();
+        PropertyInfo propertyInfo = entry.getValue();
 
-        TemporalInfo temporalInfo = request.getTemporalInfo(propertyId);
+        TemporalInfo temporalInfo = request.getTemporalInfo(id);
 
         if (temporalInfo != null && propertyInfo.isTemporal()) {
           String propertyName = propertyInfo.getPropertyId();
@@ -216,7 +193,6 @@ public class GangliaReportPropertyProvid
   /**
    * Get value from the given metric.
    *
-   *
    * @param metric     the metric
    */
   private Object getValue(GangliaMetric metric) {

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/ClusterDefinition.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/ClusterDefinition.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/ClusterDefinition.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/ClusterDefinition.java Wed Mar 20 20:44:43 2013
@@ -69,6 +69,11 @@ public class ClusterDefinition {
   private final Map<String, HostComponentState> hostComponentStateMap = new HashMap<String, HostComponentState>();
 
   /**
+   * Expiry for the health value.
+   */
+  private static final int DEFAULT_STATE_EXPIRY = 15000;
+
+  /**
    * Component name mapping to account for differences in what is provided by the gsInstaller
    * and what is expected by the Ambari providers.
    */
@@ -82,16 +87,27 @@ public class ClusterDefinition {
 
   /**
    * Create a cluster definition.
+   *
+   * @param stateProvider  the state provider
    */
   public ClusterDefinition(GSInstallerStateProvider stateProvider) {
+    this(stateProvider, DEFAULT_STATE_EXPIRY);
+  }
+
+  /**
+   * Create a cluster definition.
+   *
+   * @param stateProvider  the state provider
+   * @param stateExpiry    the state expiry
+   */
+  public ClusterDefinition(GSInstallerStateProvider stateProvider, int stateExpiry) {
     this.stateProvider = stateProvider;
     this.clusterName   = DEFAULT_CLUSTER_NAME;
     this.versionId     = DEFAULT_VERSION_ID;
     readClusterDefinition();
-    setHostComponentState();
+    setHostComponentState(stateExpiry);
   }
 
-
   // ----- ClusterDefinition -------------------------------------------------
 
   /**
@@ -270,7 +286,7 @@ public class ClusterDefinition {
   /**
    * Set the host component state maps.
    */
-  private void setHostComponentState() {
+  private void setHostComponentState(int stateExpiry) {
     for (Map.Entry<String, Map<String, Set<String>>> serviceEntry : hostComponents.entrySet()) {
       String serviceName = serviceEntry.getKey();
 
@@ -279,7 +295,7 @@ public class ClusterDefinition {
 
         for (String componentName : hostEntry.getValue()) {
 
-          HostComponentState state = new HostComponentState(hostName, componentName);
+          HostComponentState state = new HostComponentState(hostName, componentName, stateExpiry);
 
           // add state to hosts
           addState(hostName, hostStateMap, state);
@@ -378,14 +394,10 @@ public class ClusterDefinition {
   private class HostComponentState {
     private final String hostName;
     private final String componentName;
+    private final int expiry;
     private boolean healthy = true;
     private long lastAccess;
 
-    /**
-     * Expiry for the health value.
-     */
-    private static final int EXPIRY = 15000;
-
     // ----- Constructor -----------------------------------------------------
 
     /**
@@ -394,9 +406,10 @@ public class ClusterDefinition {
      * @param hostName       the host name
      * @param componentName  the component name
      */
-    HostComponentState(String hostName, String componentName) {
+    HostComponentState(String hostName, String componentName, int expiry) {
       this.hostName      = hostName;
       this.componentName = componentName;
+      this.expiry        = expiry;
     }
 
     /**
@@ -405,7 +418,7 @@ public class ClusterDefinition {
      * @return true if the associated host component is healthy
      */
     public boolean isHealthy() {
-      if (System.currentTimeMillis() - lastAccess > EXPIRY) {
+      if (System.currentTimeMillis() - lastAccess > expiry) {
         // health value has expired... get it again
         healthy = stateProvider.isHealthy(hostName, componentName);
         this.lastAccess = System.currentTimeMillis();

Modified: incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerClusterProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerClusterProvider.java?rev=1459041&r1=1459040&r2=1459041&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerClusterProvider.java (original)
+++ incubator/ambari/branches/branch-1.2/ambari-server/src/main/java/org/apache/ambari/server/controller/gsinstaller/GSInstallerClusterProvider.java Wed Mar 20 20:44:43 2013
@@ -24,9 +24,6 @@ import org.apache.ambari.server.controll
 import org.apache.ambari.server.controller.spi.Resource;
 import org.apache.ambari.server.controller.utilities.PropertyHelper;
 
-import java.util.Map;
-import java.util.Set;
-
 /**
  * A cluster resource provider for a gsInstaller defined cluster.
  */
@@ -45,24 +42,11 @@ public class GSInstallerClusterProvider 
    * @param clusterDefinition  the cluster definition
    */
   public GSInstallerClusterProvider(ClusterDefinition clusterDefinition) {
-    super(clusterDefinition);
+    super(Resource.Type.Cluster, clusterDefinition);
     initClusterResources();
   }
 
 
-  // ----- ResourceProvider --------------------------------------------------
-
-  @Override
-  public Set<String> getPropertyIdsForSchema() {
-    return PropertyHelper.getPropertyIds(Resource.Type.Cluster);
-  }
-
-  @Override
-  public Map<Resource.Type, String> getKeyPropertyIds() {
-    return PropertyHelper.getKeyPropertyIds(Resource.Type.Cluster);
-  }
-
-
   // ----- GSInstallerResourceProvider ---------------------------------------
 
   @Override