1u0 commented on a change in pull request #8741: [FLINK-12752] Add Option to
Pass Seed for JobID Hash for StandaloneJobClusterEntrypoint
URL: https://github.com/apache/flink/pull/8741#discussion_r297541840
##########
File path: flink-core/src/main/java/org/apache/flink/api/common/JobID.java
##########
@@ -64,27 +65,40 @@ public JobID(long lowerPart, long upperPart) {
public JobID(byte[] bytes) {
super(bytes);
}
-
+
//
------------------------------------------------------------------------
// Static factory methods
//
------------------------------------------------------------------------
/**
* Creates a new (statistically) random JobID.
- *
+ *
* @return A new random JobID.
*/
public static JobID generate() {
return new JobID();
}
+ /**
+ * Creates a new JobID based on the given seed. The JobIDs returned by
two invocations of this
+ * method with the same seed will be equal.
+ *
+ * @param seed the seed to base the generation of the JobID
+ *
+ * @return A new JobID based on the given seed.
+ */
+ public static JobID fromSeed(String seed) {
+ Random rnd = new Random(seed.hashCode());
Review comment:
In case of HA mode, do I get it right that it's desirable, that different
Flink jobs must have different IDs?
I think `String.hashCode()` can be too weak source of random seed to
generate such job IDs.
Maybe consider some better [hash
functions](https://docs.oracle.com/javase/8/docs/api/java/security/MessageDigest.html)
instead?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services