eagle-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h..@apache.org
Subject [27/55] [abbrv] [partial] incubator-eagle git commit: [EAGLE-46] Rename package name as "org.apache.eagle"
Date Thu, 19 Nov 2015 10:47:34 GMT
http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/TimeSeriesGroupByAPIResponseEntity.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/TimeSeriesGroupByAPIResponseEntity.java b/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/TimeSeriesGroupByAPIResponseEntity.java
new file mode 100644
index 0000000..e1d6618
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/TimeSeriesGroupByAPIResponseEntity.java
@@ -0,0 +1,101 @@
+/*
+ * 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.client;
+
+import java.util.List;
+import java.util.Map;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+//@JsonPropertyOrder({ "success", "exception", "elapsems", "totalResults", "elapsedms", "obj", "lastTimestamp" })
+@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class TimeSeriesGroupByAPIResponseEntity {
+	private boolean success;
+	private String exception;
+	private int totalResults;
+	private long elapsedms;
+	private List<Entry> obj;
+	private long lastTimestamp;
+
+	public long getElapsedms() {
+		return elapsedms;
+	}
+	public void setElapsedms(long elapsedms) {
+		this.elapsedms = elapsedms;
+	}
+	
+	public boolean isSuccess() {
+		return success;
+	}
+	public void setSuccess(boolean success) {
+		this.success = success;
+	}
+	public String getException() {
+		return exception;
+	}
+	public void setException(String exception) {
+		this.exception = exception;
+	}
+	public int getTotalResults() {
+		return totalResults;
+	}
+	public void setTotalResults(int totalResults) {
+		this.totalResults = totalResults;
+	}
+	public List<Entry> getObj() {
+		return obj;
+	}
+	public void setObj(List<Entry> obj) {
+		this.obj = obj;
+	}
+	
+	public long getLastTimestamp() {
+		return lastTimestamp;
+	}
+	public void setLastTimestamp(long lastTimestamp) {
+		this.lastTimestamp = lastTimestamp;
+	}
+
+	public static class Entry implements Map.Entry<List<String>, List<Double[]>> {
+
+		private List<String> key;
+		private List<Double[]> value;
+		public List<String> getKey() {
+			return key;
+		}
+		public void setKey(List<String> key) {
+			this.key = key;
+		}
+
+		@Override
+		public List<Double[]> getValue() {
+			return value;
+		}
+
+		@Override
+		public List<Double[]> setValue(List<Double[]> value) {
+			List<Double[]> old = this.value;
+			this.value = value;
+			return old;
+		}
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/impl/BatchSender.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/impl/BatchSender.java b/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/impl/BatchSender.java
new file mode 100644
index 0000000..ba3e6ab
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/impl/BatchSender.java
@@ -0,0 +1,93 @@
+/*
+ * 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.client.impl;
+
+import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
+import org.apache.eagle.log.entity.GenericServiceAPIResponseEntity;
+import org.apache.eagle.service.client.IEagleServiceClient;
+import org.apache.eagle.service.client.EagleServiceClientException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.LinkedList;
+import java.util.List;
+
+public class BatchSender implements Closeable {
+    private final static Logger LOG = LoggerFactory.getLogger(BatchSender.class);
+    private final List<TaggedLogAPIEntity> entityBucket;
+    private final IEagleServiceClient client;
+
+    protected int getBatchSize() {
+        return batchSize;
+    }
+
+    protected void setBatchSize(int batchSize) {
+        if(batchSize<0) throw new IllegalArgumentException("batch size should be "+batchSize);
+        this.batchSize = batchSize;
+    }
+
+    private int batchSize;
+
+    public BatchSender(IEagleServiceClient client, int batchSize){
+        this.setBatchSize(batchSize);
+        this.client = client;
+        this.entityBucket = new LinkedList<TaggedLogAPIEntity>();
+    }
+
+    public BatchSender send(TaggedLogAPIEntity entity) throws IOException, EagleServiceClientException {
+        this.entityBucket.add(entity);
+        if(this.entityBucket.size()>=this.batchSize){
+            flush();
+        }
+        return this;
+    }
+
+    public BatchSender send(List<TaggedLogAPIEntity> entities) throws IOException, EagleServiceClientException {
+        this.entityBucket.addAll(entities);
+        if(this.entityBucket.size()>= this.batchSize){
+            flush();
+        }
+        return this;
+    }
+
+    public void flush() throws IOException, EagleServiceClientException {
+        if(this.entityBucket.size() == 0 && LOG.isDebugEnabled()){
+            LOG.debug("No entities to flush");
+            return;
+        }
+
+        LOG.info("Writing "+this.entityBucket.size()+" entities");
+        GenericServiceAPIResponseEntity<String> response = this.client.create(this.entityBucket);
+        if(!response.isSuccess()){
+            LOG.error("Got service exception: "+response.getException());
+            throw new IOException("Service exception"+response.getException());
+        }else{
+            this.entityBucket.clear();
+        }
+    }
+
+    @Override
+    public void close() throws IOException {
+        try {
+            flush();
+        } catch (EagleServiceClientException e) {
+            throw new IOException(e);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/impl/ConcurrentSender.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/impl/ConcurrentSender.java b/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/impl/ConcurrentSender.java
new file mode 100644
index 0000000..0c2aad0
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/impl/ConcurrentSender.java
@@ -0,0 +1,170 @@
+/*
+ * 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.client.impl;
+
+import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
+import org.apache.eagle.service.client.EagleServiceClientException;
+import org.apache.eagle.service.client.IEagleServiceClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.SynchronousQueue;
+
+public class ConcurrentSender implements Closeable{
+    private final int parallelNum;
+    private final IEagleServiceClient client;
+    private final SynchronousQueue<TaggedLogAPIEntity> queue;
+    private final List<Handler> handlers;
+    private int batchSize = 1000;
+    private long batchInterval = 3 * 1000;
+    private boolean isStarted = false;
+
+    private final static Logger LOG = LoggerFactory.getLogger(ConcurrentSender.class);
+
+    public ConcurrentSender(IEagleServiceClient client, int parallelNum) {
+        this.parallelNum = parallelNum;
+        this.client = client;
+        this.queue= new SynchronousQueue<TaggedLogAPIEntity>();
+        this.handlers = Collections.synchronizedList(new LinkedList<Handler>());
+    }
+
+    public void start(){
+        if(!this.isStarted) {
+            LOG.info("Starting with handlers = " + this.parallelNum + ", batchSize = " + this.batchSize + ", batchInterval (ms) = " + this.batchInterval);
+
+            for (int i = 0; i < this.parallelNum; i++) {
+                Handler handler = new Handler(this.queue, this.client, this.batchSize, this.batchInterval);
+
+                Thread thread = new Thread(handler);
+                thread.setDaemon(true);
+                thread.setName("Sender-" + i);
+                this.handlers.add(handler);
+                thread.start();
+            }
+
+            this.isStarted = true;
+        }else{
+            LOG.warn("Already started");
+        }
+    }
+
+    public ConcurrentSender batchSize(int batchSize){
+        this.batchSize = batchSize;
+        return this;
+    }
+
+    public ConcurrentSender batchInterval(long batchInterval){
+        this.batchInterval = batchInterval;
+        return this;
+    }
+
+    public ConcurrentSender send(final List<? extends TaggedLogAPIEntity> entities) throws InterruptedException {
+        for(TaggedLogAPIEntity entity:entities){
+            this.send(entity);
+        }
+        return this;
+    }
+
+    public ConcurrentSender send(final TaggedLogAPIEntity entity) throws InterruptedException {
+        if(!this.isStarted){
+            this.start();
+        }
+        this.queue.put(entity);
+        return this;
+    }
+
+    @Override
+    public void close() throws IOException {
+        for(Handler handler: handlers){
+            handler.close();
+        }
+    }
+
+    private class Handler extends BatchSender implements Runnable{
+        private final long batchInterval;
+        private final SynchronousQueue<TaggedLogAPIEntity> localQueue;
+
+        private boolean isStopped;
+        private long lastFlushTime;
+
+        public Handler(SynchronousQueue<TaggedLogAPIEntity> queue, IEagleServiceClient client, int batchSize, long batchInterval) {
+            super(client, batchSize);
+            this.localQueue = queue;
+            this.batchInterval = batchInterval;
+        }
+
+        @Override
+        public void run() {
+            if(LOG.isDebugEnabled()) LOG.debug("Starting ...");
+            lastFlushTime = System.currentTimeMillis();
+
+            while(!isStopped){
+                TaggedLogAPIEntity entity = null;
+                try {
+                    entity = this.localQueue.take();
+                } catch (InterruptedException e) {
+                    LOG.error(e.getMessage(),e);
+                }
+
+                if(entity!=null){
+                    try {
+                        this.send(entity);
+                    } catch (IOException e) {
+                        LOG.error(e.getMessage(),e);
+                    } catch (EagleServiceClientException e) {
+                        LOG.error(e.getMessage(),e);
+                    }
+                    long currentTimestamp = System.currentTimeMillis();
+
+                    if((currentTimestamp - this.lastFlushTime) >= this.batchInterval){
+                        if(LOG.isDebugEnabled())
+                            LOG.info(String.format("%s - %s >= %s",currentTimestamp,this.lastFlushTime,this.batchInterval));
+
+                        try {
+                            this.flush();
+                        } catch (IOException e) {
+                            LOG.error(e.getMessage(),e);
+                        } catch (EagleServiceClientException e) {
+                            LOG.error(e.getMessage(),e);
+                        }
+                    }
+                }else{
+                    LOG.warn("Got null entity");
+                }
+            }
+
+            if(LOG.isDebugEnabled()) LOG.debug("Stopping ...");
+        }
+
+        @Override
+        public void close() throws IOException {
+            this.isStopped = true;
+            super.close();
+        }
+
+        @Override
+        public void flush() throws IOException, EagleServiceClientException {
+            super.flush();
+            this.lastFlushTime = System.currentTimeMillis();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/impl/DeleteRequestBuilder.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/impl/DeleteRequestBuilder.java b/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/impl/DeleteRequestBuilder.java
new file mode 100644
index 0000000..ba708d6
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/impl/DeleteRequestBuilder.java
@@ -0,0 +1,137 @@
+/*
+ * 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.client.impl;
+
+import org.apache.eagle.log.entity.GenericServiceAPIResponseEntity;
+import org.apache.eagle.service.client.EagleServiceClientException;
+import org.apache.eagle.service.client.EagleServiceSingleEntityQueryRequest;
+import org.apache.eagle.service.client.IEagleServiceClient;
+import org.apache.eagle.common.DateTimeUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+import java.util.List;
+
+public class DeleteRequestBuilder {
+    private final IEagleServiceClient client;
+    private List<String> deleteIds = null;
+    private EagleServiceSingleEntityQueryRequest request;
+
+    private final static Logger LOG = LoggerFactory.getLogger(DeleteRequestBuilder.class);
+    private String serviceName;
+
+    public DeleteRequestBuilder(IEagleServiceClient client){
+        this.client = client;
+    }
+
+    public DeleteRequestBuilder byId(List<String> ids){
+        this.deleteIds = ids;
+        return this;
+    }
+
+    public DeleteRequestBuilder byQuery(String query){
+        if(this.request==null)  this.request = new EagleServiceSingleEntityQueryRequest();
+        try {
+            this.request.setQuery(URLEncoder.encode(query, "UTF-8"));
+        } catch (UnsupportedEncodingException e) {
+            LOG.error(e.getMessage(),e);
+        }
+        return this;
+    }
+
+    public DeleteRequestBuilder serviceName(String serviceName){
+        this.serviceName = serviceName;
+        return this;
+    }
+
+    public DeleteRequestBuilder startRowkey(String startRowkey){
+        if(this.request==null)  this.request = new EagleServiceSingleEntityQueryRequest();
+        this.request.setStartRowkey(startRowkey);
+        return this;
+    }
+
+    public DeleteRequestBuilder pageSize(int pageSize){
+        if(this.request==null)  this.request = new EagleServiceSingleEntityQueryRequest();
+        this.request.setPageSize(pageSize);
+        return this;
+    }
+
+    public DeleteRequestBuilder startTime(long startTime){
+        if(this.request==null)  this.request = new EagleServiceSingleEntityQueryRequest();
+        this.request.setStartTime(startTime);
+        return this;
+    }
+
+    public DeleteRequestBuilder startTime(String startTime){
+        if(this.request==null)  this.request = new EagleServiceSingleEntityQueryRequest();
+        this.request.setStartTime(DateTimeUtil.humanDateToMillisecondsWithoutException(startTime));
+        return this;
+    }
+
+    public DeleteRequestBuilder endTime(long endTime){
+        if(this.request==null)  this.request = new EagleServiceSingleEntityQueryRequest();
+        this.request.setEndTime(endTime);
+        return this;
+    }
+
+    public DeleteRequestBuilder endTime(String endTime){
+        if(this.request==null)  this.request = new EagleServiceSingleEntityQueryRequest();
+        this.request.setEndTime(DateTimeUtil.humanDateToMillisecondsWithoutException(endTime));
+        return this;
+    }
+
+    public DeleteRequestBuilder timeRange(String startTime,String endTime){
+        this.startTime(startTime);
+        this.endTime(endTime);
+        return this;
+    }
+
+    public DeleteRequestBuilder timeRange(long startTime,long endTime){
+        this.startTime(startTime);
+        this.endTime(endTime);
+        return this;
+    }
+
+    public DeleteRequestBuilder treeAgg(boolean treeAgg){
+        if(this.request==null)  this.request = new EagleServiceSingleEntityQueryRequest();
+        this.request.setTreeAgg(treeAgg);
+        return this;
+    }
+
+    public DeleteRequestBuilder metricName(String metricName){
+        if(this.request==null)  this.request = new EagleServiceSingleEntityQueryRequest();
+        this.request.setMetricName(metricName);
+        return this;
+    }
+
+    public DeleteRequestBuilder filterIfMissing(Boolean filterIfMissing){
+        if(this.request==null)  this.request = new EagleServiceSingleEntityQueryRequest();
+        this.request.setFilterIfMissing(filterIfMissing);
+        return this;
+    }
+
+    public GenericServiceAPIResponseEntity<String> send() throws EagleServiceClientException, IOException {
+        if(this.deleteIds!=null){
+            return client.deleteById(this.deleteIds,this.serviceName);
+        }else {
+            return client.delete(this.request);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/impl/EagleServiceAsyncClientImpl.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/impl/EagleServiceAsyncClientImpl.java b/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/impl/EagleServiceAsyncClientImpl.java
new file mode 100644
index 0000000..7bdfab8
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/impl/EagleServiceAsyncClientImpl.java
@@ -0,0 +1,156 @@
+/*
+ * 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.client.impl;
+
+import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
+import org.apache.eagle.log.entity.GenericServiceAPIResponseEntity;
+import org.apache.eagle.service.client.EagleServiceAsyncClient;
+import org.apache.eagle.service.client.IEagleServiceClient;
+import org.apache.eagle.service.client.EagleServiceClientException;
+import org.apache.eagle.service.client.EagleServiceSingleEntityQueryRequest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Future;
+
+public class EagleServiceAsyncClientImpl implements EagleServiceAsyncClient {
+    private final IEagleServiceClient client;
+    private final static Logger LOG = LoggerFactory.getLogger(EagleServiceAsyncClientImpl.class);
+
+    public EagleServiceAsyncClientImpl(IEagleServiceClient client) {
+        this.client = client;
+    }
+
+    @Override
+    public void close() throws IOException {
+        if(LOG.isDebugEnabled()) LOG.debug("Executor service is shutting down");
+        this.client.getJerseyClient().getExecutorService().shutdown();
+    }
+
+    @Override
+    public <E extends TaggedLogAPIEntity> Future<GenericServiceAPIResponseEntity<String>> create(final List<E> entities, final String serviceName) throws IOException, EagleServiceClientException {
+        return this.client.getJerseyClient().getExecutorService().submit(new Callable<GenericServiceAPIResponseEntity<String>>() {
+            @Override
+            public GenericServiceAPIResponseEntity<String> call() throws Exception {
+                return client.create(entities,serviceName);
+            }
+        });
+    }
+
+    @Override
+    public <E extends TaggedLogAPIEntity> Future<GenericServiceAPIResponseEntity<String>> create(final List<E> entities, final Class<E> entityClass) throws IOException, EagleServiceClientException {
+        return this.client.getJerseyClient().getExecutorService().submit(new Callable<GenericServiceAPIResponseEntity<String>>() {
+            @Override
+            public GenericServiceAPIResponseEntity<String> call() throws Exception {
+                return client.create(entities,entityClass);
+            }
+        });
+    }
+
+    @Override
+    public <E extends TaggedLogAPIEntity> Future<GenericServiceAPIResponseEntity<String>> create(final List<E> entities) throws IOException, EagleServiceClientException {
+        return this.client.getJerseyClient().getExecutorService().submit(new Callable<GenericServiceAPIResponseEntity<String>>() {
+            @Override
+            public GenericServiceAPIResponseEntity<String> call() throws Exception {
+                return client.create(entities);
+            }
+        });
+    }
+
+    @Override
+    public <E extends TaggedLogAPIEntity> Future<GenericServiceAPIResponseEntity<String>> delete(final List<E> entities) throws IOException, EagleServiceClientException {
+        return this.client.getJerseyClient().getExecutorService().submit(new Callable<GenericServiceAPIResponseEntity<String>>() {
+            @Override
+            public GenericServiceAPIResponseEntity<String> call() throws Exception {
+                return client.delete(entities);
+            }
+        });
+    }
+
+    @Override
+    public <E extends TaggedLogAPIEntity> Future<GenericServiceAPIResponseEntity<String>> delete(final List<E> entities, final String serviceName) throws IOException, EagleServiceClientException {
+        return this.client.getJerseyClient().getExecutorService().submit(new Callable<GenericServiceAPIResponseEntity<String>>() {
+            @Override
+            public GenericServiceAPIResponseEntity<String> call() throws Exception {
+                return client.delete(entities, serviceName);
+            }
+        });
+    }
+
+    @Override
+    public <E extends TaggedLogAPIEntity> Future<GenericServiceAPIResponseEntity<String>> delete(final List<E> entities, final Class<E> entityClass) throws IOException, EagleServiceClientException {
+        return this.client.getJerseyClient().getExecutorService().submit(new Callable<GenericServiceAPIResponseEntity<String>>() {
+            @Override
+            public GenericServiceAPIResponseEntity<String> call() throws Exception {
+                return client.create(entities,entityClass);
+            }
+        });
+    }
+
+    @Override
+    public Future<GenericServiceAPIResponseEntity<String>> delete(final EagleServiceSingleEntityQueryRequest request) throws EagleServiceClientException, IOException {
+        return this.client.getJerseyClient().getExecutorService().submit(new Callable<GenericServiceAPIResponseEntity<String>>() {
+            @Override
+            public GenericServiceAPIResponseEntity<String> call() throws Exception {
+                return client.delete(request);
+            }
+        });
+    }
+
+    @Override
+    public <E extends TaggedLogAPIEntity> Future<GenericServiceAPIResponseEntity<String>> update(final List<E> entities) throws IOException, EagleServiceClientException {
+        return this.client.getJerseyClient().getExecutorService().submit(new Callable<GenericServiceAPIResponseEntity<String>>() {
+            @Override
+            public GenericServiceAPIResponseEntity<String> call() throws Exception {
+                return client.update(entities);
+            }
+        });
+    }
+
+    @Override
+    public <E extends TaggedLogAPIEntity> Future<GenericServiceAPIResponseEntity<String>> update(final List<E> entities, final String serviceName) throws IOException, EagleServiceClientException {
+        return this.client.getJerseyClient().getExecutorService().submit(new Callable<GenericServiceAPIResponseEntity<String>>() {
+            @Override
+            public GenericServiceAPIResponseEntity<String> call() throws Exception {
+                return client.update(entities, serviceName);
+            }
+        });
+    }
+
+    @Override
+    public <E extends TaggedLogAPIEntity> Future<GenericServiceAPIResponseEntity<String>> update(final List<E> entities, final Class<E> entityClass) throws IOException, EagleServiceClientException {
+        return this.client.getJerseyClient().getExecutorService().submit(new Callable<GenericServiceAPIResponseEntity<String>>() {
+            @Override
+            public GenericServiceAPIResponseEntity<String> call() throws Exception {
+                return client.update(entities, entityClass);
+            }
+        });
+    }
+
+    @Override
+    public <E> Future<GenericServiceAPIResponseEntity<String>> search(final EagleServiceSingleEntityQueryRequest request) throws EagleServiceClientException {
+        return this.client.getJerseyClient().getExecutorService().submit(new Callable<GenericServiceAPIResponseEntity<String>>() {
+            @Override
+            public GenericServiceAPIResponseEntity<String> call() throws Exception {
+                return client.search(request);
+            }
+        });
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/impl/EagleServiceBaseClient.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/impl/EagleServiceBaseClient.java b/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/impl/EagleServiceBaseClient.java
new file mode 100644
index 0000000..70e92bf
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/impl/EagleServiceBaseClient.java
@@ -0,0 +1,339 @@
+/*
+ * 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.client.impl;
+
+import com.sun.jersey.api.client.AsyncWebResource;
+import com.sun.jersey.api.client.Client;
+import com.sun.jersey.api.client.WebResource;
+import com.sun.jersey.api.client.config.ClientConfig;
+import com.sun.jersey.api.client.config.DefaultClientConfig;
+import com.sun.jersey.client.urlconnection.URLConnectionClientHandler;
+import org.apache.eagle.common.Base64;
+import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
+import org.apache.eagle.log.entity.GenericServiceAPIResponseEntity;
+import org.apache.eagle.log.entity.meta.EntityDefinition;
+import org.apache.eagle.log.entity.meta.EntityDefinitionManager;
+import org.apache.eagle.service.client.EagleServiceAsyncClient;
+import org.apache.eagle.service.client.EagleServiceClientException;
+import org.apache.eagle.service.client.IEagleServiceClient;
+import org.apache.eagle.service.client.security.SecurityConstants;
+import org.codehaus.jackson.JsonFactory;
+import org.codehaus.jackson.JsonGenerationException;
+import org.codehaus.jackson.jaxrs.JacksonJsonProvider;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.core.MediaType;
+import java.io.Closeable;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+public abstract class EagleServiceBaseClient implements IEagleServiceClient {
+    public final static String SERVICE_NAME="serviceName";
+    public final static String DELETE_BY_ID="byId";
+
+    private final String host;
+    private final int port;
+    private final String basePath;
+    private String username;
+    private String password;
+    protected boolean silence = false;
+
+    public String getBaseEndpoint() {
+        return baseEndpoint;
+    }
+
+    private final String baseEndpoint;
+
+    private final static Logger LOG = LoggerFactory.getLogger(EagleServiceBaseClient.class);
+
+    protected static final String DEFAULT_BASE_PATH = "/eagle-service/rest";
+    protected static final MediaType DEFAULT_MEDIA_TYPE = MediaType.APPLICATION_JSON_TYPE;
+    protected static final String DEFAULT_HTTP_HEADER_CONTENT_TYPE = "application/json";
+    protected static final String CONTENT_TYPE = "Content-Type";
+
+    protected final static String GENERIC_ENTITY_PATH = "/entities";
+    protected final static String GENERIC_ENTITY_DELETE_PATH = GENERIC_ENTITY_PATH+"/delete";
+    private final Client client;
+    private final List<Closeable> closeables = new LinkedList<Closeable>();
+
+    private volatile boolean isStopped = false;
+
+    public EagleServiceBaseClient(String host, int port, String basePath, String username, String password) {
+        this.host = host;
+        this.port = port;
+        this.basePath = basePath;
+        this.baseEndpoint = buildBathPath().toString();
+        this.username = username;
+        this.password = password;
+
+        ClientConfig cc = new DefaultClientConfig();
+        cc.getProperties().put(DefaultClientConfig.PROPERTY_CONNECT_TIMEOUT, 60 * 1000);
+        cc.getProperties().put(DefaultClientConfig.PROPERTY_READ_TIMEOUT, 60 * 1000);
+        cc.getClasses().add(JacksonJsonProvider.class);
+        cc.getProperties().put(URLConnectionClientHandler.PROPERTY_HTTP_URL_CONNECTION_SET_METHOD_WORKAROUND, true);
+        this.client = Client.create(cc);
+        client.addFilter(new com.sun.jersey.api.client.filter.GZIPContentEncodingFilter());
+        //        Runtime.getRuntime().addShutdownHook(new EagleServiceClientShutdownHook(this));
+    }
+
+    public EagleServiceBaseClient(String host, int port, String basePath){
+        this(host, port, basePath, null);
+    }
+
+    public EagleServiceBaseClient(String host, int port, String username, String password){
+        this(host, port, DEFAULT_BASE_PATH, username, password);
+    }
+
+//    private class EagleServiceClientShutdownHook extends Thread{
+//        final IEagleServiceClient client;
+//        EagleServiceClientShutdownHook(IEagleServiceClient client){
+//            this.client = client;
+//        }
+//
+//        @Override
+//        public void run() {
+//            LOG.info("Client shutdown hook");
+//            try {
+//                this.client.close();
+//            } catch (IOException e) {
+//                LOG.error(e.getMessage(),e);
+//            }
+//        }
+//    }
+
+    public Client getJerseyClient(){
+        return client;
+    }
+
+    public EagleServiceBaseClient(String host, int port){
+        this(host,port,DEFAULT_BASE_PATH);
+    }
+
+    protected final StringBuilder buildBathPath() {
+        StringBuilder sb = new StringBuilder();
+        sb.append("http://");
+        sb.append(host);
+        sb.append(":");
+        sb.append(port);
+        sb.append(basePath);
+        return sb;
+    }
+
+    protected static String marshall(List<?> entities) throws JsonMappingException, JsonGenerationException, IOException {
+        final JsonFactory factory = new JsonFactory();
+        final ObjectMapper mapper = new ObjectMapper(factory);
+        mapper.setFilters(TaggedLogAPIEntity.getFilterProvider());
+        return mapper.writeValueAsString(entities);
+    }
+
+    protected <E extends TaggedLogAPIEntity> Map<String,List<E>> groupEntitiesByService(List<E> entities) throws EagleServiceClientException {
+        Map<String,List<E>> serviceEntityMap = new HashMap<String, List<E>>();
+        if(LOG.isDebugEnabled()) LOG.debug("Grouping entities by service name");
+        for(E entity: entities){
+            if(entity == null) {
+                LOG.warn("Skip null entity");
+                continue;
+            }
+
+            try {
+                EntityDefinition entityDefinition = EntityDefinitionManager.getEntityDefinitionByEntityClass(entity.getClass());
+                if(entityDefinition == null){
+                    throw new EagleServiceClientException("Failed to find entity definition of class: "+entity.getClass());
+                }
+                String serviceName = entityDefinition.getService();
+                List<E> bucket = serviceEntityMap.get(serviceName);
+                if(bucket == null){
+                    bucket = new LinkedList<E>();
+                    serviceEntityMap.put(serviceName, bucket);
+                }
+                bucket.add(entity);
+            } catch (InstantiationException e) {
+                throw new EagleServiceClientException(e);
+            } catch (IllegalAccessException e) {
+                throw new EagleServiceClientException(e);
+            }
+        }
+        return serviceEntityMap;
+    }
+
+    @Override
+    public SearchRequestBuilder search() {
+        return new SearchRequestBuilder(this);
+    }
+
+    @Override
+    public SearchRequestBuilder search(String query) {
+        return new SearchRequestBuilder(this).query(query);
+    }
+
+    protected void register(Closeable closeable){
+        this.closeables.add(closeable);
+    }
+
+    @Override
+    public MetricSender metric(String metricName) {
+        MetricSender metricGenerator = new MetricSender(this,metricName);
+        this.register(metricGenerator);
+        return metricGenerator;
+    }
+
+    protected WebResource getWebResource(String relativePath){
+        return this.getJerseyClient().resource(this.getBaseEndpoint() + relativePath);
+    }
+
+    protected AsyncWebResource getAsyncWebResource(String relativePath){
+        return this.getJerseyClient().asyncResource(this.getBaseEndpoint() + relativePath);
+    }
+
+    protected WebResource.Builder putAuthHeaderIfNeeded(WebResource.Builder r) {
+        if (username != null && password != null) {
+           r.header(SecurityConstants.AUTHORIZATION, SecurityConstants.BASIC_AUTHORIZATION_HEADER_PREFIX + Base64.encode(username + ":" + password));
+        }
+        return r;
+    }
+
+    /**
+     * Send HTTP POST request with entities and serviceName
+     *
+     * @param resourceURL
+     * @param entities
+     * @param serviceName
+     * @return
+     * @throws JsonMappingException
+     * @throws JsonGenerationException
+     * @throws IOException
+     */
+    @SuppressWarnings("unchecked")
+    protected GenericServiceAPIResponseEntity<String> postEntitiesWithService(String resourceURL, List<? extends TaggedLogAPIEntity> entities,String serviceName) throws JsonMappingException, JsonGenerationException, IOException {
+        final String json = marshall(entities);
+        final WebResource r = getWebResource(resourceURL);
+        return putAuthHeaderIfNeeded(r.queryParam(SERVICE_NAME,serviceName).accept(DEFAULT_MEDIA_TYPE))
+                .header(CONTENT_TYPE, DEFAULT_HTTP_HEADER_CONTENT_TYPE)
+                .post(GenericServiceAPIResponseEntity.class, json);
+    }
+
+    /**
+     * Send HTTP PUT request with entities and serviceName
+     *
+     * @param resourceURL
+     * @param entities
+     * @param serviceName
+     * @return
+     * @throws JsonMappingException
+     * @throws JsonGenerationException
+     * @throws IOException
+     */
+    @SuppressWarnings("unchecked")
+    protected GenericServiceAPIResponseEntity<String> putEntitiesWithService(String resourceURL, List<? extends TaggedLogAPIEntity> entities,String serviceName) throws JsonMappingException, JsonGenerationException, IOException {
+        final String json = marshall(entities);
+        final WebResource r = getWebResource(resourceURL);
+        return putAuthHeaderIfNeeded(r.queryParam(SERVICE_NAME,serviceName).accept(DEFAULT_MEDIA_TYPE))
+                .header(CONTENT_TYPE, DEFAULT_HTTP_HEADER_CONTENT_TYPE)
+                .put(GenericServiceAPIResponseEntity.class, json);
+    }
+
+
+    protected <E extends TaggedLogAPIEntity> String getServiceNameByClass(Class<E> entityClass) throws EagleServiceClientException {
+        EntityDefinition entityDefinition = null;
+        try {
+            entityDefinition = EntityDefinitionManager.getEntityDefinitionByEntityClass(entityClass);
+        } catch (InstantiationException e) {
+            throw new EagleServiceClientException(e);
+        } catch (IllegalAccessException e) {
+            throw new EagleServiceClientException(e);
+        }
+
+        if(entityDefinition == null){
+            throw new EagleServiceClientException("cannot find entity definition of class "+entityClass);
+        }
+        return entityDefinition.getService();
+    }
+
+
+    @Override
+    public BatchSender batch(int batchSize) {
+        BatchSender batchSender = new BatchSender(this,batchSize);
+        this.register(batchSender);
+        return batchSender;
+    }
+
+    @Override
+    public EagleServiceAsyncClient async() {
+        EagleServiceAsyncClient async = new EagleServiceAsyncClientImpl(this);
+        this.register(async);
+        return async;
+    }
+
+    @Override
+    public ConcurrentSender parallel(int parallelNum) {
+        ConcurrentSender concurrentSender = new ConcurrentSender(this,parallelNum);
+        this.register(concurrentSender);
+        return concurrentSender;
+    }
+
+    @Override
+    public <E extends TaggedLogAPIEntity> GenericServiceAPIResponseEntity<String> delete(List<E> entities, Class<E> entityClass) throws IOException, EagleServiceClientException {
+        return delete(entities, getServiceNameByClass(entityClass));
+    }
+
+    @Override
+    public <E extends TaggedLogAPIEntity> GenericServiceAPIResponseEntity<String> create(List<E> entities, Class<E> entityClass) throws IOException, EagleServiceClientException {
+        return create(entities, getServiceNameByClass(entityClass));
+    }
+
+    @Override
+    public <E extends TaggedLogAPIEntity> GenericServiceAPIResponseEntity<String> update(List<E> entities, Class<E> entityClass) throws IOException, EagleServiceClientException {
+        return update(entities, getServiceNameByClass(entityClass));
+    }
+
+    @Override
+    public void close() throws IOException {
+        if(!this.isStopped) {
+            if(LOG.isDebugEnabled()) LOG.debug("Client is closing");
+            for (Closeable closeable : this.closeables) {
+                try {
+                    closeable.close();
+                } catch (IOException e) {
+                    LOG.error(e.getMessage(), e);
+                    throw e;
+                }
+            }
+        }
+        this.isStopped = true;
+    }
+
+    @Override
+    public DeleteRequestBuilder delete() {
+        return new DeleteRequestBuilder(this);
+    }
+
+    protected void checkNotNull(Object obj,String name) throws EagleServiceClientException{
+        if(obj == null) throw new EagleServiceClientException(name+" should not be null but given");
+    }
+
+    @Override
+    public EagleServiceBaseClient silence(boolean silence) {
+        this.silence = silence;
+        return this;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/impl/EagleServiceClientImpl.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/impl/EagleServiceClientImpl.java b/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/impl/EagleServiceClientImpl.java
new file mode 100644
index 0000000..abd4fb2
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/impl/EagleServiceClientImpl.java
@@ -0,0 +1,196 @@
+/*
+ * 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.client.impl;
+
+import org.apache.eagle.log.base.taggedlog.TaggedLogAPIEntity;
+import org.apache.eagle.log.entity.GenericServiceAPIResponseEntity;
+import org.apache.eagle.service.client.EagleServiceClientException;
+import org.apache.eagle.service.client.EagleServiceSingleEntityQueryRequest;
+import com.sun.jersey.api.client.WebResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+public class EagleServiceClientImpl extends EagleServiceBaseClient {
+    private final static Logger LOG = LoggerFactory.getLogger(EagleServiceClientImpl.class);
+
+    public EagleServiceClientImpl(String host, int port){
+        super(host, port);
+    }
+
+    public EagleServiceClientImpl(String host, int port, String username, String password){
+        super(host, port, username, password);
+    }
+
+    private String getWholePath(String urlString){
+    	return getBaseEndpoint() + urlString;
+    }
+
+    @Override
+    public <E extends TaggedLogAPIEntity> GenericServiceAPIResponseEntity<String> create(List<E> entities, String serviceName) throws IOException,EagleServiceClientException {
+        checkNotNull(serviceName,"serviceName");
+        checkNotNull(entities,"entities");
+
+        final GenericServiceAPIResponseEntity<String> response;
+        response = postEntitiesWithService(GENERIC_ENTITY_PATH, entities, serviceName);
+        if (!response.isSuccess()) {
+            LOG.error("Failed to create entities for service: " + serviceName);
+        }
+        return response;
+    }
+
+    @Override
+    public <E extends TaggedLogAPIEntity> GenericServiceAPIResponseEntity<String> create(List<E> entities) throws IOException, EagleServiceClientException {
+        checkNotNull(entities,"entities");
+
+        Map<String,List<E>> serviceEntityMap = groupEntitiesByService(entities);
+        if(LOG.isDebugEnabled()) LOG.debug("Creating entities for "+serviceEntityMap.keySet().size()+" services");
+
+        List<String> createdKeys = new LinkedList<String>();
+
+        for(Map.Entry<String,List<E>> entry: serviceEntityMap.entrySet()){
+            GenericServiceAPIResponseEntity<String> response = create(entry.getValue(),entry.getKey());
+            if(!response.isSuccess()){
+                throw new IOException("Service side exception: "+response.getException());
+            }else if(response.getObj()!=null){
+                createdKeys.addAll(response.getObj());
+            }
+        }
+        GenericServiceAPIResponseEntity<String> entity = new GenericServiceAPIResponseEntity<String>();
+        entity.setObj(createdKeys);
+        entity.setSuccess(true);
+        return entity;
+    }
+
+    @Override
+    public <E extends TaggedLogAPIEntity> GenericServiceAPIResponseEntity<String> delete(List<E> entities) throws IOException, EagleServiceClientException {
+        checkNotNull(entities,"entities");
+
+        Map<String,List<E>> serviceEntityMap = groupEntitiesByService(entities);
+        if(LOG.isDebugEnabled()) LOG.debug("Creating entities for "+serviceEntityMap.keySet().size()+" services");
+
+        List<String> deletedKeys = new LinkedList<String>();
+        for(Map.Entry<String,List<E>> entry: serviceEntityMap.entrySet()){
+            GenericServiceAPIResponseEntity<String> response = delete(entry.getValue(), entry.getKey());
+            if(!response.isSuccess()){
+                LOG.error("Got service exception: "+response.getException());
+                throw new IOException(response.getException());
+            }else if(response.getObj()!=null){
+                deletedKeys.addAll(response.getObj());
+            }
+        }
+        GenericServiceAPIResponseEntity<String> entity = new GenericServiceAPIResponseEntity<String>();
+        entity.setObj(deletedKeys);
+        entity.setSuccess(true);
+        return entity;
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public <E extends TaggedLogAPIEntity> GenericServiceAPIResponseEntity<String> delete(List<E> entities, String serviceName) throws IOException,EagleServiceClientException {
+        checkNotNull(entities,"entities");
+        checkNotNull(serviceName,"serviceName");
+
+        return postEntitiesWithService(GENERIC_ENTITY_DELETE_PATH,entities,serviceName);
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public GenericServiceAPIResponseEntity<String> delete(EagleServiceSingleEntityQueryRequest request) throws IOException,EagleServiceClientException {
+        String queryString = request.getQueryParameterString();
+        StringBuilder sb = new StringBuilder();
+        sb.append(GENERIC_ENTITY_PATH);
+        sb.append("?");
+        sb.append(queryString);
+        final String urlString =  sb.toString();
+
+        if(!this.silence) LOG.info("Going to delete by querying service: " + getWholePath(urlString));
+        WebResource r = getWebResource(urlString);
+        return putAuthHeaderIfNeeded(r.accept(DEFAULT_MEDIA_TYPE)
+                                      .header(CONTENT_TYPE, DEFAULT_HTTP_HEADER_CONTENT_TYPE))
+                                      .delete(GenericServiceAPIResponseEntity.class);
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public GenericServiceAPIResponseEntity<String> deleteById(List<String> ids, String serviceName) throws EagleServiceClientException, IOException {
+        checkNotNull(serviceName,"serviceName");
+        checkNotNull(ids,"ids");
+
+        final String json = marshall(ids);
+        final WebResource r = getWebResource(GENERIC_ENTITY_DELETE_PATH);
+        return putAuthHeaderIfNeeded(r.queryParam(SERVICE_NAME,serviceName)
+                                       .queryParam(DELETE_BY_ID, "true")
+                                       .accept(DEFAULT_MEDIA_TYPE))
+                                       .header(CONTENT_TYPE, DEFAULT_HTTP_HEADER_CONTENT_TYPE)
+                                       .post(GenericServiceAPIResponseEntity.class, json);
+    }
+
+    @Override
+    public <E extends TaggedLogAPIEntity> GenericServiceAPIResponseEntity<String> update(List<E> entities) throws IOException, EagleServiceClientException {
+        checkNotNull(entities,"entities");
+
+        Map<String,List<E>> serviceEntityMap = groupEntitiesByService(entities);
+        if(LOG.isDebugEnabled()) LOG.debug("Updating entities for "+serviceEntityMap.keySet().size()+" services");
+
+        List<String> createdKeys = new LinkedList<String>();
+
+        for(Map.Entry<String,List<E>> entry: serviceEntityMap.entrySet()){
+            GenericServiceAPIResponseEntity<String> response = update(entry.getValue(), entry.getKey());
+            if(!response.isSuccess()){
+                throw new IOException("Got service exception when updating service "+entry.getKey()+" : "+response.getException());
+            }else{
+                if(response.getObj()!=null) {
+                    createdKeys.addAll(response.getObj());
+                }
+            }
+        }
+
+        GenericServiceAPIResponseEntity<String> entity = new GenericServiceAPIResponseEntity<String>();
+        entity.setObj(createdKeys);
+        entity.setSuccess(true);
+        return entity;
+    }
+
+    @Override
+    public <E extends TaggedLogAPIEntity> GenericServiceAPIResponseEntity<String> update(List<E> entities, String serviceName) throws IOException, EagleServiceClientException {
+        checkNotNull(entities,"entities");
+        checkNotNull(serviceName,"serviceName");
+
+        return putEntitiesWithService(GENERIC_ENTITY_PATH,entities,serviceName);
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public <T extends Object> GenericServiceAPIResponseEntity<T> search(EagleServiceSingleEntityQueryRequest request) throws EagleServiceClientException {
+        String queryString = request.getQueryParameterString();
+        StringBuilder sb = new StringBuilder();
+        sb.append(GENERIC_ENTITY_PATH);
+        sb.append("?");
+        sb.append(queryString);
+        final String urlString =  sb.toString();
+        if(!this.silence) LOG.info("Going to query service: " + getWholePath(urlString));
+        WebResource r = getWebResource(urlString);
+        return putAuthHeaderIfNeeded(r.accept(DEFAULT_MEDIA_TYPE))
+                                       .header(CONTENT_TYPE, DEFAULT_HTTP_HEADER_CONTENT_TYPE)
+                                       .get(GenericServiceAPIResponseEntity.class);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/impl/MetricSender.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/impl/MetricSender.java b/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/impl/MetricSender.java
new file mode 100644
index 0000000..dce5045
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/impl/MetricSender.java
@@ -0,0 +1,75 @@
+/*
+ * 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.client.impl;
+
+import org.apache.eagle.log.entity.GenericMetricEntity;
+import org.apache.eagle.service.client.IEagleServiceClient;
+import org.apache.eagle.service.client.EagleServiceClientException;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+public class MetricSender extends BatchSender {
+    private final String metricName;
+    private Map<String, String> tags;
+
+    public MetricSender(IEagleServiceClient client, String metricName) {
+        super(client,1);
+        this.metricName = metricName;
+    }
+
+    public MetricSender batch(int batchSize) {
+        super.setBatchSize(batchSize);
+        return this;
+    }
+
+    public MetricSender tags(Map<String,String> tags){
+        this.tags = tags;
+        return this;
+    }
+
+    public MetricSender send(String metricName,long timestamp,Map<String,String> tags,double ...values) throws IOException, EagleServiceClientException {
+        GenericMetricEntity metric = new GenericMetricEntity();
+        metric.setPrefix(metricName);
+        metric.setValue(values);
+        metric.setTimestamp(timestamp);
+        metric.setTags(tags);
+        super.send(metric);
+        return this;
+    }
+
+    public MetricSender send(Long timestamp,Map<String,String> tags,double ...values) throws IOException, EagleServiceClientException {
+        return this.send(this.metricName,timestamp,tags,values);
+    }
+
+    public MetricSender send(Long timestamp, double ... values) throws IOException, EagleServiceClientException {
+        return this.send(timestamp,new HashMap<String, String>(this.tags),values);
+    }
+
+//    public EagleServiceMetricSender send(String metricName,Map<String,String> tags,double ... values) throws IOException, EagleServiceClientException {
+//        return this.send(metricName,System.currentTimeMillis(),tags,values);
+//    }
+//
+//    public EagleServiceMetricSender send(Map<String,String> tags,double ...values) throws IOException, EagleServiceClientException {
+//        return this.send(this.metricName,System.currentTimeMillis(),tags,values);
+//    }
+//
+//    public EagleServiceMetricSender send(double ... values) throws IOException, EagleServiceClientException {
+//        return this.send(System.currentTimeMillis(), new HashMap<String, String>(this.tags), values);
+//    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/impl/SearchRequestBuilder.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/impl/SearchRequestBuilder.java b/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/impl/SearchRequestBuilder.java
new file mode 100644
index 0000000..331043c
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/impl/SearchRequestBuilder.java
@@ -0,0 +1,97 @@
+/*
+ * 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.client.impl;
+
+import org.apache.eagle.log.entity.GenericServiceAPIResponseEntity;
+import org.apache.eagle.service.client.IEagleServiceClient;
+import org.apache.eagle.service.client.EagleServiceClientException;
+import org.apache.eagle.service.client.EagleServiceSingleEntityQueryRequest;
+import org.apache.eagle.common.DateTimeUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+public class SearchRequestBuilder {
+    private final EagleServiceSingleEntityQueryRequest request;
+    private final IEagleServiceClient client;
+    private final static Logger LOG = LoggerFactory.getLogger(SearchRequestBuilder.class);
+
+    public SearchRequestBuilder(IEagleServiceClient client) {
+        this.request = new EagleServiceSingleEntityQueryRequest();
+        this.client = client;
+    }
+
+    public SearchRequestBuilder query(String query){
+        try {
+            this.request.setQuery(URLEncoder.encode(query,"UTF-8"));
+        } catch (UnsupportedEncodingException e) {
+            LOG.error(e.getMessage(),e);
+        }
+        return this;
+    }
+
+    public SearchRequestBuilder startRowkey(String startRowkey){
+        this.request.setStartRowkey(startRowkey);
+        return this;
+    }
+
+    public SearchRequestBuilder pageSize(int pageSize){
+        this.request.setPageSize(pageSize);
+        return this;
+    }
+
+    public SearchRequestBuilder startTime(long startTime){
+        this.request.setStartTime(startTime);
+        return this;
+    }
+
+    public SearchRequestBuilder startTime(String startTime){
+        this.request.setStartTime(DateTimeUtil.humanDateToMillisecondsWithoutException(startTime));
+        return this;
+    }
+
+    public SearchRequestBuilder endTime(long endTime){
+        this.request.setEndTime(endTime);
+        return this;
+    }
+
+    public SearchRequestBuilder endTime(String endTime){
+        this.request.setEndTime(DateTimeUtil.humanDateToMillisecondsWithoutException(endTime));
+        return this;
+    }
+
+    public SearchRequestBuilder treeAgg(boolean treeAgg){
+        this.request.setTreeAgg(treeAgg);
+        return this;
+    }
+
+    public SearchRequestBuilder metricName(String metricName){
+        this.request.setMetricName(metricName);
+        return this;
+    }
+
+    public SearchRequestBuilder filterIfMissing(Boolean filterIfMissing){
+        this.request.setFilterIfMissing(filterIfMissing);
+        return this;
+    }
+
+    public <T> GenericServiceAPIResponseEntity<T> send() throws EagleServiceClientException {
+        return client.search(this.request);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/security/SecurityConstants.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/security/SecurityConstants.java b/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/security/SecurityConstants.java
new file mode 100644
index 0000000..634e2b7
--- /dev/null
+++ b/eagle-core/eagle-query/eagle-client-base/src/main/java/org/apache/eagle/service/client/security/SecurityConstants.java
@@ -0,0 +1,6 @@
+package org.apache.eagle.service.client.security;
+
+public class SecurityConstants {
+    public static final String AUTHORIZATION = "Authorization";
+    public static final String BASIC_AUTHORIZATION_HEADER_PREFIX = "Basic ";
+}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-client-base/src/test/java/eagle/service/client/Base.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-client-base/src/test/java/eagle/service/client/Base.java b/eagle-core/eagle-query/eagle-client-base/src/test/java/eagle/service/client/Base.java
deleted file mode 100644
index a89ef97..0000000
--- a/eagle-core/eagle-query/eagle-client-base/src/test/java/eagle/service/client/Base.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 eagle.service.client;
-
-import org.codehaus.jackson.annotate.JsonSubTypes;
-import org.codehaus.jackson.annotate.JsonTypeInfo;
-
-
-//@JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY, property="@class")
-@JsonTypeInfo(use=JsonTypeInfo.Id.NAME )
-@JsonSubTypes({
-    @JsonSubTypes.Type(value=ClassA.class, name="ClassA"),
-    @JsonSubTypes.Type(value=ClassB.class, name="ClassB")
-})
-public abstract class Base {
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-client-base/src/test/java/eagle/service/client/ClassA.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-client-base/src/test/java/eagle/service/client/ClassA.java b/eagle-core/eagle-query/eagle-client-base/src/test/java/eagle/service/client/ClassA.java
deleted file mode 100644
index c4f89bb..0000000
--- a/eagle-core/eagle-query/eagle-client-base/src/test/java/eagle/service/client/ClassA.java
+++ /dev/null
@@ -1,35 +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 eagle.service.client;
-
-import org.codehaus.jackson.annotate.JsonTypeName;
-
-
-@JsonTypeName("ClassA")
-public class ClassA extends Base {
-
-	private int a;
-
-	public int getA() {
-		return a;
-	}
-
-	public void setA(int a) {
-		this.a = a;
-	}
-	
-}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-client-base/src/test/java/eagle/service/client/ClassB.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-client-base/src/test/java/eagle/service/client/ClassB.java b/eagle-core/eagle-query/eagle-client-base/src/test/java/eagle/service/client/ClassB.java
deleted file mode 100644
index a797a68..0000000
--- a/eagle-core/eagle-query/eagle-client-base/src/test/java/eagle/service/client/ClassB.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 eagle.service.client;
-
-import org.codehaus.jackson.annotate.JsonTypeName;
-
-@JsonTypeName("ClassB")
-public class ClassB extends Base {
-
-	private String b;
-
-	public String getB() {
-		return b;
-	}
-
-	public void setB(String b) {
-		this.b = b;
-	}
-	
-}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-client-base/src/test/java/eagle/service/client/ClientTestBase.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-client-base/src/test/java/eagle/service/client/ClientTestBase.java b/eagle-core/eagle-query/eagle-client-base/src/test/java/eagle/service/client/ClientTestBase.java
deleted file mode 100644
index 167f1b9..0000000
--- a/eagle-core/eagle-query/eagle-client-base/src/test/java/eagle/service/client/ClientTestBase.java
+++ /dev/null
@@ -1,37 +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 eagle.service.client;
-
-import org.junit.BeforeClass;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import eagle.service.embedded.tomcat.EmbeddedServer;
-import eagle.service.hbase.EmbeddedHbase;
-
-public class ClientTestBase {
-	
-	//protected static EmbeddedServer server;
-	protected static EmbeddedHbase hbase;
-
-	//@BeforeClass
-	public static void startup() throws Exception {
-		//hbase = EmbeddedHbase.getInstance();
-		//String webappDirLocation = "../../../eagle-webservice/target/eagle-service";
-		//server = EmbeddedServer.getInstance(webappDirLocation);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-client-base/src/test/java/eagle/service/client/TestEagleServiceClientImpl.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-client-base/src/test/java/eagle/service/client/TestEagleServiceClientImpl.java b/eagle-core/eagle-query/eagle-client-base/src/test/java/eagle/service/client/TestEagleServiceClientImpl.java
deleted file mode 100644
index cc223c4..0000000
--- a/eagle-core/eagle-query/eagle-client-base/src/test/java/eagle/service/client/TestEagleServiceClientImpl.java
+++ /dev/null
@@ -1,339 +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 eagle.service.client;
-
-import eagle.log.entity.GenericMetricEntity;
-import eagle.log.entity.GenericServiceAPIResponseEntity;
-import eagle.log.entity.test.TestTimeSeriesAPIEntity;
-import eagle.service.client.impl.EagleServiceClientImpl;
-import eagle.service.client.impl.ConcurrentSender;
-import junit.framework.Assert;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.util.*;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-
-public class TestEagleServiceClientImpl extends ClientTestBase {
-
-    IEagleServiceClient client = new EagleServiceClientImpl("localhost",38080);
-
-    //@Before
-    public void setUp() {
-        hbase.createTable("unittest", "f");
-    }
-
-    //After
-    public void cleanUp() {
-        hbase.deleteTable("unittest");
-    }
-
-    //@Test
-    public void testCreateAndSearch() throws IOException, EagleServiceClientException, IllegalAccessException, InstantiationException {
-        List<TestTimeSeriesAPIEntity> entities = new ArrayList<TestTimeSeriesAPIEntity>();
-
-        for(int i=0;i<100;i++){
-            TestTimeSeriesAPIEntity entity = new TestTimeSeriesAPIEntity();
-            entity.setTimestamp(System.currentTimeMillis());
-            entity.setTags(new HashMap<String, String>() {{
-                put("cluster", "cluster4ut");
-                put("datacenter", "datacenter4ut");
-                put("timestampStr",System.currentTimeMillis()+"");
-            }});
-            entity.setField1(1);
-            entity.setField2(1);
-            entity.setField3(1);
-            entity.setField4(1l);
-            entity.setField5(1l);
-            entity.setField5(1.2);
-            entity.setField6(-1.2);
-            entity.setField7("test unit string attribute");
-            entities.add(entity);
-        }
-
-        GenericServiceAPIResponseEntity response = client.create(entities);
-        assert response.isSuccess();
-        response = client.create(entities,TestTimeSeriesAPIEntity.class);
-        assert response.isSuccess();
-        response = client.create(entities,"TestTimeSeriesAPIEntity");
-        assert response.isSuccess();
-
-        response = client.search("TestTimeSeriesAPIEntity[]{*}")
-                .startTime(0)
-                .endTime(System.currentTimeMillis() + 25 * 3600 * 1000)
-                .pageSize(1000)
-                .send();
-
-        assert  response.isSuccess();
-        assert response.getObj().size() > 0;
-    }
-
-    private TestTimeSeriesAPIEntity newEntity(){
-        TestTimeSeriesAPIEntity entity = new TestTimeSeriesAPIEntity();
-        entity.setTimestamp(System.currentTimeMillis());
-        entity.setTags(new HashMap<String, String>() {{
-            put("cluster", "cluster4ut");
-            put("datacenter", "datacenter4ut");
-        }});
-        entity.setField1(1);
-        entity.setField2(1);
-        entity.setField3(1);
-        entity.setField4(1l);
-        entity.setField5(1l);
-        entity.setField5(1.2);
-        entity.setField6(-1.2);
-        entity.setField7("test unit string attribute");
-        return entity;
-    }
-
-    //@Test
-    public void testUpdate() throws IOException, EagleServiceClientException, IllegalAccessException, InstantiationException {
-        List<TestTimeSeriesAPIEntity> entities = new ArrayList<TestTimeSeriesAPIEntity>();
-        for(int i=0;i<100;i++){
-            TestTimeSeriesAPIEntity entity = new TestTimeSeriesAPIEntity();
-            entity.setTimestamp(System.currentTimeMillis());
-            entity.setTags(new HashMap<String, String>() {{
-                put("cluster", "cluster4ut");
-                put("datacenter", "datacenter4ut");
-            }});
-            entity.setField1(1);
-            entity.setField2(1);
-            entity.setField3(1);
-            entity.setField4(1l);
-            entity.setField5(1l);
-            entity.setField5(1.2);
-            entity.setField6(-1.2);
-            entity.setField7("updated");
-            entities.add(entity);
-        }
-
-        GenericServiceAPIResponseEntity response = client.update(entities);
-        assert response.isSuccess();
-        response = client.update(entities, TestTimeSeriesAPIEntity.class);
-        assert response.isSuccess();
-        response = client.update(entities, "TestTimeSeriesAPIEntity");
-        assert response.isSuccess();
-
-        response = client.search("TestTimeSeriesAPIEntity[]{*}")
-                .startTime(0)
-                .endTime(System.currentTimeMillis() + 25 * 3600 * 1000)
-                .pageSize(1000)
-                .send();
-
-        assert response.isSuccess();
-        assert response.getObj().size() > 0;
-    }
-
-    //@Test
-    public void testDelete() throws IOException, EagleServiceClientException {
-        List<TestTimeSeriesAPIEntity> entities = new ArrayList<TestTimeSeriesAPIEntity>();
-        for(int i=0;i<100;i++){
-            TestTimeSeriesAPIEntity entity = new TestTimeSeriesAPIEntity();
-            entity.setTimestamp(System.currentTimeMillis());
-            entity.setTags(new HashMap<String, String>() {{
-                put("cluster", "cluster4ut");
-                put("datacenter", "datacenter4ut");
-            }});
-
-            entity.setField1(1);
-            entity.setField2(1);
-            entity.setField3(1);
-            entity.setField4(1l);
-            entity.setField5(1l);
-            entity.setField5(1.2);
-            entity.setField6(-1.2);
-            entity.setField7(" unit test oriented string attribute");
-            entities.add(entity);
-        }
-
-        GenericServiceAPIResponseEntity response = client.delete(entities);
-        assert response.isSuccess();
-        response = client.delete(entities, TestTimeSeriesAPIEntity.class);
-        assert response.isSuccess();
-        response = client.delete(entities, "TestTimeSeriesAPIEntity");
-        assert response.isSuccess();
-
-        response = client.delete()
-                .byId(Arrays.asList("30RR1H___rOqxUr5M_sR-g5RxZlmldR_9eQ49A"))
-                .serviceName("TestTimeSeriesAPIEntity")
-                .send();
-
-        assert response.isSuccess();
-
-        response = client.delete()
-                .byQuery("TestTimeSeriesAPIEntity[]{*}")
-                .startTime(0)
-                .endTime(System.currentTimeMillis())
-                .pageSize(1000)
-                .send();
-
-        assert response.isSuccess();
-    }
-
-    //@Test
-    public void testMetricsSender() throws IOException, EagleServiceClientException {
-        List<GenericMetricEntity> entities = new ArrayList<GenericMetricEntity>();
-
-        Map<String,String> tags = new HashMap<String, String>() {{
-            put("cluster", "cluster4ut");
-            put("datacenter", "datacenter4ut");
-        }};
-
-        for(int i=0;i<100;i++){
-            GenericMetricEntity entity = new GenericMetricEntity();
-            entity.setTimestamp(System.currentTimeMillis());
-            entity.setTags(tags);
-            entity.setValue(new double[]{1.234});
-            entity.setPrefix("unit.test.metrics");
-            entities.add(entity);
-        }
-
-        GenericServiceAPIResponseEntity response = client.create(entities);
-        assert response.isSuccess();
-        response = client.create(entities,GenericMetricEntity.class);
-        assert response.isSuccess();
-        response = client.create(entities,GenericMetricEntity.GENERIC_METRIC_SERVICE);
-        assert response.isSuccess();
-
-        client.metric("unit.test.metrics")
-                .batch(5)
-                .tags(tags)
-                .send("unit.test.anothermetrics", System.currentTimeMillis(), tags, 0.1, 0.2, 0.3)
-                .send(System.currentTimeMillis(), 0.1)
-                .send(System.currentTimeMillis(),0.1,0.2)
-                .send(System.currentTimeMillis(),0.1,0.2,0.3)
-                .send(System.currentTimeMillis(),tags,0.1,0.2,0.3)
-                .send("unit.test.anothermetrics",System.currentTimeMillis(),tags,0.1,0.2,0.3)
-                .flush();
-
-        GenericServiceAPIResponseEntity<GenericMetricEntity> metricResponse = client.search("GenericMetricService[@cluster=\"cluster4ut\" AND @datacenter = \"datacenter4ut\"]{*}")
-                .startTime(0)
-                .endTime(System.currentTimeMillis()+24 * 3600 * 1000)
-                .metricName("unit.test.metrics")
-                .pageSize(1000)
-                .send();
-        List<GenericMetricEntity> metricEntities = metricResponse.getObj();
-        assert metricEntities != null;
-        assert metricResponse.isSuccess();
-
-        GenericServiceAPIResponseEntity<Map> metricAggResponse = client.search("GenericMetricService[@cluster=\"cluster4ut\" AND @datacenter = \"datacenter4ut\"]<@cluster>{sum(value)}")
-                .startTime(0)
-                .endTime(System.currentTimeMillis()+24 * 3600 * 1000)
-                .metricName("unit.test.metrics")
-                .pageSize(1000)
-                .send();
-        List<Map> aggResult = metricAggResponse.getObj();
-        assert aggResult != null;
-        assert metricAggResponse.isSuccess();
-
-        client.close();
-    }
-
-    //@Test
-    public void testBatchSender() throws IOException, EagleServiceClientException {
-        client.batch(2)
-                .send(newEntity())
-                .send(newEntity())
-                .send(newEntity());
-        client.close();
-    }
-
-    //@Test
-    public void testAsyncSender() throws IOException, EagleServiceClientException, ExecutionException, InterruptedException {
-        EagleServiceAsyncClient asyncClient = client.async();
-
-        Future<GenericServiceAPIResponseEntity<String>> future1 =
-                asyncClient.create(Arrays.asList(newEntity()));
-
-        GenericServiceAPIResponseEntity<String> response1 = future1.get();
-
-        Assert.assertTrue(response1.isSuccess());
-
-        Future<GenericServiceAPIResponseEntity<String>> future2 =
-                asyncClient.update(Arrays.asList(newEntity()));
-
-        GenericServiceAPIResponseEntity<String> response2 = future2.get();
-
-        Assert.assertTrue(response2.isSuccess());
-
-        Future<GenericServiceAPIResponseEntity<String>> future3 =
-                asyncClient.delete(Arrays.asList(newEntity()));
-
-        GenericServiceAPIResponseEntity<String> response3 = future3.get();
-
-        Assert.assertTrue(response3.isSuccess());
-
-        client.close();
-    }
-
-    //@Test
-    public void testParallelSender() throws IOException, EagleServiceClientException, InterruptedException {
-        // Case #1:
-        ConcurrentSender concurrentSender = client
-                .parallel(10)
-                .batchSize(30)
-                .batchInterval(1000);
-
-        int num = 1000;
-
-        for(int i=0; i< num;i++) {
-            concurrentSender.send(Arrays.asList(newEntity()));
-        }
-
-        // Case #2:
-        ConcurrentSender concurrentSender2 = client
-                .parallel(10)
-                .batchSize(20)
-                .batchInterval(3);
-
-        int num2 = 50;
-
-        for(int i=0; i< num2;i++) {
-            concurrentSender2.send(Arrays.asList(newEntity()));
-            Thread.sleep(1);
-        }
-        client.close();
-    }
-
-    //@Test
-    public void testSearch() throws EagleServiceClientException, IOException {
-        hbase.createTable("eagle_metric", "f");
-
-        GenericServiceAPIResponseEntity<TestTimeSeriesAPIEntity> response =
-                client.search("TestTimeSeriesAPIEntity[]{*}").startTime(0).endTime(System.currentTimeMillis()+1000).pageSize(1000).send();
-
-        Assert.assertTrue(response.isSuccess());
-
-        GenericServiceAPIResponseEntity<Map> response2 =
-                client.search("TestTimeSeriesAPIEntity[]<@cluster>{count}").startTime(0).endTime(System.currentTimeMillis()+1000).pageSize(1000).send();
-
-        Assert.assertTrue(response2.isSuccess());
-
-        GenericServiceAPIResponseEntity<GenericMetricEntity> response3 =
-                client.search("GenericMetricService[@cluster = \"cluster4ut\" AND @datacenter = \"datacenter4ut\"]{*}").metricName("unit.test.metrics").startTime(0).endTime(System.currentTimeMillis()+1000).pageSize(1000).send();
-
-        Assert.assertTrue(response3.isSuccess());
-        hbase.deleteTable("eagle_metric");
-    }
-
-    @Test
-    public void test() {
-
-    }
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/afe86834/eagle-core/eagle-query/eagle-client-base/src/test/java/eagle/service/client/TestIEagleServiceClient.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-query/eagle-client-base/src/test/java/eagle/service/client/TestIEagleServiceClient.java b/eagle-core/eagle-query/eagle-client-base/src/test/java/eagle/service/client/TestIEagleServiceClient.java
deleted file mode 100644
index d59954a..0000000
--- a/eagle-core/eagle-query/eagle-client-base/src/test/java/eagle/service/client/TestIEagleServiceClient.java
+++ /dev/null
@@ -1,64 +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 eagle.service.client;
-
-import eagle.common.config.EagleConfigFactory;
-import eagle.log.entity.GenericMetricEntity;
-import eagle.log.entity.GenericServiceAPIResponseEntity;
-import eagle.log.entity.meta.EntityDefinition;
-import eagle.log.entity.meta.EntityDefinitionManager;
-import eagle.service.client.impl.EagleServiceClientImpl;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-public class TestIEagleServiceClient extends ClientTestBase {
-    IEagleServiceClient client;
-    //@Before
-    public void setUp(){
-        client = new EagleServiceClientImpl("localhost", EagleConfigFactory.load().getServicePort());
-    }
-
-    /**
-     * Just compiling passed is ok
-     */
-    //@Test
-    @SuppressWarnings("unused")
-    public void testCreate() throws IOException, EagleServiceClientException, IllegalAccessException, InstantiationException {
-        EntityDefinition entityDefinition = EntityDefinitionManager.getEntityDefinitionByEntityClass(GenericMetricEntity.class);
-        hbase.createTable(entityDefinition.getTable(), entityDefinition.getColumnFamily());
-
-        client = new EagleServiceClientImpl("localhost", EagleConfigFactory.load().getServicePort());
-        List<GenericMetricEntity> metricEntityList = new ArrayList<GenericMetricEntity>();
-        GenericServiceAPIResponseEntity<String> unTypedResponse = client.create(metricEntityList);
-        GenericServiceAPIResponseEntity<String> weakTypedResponse = client.create(metricEntityList,GenericMetricEntity.GENERIC_METRIC_SERVICE);
-        GenericServiceAPIResponseEntity<String> strongTypedResponse = client.create(metricEntityList,GenericMetricEntity.class);
-
-        GenericServiceAPIResponseEntity<GenericMetricEntity> weakTypedSearchResponse = client.search("").send();
-        if(weakTypedSearchResponse!=null) {
-            Class<GenericMetricEntity> typedClazz = weakTypedSearchResponse.getType();
-            List<GenericMetricEntity> typedEntities = weakTypedSearchResponse.getObj();
-        }
-    }
-
-    @Test
-    public void test() {
-
-    }
-}
\ No newline at end of file


Mime
View raw message