问:
Spark executors always EXIT
I have a 2 nodes cluster with spark installed as follows:

First node : A master and one worker

Second node : Another worker

Each time I start the cluster with the command $SPARK_HOME/sbin/start-all.sh, I encounter an anomaly in the second worker; Executors are created and closed immediately. This results in an abnormal multiplication of the number of executors and very often an error in execution when I submit jobs.

in master logs, we can see it launching and removing second executor (172.21.113.120)

```<code>Spark Command: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.222.b03-1.el7.x86_64/bin/java -cp /spark/spark-2.4.4/conf/:/spark/spark-2.4.4/assembly/target/scala-2.11/jars/* -Xmx1g org.apache.spark.deploy.master.Master --host 172.21.113.119 --port 7077 --webui-port 8080
========================================
Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
20/02/15 17:15:44 INFO Master: Started daemon with process name: 6678@ingest1.adcm.orangecm
20/02/15 17:15:44 INFO SignalUtils: Registered signal handler for TERM
20/02/15 17:15:44 INFO SignalUtils: Registered signal handler for HUP
20/02/15 17:15:44 INFO SignalUtils: Registered signal handler for INT
20/02/15 17:15:44 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
20/02/15 17:15:45 INFO SecurityManager: Changing view acls to: root
20/02/15 17:15:45 INFO SecurityManager: Changing modify acls to: root
20/02/15 17:15:45 INFO SecurityManager: Changing view acls groups to:
20/02/15 17:15:45 INFO SecurityManager: Changing modify acls groups to:
20/02/15 17:15:45 INFO SecurityManager: SecurityManager: authentication disabled; ui acls disabled; users  with view permissions: Set(root); groups with view permissions: Set(); users  with modify permissions: Set(root); groups with modify permissions: Set()
20/02/15 17:15:46 INFO Utils: Successfully started service 'sparkMaster' on port 7077.
20/02/15 17:15:46 INFO Master: Starting Spark master at spark://172.21.113.119:7077
20/02/15 17:15:46 INFO Master: Running Spark version 2.4.4
20/02/15 17:15:46 INFO Utils: Successfully started service 'MasterUI' on port 8080.
20/02/15 17:15:46 INFO MasterWebUI: Bound MasterWebUI to 0.0.0.0, and started at http://ingest2.adcm.orangecm:8080
20/02/15 17:15:46 INFO Master: I have been elected leader! New state: ALIVE
20/02/15 17:15:51 INFO Master: Registering worker 172.21.113.119:37994 with 32 cores, 61.8 GB RAM
20/02/15 17:19:01 INFO Master: Registering worker 172.21.113.120:44767 with 32 cores, 61.8 GB RAM
20/02/15 17:19:39 INFO Master: Registering app org.apache.spark.ui.DeltaPipeline
20/02/15 17:19:39 INFO Master: Registered app org.apache.spark.ui.DeltaPipeline with ID app-20200215171939-0000
20/02/15 17:19:39 INFO Master: Launching executor app-20200215171939-0000/0 on worker worker-20200215171550-172.21.113.119-37994
20/02/15 17:19:40 INFO Master: Launching executor app-20200215171939-0000/1 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:19:43 INFO Master: Removing executor app-20200215171939-0000/1 because it is EXITED
20/02/15 17:19:43 INFO Master: Launching executor app-20200215171939-0000/2 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:19:47 INFO Master: Removing executor app-20200215171939-0000/2 because it is EXITED
20/02/15 17:19:47 INFO Master: Launching executor app-20200215171939-0000/3 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:19:50 INFO Master: Removing executor app-20200215171939-0000/3 because it is EXITED
20/02/15 17:19:50 INFO Master: Launching executor app-20200215171939-0000/4 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:19:54 INFO Master: Removing executor app-20200215171939-0000/4 because it is EXITED
20/02/15 17:19:54 INFO Master: Launching executor app-20200215171939-0000/5 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:19:57 INFO Master: Removing executor app-20200215171939-0000/5 because it is EXITED
20/02/15 17:19:57 INFO Master: Launching executor app-20200215171939-0000/6 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:20:00 INFO Master: Removing executor app-20200215171939-0000/6 because it is EXITED
20/02/15 17:20:00 INFO Master: Launching executor app-20200215171939-0000/7 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:20:04 INFO Master: Removing executor app-20200215171939-0000/7 because it is EXITED
20/02/15 17:20:04 INFO Master: Launching executor app-20200215171939-0000/8 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:20:07 INFO Master: Removing executor app-20200215171939-0000/8 because it is EXITED
20/02/15 17:20:07 INFO Master: Launching executor app-20200215171939-0000/9 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:20:10 INFO Master: Removing executor app-20200215171939-0000/9 because it is EXITED
20/02/15 17:20:10 INFO Master: Launching executor app-20200215171939-0000/10 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:20:12 INFO Master: Received unregister request from application app-20200215171939-0000
20/02/15 17:20:12 INFO Master: Removing app app-20200215171939-0000
20/02/15 17:20:12 INFO Master: 172.21.113.119:42912 got disassociated, removing it.
20/02/15 17:20:12 INFO Master: ingest2.adcm.orangecm:33195 got disassociated, removing it.
20/02/15 17:20:12 WARN Master: Got status update for unknown executor app-20200215171939-0000/10
20/02/15 17:20:12 WARN Master: Got status update for unknown executor app-20200215171939-0000/0
20/02/15 17:21:22 INFO Master: Registering app org.apache.spark.ui.DeltaPipeline
20/02/15 17:21:22 INFO Master: Registered app org.apache.spark.ui.DeltaPipeline with ID app-20200215172122-0001
20/02/15 17:21:22 INFO Master: Launching executor app-20200215172122-0001/0 on worker worker-20200215171550-172.21.113.119-37994
20/02/15 17:21:22 INFO Master: Launching executor app-20200215172122-0001/1 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:21:25 INFO Master: Removing executor app-20200215172122-0001/1 because it is EXITED
20/02/15 17:21:25 INFO Master: Launching executor app-20200215172122-0001/2 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:21:29 INFO Master: Removing executor app-20200215172122-0001/2 because it is EXITED
20/02/15 17:21:29 INFO Master: Launching executor app-20200215172122-0001/3 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:21:32 INFO Master: Removing executor app-20200215172122-0001/3 because it is EXITED
20/02/15 17:21:32 INFO Master: Launching executor app-20200215172122-0001/4 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:21:35 INFO Master: Removing executor app-20200215172122-0001/4 because it is EXITED
20/02/15 17:21:35 INFO Master: Launching executor app-20200215172122-0001/5 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:21:38 INFO Master: Removing executor app-20200215172122-0001/5 because it is EXITED
20/02/15 17:21:38 INFO Master: Launching executor app-20200215172122-0001/6 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:21:42 INFO Master: Removing executor app-20200215172122-0001/6 because it is EXITED
20/02/15 17:21:42 INFO Master: Launching executor app-20200215172122-0001/7 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:21:45 INFO Master: Removing executor app-20200215172122-0001/7 because it is EXITED
20/02/15 17:21:45 INFO Master: Launching executor app-20200215172122-0001/8 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:21:48 INFO Master: Removing executor app-20200215172122-0001/8 because it is EXITED
20/02/15 17:21:48 INFO Master: Launching executor app-20200215172122-0001/9 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:21:51 INFO Master: Removing executor app-20200215172122-0001/9 because it is EXITED
20/02/15 17:21:51 INFO Master: Launching executor app-20200215172122-0001/10 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:21:54 INFO Master: Removing executor app-20200215172122-0001/10 because it is EXITED
20/02/15 17:21:54 INFO Master: Launching executor app-20200215172122-0001/11 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:21:58 INFO Master: Removing executor app-20200215172122-0001/11 because it is EXITED
20/02/15 17:21:58 INFO Master: Launching executor app-20200215172122-0001/12 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:22:01 INFO Master: Removing executor app-20200215172122-0001/12 because it is EXITED
20/02/15 17:22:01 INFO Master: Launching executor app-20200215172122-0001/13 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:22:04 INFO Master: Removing executor app-20200215172122-0001/13 because it is EXITED
20/02/15 17:22:04 INFO Master: Launching executor app-20200215172122-0001/14 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:22:08 INFO Master: Removing executor app-20200215172122-0001/14 because it is EXITED
20/02/15 17:22:08 INFO Master: Launching executor app-20200215172122-0001/15 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:22:11 INFO Master: Removing executor app-20200215172122-0001/15 because it is EXITED
20/02/15 17:22:11 INFO Master: Launching executor app-20200215172122-0001/16 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:22:15 INFO Master: Removing executor app-20200215172122-0001/16 because it is EXITED
20/02/15 17:22:15 INFO Master: Launching executor app-20200215172122-0001/17 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:22:18 INFO Master: Removing executor app-20200215172122-0001/17 because it is EXITED
20/02/15 17:22:18 INFO Master: Launching executor app-20200215172122-0001/18 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:22:23 INFO Master: Removing executor app-20200215172122-0001/18 because it is EXITED
20/02/15 17:22:23 INFO Master: Launching executor app-20200215172122-0001/19 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:22:27 INFO Master: Removing executor app-20200215172122-0001/19 because it is EXITED
20/02/15 17:22:27 INFO Master: Launching executor app-20200215172122-0001/20 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:22:31 INFO Master: Removing executor app-20200215172122-0001/20 because it is EXITED
20/02/15 17:22:31 INFO Master: Launching executor app-20200215172122-0001/21 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:22:34 INFO Master: Removing executor app-20200215172122-0001/21 because it is EXITED
20/02/15 17:22:34 INFO Master: Launching executor app-20200215172122-0001/22 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:22:38 INFO Master: Removing executor app-20200215172122-0001/22 because it is EXITED
20/02/15 17:22:38 INFO Master: Launching executor app-20200215172122-0001/23 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:22:42 INFO Master: Removing executor app-20200215172122-0001/23 because it is EXITED
20/02/15 17:22:42 INFO Master: Launching executor app-20200215172122-0001/24 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:22:46 INFO Master: Removing executor app-20200215172122-0001/24 because it is EXITED
20/02/15 17:22:46 INFO Master: Launching executor app-20200215172122-0001/25 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:22:49 INFO Master: Removing executor app-20200215172122-0001/25 because it is EXITED
20/02/15 17:22:49 INFO Master: Launching executor app-20200215172122-0001/26 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:22:53 INFO Master: Removing executor app-20200215172122-0001/26 because it is EXITED
20/02/15 17:22:53 INFO Master: Launching executor app-20200215172122-0001/27 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:22:56 INFO Master: Removing executor app-20200215172122-0001/27 because it is EXITED
20/02/15 17:22:56 INFO Master: Launching executor app-20200215172122-0001/28 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:23:00 INFO Master: Removing executor app-20200215172122-0001/28 because it is EXITED
20/02/15 17:23:00 INFO Master: Launching executor app-20200215172122-0001/29 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:23:04 INFO Master: Removing executor app-20200215172122-0001/29 because it is EXITED
20/02/15 17:23:04 INFO Master: Launching executor app-20200215172122-0001/30 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:23:07 INFO Master: Removing executor app-20200215172122-0001/30 because it is EXITED
20/02/15 17:23:07 INFO Master: Launching executor app-20200215172122-0001/31 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:23:11 INFO Master: Removing executor app-20200215172122-0001/31 because it is EXITED
20/02/15 17:23:11 INFO Master: Launching executor app-20200215172122-0001/32 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:23:14 INFO Master: Removing executor app-20200215172122-0001/32 because it is EXITED
20/02/15 17:23:14 INFO Master: Launching executor app-20200215172122-0001/33 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:23:17 INFO Master: Removing executor app-20200215172122-0001/33 because it is EXITED
20/02/15 17:23:17 INFO Master: Launching executor app-20200215172122-0001/34 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:23:20 INFO Master: Removing executor app-20200215172122-0001/34 because it is EXITED
20/02/15 17:23:20 INFO Master: Launching executor app-20200215172122-0001/35 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:23:24 INFO Master: Removing executor app-20200215172122-0001/35 because it is EXITED
20/02/15 17:23:24 INFO Master: Launching executor app-20200215172122-0001/36 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:23:27 INFO Master: Removing executor app-20200215172122-0001/36 because it is EXITED
20/02/15 17:23:27 INFO Master: Launching executor app-20200215172122-0001/37 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:23:30 INFO Master: Removing executor app-20200215172122-0001/37 because it is EXITED
20/02/15 17:23:30 INFO Master: Launching executor app-20200215172122-0001/38 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:23:34 INFO Master: Removing executor app-20200215172122-0001/38 because it is EXITED
20/02/15 17:23:34 INFO Master: Launching executor app-20200215172122-0001/39 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:23:37 INFO Master: Removing executor app-20200215172122-0001/39 because it is EXITED
20/02/15 17:23:37 INFO Master: Launching executor app-20200215172122-0001/40 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:23:40 INFO Master: Removing executor app-20200215172122-0001/40 because it is EXITED
20/02/15 17:23:40 INFO Master: Launching executor app-20200215172122-0001/41 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:23:44 INFO Master: Removing executor app-20200215172122-0001/41 because it is EXITED
20/02/15 17:23:44 INFO Master: Launching executor app-20200215172122-0001/42 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:23:47 INFO Master: Removing executor app-20200215172122-0001/42 because it is EXITED
20/02/15 17:23:47 INFO Master: Launching executor app-20200215172122-0001/43 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:23:50 INFO Master: Removing executor app-20200215172122-0001/43 because it is EXITED
20/02/15 17:23:50 INFO Master: Launching executor app-20200215172122-0001/44 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:23:53 INFO Master: Removing executor app-20200215172122-0001/44 because it is EXITED
20/02/15 17:23:53 INFO Master: Launching executor app-20200215172122-0001/45 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:23:57 INFO Master: Removing executor app-20200215172122-0001/45 because it is EXITED
20/02/15 17:23:57 INFO Master: Launching executor app-20200215172122-0001/46 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:24:00 INFO Master: Removing executor app-20200215172122-0001/46 because it is EXITED
20/02/15 17:24:00 INFO Master: Launching executor app-20200215172122-0001/47 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:24:03 INFO Master: Removing executor app-20200215172122-0001/47 because it is EXITED
20/02/15 17:24:03 INFO Master: Launching executor app-20200215172122-0001/48 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:24:07 INFO Master: Removing executor app-20200215172122-0001/48 because it is EXITED
20/02/15 17:24:07 INFO Master: Launching executor app-20200215172122-0001/49 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:24:10 INFO Master: Removing executor app-20200215172122-0001/49 because it is EXITED
20/02/15 17:24:10 INFO Master: Launching executor app-20200215172122-0001/50 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:24:13 INFO Master: Removing executor app-20200215172122-0001/50 because it is EXITED
20/02/15 17:24:13 INFO Master: Launching executor app-20200215172122-0001/51 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:24:14 INFO Master: Received unregister request from application app-20200215172122-0001
20/02/15 17:24:14 INFO Master: Removing app app-20200215172122-0001
20/02/15 17:24:14 WARN Master: Got status update for unknown executor app-20200215172122-0001/51
20/02/15 17:24:14 INFO Master: 172.21.113.119:42924 got disassociated, removing it.
20/02/15 17:24:14 INFO Master: ingest2.adcm.orangecm:33237 got disassociated, removing it.
20/02/15 17:24:14 WARN Master: Got status update for unknown executor app-20200215172122-0001/0
</code>```

