private static long makeNode() { /* * We don't have access to the MAC address but need to generate a node part * that identify this host as uniquely as possible. * The spec says that one option is to take as many source that identify * this node as possible and hash them together. That's what we do here by * gathering all the ip of this host. * Note that FBUtilities.getBroadcastAddress() should be enough to uniquely * identify the node *in the cluster* but it triggers DatabaseDescriptor * instanciation and the UUID generator is used in Stress for instance, * where we don't want to require the yaml. */ Collection<InetAddress> localAddresses = FBUtilities.getAllLocalAddresses(); if (localAddresses.isEmpty()) throw new RuntimeException("Cannot generate the node component of the UUID because cannot retrieve any IP addresses."); // ideally, we'd use the MAC address, but java doesn't expose that. byte[] hash = hash(localAddresses); long node = 0; for (int i = 0; i < Math.min(6, hash.length); i++) node |= (0x00000000000000ff & (long)hash[i]) << (5-i)*8; assert (0xff00000000000000L & node) == 0; // Since we don't use the mac address, the spec says that multicast // bit (least significant bit of the first octet of the node ID) must be 1. return node | 0x0000010000000000L; }
private static long makeNode() { /* * We don't have access to the MAC address but need to generate a node part * that identify this host as uniquely as possible. * The spec says that one option is to take as many source that identify * this node as possible and hash them together. That's what we do here by * gathering all the ip of this host. * Note that FBUtilities.getBroadcastAddress() should be enough to uniquely * identify the node *in the cluster* but it triggers DatabaseDescriptor * instanciation and the UUID generator is used in Stress for instance, * where we don't want to require the yaml. */ Collection<InetAddress> localAddresses = FBUtilities.getAllLocalAddresses(); if (localAddresses.isEmpty()) throw new RuntimeException("Cannot generate the node component of the UUID because cannot retrieve any IP addresses."); // ideally, we'd use the MAC address, but java doesn't expose that. byte[] hash = hash(localAddresses); long node = 0; for (int i = 0; i < Math.min(6, hash.length); i++) node |= (0x00000000000000ff & (long)hash[i]) << (5-i)*8; assert (0xff00000000000000L & node) == 0; // Since we don't use the mac address, the spec says that multicast // bit (least significant bit of the first octet of the node ID) must be 1. return node | 0x0000010000000000L; }
private static long makeNode() { /* * We don't have access to the MAC address but need to generate a node part * that identify this host as uniquely as possible. * The spec says that one option is to take as many source that identify * this node as possible and hash them together. That's what we do here by * gathering all the ip of this host. * Note that FBUtilities.getBroadcastAddress() should be enough to uniquely * identify the node *in the cluster* but it triggers DatabaseDescriptor * instanciation and the UUID generator is used in Stress for instance, * where we don't want to require the yaml. */ Collection<InetAddress> localAddresses = FBUtilities.getAllLocalAddresses(); if (localAddresses.isEmpty()) throw new RuntimeException("Cannot generate the node component of the UUID because cannot retrieve any IP addresses."); // ideally, we'd use the MAC address, but java doesn't expose that. byte[] hash = hash(localAddresses); long node = 0; for (int i = 0; i < Math.min(6, hash.length); i++) node |= (0x00000000000000ff & (long)hash[i]) << (5-i)*8; assert (0xff00000000000000L & node) == 0; // Since we don't use the mac address, the spec says that multicast // bit (least significant bit of the first octet of the node ID) must be 1. return node | 0x0000010000000000L; }
private static long makeNode() { /* * We don't have access to the MAC address but need to generate a node part * that identify this host as uniquely as possible. * The spec says that one option is to take as many source that identify * this node as possible and hash them together. That's what we do here by * gathering all the ip of this host. * Note that FBUtilities.getBroadcastAddress() should be enough to uniquely * identify the node *in the cluster* but it triggers DatabaseDescriptor * instanciation and the UUID generator is used in Stress for instance, * where we don't want to require the yaml. */ Collection<InetAddress> localAddresses = FBUtilities.getAllLocalAddresses(); if (localAddresses.isEmpty()) throw new RuntimeException("Cannot generate the node component of the UUID because cannot retrieve any IP addresses."); // ideally, we'd use the MAC address, but java doesn't expose that. byte[] hash = hash(localAddresses); long node = 0; for (int i = 0; i < Math.min(6, hash.length); i++) node |= (0x00000000000000ff & (long)hash[i]) << (5-i)*8; assert (0xff00000000000000L & node) == 0; // Since we don't use the mac address, the spec says that multicast // bit (least significant bit of the first octet of the node ID) must be 1. return node | 0x0000010000000000L; }
private static long makeNode() { /* * We don't have access to the MAC address but need to generate a node part * that identify this host as uniquely as possible. * The spec says that one option is to take as many source that identify * this node as possible and hash them together. That's what we do here by * gathering all the ip of this host. * Note that FBUtilities.getBroadcastAddress() should be enough to uniquely * identify the node *in the cluster* but it triggers DatabaseDescriptor * instanciation and the UUID generator is used in Stress for instance, * where we don't want to require the yaml. */ Collection<InetAddress> localAddresses = FBUtilities.getAllLocalAddresses(); if (localAddresses.isEmpty()) throw new RuntimeException("Cannot generate the node component of the UUID because cannot retrieve any IP addresses."); // ideally, we'd use the MAC address, but java doesn't expose that. byte[] hash = hash(localAddresses); long node = 0; for (int i = 0; i < Math.min(6, hash.length); i++) node |= (0x00000000000000ff & (long)hash[i]) << (5-i)*8; assert (0xff00000000000000L & node) == 0; // Since we don't use the mac address, the spec says that multicast // bit (least significant bit of the first octet of the node ID) must be 1. return node | 0x0000010000000000L; }
private static long makeNode() { /* * We don't have access to the MAC address but need to generate a node part * that identify this host as uniquely as possible. * The spec says that one option is to take as many source that identify * this node as possible and hash them together. That's what we do here by * gathering all the ip of this host. * Note that FBUtilities.getBroadcastAddress() should be enough to uniquely * identify the node *in the cluster* but it triggers DatabaseDescriptor * instanciation and the UUID generator is used in Stress for instance, * where we don't want to require the yaml. */ Collection<InetAddress> localAddresses = FBUtilities.getAllLocalAddresses(); if (localAddresses.isEmpty()) throw new RuntimeException("Cannot generate the node component of the UUID because cannot retrieve any IP addresses."); // ideally, we'd use the MAC address, but java doesn't expose that. byte[] hash = hash(localAddresses); long node = 0; for (int i = 0; i < Math.min(6, hash.length); i++) node |= (0x00000000000000ff & (long)hash[i]) << (5-i)*8; assert (0xff00000000000000L & node) == 0; // Since we don't use the mac address, the spec says that multicast // bit (least significant bit of the first octet of the node ID) must be 1. return node | 0x0000010000000000L; }
private String[] getLocations() { Collection<InetAddress> localAddresses = FBUtilities.getAllLocalAddresses(); for (InetAddress address : localAddresses) { for (String location : split.getLocations()) { InetAddress locationAddress = null; try { locationAddress = InetAddress.getByName(location); } catch (UnknownHostException e) { throw new AssertionError(e); } if (address.equals(locationAddress)) { return new String[]{location}; } } } return split.getLocations(); }
private String[] getLocations() { Collection<InetAddress> localAddresses = FBUtilities.getAllLocalAddresses(); for (InetAddress address : localAddresses) { for (String location : split.getLocations()) { InetAddress locationAddress; try { locationAddress = InetAddress.getByName(location); } catch (UnknownHostException e) { throw new AssertionError(e); } if (address.equals(locationAddress)) { return new String[] { location }; } } } return split.getLocations(); }
private String getLocation() { Collection<InetAddress> localAddresses = FBUtilities.getAllLocalAddresses(); for (InetAddress address : localAddresses) { for (String location : split.getLocations()) { InetAddress locationAddress = null; try { locationAddress = InetAddress.getByName(location); } catch (UnknownHostException e) { throw new AssertionError(e); } if (address.equals(locationAddress)) { return location; } } } return split.getLocations()[0]; }