You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lens.apache.org by am...@apache.org on 2016/02/02 14:21:25 UTC
[7/7] lens git commit: LENS-920 : Fix issues in producing and
consuming json for all api
LENS-920 : Fix issues in producing and consuming json for all api
Project: http://git-wip-us.apache.org/repos/asf/lens/repo
Commit: http://git-wip-us.apache.org/repos/asf/lens/commit/d559ef2e
Tree: http://git-wip-us.apache.org/repos/asf/lens/tree/d559ef2e
Diff: http://git-wip-us.apache.org/repos/asf/lens/diff/d559ef2e
Branch: refs/heads/master
Commit: d559ef2e524ee6c28d45b35cca827fd507b15665
Parents: a5091fe
Author: Amareshwari Sriramadasu <am...@apache.org>
Authored: Tue Feb 2 18:50:28 2016 +0530
Committer: Amareshwari Sriramadasu <am...@apache.org>
Committed: Tue Feb 2 18:50:28 2016 +0530
----------------------------------------------------------------------
lens-api/pom.xml | 8 +
.../java/org/apache/lens/api/APIResult.java | 29 +-
.../main/java/org/apache/lens/api/LensConf.java | 2 +-
.../org/apache/lens/api/LensSessionHandle.java | 3 +
.../main/java/org/apache/lens/api/Priority.java | 5 +
.../java/org/apache/lens/api/UUIDAdapter.java | 50 ++
.../apache/lens/api/query/QueryCostType.java | 5 +
.../org/apache/lens/api/query/QueryHandle.java | 4 +
.../lens/api/query/QueryPrepareHandle.java | 4 +
.../lens/api/query/QueryResultSetMetadata.java | 2 +
.../org/apache/lens/api/query/QueryStatus.java | 4 +
.../apache/lens/api/query/ResultColumnType.java | 2 +
.../lens/api/query/SchedulerJobHandle.java | 4 +
.../api/query/SchedulerJobInstanceHandle.java | 4 +
.../org/apache/lens/api/result/QueryCostTO.java | 2 +-
.../MoxyJsonConfigurationContextResolver.java | 38 +
lens-api/src/main/resources/cube-0.1.xsd | 12 +-
.../apache/lens/cli/LensCliApplicationTest.java | 2 +-
.../cli/TestLensDimensionTableCommands.java | 2 +-
.../resources/cube_with_no_weight_facts.xml | 16 +-
.../resources/dim-local-storage-element.xml | 2 +-
lens-cli/src/test/resources/dim_table.xml | 10 +-
lens-cli/src/test/resources/dim_table2.xml | 8 +-
.../resources/fact-local-storage-element.xml | 2 +-
lens-cli/src/test/resources/fact1.xml | 10 +-
.../src/test/resources/fact_without_weight.xml | 10 +-
.../src/test/resources/lens-client-site.xml | 4 +-
lens-cli/src/test/resources/logback.xml | 49 ++
lens-cli/src/test/resources/sample-cube.xml | 18 +-
lens-cli/src/test/resources/test-detail.xml | 4 +-
lens-cli/src/test/resources/test-dimension.xml | 16 +-
.../org/apache/lens/client/LensConnection.java | 5 +-
.../apache/lens/client/LensMetadataClient.java | 196 ++---
.../org/apache/lens/client/LensStatement.java | 34 +-
.../apache/lens/examples/SampleMetastore.java | 3 +
lens-examples/src/main/resources/city.xml | 8 +-
.../src/main/resources/city_subset.xml | 4 +-
lens-examples/src/main/resources/city_table.xml | 10 +-
lens-examples/src/main/resources/customer.xml | 14 +-
.../src/main/resources/customer_table.xml | 14 +-
lens-examples/src/main/resources/dim_table.xml | 10 +-
lens-examples/src/main/resources/dim_table2.xml | 8 +-
lens-examples/src/main/resources/dim_table3.xml | 8 +-
lens-examples/src/main/resources/dim_table4.xml | 10 +-
lens-examples/src/main/resources/fact1.xml | 10 +-
lens-examples/src/main/resources/fact2.xml | 12 +-
lens-examples/src/main/resources/product.xml | 16 +-
.../src/main/resources/product_db_table.xml | 14 +-
.../src/main/resources/product_table.xml | 16 +-
lens-examples/src/main/resources/rawfact.xml | 16 +-
.../resources/sales-aggr-continuous-fact.xml | 26 +-
.../src/main/resources/sales-aggr-fact1.xml | 38 +-
.../src/main/resources/sales-aggr-fact2.xml | 28 +-
lens-examples/src/main/resources/sales-cube.xml | 54 +-
.../src/main/resources/sales-raw-fact.xml | 40 +-
.../src/main/resources/sample-cube.xml | 16 +-
.../main/resources/sample-db-only-dimension.xml | 8 +-
.../src/main/resources/sample-dimension.xml | 8 +-
.../src/main/resources/sample-dimension2.xml | 6 +-
.../java/org/apache/lens/ml/server/MLApp.java | 5 +
.../java/org/apache/lens/ml/TestMLRunner.java | 8 -
.../server/api/driver/InMemoryResultSet.java | 2 +-
lens-server/pom.xml | 9 -
.../java/org/apache/lens/server/BaseApp.java | 53 ++
.../java/org/apache/lens/server/LensServer.java | 1 -
.../apache/lens/server/ServerModeFilter.java | 15 +-
.../metastore/CubeMetastoreServiceImpl.java | 24 +-
.../apache/lens/server/metastore/JAXBUtils.java | 10 +-
.../lens/server/metastore/MetastoreApp.java | 29 +-
.../server/metastore/MetastoreResource.java | 20 +-
.../org/apache/lens/server/query/QueryApp.java | 24 +-
.../lens/server/query/QueryServiceResource.java | 4 +-
.../lens/server/query/save/SavedQueryApp.java | 22 +-
.../server/query/save/SavedQueryResource.java | 4 +-
.../lens/server/scheduler/SchedulerApp.java | 22 +-
.../apache/lens/server/session/SessionApp.java | 23 +-
.../lens/server/session/SessionResource.java | 2 +-
.../java/org/apache/lens/server/ui/UIApp.java | 20 +-
.../src/main/resources/lensserver-default.xml | 12 +-
.../server/LensAllApplicationJerseyTest.java | 16 +-
.../org/apache/lens/server/LensJerseyTest.java | 37 +-
.../apache/lens/server/LensServerTestUtil.java | 49 +-
.../apache/lens/server/TestLensApplication.java | 13 +-
.../org/apache/lens/server/TestServerMode.java | 3 +-
.../apache/lens/server/TestServerRestart.java | 71 +-
.../server/common/FormDataMultiPartFactory.java | 55 +-
.../lens/server/common/RestAPITestUtil.java | 157 ++--
.../server/healthcheck/TestHealthChecks.java | 20 +-
.../server/metastore/TestMetastoreService.java | 799 ++++++++++---------
.../metastore/TestMetastoreServiceJSON.java | 28 -
.../metrics/TestResourceMethodMetrics.java | 18 +-
.../server/query/QueryAPIErrorResponseTest.java | 96 +--
.../apache/lens/server/query/TestLensDAO.java | 15 +-
.../lens/server/query/TestQueryConstraints.java | 35 +-
.../server/query/TestQueryEndEmailNotifier.java | 65 +-
.../lens/server/query/TestQueryService.java | 493 ++++++------
.../lens/server/query/TestResultFormatting.java | 62 +-
.../query/save/TestSavedQueryService.java | 8 -
.../server/session/TestSessionResource.java | 157 ++--
.../lens/server/ui/TestSessionUIResource.java | 12 -
pom.xml | 17 +-
src/site/apt/admin/config.apt | 128 +--
102 files changed, 1858 insertions(+), 1768 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-api/pom.xml
----------------------------------------------------------------------
diff --git a/lens-api/pom.xml b/lens-api/pom.xml
index 8aa2f67..1704b62 100644
--- a/lens-api/pom.xml
+++ b/lens-api/pom.xml
@@ -65,6 +65,14 @@
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-runtime</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.media</groupId>
+ <artifactId>jersey-media-jaxb</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.media</groupId>
+ <artifactId>jersey-media-moxy</artifactId>
+ </dependency>
</dependencies>
<build>
<plugins>
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-api/src/main/java/org/apache/lens/api/APIResult.java
----------------------------------------------------------------------
diff --git a/lens-api/src/main/java/org/apache/lens/api/APIResult.java b/lens-api/src/main/java/org/apache/lens/api/APIResult.java
index 0cdee0d..f50d3ea 100644
--- a/lens-api/src/main/java/org/apache/lens/api/APIResult.java
+++ b/lens-api/src/main/java/org/apache/lens/api/APIResult.java
@@ -28,21 +28,24 @@ import javax.xml.bind.annotation.*;
import org.apache.lens.api.jaxb.LensJAXBContext;
import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
/**
* APIResult is the output returned by all the APIs; status-SUCCEEDED or FAILED message- detailed message.
*/
-@XmlRootElement(name = "result")
+@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
+/*
+ * Instantiates a new API result with values
+ */
+@AllArgsConstructor
/**
* Instantiates a new API result.
*/
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class APIResult {
-
- private static final APIResult SUCCESS = new APIResult(Status.SUCCEEDED, "");
/**
* The status.
*/
@@ -73,6 +76,8 @@ public class APIResult {
/**
* API Result status.
*/
+ @XmlType
+ @XmlEnum
public enum Status {
/**
@@ -89,23 +94,6 @@ public class APIResult {
FAILED
}
- /**
- * Instantiates a new API result.
- *
- * @param status the status
- * @param message the message
- */
- public APIResult(Status status, String message) {
- super();
- this.status = status;
- this.message = message;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
@Override
public String toString() {
try {
@@ -117,6 +105,7 @@ public class APIResult {
return e.getMessage();
}
}
+ private static final APIResult SUCCESS = new APIResult(Status.SUCCEEDED, "");
public static APIResult partial(int actual, int expected) {
return new APIResult(Status.PARTIAL, actual + " out of " + expected);
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-api/src/main/java/org/apache/lens/api/LensConf.java
----------------------------------------------------------------------
diff --git a/lens-api/src/main/java/org/apache/lens/api/LensConf.java b/lens-api/src/main/java/org/apache/lens/api/LensConf.java
index ff965d6..67d6461 100644
--- a/lens-api/src/main/java/org/apache/lens/api/LensConf.java
+++ b/lens-api/src/main/java/org/apache/lens/api/LensConf.java
@@ -51,7 +51,7 @@ public class LensConf implements Serializable {
*/
@XmlElementWrapper
@Getter
- private final Map<String, String> properties = new HashMap<String, String>();
+ private final Map<String, String> properties = new HashMap<>();
/**
* Adds the property.
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-api/src/main/java/org/apache/lens/api/LensSessionHandle.java
----------------------------------------------------------------------
diff --git a/lens-api/src/main/java/org/apache/lens/api/LensSessionHandle.java b/lens-api/src/main/java/org/apache/lens/api/LensSessionHandle.java
index d4327a6..dc9142d 100644
--- a/lens-api/src/main/java/org/apache/lens/api/LensSessionHandle.java
+++ b/lens-api/src/main/java/org/apache/lens/api/LensSessionHandle.java
@@ -31,6 +31,7 @@ import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.apache.lens.api.jaxb.LensJAXBContext;
@@ -63,6 +64,7 @@ public class LensSessionHandle {
*/
@XmlElement
@Getter
+ @XmlJavaTypeAdapter(UUIDAdapter.class)
private UUID publicId;
/**
@@ -70,6 +72,7 @@ public class LensSessionHandle {
*/
@XmlElement
@Getter
+ @XmlJavaTypeAdapter(UUIDAdapter.class)
private UUID secretId;
/**
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-api/src/main/java/org/apache/lens/api/Priority.java
----------------------------------------------------------------------
diff --git a/lens-api/src/main/java/org/apache/lens/api/Priority.java b/lens-api/src/main/java/org/apache/lens/api/Priority.java
index 0e5a65d..364f892 100644
--- a/lens-api/src/main/java/org/apache/lens/api/Priority.java
+++ b/lens-api/src/main/java/org/apache/lens/api/Priority.java
@@ -21,9 +21,14 @@
*/
package org.apache.lens.api;
+import javax.xml.bind.annotation.XmlEnum;
+import javax.xml.bind.annotation.XmlType;
+
/**
* The Enum Priority.
*/
+@XmlEnum
+@XmlType
public enum Priority {
/**
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-api/src/main/java/org/apache/lens/api/UUIDAdapter.java
----------------------------------------------------------------------
diff --git a/lens-api/src/main/java/org/apache/lens/api/UUIDAdapter.java b/lens-api/src/main/java/org/apache/lens/api/UUIDAdapter.java
new file mode 100644
index 0000000..9d6fa77
--- /dev/null
+++ b/lens-api/src/main/java/org/apache/lens/api/UUIDAdapter.java
@@ -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.lens.api;
+
+import java.util.UUID;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+public class UUIDAdapter extends XmlAdapter<String, UUID> {
+
+ @Override
+ public UUID unmarshal(String s) {
+ if (null == s) {
+ return null;
+ }
+ try {
+ return UUID.fromString(s);
+ } catch (IllegalArgumentException e) {
+ return null;
+ }
+ }
+
+ @Override
+ public String marshal(UUID uuid) {
+ if (uuid == null) {
+ return null;
+ }
+ return uuid.toString();
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-api/src/main/java/org/apache/lens/api/query/QueryCostType.java
----------------------------------------------------------------------
diff --git a/lens-api/src/main/java/org/apache/lens/api/query/QueryCostType.java b/lens-api/src/main/java/org/apache/lens/api/query/QueryCostType.java
index 1485e1d..37eda42 100644
--- a/lens-api/src/main/java/org/apache/lens/api/query/QueryCostType.java
+++ b/lens-api/src/main/java/org/apache/lens/api/query/QueryCostType.java
@@ -21,6 +21,11 @@
*/
package org.apache.lens.api.query;
+import javax.xml.bind.annotation.XmlEnum;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlType
+@XmlEnum
public enum QueryCostType {
LOW, MEDIUM, HIGH
}
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-api/src/main/java/org/apache/lens/api/query/QueryHandle.java
----------------------------------------------------------------------
diff --git a/lens-api/src/main/java/org/apache/lens/api/query/QueryHandle.java b/lens-api/src/main/java/org/apache/lens/api/query/QueryHandle.java
index 9f20184..2d4c706 100644
--- a/lens-api/src/main/java/org/apache/lens/api/query/QueryHandle.java
+++ b/lens-api/src/main/java/org/apache/lens/api/query/QueryHandle.java
@@ -26,6 +26,9 @@ import java.util.UUID;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+import org.apache.lens.api.UUIDAdapter;
import org.apache.commons.lang.StringUtils;
@@ -64,6 +67,7 @@ public class QueryHandle extends QuerySubmitResult implements Serializable {
*/
@XmlElement
@Getter
+ @XmlJavaTypeAdapter(UUIDAdapter.class)
private UUID handleId;
/**
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-api/src/main/java/org/apache/lens/api/query/QueryPrepareHandle.java
----------------------------------------------------------------------
diff --git a/lens-api/src/main/java/org/apache/lens/api/query/QueryPrepareHandle.java b/lens-api/src/main/java/org/apache/lens/api/query/QueryPrepareHandle.java
index 756287e..38e87b1 100644
--- a/lens-api/src/main/java/org/apache/lens/api/query/QueryPrepareHandle.java
+++ b/lens-api/src/main/java/org/apache/lens/api/query/QueryPrepareHandle.java
@@ -25,6 +25,9 @@ import java.util.UUID;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+import org.apache.lens.api.UUIDAdapter;
import lombok.*;
@@ -56,6 +59,7 @@ public class QueryPrepareHandle extends QuerySubmitResult {
*/
@XmlElement
@Getter
+ @XmlJavaTypeAdapter(UUIDAdapter.class)
private UUID prepareHandleId;
/**
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-api/src/main/java/org/apache/lens/api/query/QueryResultSetMetadata.java
----------------------------------------------------------------------
diff --git a/lens-api/src/main/java/org/apache/lens/api/query/QueryResultSetMetadata.java b/lens-api/src/main/java/org/apache/lens/api/query/QueryResultSetMetadata.java
index 28d9710..22c61cf 100644
--- a/lens-api/src/main/java/org/apache/lens/api/query/QueryResultSetMetadata.java
+++ b/lens-api/src/main/java/org/apache/lens/api/query/QueryResultSetMetadata.java
@@ -23,6 +23,7 @@ package org.apache.lens.api.query;
import java.util.List;
+import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
@@ -52,6 +53,7 @@ public class QueryResultSetMetadata {
* The columns.
*/
@XmlElementWrapper
+ @XmlElement
@Getter
private List<ResultColumn> columns;
}
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-api/src/main/java/org/apache/lens/api/query/QueryStatus.java
----------------------------------------------------------------------
diff --git a/lens-api/src/main/java/org/apache/lens/api/query/QueryStatus.java b/lens-api/src/main/java/org/apache/lens/api/query/QueryStatus.java
index 44fd97e..915dac7 100644
--- a/lens-api/src/main/java/org/apache/lens/api/query/QueryStatus.java
+++ b/lens-api/src/main/java/org/apache/lens/api/query/QueryStatus.java
@@ -24,7 +24,9 @@ package org.apache.lens.api.query;
import java.io.Serializable;
import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
import org.apache.lens.api.result.LensErrorTO;
@@ -67,6 +69,8 @@ public class QueryStatus implements Serializable {
/**
* The Enum Status.
*/
+ @XmlType
+ @XmlEnum
public enum Status {
/**
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-api/src/main/java/org/apache/lens/api/query/ResultColumnType.java
----------------------------------------------------------------------
diff --git a/lens-api/src/main/java/org/apache/lens/api/query/ResultColumnType.java b/lens-api/src/main/java/org/apache/lens/api/query/ResultColumnType.java
index d0c21a7..c71d02e 100644
--- a/lens-api/src/main/java/org/apache/lens/api/query/ResultColumnType.java
+++ b/lens-api/src/main/java/org/apache/lens/api/query/ResultColumnType.java
@@ -21,12 +21,14 @@
*/
package org.apache.lens.api.query;
+import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlRootElement;
/**
* The Enum ResultColumnType.
*/
@XmlRootElement
+@XmlEnum
public enum ResultColumnType {
/**
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-api/src/main/java/org/apache/lens/api/query/SchedulerJobHandle.java
----------------------------------------------------------------------
diff --git a/lens-api/src/main/java/org/apache/lens/api/query/SchedulerJobHandle.java b/lens-api/src/main/java/org/apache/lens/api/query/SchedulerJobHandle.java
index aa4dc13..4a2baba 100644
--- a/lens-api/src/main/java/org/apache/lens/api/query/SchedulerJobHandle.java
+++ b/lens-api/src/main/java/org/apache/lens/api/query/SchedulerJobHandle.java
@@ -23,6 +23,9 @@ import java.util.UUID;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+import org.apache.lens.api.UUIDAdapter;
import org.apache.commons.lang.StringUtils;
@@ -51,6 +54,7 @@ public class SchedulerJobHandle implements Serializable {
*/
@XmlElement
@Getter
+ @XmlJavaTypeAdapter(UUIDAdapter.class)
private UUID handleId;
/**
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-api/src/main/java/org/apache/lens/api/query/SchedulerJobInstanceHandle.java
----------------------------------------------------------------------
diff --git a/lens-api/src/main/java/org/apache/lens/api/query/SchedulerJobInstanceHandle.java b/lens-api/src/main/java/org/apache/lens/api/query/SchedulerJobInstanceHandle.java
index c124a38..f19d3f0 100644
--- a/lens-api/src/main/java/org/apache/lens/api/query/SchedulerJobInstanceHandle.java
+++ b/lens-api/src/main/java/org/apache/lens/api/query/SchedulerJobInstanceHandle.java
@@ -23,6 +23,9 @@ import java.util.UUID;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+
+import org.apache.lens.api.UUIDAdapter;
import org.apache.commons.lang.StringUtils;
@@ -51,6 +54,7 @@ public class SchedulerJobInstanceHandle implements Serializable {
*/
@XmlElement
@Getter
+ @XmlJavaTypeAdapter(UUIDAdapter.class)
private UUID handleId;
/**
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-api/src/main/java/org/apache/lens/api/result/QueryCostTO.java
----------------------------------------------------------------------
diff --git a/lens-api/src/main/java/org/apache/lens/api/result/QueryCostTO.java b/lens-api/src/main/java/org/apache/lens/api/result/QueryCostTO.java
index a247e3c..266a4b7 100644
--- a/lens-api/src/main/java/org/apache/lens/api/result/QueryCostTO.java
+++ b/lens-api/src/main/java/org/apache/lens/api/result/QueryCostTO.java
@@ -70,6 +70,6 @@ public class QueryCostTO extends QuerySubmitResult implements Serializable {
*/
@XmlElement
@Getter
- private QueryCostType type;
+ private QueryCostType costType;
}
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-api/src/main/java/org/apache/lens/api/util/MoxyJsonConfigurationContextResolver.java
----------------------------------------------------------------------
diff --git a/lens-api/src/main/java/org/apache/lens/api/util/MoxyJsonConfigurationContextResolver.java b/lens-api/src/main/java/org/apache/lens/api/util/MoxyJsonConfigurationContextResolver.java
new file mode 100644
index 0000000..6e5b73e
--- /dev/null
+++ b/lens-api/src/main/java/org/apache/lens/api/util/MoxyJsonConfigurationContextResolver.java
@@ -0,0 +1,38 @@
+/**
+ * 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.lens.api.util;
+
+import javax.ws.rs.ext.ContextResolver;
+
+import org.eclipse.persistence.jaxb.MarshallerProperties;
+import org.glassfish.jersey.moxy.json.MoxyJsonConfig;
+
+public final class MoxyJsonConfigurationContextResolver implements ContextResolver<MoxyJsonConfig> {
+
+ @Override
+ public MoxyJsonConfig getContext(final Class<?> type) {
+ final MoxyJsonConfig configuration = new MoxyJsonConfig();
+ configuration.setIncludeRoot(true);
+ configuration.setFormattedOutput(true);
+ configuration.setMarshalEmptyCollections(false);
+ configuration.marshallerProperty(MarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
+ configuration.unmarshallerProperty(MarshallerProperties.JSON_WRAPPER_AS_ARRAY_NAME, true);
+ return configuration;
+ }
+}
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-api/src/main/resources/cube-0.1.xsd
----------------------------------------------------------------------
diff --git a/lens-api/src/main/resources/cube-0.1.xsd b/lens-api/src/main/resources/cube-0.1.xsd
index d195b08..0f4dbea 100644
--- a/lens-api/src/main/resources/cube-0.1.xsd
+++ b/lens-api/src/main/resources/cube-0.1.xsd
@@ -225,7 +225,7 @@
</xs:annotation>
<xs:complexContent>
<xs:extension base="x_field">
- <xs:attribute type="x_measure_type" name="type" use="required"/>
+ <xs:attribute type="x_measure_type" name="_type" use="required"/>
<xs:attribute type="xs:string" name="default_aggr">
<xs:annotation>
<xs:documentation>
@@ -323,7 +323,7 @@
</xs:annotation>
<xs:element type="x_expr_spec" name="expr_spec" maxOccurs="unbounded" minOccurs="1"/>
</xs:sequence>
- <xs:attribute type="xs:string" name="type" use="required">
+ <xs:attribute type="xs:string" name="_type" use="required">
<xs:annotation>
<xs:documentation>
The type indicating what the evaluation of expression will produce. Allowed types are BOOLEAN, TINYINT,
@@ -424,7 +424,7 @@
</xs:annotation>
</xs:element>
</xs:sequence>
- <xs:attribute type="xs:string" name="type">
+ <xs:attribute type="xs:string" name="_type">
<xs:annotation>
<xs:documentation>
The type indicating what the evaluation of expression will produce. Allowed types are BOOLEAN,TINYINT,
@@ -689,7 +689,7 @@
</xs:documentation>
</xs:annotation>
<xs:attribute name="name" type="xs:string" use="required"/>
- <xs:attribute type="xs:string" name="type" use="required">
+ <xs:attribute type="xs:string" name="_type" use="required">
<xs:annotation>
<xs:documentation>
The type indicating what the evaluation of expression will produce. Allowed types are BOOLEAN, TINYINT,
@@ -1006,7 +1006,7 @@
</xs:documentation>
</xs:annotation>
<xs:sequence>
- <xs:element name="storage_table" minOccurs="1" maxOccurs="unbounded" type="x_storage_table_element"/>
+ <xs:element name="storage_table" minOccurs="0" maxOccurs="unbounded" type="x_storage_table_element"/>
</xs:sequence>
</xs:complexType>
@@ -1264,7 +1264,7 @@
</xs:documentation>
</xs:annotation>
</xs:attribute>
- <xs:attribute name="owner" type="xs:string" use="required">
+ <xs:attribute name="owner" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation>
Owner of the table.
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-cli/src/test/java/org/apache/lens/cli/LensCliApplicationTest.java
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/java/org/apache/lens/cli/LensCliApplicationTest.java b/lens-cli/src/test/java/org/apache/lens/cli/LensCliApplicationTest.java
index 8647ac3..8312335 100644
--- a/lens-cli/src/test/java/org/apache/lens/cli/LensCliApplicationTest.java
+++ b/lens-cli/src/test/java/org/apache/lens/cli/LensCliApplicationTest.java
@@ -32,7 +32,7 @@ import org.testng.annotations.BeforeTest;
*/
public class LensCliApplicationTest extends LensAllApplicationJerseyTest {
public static final String SUCCESS_MESSAGE = "<?xml version=\"1.0\" encoding=\"utf-8\" "
- + "standalone=\"yes\"?><result><status>succeeded</status><message></message></result>";
+ + "standalone=\"yes\"?><apiresult><status>succeeded</status><message></message></apiresult>";
@Override
protected int getTestPort() {
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-cli/src/test/java/org/apache/lens/cli/TestLensDimensionTableCommands.java
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/java/org/apache/lens/cli/TestLensDimensionTableCommands.java b/lens-cli/src/test/java/org/apache/lens/cli/TestLensDimensionTableCommands.java
index 30f4ec1..bf92044 100644
--- a/lens-cli/src/test/java/org/apache/lens/cli/TestLensDimensionTableCommands.java
+++ b/lens-cli/src/test/java/org/apache/lens/cli/TestLensDimensionTableCommands.java
@@ -214,7 +214,7 @@ public class TestLensDimensionTableCommands extends LensCliApplicationTest {
URL resource = TestLensDimensionTableCommands.class.getClassLoader().getResource("dim-local-storage-element.xml");
command.addNewDimStorage("dim_table2", new File(resource.toURI()));
result = command.getDimStorages("dim_table2");
- assertEquals(DIM_LOCAL, result);
+ assertEquals(result, DIM_LOCAL);
result = command.getStorageFromDim("dim_table2", DIM_LOCAL);
String partString = "DAILY";
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-cli/src/test/resources/cube_with_no_weight_facts.xml
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/resources/cube_with_no_weight_facts.xml b/lens-cli/src/test/resources/cube_with_no_weight_facts.xml
index 13736b2..4673ca4 100644
--- a/lens-cli/src/test/resources/cube_with_no_weight_facts.xml
+++ b/lens-cli/src/test/resources/cube_with_no_weight_facts.xml
@@ -22,18 +22,18 @@
<x_base_cube name="cube_with_no_weight_facts" xmlns="uri:lens:cube:0.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
<measures>
- <measure name="measure1" type="BIGINT" />
- <measure name="measure2" type="INT" default_aggr="SUM" />
- <measure name="measure3" type="FLOAT" default_aggr="MAX" start_time='2013-12-12T00:00:00' />
- <measure name="measure4" type="DOUBLE" default_aggr="MIN" />
+ <measure name="measure1" _type="BIGINT" />
+ <measure name="measure2" _type="INT" default_aggr="SUM" />
+ <measure name="measure3" _type="FLOAT" default_aggr="MAX" start_time='2013-12-12T00:00:00' />
+ <measure name="measure4" _type="DOUBLE" default_aggr="MIN" />
</measures>
<dim_attributes>
- <dim_attribute name="dim1" type="INT" />
- <dim_attribute name="dim2" type="INT" start_time='2013-12-01T00:00:00' />
- <dim_attribute name="dim3" type="INT"/>
+ <dim_attribute name="dim1" _type="INT" />
+ <dim_attribute name="dim2" _type="INT" start_time='2013-12-01T00:00:00' />
+ <dim_attribute name="dim3" _type="INT"/>
</dim_attributes>
<expressions>
- <expression name="expr_msr5" type="DOUBLE">
+ <expression name="expr_msr5" _type="DOUBLE">
<expr_spec expr = "measure3 + measure4" end_time='2013-12-12T00:00:00'/>
<expr_spec expr = "measure3 + measure4 + 0.01" start_time='2013-12-12T00:00:00'/>
</expression>
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-cli/src/test/resources/dim-local-storage-element.xml
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/resources/dim-local-storage-element.xml b/lens-cli/src/test/resources/dim-local-storage-element.xml
index 6503261..ad557f9 100644
--- a/lens-cli/src/test/resources/dim-local-storage-element.xml
+++ b/lens-cli/src/test/resources/dim-local-storage-element.xml
@@ -27,7 +27,7 @@
<storage_name>dim_local</storage_name>
<table_desc external="true" field_delimiter="," table_location="${project.build.directory}/metastore/examples/local">
<part_cols>
- <column comment="Time column" name="dt" type="STRING"/>
+ <column comment="Time column" name="dt" _type="STRING"/>
</part_cols>
<time_part_cols>dt</time_part_cols>
</table_desc>
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-cli/src/test/resources/dim_table.xml
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/resources/dim_table.xml b/lens-cli/src/test/resources/dim_table.xml
index 3bc9600..eb4ddfc 100644
--- a/lens-cli/src/test/resources/dim_table.xml
+++ b/lens-cli/src/test/resources/dim_table.xml
@@ -22,10 +22,10 @@
<x_dimension_table dimension_name="test_dim" table_name="dim_table" weight="100.0" xmlns="uri:lens:cube:0.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
<columns>
- <column comment="ID" name="id" type="INT"/>
- <column comment="name" name="name" type="STRING"/>
- <column comment="more details" name="detail" type="STRING"/>
- <column comment="d2 ID" name="d2id" type="INT"/>
+ <column comment="ID" name="id" _type="INT"/>
+ <column comment="name" name="name" _type="STRING"/>
+ <column comment="more details" name="detail" _type="STRING"/>
+ <column comment="d2 ID" name="d2id" _type="INT"/>
</columns>
<properties>
<property name="dim1.prop" value="d1"/>
@@ -39,7 +39,7 @@
<table_desc external="true" field_delimiter=","
table_location="${project.build.directory}/metastore/examples/local">
<part_cols>
- <column comment="Time column" name="dt" type="STRING"/>
+ <column comment="Time column" name="dt" _type="STRING"/>
</part_cols>
<time_part_cols>dt</time_part_cols>
</table_desc>
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-cli/src/test/resources/dim_table2.xml
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/resources/dim_table2.xml b/lens-cli/src/test/resources/dim_table2.xml
index 4c3f7d9..8440e28 100644
--- a/lens-cli/src/test/resources/dim_table2.xml
+++ b/lens-cli/src/test/resources/dim_table2.xml
@@ -22,9 +22,9 @@
<x_dimension_table dimension_name="test_dim" table_name="dim_table2" weight="100.0" xmlns="uri:lens:cube:0.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
<columns>
- <column comment="ID" name="id" type="INT"/>
- <column comment="name" name="name" type="STRING"/>
- <column comment="more details for dim2" name="detail2" type="STRING"/>
+ <column comment="ID" name="id" _type="INT"/>
+ <column comment="name" name="name" _type="STRING"/>
+ <column comment="more details for dim2" name="detail2" _type="STRING"/>
</columns>
<properties>
@@ -39,7 +39,7 @@
<table_desc external="true" field_delimiter=","
table_location="${project.build.directory}/metastore/examples/dim1">
<part_cols>
- <column comment="Time column" name="dt" type="STRING"/>
+ <column comment="Time column" name="dt" _type="STRING"/>
</part_cols>
<time_part_cols>dt</time_part_cols>
</table_desc>
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-cli/src/test/resources/fact-local-storage-element.xml
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/resources/fact-local-storage-element.xml b/lens-cli/src/test/resources/fact-local-storage-element.xml
index 6f30a1c..15a847b 100644
--- a/lens-cli/src/test/resources/fact-local-storage-element.xml
+++ b/lens-cli/src/test/resources/fact-local-storage-element.xml
@@ -28,7 +28,7 @@
<storage_name>fact_local</storage_name>
<table_desc external="true" field_delimiter="," table_location="${project.build.directory}/metastore/examples/local">
<part_cols>
- <column comment="Time column" name="dt" type="STRING"/>
+ <column comment="Time column" name="dt" _type="STRING"/>
</part_cols>
<time_part_cols>dt</time_part_cols>
</table_desc>
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-cli/src/test/resources/fact1.xml
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/resources/fact1.xml b/lens-cli/src/test/resources/fact1.xml
index f6d1f9c..b18a393 100644
--- a/lens-cli/src/test/resources/fact1.xml
+++ b/lens-cli/src/test/resources/fact1.xml
@@ -22,10 +22,10 @@
<x_fact_table cube_name="sample_cube" name="fact1" weight="100.0" xmlns="uri:lens:cube:0.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
<columns>
- <column comment="" name="dim1" type="INT"/>
- <column comment="" name="measure1" type="BIGINT"/>
- <column comment="" name="measure2" type="INT"/>
- <column comment="" name="measure3" type="FLOAT"/>
+ <column comment="" name="dim1" _type="INT"/>
+ <column comment="" name="measure1" _type="BIGINT"/>
+ <column comment="" name="measure2" _type="INT"/>
+ <column comment="" name="measure3" _type="FLOAT"/>
</columns>
<properties>
<property name="fact1.prop" value="f1"/>
@@ -42,7 +42,7 @@
<table_desc external="true" field_delimiter=","
table_location="${project.build.directory}/metastore/examples/fact1_local">
<part_cols>
- <column comment="Time column" name="dt" type="STRING"/>
+ <column comment="Time column" name="dt" _type="STRING"/>
</part_cols>
<time_part_cols>dt</time_part_cols>
</table_desc>
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-cli/src/test/resources/fact_without_weight.xml
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/resources/fact_without_weight.xml b/lens-cli/src/test/resources/fact_without_weight.xml
index 8371b0b..0c124b2 100644
--- a/lens-cli/src/test/resources/fact_without_weight.xml
+++ b/lens-cli/src/test/resources/fact_without_weight.xml
@@ -22,10 +22,10 @@
<x_fact_table cube_name="cube_with_no_weight_facts" name="fact_without_wt" xmlns="uri:lens:cube:0.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
<columns>
- <column comment="" name="dim1" type="INT"/>
- <column comment="" name="measure1" type="BIGINT"/>
- <column comment="" name="measure2" type="INT"/>
- <column comment="" name="measure3" type="FLOAT"/>
+ <column comment="" name="dim1" _type="INT"/>
+ <column comment="" name="measure1" _type="BIGINT"/>
+ <column comment="" name="measure2" _type="INT"/>
+ <column comment="" name="measure3" _type="FLOAT"/>
</columns>
<properties>
<property name="fact_without_wt.prop" value="f1"/>
@@ -42,7 +42,7 @@
<table_desc external="true" field_delimiter=","
table_location="${project.build.directory}/metastore/examples/fact_local_without_wt">
<part_cols>
- <column comment="Time column" name="dt" type="STRING"/>
+ <column comment="Time column" name="dt" _type="STRING"/>
</part_cols>
<time_part_cols>dt</time_part_cols>
</table_desc>
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-cli/src/test/resources/lens-client-site.xml
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/resources/lens-client-site.xml b/lens-cli/src/test/resources/lens-client-site.xml
index e500bda..bf1443d 100644
--- a/lens-cli/src/test/resources/lens-client-site.xml
+++ b/lens-cli/src/test/resources/lens-client-site.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
@@ -19,8 +19,6 @@
under the License.
-->
-<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
-
<configuration>
<property>
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-cli/src/test/resources/logback.xml
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/resources/logback.xml b/lens-cli/src/test/resources/logback.xml
new file mode 100644
index 0000000..57cf4a4
--- /dev/null
+++ b/lens-cli/src/test/resources/logback.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<configuration>
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%d{dd MMM yyyy HH:mm:ss,SSS} [%X{logSegregationId}] [%t] %-5p %c - %m%n</pattern>
+ </encoder>
+ <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+ <level>ERROR</level>
+ </filter>
+ </appender>
+ <appender name="TEST_LOG_FILE" class="ch.qos.logback.core.FileAppender">
+ <file>target/test.log</file>
+ <encoder>
+ <pattern>%d{dd MMM yyyy HH:mm:ss,SSS} %X{logSegregationId} [%t] %-5p %c - %m%n</pattern>
+ </encoder>
+ <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+ <level>INFO</level>
+ </filter>
+ </appender>
+ <logger name="org.apache.lens.client" additivity="false" level="DEBUG">
+ <appender-ref ref="STDOUT"/>
+ <appender-ref ref="TEST_LOG_FILE"/>
+ </logger>
+ <root level="INFO">
+ <appender-ref ref="STDOUT"/>
+ <appender-ref ref="TEST_LOG_FILE"/>
+ </root>
+</configuration>
+
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-cli/src/test/resources/sample-cube.xml
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/resources/sample-cube.xml b/lens-cli/src/test/resources/sample-cube.xml
index e3b3284..9bcf177 100644
--- a/lens-cli/src/test/resources/sample-cube.xml
+++ b/lens-cli/src/test/resources/sample-cube.xml
@@ -26,23 +26,23 @@
<property name="cube.sample_cube.timed.dimensions.list" value="dt" />
</properties>
<measures>
- <measure name="measure1" type="BIGINT" />
- <measure name="measure2" type="INT" default_aggr="SUM" />
- <measure name="measure3" type="FLOAT" default_aggr="MAX" start_time='2013-12-12T00:00:00' />
- <measure name="measure4" type="DOUBLE" default_aggr="MIN" />
+ <measure name="measure1" _type="BIGINT" />
+ <measure name="measure2" _type="INT" default_aggr="SUM" />
+ <measure name="measure3" _type="FLOAT" default_aggr="MAX" start_time='2013-12-12T00:00:00' />
+ <measure name="measure4" _type="DOUBLE" default_aggr="MIN" />
</measures>
<dim_attributes>
- <dim_attribute name="dim1" type="INT" />
- <dim_attribute name="dim2" type="INT" start_time='2013-12-01T00:00:00' />
- <dim_attribute name="dim3" type="INT"/>
- <dim_attribute name="dimDetail" type="string" description="City name to which the customer belongs"
+ <dim_attribute name="dim1" _type="INT" />
+ <dim_attribute name="dim2" _type="INT" start_time='2013-12-01T00:00:00' />
+ <dim_attribute name="dim3" _type="INT"/>
+ <dim_attribute name="dimDetail" _type="string" description="City name to which the customer belongs"
display_string="Customer City">
<chain_ref_column chain_name="testdimchain" ref_col="detail" />
<chain_ref_column chain_name="testdetailchain" ref_col="name" />
</dim_attribute>
</dim_attributes>
<expressions>
- <expression name="expr_msr5" type="DOUBLE">
+ <expression name="expr_msr5" _type="DOUBLE">
<expr_spec expr = "measure3 + measure4" end_time='2013-12-12T00:00:00'/>
<expr_spec expr = "measure3 + measure4 + 0.01" start_time='2013-12-12T00:00:00'/>
</expression>
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-cli/src/test/resources/test-detail.xml
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/resources/test-detail.xml b/lens-cli/src/test/resources/test-detail.xml
index bb54354..b51c188 100644
--- a/lens-cli/src/test/resources/test-detail.xml
+++ b/lens-cli/src/test/resources/test-detail.xml
@@ -22,8 +22,8 @@
<x_dimension name="test_detail" xmlns="uri:lens:cube:0.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
<attributes>
- <dim_attribute name="id" type="INT" />
- <dim_attribute name="name" type="STRING" />
+ <dim_attribute name="id" _type="INT" />
+ <dim_attribute name="name" _type="STRING" />
</attributes>
<properties>
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-cli/src/test/resources/test-dimension.xml
----------------------------------------------------------------------
diff --git a/lens-cli/src/test/resources/test-dimension.xml b/lens-cli/src/test/resources/test-dimension.xml
index 2fa47f1..01de8e6 100644
--- a/lens-cli/src/test/resources/test-dimension.xml
+++ b/lens-cli/src/test/resources/test-dimension.xml
@@ -22,20 +22,20 @@
<x_dimension name="test_dim" xmlns="uri:lens:cube:0.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
<attributes>
- <dim_attribute name="id" type="INT" />
- <dim_attribute name="name" type="STRING" />
- <dim_attribute name="detail" type="STRING" start_time='2013-12-01T00:00:00' />
- <dim_attribute name="d2id" type="INT" start_time='2013-12-01T00:00:00'/>
- <dim_attribute name="inline" type="STRING" >
+ <dim_attribute name="id" _type="INT" />
+ <dim_attribute name="name" _type="STRING" />
+ <dim_attribute name="detail" _type="STRING" start_time='2013-12-01T00:00:00' />
+ <dim_attribute name="d2id" _type="INT" start_time='2013-12-01T00:00:00'/>
+ <dim_attribute name="inline" _type="STRING" >
<values>A</values>
<values>B</values>
<values>C</values>
</dim_attribute>
<dim_attribute name="location">
<hierarchy>
- <dim_attribute name="zipcode" type="INT" />
- <dim_attribute name="city" type="STRING" />
- <dim_attribute name="state" type="STRING" />
+ <dim_attribute name="zipcode" _type="INT" />
+ <dim_attribute name="city" _type="STRING" />
+ <dim_attribute name="state" _type="STRING" />
</hierarchy>
</dim_attribute>
</attributes>
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-client/src/main/java/org/apache/lens/client/LensConnection.java
----------------------------------------------------------------------
diff --git a/lens-client/src/main/java/org/apache/lens/client/LensConnection.java b/lens-client/src/main/java/org/apache/lens/client/LensConnection.java
index 30a7e2c..eeb473a 100644
--- a/lens-client/src/main/java/org/apache/lens/client/LensConnection.java
+++ b/lens-client/src/main/java/org/apache/lens/client/LensConnection.java
@@ -34,12 +34,14 @@ import javax.ws.rs.core.Response;
import org.apache.lens.api.APIResult;
import org.apache.lens.api.LensSessionHandle;
import org.apache.lens.api.StringList;
+import org.apache.lens.api.util.MoxyJsonConfigurationContextResolver;
import org.apache.lens.client.exceptions.LensClientServerConnectionException;
import org.glassfish.jersey.media.multipart.FormDataBodyPart;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataMultiPart;
import org.glassfish.jersey.media.multipart.MultiPartFeature;
+import org.glassfish.jersey.moxy.json.MoxyJsonFeature;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
@@ -110,7 +112,8 @@ public class LensConnection {
}
public Client buildClient() {
- ClientBuilder cb = ClientBuilder.newBuilder().register(MultiPartFeature.class);
+ ClientBuilder cb = ClientBuilder.newBuilder().register(MultiPartFeature.class).register(MoxyJsonFeature.class)
+ .register(MoxyJsonConfigurationContextResolver.class);
Iterator<Class<?>> itr = params.getRequestFilters().iterator();
while (itr.hasNext()) {
cb.register(itr.next());
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-client/src/main/java/org/apache/lens/client/LensMetadataClient.java
----------------------------------------------------------------------
diff --git a/lens-client/src/main/java/org/apache/lens/client/LensMetadataClient.java b/lens-client/src/main/java/org/apache/lens/client/LensMetadataClient.java
index 4dec1a2..07ce41e 100644
--- a/lens-client/src/main/java/org/apache/lens/client/LensMetadataClient.java
+++ b/lens-client/src/main/java/org/apache/lens/client/LensMetadataClient.java
@@ -25,6 +25,7 @@ import java.util.Date;
import java.util.List;
import javax.ws.rs.client.*;
+import javax.ws.rs.core.GenericEntity;
import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.MediaType;
import javax.xml.bind.*;
@@ -35,8 +36,6 @@ import org.apache.lens.api.StringList;
import org.apache.lens.api.jaxb.LensJAXBContext;
import org.apache.lens.api.metastore.*;
-import org.glassfish.jersey.media.multipart.*;
-
import com.google.common.base.Joiner;
import lombok.extern.slf4j.Slf4j;
@@ -87,30 +86,27 @@ public class LensMetadataClient {
public String getCurrentDatabase() {
WebTarget target = getMetastoreWebTarget();
- String database = target.path("databases").path("current")
+ return target.path("databases").path("current")
.queryParam("sessionid", connection.getSessionHandle())
.request().get(String.class);
- return database;
}
public APIResult setDatabase(String database) {
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("databases").path("current")
+ return target.path("databases").path("current")
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML_TYPE)
.put(Entity.xml(database), APIResult.class);
- return result;
}
public APIResult createDatabase(String database, boolean ignoreIfExists) {
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("databases")
+ return target.path("databases")
.queryParam("sessionid", this.connection.getSessionHandle())
.queryParam("ignoreIfExisting", ignoreIfExists)
.request(MediaType.APPLICATION_XML)
.post(Entity.xml(database), APIResult.class);
- return result;
}
public APIResult createDatabase(String database) {
@@ -156,19 +152,17 @@ public class LensMetadataClient {
public APIResult dropAllCubes() {
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("cubes")
+ return target.path("cubes")
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML).delete(APIResult.class);
- return result;
}
public APIResult createCube(XCube cube) {
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("cubes")
+ return target.path("cubes")
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
- .post(Entity.xml(objFact.createXCube(cube)), APIResult.class);
- return result;
+ .post(Entity.xml(new GenericEntity<JAXBElement<XCube>>(objFact.createXCube(cube)){}), APIResult.class);
}
private <T> T readFromXML(String filename) throws JAXBException, IOException {
@@ -194,11 +188,10 @@ public class LensMetadataClient {
public APIResult updateCube(String cubeName, XCube cube) {
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("cubes").path(cubeName)
+ return target.path("cubes").path(cubeName)
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
- .put(Entity.xml(objFact.createXCube(cube)), APIResult.class);
- return result;
+ .put(Entity.xml(new GenericEntity<JAXBElement<XCube>>(objFact.createXCube(cube)){}), APIResult.class);
}
public APIResult updateCube(String cubeName, String cubeSpec) {
@@ -239,10 +232,9 @@ public class LensMetadataClient {
public APIResult dropCube(String cubeName) {
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("cubes").path(cubeName)
+ return target.path("cubes").path(cubeName)
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML).delete(APIResult.class);
- return result;
}
public List<String> getAllDimensions() {
@@ -255,19 +247,18 @@ public class LensMetadataClient {
public APIResult dropAllDimensions() {
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("dimensions")
+ return target.path("dimensions")
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML).delete(APIResult.class);
- return result;
}
public APIResult createDimension(XDimension dimension) {
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("dimensions")
+ return target.path("dimensions")
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
- .post(Entity.xml(objFact.createXDimension(dimension)), APIResult.class);
- return result;
+ .post(Entity.xml(new GenericEntity<JAXBElement<XDimension>>(objFact.createXDimension(dimension)){}),
+ APIResult.class);
}
public APIResult createDimension(String dimSpec) {
@@ -280,11 +271,11 @@ public class LensMetadataClient {
public APIResult updateDimension(String dimName, XDimension dimension) {
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("dimensions").path(dimName)
+ return target.path("dimensions").path(dimName)
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
- .put(Entity.xml(objFact.createXDimension(dimension)), APIResult.class);
- return result;
+ .put(Entity.xml(new GenericEntity<JAXBElement<XDimension>>(objFact.createXDimension(dimension)){}),
+ APIResult.class);
}
public APIResult updateDimension(String dimName, String dimSpec) {
@@ -306,10 +297,9 @@ public class LensMetadataClient {
public APIResult dropDimension(String dimName) {
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("dimensions").path(dimName)
+ return target.path("dimensions").path(dimName)
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML).delete(APIResult.class);
- return result;
}
public List<String> getAllStorages() {
@@ -323,11 +313,10 @@ public class LensMetadataClient {
public APIResult createNewStorage(XStorage storage) {
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("storages")
+ return target.path("storages")
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
- .post(Entity.xml(objFact.createXStorage(storage)), APIResult.class);
- return result;
+ .post(Entity.xml(new GenericEntity<JAXBElement<XStorage>>(objFact.createXStorage(storage)){}), APIResult.class);
}
@@ -341,20 +330,18 @@ public class LensMetadataClient {
public APIResult dropAllStorages() {
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("storages")
+ return target.path("storages")
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
.delete(APIResult.class);
- return result;
}
public APIResult updateStorage(String storageName, XStorage storage) {
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("storages").path(storageName)
+ return target.path("storages").path(storageName)
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
- .put(Entity.xml(objFact.createXStorage(storage)), APIResult.class);
- return result;
+ .put(Entity.xml(new GenericEntity<JAXBElement<XStorage>>(objFact.createXStorage(storage)){}), APIResult.class);
}
public APIResult updateStorage(String storageName, String storage) {
@@ -377,11 +364,10 @@ public class LensMetadataClient {
public APIResult dropStorage(String storageName) {
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("storages").path(storageName)
+ return target.path("storages").path(storageName)
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
.delete(APIResult.class);
- return result;
}
public List<String> getAllFactTables(String cubeName) {
@@ -411,12 +397,11 @@ public class LensMetadataClient {
public APIResult deleteAllFactTables(boolean cascade) {
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("facts")
+ return target.path("facts")
.queryParam("sessionid", this.connection.getSessionHandle())
.queryParam("cascade", cascade)
.request(MediaType.APPLICATION_XML)
.delete(APIResult.class);
- return result;
}
@@ -432,17 +417,10 @@ public class LensMetadataClient {
public APIResult createFactTable(XFactTable f) {
WebTarget target = getMetastoreWebTarget();
- FormDataMultiPart mp = new FormDataMultiPart();
- mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid")
- .build(), this.connection.getSessionHandle(), MediaType.APPLICATION_XML_TYPE));
- mp.bodyPart(new FormDataBodyPart(
- FormDataContentDisposition.name("fact").fileName("fact").build(),
- objFact.createXFactTable(f), MediaType.APPLICATION_XML_TYPE));
- APIResult result = target.path("facts")
- .request(MediaType.APPLICATION_XML_TYPE)
- .post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE),
- APIResult.class);
- return result;
+ return target.path("facts")
+ .queryParam("sessionid", this.connection.getSessionHandle())
+ .request(MediaType.APPLICATION_XML)
+ .post(Entity.xml(new GenericEntity<JAXBElement<XFactTable>>(objFact.createXFactTable(f)){}), APIResult.class);
}
public APIResult createFactTable(String factSpec) {
@@ -455,11 +433,10 @@ public class LensMetadataClient {
public APIResult updateFactTable(String factName, XFactTable table) {
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("facts").path(factName)
+ return target.path("facts").path(factName)
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML_TYPE)
- .put(Entity.xml(objFact.createXFactTable(table)), APIResult.class);
- return result;
+ .put(Entity.xml(new GenericEntity<JAXBElement<XFactTable>>(objFact.createXFactTable(table)){}), APIResult.class);
}
public APIResult updateFactTable(String factName, String table) {
@@ -472,12 +449,11 @@ public class LensMetadataClient {
public APIResult dropFactTable(String factName, boolean cascade) {
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("facts").path(factName)
+ return target.path("facts").path(factName)
.queryParam("sessionid", this.connection.getSessionHandle())
.queryParam("cascade", cascade)
.request(MediaType.APPLICATION_XML)
.delete(APIResult.class);
- return result;
}
public APIResult dropFactTable(String factName) {
@@ -495,20 +471,19 @@ public class LensMetadataClient {
public APIResult dropAllStoragesOfFactTable(String factName) {
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("facts").path(factName).path("storages")
+ return target.path("facts").path(factName).path("storages")
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
.delete(APIResult.class);
- return result;
}
public APIResult addStorageToFactTable(String factname, XStorageTableElement storage) {
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("facts").path(factname).path("storages")
+ return target.path("facts").path(factname).path("storages")
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
- .post(Entity.xml(objFact.createXStorageTableElement(storage)), APIResult.class);
- return result;
+ .post(Entity.xml(new GenericEntity<JAXBElement<XStorageTableElement>>(
+ objFact.createXStorageTableElement(storage)){}), APIResult.class);
}
public APIResult addStorageToFactTable(String factname, String storageSpec) {
@@ -521,11 +496,10 @@ public class LensMetadataClient {
public APIResult dropStorageFromFactTable(String factName, String storageName) {
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("facts").path(factName).path("storages").path(storageName)
+ return target.path("facts").path(factName).path("storages").path(storageName)
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
.delete(APIResult.class);
- return result;
}
public XStorageTableElement getStorageOfFactTable(String factName, String storageName) {
@@ -557,13 +531,12 @@ public class LensMetadataClient {
public APIResult dropPartitionsOfFactTable(String factName, String storage, String filter) {
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("facts").path(factName)
+ return target.path("facts").path(factName)
.path("storages").path(storage).path("partitions")
.queryParam("sessionid", this.connection.getSessionHandle())
.queryParam("filter", filter)
.request(MediaType.APPLICATION_XML)
.delete(APIResult.class);
- return result;
}
public APIResult dropPartitionsOfFactTable(String factName, String storage) {
@@ -575,13 +548,12 @@ public class LensMetadataClient {
String values = Joiner.on(",").skipNulls().join(partitions);
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("facts").path(factName)
+ return target.path("facts").path(factName)
.path("storages").path(storage).path("partitions")
.queryParam("sessionid", this.connection.getSessionHandle())
.queryParam("values", values)
.request(MediaType.APPLICATION_XML)
.delete(APIResult.class);
- return result;
}
@@ -610,18 +582,11 @@ public class LensMetadataClient {
public APIResult createDimensionTable(XDimensionTable table) {
WebTarget target = getMetastoreWebTarget();
-
- FormDataMultiPart mp = new FormDataMultiPart();
- mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionid").build(),
- this.connection.getSessionHandle(), MediaType.APPLICATION_XML_TYPE));
- mp.bodyPart(new FormDataBodyPart(
- FormDataContentDisposition.name("dimensionTable").fileName("dimtable").build(),
- objFact.createXDimensionTable(table), MediaType.APPLICATION_XML_TYPE));
-
- APIResult result = target.path("dimtables")
+ return target.path("dimtables")
+ .queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
- .post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE), APIResult.class);
- return result;
+ .post(Entity.xml(new GenericEntity<JAXBElement<XDimensionTable>>(objFact.createXDimensionTable(table)){}),
+ APIResult.class);
}
public APIResult createDimensionTable(String tableXml) {
@@ -636,11 +601,11 @@ public class LensMetadataClient {
public APIResult updateDimensionTable(XDimensionTable table) {
String dimTableName = table.getTableName();
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("dimtables").path(dimTableName)
+ return target.path("dimtables").path(dimTableName)
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
- .put(Entity.xml(objFact.createXDimensionTable(table)), APIResult.class);
- return result;
+ .put(Entity.xml(new GenericEntity<JAXBElement<XDimensionTable>>(objFact.createXDimensionTable(table)){}),
+ APIResult.class);
}
public APIResult updateDimensionTable(String dimTblName, String dimSpec) {
@@ -655,12 +620,11 @@ public class LensMetadataClient {
public APIResult dropDimensionTable(String table, boolean cascade) {
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("dimtables").path(table)
+ return target.path("dimtables").path(table)
.queryParam("sessionid", this.connection.getSessionHandle())
.queryParam("cascade", cascade)
.request(MediaType.APPLICATION_XML)
.delete(APIResult.class);
- return result;
}
public APIResult dropDimensionTable(String table) {
@@ -689,11 +653,11 @@ public class LensMetadataClient {
public APIResult addStorageToDimTable(String dimTblName, XStorageTableElement table) {
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("dimtables").path(dimTblName).path("storages")
+ return target.path("dimtables").path(dimTblName).path("storages")
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
- .post(Entity.xml(objFact.createXStorageTableElement(table)), APIResult.class);
- return result;
+ .post(Entity.xml(new GenericEntity<JAXBElement<XStorageTableElement>>(
+ objFact.createXStorageTableElement(table)){}), APIResult.class);
}
public APIResult addStorageToDimTable(String dimTblName, String table) {
@@ -717,22 +681,20 @@ public class LensMetadataClient {
public APIResult dropAllStoragesOfDimension(String dimTblName) {
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("dimtables").path(dimTblName).path("storages")
+ return target.path("dimtables").path(dimTblName).path("storages")
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
.delete(APIResult.class);
- return result;
}
public APIResult dropStoragesOfDimensionTable(String dimTblName, String storage) {
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("dimtables").path(dimTblName)
+ return target.path("dimtables").path(dimTblName)
.path("storages").path(storage)
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
.delete(APIResult.class);
- return result;
}
public List<XPartition> getAllPartitionsOfDimensionTable(String dimTblName, String storage,
@@ -755,13 +717,12 @@ public class LensMetadataClient {
public APIResult dropAllPartitionsOfDimensionTable(String dimTblName, String storage,
String filter) {
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("dimtables").path(dimTblName)
+ return target.path("dimtables").path(dimTblName)
.path("storages").path(storage).path("partitions")
.queryParam("sessionid", this.connection.getSessionHandle())
.queryParam("filter", filter)
.request(MediaType.APPLICATION_XML)
.delete(APIResult.class);
- return result;
}
public APIResult dropAllPartitionsOfDimensionTable(String dimTblName, String storage) {
@@ -772,24 +733,23 @@ public class LensMetadataClient {
List<String> vals) {
String values = Joiner.on(",").skipNulls().join(vals);
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("dimtables").path(dimTblName)
+ return target.path("dimtables").path(dimTblName)
.path("storages").path(storage).path("partitions")
.queryParam("sessionid", this.connection.getSessionHandle())
.queryParam("values", values)
.request(MediaType.APPLICATION_XML)
.delete(APIResult.class);
- return result;
}
public APIResult addPartitionToDimensionTable(String dimTblName, String storage,
XPartition partition) {
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("dimtables").path(dimTblName)
+ return target.path("dimtables").path(dimTblName)
.path("storages").path(storage).path("partition")
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
- .post(Entity.xml(objFact.createXPartition(partition)), APIResult.class);
- return result;
+ .post(Entity.xml(new GenericEntity<JAXBElement<XPartition>>(objFact.createXPartition(partition)){}),
+ APIResult.class);
}
public APIResult addPartitionToDimensionTable(String dimTblName, String storage,
@@ -804,12 +764,12 @@ public class LensMetadataClient {
public APIResult addPartitionsToDimensionTable(String dimTblName, String storage,
XPartitionList partitions) {
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("dimtables").path(dimTblName)
+ return target.path("dimtables").path(dimTblName)
.path("storages").path(storage).path("partitions")
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
- .post(Entity.xml(objFact.createXPartitionList(partitions)), APIResult.class);
- return result;
+ .post(Entity.xml(new GenericEntity<JAXBElement<XPartitionList>>(objFact.createXPartitionList(partitions)){}),
+ APIResult.class);
}
public APIResult addPartitionsToDimensionTable(String dimTblName, String storage,
@@ -824,12 +784,12 @@ public class LensMetadataClient {
public APIResult addPartitionToFactTable(String fact, String storage,
XPartition partition) {
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("facts").path(fact)
+ return target.path("facts").path(fact)
.path("storages").path(storage).path("partition")
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
- .post(Entity.xml(objFact.createXPartition(partition)), APIResult.class);
- return result;
+ .post(Entity.xml(new GenericEntity<JAXBElement<XPartition>>(objFact.createXPartition(partition)){}),
+ APIResult.class);
}
public APIResult addPartitionToFactTable(String fact, String storage,
@@ -844,12 +804,12 @@ public class LensMetadataClient {
public APIResult addPartitionsToFactTable(String fact, String storage,
XPartitionList partitions) {
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("facts").path(fact)
+ return target.path("facts").path(fact)
.path("storages").path(storage).path("partitions")
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
- .post(Entity.xml(objFact.createXPartitionList(partitions)), APIResult.class);
- return result;
+ .post(Entity.xml(new GenericEntity<JAXBElement<XPartitionList>>(objFact.createXPartitionList(partitions)){}),
+ APIResult.class);
}
public APIResult addPartitionsToFactTable(String fact, String storage,
@@ -864,12 +824,12 @@ public class LensMetadataClient {
public APIResult updatePartitionOfDimensionTable(String dimTblName, String storage,
XPartition partition) {
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("dimtables").path(dimTblName)
+ return target.path("dimtables").path(dimTblName)
.path("storages").path(storage).path("partition")
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
- .put(Entity.xml(objFact.createXPartition(partition)), APIResult.class);
- return result;
+ .put(Entity.xml(new GenericEntity<JAXBElement<XPartition>>(objFact.createXPartition(partition)){}),
+ APIResult.class);
}
public APIResult updatePartitionOfDimensionTable(String dimTblName, String storage,
@@ -884,12 +844,12 @@ public class LensMetadataClient {
public APIResult updatePartitionsOfDimensionTable(String dimTblName, String storage,
XPartitionList partitions) {
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("dimtables").path(dimTblName)
+ return target.path("dimtables").path(dimTblName)
.path("storages").path(storage).path("partitions")
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
- .put(Entity.xml(objFact.createXPartitionList(partitions)), APIResult.class);
- return result;
+ .put(Entity.xml(new GenericEntity<JAXBElement<XPartitionList>>(objFact.createXPartitionList(partitions)){}),
+ APIResult.class);
}
public APIResult updatePartitionsOfDimensionTable(String dimTblName, String storage,
@@ -904,12 +864,12 @@ public class LensMetadataClient {
public APIResult updatePartitionOfFactTable(String fact, String storage,
XPartition partition) {
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("facts").path(fact)
+ return target.path("facts").path(fact)
.path("storages").path(storage).path("partition")
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
- .put(Entity.xml(objFact.createXPartition(partition)), APIResult.class);
- return result;
+ .put(Entity.xml(new GenericEntity<JAXBElement<XPartition>>(objFact.createXPartition(partition)){}),
+ APIResult.class);
}
public APIResult updatePartitionOfFactTable(String fact, String storage,
@@ -924,12 +884,12 @@ public class LensMetadataClient {
public APIResult updatePartitionsOfFactTable(String fact, String storage,
XPartitionList partitions) {
WebTarget target = getMetastoreWebTarget();
- APIResult result = target.path("facts").path(fact)
+ return target.path("facts").path(fact)
.path("storages").path(storage).path("partitions")
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
- .put(Entity.xml(objFact.createXPartitionList(partitions)), APIResult.class);
- return result;
+ .put(Entity.xml(new GenericEntity<JAXBElement<XPartitionList>>(objFact.createXPartitionList(partitions)){}),
+ APIResult.class);
}
public APIResult updatePartitionsOfFactTable(String fact, String storage,
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-client/src/main/java/org/apache/lens/client/LensStatement.java
----------------------------------------------------------------------
diff --git a/lens-client/src/main/java/org/apache/lens/client/LensStatement.java b/lens-client/src/main/java/org/apache/lens/client/LensStatement.java
index 8de7708..0009182 100644
--- a/lens-client/src/main/java/org/apache/lens/client/LensStatement.java
+++ b/lens-client/src/main/java/org/apache/lens/client/LensStatement.java
@@ -28,6 +28,7 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.apache.lens.api.APIResult;
+import org.apache.lens.api.LensConf;
import org.apache.lens.api.query.*;
import org.apache.lens.api.query.QueryStatus.Status;
@@ -41,11 +42,13 @@ import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataMultiPart;
import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
/**
* Top level class which is used to execute lens queries.
*/
@RequiredArgsConstructor
+@Slf4j
public class LensStatement {
/** The connection. */
@@ -125,7 +128,7 @@ public class LensStatement {
*/
public LensAPIResult<QueryPrepareHandle> prepareQuery(String sql, String queryName) throws LensAPIException {
if (!connection.isOpen()) {
- throw new IllegalStateException("Lens Connection has to be " + "established before querying");
+ throw new IllegalStateException("Lens Connection has to be established before querying");
}
Client client = connection.buildClient();
@@ -151,7 +154,7 @@ public class LensStatement {
*/
public LensAPIResult<QueryPlan> explainAndPrepare(String sql, String queryName) throws LensAPIException {
if (!connection.isOpen()) {
- throw new IllegalStateException("Lens Connection has to be " + "established before querying");
+ throw new IllegalStateException("Lens Connection has to be established before querying");
}
Client client = connection.buildClient();
@@ -186,6 +189,8 @@ public class LensStatement {
if (!StringUtils.isBlank(queryName)) {
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("queryName").build(), queryName));
}
+ mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), new LensConf(),
+ MediaType.APPLICATION_XML_TYPE));
return mp;
}
@@ -260,6 +265,7 @@ public class LensStatement {
.get(LensQuery.class);
return query;
} catch (Exception e) {
+ log.error("Failed to get query status, cause:", e);
throw new IllegalStateException("Failed to get query status, cause:" + e.getMessage());
}
}
@@ -277,7 +283,8 @@ public class LensStatement {
return target.path(handle.toString()).queryParam("sessionid", connection.getSessionHandle()).request()
.get(LensPreparedQuery.class);
} catch (Exception e) {
- throw new IllegalStateException("Failed to get query status, cause:" + e.getMessage());
+ log.error("Failed to get prepared query, cause:", e);
+ throw new IllegalStateException("Failed to get prepared query, cause:" + e.getMessage());
}
}
@@ -290,7 +297,7 @@ public class LensStatement {
*/
private LensAPIResult<QueryHandle> executeQuery(String sql, String queryName) throws LensAPIException {
if (!connection.isOpen()) {
- throw new IllegalStateException("Lens Connection has to be " + "established before querying");
+ throw new IllegalStateException("Lens Connection has to be established before querying");
}
Client client = connection.buildClient();
@@ -301,7 +308,8 @@ public class LensStatement {
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute"));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("queryName").build(), queryName == null ? ""
: queryName));
-
+ mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), new LensConf(),
+ MediaType.APPLICATION_XML_TYPE));
WebTarget target = getQueryWebTarget(client);
Response response = target.request().post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE));
@@ -333,7 +341,8 @@ public class LensStatement {
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "execute"));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("queryName").build(), queryName == null ? ""
: queryName));
-
+ mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), new LensConf(),
+ MediaType.APPLICATION_XML_TYPE));
QueryHandle handle = target.request()
.post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE), QueryHandle.class);
@@ -358,7 +367,8 @@ public class LensStatement {
.getSessionHandle(), MediaType.APPLICATION_XML_TYPE));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("query").build(), sql));
mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("operation").build(), "explain"));
-
+ mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("conf").fileName("conf").build(), new LensConf(),
+ MediaType.APPLICATION_XML_TYPE));
WebTarget target = getQueryWebTarget(client);
Response response = target.request().post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE));
@@ -432,6 +442,7 @@ public class LensStatement {
return target.path(query.getQueryHandle().toString()).path("resultsetmetadata")
.queryParam("sessionid", connection.getSessionHandle()).request().get(QueryResultSetMetadata.class);
} catch (Exception e) {
+ log.error("Failed to get resultset metadata, cause:", e);
throw new IllegalStateException("Failed to get resultset metadata, cause:" + e.getMessage());
}
}
@@ -452,15 +463,17 @@ public class LensStatement {
*/
public QueryResult getResultSet(LensQuery query) {
if (query.getStatus().getStatus() != QueryStatus.Status.SUCCESSFUL) {
- throw new IllegalArgumentException("Result set metadata " + "can be only queries for successful queries");
+ throw new IllegalArgumentException("Result set metadata can be only queries for successful queries");
}
Client client = connection.buildClient();
try {
WebTarget target = getQueryWebTarget(client);
return target.path(query.getQueryHandle().toString()).path("resultset")
- .queryParam("sessionid", connection.getSessionHandle()).request().get(QueryResult.class);
+ .queryParam("sessionid", connection.getSessionHandle()).request(MediaType.APPLICATION_XML_TYPE).get(
+ QueryResult.class);
} catch (Exception e) {
+ log.error("Failed to get resultset, cause:", e);
throw new IllegalStateException("Failed to get resultset, cause:" + e.getMessage());
}
}
@@ -482,7 +495,8 @@ public class LensStatement {
return target.path(query.getQueryHandle().toString()).path("httpresultset")
.queryParam("sessionid", connection.getSessionHandle()).request().get();
} catch (Exception e) {
- throw new IllegalStateException("Failed to get resultset, cause:" + e.getMessage());
+ log.error("Failed to get http resultset, cause:", e);
+ throw new IllegalStateException("Failed to get http resultset, cause:" + e.getMessage());
}
}
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-examples/src/main/java/org/apache/lens/examples/SampleMetastore.java
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/java/org/apache/lens/examples/SampleMetastore.java b/lens-examples/src/main/java/org/apache/lens/examples/SampleMetastore.java
index 1fbd358..b6385d4 100644
--- a/lens-examples/src/main/java/org/apache/lens/examples/SampleMetastore.java
+++ b/lens-examples/src/main/java/org/apache/lens/examples/SampleMetastore.java
@@ -185,6 +185,9 @@ public class SampleMetastore {
if (metastore.retCode != 0) {
System.exit(metastore.retCode);
}
+ } catch (Throwable th) {
+ log.error("Error during creating sample metastore", th);
+ throw th;
} finally {
if (metastore != null) {
metastore.close();
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-examples/src/main/resources/city.xml
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/city.xml b/lens-examples/src/main/resources/city.xml
index 1a89a2a..fe89ca7 100644
--- a/lens-examples/src/main/resources/city.xml
+++ b/lens-examples/src/main/resources/city.xml
@@ -22,10 +22,10 @@
<x_dimension name="city" xmlns="uri:lens:cube:0.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
<attributes>
- <dim_attribute name="id" type="INT"/>
- <dim_attribute name="name" type="STRING"/>
- <dim_attribute name="POI" type="ARRAY<STRING>" description="Point of interests"/>
- <dim_attribute name="population" type="BIGINT" />
+ <dim_attribute name="id" _type="INT"/>
+ <dim_attribute name="name" _type="STRING"/>
+ <dim_attribute name="POI" _type="ARRAY<STRING>" description="Point of interests"/>
+ <dim_attribute name="population" _type="BIGINT" />
</attributes>
<properties>
<property name="dimension.city.timed.dimension" value="dt"/>
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-examples/src/main/resources/city_subset.xml
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/city_subset.xml b/lens-examples/src/main/resources/city_subset.xml
index 18c7847..e39e5c3 100644
--- a/lens-examples/src/main/resources/city_subset.xml
+++ b/lens-examples/src/main/resources/city_subset.xml
@@ -22,8 +22,8 @@
<x_dimension_table dimension_name="city" table_name="city_subset" weight="100.0" xmlns="uri:lens:cube:0.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
<columns>
- <column comment="ID" name="id" type="INT"/>
- <column comment="name" name="name" type="STRING"/>
+ <column comment="ID" name="id" _type="INT"/>
+ <column comment="name" name="name" _type="STRING"/>
</columns>
<storage_tables>
<storage_table>
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-examples/src/main/resources/city_table.xml
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/city_table.xml b/lens-examples/src/main/resources/city_table.xml
index 27be305..1f9f152 100644
--- a/lens-examples/src/main/resources/city_table.xml
+++ b/lens-examples/src/main/resources/city_table.xml
@@ -22,10 +22,10 @@
<x_dimension_table dimension_name="city" table_name="city_table" weight="10.0" xmlns="uri:lens:cube:0.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
<columns>
- <column comment="ID" name="id" type="INT"/>
- <column comment="name" name="name" type="STRING"/>
- <column comment="Point of interests" name="POI" type="ARRAY<STRING>"/>
- <column comment="city population" name="population" type="BIGINT"/>
+ <column comment="ID" name="id" _type="INT"/>
+ <column comment="name" name="name" _type="STRING"/>
+ <column comment="Point of interests" name="POI" _type="ARRAY<STRING>"/>
+ <column comment="city population" name="population" _type="BIGINT"/>
</columns>
<properties>
<property name="city.prop" value="d1"/>
@@ -38,7 +38,7 @@
<storage_name>local</storage_name>
<table_desc external="true" field_delimiter="," collection_delimiter=":" table_location="/tmp/examples/city">
<part_cols>
- <column comment="Time column" name="dt" type="STRING"/>
+ <column comment="Time column" name="dt" _type="STRING"/>
</part_cols>
<time_part_cols>dt</time_part_cols>
</table_desc>
http://git-wip-us.apache.org/repos/asf/lens/blob/d559ef2e/lens-examples/src/main/resources/customer.xml
----------------------------------------------------------------------
diff --git a/lens-examples/src/main/resources/customer.xml b/lens-examples/src/main/resources/customer.xml
index c6182a2..0bb66f6 100644
--- a/lens-examples/src/main/resources/customer.xml
+++ b/lens-examples/src/main/resources/customer.xml
@@ -22,19 +22,19 @@
<x_dimension name="customer" xmlns="uri:lens:cube:0.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="uri:lens:cube:0.1 cube-0.1.xsd ">
<attributes>
- <dim_attribute name="id" type="INT"/>
- <dim_attribute name="name" type="STRING"/>
- <dim_attribute name="gender" type="STRING">
+ <dim_attribute name="id" _type="INT"/>
+ <dim_attribute name="name" _type="STRING"/>
+ <dim_attribute name="gender" _type="STRING">
<values>M</values>
<values>F</values>
</dim_attribute>
- <dim_attribute name="age" type="INT" />
- <dim_attribute name="city_id" type="INT" />
- <dim_attribute name="customer_city_name" type="string" description="City name to which the customer belongs"
+ <dim_attribute name="age" _type="INT" />
+ <dim_attribute name="city_id" _type="INT" />
+ <dim_attribute name="customer_city_name" _type="string" description="City name to which the customer belongs"
display_string="Customer City">
<chain_ref_column chain_name="customer_city" ref_col="name" />
</dim_attribute>
- <dim_attribute name="customer_credit_status" type="STRING" start_time='2015-03-01T00:00:00'/>
+ <dim_attribute name="customer_credit_status" _type="STRING" start_time='2015-03-01T00:00:00'/>
</attributes>
<join_chains>
<join_chain name="customer_city">