Finally, second executor logs (from $SPARK_HOME/logs/spark-root-org.apache.spark.deploy.worker.Worker-1-172.21.113.1.out)

```<code>Spark Command: /usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.131-11.b12.el7.x86_64/bin/java -cp /spark/spark-2.4.4/conf/:/spark/spark-2.4.4/assembly/target/scala-2.11/jars/* -Xmx1g org.apache.spark.deploy.worker.Worker --webui-port 8081 spark://172.21.113.119:7077
========================================
Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
20/02/15 17:18:54 INFO Worker: Started daemon with process name: 3448@ingest2.adcm.orangecm
20/02/15 17:18:54 INFO SignalUtils: Registered signal handler for TERM
20/02/15 17:18:54 INFO SignalUtils: Registered signal handler for HUP
20/02/15 17:18:54 INFO SignalUtils: Registered signal handler for INT
20/02/15 17:18:55 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
20/02/15 17:18:56 INFO SecurityManager: Changing view acls to: root
20/02/15 17:18:56 INFO SecurityManager: Changing modify acls to: root
20/02/15 17:18:56 INFO SecurityManager: Changing view acls groups to:
20/02/15 17:18:56 INFO SecurityManager: Changing modify acls groups to:
20/02/15 17:18:56 INFO SecurityManager: SecurityManager: authentication disabled; ui acls disabled; users  with view permissions: Set(root); groups with view permissions: Set(); users  with modify permissions: Set(root); groups with modify permissions: Set()
20/02/15 17:18:57 INFO Utils: Successfully started service 'sparkWorker' on port 44767.
20/02/15 17:18:57 INFO Worker: Starting Spark worker 172.21.113.120:44767 with 32 cores, 61.8 GB RAM
20/02/15 17:18:57 INFO Worker: Running Spark version 2.4.4
20/02/15 17:18:57 INFO Worker: Spark home: /spark/spark-2.4.4
20/02/15 17:18:58 INFO Utils: Successfully started service 'WorkerUI' on port 8081.
20/02/15 17:18:58 INFO WorkerWebUI: Bound WorkerWebUI to 0.0.0.0, and started at http://ingest2.adcm.orangecm:8081
20/02/15 17:18:58 INFO Worker: Connecting to master 172.21.113.119:7077...
20/02/15 17:18:58 INFO TransportClientFactory: Successfully created connection to /172.21.113.119:7077 after 73 ms (0 ms spent in bootstraps)
20/02/15 17:18:58 INFO Worker: Successfully registered with master spark://172.21.113.119:7077
20/02/15 17:19:37 INFO Worker: Asked to launch executor app-20200215171939-0000/1 for org.apache.spark.ui.DeltaPipeline
20/02/15 17:19:37 INFO SecurityManager: Changing view acls to: root
20/02/15 17:19:37 INFO SecurityManager: Changing modify acls to: root
20/02/15 17:19:37 INFO SecurityManager: Changing view acls groups to:
20/02/15 17:19:37 INFO SecurityManager: Changing modify acls groups to:
20/02/15 17:19:37 INFO SecurityManager: SecurityManager: authentication disabled; ui acls disabled; users  with view permissions: Set(root); groups with view permissions: Set(); users  with modify permissions: Set(root); groups with modify permissions: Set()
20/02/15 17:19:37 INFO ExecutorRunner: Launch command: "/usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.131-11.b12.el7.x86_64/bin/java" "-cp" "/spark/spark-2.4.4/conf/:/spark/spark-2.4.4/assembly/target/scala-2.11/jars/*" "-Xmx24576M" "-Dspark.driver.port=33195" "org.apache.spark.executor.CoarseGrainedExecutorBackend" "--driver-url" "spark://CoarseGrainedScheduler@ingest2.adcm.orangecm:33195" "--executor-id" "1" "--hostname" "172.21.113.120" "--cores" "32" "--app-id" "app-20200215171939-0000" "--worker-url" "spark://Worker@172.21.113.120:44767"
20/02/15 17:19:41 INFO Worker: Executor app-20200215171939-0000/1 finished with state EXITED message Command exited with code 1 exitStatus 1
20/02/15 17:19:41 INFO ExternalShuffleBlockResolver: Clean up non-shuffle files associated with the finished executor 1
20/02/15 17:19:41 INFO ExternalShuffleBlockResolver: Executor is not registered (appId=app-20200215171939-0000, execId=1)
</code>```

Any idea of what is going wrong ?

答:
I realized that the logs were more detailed on spark ui.

The problem was the connectivity of the two nodes. I just disabled the firewall between these nodes

Title: Spark executors always EXIT

Body:
I have a 2 nodes cluster with spark installed as follows:

First node : A master and one worker

Second node : Another worker

Each time I start the cluster with the command $SPARK_HOME/sbin/start-all.sh, I encounter an anomaly in the second worker; Executors are created and closed immediately. This results in an abnormal multiplication of the number of executors and very often an error in execution when I submit jobs.

in master logs, we can see it launching and removing second executor (172.21.113.120)

