@Test public void testEmptyListReturnedWhenImageSeqIsEqualToLatest() throws Exception { Mockito.when(imageRetriever.getLatestImageID()).thenReturn(1L); Mockito.when(deltaRetriever.getLatestDeltaID()).thenReturn(10L); List<PathsUpdate> updates = updater.getAllUpdatesFrom(11, 1); assertTrue(updates.isEmpty()); }
List<K> getAllUpdatesFrom(long seqNum, long imgNum) throws Exception { LOGGER.debug(String.format("(%s) GetAllUpdatesFrom sequence number %d, image number %d", retrieverType, seqNum, imgNum)); if (imgNum >= IMAGE_NUMBER_UPDATE_UNINITIALIZED) { long curImgNum = imageRetriever.getLatestImageID(); LOGGER.debug("({}) Current image number for is {}", retrieverType, curImgNum); if (curImgNum == IMAGE_NUMBER_UPDATE_UNINITIALIZED) { return Collections.emptyList(); } if (curImgNum > imgNum) { String logMessage = String.format("(%s) Current image num %d is greater than requested " + "image num %d. Request a full update", retrieverType, curImgNum, imgNum); LOGGER.info(logMessage); System.out.println(SentryServiceUtil.getCurrentTimeStampWithMessage(logMessage)); List<K>fullImage = retrieveFullImage(); if( !fullImage.isEmpty()) { logMessage = String.format("(%s) A newer full update with image number %d " + "is less than requested image number %d. Send full update to HDFS", retrieverType, curImgNum, imgNum); LOGGER.info(logMessage); System.out.println(SentryServiceUtil.getCurrentTimeStampWithMessage(logMessage)); } return fullImage; } } long curSeqNum = deltaRetriever.getLatestDeltaID(); LOGGER.debug("({}) Current sequence number is {}", retrieverType, curSeqNum); if (seqNum == curSeqNum + 1) { LOGGER.debug("{}, No new updates", retrieverType); return Collections.emptyList(); } if (seqNum > SEQUENCE_NUMBER_FULL_UPDATE_REQUEST && deltaRetriever.isDeltaAvailable(seqNum)) { List<K> deltas = deltaRetriever.retrieveDelta(seqNum, imgNum); if (!deltas.isEmpty()) { LOGGER.info("({}) Newer delta updates are found up to sequence number {} and being sent to HDFS", retrieverType, curSeqNum); return deltas; } } String logMessage = String.format("(%s) Requested sequence number %d is less than 0 or " + "requested deltas for that sequence number are not available. Fetch a full update", retrieverType, seqNum); LOGGER.info(logMessage); System.out.println(SentryServiceUtil.getCurrentTimeStampWithMessage(logMessage)); List<K>fullImage = retrieveFullImage(); if( fullImage != null && !fullImage.isEmpty()) { logMessage = String.format("(%s) A full update is returned due to an unavailable sequence number: %d", retrieverType, seqNum); LOGGER.info(logMessage); System.out.println(SentryServiceUtil.getCurrentTimeStampWithMessage(logMessage)); } return fullImage; }
DBUpdateForwarder { List<K> getAllUpdatesFrom(long seqNum, long imgNum) throws Exception { LOGGER.debug(String.format("(%s) GetAllUpdatesFrom sequence number %d, image number %d", retrieverType, seqNum, imgNum)); if (imgNum >= IMAGE_NUMBER_UPDATE_UNINITIALIZED) { long curImgNum = imageRetriever.getLatestImageID(); LOGGER.debug("({}) Current image number for is {}", retrieverType, curImgNum); if (curImgNum == IMAGE_NUMBER_UPDATE_UNINITIALIZED) { return Collections.emptyList(); } if (curImgNum > imgNum) { String logMessage = String.format("(%s) Current image num %d is greater than requested " + "image num %d. Request a full update", retrieverType, curImgNum, imgNum); LOGGER.info(logMessage); System.out.println(SentryServiceUtil.getCurrentTimeStampWithMessage(logMessage)); List<K>fullImage = retrieveFullImage(); if( !fullImage.isEmpty()) { logMessage = String.format("(%s) A newer full update with image number %d " + "is less than requested image number %d. Send full update to HDFS", retrieverType, curImgNum, imgNum); LOGGER.info(logMessage); System.out.println(SentryServiceUtil.getCurrentTimeStampWithMessage(logMessage)); } return fullImage; } } long curSeqNum = deltaRetriever.getLatestDeltaID(); LOGGER.debug("({}) Current sequence number is {}", retrieverType, curSeqNum); if (seqNum == curSeqNum + 1) { LOGGER.debug("{}, No new updates", retrieverType); return Collections.emptyList(); } if (seqNum > SEQUENCE_NUMBER_FULL_UPDATE_REQUEST && deltaRetriever.isDeltaAvailable(seqNum)) { List<K> deltas = deltaRetriever.retrieveDelta(seqNum, imgNum); if (!deltas.isEmpty()) { LOGGER.info("({}) Newer delta updates are found up to sequence number {} and being sent to HDFS", retrieverType, curSeqNum); return deltas; } } String logMessage = String.format("(%s) Requested sequence number %d is less than 0 or " + "requested deltas for that sequence number are not available. Fetch a full update", retrieverType, seqNum); LOGGER.info(logMessage); System.out.println(SentryServiceUtil.getCurrentTimeStampWithMessage(logMessage)); List<K>fullImage = retrieveFullImage(); if( fullImage != null && !fullImage.isEmpty()) { logMessage = String.format("(%s) A full update is returned due to an unavailable sequence number: %d", retrieverType, seqNum); LOGGER.info(logMessage); System.out.println(SentryServiceUtil.getCurrentTimeStampWithMessage(logMessage)); } return fullImage; } }
DBUpdateForwarder { List<K> getAllUpdatesFrom(long seqNum, long imgNum) throws Exception { LOGGER.debug(String.format("(%s) GetAllUpdatesFrom sequence number %d, image number %d", retrieverType, seqNum, imgNum)); if (imgNum >= IMAGE_NUMBER_UPDATE_UNINITIALIZED) { long curImgNum = imageRetriever.getLatestImageID(); LOGGER.debug("({}) Current image number for is {}", retrieverType, curImgNum); if (curImgNum == IMAGE_NUMBER_UPDATE_UNINITIALIZED) { return Collections.emptyList(); } if (curImgNum > imgNum) { String logMessage = String.format("(%s) Current image num %d is greater than requested " + "image num %d. Request a full update", retrieverType, curImgNum, imgNum); LOGGER.info(logMessage); System.out.println(SentryServiceUtil.getCurrentTimeStampWithMessage(logMessage)); List<K>fullImage = retrieveFullImage(); if( !fullImage.isEmpty()) { logMessage = String.format("(%s) A newer full update with image number %d " + "is less than requested image number %d. Send full update to HDFS", retrieverType, curImgNum, imgNum); LOGGER.info(logMessage); System.out.println(SentryServiceUtil.getCurrentTimeStampWithMessage(logMessage)); } return fullImage; } } long curSeqNum = deltaRetriever.getLatestDeltaID(); LOGGER.debug("({}) Current sequence number is {}", retrieverType, curSeqNum); if (seqNum == curSeqNum + 1) { LOGGER.debug("{}, No new updates", retrieverType); return Collections.emptyList(); } if (seqNum > SEQUENCE_NUMBER_FULL_UPDATE_REQUEST && deltaRetriever.isDeltaAvailable(seqNum)) { List<K> deltas = deltaRetriever.retrieveDelta(seqNum, imgNum); if (!deltas.isEmpty()) { LOGGER.info("({}) Newer delta updates are found up to sequence number {} and being sent to HDFS", retrieverType, curSeqNum); return deltas; } } String logMessage = String.format("(%s) Requested sequence number %d is less than 0 or " + "requested deltas for that sequence number are not available. Fetch a full update", retrieverType, seqNum); LOGGER.info(logMessage); System.out.println(SentryServiceUtil.getCurrentTimeStampWithMessage(logMessage)); List<K>fullImage = retrieveFullImage(); if( fullImage != null && !fullImage.isEmpty()) { logMessage = String.format("(%s) A full update is returned due to an unavailable sequence number: %d", retrieverType, seqNum); LOGGER.info(logMessage); System.out.println(SentryServiceUtil.getCurrentTimeStampWithMessage(logMessage)); } return fullImage; } DBUpdateForwarder(final ImageRetriever<K> imageRetriever,
      final DeltaRetriever<K> deltaRetriever); }
