[ 
https://issues.apache.org/jira/browse/SCB-85?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16315558#comment-16315558
 ] 

ASF GitHub Bot commented on SCB-85:
-----------------------------------

zhengyangyong commented on a change in pull request #476: [SCB-85] Upgrade 
Metrics File Output from 0.5.0 to 1.0.0-m1
URL: 
https://github.com/apache/incubator-servicecomb-java-chassis/pull/476#discussion_r160067031
 
 

 ##########
 File path: 
metrics/metrics-extension/metrics-write-file/src/main/java/io/servicecomb/metrics/extension/writefile/WriteFileInitializer.java
 ##########
 @@ -0,0 +1,110 @@
+/*
+ * 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 io.servicecomb.metrics.extension.writefile;
+
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
+
+import java.util.Map;
+import java.util.concurrent.Executors;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import com.netflix.config.DynamicPropertyFactory;
+
+import io.servicecomb.foundation.common.net.NetUtils;
+import io.servicecomb.metrics.common.RegistryMetric;
+import io.servicecomb.metrics.core.publish.DataSource;
+import io.servicecomb.metrics.extension.writefile.config.MetricsFileWriter;
+import io.servicecomb.serviceregistry.RegistryUtils;
+import io.servicecomb.serviceregistry.api.registry.Microservice;
+
+@Component
+public class WriteFileInitializer {
+
+  private static final String METRICS_WINDOW_TIME = 
"servicecomb.metrics.window_time";
+
+  private final int metricPoll;
+
+  private FileContentConvertor convertor;
+
+  private FileContentFormatter formatter;
+
+  private final DataSource dataSource;
+
+  private final MetricsFileWriter fileWriter;
+
+  private String filePrefix;
+
+  private String hostName;
+
+  @Autowired
+  public WriteFileInitializer(MetricsFileWriter fileWriter, DataSource 
dataSource) {
+    metricPoll = 
DynamicPropertyFactory.getInstance().getIntProperty(METRICS_WINDOW_TIME, 
5000).get();
+    this.fileWriter = fileWriter;
+    this.dataSource = dataSource;
+
+    this.init();
+  }
+
+  public WriteFileInitializer(MetricsFileWriter fileWriter, DataSource 
dataSource, String hostName, String filePrefix) {
+    metricPoll = 
DynamicPropertyFactory.getInstance().getIntProperty(METRICS_WINDOW_TIME, 
5000).get();
+    this.fileWriter = fileWriter;
+    this.dataSource = dataSource;
+    this.hostName = hostName;
+    this.filePrefix = filePrefix;
+  }
+
+  private void init() {
+    final Runnable poller = this::run;
+    Executors.newScheduledThreadPool(1)
+        .scheduleWithFixedDelay(poller, 0, metricPoll, MILLISECONDS);
+  }
+
+  public void run() {
+    //wait RegistryUtils init completed
 
 Review comment:
   my no need,this way is simple and enough

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Upgrade Metrics File Output from 0.5.0 to 1.0.0-m1
> --------------------------------------------------
>
>                 Key: SCB-85
>                 URL: https://issues.apache.org/jira/browse/SCB-85
>             Project: Apache ServiceComb
>          Issue Type: Sub-task
>          Components: Java-Chassis
>            Reporter: yangyongzheng
>            Assignee: yangyongzheng
>             Fix For: java-chassis-1.0.0-m1
>
>
> Because metrics had complete reflected in 1.0.0-m1,so we need upgrade file 
> output example and show new features.
> 1.support more build-in metric
> 2.support output operation level metric



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to