eagle-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h..@apache.org
Subject incubator-eagle git commit: [MINOR] Create MetricSchema in batch of 1
Date Fri, 09 Dec 2016 18:29:48 GMT
Repository: incubator-eagle
Updated Branches:
  refs/heads/master 7ad45fd1b -> e99b2fedf


[MINOR] Create MetricSchema in batch of 1


Project: http://git-wip-us.apache.org/repos/asf/incubator-eagle/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-eagle/commit/e99b2fed
Tree: http://git-wip-us.apache.org/repos/asf/incubator-eagle/tree/e99b2fed
Diff: http://git-wip-us.apache.org/repos/asf/incubator-eagle/diff/e99b2fed

Branch: refs/heads/master
Commit: e99b2fedf158f36857cc78279771e4b95a582776
Parents: 7ad45fd
Author: Hao Chen <hao@apache.org>
Authored: Sat Dec 10 02:29:31 2016 +0800
Committer: Hao Chen <hao@apache.org>
Committed: Sat Dec 10 02:29:31 2016 +0800

----------------------------------------------------------------------
 .../eagle/app/messaging/MetricSchemaGenerator.java   | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-eagle/blob/e99b2fed/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/messaging/MetricSchemaGenerator.java
----------------------------------------------------------------------
diff --git a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/messaging/MetricSchemaGenerator.java
b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/messaging/MetricSchemaGenerator.java
index 6563cd7..88fe338 100644
--- a/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/messaging/MetricSchemaGenerator.java
+++ b/eagle-core/eagle-app/eagle-app-base/src/main/java/org/apache/eagle/app/messaging/MetricSchemaGenerator.java
@@ -22,10 +22,11 @@ import backtype.storm.topology.OutputFieldsDeclarer;
 import backtype.storm.topology.base.BaseRichBolt;
 import backtype.storm.tuple.Tuple;
 import com.typesafe.config.Config;
+import org.apache.eagle.log.entity.GenericServiceAPIResponseEntity;
 import org.apache.eagle.metadata.model.MetricSchemaEntity;
 import org.apache.eagle.app.environment.builder.MetricDefinition;
 import org.apache.eagle.service.client.EagleServiceClientException;
-import org.apache.eagle.service.client.impl.BatchSender;
+import org.apache.eagle.service.client.IEagleServiceClient;
 import org.apache.eagle.service.client.impl.EagleServiceClientImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -43,7 +44,7 @@ public class MetricSchemaGenerator extends BaseRichBolt {
     private final Config config;
 
     private OutputCollector collector;
-    private BatchSender client;
+    private IEagleServiceClient client;
 
     public MetricSchemaGenerator(MetricDefinition metricDefinition, Config config) {
         this.metricDefinition = metricDefinition;
@@ -53,7 +54,7 @@ public class MetricSchemaGenerator extends BaseRichBolt {
     @Override
     public void prepare(Map stormConf, TopologyContext context, OutputCollector collector)
{
         this.collector = collector;
-        this.client = new EagleServiceClientImpl(config).batch(100);
+        this.client = new EagleServiceClientImpl(config);
     }
 
     @Override
@@ -102,6 +103,12 @@ public class MetricSchemaGenerator extends BaseRichBolt {
         schemaEntity.setDimensionFields(metricDefinition.getDimensionFields());
         schemaEntity.setMetricFields(Collections.singletonList(GENERIC_METRIC_VALUE_NAME));
         schemaEntity.setModifiedTimestamp(System.currentTimeMillis());
-        this.client.send(Collections.singletonList(schemaEntity));
+        GenericServiceAPIResponseEntity<String> response = this.client.create(Collections.singletonList(schemaEntity));
+        if (response.isSuccess() && LOG.isDebugEnabled()) {
+            LOG.debug("Created {}", schemaEntity);
+        } else {
+            LOG.error("Failed to create {}", schemaEntity, response.getException());
+            throw new IOException("Service error: " + response.getException());
+        }
     }
 }
\ No newline at end of file


Mime
View raw message