Spark Command: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.222.b03-1.el7.x86_64/bin/java -cp /spark/spark-2.4.4/conf/:/spark/spark-2.4.4/assembly/target/scala-2.11/jars/* -Xmx1g org.apache.spark.deploy.master.Master --host 172.21.113.119 --port 7077 --webui-port 8080
========================================
Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
20/02/15 17:15:44 INFO Master: Started daemon with process name: 6678@ingest1.adcm.orangecm
20/02/15 17:15:44 INFO SignalUtils: Registered signal handler for TERM
20/02/15 17:15:44 INFO SignalUtils: Registered signal handler for HUP
20/02/15 17:15:44 INFO SignalUtils: Registered signal handler for INT
20/02/15 17:15:44 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
20/02/15 17:15:45 INFO SecurityManager: Changing view acls to: root
20/02/15 17:15:45 INFO SecurityManager: Changing modify acls to: root
20/02/15 17:15:45 INFO SecurityManager: Changing view acls groups to:
20/02/15 17:15:45 INFO SecurityManager: Changing modify acls groups to:
20/02/15 17:15:45 INFO SecurityManager: SecurityManager: authentication disabled; ui acls disabled; users  with view permissions: Set(root); groups with view permissions: Set(); users  with modify permissions: Set(root); groups with modify permissions: Set()
20/02/15 17:15:46 INFO Utils: Successfully started service 'sparkMaster' on port 7077.
20/02/15 17:15:46 INFO Master: Starting Spark master at spark://172.21.113.119:7077
20/02/15 17:15:46 INFO Master: Running Spark version 2.4.4
20/02/15 17:15:46 INFO Utils: Successfully started service 'MasterUI' on port 8080.
20/02/15 17:15:46 INFO MasterWebUI: Bound MasterWebUI to 0.0.0.0, and started at http://ingest2.adcm.orangecm:8080
20/02/15 17:15:46 INFO Master: I have been elected leader! New state: ALIVE
20/02/15 17:15:51 INFO Master: Registering worker 172.21.113.119:37994 with 32 cores, 61.8 GB RAM
20/02/15 17:19:01 INFO Master: Registering worker 172.21.113.120:44767 with 32 cores, 61.8 GB RAM
20/02/15 17:19:39 INFO Master: Registering app org.apache.spark.ui.DeltaPipeline
20/02/15 17:19:39 INFO Master: Registered app org.apache.spark.ui.DeltaPipeline with ID app-20200215171939-0000
20/02/15 17:19:39 INFO Master: Launching executor app-20200215171939-0000/0 on worker worker-20200215171550-172.21.113.119-37994
20/02/15 17:19:40 INFO Master: Launching executor app-20200215171939-0000/1 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:19:43 INFO Master: Removing executor app-20200215171939-0000/1 because it is EXITED
20/02/15 17:19:43 INFO Master: Launching executor app-20200215171939-0000/2 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:19:47 INFO Master: Removing executor app-20200215171939-0000/2 because it is EXITED
20/02/15 17:19:47 INFO Master: Launching executor app-20200215171939-0000/3 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:19:50 INFO Master: Removing executor app-20200215171939-0000/3 because it is EXITED
20/02/15 17:19:50 INFO Master: Launching executor app-20200215171939-0000/4 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:19:54 INFO Master: Removing executor app-20200215171939-0000/4 because it is EXITED
20/02/15 17:19:54 INFO Master: Launching executor app-20200215171939-0000/5 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:19:57 INFO Master: Removing executor app-20200215171939-0000/5 because it is EXITED
20/02/15 17:19:57 INFO Master: Launching executor app-20200215171939-0000/6 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:20:00 INFO Master: Removing executor app-20200215171939-0000/6 because it is EXITED
20/02/15 17:20:00 INFO Master: Launching executor app-20200215171939-0000/7 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:20:04 INFO Master: Removing executor app-20200215171939-0000/7 because it is EXITED
20/02/15 17:20:04 INFO Master: Launching executor app-20200215171939-0000/8 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:20:07 INFO Master: Removing executor app-20200215171939-0000/8 because it is EXITED
20/02/15 17:20:07 INFO Master: Launching executor app-20200215171939-0000/9 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:20:10 INFO Master: Removing executor app-20200215171939-0000/9 because it is EXITED
20/02/15 17:20:10 INFO Master: Launching executor app-20200215171939-0000/10 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:20:12 INFO Master: Received unregister request from application app-20200215171939-0000
20/02/15 17:20:12 INFO Master: Removing app app-20200215171939-0000
20/02/15 17:20:12 INFO Master: 172.21.113.119:42912 got disassociated, removing it.
20/02/15 17:20:12 INFO Master: ingest2.adcm.orangecm:33195 got disassociated, removing it.
20/02/15 17:20:12 WARN Master: Got status update for unknown executor app-20200215171939-0000/10
20/02/15 17:20:12 WARN Master: Got status update for unknown executor app-20200215171939-0000/0
20/02/15 17:21:22 INFO Master: Registering app org.apache.spark.ui.DeltaPipeline
20/02/15 17:21:22 INFO Master: Registered app org.apache.spark.ui.DeltaPipeline with ID app-20200215172122-0001
20/02/15 17:21:22 INFO Master: Launching executor app-20200215172122-0001/0 on worker worker-20200215171550-172.21.113.119-37994
20/02/15 17:21:22 INFO Master: Launching executor app-20200215172122-0001/1 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:21:25 INFO Master: Removing executor app-20200215172122-0001/1 because it is EXITED
20/02/15 17:21:25 INFO Master: Launching executor app-20200215172122-0001/2 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:21:29 INFO Master: Removing executor app-20200215172122-0001/2 because it is EXITED
20/02/15 17:21:29 INFO Master: Launching executor app-20200215172122-0001/3 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:21:32 INFO Master: Removing executor app-20200215172122-0001/3 because it is EXITED
20/02/15 17:21:32 INFO Master: Launching executor app-20200215172122-0001/4 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:21:35 INFO Master: Removing executor app-20200215172122-0001/4 because it is EXITED
20/02/15 17:21:35 INFO Master: Launching executor app-20200215172122-0001/5 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:21:38 INFO Master: Removing executor app-20200215172122-0001/5 because it is EXITED
20/02/15 17:21:38 INFO Master: Launching executor app-20200215172122-0001/6 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:21:42 INFO Master: Removing executor app-20200215172122-0001/6 because it is EXITED
20/02/15 17:21:42 INFO Master: Launching executor app-20200215172122-0001/7 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:21:45 INFO Master: Removing executor app-20200215172122-0001/7 because it is EXITED
20/02/15 17:21:45 INFO Master: Launching executor app-20200215172122-0001/8 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:21:48 INFO Master: Removing executor app-20200215172122-0001/8 because it is EXITED
20/02/15 17:21:48 INFO Master: Launching executor app-20200215172122-0001/9 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:21:51 INFO Master: Removing executor app-20200215172122-0001/9 because it is EXITED
20/02/15 17:21:51 INFO Master: Launching executor app-20200215172122-0001/10 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:21:54 INFO Master: Removing executor app-20200215172122-0001/10 because it is EXITED
20/02/15 17:21:54 INFO Master: Launching executor app-20200215172122-0001/11 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:21:58 INFO Master: Removing executor app-20200215172122-0001/11 because it is EXITED
20/02/15 17:21:58 INFO Master: Launching executor app-20200215172122-0001/12 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:22:01 INFO Master: Removing executor app-20200215172122-0001/12 because it is EXITED
20/02/15 17:22:01 INFO Master: Launching executor app-20200215172122-0001/13 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:22:04 INFO Master: Removing executor app-20200215172122-0001/13 because it is EXITED
20/02/15 17:22:04 INFO Master: Launching executor app-20200215172122-0001/14 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:22:08 INFO Master: Removing executor app-20200215172122-0001/14 because it is EXITED
20/02/15 17:22:08 INFO Master: Launching executor app-20200215172122-0001/15 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:22:11 INFO Master: Removing executor app-20200215172122-0001/15 because it is EXITED
20/02/15 17:22:11 INFO Master: Launching executor app-20200215172122-0001/16 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:22:15 INFO Master: Removing executor app-20200215172122-0001/16 because it is EXITED
20/02/15 17:22:15 INFO Master: Launching executor app-20200215172122-0001/17 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:22:18 INFO Master: Removing executor app-20200215172122-0001/17 because it is EXITED
20/02/15 17:22:18 INFO Master: Launching executor app-20200215172122-0001/18 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:22:23 INFO Master: Removing executor app-20200215172122-0001/18 because it is EXITED
20/02/15 17:22:23 INFO Master: Launching executor app-20200215172122-0001/19 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:22:27 INFO Master: Removing executor app-20200215172122-0001/19 because it is EXITED
20/02/15 17:22:27 INFO Master: Launching executor app-20200215172122-0001/20 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:22:31 INFO Master: Removing executor app-20200215172122-0001/20 because it is EXITED
20/02/15 17:22:31 INFO Master: Launching executor app-20200215172122-0001/21 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:22:34 INFO Master: Removing executor app-20200215172122-0001/21 because it is EXITED
20/02/15 17:22:34 INFO Master: Launching executor app-20200215172122-0001/22 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:22:38 INFO Master: Removing executor app-20200215172122-0001/22 because it is EXITED
20/02/15 17:22:38 INFO Master: Launching executor app-20200215172122-0001/23 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:22:42 INFO Master: Removing executor app-20200215172122-0001/23 because it is EXITED
20/02/15 17:22:42 INFO Master: Launching executor app-20200215172122-0001/24 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:22:46 INFO Master: Removing executor app-20200215172122-0001/24 because it is EXITED
20/02/15 17:22:46 INFO Master: Launching executor app-20200215172122-0001/25 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:22:49 INFO Master: Removing executor app-20200215172122-0001/25 because it is EXITED
20/02/15 17:22:49 INFO Master: Launching executor app-20200215172122-0001/26 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:22:53 INFO Master: Removing executor app-20200215172122-0001/26 because it is EXITED
20/02/15 17:22:53 INFO Master: Launching executor app-20200215172122-0001/27 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:22:56 INFO Master: Removing executor app-20200215172122-0001/27 because it is EXITED
20/02/15 17:22:56 INFO Master: Launching executor app-20200215172122-0001/28 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:23:00 INFO Master: Removing executor app-20200215172122-0001/28 because it is EXITED
20/02/15 17:23:00 INFO Master: Launching executor app-20200215172122-0001/29 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:23:04 INFO Master: Removing executor app-20200215172122-0001/29 because it is EXITED
20/02/15 17:23:04 INFO Master: Launching executor app-20200215172122-0001/30 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:23:07 INFO Master: Removing executor app-20200215172122-0001/30 because it is EXITED
20/02/15 17:23:07 INFO Master: Launching executor app-20200215172122-0001/31 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:23:11 INFO Master: Removing executor app-20200215172122-0001/31 because it is EXITED
20/02/15 17:23:11 INFO Master: Launching executor app-20200215172122-0001/32 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:23:14 INFO Master: Removing executor app-20200215172122-0001/32 because it is EXITED
20/02/15 17:23:14 INFO Master: Launching executor app-20200215172122-0001/33 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:23:17 INFO Master: Removing executor app-20200215172122-0001/33 because it is EXITED
20/02/15 17:23:17 INFO Master: Launching executor app-20200215172122-0001/34 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:23:20 INFO Master: Removing executor app-20200215172122-0001/34 because it is EXITED
20/02/15 17:23:20 INFO Master: Launching executor app-20200215172122-0001/35 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:23:24 INFO Master: Removing executor app-20200215172122-0001/35 because it is EXITED
20/02/15 17:23:24 INFO Master: Launching executor app-20200215172122-0001/36 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:23:27 INFO Master: Removing executor app-20200215172122-0001/36 because it is EXITED
20/02/15 17:23:27 INFO Master: Launching executor app-20200215172122-0001/37 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:23:30 INFO Master: Removing executor app-20200215172122-0001/37 because it is EXITED
20/02/15 17:23:30 INFO Master: Launching executor app-20200215172122-0001/38 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:23:34 INFO Master: Removing executor app-20200215172122-0001/38 because it is EXITED
20/02/15 17:23:34 INFO Master: Launching executor app-20200215172122-0001/39 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:23:37 INFO Master: Removing executor app-20200215172122-0001/39 because it is EXITED
20/02/15 17:23:37 INFO Master: Launching executor app-20200215172122-0001/40 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:23:40 INFO Master: Removing executor app-20200215172122-0001/40 because it is EXITED
20/02/15 17:23:40 INFO Master: Launching executor app-20200215172122-0001/41 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:23:44 INFO Master: Removing executor app-20200215172122-0001/41 because it is EXITED
20/02/15 17:23:44 INFO Master: Launching executor app-20200215172122-0001/42 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:23:47 INFO Master: Removing executor app-20200215172122-0001/42 because it is EXITED
20/02/15 17:23:47 INFO Master: Launching executor app-20200215172122-0001/43 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:23:50 INFO Master: Removing executor app-20200215172122-0001/43 because it is EXITED
20/02/15 17:23:50 INFO Master: Launching executor app-20200215172122-0001/44 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:23:53 INFO Master: Removing executor app-20200215172122-0001/44 because it is EXITED
20/02/15 17:23:53 INFO Master: Launching executor app-20200215172122-0001/45 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:23:57 INFO Master: Removing executor app-20200215172122-0001/45 because it is EXITED
20/02/15 17:23:57 INFO Master: Launching executor app-20200215172122-0001/46 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:24:00 INFO Master: Removing executor app-20200215172122-0001/46 because it is EXITED
20/02/15 17:24:00 INFO Master: Launching executor app-20200215172122-0001/47 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:24:03 INFO Master: Removing executor app-20200215172122-0001/47 because it is EXITED
20/02/15 17:24:03 INFO Master: Launching executor app-20200215172122-0001/48 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:24:07 INFO Master: Removing executor app-20200215172122-0001/48 because it is EXITED
20/02/15 17:24:07 INFO Master: Launching executor app-20200215172122-0001/49 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:24:10 INFO Master: Removing executor app-20200215172122-0001/49 because it is EXITED
20/02/15 17:24:10 INFO Master: Launching executor app-20200215172122-0001/50 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:24:13 INFO Master: Removing executor app-20200215172122-0001/50 because it is EXITED
20/02/15 17:24:13 INFO Master: Launching executor app-20200215172122-0001/51 on worker worker-20200215171857-172.21.113.120-44767
20/02/15 17:24:14 INFO Master: Received unregister request from application app-20200215172122-0001
20/02/15 17:24:14 INFO Master: Removing app app-20200215172122-0001
20/02/15 17:24:14 WARN Master: Got status update for unknown executor app-20200215172122-0001/51
20/02/15 17:24:14 INFO Master: 172.21.113.119:42924 got disassociated, removing it.
20/02/15 17:24:14 INFO Master: ingest2.adcm.orangecm:33237 got disassociated, removing it.
20/02/15 17:24:14 WARN Master: Got status update for unknown executor app-20200215172122-0001/0

Finally, second executor logs (from $SPARK_HOME/logs/spark-root-org.apache.spark.deploy.worker.Worker-1-172.21.113.1.out)

Spark Command: /usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.131-11.b12.el7.x86_64/bin/java -cp /spark/spark-2.4.4/conf/:/spark/spark-2.4.4/assembly/target/scala-2.11/jars/* -Xmx1g org.apache.spark.deploy.worker.Worker --webui-port 8081 spark://172.21.113.119:7077
========================================
Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
20/02/15 17:18:54 INFO Worker: Started daemon with process name: 3448@ingest2.adcm.orangecm
20/02/15 17:18:54 INFO SignalUtils: Registered signal handler for TERM
20/02/15 17:18:54 INFO SignalUtils: Registered signal handler for HUP
20/02/15 17:18:54 INFO SignalUtils: Registered signal handler for INT
20/02/15 17:18:55 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
20/02/15 17:18:56 INFO SecurityManager: Changing view acls to: root
20/02/15 17:18:56 INFO SecurityManager: Changing modify acls to: root
20/02/15 17:18:56 INFO SecurityManager: Changing view acls groups to:
20/02/15 17:18:56 INFO SecurityManager: Changing modify acls groups to:
20/02/15 17:18:56 INFO SecurityManager: SecurityManager: authentication disabled; ui acls disabled; users  with view permissions: Set(root); groups with view permissions: Set(); users  with modify permissions: Set(root); groups with modify permissions: Set()
20/02/15 17:18:57 INFO Utils: Successfully started service 'sparkWorker' on port 44767.
20/02/15 17:18:57 INFO Worker: Starting Spark worker 172.21.113.120:44767 with 32 cores, 61.8 GB RAM
20/02/15 17:18:57 INFO Worker: Running Spark version 2.4.4
20/02/15 17:18:57 INFO Worker: Spark home: /spark/spark-2.4.4
20/02/15 17:18:58 INFO Utils: Successfully started service 'WorkerUI' on port 8081.
20/02/15 17:18:58 INFO WorkerWebUI: Bound WorkerWebUI to 0.0.0.0, and started at http://ingest2.adcm.orangecm:8081
20/02/15 17:18:58 INFO Worker: Connecting to master 172.21.113.119:7077...
20/02/15 17:18:58 INFO TransportClientFactory: Successfully created connection to /172.21.113.119:7077 after 73 ms (0 ms spent in bootstraps)
20/02/15 17:18:58 INFO Worker: Successfully registered with master spark://172.21.113.119:7077
20/02/15 17:19:37 INFO Worker: Asked to launch executor app-20200215171939-0000/1 for org.apache.spark.ui.DeltaPipeline
20/02/15 17:19:37 INFO SecurityManager: Changing view acls to: root
20/02/15 17:19:37 INFO SecurityManager: Changing modify acls to: root
20/02/15 17:19:37 INFO SecurityManager: Changing view acls groups to:
20/02/15 17:19:37 INFO SecurityManager: Changing modify acls groups to:
20/02/15 17:19:37 INFO SecurityManager: SecurityManager: authentication disabled; ui acls disabled; users  with view permissions: Set(root); groups with view permissions: Set(); users  with modify permissions: Set(root); groups with modify permissions: Set()
20/02/15 17:19:37 INFO ExecutorRunner: Launch command: "/usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.131-11.b12.el7.x86_64/bin/java" "-cp" "/spark/spark-2.4.4/conf/:/spark/spark-2.4.4/assembly/target/scala-2.11/jars/*" "-Xmx24576M" "-Dspark.driver.port=33195" "org.apache.spark.executor.CoarseGrainedExecutorBackend" "--driver-url" "spark://CoarseGrainedScheduler@ingest2.adcm.orangecm:33195" "--executor-id" "1" "--hostname" "172.21.113.120" "--cores" "32" "--app-id" "app-20200215171939-0000" "--worker-url" "spark://Worker@172.21.113.120:44767"
20/02/15 17:19:41 INFO Worker: Executor app-20200215171939-0000/1 finished with state EXITED message Command exited with code 1 exitStatus 1
20/02/15 17:19:41 INFO ExternalShuffleBlockResolver: Clean up non-shuffle files associated with the finished executor 1
20/02/15 17:19:41 INFO ExternalShuffleBlockResolver: Executor is not registered (appId=app-20200215171939-0000, execId=1)

Any idea of what is going wrong ?


来源: stackexchange

问:
Which Access Levels to use to make enum accessible only for that Project
I am trying to import two Xcode Project in one. Now both the projects have an enum BakerType defined. This is creating a conflict.

Is there any way to restrict the scope of enum to that project only?

答: You can use internal access that enables entities to be used within any source file from their defining module, but not in any source file outside of that module.

ContentLicense: CC BY-SA 4.0


问:
How do I set the class path on Linux?
I need an answer for the question in the title.

Thanks.

答:
If you mean the Java classpath (from your tag), then this is only different from Windows in terms of path-separators (: instead of ;). For example

```<code>java -classpath /mydir/mylib.jar:/otherdir/otherlib.jar com.MyProgram -Xmx64m
</code>```

ContentLicense: CC BY-SA 2.5

Title: How do I set the class path on Linux?

LastEditorDisplayName: Andrew Hare

Body:
If you mean the Java classpath (from your tag), then this is only different from Windows in terms of path-separators (: instead of ;). For example

java -classpath /mydir/mylib.jar:/otherdir/otherlib.jar com.MyProgram -Xmx64m


问:
How can I play my lottie animation with an OnTapGesture event?
I followed MengTo's example of how to get a Lottie animation to play within SwiftUI. (https://www.youtube.com/watch?v=fVehE3Jf7K0) However, I was wondering if anyone could help me understand how to initially present the first frame of the animation, but only have the animation play once a user taps on it in a button format.

My current LottieButton file is as follows:

```<code>import SwiftUI
import Lottie

struct LottieButton: UIViewRepresentable {
/// Create a button.
let animationButton = AnimatedButton()
var filename = "LottieLogo2"

func makeUIView(context: UIViewRepresentableContext<LottieButton>) -> UIView {
    let view = UIView()

    let animation = Animation.named(filename)
    animationButton.animation = animation
    animationButton.contentMode = .scaleAspectFit

    animationButton.translatesAutoresizingMaskIntoConstraints = false
    view.addSubview(animationButton)

    animationButton.clipsToBounds = false
       /// Set animation play ranges for touch states
    animationButton.setPlayRange(fromMarker: "touchDownStart", toMarker: "touchDownEnd", event: .touchUpInside)
       animationButton.setPlayRange(fromMarker: "touchDownEnd", toMarker: "touchUpCancel", event: .touchUpOutside)
       animationButton.setPlayRange(fromMarker: "touchDownEnd", toMarker: "touchUpEnd", event: .touchUpInside)

    NSLayoutConstraint.activate([
        animationButton.heightAnchor.constraint(equalTo: view.heightAnchor),
        animationButton.widthAnchor.constraint(equalTo: view.widthAnchor),
    ])

    return view

}

func updateUIView(_ uiView: UIView, context: UIViewRepresentableContext<LottieButton>) {

    }
}
</code>```

And then I just have a simple view that is displaying the animation:

```<code>struct InboxView: View {
var body: some View {
    VStack {
        Button(action: {}) {
        LottieButton(filename: "inbox-notification")
        .frame(width: 100)
            }
        }
    }
}
</code>```

答:
After digging deeper into the Lottie documentation, I saw that there was commented code that showed how to implement an animated button. I edited the code above in LottieButton to set up the button and then I was able to place it into a view and get it to animate on tap. Here is the working code:</p>
```<code>struct InboxView: View {
var body: some View {
    VStack {
        LottieButton(filename: "inbox-notification")
        .frame(width: 100)
            }
    }
}
</code>```

Body:
I followed MengTo's example of how to get a Lottie animation to play within SwiftUI. (https://www.youtube.com/watch?v=fVehE3Jf7K0) However, I was wondering if anyone could help me understand how to initially present the first frame of the animation, but only have the animation play once a user taps on it in a button format.

My current LottieButton file is as follows:

import SwiftUI
import Lottie

struct LottieButton: UIViewRepresentable {
/// Create a button.
let animationButton = AnimatedButton()
var filename = "LottieLogo2"

func makeUIView(context: UIViewRepresentableContext<LottieButton>) -> UIView {
    let view = UIView()

    let animation = Animation.named(filename)
    animationButton.animation = animation
    animationButton.contentMode = .scaleAspectFit

    animationButton.translatesAutoresizingMaskIntoConstraints = false
    view.addSubview(animationButton)

    animationButton.clipsToBounds = false
       /// Set animation play ranges for touch states
    animationButton.setPlayRange(fromMarker: "touchDownStart", toMarker: "touchDownEnd", event: .touchUpInside)
       animationButton.setPlayRange(fromMarker: "touchDownEnd", toMarker: "touchUpCancel", event: .touchUpOutside)
       animationButton.setPlayRange(fromMarker: "touchDownEnd", toMarker: "touchUpEnd", event: .touchUpInside)

    NSLayoutConstraint.activate([
        animationButton.heightAnchor.constraint(equalTo: view.heightAnchor),
        animationButton.widthAnchor.constraint(equalTo: view.widthAnchor),
    ])

    return view

}

func updateUIView(_ uiView: UIView, context: UIViewRepresentableContext<LottieButton>) {

    }
}

And then I just have a simple view that is displaying the animation:

struct InboxView: View {
var body: some View {
    VStack {
        Button(action: {}) {
        LottieButton(filename: "inbox-notification")
        .frame(width: 100)
            }
        }
    }
}

Body:
After digging deeper into the Lottie documentation, I saw that there was commented code that showed how to implement an animated button. I edited the code above in LottieButton to set up the button and then I was able to place it into a view and get it to animate on tap. Here is the working code:

struct InboxView: View {
var body: some View {
    VStack {
        LottieButton(filename: "inbox-notification")
        .frame(width: 100)
            }
    }
}


问:
Setting multiple images to the response entity
I want to return response with multiple images to client. And in client side i want to download those images. I haven't find any method like .setEntity() for HttpServletResponse. So i have decided to add images in header fields. I am adding in following way,

```<code>File sourceFile = new File(serverLocation + "/" + filename);

servletresponse.setContentType(new MimetypesFileTypeMap().getContentType(sourceFile));
servletresponse.setContentLength((int)sourceFile.length());
servletresponse.setHeader(filename, "attachment; filename=" + URLEncoder.encode(filename, "UTF-8"));
</code>```

I am unable to download on client side. This is what i am doing on client side,

```<code>CloseableHttpResponse response = httpclient.execute(httppost);
Header[] headers = response.getAllHeaders();
            for (int i = 0; i < headers.length; i++) {
                if (headers[i].getName().equals(filename)) {
                    imagename = headers[i].getValue();
                }
            }
InputStream fileInputStream = new ByteArrayInputStream(imagename.getBytes(StandardCharsets.UTF_8));
            byte[] bufffer = new byte[512];
            while ((bufferSize = fileInputStream.read(bufffer)) > 0) {
                fileOutputStream.write(bufffer, 0, bufferSize);
            }
</code>```

However its not writing images. How can i add multiple files and download it on client side. Please help.

答:
A file name is not an image.  It’s just the text that identifies the file.

The contents of the file is a sequence of bytes which is entirely separate from the name.  This is the actual image data.

Sending the file name in the response will not send the contents.

There are two common ways to send multiple images in an HTTP response:

Send an archive containing multiple files, such as a zip file.

Send a response whose content type is multipart/mixed, as described in RFC 2046.  You can do this manually, but the classes of the javax.mail.internet package make it a lot easier.

Both approaches require the images to be in the response body, not in the headers.  Headers are only intended for (relatively) short strings, and header names have restrictions on which characters they may contain.

The zip file approach is the easiest to code:

```<code>String[] filenames = { /* ... */ };

