/** * An offset file associated with logged store {@code storeDir} is valid if it exists and is not empty. * * @param storeDir the base directory of the store * @param offsetFileName name of the offset file * @return true if the offset file is valid. false otherwise. */ public static boolean isOffsetFileValid(File storeDir, String offsetFileName) { boolean hasValidOffsetFile = false; if (storeDir.exists()) { String offsetContents = readOffsetFile(storeDir, offsetFileName); if (offsetContents != null && !offsetContents.isEmpty()) { hasValidOffsetFile = true; } else { LOG.info("Offset file is not valid for store: {}.", storeDir.toPath()); } } return hasValidOffsetFile; }
/** * An offset file associated with logged store {@code storeDir} is valid if it exists and is not empty. * * @param storeDir the base directory of the store * @param offsetFileName name of the offset file * @return true if the offset file is valid. false otherwise. */ public static boolean isOffsetFileValid(File storeDir, String offsetFileName) { boolean hasValidOffsetFile = false; if (storeDir.exists()) { String offsetContents = readOffsetFile(storeDir, offsetFileName); if (offsetContents != null && !offsetContents.isEmpty()) { hasValidOffsetFile = true; } else { LOG.info("Offset file is not valid for store: {}.", storeDir.toPath()); } } return hasValidOffsetFile; }
/** * An offset file associated with logged store {@code storeDir} is valid if it exists and is not empty. * * @param storeDir the base directory of the store * @param offsetFileName name of the offset file * @return true if the offset file is valid. false otherwise. */ public static boolean isOffsetFileValid(File storeDir, String offsetFileName) { boolean hasValidOffsetFile = false; if (storeDir.exists()) { String offsetContents = readOffsetFile(storeDir, offsetFileName); if (offsetContents != null && !offsetContents.isEmpty()) { hasValidOffsetFile = true; } else { LOG.info("Offset file is not valid for store: {}.", storeDir.toPath()); } } return hasValidOffsetFile; }
/** * An offset file associated with logged store {@code storeDir} is valid if it exists and is not empty. * * @param storeDir the base directory of the store * @param offsetFileName name of the offset file * @return true if the offset file is valid. false otherwise. */ public static boolean isOffsetFileValid(File storeDir, String offsetFileName) { boolean hasValidOffsetFile = false; if (storeDir.exists()) { String offsetContents = readOffsetFile(storeDir, offsetFileName); if (offsetContents != null && !offsetContents.isEmpty()) { hasValidOffsetFile = true; } else { LOG.info("Offset file is not valid for store: {}.", storeDir.toPath()); } } return hasValidOffsetFile; }
/** * An offset file associated with logged store {@code storeDir} is valid if it exists and is not empty. * * @param storeDir the base directory of the store * @param offsetFileName name of the offset file * @return true if the offset file is valid. false otherwise. */ public static boolean isOffsetFileValid(File storeDir, String offsetFileName) { boolean hasValidOffsetFile = false; if (storeDir.exists()) { String offsetContents = readOffsetFile(storeDir, offsetFileName); if (offsetContents != null && !offsetContents.isEmpty()) { hasValidOffsetFile = true; } else { LOG.info("Offset file is not valid for store: {}.", storeDir.toPath()); } } return hasValidOffsetFile; }
/** * Gets the side input SSP offsets for all stores from their local offset files. * * @return a {@link Map} of {@link SystemStreamPartition} to offset in the offset files. */ @SuppressWarnings("unchecked") @VisibleForTesting Map<SystemStreamPartition, String> getFileOffsets() { LOG.info("Loading initial offsets from the file for side input stores."); Map<SystemStreamPartition, String> fileOffsets = new HashMap<>(); stores.keySet().forEach(storeName -> { LOG.debug("Reading local offsets for store: {}", storeName); File storeLocation = getStoreLocation(storeName); if (isValidSideInputStore(storeName, storeLocation)) { try { String fileContents = StorageManagerUtil.readOffsetFile(storeLocation, OFFSET_FILE); Map<SystemStreamPartition, String> offsets = OBJECT_MAPPER.readValue(fileContents, OFFSETS_TYPE_REFERENCE); fileOffsets.putAll(offsets); } catch (Exception e) { LOG.warn("Failed to load the offset file for side input store:" + storeName, e); } } }); return fileOffsets; }
/** * Gets the side input SSP offsets for all stores from their local offset files. * * @return a {@link Map} of {@link SystemStreamPartition} to offset in the offset files. */ @SuppressWarnings("unchecked") @VisibleForTesting Map<SystemStreamPartition, String> getFileOffsets() { LOG.info("Loading initial offsets from the file for side input stores."); Map<SystemStreamPartition, String> fileOffsets = new HashMap<>(); stores.keySet().forEach(storeName -> { LOG.debug("Reading local offsets for store: {}", storeName); File storeLocation = getStoreLocation(storeName); if (isValidSideInputStore(storeName, storeLocation)) { try { String fileContents = StorageManagerUtil.readOffsetFile(storeLocation, OFFSET_FILE); Map<SystemStreamPartition, String> offsets = OBJECT_MAPPER.readValue(fileContents, OFFSETS_TYPE_REFERENCE); fileOffsets.putAll(offsets); } catch (Exception e) { LOG.warn("Failed to load the offset file for side input store:" + storeName, e); } } }); return fileOffsets; }
/** * Gets the side input SSP offsets for all stores from their local offset files. * * @return a {@link Map} of {@link SystemStreamPartition} to offset in the offset files. */ @SuppressWarnings("unchecked") @VisibleForTesting Map<SystemStreamPartition, String> getFileOffsets() { LOG.info("Loading initial offsets from the file for side input stores."); Map<SystemStreamPartition, String> fileOffsets = new HashMap<>(); stores.keySet().forEach(storeName -> { LOG.debug("Reading local offsets for store: {}", storeName); File storeLocation = getStoreLocation(storeName); if (isValidSideInputStore(storeName, storeLocation)) { try { String fileContents = StorageManagerUtil.readOffsetFile(storeLocation, OFFSET_FILE); Map<SystemStreamPartition, String> offsets = OBJECT_MAPPER.readValue(fileContents, OFFSETS_TYPE_REFERENCE); fileOffsets.putAll(offsets); } catch (Exception e) { LOG.warn("Failed to load the offset file for side input store:" + storeName, e); } } }); return fileOffsets; }
/** * Gets the side input SSP offsets for all stores from their local offset files. * * @return a {@link Map} of {@link SystemStreamPartition} to offset in the offset files. */ @SuppressWarnings("unchecked") @VisibleForTesting Map<SystemStreamPartition, String> getFileOffsets() { LOG.info("Loading initial offsets from the file for side input stores."); Map<SystemStreamPartition, String> fileOffsets = new HashMap<>(); stores.keySet().forEach(storeName -> { LOG.debug("Reading local offsets for store: {}", storeName); File storeLocation = getStoreLocation(storeName); if (isValidSideInputStore(storeName, storeLocation)) { try { String fileContents = StorageManagerUtil.readOffsetFile(storeLocation, OFFSET_FILE); Map<SystemStreamPartition, String> offsets = OBJECT_MAPPER.readValue(fileContents, OFFSETS_TYPE_REFERENCE); fileOffsets.putAll(offsets); } catch (Exception e) { LOG.warn("Failed to load the offset file for side input store:" + storeName, e); } } }); return fileOffsets; }
/** * Gets the side input SSP offsets for all stores from their local offset files. * * @return a {@link Map} of {@link SystemStreamPartition} to offset in the offset files. */ @SuppressWarnings("unchecked") @VisibleForTesting Map<SystemStreamPartition, String> getFileOffsets() { LOG.info("Loading initial offsets from the file for side input stores."); Map<SystemStreamPartition, String> fileOffsets = new HashMap<>(); stores.keySet().forEach(storeName -> { LOG.debug("Reading local offsets for store: {}", storeName); File storeLocation = getStoreLocation(storeName); if (isValidSideInputStore(storeName, storeLocation)) { try { String fileContents = StorageManagerUtil.readOffsetFile(storeLocation, OFFSET_FILE); Map<SystemStreamPartition, String> offsets = OBJECT_MAPPER.readValue(fileContents, OFFSETS_TYPE_REFERENCE); fileOffsets.putAll(offsets); } catch (Exception e) { LOG.warn("Failed to load the offset file for side input store:" + storeName, e); } } }); return fileOffsets; }
FileUtil.rm(loggedStorePartitionDir); } else { String offset = StorageManagerUtil.readOffsetFile(loggedStorePartitionDir, OFFSET_FILE_NAME); LOG.info("Read offset " + offset + " for the store " + storeName + " from logged storage partition directory " + loggedStorePartitionDir);