public UUID generateTimeBasedUUID(final byte[] byteAddr) { byte[] contents = new byte[16]; int pos = 10; System.arraycopy(byteAddr, 0, contents, pos, 6); synchronized (mTimerLock) { if (mTimer == null) { mTimer = new UUIDTimer(getRandomNumberGenerator()); } mTimer.getTimestamp(contents); } return new UUID(UUID.TYPE_TIME_BASED, contents); }
private void decodeHeadersAndProperties(final ByteBuf buffer, boolean lazyProperties) { messageIDPosition = buffer.readerIndex(); messageID = buffer.readLong(); address = SimpleString.readNullableSimpleString(buffer, coreMessageObjectPools == null ? null : coreMessageObjectPools.getAddressDecoderPool()); if (buffer.readByte() == DataConstants.NOT_NULL) { byte[] bytes = new byte[16]; buffer.readBytes(bytes); userID = new UUID(UUID.TYPE_TIME_BASED, bytes); } else { userID = null; } type = buffer.readByte(); durable = buffer.readBoolean(); expiration = buffer.readLong(); timestamp = buffer.readLong(); priority = buffer.readByte(); if (lazyProperties) { properties = null; propertiesLocation = buffer.readerIndex(); } else { properties = new TypedProperties(); properties.decode(buffer, coreMessageObjectPools == null ? null : coreMessageObjectPools.getPropertiesDecoderPools()); } }
private UUID rawReadNodeId() throws SQLException { final PreparedStatement preparedStatement = this.readNodeId; try (ResultSet resultSet = preparedStatement.executeQuery()) { if (!resultSet.next()) { return null; } else { final String nodeId = resultSet.getString(1); if (nodeId != null) { return new UUID(UUID.TYPE_TIME_BASED, UUID.stringToBytes(nodeId)); } else { return null; } } } }
@Override public final SimpleString readNodeId() throws ActiveMQIllegalStateException, IOException { ByteBuffer id = ByteBuffer.allocateDirect(16); int read = channel.read(id, 3); if (read != 16) { throw new ActiveMQIllegalStateException("live server did not write id to file"); } byte[] bytes = new byte[16]; id.position(0); id.get(bytes); setUUID(new UUID(UUID.TYPE_TIME_BASED, bytes)); return getNodeId(); }
/** * Sets the nodeID. * <p> * Only used by replicating backups. * * @param nodeID */ public void setNodeID(String nodeID) { synchronized (nodeIDGuard) { this.nodeID = new SimpleString(nodeID); this.uuid = new UUID(UUID.TYPE_TIME_BASED, UUID.stringToBytes(nodeID)); } }
public UUID generateTimeBasedUUID(final byte[] byteAddr) { byte[] contents = new byte[16]; int pos = 10; System.arraycopy(byteAddr, 0, contents, pos, 6); synchronized (mTimerLock) { if (mTimer == null) { mTimer = new UUIDTimer(getRandomNumberGenerator()); } mTimer.getTimestamp(contents); } return new UUID(UUID.TYPE_TIME_BASED, contents); }
public UUID generateTimeBasedUUID(final byte[] byteAddr) { byte[] contents = new byte[16]; int pos = 10; System.arraycopy(byteAddr, 0, contents, pos, 6); synchronized (mTimerLock) { if (mTimer == null) { mTimer = new UUIDTimer(getRandomNumberGenerator()); } mTimer.getTimestamp(contents); } return new UUID(UUID.TYPE_TIME_BASED, contents); }
public UUID generateTimeBasedUUID(final byte[] byteAddr) { byte[] contents = new byte[16]; int pos = 10; System.arraycopy(byteAddr, 0, contents, pos, 6); synchronized (mTimerLock) { if (mTimer == null) { mTimer = new UUIDTimer(getRandomNumberGenerator()); } mTimer.getTimestamp(contents); } return new UUID(UUID.TYPE_TIME_BASED, contents); }
public UUID generateTimeBasedUUID(final byte[] byteAddr) { byte[] contents = new byte[16]; int pos = 10; System.arraycopy(byteAddr, 0, contents, pos, 6); synchronized (mTimerLock) { if (mTimer == null) { mTimer = new UUIDTimer(getRandomNumberGenerator()); } mTimer.getTimestamp(contents); } return new UUID(UUID.TYPE_TIME_BASED, contents); }
public UUID generateTimeBasedUUID(final byte[] byteAddr) { byte[] contents = new byte[16]; int pos = 10; System.arraycopy(byteAddr, 0, contents, pos, 6); synchronized (mTimerLock) { if (mTimer == null) { mTimer = new UUIDTimer(getRandomNumberGenerator()); } mTimer.getTimestamp(contents); } return new UUID(UUID.TYPE_TIME_BASED, contents); }
public UUID generateTimeBasedUUID(final byte[] byteAddr) { byte[] contents = new byte[16]; int pos = 10; System.arraycopy(byteAddr, 0, contents, pos, 6); synchronized (mTimerLock) { if (mTimer == null) { mTimer = new UUIDTimer(getRandomNumberGenerator()); } mTimer.getTimestamp(contents); } return new UUID(UUID.TYPE_TIME_BASED, contents); }
private void decodeHeadersAndProperties(final ByteBuf buffer, boolean lazyProperties) { messageIDPosition = buffer.readerIndex(); messageID = buffer.readLong(); address = SimpleString.readNullableSimpleString(buffer, coreMessageObjectPools == null ? null : coreMessageObjectPools.getAddressDecoderPool()); if (buffer.readByte() == DataConstants.NOT_NULL) { byte[] bytes = new byte[16]; buffer.readBytes(bytes); userID = new UUID(UUID.TYPE_TIME_BASED, bytes); } else { userID = null; } type = buffer.readByte(); durable = buffer.readBoolean(); expiration = buffer.readLong(); timestamp = buffer.readLong(); priority = buffer.readByte(); if (lazyProperties) { properties = null; propertiesLocation = buffer.readerIndex(); } else { properties = new TypedProperties(INTERNAL_PROPERTY_NAMES_PREDICATE); properties.decode(buffer, coreMessageObjectPools == null ? null : coreMessageObjectPools.getPropertiesDecoderPools()); } }
protected final synchronized void createNodeId() throws IOException { synchronized (nodeIDGuard) { ByteBuffer id = ByteBuffer.allocateDirect(16); int read = channel.read(id, 3); if (replicatedBackup) { id.position(0); id.put(getUUID().asBytes(), 0, 16); id.position(0); channel.write(id, 3); channel.force(true); } else if (read != 16) { setUUID(UUIDGenerator.getInstance().generateUUID()); id.put(getUUID().asBytes(), 0, 16); id.position(0); channel.write(id, 3); channel.force(true); } else { byte[] bytes = new byte[16]; id.position(0); id.get(bytes); setUUID(new UUID(UUID.TYPE_TIME_BASED, bytes)); } } }
private void decodeHeadersAndProperties(final ByteBuf buffer, boolean lazyProperties) { messageIDPosition = buffer.readerIndex(); messageID = buffer.readLong(); address = SimpleString.readNullableSimpleString(buffer, coreMessageObjectPools == null ? null : coreMessageObjectPools.getAddressDecoderPool()); if (buffer.readByte() == DataConstants.NOT_NULL) { byte[] bytes = new byte[16]; buffer.readBytes(bytes); userID = new UUID(UUID.TYPE_TIME_BASED, bytes); } else { userID = null; } type = buffer.readByte(); durable = buffer.readBoolean(); expiration = buffer.readLong(); timestamp = buffer.readLong(); priority = buffer.readByte(); if (lazyProperties) { properties = null; propertiesLocation = buffer.readerIndex(); } else { properties = new TypedProperties(INTERNAL_PROPERTY_NAMES_PREDICATE); properties.decode(buffer, coreMessageObjectPools == null ? null : coreMessageObjectPools.getPropertiesDecoderPools()); } }
private void decodeHeadersAndProperties(final ByteBuf buffer, boolean lazyProperties) { messageIDPosition = buffer.readerIndex(); messageID = buffer.readLong(); address = SimpleString.readNullableSimpleString(buffer, coreMessageObjectPools == null ? null : coreMessageObjectPools.getAddressDecoderPool()); if (buffer.readByte() == DataConstants.NOT_NULL) { byte[] bytes = new byte[16]; buffer.readBytes(bytes); userID = new UUID(UUID.TYPE_TIME_BASED, bytes); } else { userID = null; } type = buffer.readByte(); durable = buffer.readBoolean(); expiration = buffer.readLong(); timestamp = buffer.readLong(); priority = buffer.readByte(); if (lazyProperties) { properties = null; propertiesLocation = buffer.readerIndex(); } else { properties = new TypedProperties(); properties.decode(buffer, coreMessageObjectPools == null ? null : coreMessageObjectPools.getPropertiesDecoderPools()); } }
private void decodeHeadersAndProperties(final ByteBuf buffer, boolean lazyProperties) { messageIDPosition = buffer.readerIndex(); messageID = buffer.readLong(); address = SimpleString.readNullableSimpleString(buffer, coreMessageObjectPools == null ? null : coreMessageObjectPools.getAddressDecoderPool()); if (buffer.readByte() == DataConstants.NOT_NULL) { byte[] bytes = new byte[16]; buffer.readBytes(bytes); userID = new UUID(UUID.TYPE_TIME_BASED, bytes); } else { userID = null; } type = buffer.readByte(); durable = buffer.readBoolean(); expiration = buffer.readLong(); timestamp = buffer.readLong(); priority = buffer.readByte(); if (lazyProperties) { properties = null; propertiesLocation = buffer.readerIndex(); } else { properties = new TypedProperties(); properties.decode(buffer, coreMessageObjectPools == null ? null : coreMessageObjectPools.getPropertiesDecoderPools()); } }
private void decodeHeadersAndProperties(final ByteBuf buffer, boolean lazyProperties) { messageIDPosition = buffer.readerIndex(); messageID = buffer.readLong(); address = SimpleString.readNullableSimpleString(buffer, coreMessageObjectPools == null ? null : coreMessageObjectPools.getAddressDecoderPool()); if (buffer.readByte() == DataConstants.NOT_NULL) { byte[] bytes = new byte[16]; buffer.readBytes(bytes); userID = new UUID(UUID.TYPE_TIME_BASED, bytes); } else { userID = null; } type = buffer.readByte(); durable = buffer.readBoolean(); expiration = buffer.readLong(); timestamp = buffer.readLong(); priority = buffer.readByte(); if (lazyProperties) { properties = null; propertiesLocation = buffer.readerIndex(); } else { properties = new TypedProperties(); properties.decode(buffer, coreMessageObjectPools == null ? null : coreMessageObjectPools.getPropertiesDecoderPools()); } }
UUID uuid = new UUID(UUID.TYPE_TIME_BASED, bytesUUID);
private void decodeHeadersAndProperties(final ByteBuf buffer, boolean lazyProperties) { messageIDPosition = buffer.readerIndex(); messageID = buffer.readLong(); address = SimpleString.readNullableSimpleString(buffer, coreMessageObjectPools == null ? null : coreMessageObjectPools.getAddressDecoderPool()); if (buffer.readByte() == DataConstants.NOT_NULL) { byte[] bytes = new byte[16]; buffer.readBytes(bytes); userID = new UUID(UUID.TYPE_TIME_BASED, bytes); } else { userID = null; } type = buffer.readByte(); durable = buffer.readBoolean(); expiration = buffer.readLong(); timestamp = buffer.readLong(); priority = buffer.readByte(); if (lazyProperties) { properties = null; propertiesLocation = buffer.readerIndex(); } else { properties = new TypedProperties(INTERNAL_PROPERTY_NAMES_PREDICATE); properties.decode(buffer, coreMessageObjectPools == null ? null : coreMessageObjectPools.getPropertiesDecoderPools()); } }
@Test public void testStringToUuidConversion() { UUIDGenerator gen = UUIDGenerator.getInstance(); for (int i = 0; i < MANY_TIMES; i++) { final UUID uuid = gen.generateUUID(); final String uuidString = uuid.toString(); byte[] data2 = UUID.stringToBytes(uuidString); final UUID uuid2 = new UUID(UUID.TYPE_TIME_BASED, data2); assertEqualsByteArrays(uuid.asBytes(), data2); assertEquals(uuidString, uuid, uuid2); assertEquals(uuidString, uuidString, uuid2.toString()); } } }