servletresponse.setContentType("application/zip");

try (ZipOutputStream zip = new ZipOutputStream(
    servletresponse.getOutputStream())) {

    for (String filename : filenames) {
        ZipEntry entry = new ZipEntry(filename);
        zip.putNextEntry(entry);
        Files.copy(Paths.get(filename), zip);
    }
}
</code>```

The second approach requires the JavaMail API, and the Java Activation Framework API.  If you are running in a true Java EE server like GlassFish or JBoss, you have access to them already, since JavaMail and JAF are components required by the Java EE specification.

```<code>String[] filenames = { /* ... */ };

MimeMultipart multipart = new MimeMultipart("mixed");

for (String filename : filenames) {
    MimeBodyPart part = new MimeBodyPart();
    part.attachFile(filename, null, "base64");
    multipart.addBodyPart(part);
}

Properties props = new Properties();
Session session = Session.getDefaultInstance(props);
MimeMessage message = new MimeMessage(session);
message.setContent(multipart);
message.saveChanges();

servletresponse.setContentType(multipart.getContentType());
try (OutputStream out = servletresponse.getOutputStream()) {
    multipart.writeTo(out);
}
</code>```

Each approach will require different handling on the client side.  The client can just save the zip archive directly:

```<code>String home = System.getProperty("user.home");

