List of usage examples for java.util UUID UUID
public UUID(long mostSigBits, long leastSigBits)
From source file:org.midonet.benchmarks.mpi.MPIBenchApp.java
/** * Share partial arrays of UUID to form a single array with data from all * processes. All the partial arrays must be of the same size, and can * contain nulls (NOTE: an UUID with all bytes to zero is considered * equivalent to null).//w w w. j a va 2 s . c o m * * @param idArray is the partial array of UUIDS * @return for all processes, the concatenation of all partial arrays */ protected UUID[] allgatherUUID(UUID[] idArray) throws MPIException { int baseArraySize = idArray.length * 2; long[] smsg = new long[baseArraySize]; for (int i = 0; i < idArray.length; i++) { if (idArray[i] == null) { smsg[2 * i] = 0; smsg[2 * i + 1] = 0; } else { smsg[2 * i] = idArray[i].getMostSignificantBits(); smsg[2 * i + 1] = idArray[i].getLeastSignificantBits(); } } // Note: passing the send buffer size as the second length // for the receiving buffer is NOT a bug. long[] rmsg = new long[baseArraySize * mpiSize]; MPI.COMM_WORLD.allGather(smsg, baseArraySize, MPI.LONG, rmsg, baseArraySize, MPI.LONG); UUID[] allIds = new UUID[idArray.length * mpiSize]; for (int i = 0; i < (idArray.length * mpiSize); i++) { if (rmsg[2 * i] == 0 && rmsg[2 * i + 1] == 0) { allIds[i] = null; } else { allIds[i] = new UUID(rmsg[2 * i], rmsg[2 * i + 1]); } } return allIds; }
From source file:org.linguafranca.pwdb.kdbx.dom.DomHelper.java
static UUID uuidFromBase64(String base64) { // round the houses for Android byte[] buffer = Base64.decodeBase64(base64.getBytes()); ByteBuffer b = ByteBuffer.wrap(buffer); return new UUID(b.getLong(), b.getLong(8)); }
From source file:com.palantir.atlasdb.keyvalue.cassandra.CassandraKeyValueServices.java
static String convertCassandraByteBufferUUIDtoString(ByteBuffer uuid) { return new UUID(uuid.getLong(uuid.position()), uuid.getLong(uuid.position() + 8)).toString(); }
From source file:com.strategicgains.docussandra.controller.QueryControllerTest.java
/** * Tests that the POST /{databases}/{table}/query endpoint properly runs a * query with limits.//from w w w . j a va 2 s . com */ @Test public void postQueryTestWithLimitMoreThanResponse() { Query q = new Query(); q.setWhere("field1 = 'this is my data'"); q.setTable("mytable"); //act given().header("limit", "10000").header("offset", "0").body("{\"where\":\"" + q.getWhere() + "\"}").expect() .statusCode(200) //.header("Location", startsWith(RestAssured.basePath + "/")) .body("", notNullValue()).body("id", notNullValue()) .body("id[0]", equalTo(new UUID(Long.MAX_VALUE - 33, 1l).toString())) .body("object[0]", notNullValue()) .body("object[0]", containsString("this is some more random data32")).when().post(""); }
From source file:controllers.ProcessController.java
@RequestMapping(value = "login/resetProcessing", method = RequestMethod.POST) public String submitReset(ModelMap model, @RequestParam("password") String password, @RequestParam("comfirm") String comfirmPassword, @RequestParam("username") String username, @RequestParam("token") String tokenString) { String oldPassword = ""; Users user = new Users(); Session session = HibernateUtil.getSessionFactory().openSession(); try {/* w ww . j av a 2 s. c o m*/ session.getTransaction().begin(); Query query = session.createQuery("FROM Users WHERE username = :username"); query.setString("username", username); user = (Users) query.uniqueResult(); oldPassword = user.getPassword(); session.getTransaction().commit(); } catch (Exception e) { session.getTransaction().rollback(); } if (!password.equals(comfirmPassword)) { model.addAttribute("message", "Comfirm password not match! Please try again!"); model.addAttribute("username", username); model.addAttribute("token", tokenString); return "reset-password"; } else if (oldPassword.equals(comfirmPassword)) { model.addAttribute("message", "The new password is same with the old one! Please try agian!"); model.addAttribute("username", username); model.addAttribute("token", tokenString); return "reset-password"; } else { UsersDAO usersDAO = new UsersDAO(); usersDAO.changePassword(user, password); model.addAttribute("message", "Reset password complete!"); for (ChangePasswordToken token : list) { if (token.getToken().toString().equals(tokenString)) { token.setToken(new UUID(0, 0)); token.setEmail(""); } } return "reset-message"; } }
From source file:com.joyent.manta.client.multipart.ServerSideMultipartManagerTest.java
public void canAbortMpu() throws IOException { StatusLine statusLine = new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_NO_CONTENT, "NO_CONTENT"); ServerSideMultipartManager manager = buildMockManager(statusLine, null); UUID id = new UUID(0L, 0L); String partsDirectory = manager.uuidPrefixedPath(id); ServerSideMultipartUpload upload = new ServerSideMultipartUpload(id, null, partsDirectory); manager.abort(upload);/*from w w w. j a v a 2 s . c om*/ }
From source file:com.eventsourcing.postgresql.PostgreSQLJournalTest.java
@Test @SneakyThrows// w w w. j a va2 s .c o m public void serializationNull() { HybridTimestamp timestamp = new HybridTimestamp(timeProvider); timestamp.update(); Journal.Transaction tx = journal.beginTransaction(); SerializationEvent event = SerializationEvent.builder().test(TestClass.builder().build()).build(); event = (SerializationEvent) journal.journal(tx, event); tx.rollback(); TestClass test = event.getTest(); assertEquals(test.pByte, 0); assertEquals(test.oByte, Byte.valueOf((byte) 0)); assertEquals(test.pByteArr.length, 0); assertEquals(test.oByteArr.length, 0); assertEquals(test.pShort, 0); assertEquals(test.oShort, Short.valueOf((short) 0)); assertEquals(test.pInt, 0); assertEquals(test.oInt, Integer.valueOf(0)); assertEquals(test.pLong, 0); assertEquals(test.oLong, Long.valueOf(0)); assertTrue(test.pFloat == 0.0); assertEquals(test.oFloat, Float.valueOf((float) 0.0)); assertEquals(test.pDouble, 0.0); assertEquals(test.oDouble, Double.valueOf(0.0)); assertEquals(test.pBoolean, false); assertEquals(test.oBoolean, Boolean.FALSE); assertEquals(test.str, ""); assertEquals(test.uuid, new UUID(0, 0)); assertEquals(test.e, TestClass.E.A); assertNotNull(test.value); assertEquals(test.value.value, ""); assertNotNull(test.value1); assertTrue(test.value1.value().isEmpty()); assertNotNull(test.list); assertEquals(test.list.size(), 0); assertNotNull(test.map); assertEquals(test.map.size(), 0); assertNotNull(test.optional); assertFalse(test.optional.isPresent()); assertNotNull(test.bigDecimal); assertEquals(test.bigDecimal, BigDecimal.ZERO); assertNotNull(test.bigInteger); assertEquals(test.bigInteger, BigInteger.ZERO); assertNotNull(test.date); assertEquals(test.date, new Date(0)); }
From source file:com.joyent.manta.client.multipart.ServerSideMultipartManagerTest.java
public void canCompleteMpu() throws IOException { StatusLine statusLine = new BasicStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_CREATED, "NO_CONTENT"); ServerSideMultipartManager manager = buildMockManager(statusLine, null); UUID id = new UUID(0L, 0L); String partsDirectory = manager.uuidPrefixedPath(id); ServerSideMultipartUpload upload = new ServerSideMultipartUpload(id, "/test/stor/myobject", partsDirectory); MantaMultipartUploadTuple[] unsortedTuples = new MantaMultipartUploadTuple[] { new MantaMultipartUploadTuple(5, new UUID(0L, 5L)), new MantaMultipartUploadTuple(3, new UUID(0L, 3L)), new MantaMultipartUploadTuple(1, new UUID(0L, 1L)), new MantaMultipartUploadTuple(2, new UUID(0L, 2L)), new MantaMultipartUploadTuple(4, new UUID(0L, 4L)) }; manager.complete(upload, Stream.of(unsortedTuples)); }
From source file:com.strategicgains.docussandra.controller.QueryControllerTest.java
/** * Tests that the POST /{databases}/{table}/query endpoint properly runs a * query with limits.//from ww w. j a v a2s .co m */ @Test public void postQueryTestWithLimitAndOffset() { Query q = new Query(); q.setWhere("field1 = 'this is my data'"); q.setTable("mytable"); //act given().header("limit", "1").header("offset", "1").body("{\"where\":\"" + q.getWhere() + "\"}").expect() .statusCode(206) //.header("Location", startsWith(RestAssured.basePath + "/")) .body("", notNullValue()).body("id", notNullValue()) .body("id[0]", equalTo(new UUID(Long.MAX_VALUE - 32, 1l).toString())) .body("object[0]", notNullValue()) .body("object[0]", containsString("this is some more random data31")).when().post(""); }
From source file:com.palantir.atlasdb.ptobject.EncodingUtils.java
public static UUID decodeUUID(byte[] bytes, int offset) { ByteBuffer buf = ByteBuffer.wrap(bytes, offset, 2 * Longs.BYTES).order(ByteOrder.BIG_ENDIAN); long mostSigBits = buf.getLong(); long leastSigBits = buf.getLong(); return new UUID(mostSigBits, leastSigBits); }