DBUpdateForwarder { List<K> getAllUpdatesFrom(long seqNum, long imgNum) throws Exception { LOGGER.debug(String.format("(%s) GetAllUpdatesFrom sequence number %d, image number %d", retrieverType, seqNum, imgNum)); if (imgNum >= IMAGE_NUMBER_UPDATE_UNINITIALIZED) { long curImgNum = imageRetriever.getLatestImageID(); LOGGER.debug("({}) Current image number for is {}", retrieverType, curImgNum); if (curImgNum == IMAGE_NUMBER_UPDATE_UNINITIALIZED) { return Collections.emptyList(); } if (curImgNum > imgNum) { String logMessage = String.format("(%s) Current image num %d is greater than requested " + "image num %d. Request a full update", retrieverType, curImgNum, imgNum); LOGGER.info(logMessage); System.out.println(SentryServiceUtil.getCurrentTimeStampWithMessage(logMessage)); List<K>fullImage = retrieveFullImage(); if( !fullImage.isEmpty()) { logMessage = String.format("(%s) A newer full update with image number %d " + "is less than requested image number %d. Send full update to HDFS", retrieverType, curImgNum, imgNum); LOGGER.info(logMessage); System.out.println(SentryServiceUtil.getCurrentTimeStampWithMessage(logMessage)); } return fullImage; } } long curSeqNum = deltaRetriever.getLatestDeltaID(); LOGGER.debug("({}) Current sequence number is {}", retrieverType, curSeqNum); if (seqNum == curSeqNum + 1) { LOGGER.debug("{}, No new updates", retrieverType); return Collections.emptyList(); } if (seqNum > SEQUENCE_NUMBER_FULL_UPDATE_REQUEST && deltaRetriever.isDeltaAvailable(seqNum)) { List<K> deltas = deltaRetriever.retrieveDelta(seqNum, imgNum); if (!deltas.isEmpty()) { LOGGER.info("({}) Newer delta updates are found up to sequence number {} and being sent to HDFS", retrieverType, curSeqNum); return deltas; } } String logMessage = String.format("(%s) Requested sequence number %d is less than 0 or " + "requested deltas for that sequence number are not available. Fetch a full update", retrieverType, seqNum); LOGGER.info(logMessage); System.out.println(SentryServiceUtil.getCurrentTimeStampWithMessage(logMessage)); List<K>fullImage = retrieveFullImage(); if( fullImage != null && !fullImage.isEmpty()) { logMessage = String.format("(%s) A full update is returned due to an unavailable sequence number: %d", retrieverType, seqNum); LOGGER.info(logMessage); System.out.println(SentryServiceUtil.getCurrentTimeStampWithMessage(logMessage)); } return fullImage; } DBUpdateForwarder(final ImageRetriever<K> imageRetriever,
      final DeltaRetriever<K> deltaRetriever); static void translateOwnerPrivileges(Map<TPrivilegePrincipal,String> privMap); }