try (InputStream content = response.getEntity().getContent()) {
    Files.copy(content, Paths.get(home, "Downloads", "images.zip"));
}
</code>```

Or, of course, you can use ZipInputStream to read the entries in the zip archive, and save each zip entry to a file whose name matches the zip entry name.

The multipart response would require an API capable of reading a MIME multipart message.  JavaMail and JAF are one such option.

Body:
I want to return response with multiple images to client. And in client side i want to download those images. I haven't find any method like .setEntity() for HttpServletResponse. So i have decided to add images in header fields. I am adding in following way,

File sourceFile = new File(serverLocation + "/" + filename);

servletresponse.setContentType(new MimetypesFileTypeMap().getContentType(sourceFile));
servletresponse.setContentLength((int)sourceFile.length());
servletresponse.setHeader(filename, "attachment; filename=" + URLEncoder.encode(filename, "UTF-8"));

I am unable to download on client side. This is what i am doing on client side,

CloseableHttpResponse response = httpclient.execute(httppost);
Header[] headers = response.getAllHeaders();
            for (int i = 0; i < headers.length; i++) {
                if (headers[i].getName().equals(filename)) {
                    imagename = headers[i].getValue();
                }
            }
InputStream fileInputStream = new ByteArrayInputStream(imagename.getBytes(StandardCharsets.UTF_8));
            byte[] bufffer = new byte[512];
            while ((bufferSize = fileInputStream.read(bufffer)) > 0) {
                fileOutputStream.write(bufffer, 0, bufferSize);
            }

However its not writing images. How can i add multiple files and download it on client side. Please help.

Body:
A file name is not an image.  It’s just the text that identifies the file.

The contents of the file is a sequence of bytes which is entirely separate from the name.  This is the actual image data.

Sending the file name in the response will not send the contents.

There are two common ways to send multiple images in an HTTP response:

Send an archive containing multiple files, such as a zip file.

Send a response whose content type is multipart/mixed, as described in RFC 2046.  You can do this manually, but the classes of the javax.mail.internet package make it a lot easier.

Both approaches require the images to be in the response body, not in the headers.  Headers are only intended for (relatively) short strings, and header names have restrictions on which characters they may contain.

The zip file approach is the easiest to code:

String[] filenames = { /* ... */ };

servletresponse.setContentType("application/zip");

try (ZipOutputStream zip = new ZipOutputStream(
    servletresponse.getOutputStream())) {

    for (String filename : filenames) {
        ZipEntry entry = new ZipEntry(filename);
        zip.putNextEntry(entry);
        Files.copy(Paths.get(filename), zip);
    }
}

The second approach requires the JavaMail API, and the Java Activation Framework API.  If you are running in a true Java EE server like GlassFish or JBoss, you have access to them already, since JavaMail and JAF are components required by the Java EE specification.

String[] filenames = { /* ... */ };

MimeMultipart multipart = new MimeMultipart("mixed");

for (String filename : filenames) {
    MimeBodyPart part = new MimeBodyPart();
    part.attachFile(filename, null, "base64");
    multipart.addBodyPart(part);
}

Properties props = new Properties();
Session session = Session.getDefaultInstance(props);
MimeMessage message = new MimeMessage(session);
message.setContent(multipart);
message.saveChanges();

servletresponse.setContentType(multipart.getContentType());
try (OutputStream out = servletresponse.getOutputStream()) {
    multipart.writeTo(out);
}

Each approach will require different handling on the client side.  The client can just save the zip archive directly:

String home = System.getProperty("user.home");

try (InputStream content = response.getEntity().getContent()) {
    Files.copy(content, Paths.get(home, "Downloads", "images.zip"));
}

Or, of course, you can use ZipInputStream to read the entries in the zip archive, and save each zip entry to a file whose name matches the zip entry name.

The multipart response would require an API capable of reading a MIME multipart message.  JavaMail and JAF are one such option.


问:
Webpage blanking after adding component tag for Angular form
I am having an issue when creating an Angular form. Whenever I include the app-name-editor tag, my entire HTML webpage goes blank and the form will not display. However, if I remove the tag, the webpage works as normal. So I am thinking there must be something wrong with my HTML code. Any insights on this would be appreciated.

I was following the guide on Angular.io and I am stuck on the part that talks about displaying the component. https://angular.io/guide/reactive-forms

Below is my code:

```<code><!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
<!-- * * * * * * * * * * * The content below * * * * * * * * * * * -->
<!-- * * * * * * * * * * is only a placeholder * * * * * * * * * * -->
<!-- * * * * * * * * * * and can be replaced. * * * * * * * * * * * -->
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
<!-- * * * * * * * * * Delete the template below * * * * * * * * * * -->
<!-- * * * * * * * to get started with your project! * * * * * * * * -->
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->

<style>
  :host {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    font-size: 14px;
    color: #333;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    margin: 8px 0;
  }

  p {
    margin: 0;
  }

  .spacer {
    flex: 1;
  }

  .toolbar {
    height: 60px;
    margin: -8px;
    display: flex;
    align-items: center;
    background-color: #1976d2;
    color: white;
    font-weight: 600;
  }

  .toolbar img {
    margin: 0 16px;
  }

  .toolbar #twitter-logo {
    height: 40px;
    margin: 0 16px;
  }

  .toolbar #twitter-logo:hover {
    opacity: 0.8;
  }

  .content {
    display: flex;
    margin: 32px auto;
    padding: 0 16px;
    max-width: 960px;
    flex-direction: column;
    align-items: center;
  }

  svg.material-icons {
    height: 24px;
    width: auto;
  }

  svg.material-icons:not(:last-child) {
    margin-right: 8px;
  }

  .card svg.material-icons path {
    fill: #888;
  }

  .card-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 16px;
  }

  .card {
    border-radius: 4px;
    border: 1px solid #eee;
    background-color: #fafafa;
    height: 40px;
    width: 200px;
    margin: 0 8px 16px;
    padding: 16px;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease-in-out;
    line-height: 24px;
  }

  .card-container .card:not(:last-child) {
    margin-right: 0;
  }

  .card.card-small {
    height: 16px;
    width: 168px;
  }

  .card-container .card:not(.highlight-card) {
    cursor: pointer;
  }

  .card-container .card:not(.highlight-card):hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 17px rgba(black, 0.35);
  }

  .card-container .card:not(.highlight-card):hover .material-icons path {
    fill: rgb(105, 103, 103);
  }

  .card.highlight-card {
    background-color: #1976d2;
    color: white;
    font-weight: 600;
    border: none;
    width: auto;
    min-width: 30%;
    position: relative;
  }

  .card.card.highlight-card span {
    margin-left: 60px;
  }

  svg#rocket {
    width: 80px;
    position: absolute;
    left: -10px;
    top: -24px;
  }

  svg#rocket-smoke {
    height: 100vh;
    position: absolute;
    top: 10px;
    right: 180px;
    z-index: -10;
  }

  a,
  a:visited,
  a:hover {
    color: #1976d2;
    text-decoration: none;
  }

  a:hover {
    color: #125699;
  }

  .terminal {
    position: relative;
    width: 80%;
    max-width: 600px;
    border-radius: 6px;
    padding-top: 45px;
    margin-top: 8px;
    overflow: hidden;
    background-color: rgb(15, 15, 16);
  }

  .terminal::before {
    content: "\2022 \2022 \2022";
    position: absolute;
    top: 0;
    left: 0;
    height: 4px;
    background: rgb(58, 58, 58);
    color: #c2c3c4;
    width: 100%;
    font-size: 2rem;
    line-height: 0;
    padding: 14px 0;
    text-indent: 4px;
  }

  .terminal pre {
    font-family: SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;
    color: white;
    padding: 0 1rem 1rem;
    margin: 0;
  }

  .circle-link {
    height: 40px;
    width: 40px;
    border-radius: 40px;
    margin: 8px;
    background-color: white;
    border: 1px solid #eeeeee;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
    transition: 1s ease-out;
  }

  .circle-link:hover {
    transform: translateY(-0.25rem);
    box-shadow: 0px 3px 15px rgba(0, 0, 0, 0.2);
  }

  footer {
    margin-top: 8px;
    display: flex;
    align-items: center;
    line-height: 20px;
  }

  footer a {
    display: flex;
    align-items: center;
  }

  .github-star-badge {
    color: #24292e;
    display: flex;
    align-items: center;
    font-size: 12px;
    padding: 3px 10px;
    border: 1px solid rgba(27,31,35,.2);
    border-radius: 3px;
    background-image: linear-gradient(-180deg,#fafbfc,#eff3f6 90%);
    margin-left: 4px;
    font-weight: 600;
    font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
  }

  .github-star-badge:hover {
    background-image: linear-gradient(-180deg,#f0f3f6,#e6ebf1 90%);
    border-color: rgba(27,31,35,.35);
    background-position: -.5em;
  }

  .github-star-badge .material-icons {
    height: 16px;
    width: 16px;
    margin-right: 4px;
  }

  svg#clouds {
    position: fixed;
    bottom: -160px;
    left: -230px;
    z-index: -10;
    width: 1920px;
  }

  /* Responsive Styles */
  @media screen and (max-width: 767px) {

    .card-container > *:not(.circle-link) ,
    .terminal {
      width: 100%;
    }

    .card:not(.highlight-card) {
      height: 16px;
      margin: 8px 0;
    }

    .card.highlight-card span {
      margin-left: 72px;
    }

    svg#rocket-smoke {
      right: 120px;
      transform: rotate(-5deg);
    }
  }

  @media screen and (max-width: 575px) {
    svg#rocket-smoke {
      display: none;
      visibility: hidden;
    }
  }
</style>

<!-- Toolbar -->
<div class="toolbar" role="banner">
  <img
    width="40"
    alt="Angular Logo"
    src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTAgMjUwIj4KICAgIDxwYXRoIGZpbGw9IiNERDAwMzEiIGQ9Ik0xMjUgMzBMMzEuOSA2My4ybDE0LjIgMTIzLjFMMTI1IDIzMGw3OC45LTQzLjcgMTQuMi0xMjMuMXoiIC8+CiAgICA8cGF0aCBmaWxsPSIjQzMwMDJGIiBkPSJNMTI1IDMwdjIyLjItLjFWMjMwbDc4LjktNDMuNyAxNC4yLTEyMy4xTDEyNSAzMHoiIC8+CiAgICA8cGF0aCAgZmlsbD0iI0ZGRkZGRiIgZD0iTTEyNSA1Mi4xTDY2LjggMTgyLjZoMjEuN2wxMS43LTI5LjJoNDkuNGwxMS43IDI5LjJIMTgzTDEyNSA1Mi4xem0xNyA4My4zaC0zNGwxNy00MC45IDE3IDQwLjl6IiAvPgogIDwvc3ZnPg=="
  />
  <span>Welcome</span>
  <h1>2/5/20</h1>
    <div class="spacer"></div>
  <a aria-label="Angular on twitter" target="_blank" rel="noopener" href="https://twitter.com/angular" title="Twitter">

    <svg id="twitter-logo" height="24" data-name="Logo â€” FIXED" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400">
      <defs>
        <style>
          .cls-1 {
            fill: none;
          }

          .cls-2 {
            fill: #ffffff;
          }
        </style>
      </defs>
      <rect class="cls-1" width="400" height="400" />
      <path class="cls-2" d="M153.62,301.59c94.34,0,145.94-78.16,145.94-145.94,0-2.22,0-4.43-.15-6.63A104.36,104.36,0,0,0,325,122.47a102.38,102.38,0,0,1-29.46,8.07,51.47,51.47,0,0,0,22.55-28.37,102.79,102.79,0,0,1-32.57,12.45,51.34,51.34,0,0,0-87.41,46.78A145.62,145.62,0,0,1,92.4,107.81a51.33,51.33,0,0,0,15.88,68.47A50.91,50.91,0,0,1,85,169.86c0,.21,0,.43,0,.65a51.31,51.31,0,0,0,41.15,50.28,51.21,51.21,0,0,1-23.16.88,51.35,51.35,0,0,0,47.92,35.62,102.92,102.92,0,0,1-63.7,22A104.41,104.41,0,0,1,75,278.55a145.21,145.21,0,0,0,78.62,23"
      />
    </svg>

  </a>
