List of usage examples for org.apache.cassandra.utils UUIDGen getTimeUUID
public static UUID getTimeUUID()
From source file:com.intuit.wasabi.assignmentobjects.AssignmentEnvelopePayload.java
License:Apache License
@Override public String toJson() { JSONObject assignmentJson = new JSONObject(); assignmentJson.put("userID", userID != null ? userID.toString() : ""); assignmentJson.put("applicationName", applicationName != null ? applicationName.toString() : ""); assignmentJson.put("experimentLabel", experimentLabel != null ? experimentLabel.toString() : ""); assignmentJson.put("context", context != null ? context.toString() : "PROD"); assignmentJson.put("createAssignment", createAssignment); assignmentJson.put("putAssignment", putAssignment); assignmentJson.put("ignoreSamplingPercent", ignoreSamplingPercent); assignmentJson.put("segmentationProfile", segmentationProfile != null ? segmentationProfile.getProfile() != null ? segmentationProfile.getProfile().toString() : "" : ""); assignmentJson.put("experimentID", experimentID != null ? experimentID.toString() : ""); assignmentJson.put("pageName", pageName != null ? pageName.toString() : ""); assignmentJson.put("assignmentStatus", assignmentStatus != null ? assignmentStatus.toString() : ""); assignmentJson.put("bucketLabel", bucketLabel != null ? bucketLabel.toString() : "NULL"); assignmentJson.put("time_uuid", UUIDGen.getTimeUUID()); assignmentJson.put("epochTimestamp", date != null ? date.getTime() : ""); assignmentJson.put("messageType", MessageType.ASSIGNMENT.toString()); return assignmentJson.toString(); }
From source file:com.intuit.wasabi.eventobjects.EventEnvelopePayload.java
License:Apache License
/** * Helper method for creating uuid * @return UUID */ protected UUID makeUUID() { return UUIDGen.getTimeUUID(); }
From source file:com.intuit.wasabi.repository.cassandra.impl.CassandraAssignmentsRepository.java
License:Apache License
/** * {@inheritDoc}//from w w w .ja v a 2 s . c o m */ public void pushAssignmentsToStaging(String type, String exception, Collection<String> data) { try { Session session = driver.getSession(); final BatchStatement batchStatement = new BatchStatement(BatchStatement.Type.UNLOGGED); final UUID timeUUID = UUIDGen.getTimeUUID(); data.forEach(message -> { LOGGER.debug("message={}", message); batchStatement.add(stagingAccessor.batchInsertBy(timeUUID, type, exception, message)); }); session.execute(batchStatement); LOGGER.debug("Finished pushAssignmentsToStaging"); } catch (Exception e) { LOGGER.error("Error occurred while pushAssignmentsToStaging", e); throw new RepositoryException("Error occurred while pushAssignmentsToStaging", e); } }
From source file:info.archinnov.achilles.test.integration.tests.ClusteredEntityIT2.java
License:Apache License
@Test public void should_persist_and_find() throws Exception { Long userId = new Random().nextLong(); UUID tweetId = UUIDGen.getTimeUUID(); Date creationDate = new Date(); ClusteredTweetId id = new ClusteredTweetId(userId, tweetId, creationDate); ClusteredTweetEntity tweet = new ClusteredTweetEntity(id, "this is a tweet", userId, false); manager.persist(tweet);/* w w w . jav a 2s .c o m*/ ClusteredTweetEntity found = manager.find(ClusteredTweetEntity.class, id); assertThat(found.getContent()).isEqualTo("this is a tweet"); assertThat(found.getOriginalAuthorId()).isEqualTo(userId); assertThat(found.getIsARetweet()).isFalse(); }
From source file:info.archinnov.achilles.test.integration.tests.ClusteredEntityIT2.java
License:Apache License
@Test public void should_merge() throws Exception { Long userId = new Random().nextLong(); Long originalAuthorId = new Random().nextLong(); UUID tweetId = UUIDGen.getTimeUUID(); Date creationDate = new Date(); ClusteredTweetId id = new ClusteredTweetId(userId, tweetId, creationDate); ClusteredTweetEntity tweet = new ClusteredTweetEntity(id, "this is a tweet", userId, false); tweet = manager.persist(tweet);// w ww.j a v a 2 s .c om tweet.setContent("this is a new tweet2"); tweet.setIsARetweet(true); tweet.setOriginalAuthorId(originalAuthorId); manager.update(tweet); ClusteredTweetEntity found = manager.find(ClusteredTweetEntity.class, id); assertThat(found.getContent()).isEqualTo("this is a new tweet2"); assertThat(found.getOriginalAuthorId()).isEqualTo(originalAuthorId); assertThat(found.getIsARetweet()).isTrue(); }
From source file:info.archinnov.achilles.test.integration.tests.ClusteredEntityIT2.java
License:Apache License
@Test public void should_remove() throws Exception { Long userId = new Random().nextLong(); UUID tweetId = UUIDGen.getTimeUUID(); Date creationDate = new Date(); ClusteredTweetId id = new ClusteredTweetId(userId, tweetId, creationDate); ClusteredTweetEntity tweet = new ClusteredTweetEntity(id, "this is a tweet", userId, false); tweet = manager.persist(tweet);// www .ja va 2 s.co m manager.remove(tweet); ClusteredTweetEntity found = manager.find(ClusteredTweetEntity.class, id); assertThat(found).isNull(); }
From source file:info.archinnov.achilles.test.integration.tests.ClusteredEntityIT2.java
License:Apache License
@Test public void should_refresh() throws Exception { Long userId = new Random().nextLong(); Long originalAuthorId = new Random().nextLong(); UUID tweetId = UUIDGen.getTimeUUID(); Date creationDate = new Date(); ClusteredTweetId id = new ClusteredTweetId(userId, tweetId, creationDate); ClusteredTweetEntity tweet = new ClusteredTweetEntity(id, "this is a tweet", userId, false); tweet = manager.persist(tweet);// w w w . ja v a2 s.c o m session.execute("update " + CLUSTERED_TWEET_TABLE + " set content='New tweet',original_author_id=" + originalAuthorId + ",is_a_retweet=true where user_id=" + userId + " and tweet_id=" + tweetId + " and creation_date=" + creationDate.getTime()); Thread.sleep(100); manager.refresh(tweet); assertThat(tweet.getContent()).isEqualTo("New tweet"); assertThat(tweet.getOriginalAuthorId()).isEqualTo(originalAuthorId); assertThat(tweet.getIsARetweet()).isTrue(); }
From source file:info.archinnov.achilles.test.integration.tests.InitializeIT.java
License:Apache License
@Test public void should_initialize_lazy_properties() throws Exception { Tweet tweet = new Tweet(); tweet.setId(UUIDGen.getTimeUUID()); tweet.setContent("welcome"); CompleteBean entity = CompleteBeanTestBuilder.builder().randomId().name("name").label("label").age(45L) .addFriends("foo", "bar").welcomeTweet(tweet).version(CounterBuilder.incr(11L)).buid(); manager.persist(entity);//from w ww .j a v a 2 s . co m CompleteBean foundEntity = manager.find(CompleteBean.class, entity.getId()); CompleteBean rawEntity = manager.initAndRemoveProxy(foundEntity); assertThat(rawEntity.getName()).isEqualTo("name"); assertThat(rawEntity.getLabel()).isEqualTo("label"); assertThat(rawEntity.getAge()).isEqualTo(45L); assertThat(rawEntity.getFriends()).containsExactly("foo", "bar"); assertThat(rawEntity.getWelcomeTweet().getContent()).isEqualTo("welcome"); assertThat(rawEntity.getVersion()).isInstanceOf(InternalCounterImpl.class); assertThat(rawEntity.getVersion().get()).isEqualTo(11L); }
From source file:info.archinnov.achilles.test.integration.tests.QueryIT.java
License:Apache License
@Test public void should_return_cql_functions_for_native_query() throws Exception { Long id = new Random().nextLong(); UUID date = UUIDGen.getTimeUUID(); manager.persist(new ClusteredEntityWithTimeUUID(id, date, "value")); Map<String, Object> result = manager.nativeQuery("SELECT now(),dateOf(date),unixTimestampOf(date) FROM " + ClusteredEntityWithTimeUUID.TABLE_NAME + " WHERE id=" + id).first(); assertThat(result.get("now()")).isNotNull().isInstanceOf(UUID.class); assertThat(result.get("dateOf(date)")).isNotNull().isInstanceOf(Date.class); assertThat(result.get("unixTimestampOf(date)")).isNotNull().isInstanceOf(Long.class); }
From source file:kina.rdd.CassandraJavaRDDTest.java
License:Apache License
@Override public Cells call(Tuple2<String, Double> t) throws Exception { Cell sensorNameCell = CassandraCell.create("name", t._1()); Cell sensorTimeUUID = CassandraCell.create("time_taken", UUIDGen.getTimeUUID()); Cell sensorDataCell = CassandraCell.create("value", t._2()); return new Cells("defaultTable", sensorNameCell, sensorTimeUUID, sensorDataCell); }