[JAVA-586] ObjectId MachineId uses network interface names instead of mac address or something more unique Created: 08/Jun/12 Updated: 31/Mar/15 Resolved: 25/Jun/13 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Codecs |
| Affects Version/s: | 2.7.2 |
| Fix Version/s: | 3.0.0 |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Wes Freeman | Assignee: | Jeffrey Yemin |
| Resolution: | Done | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Affects all environments AFAIK, although I only tested on OSX 10.7.3 |
||
| Description |
|
The 3 byte hash of the machine id should be based on something more unique than the network interface names (ie. "en1" or "eth0"). |
| Comments |
| Comment by Jeffrey Yemin [ 31/Mar/15 ] |
|
Closing all resolved 3.0.0 issues, as 3.0.0 has been tagged and released. |
| Comment by Ivan Todoroski [ 13/Sep/14 ] |
|
Hello Jeff, I appreciate the solution for 3.x, but that release seems a long way off (this ticket was assigned to 3.x almost 2 years ago) and besides, not everyone might be able to upgrade to 3.x immediately. Why not just use reflection in the 2.x driver to get the same functionality? You can check if the method getHardwareAddress() exists and call it reflectively if it does, otherwise fall back on toString(). That way if the 2.x driver is running inside a Java 6+ VM we get to benefit from improved uniqueness of ObjectId, while if it's running on Java 5 it will still be backward compatible, it will just use toString() like it does now. I realize that reflection should be avoided in general, but we're talking about a static initializer here that only gets called once on startup, so performance is not an issue, and the practical advantages in this case should outweigh the general distaste for reflection. |
| Comment by auto [ 30/May/13 ] |
|
Author: {u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}Message: The logic for generating machine identifier has changed. Since we are java 6 minimum now, using NetworkInterface.getHardwareAddress() for more uniqueness. The logic for generating process identifier has changed. It attempts to get the actual numeric process id from JMX, falling back to a string hash only if if it can't. It looks for a pattern in the process name of <process_id>@<host_name>. No longer using the classloader hash either, since each class loader will have a separate instance of NEXT_COUNTER, which is seeded with a random number and so is very unlikely to clash. Removed a bunch of stuff Removed support for 'babble' format. Other non-backwards compatible changes: equals method will no longer compare equal to anything but an ObjectId Additionally, added getters that conform to the spec: timestamp, machineIdentifier, processIdentifier, and counter. Deprecated the old ones. |
| Comment by Jeffrey Yemin [ 30/Dec/12 ] |
|
Moving to 3.0, where we can consider abandoning Java 5. See https://github.com/mongodb/mongo-java-driver/pull/76 for an implementation which uses a method added in Java 6. |