</div>

<div class="content" role="main">

  <!-- Highlight Card -->
  <div class="card highlight-card card-small">

    <svg id="rocket" alt="Rocket Ship" xmlns="http://www.w3.org/2000/svg" width="101.678" height="101.678" viewBox="0 0 101.678 101.678">
      <g id="Group_83" data-name="Group 83" transform="translate(-141 -696)">
        <circle id="Ellipse_8" data-name="Ellipse 8" cx="50.839" cy="50.839" r="50.839" transform="translate(141 696)" fill="#dd0031"/>
        <g id="Group_47" data-name="Group 47" transform="translate(165.185 720.185)">
          <path id="Path_33" data-name="Path 33" d="M3.4,42.615a3.084,3.084,0,0,0,3.553,3.553,21.419,21.419,0,0,0,12.215-6.107L9.511,30.4A21.419,21.419,0,0,0,3.4,42.615Z" transform="translate(0.371 3.363)" fill="#fff"/>
          <path id="Path_34" data-name="Path 34" d="M53.3,3.221A3.09,3.09,0,0,0,50.081,0,48.227,48.227,0,0,0,18.322,13.437c-6-1.666-14.991-1.221-18.322,7.218A33.892,33.892,0,0,1,9.439,25.1l-.333.666a3.013,3.013,0,0,0,.555,3.553L23.985,43.641a2.9,2.9,0,0,0,3.553.555l.666-.333A33.892,33.892,0,0,1,32.647,53.3c8.55-3.664,8.884-12.326,7.218-18.322A48.227,48.227,0,0,0,53.3,3.221ZM34.424,9.772a6.439,6.439,0,1,1,9.106,9.106,6.368,6.368,0,0,1-9.106,0A6.467,6.467,0,0,1,34.424,9.772Z" transform="translate(0 0.005)" fill="#fff"/>
        </g>
      </g>
    </svg>

    <span>{{ title }} app is running!</span>

    <svg id="rocket-smoke" alt="Rocket Ship Smoke" xmlns="http://www.w3.org/2000/svg" width="516.119" height="1083.632" viewBox="0 0 516.119 1083.632">
      <path id="Path_40" data-name="Path 40" d="M644.6,141S143.02,215.537,147.049,870.207s342.774,201.755,342.774,201.755S404.659,847.213,388.815,762.2c-27.116-145.51-11.551-384.124,271.9-609.1C671.15,139.365,644.6,141,644.6,141Z" transform="translate(-147.025 -140.939)" fill="#f5f5f5"/>
    </svg>

  </div>

 <h2>{{ formName }}</h2>

 <app-name-editor></app-name-editor>

  <svg id="clouds" alt="Gray Clouds Background" xmlns="http://www.w3.org/2000/svg" width="2611.084" height="485.677" viewBox="0 0 2611.084 485.677">
    <path id="Path_39" data-name="Path 39" d="M2379.709,863.793c10-93-77-171-168-149-52-114-225-105-264,15-75,3-140,59-152,133-30,2.83-66.725,9.829-93.5,26.25-26.771-16.421-63.5-23.42-93.5-26.25-12-74-77-130-152-133-39-120-212-129-264-15-54.084-13.075-106.753,9.173-138.488,48.9-31.734-39.726-84.4-61.974-138.487-48.9-52-114-225-105-264,15a162.027,162.027,0,0,0-103.147,43.044c-30.633-45.365-87.1-72.091-145.206-58.044-52-114-225-105-264,15-75,3-140,59-152,133-53,5-127,23-130,83-2,42,35,72,70,86,49,20,106,18,157,5a165.625,165.625,0,0,0,120,0c47,94,178,113,251,33,61.112,8.015,113.854-5.72,150.492-29.764a165.62,165.62,0,0,0,110.861-3.236c47,94,178,113,251,33,31.385,4.116,60.563,2.495,86.487-3.311,25.924,5.806,55.1,7.427,86.488,3.311,73,80,204,61,251-33a165.625,165.625,0,0,0,120,0c51,13,108,15,157-5a147.188,147.188,0,0,0,33.5-18.694,147.217,147.217,0,0,0,33.5,18.694c49,20,106,18,157,5a165.625,165.625,0,0,0,120,0c47,94,178,113,251,33C2446.709,1093.793,2554.709,922.793,2379.709,863.793Z" transform="translate(142.69 -634.312)" fill="#eee"/>
  </svg>

</div>

<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
<!-- * * * * * * * * * * * The content above * * * * * * * * * * * -->
<!-- * * * * * * * * * * is only a placeholder * * * * * * * * * * -->
<!-- * * * * * * * * * * and can be replaced. * * * * * * * * * * * -->
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->
<!-- * * * * * * * * * * End of Placeholder * * * * * * * * * * * -->
<!-- * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -->

</code>```

And here is my name-editor.component.ts file code:

```<code>import { Component, OnInit } from '@angular/core';
import { FormControl } from '@angular/forms';

@Component({
  selector: 'app-name-editor',
  templateUrl: './name-editor.component.html',
  styleUrls: ['./name-editor.component.css']
})
export class NameEditorComponent implements OnInit {

  constructor() { }

  ngOnInit() {
  }

  name = new FormControl('');

}

</code>```

答:
you need to add NameEditorComponent in declarations array of NgModule.

Just do 2 steps:
1. Write import statement to include that array
import {NameEditorComponent } from 'write path here'

Include component in declarations array.

@NgModule({
  declarations: [AppComponent, NameEditorComponent ],
  imports: [BrowserModule, ReactiveFormsModule],
  providers: [],
  bootstrap: [AppComponent]
})```

Body:
I am having an issue when creating an Angular form. Whenever I include the app-name-editor tag, my entire HTML webpage goes blank and the form will not display. However, if I remove the tag, the webpage works as normal. So I am thinking there must be something wrong with my HTML code. Any insights on this would be appreciated.

I was following the guide on Angular.io and I am stuck on the part that talks about displaying the component. https://angular.io/guide/reactive-forms

Below is my code:

  <img
    width="40"
    alt="Angular Logo"
    src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTAgMjUwIj4KICAgIDxwYXRoIGZpbGw9IiNERDAwMzEiIGQ9Ik0xMjUgMzBMMzEuOSA2My4ybDE0LjIgMTIzLjFMMTI1IDIzMGw3OC45LTQzLjcgMTQuMi0xMjMuMXoiIC8+CiAgICA8cGF0aCBmaWxsPSIjQzMwMDJGIiBkPSJNMTI1IDMwdjIyLjItLjFWMjMwbDc4LjktNDMuNyAxNC4yLTEyMy4xTDEyNSAzMHoiIC8+CiAgICA8cGF0aCAgZmlsbD0iI0ZGRkZGRiIgZD0iTTEyNSA1Mi4xTDY2LjggMTgyLjZoMjEuN2wxMS43LTI5LjJoNDkuNGwxMS43IDI5LjJIMTgzTDEyNSA1Mi4xem0xNyA4My4zaC0zNGwxNy00MC45IDE3IDQwLjl6IiAvPgogIDwvc3ZnPg=="
  />
  Welcome

2/5/20

    <svg id="twitter-logo" height="24" data-name="Logo â€” FIXED" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400">
      <defs>

      </defs>
      <rect class="cls-1" width="400" height="400" />
      <path class="cls-2" d="M153.62,301.59c94.34,0,145.94-78.16,145.94-145.94,0-2.22,0-4.43-.15-6.63A104.36,104.36,0,0,0,325,122.47a102.38,102.38,0,0,1-29.46,8.07,51.47,51.47,0,0,0,22.55-28.37,102.79,102.79,0,0,1-32.57,12.45,51.34,51.34,0,0,0-87.41,46.78A145.62,145.62,0,0,1,92.4,107.81a51.33,51.33,0,0,0,15.88,68.47A50.91,50.91,0,0,1,85,169.86c0,.21,0,.43,0,.65a51.31,51.31,0,0,0,41.15,50.28,51.21,51.21,0,0,1-23.16.88,51.35,51.35,0,0,0,47.92,35.62,102.92,102.92,0,0,1-63.7,22A104.41,104.41,0,0,1,75,278.55a145.21,145.21,0,0,0,78.62,23"
      />
    </svg>

    <svg id="rocket" alt="Rocket Ship" xmlns="http://www.w3.org/2000/svg" width="101.678" height="101.678" viewBox="0 0 101.678 101.678">
      <g id="Group_83" data-name="Group 83" transform="translate(-141 -696)">
        <circle id="Ellipse_8" data-name="Ellipse 8" cx="50.839" cy="50.839" r="50.839" transform="translate(141 696)" fill="#dd0031"/>
        <g id="Group_47" data-name="Group 47" transform="translate(165.185 720.185)">
          <path id="Path_33" data-name="Path 33" d="M3.4,42.615a3.084,3.084,0,0,0,3.553,3.553,21.419,21.419,0,0,0,12.215-6.107L9.511,30.4A21.419,21.419,0,0,0,3.4,42.615Z" transform="translate(0.371 3.363)" fill="#fff"/>
          <path id="Path_34" data-name="Path 34" d="M53.3,3.221A3.09,3.09,0,0,0,50.081,0,48.227,48.227,0,0,0,18.322,13.437c-6-1.666-14.991-1.221-18.322,7.218A33.892,33.892,0,0,1,9.439,25.1l-.333.666a3.013,3.013,0,0,0,.555,3.553L23.985,43.641a2.9,2.9,0,0,0,3.553.555l.666-.333A33.892,33.892,0,0,1,32.647,53.3c8.55-3.664,8.884-12.326,7.218-18.322A48.227,48.227,0,0,0,53.3,3.221ZM34.424,9.772a6.439,6.439,0,1,1,9.106,9.106,6.368,6.368,0,0,1-9.106,0A6.467,6.467,0,0,1,34.424,9.772Z" transform="translate(0 0.005)" fill="#fff"/>
        </g>
      </g>
    </svg>

    {{ title }} app is running!

    <svg id="rocket-smoke" alt="Rocket Ship Smoke" xmlns="http://www.w3.org/2000/svg" width="516.119" height="1083.632" viewBox="0 0 516.119 1083.632">
      <path id="Path_40" data-name="Path 40" d="M644.6,141S143.02,215.537,147.049,870.207s342.774,201.755,342.774,201.755S404.659,847.213,388.815,762.2c-27.116-145.51-11.551-384.124,271.9-609.1C671.15,139.365,644.6,141,644.6,141Z" transform="translate(-147.025 -140.939)" fill="#f5f5f5"/>
    </svg>

