CodePudding user response:
Radio variable sc. Broadcast ()?CodePudding user response:
Spark provides the accumulative variables, see the official made it very clearCodePudding user response:
LZ, please find the solutionCodePudding user response:
The broadcast on radio variables from the Driver object serialization and deserialization on the Executor, therefore in the Executor of the variable changes, just modify the Executor of the local copy of a copy of the other Executor will not be affected,The accumulator is Driver read-only, Executor writing object, only
So you can do through database or HDFS file, and thus the real-time share the data encapsulation method inside the operator to access your visits, attention to the problem of read-write lock,
CodePudding user response:
In addition if not particularly large objects, such as string or an array, not a collection of attention can be serialized on the ZooKeeper, ZK data cannot be more than 1 MBRecommend a menagerie, realized the distributed lock, Leader election, and implements the Java. Util. Concurrent package under the concurrent collections of the distributed implementation of the interface
CodePudding user response:
Themselves can encapsulate implementation, broadcast and accumulated variables cannot be as you say it,Put to Shared data zookeeper is a way, is to control concurrent write the problems by themselves, not the trouble, and then open a web service, every time get the value from the web service, finished the update,