[ 
https://issues.apache.org/jira/browse/BEAM-6165?focusedWorklogId=172359&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-172359
 ]

ASF GitHub Bot logged work on BEAM-6165:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 05/Dec/18 16:20
            Start Date: 05/Dec/18 16:20
    Worklog Time Spent: 10m 
      Work Description: ryan-williams commented on a change in pull request 
#7183: [BEAM-6165] send metrics to Flink in portable Flink runner
URL: https://github.com/apache/beam/pull/7183#discussion_r239135253
 
 

 ##########
 File path: sdks/python/apache_beam/runners/portability/flink_runner_test.py
 ##########
 @@ -59,25 +65,63 @@
   environment_type = known_args.environment_type.lower()
   environment_config = (
       known_args.environment_config if known_args.environment_config else None)
+  test = known_args.test
 
   # This is defined here to only be run when we invoke this file explicitly.
   class FlinkRunnerTest(portable_runner_test.PortableRunnerTest):
     _use_grpc = True
     _use_subprocesses = True
 
+    conf_dir = None
+
+    @classmethod
+    def tearDownClass(cls):
+      if cls.conf_dir and exists(cls.conf_dir):
+        logging.info("removing conf dir: %s" % cls.conf_dir)
+        rmtree(cls.conf_dir)
+      super(FlinkRunnerTest, cls).tearDownClass()
+
+    @classmethod
+    def _create_conf_dir(cls):
+      """Create (and save a static reference to) a "conf dir", used to provide 
metrics configs and
+       verify metrics output
+
+       It gets cleaned up when the suite is done executing"""
+
+      if hasattr(cls, 'conf_dir'):
+        cls.conf_dir = mkdtemp(prefix='flinktest-conf')
+
+        # path for a FileReporter to write metrics to
+        cls.test_metrics_path = path.join(cls.conf_dir, 'test-metrics.txt')
+
+        # path to write Flink configuration to
+        conf_path = path.join(cls.conf_dir, 'flink-conf.yaml')
+        with open(conf_path, 'w') as f:
+          f.write(linesep.join([
+            'metrics.reporters: test',
+            'metrics.reporter.test.class: 
org.apache.beam.runners.flink.metrics.FileReporter',
+            'metrics.reporter.test.file: %s' % cls.test_metrics_path
+          ]))
+
     @classmethod
     def _subprocess_command(cls, port):
-      tmp_dir = tempfile.mkdtemp(prefix='flinktest')
+      # will be cleaned up at the end of this method, and recreated and used 
by the job server
+      tmp_dir = mkdtemp(prefix='flinktest')
+
+      cls._create_conf_dir()
+
       try:
         return [
             'java',
             '-jar', flink_job_server_jar,
+            '--flink-master-url', '[local]',
 
 Review comment:
   thanks, I am using the `--flink-conf-dir` added in #7031; I don't see a way 
to avoid specifying `[local]` here though. it also sounds like we are saying 
that this test is intended to only run in local mode, so we may as well make 
that explicit?
   
   The previous (`[auto]`) code path goes through Flink code that doesn't seem 
to support injecting an existing `Configuration` (cf. 
[streaming](https://github.com/apache/flink/blob/release-1.5.5/flink-streaming-java/src/main/java/org/apache/flink/streaming/api/environment/StreamExecutionEnvironment.java#L1595-L1612),
 
[batch](https://github.com/apache/flink/blob/release-1.5.5/flink-java/src/main/java/org/apache/flink/api/java/ExecutionEnvironment.java#L1058-L1061);
 presumably this makes sense because it would be strange to do that if actually 
in remote/cluster mode?)
   
   lmk if that doesn't make sense or there is something I should change here, 
thanks

----------------------------------------------------------------
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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 172359)
    Time Spent: 5h 50m  (was: 5h 40m)

> Send metrics to Flink in portable Flink runner
> ----------------------------------------------
>
>                 Key: BEAM-6165
>                 URL: https://issues.apache.org/jira/browse/BEAM-6165
>             Project: Beam
>          Issue Type: Improvement
>          Components: runner-flink
>    Affects Versions: 2.8.0
>            Reporter: Ryan Williams
>            Assignee: Ryan Williams
>            Priority: Major
>              Labels: metrics, portability, portability-flink
>          Time Spent: 5h 50m
>  Remaining Estimate: 0h
>
> Metrics are sent from the fn harness to runnerĀ in the Python SDK (and likely 
> Java soon), but the portable Flink runner doesn't pass them on to Flink, 
> which it should, so that users can see them in e.g. the Flink UI or via any 
> Flink metrics reporters.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to