You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@eagle.apache.org by ha...@apache.org on 2016/03/03 19:09:44 UTC
[11/51] [partial] incubator-eagle git commit: EAGLE-184 Migrate eagle
website from https://github.com/eaglemonitoring/eaglemonitoring.github.io to
document branch
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-query/eagle-service-base/src/test/java/org/apache/eagle/service/generic/TestListQueryResource.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-service-base/src/test/java/org/apache/eagle/service/generic/TestListQueryResource.java b/eagle-core/eagle-query/eagle-service-base/src/test/java/org/apache/eagle/service/generic/TestListQueryResource.java
deleted file mode 100755
index a53f980..0000000
--- a/eagle-core/eagle-query/eagle-service-base/src/test/java/org/apache/eagle/service/generic/TestListQueryResource.java
+++ /dev/null
@@ -1,601 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.eagle.service.generic;
-
-import org.apache.eagle.common.config.EagleConfigFactory;
-import org.apache.eagle.log.entity.GenericEntityWriter;
-import org.apache.eagle.log.entity.GenericMetricEntity;
-import org.apache.eagle.log.entity.ListQueryAPIResponseEntity;
-import org.apache.eagle.log.entity.meta.EntityDefinition;
-import org.apache.eagle.log.entity.meta.EntityDefinitionManager;
-import org.apache.eagle.log.entity.test.TestLogAPIEntity;
-import org.apache.eagle.log.entity.test.TestTimeSeriesAPIEntity;
-import org.apache.eagle.query.ListQueryCompiler;
-import org.apache.eagle.service.hbase.TestHBaseBase;
-import org.apache.eagle.storage.hbase.query.coprocessor.AggregateClient;
-import org.apache.eagle.storage.hbase.query.coprocessor.impl.AggregateClientImpl;
-import org.apache.eagle.common.DateTimeUtil;
-import org.apache.hadoop.hbase.client.HTableInterface;
-import org.apache.hadoop.hbase.client.Scan;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-public class TestListQueryResource extends TestHBaseBase {
-
- HTableInterface table;
- long startTime;
- long endTime;
- List<String> rowkeys;
- AggregateClient client;
- Scan scan;
- String TEST_TIME_SERIES_API_SERVICE = "TestTimeSeriesAPIEntity";
- EntityDefinition entityDefinition = null;
-
- @Before
- public void setUp() throws IllegalAccessException, InstantiationException, IOException {
- entityDefinition = EntityDefinitionManager.getEntityDefinitionByEntityClass(GenericMetricEntity.class);
- hbase.createTable(entityDefinition.getTable(), entityDefinition.getColumnFamily());
-
- entityDefinition = EntityDefinitionManager.getEntityDefinitionByEntityClass(TestLogAPIEntity.class);
- hbase.createTable(entityDefinition.getTable(), entityDefinition.getColumnFamily());
-
- table = EagleConfigFactory.load().getHTable("unittest");
- startTime = System.currentTimeMillis();
- try {
-// rowkeys = prepareTestEntity(200);
- } catch (Exception e) {
- e.printStackTrace();
- junit.framework.Assert.fail(e.getMessage());
- }
- endTime = System.currentTimeMillis();
-
- client = new AggregateClientImpl();
- scan = new Scan();
- ListQueryCompiler compiler = null;
- try {
- compiler = new ListQueryCompiler(TEST_TIME_SERIES_API_SERVICE +"[@cluster=\"test4UT\" and @datacenter = \"dc1\"]{@field1,@field2}");
- } catch (Exception e) {
- junit.framework.Assert.fail(e.getMessage());
- }
- scan.setFilter(compiler.filter());
-// scan.setStartRow(EagleBase64Wrapper.decode(rowkeys.get(0)));
-// scan.setStopRow(EagleBase64Wrapper.decode(rowkeys.get(rowkeys.size()-1)));
- }
-
- @After
- public void cleanUp() throws IllegalAccessException, InstantiationException, IOException {
- entityDefinition = EntityDefinitionManager.getEntityDefinitionByEntityClass(GenericMetricEntity.class);
- hbase.deleteTable(entityDefinition.getTable());
-
- entityDefinition = EntityDefinitionManager.getEntityDefinitionByEntityClass(TestLogAPIEntity.class);
- hbase.deleteTable(entityDefinition.getTable());
- }
-
- @SuppressWarnings("unused")
- private List<String> prepareTestEntity(int count) throws Exception {
- List<TestTimeSeriesAPIEntity> list = new ArrayList<TestTimeSeriesAPIEntity>();
- EntityDefinition ed = EntityDefinitionManager.getEntityDefinitionByEntityClass(TestTimeSeriesAPIEntity.class);
-
- if (ed == null) {
- EntityDefinitionManager.registerEntity(TestTimeSeriesAPIEntity.class);
- ed = EntityDefinitionManager.getEntityDefinitionByEntityClass(TestTimeSeriesAPIEntity.class);
- }
-
- for(int i=0;i<count;i++){
- TestTimeSeriesAPIEntity e = new TestTimeSeriesAPIEntity();
- e.setTimestamp(System.currentTimeMillis());
- e.setField1(1);
- e.setField2(2);
- e.setField3(3);
- e.setField4(4L);
- e.setField5(5.0);
- e.setField6(5.0);
- e.setField7("7");
- e.setTags(new HashMap<String, String>());
- e.getTags().put("cluster", "test4UT");
- e.getTags().put("datacenter", "dc1");
- e.getTags().put("index", ""+i);
- e.getTags().put("jobId", "job_"+System.currentTimeMillis());
- list.add(e);
- }
-
- GenericEntityWriter writer = new GenericEntityWriter(ed.getService());
- List<String> result = writer.write(list);
- return result;
- }
-
- private List<String> prepareMetricEntity(long startTime,int count) throws Exception {
- List<GenericMetricEntity> list = new ArrayList<GenericMetricEntity>();
- EntityDefinition ed = EntityDefinitionManager.getEntityDefinitionByEntityClass(GenericMetricEntity.class);
-
- double[] value = new double[60];
- for(int i=0;i<60;i++){
- value[i] = 1;
- }
- for(int i=0;i<count;i++){
- GenericMetricEntity e = new GenericMetricEntity();
- e.setTimestamp(startTime+i*3600*1000);
- e.setValue(value);
- e.setTags(new HashMap<String, String>());
- e.getTags().put("cluster", "test4UT");
- e.getTags().put("datacenter", "dc1");
- e.getTags().put("index", ""+i);
- e.getTags().put("jobId", "job_"+System.currentTimeMillis());
- e.setPrefix("eagle.metric.test");
- list.add(e);
- }
-
- GenericEntityWriter writer = new GenericEntityWriter(ed.getService());
- List<String> result = writer.write(list);
- return result;
- }
-
- @Test
- public void testMetricQuery() throws Exception {
- long _startTime = System.currentTimeMillis();
- List<String> rowKeys = prepareMetricEntity(startTime,200);
- long _endTime = startTime+ 200 * 3600*1000;
- String startTime = DateTimeUtil.secondsToHumanDate(_startTime / 1000);
- String endTime = DateTimeUtil.secondsToHumanDate((_endTime + 1000) / 1000);
-
- ListQueryResource resource = new ListQueryResource();
- String query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{count}";
-
- ListQueryAPIResponseEntity response = resource.listQuery(query, startTime, endTime, 100, null, false, false, 1, 0, false, 0, "eagle.metric.test");
- Assert.assertNotNull(response);
- Assert.assertTrue(response.isSuccess());
-
- query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]{EXP{@value/3}}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, false, 1, 0, false, 0, "eagle.metric.test");
- Assert.assertNotNull(response);
- Assert.assertTrue(response.isSuccess());
-
- query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]{*}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, false, 1, 0, false, 0, "eagle.metric.test");
- Assert.assertNotNull(response);
- Assert.assertTrue(response.isSuccess());
-
- query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{max(value)}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, false, 1, 0, false, 0, "eagle.metric.test");
- Assert.assertNotNull(response);
- Assert.assertTrue(response.isSuccess());
-
- query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{min(value)}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, false, 1, 0, false, 0, "eagle.metric.test");
- Assert.assertNotNull(response);
- Assert.assertTrue(response.isSuccess());
-
- query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{sum(value)}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, false, 1, 0, false, 0, "eagle.metric.test");
- Assert.assertNotNull(response);
- Assert.assertTrue(response.isSuccess());
-
- query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{avg(value)}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, false, 1, 0, false, 0, "eagle.metric.test");
- Assert.assertNotNull(response);
- Assert.assertTrue(response.isSuccess());
-
-
- //////////////////////////////////////////
- /// Time series aggregation
- //////////////////////////////////////////
- query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{avg(value)}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 6000000, 0, false, 0, "eagle.metric.test");
- Assert.assertNotNull(response);
- Assert.assertTrue(response.isSuccess());
-
- query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{sum(value)}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 6000000, 0, false, 0, "eagle.metric.test");
- Assert.assertNotNull(response);
- Assert.assertTrue(response.isSuccess());
-
- query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{max(value)}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 6000000, 0, false, 0, "eagle.metric.test");
- Assert.assertNotNull(response);
- Assert.assertTrue(response.isSuccess());
-
- query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{min(value)}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 6000000, 0, false, 0, "eagle.metric.test");
- Assert.assertNotNull(response);
- Assert.assertTrue(response.isSuccess());
-
- query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{count}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 6000000, 0, false, 0, "eagle.metric.test");
- Assert.assertNotNull(response);
- Assert.assertTrue(response.isSuccess());
- }
-
- @Test
- public void testMetricQueryWithSort() throws Exception {
- long _startTime = System.currentTimeMillis();
- List<String> rowKeys = prepareMetricEntity(startTime,200);
- long _endTime = startTime+ 200 * 3600*1000;
- String startTime = DateTimeUtil.secondsToHumanDate(_startTime / 1000);
- String endTime = DateTimeUtil.secondsToHumanDate((_endTime + 1000) / 1000);
-
- ListQueryResource resource = new ListQueryResource();
- String query;
-
- ListQueryAPIResponseEntity response;
-
-
- //////////////////////////////////////////
- /// Time series aggregation
- //////////////////////////////////////////
- query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{sum(value)}.{avg(value) desc}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 6000000, 0, false, 0, "eagle.metric.test");
- Assert.assertNotNull(response);
- Assert.assertTrue(response.isSuccess());
-
- query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{avg(value)}.{sum(value) desc}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 6000000, 0, false, 0, "eagle.metric.test");
- Assert.assertNotNull(response);
- Assert.assertTrue(response.isSuccess());
-
- query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{sum(value)}.{max(value) asc}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 6000000, 0, false, 0, "eagle.metric.test");
- Assert.assertNotNull(response);
- Assert.assertTrue(response.isSuccess());
-
- query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{max(value)}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 6000000, 0, false, 0, "eagle.metric.test");
- Assert.assertNotNull(response);
- Assert.assertTrue(response.isSuccess());
-
- query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{min(value)}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 6000000, 0, false, 0, "eagle.metric.test");
- Assert.assertNotNull(response);
- Assert.assertTrue(response.isSuccess());
-
- query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{count}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 6000000, 0, false, 0, "eagle.metric.test");
- Assert.assertNotNull(response);
- Assert.assertTrue(response.isSuccess());
-
- query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{max(value)}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, false, 1, 0, false, 0, "eagle.metric.test");
- Assert.assertNotNull(response);
- Assert.assertTrue(response.isSuccess());
-
- query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{min(value)}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, false, 1, 0, false, 0, "eagle.metric.test");
- Assert.assertNotNull(response);
- Assert.assertTrue(response.isSuccess());
-
- query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{sum(value)}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, false, 1, 0, false, 0, "eagle.metric.test");
- Assert.assertNotNull(response);
- Assert.assertTrue(response.isSuccess());
-
- query = "GenericMetricService[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{avg(value)}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, false, 1, 0, false, 0, "eagle.metric.test");
- Assert.assertNotNull(response);
- Assert.assertTrue(response.isSuccess());
- }
-
- @Test
- public void testPartitionBasedQuery() throws InstantiationException, IllegalAccessException {
- String[] partitions = new String[2];
- partitions[0] = "cluster";
- partitions[1] = "datacenter";
- EntityDefinitionManager.registerEntity(TestLogAPIEntity.class);
- EntityDefinition entityDef = EntityDefinitionManager.getEntityByServiceName("TestLogAPIEntity");
- entityDef.setPartitions(partitions);
- entityDef.setTimeSeries(true);
-
- ListQueryResource resource = new ListQueryResource();
- String query = "TestLogAPIEntity[]{@cluster}";
- String startTime = DateTimeUtil.secondsToHumanDate(System.currentTimeMillis() / 1000);
- String endTime = DateTimeUtil.secondsToHumanDate((System.currentTimeMillis() + 1000) / 1000);
-
- ListQueryAPIResponseEntity response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null);
- Assert.assertNotNull(response);
- Assert.assertFalse(response.isSuccess());
-
- query = "TestLogAPIEntity[@cluster=\"cluster1\" ]{@cluster}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null);
- Assert.assertNotNull(response);
- Assert.assertFalse(response.isSuccess());
-
- query = "TestLogAPIEntity[@cluster=\"cluster1\" AND @datacenter=\"dc1\"]{@cluster}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null);
- Assert.assertNotNull(response);
- Assert.assertTrue(response.isSuccess());
-
- query = "TestLogAPIEntity[(@cluster=\"cluster1\") OR (@cluster=\"cluster1\" AND @datacenter=\"dc1\")]{@cluster}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null);
- Assert.assertNotNull(response);
- Assert.assertFalse(response.isSuccess());
-
- query = "TestLogAPIEntity[(@cluster=\"cluster1\" AND @datacenter=\"dc1\" AND @tag1=\"value1\") OR (@cluster=\"cluster1\" AND @datacenter=\"dc1\" AND @tag2=\"value2\")]{@cluster}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null);
- Assert.assertNotNull(response);
- Assert.assertTrue(response.isSuccess());
-
- query = "TestLogAPIEntity[@cluster=\"cluster1\" AND @datacenter=\"dc1\" AND (@tag1=\"value1\" OR @tag2=\"value2\")]{@cluster}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null);
- Assert.assertNotNull(response);
- Assert.assertTrue(response.isSuccess());
-
- // Tag with =, !=, =~, !=~, contains, not contains, in, not in
- query = "TestLogAPIEntity[@cluster=\"cluster1\" AND @datacenter=\"dc1\" AND (@tag1!=\"value1\" or @tag2=~\"value2\" or ((@tag3 contains \"value3\") or (@tag3 not contains \"value3\")) or @tag4 !=~ \"value4\" or @tag5 in (\"value5-1\",\"value5-2\",\"value5-3\") or @tag6 not in (\"value5-1\",\"value5-2\",\"value5-3\"))]{@cluster}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null);
- Assert.assertNotNull(response);
- Assert.assertTrue(response.isSuccess());
-
- // Tag with complex IN & List
- query = "TestLogAPIEntity[@cluster=\"cluster1\" AND @datacenter=\"dc1\" AND (@tag5 in (\"value5-1\",\"value5,2\"))]{@cluster}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null);
- Assert.assertNotNull(response);
- Assert.assertTrue(response.isSuccess());
-
- // Tag with unsupported operation
- query = "TestLogAPIEntity[@cluster=\"cluster1\" AND @datacenter=\"dc1\" AND (@tag1 < \"value1\")]{@cluster}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null);
- Assert.assertNotNull(response);
- Assert.assertFalse("Tag with unsupported operation, should get exception",response.isSuccess());
-
- // Field with numeric
- query = "TestLogAPIEntity[@cluster=\"cluster1\" AND @datacenter=\"dc1\" AND " +
- "(@field1 < 1 or @field2 = 2 or @field3 = 13456789 or @field4 = 987654321 or @field5 = 5.6 or @field7 < \"value7\")]{@cluster}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null);
- Assert.assertNotNull(response);
- Assert.assertTrue("Field with numeric, should success",response.isSuccess());
-
- // Field with not supported negative numeric value which is to be supported with coprocessor later
- query = "TestLogAPIEntity[@cluster=\"cluster1\" AND @datacenter=\"dc1\" AND (@field1 < -1)]{@cluster}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null);
- Assert.assertNotNull(response);
- Assert.assertTrue("Field supporte negative numeric value, should get exception", response.isSuccess());
-
- // Query with escaped value
- query = "TestLogAPIEntity[@cluster=\"cluster1\" AND @datacenter=\"dc1\" AND (@tag1 in (\"\\\"value1-part1\\\",\\\"value1-part2\\\"\",\"value2\"))]{@cluster}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null);
- Assert.assertNotNull(response);
- Assert.assertTrue("Support escaped quotes, should success: "+query,response.isSuccess());
-
- // Query with null
- query = "TestLogAPIEntity[@cluster=\"cluster1\" AND @datacenter=\"dc1\" AND @tag1 is null ]{@cluster}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null);
- Assert.assertNotNull(response);
- Assert.assertTrue("Support is null, should success: "+query,response.isSuccess());
-
- query = "TestLogAPIEntity[@cluster=\"cluster1\" AND @datacenter=\"dc1\" AND @tag1 is not null]{@cluster}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null);
- Assert.assertNotNull(response);
- Assert.assertTrue("Support is not null, should success: "+query,response.isSuccess());
-
- query = "TestLogAPIEntity[@cluster=\"cluster1\" AND @datacenter=\"dc1\" AND @tag1 is not null]{*}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null);
- Assert.assertNotNull(response);
- Assert.assertTrue("Support is not null, should success: "+query,response.isSuccess());
-
-// startTime = "2014-02-13 15:00:00";
-// endTime = "2014-02-13 15:05:00";
-// query = "TaskAttemptExecutionService[@cluster=\"cluster1\" AND @datacenter=\"dc1\"]{@cluster,@startTime}";
-// response = resource.listQuery(query, startTime, endTime, 10, null, false, true, 1);
-// Assert.assertNotNull(response);
-// Assert.assertTrue(response.isSuccess());
-
- query = "TestLogAPIEntity[@cluster=\"cluster1\" AND @datacenter=\"dc1\" AND EXP{@field1 + @field2} > 0]{@cluster}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null);
- Assert.assertNotNull(response);
- Assert.assertTrue("Support expression in filter, should success: "+query,response.isSuccess());
-
- query = "TestLogAPIEntity[@cluster=\"cluster1\" AND @datacenter=\"dc1\" AND EXP{@field1 + @field2} > 0]{EXP{@field1 + @field2} }";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null);
- Assert.assertNotNull(response);
- Assert.assertTrue("Support expression in output, should success: "+query,response.isSuccess());
-
- query = "TestLogAPIEntity[@cluster=\"cluster1\" AND @datacenter=\"dc1\" AND EXP{@field1 + @field2} > 0]{EXP{@field1 + @field2} as A}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null);
- Assert.assertNotNull(response);
- Assert.assertTrue("Support expression output with alias, should success: "+query,response.isSuccess());
-
- query = "TestLogAPIEntity[@cluster=\"cluster1\" AND @datacenter=\"dc1\" AND EXP{@field1 + @field2} > 0]{@cluster,EXP{@field1 + @field2} as A}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null,true);
- Assert.assertNotNull(response);
- Assert.assertTrue("Support parameter \"verbose\" is true, should success: "+query,response.isSuccess());
-
- query = "TestLogAPIEntity[@cluster=\"cluster1\" AND @datacenter=\"dc1\" AND EXP{@field1 + @field2} > 0]{@cluster,EXP{@field1 + @field2} as A}";
- response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null,false);
- Assert.assertNotNull(response);
- Assert.assertTrue("Support parameter \"verbose\" is false, should success: "+query,response.isSuccess());
- }
-
- @Test
- public void testObjectTypeFieldQuery() throws IllegalAccessException, InstantiationException {
-
- String startTime = DateTimeUtil.secondsToHumanDate(System.currentTimeMillis() / 1000);
- String endTime = DateTimeUtil.secondsToHumanDate((System.currentTimeMillis() + 1000) / 1000);
-
- String[] partitions = new String[2];
- partitions[0] = "cluster";
- partitions[1] = "datacenter";
- EntityDefinitionManager.registerEntity(TestLogAPIEntity.class);
- EntityDefinition entityDef = EntityDefinitionManager.getEntityByServiceName("TestLogAPIEntity");
- entityDef.setPartitions(partitions);
- entityDef.setTimeSeries(true);
-
- ListQueryResource resource = new ListQueryResource();
- String query = "TestLogAPIEntity[]{@cluster}";
-
- // Field with numeric
- query = "TestLogAPIEntity[@cluster=\"cluster1\" AND @datacenter=\"dc1\" AND " +
- "(@field1 < 1 or @field2 = 2 or @field3 = 13456789 or @field4 = 987654321 or @field5 = 5.6 or @field7 < \"value7\")]{@cluster}";
- ListQueryAPIResponseEntity response = resource.listQuery(query, startTime, endTime, 100, null, false, true, 1, 0, false, 0, null);
- Assert.assertNotNull(response);
- Assert.assertTrue("Field with numeric, should success",response.isSuccess());
- }
-
- @Test
- public void testFlatAggregateQuery(){
- ListQueryResource resource = new ListQueryResource();
- ListQueryAPIResponseEntity response = null;
- String query = null;
-// String start = DateTimeUtil.secondsToHumanDate(startTime / 1000);
- String start = DateTimeUtil.secondsToHumanDate(0);
-
- String end = DateTimeUtil.secondsToHumanDate((endTime + 24 * 3600) / 1000);
-
- query = TEST_TIME_SERIES_API_SERVICE +"[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{count}";
- response = resource.listQuery(query, start, end, 100000, null, false, false, 1, 0, false, 0, null);
-
- Assert.assertNotNull(response);
-// Assert.assertTrue(response.getLastTimestamp() > 0);
-// Assert.assertTrue(response.getFirstTimestamp() >= 0);
-// Assert.assertTrue(response.getLastTimestamp() >= response.getFirstTimestamp());
-
- Assert.assertTrue("Support is null, should success: "+query,response.isSuccess());
-
- query = TEST_TIME_SERIES_API_SERVICE +"[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{max(field1)}.{max(field1) desc}";
- response = resource.listQuery(query, start, end, 100000, null, false, false, 1, 0, false, 0, null);
- Assert.assertNotNull(response);
- Assert.assertTrue("Support is null, should success: "+query,response.isSuccess());
-
- query = TEST_TIME_SERIES_API_SERVICE +"[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{min(field1)}.{min(field1) desc}";
- response = resource.listQuery(query, start, end, 100000, null, false, false, 1, 0, false, 0, null);
- Assert.assertNotNull(response);
- Assert.assertTrue("Support is null, should success: "+query,response.isSuccess());
-
- query = TEST_TIME_SERIES_API_SERVICE +"[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{sum(field1)}.{sum(field1) desc}";
- response = resource.listQuery(query, start, end, 100000, null, false, false, 1, 0, false, 0, null);
- Assert.assertNotNull(response);
- Assert.assertTrue("Support is null, should success: "+query,response.isSuccess());
-
- query = TEST_TIME_SERIES_API_SERVICE +"[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{avg(field1)}.{avg(field1) desc}";
- response = resource.listQuery(query, start, end, 100000, null, false, false, 1, 0, false, 0, null);
- Assert.assertNotNull(response);
- Assert.assertTrue("Support is null, should success: "+query,response.isSuccess());
-
- query = TEST_TIME_SERIES_API_SERVICE +"[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{count}.{count desc}";
- response = resource.listQuery(query, start, end, 100000, null, false, false, 1, 0, false, 0, null);
- Assert.assertNotNull(response);
- Assert.assertTrue("Support is null, should success: "+query,response.isSuccess());
-
- query = TEST_TIME_SERIES_API_SERVICE +"[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@c...@datacenter>{max(field1),min(field1),avg(field1),sum(field1),count}.{sum(field1) desc}";
- response = resource.listQuery(query, start, end, 100000, null, false, false, 1, 0, false, 0, null);
- Assert.assertNotNull(response);
- Assert.assertTrue("Support is null, should success: " + query, response.isSuccess());
-// Assert.assertEquals(1, response.getTotalResults());
-
- query = TEST_TIME_SERIES_API_SERVICE +"[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@c...@datacenter>{max(field1),min(field1),avg(field1),sum(field1),count}.{count desc}";
- response = resource.listQuery(query, start, end, 100000, null, false, false, 1, 0, false, 0, null);
- Assert.assertNotNull(response);
- Assert.assertTrue("Support is null, should success: " + query, response.isSuccess());
-// Assert.assertEquals(1, response.getTotalResults());
-
-// ArrayList<Map.Entry<List<String>,List<Double>>> obj = (ArrayList<Map.Entry<List<String>,List<Double>>>) response.getObj();
-// Assert.assertEquals(1,obj.size());
-// Assert.assertEquals(2,obj.get(0).getKey().size());
-// Assert.assertEquals("test4UT",obj.get(0).getKey().get(0));
-// Assert.assertEquals("dc1",obj.get(0).getKey().get(1));
-// Assert.assertEquals(new Double(1.0),obj.get(0).getValue().get(0));
-// Assert.assertEquals(new Double(1.0),obj.get(0).getValue().get(1));
-// Assert.assertEquals(new Double(1.0), obj.get(0).getValue().get(2));
-// Assert.assertTrue(obj.get(0).getValue().get(3) > 1.0);
- }
-
- /**
- * TODO: Add time series aggregation query unit test
- */
- @Test
- public void testTimeSeriesAggregateQuery(){
- ListQueryResource resource = new ListQueryResource();
- ListQueryAPIResponseEntity response = null;
- String query = null;
- String start = DateTimeUtil.secondsToHumanDate(startTime / 1000);
- String end = DateTimeUtil.secondsToHumanDate((endTime + 1000) / 1000);
-
- query = TEST_TIME_SERIES_API_SERVICE +"[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{count}";
- response = resource.listQuery(query, start, end, 100000, null, false, true, 16, 0, false, 0, null);
- Assert.assertNotNull(response);
- Assert.assertTrue("Support is null, should success: "+query,response.isSuccess());
-
- query = TEST_TIME_SERIES_API_SERVICE +"[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{max(field1)}.{max(field1) desc}";
- response = resource.listQuery(query, start, end, 100000, null, false, true, 16, 0, false, 0, null);
- Assert.assertNotNull(response);
- Assert.assertTrue("Support is null, should success: "+query,response.isSuccess());
-
- query = TEST_TIME_SERIES_API_SERVICE +"[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{min(field1)}.{min(field1) desc}";
- response = resource.listQuery(query, start, end, 100000, null, false, true, 16, 0, false, 0, null);
- Assert.assertNotNull(response);
- Assert.assertTrue("Support is null, should success: "+query,response.isSuccess());
-
- query = TEST_TIME_SERIES_API_SERVICE +"[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{sum(field1)}.{sum(field1) desc}";
- response = resource.listQuery(query, start, end, 100000, null, false, true, 16, 0, false, 0, null);
- Assert.assertNotNull(response);
- Assert.assertTrue("Support is null, should success: "+query,response.isSuccess());
-
- query = TEST_TIME_SERIES_API_SERVICE +"[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{avg(field1)}.{avg(field1) asc}";
- response = resource.listQuery(query, start, end, 100000, null, false, true, 16, 0, false, 0, null);
- Assert.assertNotNull(response);
- Assert.assertTrue("Support is null, should success: "+query,response.isSuccess());
-
- query = TEST_TIME_SERIES_API_SERVICE +"[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@c...@datacenter>{max(field1),min(field1),avg(field1),sum(field1),count}.{max(field1) asc}";
- response = resource.listQuery(query, start, end, 100000, null, false, true, 16, 0, false, 0, null);
- Assert.assertNotNull(response);
- Assert.assertTrue("Support is null, should success: " + query, response.isSuccess());
-// Assert.assertEquals(1, response.getTotalResults());
-
- query = TEST_TIME_SERIES_API_SERVICE +"[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@c...@datacenter>{max(field1),min(field1),avg(field1),sum(field1),count}.{count desc}";
- response = resource.listQuery(query, start, end, 100000, null, false, true, 16, 1000, false, 0, null);
- Assert.assertNotNull(response);
- Assert.assertTrue("Support is null, should success: " + query, response.isSuccess());
-// Assert.assertEquals(1, response.getTotalResults());
- }
- /**
- * TODO: Add time series aggregation query unit test
- */
- @Test
- public void testTimeSeriesAggregateQueryWithoutCoprocessor(){
- ListQueryResource resource = new ListQueryResource();
- ListQueryAPIResponseEntity response = null;
- String query = null;
- String start = DateTimeUtil.secondsToHumanDate(startTime / 1000);
- String end = DateTimeUtil.secondsToHumanDate((endTime + 1000) / 1000);
-
- query = TEST_TIME_SERIES_API_SERVICE +"[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{count}";
- response = resource.listQuery(query, start, end, 100000, null, false, true, 10, 0, false, 0, null);
- Assert.assertNotNull(response);
- Assert.assertTrue("Support is null, should success: "+query,response.isSuccess());
-
- query = TEST_TIME_SERIES_API_SERVICE +"[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@cluster>{max(field1)}";
- response = resource.listQuery(query, start, end, 100000, null, false, true, 10, 0, false, 0, null);
- Assert.assertNotNull(response);
- Assert.assertTrue("Support is null, should success: "+query,response.isSuccess());
-
- query = TEST_TIME_SERIES_API_SERVICE +"[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@c...@datacenter>{max(field1),min(field1),avg(field1),sum(field1),count}";
- response = resource.listQuery(query, start, end, 100000, null, false, true, 10, 0, false, 0, null);
- Assert.assertNotNull(response);
- Assert.assertTrue("Support is null, should success: " + query, response.isSuccess());
-// Assert.assertEquals(1, response.getTotalResults());
-
- query = TEST_TIME_SERIES_API_SERVICE +"[@cluster=\"test4UT\" AND @datacenter=\"dc1\"]<@c...@datacenter>{max(field1),min(field1),avg(field1),sum(field1),count}.{max(field1) desc}";
- response = resource.listQueryWithoutCoprocessor(query, start, end, 100000, null, false, true, 10, 1000, false, 0, null,false);
- Assert.assertNotNull(response);
- Assert.assertTrue("Support is null, should success: " + query, response.isSuccess());
-// Assert.assertEquals(1, response.getTotalResults());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-query/eagle-storage-base/pom.xml
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-storage-base/pom.xml b/eagle-core/eagle-query/eagle-storage-base/pom.xml
deleted file mode 100644
index 12b9316..0000000
--- a/eagle-core/eagle-query/eagle-storage-base/pom.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?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.
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <parent>
- <artifactId>eagle-query-parent</artifactId>
- <groupId>eagle</groupId>
- <version>0.3.0</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>eagle-storage-base</artifactId>
-
- <dependencies>
- <dependency>
- <groupId>eagle</groupId>
- <artifactId>eagle-query-base</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/DataStorage.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/DataStorage.java b/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/DataStorage.java
deleted file mode 100644
index 4347401..0000000
--- a/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/DataStorage.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.eagle.storage;
-
-import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
-import org.apache.eagle.log.entity.meta.EntityDefinition;
-import org.apache.eagle.storage.exception.QueryCompileException;
-import org.apache.eagle.storage.operation.CompiledQuery;
-import org.apache.eagle.storage.result.ModifyResult;
-import org.apache.eagle.storage.result.QueryResult;
-import org.apache.eagle.storage.operation.RawQuery;
-
-import java.io.IOException;
-import java.util.List;
-
-/**
- * Eagle DataStorage Interface
- *
- * Interface description:
- * 1) TaggedLogAPIEntity (Why not InternalLog: it's deeply hbase specific and all values are converted to byte[] which is unnecessary for other database like mysql)
- * 2) EntityDefinition
- * 3) Assume all ID are in type of String like encoded rowkey to hbase and UUID for RDBMS
- *
- * @since 3/18/15
- */
-public interface DataStorage<I> {
-
- /**
- * Initialize when data storage is created
- *
- * @throws IOException
- */
- void init() throws IOException;
-
- /**
- * Execute update operation
- *
- * @throws IOException
- */
- <E extends TaggedLogAPIEntity> ModifyResult<I> update(List<E> entities, EntityDefinition entityDefinition) throws IOException;
-
- /**
- * Execute create operation
- *
- * @throws IOException
- */
- <E extends TaggedLogAPIEntity> ModifyResult<I> create(List<E> entities, EntityDefinition entityDefinition) throws IOException;
-
- /**
- * Execute delete operation by entities
- *
- * @param entities
- * @return
- * @throws IOException
- */
- <E extends TaggedLogAPIEntity> ModifyResult<I> delete(List<E> entities, EntityDefinition entityDefinition) throws IOException;
-
- /**
- * Execute delete operation by entity ids
- *
- * @throws IOException
- */
- ModifyResult<I> deleteByID(List<I> ids, EntityDefinition entityDefinition) throws IOException;
-
- /**
- * Execute delete operation
- *
- * @throws IOException
- */
- ModifyResult<I> delete(CompiledQuery query, EntityDefinition entityDefinition) throws IOException;
-
- /**
- * Execute query to return a list of results, may not always tagged entities
- *
- * @throws IOException
- */
- <E extends Object> QueryResult<E> query(CompiledQuery query, EntityDefinition entityDefinition) throws IOException;
-
- /**
- * Execute query to return a list of results
- * @param ids id set
- * @param entityDefinition entity definition
- * @param <E> result item type
- * @return QueryResult object
- * @throws IOException
- */
- <E extends Object> QueryResult<E> queryById(List<I> ids, EntityDefinition entityDefinition) throws IOException;
-
- /**
- * close data storage
- *
- * @throws IOException
- */
- void close() throws IOException;
-
- CompiledQuery compile(RawQuery query) throws QueryCompileException;
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/DataStorageBase.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/DataStorageBase.java b/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/DataStorageBase.java
deleted file mode 100644
index 29608b3..0000000
--- a/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/DataStorageBase.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.eagle.storage;
-
-import org.apache.eagle.storage.exception.QueryCompileException;
-import org.apache.eagle.storage.operation.CompiledQuery;
-import org.apache.eagle.storage.operation.RawQuery;
-
-/**
- * @since 3/23/15
- */
-public abstract class DataStorageBase implements DataStorage<String> {
- @Override
- public CompiledQuery compile(RawQuery query) throws QueryCompileException {
- return new CompiledQuery(query);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/DataStorageManager.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/DataStorageManager.java b/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/DataStorageManager.java
deleted file mode 100644
index 23fafeb..0000000
--- a/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/DataStorageManager.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.eagle.storage;
-
-import org.apache.eagle.common.config.EagleConfigFactory;
-import org.apache.eagle.storage.spi.DataStorageServiceLoader;
-import org.apache.eagle.storage.exception.IllegalDataStorageTypeException;
-import org.apache.eagle.storage.spi.DataStorageServiceProvider;
-import org.apache.commons.configuration.Configuration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.util.Properties;
-
-/**
- * @since 3/20/15
- */
-public class DataStorageManager {
- public final static String EAGLE_STORAGE_TYPE = "eagle.service.storage-type";
- public final static String DEFAULT_DATA_STORAGE_TYPE = "hbase";
-
- private final static Logger LOG = LoggerFactory.getLogger(DataStorageManager.class);
-
- /**
- * Get data storage without cache
- *
- * @param type
- * @throws IllegalDataStorageTypeException
- */
- public static DataStorage newDataStorage(String type) throws IllegalDataStorageTypeException {
- DataStorageServiceProvider serviceProvider = DataStorageServiceLoader.getInstance().getStorageProviderByType(type);
- if(serviceProvider == null){
- throw new IllegalDataStorageTypeException("data storage provider of type: "+type+" is null");
- }
- DataStorage dataStorage = serviceProvider.getStorage();
- try {
- LOG.info("Initializing data storage engine: "+dataStorage);
- dataStorage.init();
- } catch (IOException e) {
- LOG.error("Failed to initialize data storage engine "+dataStorage,e);
- throw new IllegalStateException(e);
- }
- return dataStorage;
- }
-
- private static DataStorage singletonStorageInstance;
- /**
- * get storage class by type configured as eagle.storage.type from eagle configuration: config.properties
- *
- * @return DataStorage instance
- *
- * @throws IllegalDataStorageTypeException
- */
- public static DataStorage getDataStorageByEagleConfig(boolean cache) throws IllegalDataStorageTypeException{
- String storageType = EagleConfigFactory.load().getStorageType();
-
- if(!cache)
- return newDataStorage(storageType);
-
- if(singletonStorageInstance == null) {
- if (storageType == null) {
- LOG.error(EAGLE_STORAGE_TYPE + " is null, trying default data storage: " + DEFAULT_DATA_STORAGE_TYPE);
- storageType = DEFAULT_DATA_STORAGE_TYPE;
- }
- singletonStorageInstance = newDataStorage(storageType);
- }
- return singletonStorageInstance;
- }
-
- /**
- * @return DataStorage instance by singleton pattern
- *
- * @throws IllegalDataStorageTypeException
- */
- public static DataStorage getDataStorageByEagleConfig() throws IllegalDataStorageTypeException{
- return getDataStorageByEagleConfig(true);
- }
-
- /**
- * Get data storage by configuration
- *
- * @param configuration
- * @return
- * @throws IllegalDataStorageTypeException
- */
- public static DataStorage newDataStorage(Configuration configuration) throws IllegalDataStorageTypeException {
- String storageType = configuration.getString(EAGLE_STORAGE_TYPE);
- if(storageType == null){
- throw new IllegalDataStorageTypeException(EAGLE_STORAGE_TYPE+" is null");
- }
- return newDataStorage(storageType);
- }
-
- /**
- * Get data storage by properties
- *
- * @param properties
- * @return
- * @throws IllegalDataStorageTypeException
- */
- public static DataStorage newDataStorage(Properties properties) throws IllegalDataStorageTypeException {
- String storageType = (String) properties.get(EAGLE_STORAGE_TYPE);
- if(storageType == null){
- LOG.error(EAGLE_STORAGE_TYPE+" is null");
- throw new IllegalDataStorageTypeException(EAGLE_STORAGE_TYPE+" is null");
- }
- return newDataStorage(storageType);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/exception/IllegalDataStorageException.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/exception/IllegalDataStorageException.java b/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/exception/IllegalDataStorageException.java
deleted file mode 100644
index ddd520d..0000000
--- a/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/exception/IllegalDataStorageException.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.eagle.storage.exception;
-
-/**
- * @since 3/20/15
- */
-public class IllegalDataStorageException extends Exception{
- public IllegalDataStorageException() {
- super();
- }
-
- public IllegalDataStorageException(String s) {
- super(s);
- }
-
- public IllegalDataStorageException(String s, Throwable throwable) {
- super(s, throwable);
- }
-
- public IllegalDataStorageException(Throwable throwable) {
- super(throwable);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/exception/IllegalDataStorageTypeException.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/exception/IllegalDataStorageTypeException.java b/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/exception/IllegalDataStorageTypeException.java
deleted file mode 100644
index e0b99d9..0000000
--- a/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/exception/IllegalDataStorageTypeException.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.eagle.storage.exception;
-
-/**
- * @since 3/20/15
- */
-public class IllegalDataStorageTypeException extends Exception{
- public IllegalDataStorageTypeException() {
- super();
- }
-
- public IllegalDataStorageTypeException(String s, Throwable throwable) {
- super(s, throwable);
- }
-
- public IllegalDataStorageTypeException(Throwable throwable) {
- super(throwable);
- }
-
- public IllegalDataStorageTypeException(String s) {
- super(s);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/exception/QueryCompileException.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/exception/QueryCompileException.java b/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/exception/QueryCompileException.java
deleted file mode 100644
index 664e079..0000000
--- a/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/exception/QueryCompileException.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.eagle.storage.exception;
-
-/**
- * @since 3/23/15
- */
-public class QueryCompileException extends Exception {
- public QueryCompileException() {
- super();
- }
-
- public QueryCompileException(String s) {
- super(s);
- }
-
- public QueryCompileException(String s, Throwable throwable) {
- super(s, throwable);
- }
-
- public QueryCompileException(Throwable throwable) {
- super(throwable);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/operation/CompiledQuery.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/operation/CompiledQuery.java b/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/operation/CompiledQuery.java
deleted file mode 100644
index 8f822c8..0000000
--- a/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/operation/CompiledQuery.java
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.eagle.storage.operation;
-
-import org.apache.eagle.log.entity.GenericMetricEntity;
-import org.apache.eagle.log.entity.SearchCondition;
-import org.apache.eagle.log.entity.meta.EntityDefinition;
-import org.apache.eagle.log.entity.meta.EntityDefinitionManager;
-import org.apache.eagle.query.ListQueryCompiler;
-import org.apache.eagle.query.aggregate.timeseries.SortOption;
-import org.apache.eagle.query.aggregate.AggregateFunctionType;
-import org.apache.eagle.storage.exception.QueryCompileException;
-import org.apache.eagle.common.DateTimeUtil;
-import org.apache.commons.lang.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Set;
-
-/**
- * TODO: refactor to remove hbase related fields
- *
- * @since 3/23/15
- */
-public class CompiledQuery {
- private final static Logger LOG = LoggerFactory.getLogger(CompiledQuery.class);
-
- public boolean isHasAgg() {
- return hasAgg;
- }
-
- public void setHasAgg(boolean hasAgg) {
- this.hasAgg = hasAgg;
- }
-
- public List<AggregateFunctionType> getAggregateFunctionTypes() {
- return aggregateFunctionTypes;
- }
-
- public void setAggregateFunctionTypes(List<AggregateFunctionType> aggregateFunctionTypes) {
- this.aggregateFunctionTypes = aggregateFunctionTypes;
- }
-
- public List<SortOption> getSortOptions() {
- return sortOptions;
- }
-
- public void setSortOptions(List<SortOption> sortOptions) {
- this.sortOptions = sortOptions;
- }
-
- public List<AggregateFunctionType> getSortFunctions() {
- return sortFunctions;
- }
-
- public void setSortFunctions(List<AggregateFunctionType> sortFunctions) {
- this.sortFunctions = sortFunctions;
- }
-
- public List<String> getSortFields() {
- return sortFields;
- }
-
- public void setSortFields(List<String> sortFields) {
- this.sortFields = sortFields;
- }
-
- public static Logger getLog() {
-
- return LOG;
- }
-
- public String getServiceName() {
- return serviceName;
- }
-
- public void setServiceName(String serviceName) {
- this.serviceName = serviceName;
- }
-
- public SearchCondition getSearchCondition() {
- return searchCondition;
- }
-
- public void setSearchCondition(SearchCondition searchCondition) {
- this.searchCondition = searchCondition;
- }
-
- public RawQuery getRawQuery() {
- return rawQuery;
- }
-
- private String serviceName;
- private SearchCondition searchCondition;
- private final RawQuery rawQuery;
- private boolean hasAgg;
- private List<AggregateFunctionType> aggregateFunctionTypes;
- private List<SortOption> sortOptions;
- private List<AggregateFunctionType> sortFunctions;
- private List<String> sortFields;
- private List<String> groupByFields;
-
- private long startTime;
-
- public long getEndTime() {
- return endTime;
- }
-
- public void setEndTime(long endTime) {
- this.endTime = endTime;
- }
-
- public long getStartTime() {
- return startTime;
- }
-
- public void setStartTime(long startTime) {
- this.startTime = startTime;
- }
-
- private long endTime;
-
- public List<String> getAggregateFields() {
- return aggregateFields;
- }
-
- public void setAggregateFields(List<String> aggregateFields) {
- this.aggregateFields = aggregateFields;
- }
-
- private List<String> aggregateFields;
-
- public CompiledQuery(RawQuery rawQueryCondition) throws QueryCompileException {
- this.rawQuery = rawQueryCondition;
- try {
- this.compile();
- } catch (Exception e) {
- throw new QueryCompileException(e);
- }
- }
-
- public List<String> getGroupByFields() {
- return groupByFields;
- }
-
- public void setGroupByFields(List<String> groupByFields) {
- this.groupByFields = groupByFields;
- }
-
- private void validateQueryParameters(String startRowkey, int pageSize){
- if(pageSize < 0){
- throw new IllegalArgumentException("Positive pageSize value should be always provided. The list query format is:\n" + "eagle-service/rest/list?query=<querystring>&pageSize=10&startRowkey=xyz&startTime=xxx&endTime=xxx");
- }
-
- if(startRowkey != null && startRowkey.equals("null")){
- LOG.warn("startRowkey being null string is not same to startRowkey == null");
- }
- return;
- }
-
- private void checkNotNull(Object obj,String name){
- if(obj == null) throw new IllegalArgumentException(name+" should not be null");
- }
-
- protected void compile() throws Exception {
- validateQueryParameters(this.getRawQuery().getStartRowkey(),this.getRawQuery().getPageSize());
- checkNotNull(this.rawQuery,"rawQuery instance");
- checkNotNull(this.rawQuery.getQuery(),"query");
-
- ListQueryCompiler compiler = new ListQueryCompiler(this.rawQuery.getQuery(),this.rawQuery.isFilterIfMissing());
- this.serviceName = compiler.serviceName();
- this.searchCondition = new SearchCondition();
- this.searchCondition.setOutputVerbose(this.rawQuery.isVerbose() );
- this.searchCondition.setOutputAlias(compiler.getOutputAlias());
- this.searchCondition.setFilter(compiler.filter());
- this.searchCondition.setQueryExpression(compiler.getQueryExpression());
- if(compiler.sortOptions() == null && this.rawQuery.getTop() > 0) {
- LOG.warn("Parameter \"top\" is only used for sort query! Ignore top parameter this time since it's not a sort query");
- }
-
- this.hasAgg = compiler.hasAgg();
- this.aggregateFunctionTypes = compiler.aggregateFunctionTypes();
- this.sortOptions = compiler.sortOptions();
- this.sortFields = compiler.sortFields();
- this.sortFunctions = compiler.sortFunctions();
- this.groupByFields = compiler.groupbyFields();
- this.aggregateFields = compiler.aggregateFields();
-
- final List<String[]> partitionValues = compiler.getQueryPartitionValues();
- if (partitionValues != null) {
- this.searchCondition.setPartitionValues(Arrays.asList(partitionValues.get(0)));
- }
-
- // 3. Set time range if it's timeseries service
- EntityDefinition ed = EntityDefinitionManager.getEntityByServiceName(serviceName);
- if(ed.isTimeSeries()){
- // TODO check Time exists for timeseries or topology data
- this.searchCondition.setStartTime(this.rawQuery.getStartTime());
- this.searchCondition.setEndTime(this.rawQuery.getEndTime());
- this.setStartTime(DateTimeUtil.humanDateToSeconds(this.getRawQuery().getStartTime()) * 1000);
- this.setEndTime(DateTimeUtil.humanDateToSeconds(this.getRawQuery().getEndTime()) * 1000);
- }
-
- // 4. Set HBase start scanning rowkey if given
- searchCondition.setStartRowkey(this.rawQuery.getStartRowkey());
-
- // 5. Set page size
- searchCondition.setPageSize(this.rawQuery.getPageSize());
-
- // 6. Generate output,group-by,aggregated fields
- List<String> outputFields = compiler.outputFields();
- List<String> groupbyFields = compiler.groupbyFields();
- List<String> aggregateFields = compiler.aggregateFields();
- Set<String> filterFields = compiler.getFilterFields();
-
- // Start to generate output fields list {
- searchCondition.setOutputAll(compiler.isOutputAll());
- if(outputFields == null) outputFields = new ArrayList<String>();
- if(compiler.hasAgg()){
- if(groupbyFields != null) outputFields.addAll(groupbyFields);
- if(aggregateFields != null) outputFields.addAll(aggregateFields);
- if(GenericMetricEntity.GENERIC_METRIC_SERVICE.equals(serviceName) && !outputFields.contains(GenericMetricEntity.VALUE_FIELD)){
- outputFields.add(GenericMetricEntity.VALUE_FIELD);
- }
- }
- if(filterFields!=null) outputFields.addAll(filterFields);
- searchCondition.setOutputFields(outputFields);
- if(LOG.isDebugEnabled()) {
- if (compiler.isOutputAll()) {
- LOG.debug("Output fields: all");
- } else {
- LOG.debug("Output fields: " + StringUtils.join(outputFields, ","));
- }
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/operation/CreateStatement.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/operation/CreateStatement.java b/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/operation/CreateStatement.java
deleted file mode 100644
index 80256e1..0000000
--- a/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/operation/CreateStatement.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.eagle.storage.operation;
-
-import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
-import org.apache.eagle.log.entity.meta.EntityDefinition;
-import org.apache.eagle.log.entity.meta.EntityDefinitionManager;
-import org.apache.eagle.storage.DataStorage;
-import org.apache.eagle.storage.result.ModifyResult;
-
-import java.io.IOException;
-import java.util.List;
-
-/**
- * @since 3/18/15
- */
-public class CreateStatement implements Statement<ModifyResult<String>> {
- private final List<? extends TaggedLogAPIEntity> entities;
- private final EntityDefinition entityDefinition;
-
- public CreateStatement(List<? extends TaggedLogAPIEntity> entities,String serviceName){
- this.entities = entities;
-
- try {
- this.entityDefinition = EntityDefinitionManager.getEntityByServiceName(serviceName);
- } catch (InstantiationException e) {
- throw new IllegalArgumentException(e);
- } catch (IllegalAccessException e) {
- throw new IllegalArgumentException(e);
- }
- }
-
- public CreateStatement(List<? extends TaggedLogAPIEntity> entities,EntityDefinition entityDefinition){
- this.entities = entities;
- this.entityDefinition = entityDefinition;
- }
-
- private void checkNotNull(Object obj,String fieldName){
- if(obj == null){
- throw new IllegalArgumentException(fieldName+" is null");
- }
- }
-
- @Override
- public ModifyResult<String> execute(DataStorage dataStorage) throws IOException {
- try {
- checkNotNull(this.entities,"entities");
- checkNotNull(this.entityDefinition,"entity definition");
- return dataStorage.create(entities, this.entityDefinition);
- } catch (IOException e) {
- throw e;
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/operation/DeleteStatement.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/operation/DeleteStatement.java b/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/operation/DeleteStatement.java
deleted file mode 100644
index 37f5397..0000000
--- a/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/operation/DeleteStatement.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.eagle.storage.operation;
-
-import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
-import org.apache.eagle.log.entity.meta.EntityDefinition;
-import org.apache.eagle.log.entity.meta.EntityDefinitionManager;
-import org.apache.eagle.storage.DataStorage;
-import org.apache.eagle.storage.exception.QueryCompileException;
-import org.apache.eagle.storage.result.ModifyResult;
-
-import java.io.IOException;
-import java.util.List;
-
-/**
- * @since 3/18/15
- */
-public class DeleteStatement implements Statement<ModifyResult<String>> {
- private List<? extends TaggedLogAPIEntity> entities;
- private List ids = null;
- private RawQuery query;
-
- private EntityDefinition entityDefinition;
-
- public DeleteStatement(String serviceName){
- try {
- this.entityDefinition = EntityDefinitionManager.getEntityByServiceName(serviceName);
- } catch (InstantiationException e) {
- throw new IllegalArgumentException(e);
- } catch (IllegalAccessException e) {
- throw new IllegalArgumentException(e);
- }
- }
-
- public DeleteStatement(Class<? extends TaggedLogAPIEntity> entityClass){
- try {
- this.entityDefinition = EntityDefinitionManager.getEntityDefinitionByEntityClass(entityClass);
- } catch (InstantiationException e) {
- throw new IllegalArgumentException(e);
- } catch (IllegalAccessException e) {
- throw new IllegalArgumentException(e);
- }
- }
-
- public DeleteStatement(RawQuery query){
- this.query = query;
- }
-
- public void setIds(List ids){
- this.ids = ids;
- }
-
- public void setEntities(List<? extends TaggedLogAPIEntity> entities){
- this.entities = entities;
- }
-
-// public void setQuery(RawQuery query){
-// this.query = query;
-// }
-
- @SuppressWarnings("unchecked")
- @Override
- public ModifyResult<String> execute(DataStorage storage) throws IOException{
- ModifyResult result;
- try {
- if(this.ids !=null){
- result = storage.deleteByID(this.ids,this.entityDefinition);
- }else if(this.entities != null){
- result =storage.delete(this.entities, this.entityDefinition);
- }else if(this.query != null){
- CompiledQuery compiledQuery = storage.compile(this.query);
- this.entityDefinition = EntityDefinitionManager.getEntityByServiceName(compiledQuery.getServiceName());
- result = storage.delete(compiledQuery,this.entityDefinition);
- }else{
- throw new IllegalStateException("bad delete statement, not given enough parameters");
- }
- } catch (QueryCompileException e) {
- throw new IOException(e);
- }catch (Exception ex){
- throw new IOException(ex);
- }
- return result;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/operation/QueryStatement.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/operation/QueryStatement.java b/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/operation/QueryStatement.java
deleted file mode 100644
index ca40961..0000000
--- a/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/operation/QueryStatement.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.eagle.storage.operation;
-
-import org.apache.eagle.log.entity.meta.EntityDefinition;
-import org.apache.eagle.log.entity.meta.EntityDefinitionManager;
-import org.apache.eagle.storage.DataStorage;
-import org.apache.eagle.storage.exception.QueryCompileException;
-import org.apache.eagle.storage.result.QueryResult;
-
-import java.io.IOException;
-
-/**
- * @since 3/18/15
- */
-public class QueryStatement implements Statement<QueryResult<?>>{
- private final RawQuery query;
-
- public QueryStatement(RawQuery queryCondition){
- this.query = queryCondition;
- }
-
- @Override
- public QueryResult<?> execute(DataStorage dataStorage) throws IOException {
- CompiledQuery compiledQuery;
- try {
- compiledQuery = dataStorage.compile(this.query);
- } catch (QueryCompileException e) {
- throw new IOException(e);
- }
- try {
- EntityDefinition entityDefinition = EntityDefinitionManager.getEntityByServiceName(compiledQuery.getServiceName());
- return dataStorage.query(compiledQuery, entityDefinition);
- } catch (InstantiationException | IllegalAccessException e) {
- throw new IOException(e);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/operation/RawQuery.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/operation/RawQuery.java b/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/operation/RawQuery.java
deleted file mode 100755
index 21d7c2f..0000000
--- a/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/operation/RawQuery.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.eagle.storage.operation;
-
-import org.codehaus.jackson.map.ObjectMapper;
-
-import java.io.IOException;
-
-/**
- */
-public class RawQuery {
- private String query;
- private String startTime;
- private String endTime;
- private int pageSize;
- private String startRowkey;
- private boolean treeAgg;
- private boolean timeSeries;
- private long intervalmin;
- private int top;
- private boolean filterIfMissing;
- private String metricName;
- private boolean verbose;
-
- public int getParallel() {
- return parallel;
- }
-
- public void setParallel(int parallel) {
- this.parallel = parallel;
- }
-
- private int parallel;
-
- public boolean isVerbose() {
- return verbose;
- }
-
- public void setVerbose(boolean verbose) {
- this.verbose = verbose;
- }
-
- public String getQuery() {
- return query;
- }
-
- public void setQuery(String query) {
- this.query = query;
- }
-
- public String getStartTime() {
- return startTime;
- }
-
- public void setStartTime(String startTime) {
- this.startTime = startTime;
- }
-
- public String getEndTime() {
- return endTime;
- }
-
- public void setEndTime(String endTime) {
- this.endTime = endTime;
- }
-
- public int getPageSize() {
- return pageSize;
- }
-
- public void setPageSize(int pageSize) {
- this.pageSize = pageSize;
- }
-
- public String getStartRowkey() {
- return startRowkey;
- }
-
- public void setStartRowkey(String startRowkey) {
- this.startRowkey = startRowkey;
- }
-
- public boolean isTreeAgg() {
- return treeAgg;
- }
-
- public void setTreeAgg(boolean treeAgg) {
- this.treeAgg = treeAgg;
- }
-
- public boolean isTimeSeries() {
- return timeSeries;
- }
-
- public void setTimeSeries(boolean timeSeries) {
- this.timeSeries = timeSeries;
- }
-
- public long getIntervalmin() {
- return intervalmin;
- }
-
- public void setIntervalmin(long intervalmin) {
- this.intervalmin = intervalmin;
- }
-
- public int getTop() {
- return top;
- }
-
- public void setTop(int top) {
- this.top = top;
- }
-
- public boolean isFilterIfMissing() {
- return filterIfMissing;
- }
-
- public void setFilterIfMissing(boolean filterIfMissing) {
- this.filterIfMissing = filterIfMissing;
- }
-
- public String getMetricName() {
- return metricName;
- }
-
- public void setMetricName(String metricName) {
- this.metricName = metricName;
- }
-
- public static Builder build(){
- return new Builder();
- }
- public static class Builder{
- private final RawQuery rawQuery;
- public Builder(){
- this.rawQuery= new RawQuery();
- }
- public RawQuery done(){
- return this.rawQuery;
- }
- public Builder query(String query) {
- this.rawQuery.setQuery(query);
- return this;
- }
-
- public Builder startTime(String startTime) {
- this.rawQuery.setStartTime(startTime);
- return this;
- }
-
- public Builder endTime(String endTime) {
- this.rawQuery.setEndTime(endTime);
- return this;
- }
-
- public Builder pageSize(int pageSize) {
- this.rawQuery.setPageSize(pageSize);
- return this;
- }
-
- public Builder startRowkey(String startRowkey) {
- this.rawQuery.setStartRowkey(startRowkey);
- return this;
- }
-
- public Builder treeAgg(boolean treeAgg) {
- this.rawQuery.setTreeAgg(treeAgg);
- return this;
- }
-
- public Builder timeSeries(boolean timeSeries) {
- this.rawQuery.setTimeSeries(timeSeries);
- return this;
- }
-
- public Builder intervalMin(long intervalmin) {
- this.rawQuery.setIntervalmin(intervalmin);
- return this;
- }
-
- public Builder top(int top) {
- this.rawQuery.setTop(top);
- return this;
- }
-
- public Builder filerIfMissing(boolean filterIfMissing) {
- this.rawQuery.setFilterIfMissing(filterIfMissing);
- return this;
- }
-
- public Builder parallel(int parallel) {
- this.rawQuery.setParallel(parallel);
- return this;
- }
-
- public Builder metricName(String metricName) {
- this.rawQuery.setMetricName(metricName);
- return this;
- }
-
- public Builder verbose(Boolean verbose) {
- if(verbose == null) verbose = true;
- this.rawQuery.setVerbose(verbose);
- return this;
- }
- }
-
- @Override
- public String toString() {
- ObjectMapper objectMapper = new ObjectMapper();
- try {
- return objectMapper.writeValueAsString(this);
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/operation/RowkeyQueryStatement.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/operation/RowkeyQueryStatement.java b/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/operation/RowkeyQueryStatement.java
deleted file mode 100644
index 017224c..0000000
--- a/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/operation/RowkeyQueryStatement.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.eagle.storage.operation;
-
-import org.apache.eagle.log.entity.meta.EntityDefinition;
-import org.apache.eagle.log.entity.meta.EntityDefinitionManager;
-import org.apache.eagle.storage.DataStorage;
-import org.apache.eagle.storage.result.QueryResult;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @since 6/29/15
- */
-public class RowkeyQueryStatement implements Statement<QueryResult<?>>{
- private final List<String> rowkeys;
- private final EntityDefinition entityDefinition;
-
- public RowkeyQueryStatement(String rowkey,EntityDefinition entityDefinition) {
- this.rowkeys = new ArrayList<>(1);
- this.rowkeys.add(rowkey);
- this.entityDefinition = entityDefinition;
- }
-
- public RowkeyQueryStatement(String rowkey,String serviceName) throws IllegalAccessException, InstantiationException {
- this.rowkeys = new ArrayList<>(1);
- this.rowkeys.add(rowkey);
- this.entityDefinition = EntityDefinitionManager.getEntityByServiceName(serviceName);
- }
-
- public RowkeyQueryStatement(List<String> rowkeys,EntityDefinition entityDefinition) {
- this.rowkeys = rowkeys;
- this.entityDefinition = entityDefinition;
- }
-
- public RowkeyQueryStatement(List<String> rowkeys,String serviceName) throws IllegalAccessException, InstantiationException {
- this.rowkeys = rowkeys;
- this.entityDefinition = EntityDefinitionManager.getEntityByServiceName(serviceName);
- }
-
- @Override
- public <I> QueryResult<?> execute(DataStorage<I> dataStorage) throws IOException {
- return dataStorage.queryById((List<I>) this.rowkeys,this.entityDefinition);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/operation/Statement.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/operation/Statement.java b/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/operation/Statement.java
deleted file mode 100644
index 29bda96..0000000
--- a/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/operation/Statement.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.eagle.storage.operation;
-
-import org.apache.eagle.storage.DataStorage;
-import org.apache.eagle.storage.result.Result;
-
-import java.io.IOException;
-
-/**
- * Fluent API Wrapper statements
- *
- * @since 3/18/15
- */
-public interface Statement<R extends Result> {
- /**
- * Submit and execute statment
- */
- <I> R execute(DataStorage<I> dataStorage) throws IOException;
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/0ea130ef/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/operation/UpdateStatement.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/operation/UpdateStatement.java b/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/operation/UpdateStatement.java
deleted file mode 100644
index 1c59e0b..0000000
--- a/eagle-core/eagle-query/eagle-storage-base/src/main/java/org/apache/eagle/storage/operation/UpdateStatement.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.eagle.storage.operation;
-
-import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
-import org.apache.eagle.log.entity.meta.EntityDefinition;
-import org.apache.eagle.log.entity.meta.EntityDefinitionManager;
-import org.apache.eagle.storage.DataStorage;
-import org.apache.eagle.storage.result.ModifyResult;
-
-import java.io.IOException;
-import java.util.List;
-
-/**
- * @since 3/18/15
- */
-public class UpdateStatement implements Statement<ModifyResult<String>> {
- private final List<? extends TaggedLogAPIEntity> entities;
-
- private final EntityDefinition entityDefinition;
-
- public UpdateStatement(List<? extends TaggedLogAPIEntity> entities,String serviceName){
- this.entities = entities;
- try {
- this.entityDefinition = EntityDefinitionManager.getEntityByServiceName(serviceName);
- } catch (InstantiationException e) {
- throw new IllegalArgumentException(e);
- } catch (IllegalAccessException e) {
- throw new IllegalArgumentException(e);
- }
- }
-
- public UpdateStatement(List<? extends TaggedLogAPIEntity> entities,EntityDefinition entityDefinition){
- this.entities = entities;
- this.entityDefinition = entityDefinition;
- }
-
- @Override
- public ModifyResult<String> execute(DataStorage storage) throws IOException {
- return storage.update(entities,this.entityDefinition);
- }
-}
\ No newline at end of file