List of usage examples for java.util UUID getMostSignificantBits
public long getMostSignificantBits()
From source file:natalia.dymnikova.cluster.scheduler.impl.AkkaBackedScheduler.java
private String makeFlowName(String descriptor) { final UUID uuid = UUID.randomUUID(); return format("%s%016x%016x", descriptor, uuid.getMostSignificantBits(), uuid.getLeastSignificantBits()); }
From source file:ro.kuberam.libs.java.crypto.CryptoModuleTests.java
@Test public void uuid5NewTest() throws Exception { final String NameSpace_OID_string = "6ba7b812-9dad-11d1-80b4-00c04fd430c8"; final UUID NameSpace_OID_uuid = UUID.fromString(NameSpace_OID_string); final long msb = NameSpace_OID_uuid.getMostSignificantBits(); final long lsb = NameSpace_OID_uuid.getLeastSignificantBits(); final byte[] NameSpace_OID_buffer = new byte[16]; for (int i = 0; i < 8; i++) { NameSpace_OID_buffer[i] = (byte) (msb >>> 8 * (7 - i)); }/*from w w w . jav a 2 s .com*/ for (int i = 8; i < 16; i++) { NameSpace_OID_buffer[i] = (byte) (lsb >>> 8 * (7 - i)); } final String name = "user123"; final byte[] name_buffer = name.getBytes(); try (final ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { outputStream.write(NameSpace_OID_buffer); outputStream.write(name_buffer); final byte byteArray[] = outputStream.toByteArray(); System.out.println(UUID.nameUUIDFromBytes(byteArray).toString()); } catch (final IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.github.sebhoss.identifier.service.SuppliedIdentifiers.java
private String convertUuidToBase64(final UUID uuid) { final ByteBuffer bb = ByteBuffer.wrap(new byte[16]); bb.putLong(uuid.getMostSignificantBits()); bb.putLong(uuid.getLeastSignificantBits()); return removePadding(encoder.encodeToString(bb.array())); }
From source file:org.apache.cassandra.db.marshal.TypeCompareTest.java
License:asdf
@Test public void testTimeUUID() { // two different UUIDs w/ the same timestamp UUID uuid1 = UUID.fromString("1077e700-c7f2-11de-86d5-f5bcc793a028"); byte[] bytes1 = new byte[16]; ByteBuffer bb1 = ByteBuffer.wrap(bytes1); bb1.putLong(uuid1.getMostSignificantBits()); bb1.putLong(uuid1.getLeastSignificantBits()); UUID uuid2 = UUID.fromString("1077e700-c7f2-11de-982e-6fad363d5f29"); byte[] bytes2 = new byte[16]; ByteBuffer bb2 = ByteBuffer.wrap(bytes2); bb2.putLong(uuid2.getMostSignificantBits()); bb2.putLong(uuid2.getLeastSignificantBits()); assert new TimeUUIDType().compare(bytes1, bytes2) != 0; }
From source file:io.warp10.quasar.encoder.QuasarTokenEncoder.java
private ByteBuffer toByteBuffer(String strUUID) { ByteBuffer buffer = ByteBuffer.allocate(16); buffer.order(ByteOrder.BIG_ENDIAN); UUID uuid = UUID.fromString(strUUID); buffer.putLong(uuid.getMostSignificantBits()); buffer.putLong(uuid.getLeastSignificantBits()); buffer.position(0);/*from www . j ava 2s. c o m*/ return buffer; }
From source file:org.midonet.benchmarks.mpi.MPIBenchApp.java
/** * Broadcast an UUID value from the 'source' process to the rest. * Note: an UUID with all bytes to zero is considered equivalent to null * (and therefore, converted to null)./*from ww w . ja va 2s .co m*/ * * @param id is the UUID to transmit, only needs to be set in the * source process. * @param source is the rank of the source process. * @return for all processes, the transmitted UUID */ protected UUID broadcastUUID(UUID id, int source) throws MPIException { long[] msg = { 0, 0 }; if (source == mpiRank) { if (id != null) { msg[0] = id.getMostSignificantBits(); msg[1] = id.getLeastSignificantBits(); } } MPI.COMM_WORLD.bcast(msg, 2, MPI.LONG, source); return (msg[0] == 0 && msg[1] == 0) ? null : new UUID(msg[0], msg[1]); }
From source file:org.hillview.dataset.RemoteDataSet.java
@Override public Observable<PartialResult<ControlMessage.StatusList>> manage(ControlMessage message) { final ManageOperation manageOp = new ManageOperation(message); final byte[] serializedOp = SerializationUtils.serialize(manageOp); final UUID operationId = UUID.randomUUID(); final Command command = Command.newBuilder().setIdsIndex(this.remoteHandle) .setSerializedOp(ByteString.copyFrom(serializedOp)).setHighId(operationId.getMostSignificantBits()) .setLowId(operationId.getLeastSignificantBits()).build(); final SerializedSubject<PartialResult<ControlMessage.StatusList>, PartialResult<ControlMessage.StatusList>> subj = createSerializedSubject(); final StreamObserver<PartialResponse> responseObserver = new ManageObserver(subj, message, this); return subj.unsubscribeOn(ExecutorUtils.getUnsubscribeScheduler()).doOnSubscribe( () -> this.stub.withDeadlineAfter(TIMEOUT, TimeUnit.MILLISECONDS).manage(command, responseObserver)) .doOnUnsubscribe(() -> this.unsubscribe(operationId)); }
From source file:org.hillview.dataset.RemoteDataSet.java
/** * Map operations on a RemoteDataSet result in only one onNext * invocation that will return the final IDataSet. */// w w w . j av a2s . co m @Override public <S> Observable<PartialResult<IDataSet<S>>> map(final IMap<T, S> mapper) { final MapOperation<T, S> mapOp = new MapOperation<T, S>(mapper); final byte[] serializedOp = SerializationUtils.serialize(mapOp); final UUID operationId = UUID.randomUUID(); final Command command = Command.newBuilder().setIdsIndex(this.remoteHandle) .setSerializedOp(ByteString.copyFrom(serializedOp)).setHighId(operationId.getMostSignificantBits()) .setLowId(operationId.getLeastSignificantBits()).build(); final SerializedSubject<PartialResult<IDataSet<S>>, PartialResult<IDataSet<S>>> subj = createSerializedSubject(); final StreamObserver<PartialResponse> responseObserver = new NewDataSetObserver<S>(subj); return subj.unsubscribeOn(ExecutorUtils.getUnsubscribeScheduler()).doOnSubscribe( () -> this.stub.withDeadlineAfter(TIMEOUT, TimeUnit.MILLISECONDS).map(command, responseObserver)) .doOnUnsubscribe(() -> this.unsubscribe(operationId)); }
From source file:org.hillview.dataset.RemoteDataSet.java
@Override public <S> Observable<PartialResult<IDataSet<S>>> flatMap(IMap<T, List<S>> mapper) { final FlatMapOperation<T, S> mapOp = new FlatMapOperation<T, S>(mapper); final byte[] serializedOp = SerializationUtils.serialize(mapOp); final UUID operationId = UUID.randomUUID(); final Command command = Command.newBuilder().setIdsIndex(this.remoteHandle) .setSerializedOp(ByteString.copyFrom(serializedOp)).setHighId(operationId.getMostSignificantBits()) .setLowId(operationId.getLeastSignificantBits()).build(); final SerializedSubject<PartialResult<IDataSet<S>>, PartialResult<IDataSet<S>>> subj = createSerializedSubject(); final StreamObserver<PartialResponse> responseObserver = new NewDataSetObserver<S>(subj); return subj//from w w w . ja va 2 s. c om .unsubscribeOn(ExecutorUtils.getUnsubscribeScheduler()).doOnSubscribe(() -> this.stub .withDeadlineAfter(TIMEOUT, TimeUnit.MILLISECONDS).flatMap(command, responseObserver)) .doOnUnsubscribe(() -> this.unsubscribe(operationId)); }
From source file:org.hillview.dataset.RemoteDataSet.java
/** * Sketch operation that streams partial results from the server to the caller. */// w ww. jav a2 s . c om @Override public <R> Observable<PartialResult<R>> sketch(final ISketch<T, R> sketch) { final SketchOperation<T, R> sketchOp = new SketchOperation<T, R>(sketch); final byte[] serializedOp = SerializationUtils.serialize(sketchOp); final UUID operationId = UUID.randomUUID(); final Command command = Command.newBuilder().setIdsIndex(this.remoteHandle) .setSerializedOp(ByteString.copyFrom(serializedOp)).setHighId(operationId.getMostSignificantBits()) .setLowId(operationId.getLeastSignificantBits()).build(); final SerializedSubject<PartialResult<R>, PartialResult<R>> subj = createSerializedSubject(); final StreamObserver<PartialResponse> responseObserver = new SketchObserver<R>(subj); return subj .doOnSubscribe(() -> this.stub.withDeadlineAfter(TIMEOUT, TimeUnit.MILLISECONDS).sketch(command, responseObserver)) .unsubscribeOn(ExecutorUtils.getUnsubscribeScheduler()) .doOnUnsubscribe(() -> this.unsubscribe(operationId)); }