DBUpdateForwarder { List<K> getAllUpdatesFrom(long seqNum, long imgNum) throws Exception { LOGGER.debug(String.format("(%s) GetAllUpdatesFrom sequence number %d, image number %d", retrieverType, seqNum, imgNum)); if (imgNum >= IMAGE_NUMBER_UPDATE_UNINITIALIZED) { long curImgNum = imageRetriever.getLatestImageID(); LOGGER.debug("({}) Current image number for is {}", retrieverType, curImgNum); if (curImgNum == IMAGE_NUMBER_UPDATE_UNINITIALIZED) { return Collections.emptyList(); } if (curImgNum > imgNum) { String logMessage = String.format("(%s) Current image num %d is greater than requested " + "image num %d. Request a full update", retrieverType, curImgNum, imgNum); LOGGER.info(logMessage); System.out.println(SentryServiceUtil.getCurrentTimeStampWithMessage(logMessage)); List<K>fullImage = retrieveFullImage(); if( !fullImage.isEmpty()) { logMessage = String.format("(%s) A newer full update with image number %d " + "is less than requested image number %d. Send full update to HDFS", retrieverType, curImgNum, imgNum); LOGGER.info(logMessage); System.out.println(SentryServiceUtil.getCurrentTimeStampWithMessage(logMessage)); } return fullImage; } } long curSeqNum = deltaRetriever.getLatestDeltaID(); LOGGER.debug("({}) Current sequence number is {}", retrieverType, curSeqNum); if (seqNum == curSeqNum + 1) { LOGGER.debug("{}, No new updates", retrieverType); return Collections.emptyList(); } if (seqNum > SEQUENCE_NUMBER_FULL_UPDATE_REQUEST && deltaRetriever.isDeltaAvailable(seqNum)) { List<K> deltas = deltaRetriever.retrieveDelta(seqNum, imgNum); if (!deltas.isEmpty()) { LOGGER.info("({}) Newer delta updates are found up to sequence number {} and being sent to HDFS", retrieverType, curSeqNum); return deltas; } } String logMessage = String.format("(%s) Requested sequence number %d is less than 0 or " + "requested deltas for that sequence number are not available. Fetch a full update", retrieverType, seqNum); LOGGER.info(logMessage); System.out.println(SentryServiceUtil.getCurrentTimeStampWithMessage(logMessage)); List<K>fullImage = retrieveFullImage(); if( fullImage != null && !fullImage.isEmpty()) { logMessage = String.format("(%s) A full update is returned due to an unavailable sequence number: %d", retrieverType, seqNum); LOGGER.info(logMessage); System.out.println(SentryServiceUtil.getCurrentTimeStampWithMessage(logMessage)); } return fullImage; } DBUpdateForwarder(final ImageRetriever<K> imageRetriever,
      final DeltaRetriever<K> deltaRetriever); static void translateOwnerPrivileges(Map<TPrivilegePrincipal,String> privMap);  }