You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@griffin.apache.org by gu...@apache.org on 2017/03/03 12:16:51 UTC
[45/51] [partial] incubator-griffin git commit: Init move
http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/a8ba6ba9/griffin-core/src/main/java/com/ebay/oss/griffin/vo/PlatformMetadata.java
----------------------------------------------------------------------
diff --git a/griffin-core/src/main/java/com/ebay/oss/griffin/vo/PlatformMetadata.java b/griffin-core/src/main/java/com/ebay/oss/griffin/vo/PlatformMetadata.java
new file mode 100644
index 0000000..e2927ce
--- /dev/null
+++ b/griffin-core/src/main/java/com/ebay/oss/griffin/vo/PlatformMetadata.java
@@ -0,0 +1,52 @@
+/*
+ Copyright (c) 2016 eBay Software Foundation.
+ Licensed 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 com.ebay.oss.griffin.vo;
+
+import java.util.List;
+
+public class PlatformMetadata{
+
+ private String id;
+
+ private String platform;
+
+ private List<SystemMetadata> systems;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getPlatform() {
+ return platform;
+ }
+
+ public void setPlatform(String platform) {
+ this.platform = platform;
+ }
+
+ public List<SystemMetadata> getSystems() {
+ return systems;
+ }
+
+ public void setSystems(List<SystemMetadata> systems) {
+ this.systems = systems;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/a8ba6ba9/griffin-core/src/main/java/com/ebay/oss/griffin/vo/PlatformSubscription.java
----------------------------------------------------------------------
diff --git a/griffin-core/src/main/java/com/ebay/oss/griffin/vo/PlatformSubscription.java b/griffin-core/src/main/java/com/ebay/oss/griffin/vo/PlatformSubscription.java
new file mode 100644
index 0000000..9f4433f
--- /dev/null
+++ b/griffin-core/src/main/java/com/ebay/oss/griffin/vo/PlatformSubscription.java
@@ -0,0 +1,58 @@
+/*
+ Copyright (c) 2016 eBay Software Foundation.
+ Licensed 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 com.ebay.oss.griffin.vo;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class PlatformSubscription {
+
+ String platform;
+
+ boolean selectAll;
+
+ List<SystemSubscription> systems = new ArrayList<SystemSubscription>();
+
+ public PlatformSubscription() { }
+
+ public PlatformSubscription(String platform) {
+ this.platform = platform;
+ }
+
+ public String getPlatform() {
+ return platform;
+ }
+
+ public void setPlatform(String platform) {
+ this.platform = platform;
+ }
+
+ public boolean isSelectAll() {
+ return selectAll;
+ }
+
+ public void setSelectAll(boolean selectAll) {
+ this.selectAll = selectAll;
+ }
+
+ public List<SystemSubscription> getSystems() {
+ return systems;
+ }
+
+ public void setSystems(List<SystemSubscription> systems) {
+ this.systems = systems;
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/a8ba6ba9/griffin-core/src/main/java/com/ebay/oss/griffin/vo/SampleOut.java
----------------------------------------------------------------------
diff --git a/griffin-core/src/main/java/com/ebay/oss/griffin/vo/SampleOut.java b/griffin-core/src/main/java/com/ebay/oss/griffin/vo/SampleOut.java
new file mode 100644
index 0000000..705334c
--- /dev/null
+++ b/griffin-core/src/main/java/com/ebay/oss/griffin/vo/SampleOut.java
@@ -0,0 +1,36 @@
+/*
+ Copyright (c) 2016 eBay Software Foundation.
+ Licensed 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 com.ebay.oss.griffin.vo;
+
+
+public class SampleOut {
+
+ private long date;
+ private String path;
+
+ public long getDate() {
+ return date;
+ }
+ public void setDate(long date) {
+ this.date = date;
+ }
+ public String getPath() {
+ return path;
+ }
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/a8ba6ba9/griffin-core/src/main/java/com/ebay/oss/griffin/vo/SystemLevelMetrics.java
----------------------------------------------------------------------
diff --git a/griffin-core/src/main/java/com/ebay/oss/griffin/vo/SystemLevelMetrics.java b/griffin-core/src/main/java/com/ebay/oss/griffin/vo/SystemLevelMetrics.java
new file mode 100644
index 0000000..45c674d
--- /dev/null
+++ b/griffin-core/src/main/java/com/ebay/oss/griffin/vo/SystemLevelMetrics.java
@@ -0,0 +1,66 @@
+/*
+ Copyright (c) 2016 eBay Software Foundation.
+ Licensed 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 com.ebay.oss.griffin.vo;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class SystemLevelMetrics {
+ private String name;
+ private float dq;
+
+ private List<AssetLevelMetrics> metrics;
+
+ public SystemLevelMetrics()
+ {
+ metrics = new ArrayList<AssetLevelMetrics>();
+ }
+
+ public SystemLevelMetrics(String name)
+ {
+ this.name = name;
+ metrics = new ArrayList<AssetLevelMetrics>();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public float getDq() {
+ return dq;
+ }
+
+ public void setDq(float dq) {
+ this.dq = dq;
+ }
+
+ public List<AssetLevelMetrics> getMetrics() {
+ return metrics;
+ }
+
+ public void setMetrics(List<AssetLevelMetrics> metrics) {
+ this.metrics = metrics;
+ }
+
+ public void addAssetLevelMetrics(AssetLevelMetrics item)
+ {
+ this.metrics.add(item);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/a8ba6ba9/griffin-core/src/main/java/com/ebay/oss/griffin/vo/SystemLevelMetricsList.java
----------------------------------------------------------------------
diff --git a/griffin-core/src/main/java/com/ebay/oss/griffin/vo/SystemLevelMetricsList.java b/griffin-core/src/main/java/com/ebay/oss/griffin/vo/SystemLevelMetricsList.java
new file mode 100644
index 0000000..2b85a2a
--- /dev/null
+++ b/griffin-core/src/main/java/com/ebay/oss/griffin/vo/SystemLevelMetricsList.java
@@ -0,0 +1,371 @@
+/*
+ Copyright (c) 2016 eBay Software Foundation.
+ Licensed 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 com.ebay.oss.griffin.vo;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.ebay.oss.griffin.domain.MetricType;
+import com.ebay.oss.griffin.domain.UserSubscription;
+
+public class SystemLevelMetricsList {
+
+ private static Logger logger = LoggerFactory.getLogger(SystemLevelMetricsList.class);
+
+ public List<SystemLevelMetrics> latestDQList = new ArrayList<SystemLevelMetrics>();
+
+ public String limitPlatform = "Apollo";
+
+ boolean containsAsset(String system, String name) {
+ for (SystemLevelMetrics tempSystemLevelMetrics : latestDQList) {
+ if (tempSystemLevelMetrics.getName().equals(system)) {
+ for (AssetLevelMetrics tempAssetLevelMetrics : tempSystemLevelMetrics.getMetrics()) {
+ if (tempAssetLevelMetrics.getName().equals(name)) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ public SystemLevelMetrics getSystemLevelMetrics(String system) {
+ for (SystemLevelMetrics tempSystemLevelMetrics : latestDQList) {
+ if (tempSystemLevelMetrics.getName().equals(system)) {
+ return tempSystemLevelMetrics;
+ }
+ }
+ return null;
+ }
+
+
+ public List<SystemLevelMetrics> getListWithLatestNAssets(int N, String system,
+ UserSubscription subscribe, Map<String, String> assetMap) {
+
+ List<SystemLevelMetrics> result = new ArrayList<SystemLevelMetrics>();
+ try {
+
+ for (SystemLevelMetrics tempSystemLevelMetrics : latestDQList) {
+ if (tempSystemLevelMetrics.getName().equals(system) || system.equals("all")) {
+
+ SystemLevelMetrics tempSystemLevelMetrics1 =
+ new SystemLevelMetrics(tempSystemLevelMetrics.getName());
+ tempSystemLevelMetrics1.setDq(tempSystemLevelMetrics.getDq());
+ List<AssetLevelMetrics> metrics = tempSystemLevelMetrics.getMetrics();
+
+ boolean isCurrentSystemSelected;
+ if (subscribe != null)
+ isCurrentSystemSelected =
+ subscribe.isSystemSelected(limitPlatform,
+ tempSystemLevelMetrics.getName());
+ else
+ isCurrentSystemSelected = true;
+
+ for (AssetLevelMetrics tempAssetLevelMetrics : metrics)
+ {
+ boolean isCurrentDataassetSelected;
+ if (subscribe != null)
+ isCurrentDataassetSelected =
+ subscribe.isDataAssetSelected(limitPlatform,
+ tempSystemLevelMetrics.getName(),
+ assetMap.get(tempAssetLevelMetrics
+ .getName()));
+ else
+ isCurrentDataassetSelected = true;
+
+ if (isCurrentSystemSelected || isCurrentDataassetSelected)
+ {
+ AssetLevelMetrics tempAssetLevelMetrics1 =
+ new AssetLevelMetrics(tempAssetLevelMetrics.getName(),
+ tempAssetLevelMetrics.getMetricType(),
+ tempAssetLevelMetrics.getDq(),
+ tempAssetLevelMetrics.getTimestamp(),
+ tempAssetLevelMetrics.getDqfail());
+ List<AssetLevelMetricsDetail> otherdetails =
+ tempAssetLevelMetrics.getDetails();
+ List<AssetLevelMetricsDetail> tempdetails =
+ new ArrayList<AssetLevelMetricsDetail>();
+ if (otherdetails != null)
+ {
+ Collections.sort(otherdetails);
+ for (int i = 0; i < otherdetails.size() && i < N; i++)
+ {
+ tempdetails.add(otherdetails.get(i));
+ }
+ }
+
+ tempAssetLevelMetrics1.setDetails(tempdetails);
+
+ tempSystemLevelMetrics1.addAssetLevelMetrics(tempAssetLevelMetrics1);
+ }
+ }
+
+ if (tempSystemLevelMetrics1.getMetrics().size() > 0)
+ result.add(tempSystemLevelMetrics1);
+ }
+ }
+ } catch (Exception e) {
+ logger.error("{}", e);
+ }
+ return result;
+ }
+
+ public AssetLevelMetrics getListWithSpecificAssetName(String name)
+ {
+ for (SystemLevelMetrics tempSystemLevelMetrics : latestDQList)
+ {
+ SystemLevelMetrics tempSystemLevelMetrics1 =
+ new SystemLevelMetrics(tempSystemLevelMetrics.getName());
+ tempSystemLevelMetrics1.setDq(tempSystemLevelMetrics.getDq());
+ for (AssetLevelMetrics tempAssetLevelMetrics : tempSystemLevelMetrics.getMetrics())
+ {
+ if (tempAssetLevelMetrics.getName().equals(name))
+ {
+ return tempAssetLevelMetrics;
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public AssetLevelMetrics getListWithSpecificAssetName(String name, int count)
+ {
+ for (SystemLevelMetrics tempSystemLevelMetrics : latestDQList)
+ {
+ SystemLevelMetrics tempSystemLevelMetrics1 =
+ new SystemLevelMetrics(tempSystemLevelMetrics.getName());
+ tempSystemLevelMetrics1.setDq(tempSystemLevelMetrics.getDq());
+ for (AssetLevelMetrics tempAssetLevelMetrics : tempSystemLevelMetrics.getMetrics())
+ {
+ if (tempAssetLevelMetrics.getName().equals(name))
+ {
+ return new AssetLevelMetrics(tempAssetLevelMetrics, count);
+ }
+ }
+ }
+
+ return null;
+ }
+
+ public void updateDQFail(Map<String, String> thresholds)
+ {
+ for (SystemLevelMetrics tempSystemLevelMetrics : latestDQList)
+ {
+ for (AssetLevelMetrics tempAssetLevelMetrics : tempSystemLevelMetrics.getMetrics())
+ {
+ if (thresholds.containsKey(tempAssetLevelMetrics.getName()))
+ {
+ if (tempAssetLevelMetrics.getDq() < Float.parseFloat(thresholds
+ .get(tempAssetLevelMetrics.getName())))
+ {
+ tempAssetLevelMetrics.setDqfail(1);
+ }
+ }
+ }
+ }
+ }
+
+
+ public List<SystemLevelMetrics> getHeatMap(Map<String, String> thresholds) {
+ List<SystemLevelMetrics> result = new ArrayList<SystemLevelMetrics>();
+
+ SystemLevelMetricsList latestSysMetricsList = new SystemLevelMetricsList();
+ latestSysMetricsList.setLatestDQList(latestDQList);
+ SystemLevelMetricsList resultSysMetricsList = new SystemLevelMetricsList();
+
+ for (SystemLevelMetrics tempSystemMetrics : latestDQList) {
+ int size = 0;
+ for (AssetLevelMetrics tempAssetLevelMetrics : tempSystemMetrics.getMetrics()) {
+ if (thresholds.containsKey(tempAssetLevelMetrics.getName())) {
+ if (tempAssetLevelMetrics.getDq() < Float.parseFloat(thresholds
+ .get(tempAssetLevelMetrics.getName()))) {
+ tempAssetLevelMetrics.setDqfail(1);
+ resultSysMetricsList.upsertNewAssetExecute(
+ tempAssetLevelMetrics.getName(),
+ tempAssetLevelMetrics.getMetricType(),
+ tempAssetLevelMetrics.getTimestamp(),
+ tempAssetLevelMetrics.getDq(),
+ tempSystemMetrics.getName(),
+ tempAssetLevelMetrics.getDqfail(), false, null);
+
+ size++;
+ }
+ }
+ }
+ if (size == 0) {
+ SystemLevelMetrics sysMetric = new SystemLevelMetrics(tempSystemMetrics.getName());
+ resultSysMetricsList.getLatestDQList().add(sysMetric);
+ }
+ }
+
+ result = resultSysMetricsList.getLatestDQList();
+ for (SystemLevelMetrics tempSystemLevelMetrics : result) {
+ int size = tempSystemLevelMetrics.getMetrics().size();
+ String system = tempSystemLevelMetrics.getName();
+ if (size >= 8) {
+ continue;
+ }
+
+ SystemLevelMetrics latestSystLvlMetrics = latestSysMetricsList.getSystemLevelMetrics(tempSystemLevelMetrics
+ .getName());
+ for (AssetLevelMetrics latestAssMetrics : latestSystLvlMetrics .getMetrics()) {
+ if (!resultSysMetricsList.containsAsset(system, latestAssMetrics.getName())) {
+ resultSysMetricsList.upsertNewAssetExecute(
+ latestAssMetrics.getName(),
+ latestAssMetrics.getMetricType(),
+ latestAssMetrics.getTimestamp(),
+ latestAssMetrics.getDq(),
+ system,
+ latestAssMetrics.getDqfail(),
+ false, null);
+ size++;
+ if (size >= 8)
+ break;
+ }
+ }
+ }
+
+ return result;
+ }
+
+ public void upsertNewAssetExecute(String metricName, String metricType, long metricTs,
+ float metricValue, String currentSystem,
+ int dqfail, boolean needdetail,
+ AssetLevelMetricsDetail otherAttributes) {
+ boolean systemFound = false;
+ if (currentSystem == null) {
+ currentSystem = "unknown";
+ }
+ try {
+ for (SystemLevelMetrics tmpSysMetrics : latestDQList) {
+ // find the system item
+ if (!tmpSysMetrics.getName().equals(currentSystem)) {
+ continue;
+ }
+ systemFound = true;
+
+ List<AssetLevelMetrics> tmpAssMetricsList = tmpSysMetrics.getMetrics();
+ boolean metricFound = false;
+ for (int k = 0; k < tmpAssMetricsList.size(); k++) {
+ AssetLevelMetrics tempAssetLevelMetrics = tmpAssMetricsList.get(k);
+ // find the metric
+ if (!tempAssetLevelMetrics.getName().equals(metricName)) {
+ continue;
+ }
+ metricFound = true;
+
+ if (tempAssetLevelMetrics.getTimestamp() - (metricTs) < 0) {
+ tempAssetLevelMetrics.setTimestamp(metricTs);
+ tempAssetLevelMetrics.setDq(metricValue);
+ tempAssetLevelMetrics.setDqfail(dqfail);
+ tmpAssMetricsList.set(k, tempAssetLevelMetrics); // FIXME why???
+ }
+ if (!needdetail) {
+ continue;
+ }
+
+ if (metricType.equals(MetricType.Bollinger.toString())) {
+ AssetLevelMetricsDetail detail = new AssetLevelMetricsDetail(
+ metricTs,
+ metricValue, otherAttributes.getBolling().clone()
+ );
+ tempAssetLevelMetrics.addAssetLevelMetricsDetail(detail);
+ } else if (metricType.equals(MetricType.Trend.toString())) {
+ AssetLevelMetricsDetail detail = new AssetLevelMetricsDetail(
+ metricTs,
+ metricValue,
+ otherAttributes.getComparisionValue());
+ tempAssetLevelMetrics.addAssetLevelMetricsDetail(detail);
+ } else if (metricType.equals(MetricType.MAD.toString())) {
+ tempAssetLevelMetrics
+ .addAssetLevelMetricsDetail(new AssetLevelMetricsDetail(
+ metricTs, metricValue, otherAttributes
+ .getMAD()));
+ } else {
+ tempAssetLevelMetrics
+ .addAssetLevelMetricsDetail(new AssetLevelMetricsDetail(
+ metricTs, metricValue));
+ }
+ }
+
+ // didn't find the metric, create one
+ if (!metricFound ) {
+ AssetLevelMetrics newTempAssetLevelMetrics =
+ new AssetLevelMetrics(metricName, metricType, metricValue,
+ metricTs, dqfail);
+ if (needdetail ) {
+ if (metricType.equals(MetricType.Bollinger.toString())) {
+ AssetLevelMetricsDetail detail =
+ new AssetLevelMetricsDetail(
+ metricTs,
+ metricValue,
+ otherAttributes.getBolling().clone());
+ newTempAssetLevelMetrics .addAssetLevelMetricsDetail(detail);
+ } else if (metricType.equals(MetricType.Trend.toString())) {
+ newTempAssetLevelMetrics
+ .addAssetLevelMetricsDetail(new AssetLevelMetricsDetail(
+ metricTs,
+ metricValue,
+ otherAttributes.getComparisionValue()));
+ } else if (metricType.equals(MetricType.MAD.toString())) {
+ newTempAssetLevelMetrics
+ .addAssetLevelMetricsDetail(new AssetLevelMetricsDetail(
+ metricTs, metricValue, otherAttributes
+ .getMAD()));
+ } else {
+ newTempAssetLevelMetrics
+ .addAssetLevelMetricsDetail(new AssetLevelMetricsDetail(
+ metricTs, metricValue));
+ }
+ }
+ tmpAssMetricsList.add(newTempAssetLevelMetrics);
+ }
+ }
+ } catch (Exception e) {
+ logger.error("{}", e);
+ }
+
+ // can't find the system
+ if (!systemFound ) {
+ SystemLevelMetrics newSystemLevelMetrics = new SystemLevelMetrics(currentSystem);
+ newSystemLevelMetrics.addAssetLevelMetrics(new AssetLevelMetrics(metricName,
+ metricType, metricValue, metricTs, dqfail));
+ if (needdetail ) {
+ List<AssetLevelMetricsDetail> tempDetailList =
+ new ArrayList<AssetLevelMetricsDetail>();
+ tempDetailList.add(new AssetLevelMetricsDetail(metricTs, metricValue));
+ newSystemLevelMetrics.getMetrics().get(0).setDetails(tempDetailList);
+ }
+ latestDQList.add(newSystemLevelMetrics);
+ }
+ }
+
+
+ public List<SystemLevelMetrics> getLatestDQList() {
+ return latestDQList;
+ }
+
+ public void setLatestDQList(List<SystemLevelMetrics> latestDQList) {
+ this.latestDQList = latestDQList;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/a8ba6ba9/griffin-core/src/main/java/com/ebay/oss/griffin/vo/SystemMetadata.java
----------------------------------------------------------------------
diff --git a/griffin-core/src/main/java/com/ebay/oss/griffin/vo/SystemMetadata.java b/griffin-core/src/main/java/com/ebay/oss/griffin/vo/SystemMetadata.java
new file mode 100644
index 0000000..6f91479
--- /dev/null
+++ b/griffin-core/src/main/java/com/ebay/oss/griffin/vo/SystemMetadata.java
@@ -0,0 +1,52 @@
+/*
+ Copyright (c) 2016 eBay Software Foundation.
+ Licensed 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 com.ebay.oss.griffin.vo;
+
+import java.util.List;
+
+public class SystemMetadata{
+
+ private String id;
+
+ private String name;
+
+ private List<DataAssetIndex> assets;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public List<DataAssetIndex> getAssets() {
+ return assets;
+ }
+
+ public void setAssets(List<DataAssetIndex> assets) {
+ this.assets = assets;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/a8ba6ba9/griffin-core/src/main/java/com/ebay/oss/griffin/vo/SystemSubscription.java
----------------------------------------------------------------------
diff --git a/griffin-core/src/main/java/com/ebay/oss/griffin/vo/SystemSubscription.java b/griffin-core/src/main/java/com/ebay/oss/griffin/vo/SystemSubscription.java
new file mode 100644
index 0000000..a1da9e8
--- /dev/null
+++ b/griffin-core/src/main/java/com/ebay/oss/griffin/vo/SystemSubscription.java
@@ -0,0 +1,58 @@
+/*
+ Copyright (c) 2016 eBay Software Foundation.
+ Licensed 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 com.ebay.oss.griffin.vo;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class SystemSubscription {
+ String system;
+ boolean selectAll;
+ List<String> dataassets = new ArrayList<String>();
+
+ public SystemSubscription() { }
+
+ public SystemSubscription(String system) {
+ this.system = system;
+ }
+
+ public String getSystem() {
+ return system;
+ }
+
+ public void setSystem(String system) {
+ this.system = system;
+ }
+
+ public boolean isSelectAll() {
+ return selectAll;
+ }
+
+ public void setSelectAll(boolean selectAll) {
+ this.selectAll = selectAll;
+ }
+
+ public List<String> getDataassets() {
+ return dataassets;
+ }
+
+ public void setDataassets(List<String> dataassets) {
+ this.dataassets = dataassets;
+ }
+
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/a8ba6ba9/griffin-core/src/main/java/com/ebay/oss/griffin/vo/ValidateHiveJobConfig.java
----------------------------------------------------------------------
diff --git a/griffin-core/src/main/java/com/ebay/oss/griffin/vo/ValidateHiveJobConfig.java b/griffin-core/src/main/java/com/ebay/oss/griffin/vo/ValidateHiveJobConfig.java
new file mode 100644
index 0000000..9561f65
--- /dev/null
+++ b/griffin-core/src/main/java/com/ebay/oss/griffin/vo/ValidateHiveJobConfig.java
@@ -0,0 +1,99 @@
+/*
+ Copyright (c) 2016 eBay Software Foundation.
+ Licensed 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 com.ebay.oss.griffin.vo;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ValidateHiveJobConfig {
+ public String dataSet;
+ public List<ValidateHiveJobConfigLv1Detail> validityReq = new ArrayList<ValidateHiveJobConfigLv1Detail>();
+ public List<PartitionConfig> timePartitions = new ArrayList<PartitionConfig>();
+
+ public ValidateHiveJobConfig() { }
+
+ public ValidateHiveJobConfig(String dataSet) {
+ this.dataSet = dataSet;
+ }
+
+ public String getDataSet() {
+ return dataSet;
+ }
+
+ public void setDataSet(String dataSet) {
+ this.dataSet = dataSet;
+ }
+
+ public List<ValidateHiveJobConfigLv1Detail> getValidityReq() {
+ return validityReq;
+ }
+
+ public void setValidityReq(List<ValidateHiveJobConfigLv1Detail> validityReq) {
+ this.validityReq = validityReq;
+ }
+
+ public List<PartitionConfig> getTimePartitions() {
+ return timePartitions;
+ }
+
+ public void setTimePartitions(List<PartitionConfig> timePartitions) {
+ this.timePartitions = timePartitions;
+ }
+
+ public void addColumnCalculation(int colId, String colName, int type)
+ {
+ if(validityReq == null) validityReq = new ArrayList<ValidateHiveJobConfigLv1Detail>();
+ int lv1index = 0;
+ for(ValidateHiveJobConfigLv1Detail tempValidateHiveJobConfigLv1Detail : validityReq)
+ {
+ if(tempValidateHiveJobConfigLv1Detail.getColId() == colId && tempValidateHiveJobConfigLv1Detail.getColName().equals(colName))
+ {
+ lv1index = 1;
+ tempValidateHiveJobConfigLv1Detail.getMetrics().add(new ValidateHiveJobConfigLv2Detail(type));
+ }
+ }
+ if(lv1index == 0)
+ {
+ List<ValidateHiveJobConfigLv2Detail> newMetrics = new ArrayList<ValidateHiveJobConfigLv2Detail>();
+ newMetrics.add(new ValidateHiveJobConfigLv2Detail(type));
+ ValidateHiveJobConfigLv1Detail newValidateHiveJobConfigLv1Detail = new ValidateHiveJobConfigLv1Detail(colId, colName, newMetrics);
+ validityReq.add(newValidateHiveJobConfigLv1Detail);
+ }
+ }
+
+ public long getValue(String colName, int type)
+ {
+ long result = Long.MIN_VALUE;
+ for(ValidateHiveJobConfigLv1Detail tempValidateHiveJobConfigLv1Detail : validityReq)
+ {
+ if(tempValidateHiveJobConfigLv1Detail.getColName().equals(colName))
+ {
+ for(ValidateHiveJobConfigLv2Detail tempValidateHiveJobConfigLv2Detail : tempValidateHiveJobConfigLv1Detail.getMetrics())
+ {
+ if(tempValidateHiveJobConfigLv2Detail.getName()==type)
+ {
+ return (long) tempValidateHiveJobConfigLv2Detail.getResult();
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/a8ba6ba9/griffin-core/src/main/java/com/ebay/oss/griffin/vo/ValidateHiveJobConfigLv1Detail.java
----------------------------------------------------------------------
diff --git a/griffin-core/src/main/java/com/ebay/oss/griffin/vo/ValidateHiveJobConfigLv1Detail.java b/griffin-core/src/main/java/com/ebay/oss/griffin/vo/ValidateHiveJobConfigLv1Detail.java
new file mode 100644
index 0000000..b64ef77
--- /dev/null
+++ b/griffin-core/src/main/java/com/ebay/oss/griffin/vo/ValidateHiveJobConfigLv1Detail.java
@@ -0,0 +1,59 @@
+/*
+ Copyright (c) 2016 eBay Software Foundation.
+ Licensed 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 com.ebay.oss.griffin.vo;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ValidateHiveJobConfigLv1Detail {
+ public int colId;
+ public String colName;
+ public List<ValidateHiveJobConfigLv2Detail> metrics = new ArrayList<ValidateHiveJobConfigLv2Detail>();
+
+ public ValidateHiveJobConfigLv1Detail() { }
+
+ public ValidateHiveJobConfigLv1Detail(int colId, String colName, List<ValidateHiveJobConfigLv2Detail> metrics) {
+ this.colId = colId;
+ this.colName = colName;
+ this.metrics = metrics;
+ }
+
+ public int getColId() {
+ return colId;
+ }
+
+ public void setColId(int colId) {
+ this.colId = colId;
+ }
+
+ public String getColName() {
+ return colName;
+ }
+
+ public void setColName(String colName) {
+ this.colName = colName;
+ }
+
+ public List<ValidateHiveJobConfigLv2Detail> getMetrics() {
+ return metrics;
+ }
+
+ public void setMetrics(List<ValidateHiveJobConfigLv2Detail> metrics) {
+ this.metrics = metrics;
+ }
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/a8ba6ba9/griffin-core/src/main/java/com/ebay/oss/griffin/vo/ValidateHiveJobConfigLv2Detail.java
----------------------------------------------------------------------
diff --git a/griffin-core/src/main/java/com/ebay/oss/griffin/vo/ValidateHiveJobConfigLv2Detail.java b/griffin-core/src/main/java/com/ebay/oss/griffin/vo/ValidateHiveJobConfigLv2Detail.java
new file mode 100644
index 0000000..1a2e805
--- /dev/null
+++ b/griffin-core/src/main/java/com/ebay/oss/griffin/vo/ValidateHiveJobConfigLv2Detail.java
@@ -0,0 +1,52 @@
+/*
+ Copyright (c) 2016 eBay Software Foundation.
+ Licensed 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 com.ebay.oss.griffin.vo;
+
+
+public class ValidateHiveJobConfigLv2Detail {
+ private int name;
+ private double result;
+
+ public ValidateHiveJobConfigLv2Detail() { }
+
+ public ValidateHiveJobConfigLv2Detail(int name) {
+ this.name = name;
+ }
+
+ public ValidateHiveJobConfigLv2Detail(int name, double result) {
+ this.name = name;
+ this.result = result;
+ }
+
+ public int getName() {
+ return name;
+ }
+
+ public void setName(int name) {
+ this.name = name;
+ }
+
+ public double getResult() {
+ return result;
+ }
+
+ public void setResult(double result) {
+ this.result = result;
+ }
+
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/a8ba6ba9/griffin-core/src/main/resources/application.properties
----------------------------------------------------------------------
diff --git a/griffin-core/src/main/resources/application.properties b/griffin-core/src/main/resources/application.properties
new file mode 100644
index 0000000..2eda2b9
--- /dev/null
+++ b/griffin-core/src/main/resources/application.properties
@@ -0,0 +1,36 @@
+#
+# Copyright (c) 2016 eBay Software Foundation.
+# Licensed 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.
+
+#ldap query, this is used for user login service
+# ldap.server=localhost
+# ldap.port=389
+#ldap.user=test
+#ldap.pass=test
+
+####QA version
+env=prod
+#job.local.folder=C:\\bark
+#This is used to store the temporary files, make sure the process has write
+#permission on this folder
+job.local.folder=/griffin/tmp
+#This is used to store the job running files on hadoop, make sure the process
+#has write permission on this folder
+job.hdfs.folder=/user/griffin
+job.hdfs.runningfoldername=running
+job.hdfs.historyfoldername=history
+job.hdfs.failurefoldername=failure
+#Specify the mongodb information here
+#spring.data.mongodb.host=dart-8984.phx02.dev.ebayc3.com
+spring.data.mongodb.host=localhost
+spring.data.mongodb.port=27017
http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/a8ba6ba9/griffin-core/src/main/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/griffin-core/src/main/resources/log4j.properties b/griffin-core/src/main/resources/log4j.properties
new file mode 100644
index 0000000..a1be8fc
--- /dev/null
+++ b/griffin-core/src/main/resources/log4j.properties
@@ -0,0 +1,5 @@
+log4j.rootLogger=INFO, stdout
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd'T'HH:mm:ss.SSS} %-5p [%c] - %m%n
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/a8ba6ba9/griffin-core/src/main/webapp/WEB-INF/spring/context.xml
----------------------------------------------------------------------
diff --git a/griffin-core/src/main/webapp/WEB-INF/spring/context.xml b/griffin-core/src/main/webapp/WEB-INF/spring/context.xml
new file mode 100644
index 0000000..6117bb9
--- /dev/null
+++ b/griffin-core/src/main/webapp/WEB-INF/spring/context.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (c) 2016 eBay Software Foundation. Licensed 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. -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:mvc="http://www.springframework.org/schema/mvc"
+ xmlns:task="http://www.springframework.org/schema/task"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
+ http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
+ http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.1.xsd">
+
+
+ <context:annotation-config />
+
+ <context:component-scan base-package="com.ebay.oss.griffin.common" />
+ <context:component-scan base-package="com.ebay.oss.griffin.domain" />
+ <context:component-scan base-package="com.ebay.oss.griffin.repo" />
+ <context:component-scan base-package="com.ebay.oss.griffin.error" />
+ <context:component-scan base-package="com.ebay.oss.griffin.service" />
+ <context:component-scan base-package="com.ebay.oss.griffin.ebay" />
+ <context:component-scan base-package="com.ebay.oss.griffin.resources" />
+
+ <bean id="modelCreatorChain" class="com.ebay.oss.griffin.service.modelcreator.DqModelCreatorChain">
+ <constructor-arg>
+ <list>
+ <ref bean="accuracyModelCreator"/>
+ <ref bean="anomalyModelCreator"/>
+ <ref bean="publishModelCreator"/>
+ <ref bean="validityModelCreator"/>
+ </list>
+ </constructor-arg>
+ </bean>
+
+
+ <task:scheduled-tasks scheduler="griffinScheduler">
+ <task:scheduled ref="dqmetrics" method="updateLatestDQList" fixed-delay="180000"/>
+ <task:scheduled ref="scheduleService" method="schedulingJobs" fixed-delay="120000"/>
+ </task:scheduled-tasks>
+ <task:scheduler id="griffinScheduler" pool-size="5"/>
+
+</beans>
http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/a8ba6ba9/griffin-core/src/main/webapp/WEB-INF/spring/static-context.xml
----------------------------------------------------------------------
diff --git a/griffin-core/src/main/webapp/WEB-INF/spring/static-context.xml b/griffin-core/src/main/webapp/WEB-INF/spring/static-context.xml
new file mode 100644
index 0000000..58756c8
--- /dev/null
+++ b/griffin-core/src/main/webapp/WEB-INF/spring/static-context.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans:beans xmlns="http://www.springframework.org/schema/mvc"
+ xmlns:mvc="http://www.springframework.org/schema/mvc"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:beans="http://www.springframework.org/schema/beans"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:aop="http://www.springframework.org/schema/aop"
+ xmlns:task="http://www.springframework.org/schema/task"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
+ http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
+ http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.1.xsd">
+
+ <!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
+
+ <!-- Allow proxys -->
+ <aop:aspectj-autoproxy />
+ <mvc:annotation-driven></mvc:annotation-driven>
+
+ <mvc:resources mapping="/**" location="/" />
+
+
+</beans:beans>
http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/a8ba6ba9/griffin-core/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/griffin-core/src/main/webapp/WEB-INF/web.xml b/griffin-core/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..519295a
--- /dev/null
+++ b/griffin-core/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright (c) 2016 eBay Software Foundation. Licensed 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. -->
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ id="WebApp_ID" version="3.0">
+ <display-name>bark-core</display-name>
+ <welcome-file-list>
+ <welcome-file>index.html</welcome-file>
+ <welcome-file>index.htm</welcome-file>
+ <welcome-file>index.jsp</welcome-file>
+ <welcome-file>default.html</welcome-file>
+ <welcome-file>default.htm</welcome-file>
+ <welcome-file>index</welcome-file>
+ </welcome-file-list>
+ <listener>
+ <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
+ </listener>
+ <context-param>
+ <param-name>contextConfigLocation</param-name>
+ <param-value>/WEB-INF/spring/context.xml</param-value>
+ </context-param>
+ <filter>
+ <filter-name>CORSFilter</filter-name>
+ <filter-class>com.ebay.oss.griffin.common.SimpleCORSFilter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>CORSFilter</filter-name>
+ <servlet-name>*</servlet-name>
+ <dispatcher>REQUEST</dispatcher>
+ <dispatcher>INCLUDE</dispatcher>
+ <dispatcher>FORWARD</dispatcher>
+ </filter-mapping>
+ <servlet>
+ <servlet-name>jersey-serlvet</servlet-name>
+ <servlet-class>
+ com.sun.jersey.spi.spring.container.servlet.SpringServlet
+ </servlet-class>
+ <init-param>
+ <param-name>com.sun.jersey.config.property.packages</param-name>
+ <param-value>org.apache.griffin.resources</param-value>
+ </init-param>
+ <init-param>
+ <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
+ <param-value>true</param-value>
+ </init-param>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet>
+ <servlet-name>StaticServlet</servlet-name>
+ <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
+
+ <init-param>
+ <param-name>contextConfigLocation</param-name>
+ <param-value>/WEB-INF/spring/static-context.xml</param-value>
+ </init-param>
+
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>jersey-serlvet</servlet-name>
+ <url-pattern>/api/v1/*</url-pattern>
+ </servlet-mapping>
+
+ <servlet-mapping>
+ <servlet-name>StaticServlet</servlet-name>
+ <url-pattern>/</url-pattern>
+ </servlet-mapping>
+</web-app>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/a8ba6ba9/griffin-core/src/main/webapp/WEB-INF/webres/resource.properties
----------------------------------------------------------------------
diff --git a/griffin-core/src/main/webapp/WEB-INF/webres/resource.properties b/griffin-core/src/main/webapp/WEB-INF/webres/resource.properties
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/a8ba6ba9/griffin-core/src/test/java/com/ebay/oss/griffin/common/CommonResourceTest.java
----------------------------------------------------------------------
diff --git a/griffin-core/src/test/java/com/ebay/oss/griffin/common/CommonResourceTest.java b/griffin-core/src/test/java/com/ebay/oss/griffin/common/CommonResourceTest.java
new file mode 100644
index 0000000..03aa6fd
--- /dev/null
+++ b/griffin-core/src/test/java/com/ebay/oss/griffin/common/CommonResourceTest.java
@@ -0,0 +1,34 @@
+package com.ebay.oss.griffin.common;
+
+import org.junit.Test;
+
+import com.ebay.oss.griffin.common.Pair;
+
+import java.util.*;
+
+import static org.junit.Assert.*;
+
+public class CommonResourceTest {
+
+ @Test
+ public void testPair() {
+ Pair pair = new Pair("key", "value");
+ Pair pair1 = new Pair("key", "value");
+ Pair pair2 = new Pair("key", "notVal");
+ Pair pair3 = new Pair("notKey", "notVal");
+
+ assertEquals(pair.hashCode(), pair1.hashCode());
+ assertTrue(pair.hashCode() != pair2.hashCode());
+
+ assertTrue(pair.equals(pair));
+ assertFalse(pair.equals(null));
+ assertTrue(pair.equals(pair1));
+ assertFalse(pair.equals(pair2));
+ assertFalse(pair.equals(pair3));
+ assertFalse(pair.equals("key value"));
+ assertTrue(new Pair(null, null).equals(new Pair(null, null)));
+ assertFalse(new Pair(null, null).equals(new Pair("key", null)));
+ assertTrue(new Pair("key", null).equals(new Pair("key", null)));
+ assertFalse(new Pair("key", null).equals(new Pair("key", "val")));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/a8ba6ba9/griffin-core/src/test/java/com/ebay/oss/griffin/domain/DomainResourceTest.java
----------------------------------------------------------------------
diff --git a/griffin-core/src/test/java/com/ebay/oss/griffin/domain/DomainResourceTest.java b/griffin-core/src/test/java/com/ebay/oss/griffin/domain/DomainResourceTest.java
new file mode 100644
index 0000000..9e09a68
--- /dev/null
+++ b/griffin-core/src/test/java/com/ebay/oss/griffin/domain/DomainResourceTest.java
@@ -0,0 +1,255 @@
+package com.ebay.oss.griffin.domain;
+
+import com.ebay.oss.griffin.domain.DataAsset;
+import com.ebay.oss.griffin.domain.DataSchema;
+import com.ebay.oss.griffin.domain.DqJob;
+import com.ebay.oss.griffin.domain.DqMetricsValue;
+import com.ebay.oss.griffin.domain.DqModel;
+import com.ebay.oss.griffin.domain.DqSchedule;
+import com.ebay.oss.griffin.domain.IdEntity;
+import com.ebay.oss.griffin.domain.JobStatus;
+import com.ebay.oss.griffin.domain.PartitionFormat;
+import com.ebay.oss.griffin.domain.SampleFilePathLKP;
+import com.ebay.oss.griffin.domain.UserSubscription;
+import com.ebay.oss.griffin.vo.PlatformSubscription;
+import com.ebay.oss.griffin.vo.SystemSubscription;
+
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import static org.junit.Assert.*;
+
+public class DomainResourceTest {
+
+ @Test
+ public void testDataAsset() {
+ DataAsset asset = new DataAsset();
+
+ asset.setPlatform("platform");
+ assertEquals("platform", asset.getPlatform());
+ asset.setSystem("system");
+ assertEquals("system", asset.getSystem());
+ asset.setAssetName("name");
+ assertEquals("name", asset.getAssetName());
+ asset.setAssetType("type");
+ assertEquals("type", asset.getAssetType());
+ asset.setAssetHDFSPath("path");
+ assertEquals("path", asset.getAssetHDFSPath());
+ asset.setOwner("owner");
+ assertEquals("owner", asset.getOwner());
+ Date dt = new Date();
+ asset.setTimestamp(dt);
+ assertEquals(dt, asset.getTimestamp());
+
+ List<DataSchema> schema = new ArrayList<DataSchema>();
+ schema.add(new DataSchema("sname", "stype", "sdesc", "ssample"));
+ asset.setSchema(schema);
+ assertEquals(schema, asset.getSchema());
+
+ List<PartitionFormat> partitions = new ArrayList<PartitionFormat>();
+ partitions.add(new PartitionFormat("pname", "pformat"));
+ asset.setPartitions(partitions);
+ assertEquals(partitions, asset.getPartitions());
+
+ assertEquals(asset.getColId("sname"), 0);
+ assertEquals(asset.getColId("sname_unknown"), -1);
+ }
+
+ @Test
+ public void testDataSchema() {
+ DataSchema schema = new DataSchema();
+
+ schema.setName("name");
+ assertEquals("name", schema.getName());
+ schema.setType("type");
+ assertEquals("type", schema.getType());
+ schema.setDesc("desc");
+ assertEquals("desc", schema.getDesc());
+ schema.setSample("sample");
+ assertEquals("sample", schema.getSample());
+ }
+
+ @Test
+ public void testDqMetricsValue() {
+ DqMetricsValue dmv = new DqMetricsValue();
+
+ dmv.setAssetId("id");
+ assertEquals("id", dmv.getAssetId());
+ dmv.setValue(3.56f);
+ assertTrue(3.56f == dmv.getValue());
+ dmv.setMetricName("name");
+ assertEquals("name", dmv.getMetricName());
+ dmv.setTimestamp(12345L);
+ assertEquals(12345L, dmv.getTimestamp());
+ dmv.set_id(12345L);
+ assertEquals(new Long(12345L), dmv.get_id());
+
+ DqMetricsValue dmv1 = new DqMetricsValue("name", 12345L, 20.3f);
+ assertEquals(0, dmv1.compareTo(dmv));
+
+ dmv1.setTimestamp(12346L);
+ assertEquals(-1, dmv1.compareTo(dmv));
+ dmv1.setTimestamp(12344L);
+ assertEquals(1, dmv1.compareTo(dmv));
+ }
+
+ @Test
+ public void testDqModel() {
+ DqModel dm = new DqModel();
+
+ dm.setModelId("id");
+ assertEquals("id", dm.getModelId());
+ dm.setModelName("name");
+ assertEquals("name", dm.getModelName());
+ dm.setModelType(2);
+ assertEquals(2, dm.getModelType());
+ dm.setModelDesc("desc");
+ assertEquals("desc", dm.getModelDesc());
+ dm.setAssetId(12345L);
+ assertEquals(12345L, dm.getAssetId());
+ dm.setThreshold(1.2f);
+ assertTrue(1.2f == dm.getThreshold());
+ dm.setNotificationEmail("abc@xxx.com");
+ assertEquals("abc@xxx.com", dm.getNotificationEmail());
+ dm.setOwner("owner");
+ assertEquals("owner", dm.getOwner());
+ dm.setStatus(1);
+ assertEquals(1, dm.getStatus());
+ dm.setModelContent("content");
+ assertEquals("content", dm.getModelContent());
+ dm.setTimestamp(12345L);
+ assertEquals(12345L, dm.getTimestamp());
+ dm.setSchedule(3);
+ assertEquals(3, dm.getSchedule());
+ dm.setSystem(1);
+ assertEquals(1, dm.getSystem());
+ dm.setAssetName("asset");
+ assertEquals("asset", dm.getAssetName());
+ dm.setReferenceModel("ref");
+ assertEquals("ref", dm.getReferenceModel());
+ dm.setStarttime(12345L);
+ assertEquals(12345L, dm.getStarttime());
+
+ }
+
+ @Test
+ public void testDqJob() {
+ DqJob dj = new DqJob();
+
+ dj.setId("id");
+ assertEquals("id", dj.getId());
+ dj.setModelList("list");
+ assertEquals("list", dj.getModelList());
+ dj.setContent("content");
+ assertEquals("content", dj.getContent());
+ dj.setStatus(3);
+ assertEquals(3, dj.getStatus());
+ dj.setStarttime(12345L);
+ assertEquals(12345L, dj.getStarttime());
+ dj.setEndtime(12345L);
+ assertEquals(12345L, dj.getEndtime());
+ dj.setValue(12345L);
+ assertEquals(12345L, dj.getValue());
+ dj.setJobType(2);
+ assertEquals(2, dj.getJobType());
+ }
+
+ @Test
+ public void testDqSchedule() {
+ DqSchedule ds = new DqSchedule();
+
+ ds.setStatus(1);
+ assertEquals(1, ds.getStatus());
+ ds.setStarttime(12345L);
+ assertEquals(12345L, ds.getStarttime());
+ ds.setContent("content");
+ assertEquals("content", ds.getContent());
+ ds.setScheduleType(2);
+ assertEquals(2, ds.getScheduleType());
+ ds.setModelList("list");
+ assertEquals("list", ds.getModelList());
+ ds.setAssetId(12345L);
+ assertEquals(12345L, ds.getAssetId());
+ ds.setJobType(3);
+ assertEquals(3, ds.getJobType());
+
+ }
+
+ @Test
+ public void testIdEntity() {
+ IdEntity ide = new IdEntity();
+
+ ide.set_id(12345L);
+ assertEquals(new Long(12345L), ide.get_id());
+ }
+
+ @Test
+ public void testJobStatus() {
+ assertEquals(0, JobStatus.READY);
+ }
+
+ @Test
+ public void testPartitionFormat() {
+ PartitionFormat pf = new PartitionFormat();
+
+ pf.setName("name");
+ assertEquals("name", pf.getName());
+ pf.setFormat("format");
+ assertEquals("format", pf.getFormat());
+
+ PartitionFormat pf1 = new PartitionFormat("name1", "format1");
+ assertEquals("name1", pf1.getName());
+ assertEquals("format1", pf1.getFormat());
+ }
+
+ @Test
+ public void testSampleFilePathLKP() {
+ SampleFilePathLKP sfp = new SampleFilePathLKP();
+
+ sfp.setModelName("name");
+ assertEquals("name", sfp.getModelName());
+ sfp.setHdfsPath("path");
+ assertEquals("path", sfp.getHdfsPath());
+ sfp.setTimestamp(12345L);
+ assertEquals(12345L, sfp.getTimestamp());
+ }
+
+ @Test
+ public void testUserSubscription() {
+ UserSubscription us = new UserSubscription();
+
+ us.setId("id");
+ assertEquals("id", us.getId());
+ us.setNtaccount("count");
+ assertEquals("count", us.getNtaccount());
+
+ List<PlatformSubscription> psList = new ArrayList<PlatformSubscription>();
+ PlatformSubscription ps = new PlatformSubscription("platform");
+ ps.setSelectAll(true);
+ List<SystemSubscription> ssList = new ArrayList<SystemSubscription>();
+ SystemSubscription ss = new SystemSubscription("system");
+ ss.setSelectAll(true);
+ List<String> daList = new ArrayList<String>();
+ daList.add("dataAsset");
+ ss.setDataassets(daList);
+ ssList.add(ss);
+ ps.setSystems(ssList);
+ psList.add(ps);
+ us.setSubscribes(psList);
+ assertEquals(psList, us.getSubscribes());
+
+ assertTrue(us.isPlatformSelected("platform"));
+ assertFalse(us.isPlatformSelected("platform1"));
+
+ assertTrue(us.isSystemSelected("platform", "system"));
+ assertFalse(us.isSystemSelected("platform", "system1"));
+
+ assertTrue(us.isDataAssetSelected("platform", "system", "dataAsset"));
+ assertFalse(us.isDataAssetSelected("platform", "system", "dataAsset1"));
+
+ UserSubscription us1 = new UserSubscription("user");
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/a8ba6ba9/griffin-core/src/test/java/com/ebay/oss/griffin/domain/SystemTypeTest.java
----------------------------------------------------------------------
diff --git a/griffin-core/src/test/java/com/ebay/oss/griffin/domain/SystemTypeTest.java b/griffin-core/src/test/java/com/ebay/oss/griffin/domain/SystemTypeTest.java
new file mode 100644
index 0000000..57f8c31
--- /dev/null
+++ b/griffin-core/src/test/java/com/ebay/oss/griffin/domain/SystemTypeTest.java
@@ -0,0 +1,29 @@
+package com.ebay.oss.griffin.domain;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+import com.ebay.oss.griffin.domain.SystemType;
+
+
+public class SystemTypeTest {
+
+ private static final String[] array = {"Bullseye", "GPS", "Hadoop", "PDS", "IDLS", "Pulsar", "Kafka", "Sojourner", "SiteSpeed", "EDW"};
+
+ @Test
+ public void testIndexOf() {
+ for(int i = 0; i < array.length; i++) {
+ assertEquals(i, SystemType.indexOf(array[i]));
+ }
+ assertEquals(-1, SystemType.indexOf("abcdefg"));
+ }
+
+ @Test
+ public void testVal() {
+ for (int i = 0; i < array.length; i++) {
+ assertEquals(array[i], SystemType.val(i));
+ }
+ assertEquals(SystemType.val(105), "105");
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/a8ba6ba9/griffin-core/src/test/java/com/ebay/oss/griffin/resources/ControllersTest.java
----------------------------------------------------------------------
diff --git a/griffin-core/src/test/java/com/ebay/oss/griffin/resources/ControllersTest.java b/griffin-core/src/test/java/com/ebay/oss/griffin/resources/ControllersTest.java
new file mode 100644
index 0000000..f0bd627
--- /dev/null
+++ b/griffin-core/src/test/java/com/ebay/oss/griffin/resources/ControllersTest.java
@@ -0,0 +1,524 @@
+package com.ebay.oss.griffin.resources;
+
+import static junit.framework.Assert.assertEquals;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriBuilder;
+
+import org.glassfish.grizzly.http.server.HttpServer;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import com.ebay.oss.griffin.domain.DataAsset;
+import com.ebay.oss.griffin.domain.DqMetricsValue;
+import com.ebay.oss.griffin.domain.UserSubscription;
+import com.ebay.oss.griffin.vo.AssetLevelMetrics;
+import com.ebay.oss.griffin.vo.DqModelVo;
+import com.ebay.oss.griffin.vo.ModelInput;
+import com.ebay.oss.griffin.vo.NotificationRecord;
+import com.ebay.oss.griffin.vo.OverViewStatistics;
+import com.ebay.oss.griffin.vo.PlatformMetadata;
+import com.ebay.oss.griffin.vo.SampleOut;
+import com.ebay.oss.griffin.vo.SystemLevelMetrics;
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.ClientResponse;
+import com.sun.jersey.api.client.GenericType;
+import com.sun.jersey.api.client.WebResource;
+import com.sun.jersey.api.client.config.DefaultClientConfig;
+import com.sun.jersey.api.container.grizzly2.GrizzlyServerFactory;
+import com.sun.jersey.api.core.PackagesResourceConfig;
+import com.sun.jersey.api.core.ResourceConfig;
+import com.sun.jersey.core.spi.component.ioc.IoCComponentProviderFactory;
+import com.sun.jersey.spi.spring.container.SpringComponentProviderFactory;
+
+@Ignore
+public class ControllersTest {
+ static final URI BASE_URI = getBaseURI();
+ static final String REST_PATH = "rest";
+ static HttpServer server;
+ static WebResource service;
+
+ private static URI getBaseURI() {
+ return UriBuilder.fromUri("http://localhost/").port(9998).build();
+ }
+
+ @BeforeClass
+ public static void startServer() throws IOException {
+ System.out.println("Starting grizzly...");
+
+ // Injector injector = Guice.createInjector(new ServletModule() {
+ // @Override
+ // protected void configureServlets() {
+ // bind(LoginService.class).to(LoginServiceImpl.class);
+ //
+ // }
+ // });
+
+ ResourceConfig rc = new PackagesResourceConfig(
+ "org.apache.bark.resources");
+
+ // IoCComponentProviderFactory ioc = new GuiceComponentProviderFactory(rc,
+ // injector);
+ ConfigurableApplicationContext cac =
+ new ClassPathXmlApplicationContext("classpath:context.xml");
+ IoCComponentProviderFactory ioc = new SpringComponentProviderFactory(rc,
+ cac);
+
+ server = GrizzlyServerFactory.createHttpServer(BASE_URI + REST_PATH, rc,
+ ioc);
+
+
+ System.out
+ .println(String
+ .format("Jersey app started with WADL available at "
+ + "%srest/application.wadl\nTry out %s\nHit enter to stop it...",
+ BASE_URI, BASE_URI));
+
+ Client client = Client.create(new DefaultClientConfig());
+ service = client.resource(getBaseURI());
+ }
+
+ @AfterClass
+ public static void stopServer() {
+ server.stop();
+ }
+
+
+ //-- LoginController test --
+ @Test
+ public void testLoginUser() throws IOException {
+ // Client client = Client.create(new DefaultClientConfig());
+ // WebResource service = client.resource(getBaseURI());
+
+ // String input = "{\"username\":\"test\",\"password\":\"test\"}";
+ //
+ //
+ // ClientResponse resp = service.path(REST_PATH).path("login/authenticate")
+ // .header("Content-Type", MediaType.APPLICATION_JSON)
+ // .accept(MediaType.APPLICATION_JSON)
+ // .post(ClientResponse.class, input);
+ // // .get(ClientResponse.class);
+ // //System.out.println("Got stuff: " + resp);
+ // String text = resp.getEntity(String.class);
+ //
+ // assertEquals(200, resp.getStatus());
+ // Assert.assertNotNull(text);
+ }
+
+
+ //-- DataAssetController test --
+ @Test
+ public void testDataAssetControllerGetSrcTree() throws IOException{
+ ClientResponse resp = service.path(REST_PATH).path("dataassets/metadata")
+ .accept(MediaType.APPLICATION_JSON)
+ .get(ClientResponse.class);
+
+ List<PlatformMetadata> list = resp.getEntity(new GenericType<List<PlatformMetadata>>(){});
+
+ assertEquals(200, resp.getStatus());
+ Assert.assertNotNull(list);
+ }
+
+ @Test
+ public void testDataAssetControllerNewGetUpdateDeleteAndGetAll() throws IOException{
+ String name = "testAsset_lliu13", owner = "lliu13";
+ String input = "{\"assetName\":\"" + name + "\",\"assetType\":\"hdfsfile\",\"assetHDFSPath\":\"/user/b_des/bark/\",\"system\":\"Bullseye\",\"platform\":\"Apollo\",\"owner\":\"" + owner + "\"}";
+
+ //add new data asset
+ ClientResponse respAdd = service.path(REST_PATH).path("dataassets/")
+ .header("Content-Type", MediaType.APPLICATION_JSON)
+ .accept(MediaType.APPLICATION_JSON)
+ .post(ClientResponse.class, input);
+ assertEquals(201, respAdd.getStatus());
+
+ //get all data asset
+ ClientResponse respGetAll = service.path(REST_PATH).path("dataassets/")
+ .accept(MediaType.APPLICATION_JSON)
+ .get(ClientResponse.class);
+ List<DataAsset> list = respGetAll.getEntity(new GenericType<List<DataAsset>>(){});
+ assertEquals(200, respGetAll.getStatus());
+ Assert.assertNotNull(list);
+ Assert.assertTrue(list.size() > 0);
+
+ //find the new add data asset id
+ long id = 0;
+ Iterator<DataAsset> itr = list.iterator();
+ while (itr.hasNext()) {
+ DataAsset da = itr.next();
+ if (da.getAssetName().equals(name)) {
+ id = da.get_id();
+ break ;
+ }
+ }
+
+ //get new add data asset
+ String prmGet = Long.toString(id);
+ ClientResponse respGet = service.path(REST_PATH).path("dataassets/metadata/" + prmGet)
+ .accept(MediaType.APPLICATION_JSON)
+ .get(ClientResponse.class);
+ DataAsset da = respGet.getEntity(DataAsset.class);
+ assertEquals(200, respGet.getStatus());
+ Assert.assertNotNull(da);
+
+ //get one asset, this interface is the same with the previous one
+ String prmGet1 = Long.toString(id);
+ ClientResponse respGet1 = service.path(REST_PATH).path("dataassets/" + prmGet1)
+ .accept(MediaType.APPLICATION_JSON)
+ .get(ClientResponse.class);
+ DataAsset da1 = respGet1.getEntity(DataAsset.class);
+ assertEquals(200, respGet1.getStatus());
+ Assert.assertNotNull(da1);
+
+ //update the data asset
+ String newOwner = "wenzhao";
+ String updateInput = "{\"assetName\":\"" + name + "\",\"assetType\":\"hdfsfile\",\"assetHDFSPath\":\"/user/b_des/bark/\",\"system\":\"Bullseye\",\"platform\":\"Apollo\",\"owner\":\"" + newOwner + "\"}";
+ ClientResponse respUpdate = service.path(REST_PATH).path("dataassets/")
+ .header("Content-Type", MediaType.APPLICATION_JSON)
+ .accept(MediaType.APPLICATION_JSON)
+ .put(ClientResponse.class, updateInput);
+ String updt = respUpdate.getEntity(String.class);
+ assertEquals(200, respUpdate.getStatus());
+ String sucUpdate = "{\"status\":\"0\" , \"result\":\"success\"}";
+ assertEquals(sucUpdate, updt);
+
+ //delete the data asset
+ String prmDel = Long.toString(id);
+ ClientResponse respDel = service.path(REST_PATH).path("dataassets/" + prmDel)
+ .accept(MediaType.APPLICATION_JSON)
+ .delete(ClientResponse.class);
+ String rm = respDel.getEntity(String.class);
+ assertEquals(200, respDel.getStatus());
+ String sucDel = "{\"status\":\"0\" , \"result\":\"success\"}";
+ assertEquals(sucDel, rm);
+ }
+
+ @Test
+ public void testDataAssetControllerGetAssetList() throws IOException{
+ ClientResponse resp = service.path(REST_PATH).path("dataassets/")
+ .accept(MediaType.APPLICATION_JSON)
+ .get(ClientResponse.class);
+
+ List<DataAsset> list = resp.getEntity(new GenericType<List<DataAsset>>(){});
+
+ assertEquals(200, resp.getStatus());
+ Assert.assertNotNull(list);
+ }
+
+ //-- DQMetricsController test --
+ @Test
+ public void testDQMetricsControllerInsertAndGetMetadata() throws IOException{
+
+ String asset_id = "test100", metricName = "test1001";
+ float v = 1638.6f;
+
+ //insert
+ String dq = "{\"id\":12345678,\"assetId\":\"" + asset_id + "\",\"metricName\":\"" + metricName + "\",\"timestamp\":" + new Date().getTime() + ",\"value\":" + v + "}";
+ ClientResponse respAdd = service.path(REST_PATH).path("metrics/")
+ .header("Content-Type", MediaType.APPLICATION_JSON)
+ .accept(MediaType.APPLICATION_JSON)
+ .post(ClientResponse.class, dq);
+ assertEquals(201, respAdd.getStatus());
+
+ ClientResponse respGet = service.path(REST_PATH).path("metrics/" + asset_id + "/latest")
+ .accept(MediaType.APPLICATION_JSON)
+ .get(ClientResponse.class);
+ DqMetricsValue val = respGet.getEntity(DqMetricsValue.class);
+ assertEquals(200, respGet.getStatus());
+ Assert.assertNotNull(val);
+ assertEquals(val.getValue(), v);
+ }
+
+ @Test
+ public void testDQMetricsControllerGetHeatMap() throws IOException{
+ ClientResponse resp = service.path(REST_PATH).path("metrics/heatmap")
+ .accept(MediaType.APPLICATION_JSON)
+ .get(ClientResponse.class);
+ List<SystemLevelMetrics> list = resp.getEntity(new GenericType<List<SystemLevelMetrics>>(){});
+ assertEquals(200, resp.getStatus());
+ Assert.assertNotNull(list);
+ }
+
+ @Test
+ public void testDQMetricsControllerGetAllBriefMetrics() throws IOException{
+ ClientResponse resp = service.path(REST_PATH).path("metrics/briefmetrics")
+ .accept(MediaType.APPLICATION_JSON)
+ .get(ClientResponse.class);
+ List<SystemLevelMetrics> list = resp.getEntity(new GenericType<List<SystemLevelMetrics>>(){});
+ assertEquals(200, resp.getStatus());
+ Assert.assertNotNull(list);
+ }
+
+ @Test
+ public void testDQMetricsControllerGetBriefMetrics() throws IOException{
+ String system = "unknown";
+ ClientResponse resp = service.path(REST_PATH).path("metrics/briefmetrics/" + system)
+ .accept(MediaType.APPLICATION_JSON)
+ .get(ClientResponse.class);
+ List<SystemLevelMetrics> list = resp.getEntity(new GenericType<List<SystemLevelMetrics>>(){});
+ assertEquals(200, resp.getStatus());
+ Assert.assertNotNull(list);
+ }
+
+ @Test
+ public void testDQMetricsControllerGetAllDashboard() throws IOException{
+ ClientResponse resp = service.path(REST_PATH).path("metrics/dashboard")
+ .accept(MediaType.APPLICATION_JSON)
+ .get(ClientResponse.class);
+ List<SystemLevelMetrics> list = resp.getEntity(new GenericType<List<SystemLevelMetrics>>(){});
+ assertEquals(200, resp.getStatus());
+ Assert.assertNotNull(list);
+ }
+
+ @Test
+ public void testDQMetricsControllerGetDashboard() throws IOException{
+ String system = "IDLS";
+ ClientResponse resp = service.path(REST_PATH).path("metrics/dashboard/" + system)
+ .accept(MediaType.APPLICATION_JSON)
+ .get(ClientResponse.class);
+ List<SystemLevelMetrics> list = resp.getEntity(new GenericType<List<SystemLevelMetrics>>(){});
+ assertEquals(200, resp.getStatus());
+ Assert.assertNotNull(list);
+ }
+
+ @Test
+ public void testDQMetricsControllerGetMyDashboard() throws IOException{
+ String user = "lliu13";
+ ClientResponse resp = service.path(REST_PATH).path("metrics/mydashboard/" + user)
+ .accept(MediaType.APPLICATION_JSON)
+ .get(ClientResponse.class);
+ List<SystemLevelMetrics> list = resp.getEntity(new GenericType<List<SystemLevelMetrics>>(){});
+ assertEquals(200, resp.getStatus());
+ Assert.assertNotNull(list);
+ }
+
+ @Test
+ public void testDQMetricsControllerGetCompelete() throws IOException{
+ String name = "TotalCount_asset1";
+ ClientResponse resp = service.path(REST_PATH).path("metrics/complete/" + name)
+ .accept(MediaType.APPLICATION_JSON)
+ .get(ClientResponse.class);
+ AssetLevelMetrics alm = resp.getEntity(AssetLevelMetrics.class);
+ assertEquals(200, resp.getStatus());
+ Assert.assertNotNull(alm);
+ System.out.println(alm.getName() + " -> " + alm.getDq());
+ System.out.println();
+ }
+
+ @Test
+ public void testDQMetricsControllerGetBrief() throws IOException{
+ String name = "TotalCount_asset1";
+ ClientResponse resp = service.path(REST_PATH).path("metrics/brief/" + name)
+ .accept(MediaType.APPLICATION_JSON)
+ .get(ClientResponse.class);
+ AssetLevelMetrics alm = resp.getEntity(AssetLevelMetrics.class);
+ assertEquals(200, resp.getStatus());
+ Assert.assertNotNull(alm);
+ System.out.println(alm.getName() + " -> " + alm.getDq());
+ System.out.println();
+ }
+
+ @Test
+ public void testDQMetricsControllerRefreshDQ() throws IOException{
+ ClientResponse resp = service.path(REST_PATH).path("metrics/refresh")
+ .accept(MediaType.APPLICATION_JSON)
+ .get(ClientResponse.class);
+ assertEquals(204, resp.getStatus());
+ }
+
+ @Test
+ public void testDQMetricsControllerGetOverViewStats() throws IOException{
+ ClientResponse resp = service.path(REST_PATH).path("metrics/statics")
+ .accept(MediaType.APPLICATION_JSON)
+ .get(ClientResponse.class);
+ OverViewStatistics ovs = resp.getEntity(OverViewStatistics.class);
+ assertEquals(200, resp.getStatus());
+ Assert.assertNotNull(ovs);
+ System.out.println("metrics: " + ovs.getMetrics() + " assets: " + ovs.getAssets());
+ System.out.println();
+ }
+
+ @Test
+ public void testDQMetricsControllerInsertGetAndDownloadSamplePath() throws IOException{
+
+ String name = "testModel100", path = "/user/b_des/bark/testPath/";
+
+ //insertSamplePath
+ String sample = "{\"modelName\":\"" + name + "\",\"hdfsPath\":\"" + path + "\",\"timestamp\":" + new Date().getTime() + "}";
+ ClientResponse respInsert = service.path(REST_PATH).path("metrics/sample")
+ .header("Content-Type", MediaType.APPLICATION_JSON)
+ .accept(MediaType.APPLICATION_JSON)
+ .post(ClientResponse.class, sample);
+ assertEquals(201, respInsert.getStatus());
+
+ //getSampleList
+ ClientResponse respGet = service.path(REST_PATH).path("metrics/sample/" + name)
+ .accept(MediaType.APPLICATION_JSON)
+ .get(ClientResponse.class);
+ List<SampleOut> list = respGet.getEntity(new GenericType<List<SampleOut>>(){});
+ assertEquals(200, respGet.getStatus());
+ Assert.assertNotNull(list);
+ Iterator<SampleOut> itr = list.iterator();
+ while (itr.hasNext()) {
+ SampleOut so = itr.next();
+ System.out.println("SampleOut: " + new Date(so.getDate()).toString() + " " + so.getPath());
+ }
+ if (list.size() == 0) System.out.println("Sample File List is empty");
+
+ //downloadFile
+ ClientResponse respDownload = service.path(REST_PATH).path("metrics/download/" + path)
+ .accept(MediaType.APPLICATION_OCTET_STREAM)
+ .get(ClientResponse.class);
+ assertEquals(200, respDownload.getStatus());
+ }
+
+
+
+ //-- DQModelController test --
+ @Test
+ public void testDQModelControllerAllModels() throws IOException{
+ ClientResponse resp = service.path(REST_PATH).path("models/")
+ .accept(MediaType.APPLICATION_JSON)
+ .get(ClientResponse.class);
+
+ List<DqModelVo> list = resp.getEntity(new GenericType<List<DqModelVo>>(){});
+
+ assertEquals(200, resp.getStatus());
+ Assert.assertNotNull(list);
+ }
+
+ @Test
+ public void testDQModelControllerNewGetAndDeleteModel() throws IOException{
+ String name = "testVali", owner = "lliu13", email = owner + "@ebay.com", db = "Apollo";
+
+ //newModel
+ String input = "{\"basic\":{\"type\":1,\"system\":0,\"status\":2,\"scheduleType\":0,\"owner\":\"" + owner +
+ "\",\"name\":\"" + name + "\",\"email\":\"" + email + "\",\"desc\":\"total count for dmg\"," +
+ "\"dataasetId\":6,\"dataaset\":\"dmg\"},\"extra\":{\"vaType\":1," +
+ "\"column\":\"age\",\"srcDataSet\":\"Bullseye.dmg\",\"srcDb\":\"" + db + "\"}}";
+ ClientResponse respNew = service.path(REST_PATH).path("models/")
+ .header("Content-Type", MediaType.APPLICATION_JSON)
+ .accept(MediaType.APPLICATION_JSON)
+ .post(ClientResponse.class, input);
+ assertEquals(201, respNew.getStatus());
+
+ //getModel
+ ClientResponse respGet = service.path(REST_PATH).path("models/" + name)
+ .accept(MediaType.APPLICATION_JSON)
+ .get(ClientResponse.class);
+ ModelInput mi = respGet.getEntity(ModelInput.class);
+ assertEquals(200, respGet.getStatus());
+ Assert.assertNotNull(mi);
+ assertEquals(mi.getBasic().getOwner(), owner);
+ assertEquals(mi.getExtra().getSrcDb(), db);
+
+ //deleteModel
+ ClientResponse respDel = service.path(REST_PATH).path("models/" + name)
+ .accept(MediaType.APPLICATION_JSON)
+ .delete(ClientResponse.class);
+ assertEquals(204, respDel.getStatus());
+ }
+
+ @Test
+ public void testDQModelControllerEnableModel() throws IOException{
+ String name = "accuracy_viewitem_e2e_user";
+ ClientResponse resp = service.path(REST_PATH).path("models/enableModel/" + name)
+ .accept(MediaType.APPLICATION_JSON)
+ .get(ClientResponse.class);
+
+ assertEquals(204, resp.getStatus());
+ }
+
+
+ //-- NotificationController test --
+ @Test
+ public void testNotificationControllerGetAll() throws IOException{
+ ClientResponse resp = service.path(REST_PATH).path("notifications/")
+ .accept(MediaType.APPLICATION_JSON)
+ .get(ClientResponse.class);
+
+ List<NotificationRecord> list = resp.getEntity(new GenericType<List<NotificationRecord>>(){});
+
+ assertEquals(200, resp.getStatus());
+ Assert.assertNotNull(list);
+ }
+
+
+
+ //-- ScheduleController test --
+ @Test
+ public void testScheduleControllerSchedule() throws IOException{
+ ClientResponse resp = service.path(REST_PATH).path("schedule/")
+ .accept(MediaType.APPLICATION_JSON)
+ .get(ClientResponse.class);
+
+ assertEquals(204, resp.getStatus());
+ }
+
+
+
+ //-- SubscribeController test --
+ @Test
+ public void testSubscribeControllerGet() throws IOException{
+ String user = "lliu13";
+ ClientResponse resp = service.path(REST_PATH).path("subscribe/" + user)
+ .accept(MediaType.APPLICATION_JSON)
+ .get(ClientResponse.class);
+
+ UserSubscription usi = resp.getEntity(UserSubscription.class);
+
+ assertEquals(200, resp.getStatus());
+ Assert.assertNotNull(usi);
+ }
+
+ @Test
+ public void testSubscribeControllerSet() throws IOException{
+ String input = "{}";
+ ClientResponse resp = service.path(REST_PATH).path("subscribe/")
+ .header("Content-Type", MediaType.APPLICATION_JSON)
+ .accept(MediaType.APPLICATION_JSON)
+ .post(ClientResponse.class, input);
+
+ assertEquals(204, resp.getStatus());
+ }
+
+ //-- ReportController test --
+ @Test
+ public void testReportControllerGetBEReportByName() throws IOException{
+ String name = "mean";
+ ClientResponse resp = service.path(REST_PATH).path("report/be")
+ .queryParam("name", name)
+ .header("Content-Type", MediaType.APPLICATION_JSON)
+ .accept(MediaType.APPLICATION_JSON)
+ .get(ClientResponse.class);
+
+ String str = resp.getEntity(String.class);
+ assertEquals(200, resp.getStatus());
+ Assert.assertNotNull(str);
+ }
+
+ @Test
+ public void testReportControllerGetBrief() throws IOException{
+ String name = "test1001";
+ ClientResponse resp = service.path(REST_PATH).path("report/24h")
+ .queryParam("name", name)
+ .header("Content-Type", MediaType.APPLICATION_JSON)
+ .accept(MediaType.APPLICATION_JSON)
+ .get(ClientResponse.class);
+
+ AssetLevelMetrics alm = resp.getEntity(AssetLevelMetrics.class);
+ assertEquals(200, resp.getStatus());
+ Assert.assertNotNull(alm);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/a8ba6ba9/griffin-core/src/test/java/com/ebay/oss/griffin/service/DQMetricsServiceImplTest.java
----------------------------------------------------------------------
diff --git a/griffin-core/src/test/java/com/ebay/oss/griffin/service/DQMetricsServiceImplTest.java b/griffin-core/src/test/java/com/ebay/oss/griffin/service/DQMetricsServiceImplTest.java
new file mode 100644
index 0000000..2526fc6
--- /dev/null
+++ b/griffin-core/src/test/java/com/ebay/oss/griffin/service/DQMetricsServiceImplTest.java
@@ -0,0 +1,206 @@
+package com.ebay.oss.griffin.service;
+
+import static org.junit.Assert.*;
+
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.ebay.oss.griffin.domain.DqMetricsValue;
+import com.ebay.oss.griffin.domain.SampleFilePathLKP;
+import com.ebay.oss.griffin.service.DQMetricsServiceImpl;
+import com.ebay.oss.griffin.vo.AssetLevelMetrics;
+import com.ebay.oss.griffin.vo.OverViewStatistics;
+import com.ebay.oss.griffin.vo.SampleOut;
+import com.ebay.oss.griffin.vo.SystemLevelMetrics;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = {"classpath:context.xml"})
+public class DQMetricsServiceImplTest {
+
+ @Autowired
+ private DQMetricsServiceImpl dqMetricsService;
+
+ //insertMetadata
+ private void testInsertMetadata(String id, String metric, float val) {
+ DqMetricsValue dqmv = new DqMetricsValue();
+ dqmv.set_id(12345678L);
+ dqmv.setAssetId(id);
+ dqmv.setMetricName(metric);
+ dqmv.setTimestamp(new Date().getTime());
+ dqmv.setValue(val);
+ dqMetricsService.insertMetadata(dqmv);
+ }
+
+ //getLatestlMetricsbyId
+ private void testGetLatestlMetricsbyId(String id, String metric, float val) {
+ DqMetricsValue dv = dqMetricsService.getLatestlMetricsbyId(id);
+ assertNotNull(dv);
+ assertEquals(dv.getMetricName(), metric);
+ assertTrue(dv.getValue() == val);
+ }
+
+ @Test
+ public void testDQMetricsService() {
+
+ String id = "test100", metric = "mean";
+ float val = 4835.3f;
+
+ //insertMetadata
+ testInsertMetadata(id, metric, val);
+
+ //getLatestlMetricsbyId
+ testGetLatestlMetricsbyId(id, metric, val);
+ }
+
+ @Test
+ public void testHeatMap() {
+ System.out.println("===== Heat Map =====");
+ List<SystemLevelMetrics> slmList = dqMetricsService.heatMap();
+ for (SystemLevelMetrics slm : slmList) {
+ System.out.println("--- " + slm.getName() + ": Dq: " + slm.getDq() + " ---");
+ List<AssetLevelMetrics> almList = slm.getMetrics();
+ for (AssetLevelMetrics alm : almList) {
+ System.out.println(alm.getName() + ": " + alm.getMetricType() + " -> " + alm.getDq());
+ }
+ System.out.println();
+ }
+ }
+
+ @Test
+ public void testBriefMetrics() {
+ System.out.println("===== Brief Metrics =====");
+ List<SystemLevelMetrics> slmList1 = dqMetricsService.briefMetrics("Bullseye");
+ for (SystemLevelMetrics slm : slmList1) {
+ System.out.println("--- " + slm.getName() + ": Dq: " + slm.getDq() + " ---");
+ List<AssetLevelMetrics> almList = slm.getMetrics();
+ for (AssetLevelMetrics alm : almList) {
+ System.out.println(alm.getName() + ": " + alm.getMetricType() + " -> " + alm.getDq());
+ }
+ System.out.println();
+ }
+ }
+
+ @Test
+ public void testDashBoard() {
+ System.out.println("===== Dash Board =====");
+ List<SystemLevelMetrics> slmList2 = dqMetricsService.dashboard("IDLS");
+ for (SystemLevelMetrics slm : slmList2) {
+ System.out.println("--- " + slm.getName() + ": Dq: " + slm.getDq() + " ---");
+ List<AssetLevelMetrics> almList = slm.getMetrics();
+ for (AssetLevelMetrics alm : almList) {
+ System.out.println(alm.getName() + ": " + alm.getMetricType() + " -> " + alm.getDq());
+ }
+ System.out.println();
+ }
+ }
+
+ @Test
+ public void testOneDataCompleteDashboard() {
+ System.out.println("===== oneDataCompleteDashboard =====");
+ AssetLevelMetrics aslm = dqMetricsService.oneDataCompleteDashboard("test_accuracy_1");
+ assertNotNull(aslm);
+ System.out.println(aslm.getName() + " -> " + aslm.getDq());
+ System.out.println();
+ }
+
+ @Test
+ public void testOneDataBriefDashboard() {
+ System.out.println("===== oneDataBriefDashboard =====");
+ AssetLevelMetrics alm1 = dqMetricsService.oneDataBriefDashboard("test_accuracy_1");
+ assertNotNull(alm1);
+ System.out.println(alm1.getName() + " -> " + alm1.getDq());
+ System.out.println();
+ }
+
+ @Test
+ public void testMetricsForReport() {
+ System.out.println("===== metricsForReport =====");
+ AssetLevelMetrics alm2 = dqMetricsService.metricsForReport("test_accuracy_1");
+ assertNotNull(alm2);
+ System.out.println(alm2.getName() + " -> " + alm2.getDq());
+ System.out.println();
+ }
+
+ @Test
+ public void testUpdateLatestDQList() {
+ System.out.println("===== updateLatestDQList =====");
+ dqMetricsService.updateLatestDQList();
+ System.out.println("update latest dq list succeed");
+ System.out.println();
+ }
+
+ @Test
+ public void testGetOverViewStats() {
+ System.out.println("===== getOverViewStats =====");
+ OverViewStatistics ovs = dqMetricsService.getOverViewStats();
+ assertNotNull(ovs);
+ System.out.println("metrics: " + ovs.getMetrics() + " assets: " + ovs.getAssets());
+ System.out.println();
+ }
+
+ @Test
+ public void testMydashboard() {
+ System.out.println("===== My Dash Board =====");
+ List<SystemLevelMetrics> slmList3 = dqMetricsService.mydashboard("lliu13");
+ for (SystemLevelMetrics slm : slmList3) {
+ System.out.println("--- " + slm.getName() + ": Dq: " + slm.getDq() + " ---");
+ List<AssetLevelMetrics> almList = slm.getMetrics();
+ for (AssetLevelMetrics alm : almList) {
+ System.out.println(alm.getName() + ": " + alm.getMetricType() + " -> " + alm.getDq());
+ }
+ System.out.println();
+ }
+ if (slmList3.size() == 0) System.out.println("my dash board is empty");
+ }
+
+ private void testInsertSampleFilePath(String modelName, String path) {
+ System.out.println("===== Insert Sample File Path =====");
+ SampleFilePathLKP sfp = new SampleFilePathLKP();
+ sfp.setModelName(modelName);
+ sfp.setHdfsPath(path);
+ sfp.setTimestamp(new Date().getTime());
+ dqMetricsService.insertSampleFilePath(sfp);
+ System.out.println("Insert Sample File Path");
+ }
+
+ private void testListSampleFile(String modelName) {
+ System.out.println("===== List Sample File =====");
+ List<SampleOut> soList = dqMetricsService.listSampleFile(modelName);
+ Iterator<SampleOut> itr = soList.iterator();
+ while (itr.hasNext()) {
+ SampleOut so = itr.next();
+ System.out.println("SampleOut: " + new Date(so.getDate()).toString() + " " + so.getPath());
+ }
+ if (soList.size() == 0) System.out.println("Sample File List is empty");
+ }
+
+ @Test
+ public void testSampleFileProcess() {
+ String modelName = "testModel100", path = "/user/b_des/bark/testPath/";
+
+ //insert sample file
+ testInsertSampleFilePath(modelName, path);
+
+ //list sample file
+ testListSampleFile(modelName);
+
+ }
+
+ @Test
+ public void testGetThresholds() {
+ Map<String, String> thresholdMap = dqMetricsService.getThresholds();
+ System.out.println("---- threshold map ----");
+ for (Map.Entry<String, String> me : thresholdMap.entrySet()) {
+ System.out.println(me.getKey() + " -> " + me.getValue());
+ }
+ }
+
+}