{{ formName }}

 <app-name-editor></app-name-editor>

  <svg id="clouds" alt="Gray Clouds Background" xmlns="http://www.w3.org/2000/svg" width="2611.084" height="485.677" viewBox="0 0 2611.084 485.677">
    <path id="Path_39" data-name="Path 39" d="M2379.709,863.793c10-93-77-171-168-149-52-114-225-105-264,15-75,3-140,59-152,133-30,2.83-66.725,9.829-93.5,26.25-26.771-16.421-63.5-23.42-93.5-26.25-12-74-77-130-152-133-39-120-212-129-264-15-54.084-13.075-106.753,9.173-138.488,48.9-31.734-39.726-84.4-61.974-138.487-48.9-52-114-225-105-264,15a162.027,162.027,0,0,0-103.147,43.044c-30.633-45.365-87.1-72.091-145.206-58.044-52-114-225-105-264,15-75,3-140,59-152,133-53,5-127,23-130,83-2,42,35,72,70,86,49,20,106,18,157,5a165.625,165.625,0,0,0,120,0c47,94,178,113,251,33,61.112,8.015,113.854-5.72,150.492-29.764a165.62,165.62,0,0,0,110.861-3.236c47,94,178,113,251,33,31.385,4.116,60.563,2.495,86.487-3.311,25.924,5.806,55.1,7.427,86.488,3.311,73,80,204,61,251-33a165.625,165.625,0,0,0,120,0c51,13,108,15,157-5a147.188,147.188,0,0,0,33.5-18.694,147.217,147.217,0,0,0,33.5,18.694c49,20,106,18,157,5a165.625,165.625,0,0,0,120,0c47,94,178,113,251,33C2446.709,1093.793,2554.709,922.793,2379.709,863.793Z" transform="translate(142.69 -634.312)" fill="#eee"/>
  </svg>

And here is my name-editor.component.ts file code:

import { Component, OnInit } from '@angular/core';
import { FormControl } from '@angular/forms';

@Component({
  selector: 'app-name-editor',
  templateUrl: './name-editor.component.html',
  styleUrls: ['./name-editor.component.css']
})
export class NameEditorComponent implements OnInit {

  constructor() { }

  ngOnInit() {
  }

  name = new FormControl('');

}


问:
Conditional flag based on Groupby Python
I want to use conditional statements to create flag based on id and precedence order -

Dataframe -

```<code>    df=pd.DataFrame({'id':[1,1,1,1,2,3,3,3],
     'var':['Apple','Banana','Orange','Mango', 'Mango', 'Banana','Orange','Mango'],
      'flag':[1,1,1,1,1,1,1,1]})
</code>```

Precedence order -
Apple > Banana > Orange

Conditions -

1 - if Apple, Banana & Mango are present in id then flag for Banana & Ornage becomes 0, there will be no impact on Mango, it will be 1.

2 - If Banana & Orange are present then flag for Orange will become 0

Output -

```<code>     df=pd.DataFrame({'id':[1,1,1,1,2,3,3,3],
     'var':['Apple','Banana','Orange','Mango', 'Mango', 'Banana','Orange','Mango'],
      'flag':[1,0,0,1,1,1,0,1]})
</code>```

Method -

I have tried grouping the data and thought of performing the intersection by defining conditional lists.

I believe I have complicated it and doing the wrong way. Please guide.

```<code>group_test = df.groupby(['id'],as_index=False).var.agg(lambda x: x.unique().tolist())
list_1 = ['Apple','Banana','Orange']
list_2 = ['Banana', 'Orange']
</code>```

答:
This is a solution that works with the given data. I don't think it would work if you had orders on (n-2) of the categories where n = number of categories.

This is a more general answer if you want to identify the Highest Category for each id

Edit: If you have a small set of categories that dictate the ordering, simply lump them together into an other category which can be assigned the last order. That should be enough

import pandas as pd
df=pd.DataFrame({'id':[1,1,1,1,2,3,3,3],
     'var':['Apple','Banana','Orange','Mango', 'Mango', 'Banana','Orange','Mango'],
      'flag':[1,1,1,1,1,1,1,1]})

# create a categorical array with the orders set this way.
# this keeps the ordering Apple > Banana > Orange > Mango
df['category'] = pd.Categorical(df['var'], ordered=True, categories=reversed(['Apple', 'Banana', 'Orange', 'Mango']))

# group by id and just get a boolean of whether var = max category
# for each id subset, compare each var to the maximum category in that subset
df['highest_level'] = df.groupby('id').apply(lambda df_: 1 * (df_['var'] == df_['category'].max())).reset_index(drop=True)

# put mango back to 1 - since Mango was the lowest in the order
# the only times Mango would have a highest_level = 1 would be
# when the entire subset only has Mango var
df.loc[df['var'] == 'Mango', 'highest_level'] = 1
```

Body:
I want to use conditional statements to create flag based on id and precedence order -

Dataframe -

    df=pd.DataFrame({'id':[1,1,1,1,2,3,3,3],
     'var':['Apple','Banana','Orange','Mango', 'Mango', 'Banana','Orange','Mango'],
      'flag':[1,1,1,1,1,1,1,1]})

Precedence order -
Apple > Banana > Orange

Conditions -

1 - if Apple, Banana & Mango are present in id then flag for Banana & Ornage becomes 0, there will be no impact on Mango, it will be 1.

2 - If Banana & Orange are present then flag for Orange will become 0

Output -

     df=pd.DataFrame({'id':[1,1,1,1,2,3,3,3],
     'var':['Apple','Banana','Orange','Mango', 'Mango', 'Banana','Orange','Mango'],
      'flag':[1,0,0,1,1,1,0,1]})

Method -

I have tried grouping the data and thought of performing the intersection by defining conditional lists.

I believe I have complicated it and doing the wrong way. Please guide.

group_test = df.groupby(['id'],as_index=False).var.agg(lambda x: x.unique().tolist())
list_1 = ['Apple','Banana','Orange']
list_2 = ['Banana', 'Orange']


问:
publishing the database with the project
How can I publish the application database along with it?

I'm using Visual Studio 2008 with C# language.

The database has the log-in information needed in order to go in the MdiParent and do tasks there. The same database is where employee records would also be saved...

I'm currently developing an employee information system.

答:
The easiest option it to use a file based database and distribute it with your application, unless you need the data to be shared between all users of the applications as it changes.

SqlLite and SQL Server CE are both file based.

ContentLicense: CC BY-SA 3.0


问:
IndexOf method Java
My method indexOf is supposed to return the index of the first occurrence of the specified element in a list, or -1 if this list does not contain the element. More formally: returns the lowest index i such that (E == null ? get(i) == null : E.equals(get(i))), or -1 if there is no such index. The problem with this code is that it always seems to return -1, any suggestions on how I can fix this?

```<code> public int indexOf(E element) {

    Node current = head;
    int index = 0;
    for (int i = 0; i < size; i++) {
        if (current.getmElement() == element) {
            return index;
        }
        index++;
        current = current.getmNextNode();
    }
    return -1;
}
</code>```

I am using generics to find the next element in the list:

```<code>public class Node<E> {
private E mElement;
private Node<E> mNextNode;

Node(E data) {

    this.setmElement(data);
}
public E getmElement() {
    return this.mElement;
}
public void setmElement(E element) {
    this.mElement = element;
}
public Node<E> getmNextNode()
{
    return this.mNextNode;
}
public void setmNextNode(Node<E> node)
{
    this.mNextNode = node;
}}
</code>```

答:
You're doing a refernece check: current.getmElement() == element. What you meant to do is to check if those objects are equal:

```<code>current.getmElement().equals(element)
</code>```

Title: IndexOf method Java

Body:
My method indexOf is supposed to return the index of the first occurrence of the specified element in a list, or -1 if this list does not contain the element. More formally: returns the lowest index i such that (E == null ? get(i) == null : E.equals(get(i))), or -1 if there is no such index. The problem with this code is that it always seems to return -1, any suggestions on how I can fix this?

 public int indexOf(E element) {

    Node current = head;
    int index = 0;
    for (int i = 0; i < size; i++) {
        if (current.getmElement() == element) {
            return index;
        }
        index++;
        current = current.getmNextNode();
    }
    return -1;
}

I am using generics to find the next element in the list:

public class Node<E> {
private E mElement;
private Node<E> mNextNode;

Node(E data) {

    this.setmElement(data);
}
public E getmElement() {
    return this.mElement;
}
public void setmElement(E element) {
    this.mElement = element;
}
public Node<E> getmNextNode()
{
    return this.mNextNode;
}
public void setmNextNode(Node<E> node)
{
    this.mNextNode = node;
}}

Body:
You're doing a refernece check: current.getmElement() == element. What you meant to do is to check if those objects are equal:

current.getmElement().equals(element)


问:
How to display dynamic keys and values of json data in html using php
The below values are dynamic in JSON format, which will change for every entry.
1) {"ABCD":{"Hindi":"82"},"EFGH":{"English":"78"},"IJKL":{"Urdu":"82"},"MNOP":{"Sanskrit":"78"}}

I want to display in single cell in a column, as shown below. how can i achieve that using PHP

REMARKS

ABCD: Hindi = 82,

EFGH: English = 78,

IJKL: Urdu = 82,

MNOP: Sanskrit = 78

答:
I am going to assume that you have the the json as a string:

```<code>$str = '{"ABCD":{"Hindi":"82"},"EFGH":{"English":"78"},"IJKL":{"Urdu":"82"},"MNOP":{"Sanskrit":"78"}}';

$str = str_replace("{", "array(", $str);
$str = str_replace("}", ")", $str);
$str = str_replace(":", ",", $str);
$obj = "";
$newstr = "";

for ($i = 0; $i < count($obj); $i++) {
  $e = $obj[$i];
  $zero = 0;
  $one = 1;
  $last = intval(count($obj)) - $one;
  if (gettype($obj[$i]) == gettype(array(0,0))) {
    //optional if to prevent the comma at the end.
    if ($i != $last) {
      $newstr = $newstr."$e[$zero] = $e[$one], <br/>\n"; //<br/> if displayed as html
    } else {
      $newstr = $newstr."$e[$zero] = $e[$one]";
    }
  } else {
    $newstr = $newstr."$e : ";
  }
}

echo $newstr;
</code>```

I didn't use json_decode because I find the nested arrays easier to parse with loops.

I am aware that there are a few shortcuts you can take instead of doing what I did (but copying is easier).

Also, output would be:

```<code>ABCD: Hindi = 82,
EFGH: English = 78,
IJKL: Urdu = 82,
MNOP: Sanskrit = 78
</code>```

Hope this helps!

Body:
I am going to assume that you have the the json as a string:

$str = '{"ABCD":{"Hindi":"82"},"EFGH":{"English":"78"},"IJKL":{"Urdu":"82"},"MNOP":{"Sanskrit":"78"}}';

$str = str_replace("{", "array(", $str);
$str = str_replace("}", ")", $str);
$str = str_replace(":", ",", $str);
$obj = "";
$newstr = "";

for ($i = 0; $i < count($obj); $i++) {
  $e = $obj[$i];
  $zero = 0;
  $one = 1;
  $last = intval(count($obj)) - $one;
  if (gettype($obj[$i]) == gettype(array(0,0))) {
    //optional if to prevent the comma at the end.
    if ($i != $last) {
      $newstr = $newstr."$e[$zero] = $e[$one], <br/>\n"; //<br/> if displayed as html
    } else {
      $newstr = $newstr."$e[$zero] = $e[$one]";
    }
  } else {
    $newstr = $newstr."$e : ";
  }
}

echo $newstr;

I didn't use json_decode because I find the nested arrays easier to parse with loops.

I am aware that there are a few shortcuts you can take instead of doing what I did (but copying is easier).

Also, output would be:

ABCD: Hindi = 82,
EFGH: English = 78,
IJKL: Urdu = 82,
MNOP: Sanskrit = 78

Hope this helps!


问:
What are the functions of an array of an arrayList?
I tried to do:

```<code>static boolean newTrait(ArrayList<Integer> population, int[] traits) {
        for(int i = 0; i < 25; i++) {
            for(int j = 0; j < 625; j++) {
                if(traits[j].equals(population[i].get(i))) {
                    return false;
                }
            }
        }
        return true;
    }
