View Javadoc

1   /*
2    * Copyright (c) 2010.  The Apache Software Foundation
3    *
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *     http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS,
16   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17   * See the License for the specific language governing permissions and
18   * limitations under the License.
19   */
20  
21  package org.apache.hadoop.hbase.hbql.executor;
22  
23  import org.apache.expreval.expr.ArgumentListTypeSignature;
24  import org.apache.expreval.expr.ExpressionProperty;
25  import org.apache.expreval.expr.PropertyType;
26  import org.apache.expreval.expr.node.BooleanValue;
27  import org.apache.expreval.expr.node.GenericValue;
28  import org.apache.expreval.expr.node.IntegerValue;
29  import org.apache.expreval.expr.node.LongValue;
30  
31  public class ExecutorProperty extends ExpressionProperty {
32  
33      public static enum Type implements PropertyType {
34  
35          MAX_EXECUTOR_POOL_SIZE(new ArgumentListTypeSignature(IntegerValue.class)),
36          MIN_THREAD_COUNT(new ArgumentListTypeSignature(IntegerValue.class)),
37          MAX_THREAD_COUNT(new ArgumentListTypeSignature(IntegerValue.class)),
38          KEEP_ALIVE_SECS(new ArgumentListTypeSignature(LongValue.class)),
39          THREADS_READ_RESULTS(new ArgumentListTypeSignature(BooleanValue.class)),
40          COMPLETION_QUEUE_SIZE(new ArgumentListTypeSignature(IntegerValue.class));
41  
42          private final ArgumentListTypeSignature typeSignature;
43          private final String description;
44  
45          Type(final ArgumentListTypeSignature typeSignature) {
46              this.typeSignature = typeSignature;
47              this.description = this.name();
48          }
49  
50          public ArgumentListTypeSignature getTypeSignature() {
51              return this.typeSignature;
52          }
53  
54          public String getDescription() {
55              return this.description;
56          }
57      }
58  
59      public ExecutorProperty(final String text, final GenericValue arg0) {
60          super(ExecutorProperty.Type.valueOf(text.toUpperCase()), arg0);
61      }
62  
63      public Type getEnumType() {
64          return (Type)this.getPropertyType();
65      }
66  
67      public String asString() {
68          return this.getPropertyType().getDescription() + ": " + this.getGenericValue(0).asString();
69      }
70  }