</code>```

The java compiler said that I had an "unresolved compiler issue."

Can anyone help?

答:
All simple types (not objects) do not have any methods. In your case neither the array not the int values inside the array have methods.

Fix:

```<code>if(traits[j] == population.get(i))
{
    return false;
}
</code>```

This compares an int on the left side with an Integer on the right side. For int the == operator is correct but it would be wrong for Integers. However in this case the compiler does automatically 'unbox' the Integer on the right side to int.

Notice that I removed the wrong [i] after population as well. Population is not an array.

Body:
I tried to do:

static boolean newTrait(ArrayList<Integer> population, int[] traits) {
        for(int i = 0; i < 25; i++) {
            for(int j = 0; j < 625; j++) {
                if(traits[j].equals(population[i].get(i))) {
                    return false;
                }
            }
        }
        return true;
    }

The java compiler said that I had an "unresolved compiler issue."

Can anyone help?

Body:
All simple types (not objects) do not have any methods. In your case neither the array not the int values inside the array have methods.

Fix:

if(traits[j] == population.get(i))
{
    return false;
}

This compares an int on the left side with an Integer on the right side. For int the == operator is correct but it would be wrong for Integers. However in this case the compiler does automatically 'unbox' the Integer on the right side to int.

Notice that I removed the wrong [i] after population as well. Population is not an array.


问:
Formatting DataBinder.Eval data
How can I format data coming from a DataBinder.Eval statement in an ASPX page?

For example, I want to display the published date of the news items in a particular format in the homepage. I'm using the ASP.NET 2.0 Repeater control to show the list of news items.

The code for this goes like this:

```<code><asp:Repeater ID="Repeater1" runat="server" DataSourceID="ObjectDataSource1">
<HeaderTemplate><table cellpadding="0" cellspacing="0" width="255"></HeaderTemplate>
<ItemTemplate>
    <tr><td >
            <a href='/content/latestNews.aspx?id=<%#DataBinder.Eval(Container.DataItem, "id") %>'>
                <asp:Label ID="lblNewsTitle" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "title") %>'></asp:Label>
            </a>
    </td></tr>
    <tr><td>
           <asp:Label ID="lblNewsDate" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "publishedDate"))%>'></asp:Label>
    </td></tr>
</ItemTemplate>
<FooterTemplate></table></FooterTemplate></asp:Repeater>
</code>```

Is there a way I could call a custom method with the DataBinder.Eval value as its parameter (something like below)?

```<code><asp:Label ID="lblNewsDate" runat="server" Text='<%# GetDateInHomepageFormat(DataBinder.Eval(Container.DataItem, "publishedDate")) )%>'></asp:Label>
</code>```

If yes, then where do I write the GetDateInHomepageFormat method? I tried out in the code behind page but got a run time error?
If this is not possible, is there a way to do inline formatting?

答:
Why not use the simpler syntax?

```<code><asp:Label id="lblNewsDate" runat="server" Text='<%# Eval("publishedDate", "{0:dddd d MMMM}") %>'</label>
</code>```

This is the template control "Eval" that takes in the expression and the string format:

```<code>protected internal string Eval(
string expression,
string format
</code>```

)

http://msdn.microsoft.com/en-us/library/3d2sz789.aspx

OwnerDisplayName: Nahom Tijnam

Title: Formatting DataBinder.Eval data

Body:
How can I format data coming from a DataBinder.Eval statement in an ASPX page?

For example, I want to display the published date of the news items in a particular format in the homepage. I'm using the ASP.NET 2.0 Repeater control to show the list of news items.

The code for this goes like this:

<asp:Repeater ID="Repeater1" runat="server" DataSourceID="ObjectDataSource1">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>

            <a href='/content/latestNews.aspx?id=<%#DataBinder.Eval(Container.DataItem, "id") %>'>
                <asp:Label ID="lblNewsTitle" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "title") %>'></asp:Label>

           <asp:Label ID="lblNewsDate" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "publishedDate"))%>'></asp:Label>

</ItemTemplate>
<FooterTemplate>
</FooterTemplate></asp:Repeater>

Is there a way I could call a custom method with the DataBinder.Eval value as its parameter (something like below)?

<asp:Label ID="lblNewsDate" runat="server" Text='<%# GetDateInHomepageFormat(DataBinder.Eval(Container.DataItem, "publishedDate")) )%>'></asp:Label>

If yes, then where do I write the GetDateInHomepageFormat method? I tried out in the code behind page but got a run time error?
If this is not possible, is there a way to do inline formatting?

LastEditorDisplayName: Nahom Tijnam

Body:
Why not use the simpler syntax?

<asp:Label id="lblNewsDate" runat="server" Text='<%# Eval("publishedDate", "{0:dddd d MMMM}") %>'</label>

This is the template control "Eval" that takes in the expression and the string format:

protected internal string Eval(
string expression,
string format

)

http://msdn.microsoft.com/en-us/library/3d2sz789.aspx


问:
Binding jQuery parameters from Angular
Please forgive my inexperience here. I am a longtime object oriented developer who is new to both Angular and jQuery.  I am developing my first single place application using Angular 8.  It involves a 3rd party audio player that I purchased online - and it employs jQuery to trigger song selection, etc.  It works perfectly when I hard code the jQuery call.  But I need to bind the values sent to the audio player to whats in my data set.  Consider this colum in my NGX-DATATABLE:</p>

```<code>              <ng-template let-column="column" ngx-datatable-header-template> Track Name </ng-template>
              <ng-template let-row="row" let-value="value" ngx-datatable-cell-template>
                <a href="javascript:void(0);" onclick="jQuery.audio7_html5.changeMp3('/assets/songs/feelit.m4a','The Song Name','The Song Author','/assets/audio/images/p3.jpg')">
                   {{ value }}
                </a>
              </ng-template>
            </ngx-datatable-column>

Works fine.  But I need something like this:

<ngx-datatable-column name="Title">
              <ng-template let-column="column" ngx-datatable-header-template> Track Name </ng-template>
              <ng-template let-row="row" let-value="value" ngx-datatable-cell-template>
                <a href="javascript:void(0);" onclick="jQuery.audio7_html5.changeMp3('{{ row.songURL }}','{{ row.songTitle }}', '{{ row.songAuthor }}','{{ row.coverArtURL }}')">
                   {{ value }}
                </a>
              </ng-template>
            </ngx-datatable-column>

Is what I am trying to do possible?  Or is there a better way?  I'm very frustrated over here.  Thanks in advance for any advice or guidance you might be able to offer.
</code>```

答:
Please can you try to implement this scenario.

in template change, this

```<code>onclick="jQuery.audio7_html5.changeMp3('{{ row.songURL }}','{{ row.songTitle }}', '{{ row.songAuthor }}','{{ row.coverArtURL }}')"
</code>```

to this

```<code>(click)="functionFromTsFile(row)"
</code>```

in ts file

```<code>declare var jQuery: any;   // <---- this line is very important

@Component({
  selector: 'app-some',
  templateUrl: './some.component.html',
  styleUrls: ['./some.component.scss'],
})
export class SomeComponent {
   // some code ......

   functionFromTsFile(row: {
      songURL: string;
      songTitle: string;
      songAuthor: string;
      coverArtURL: string
    }) {
       jQuery.audio7_html5.changeMp3(row.songURL, row.songTitle, row.songAuthor, row.coverArtURL);
   }

}
</code>```

Title: Binding jQuery parameters from Angular

Body:
Please forgive my inexperience here. I am a longtime object oriented developer who is new to both Angular and jQuery.  I am developing my first single place application using Angular 8.  It involves a 3rd party audio player that I purchased online - and it employs jQuery to trigger song selection, etc.  It works perfectly when I hard code the jQuery call.  But I need to bind the values sent to the audio player to whats in my data set.  Consider this colum in my NGX-DATATABLE:

              <ng-template let-column="column" ngx-datatable-header-template> Track Name </ng-template>
              <ng-template let-row="row" let-value="value" ngx-datatable-cell-template>

                   {{ value }}

              </ng-template>
            </ngx-datatable-column>

Works fine.  But I need something like this:

<ngx-datatable-column name="Title">
              <ng-template let-column="column" ngx-datatable-header-template> Track Name </ng-template>
              <ng-template let-row="row" let-value="value" ngx-datatable-cell-template>

                   {{ value }}

              </ng-template>
            </ngx-datatable-column>

Is what I am trying to do possible?  Or is there a better way?  I'm very frustrated over here.  Thanks in advance for any advice or guidance you might be able to offer.

Body:
Please can you try to implement this scenario.

in template change, this

onclick="jQuery.audio7_html5.changeMp3('{{ row.songURL }}','{{ row.songTitle }}', '{{ row.songAuthor }}','{{ row.coverArtURL }}')"

to this

(click)="functionFromTsFile(row)"

in ts file

declare var jQuery: any;   // <---- this line is very important

@Component({
  selector: 'app-some',
  templateUrl: './some.component.html',
  styleUrls: ['./some.component.scss'],
})
export class SomeComponent {
   // some code ......

   functionFromTsFile(row: {
      songURL: string;
      songTitle: string;
      songAuthor: string;
      coverArtURL: string
    }) {
       jQuery.audio7_html5.changeMp3(row.songURL, row.songTitle, row.songAuthor, row.coverArtURL);
   }

}


问:
How do I change global variable in nested scope using python?
My example below. I have tried adding global to the variable that I want to change but doesn't help. The error I'm getting is in the comment.

```<code>def getNumOfSwapsToSort(array):
    sorted = array.copy()
    sorted.sort()

    swaps = 0

    def swap():
        currentSwaps = 0
        for i, el in enumerate(array):
            if ((len(array) - 1) == i) and currentSwaps != 0:
                swap()

            elif el != sorted[i]:
                idx = sorted.index(el)
                temp = array[idx]
                array[idx] = el
                array[i] = temp
                # UnboundLocalError: local variable 'swaps' referenced before assignment
                # if I use global swaps, then NameError: name 'swaps' is not defined
                swaps += 1
                currentSwaps += 1

    swap()

    return swaps
</code>```

答:
swaps isn't a global, it's in getNumOfSwapsToSort, which is the parent scope of swap. So use a nonlocal declaration.

```<code>def swap():
    nonlocal swaps
    ...
</code>```

Body:
My example below. I have tried adding global to the variable that I want to change but doesn't help. The error I'm getting is in the comment.

def getNumOfSwapsToSort(array):
    sorted = array.copy()
    sorted.sort()

    swaps = 0

    def swap():
        currentSwaps = 0
        for i, el in enumerate(array):
            if ((len(array) - 1) == i) and currentSwaps != 0:
                swap()

            elif el != sorted[i]:
                idx = sorted.index(el)
                temp = array[idx]
                array[idx] = el
                array[i] = temp
                # UnboundLocalError: local variable 'swaps' referenced before assignment
                # if I use global swaps, then NameError: name 'swaps' is not defined
                swaps += 1
                currentSwaps += 1

    swap()

    return swaps

Body:
swaps isn't a global, it's in getNumOfSwapsToSort, which is the parent scope of swap. So use a nonlocal declaration.

def swap():
    nonlocal swaps
    ...


问:
How to convert string without delimiter to list in python
So I have string like this:

```<code>"UFFKTEWKW"
</code>```

And I need to convert it to a list or tuple like this:

```<code>("UFF", "KTE", "WKW")
</code>```

So every 3 letters from the string goes to separate element of list or tuple.

I can't use split() here because string doesn't have any delimiters. I don't wanna make some dummy for cycle for it. And I think there should be simple solution for it.

答:
You can use this.</p>

```<code>a="UFFKTEWKW"
out=tuple(a[i:i+3] for i in range(0,len(a),3))
# ('UFF', 'KTE', 'WKW')
</code>```

Body:
So I have string like this:

"UFFKTEWKW"

And I need to convert it to a list or tuple like this:

("UFF", "KTE", "WKW")

So every 3 letters from the string goes to separate element of list or tuple.

I can't use split() here because string doesn't have any delimiters. I don't wanna make some dummy for cycle for it. And I think there should be simple solution for it.

Body:
You can use this.

a="UFFKTEWKW"
out=tuple(a[i:i+3] for i in range(0,len(a),3))
# ('UFF', 'KTE', 'WKW')