SCQRoll(@NotNull RollCycle rollCycle, long epoch, @Nullable LocalTime rollTime, @Nullable ZoneId rollTimeZone) { this.length = rollCycle.length(); this.format = rollCycle.format(); this.epoch = epoch; this.rollTime = rollTime; this.rollTimeZone = rollTimeZone; }
public RollingResourcesCache(@NotNull final RollCycle cycle, long epoch, @NotNull Function<String, File> nameToFile, @NotNull Function<File, String> fileToName) { this(cycle.length(), cycle.format(), epoch, nameToFile, fileToName); }
private void validateRollCycle(File metapath) { if (!metapath.exists()) { // no metadata, so we need to check if there're cq4 files and if so try to validate roll cycle // the code is slightly brutal and crude but should work for most cases. It will NOT work if files were created with // the following cycles: LARGE_HOURLY_SPARSE LARGE_HOURLY_XSPARSE LARGE_DAILY XLARGE_DAILY HUGE_DAILY HUGE_DAILY_XSPARSE // for such cases user MUST use correct roll cycle when creating the queue String[] list = path.list((d, name) -> name.endsWith(SingleChronicleQueue.SUFFIX)); if (list != null && list.length > 0) { String filename = list[0]; if (rollCycle().format().length() + 4 != filename.length()) { // probably different roll cycle used overrideRollCycleForFileNameLength(filename.length() - 4); } } } }
protected void initializeMetadata() { File metapath = metapath(); validateRollCycle(metapath); SCQMeta metadata = new SCQMeta(new SCQRoll(rollCycle(), epoch(), rollTime, rollTimeZone), deltaCheckpointInterval(), sourceId()); try { boolean readOnly = readOnly(); metaStore = SingleTableBuilder.binary(metapath, metadata).timeoutMS(timeoutMS()).readOnly(readOnly).build(); // check if metadata was overridden SCQMeta newMeta = metaStore.metadata(); if (sourceId() == 0) sourceId(newMeta.sourceId()); if (!newMeta.roll().format().equals(rollCycle().format())) { // roll cycle changed overrideRollCycleForFileNameLength(newMeta.roll().format().length()); } // if it was overriden - reset rollTime = newMeta.roll().rollTime(); rollTimeZone = newMeta.roll().rollTimeZone(); epoch = newMeta.roll().epoch(); } catch (IORuntimeException ex) { // readonly=true and file doesn't exist if (OS.isWindows()) throw ex; // we cant have a read-only table store on windows so we have no option but to throw the ex. Jvm.warn().on(getClass(), "Failback to readonly tablestore", ex); metaStore = new ReadonlyTableStore<>(metadata); } }
public RollingResourcesCache(@NotNull final RollCycle cycle, long epoch, @NotNull Function<String, File> nameToFile, @NotNull Function<File, String> fileToName) { this(cycle.length(), cycle.format(), epoch, nameToFile, fileToName); }
SCQRoll(@NotNull RollCycle rollCycle, long epoch, @Nullable LocalTime rollTime, @Nullable ZoneId rollTimeZone) { this.length = rollCycle.length(); this.format = rollCycle.format(); this.epoch = epoch; this.rollTime = rollTime; this.rollTimeZone = rollTimeZone; }
private void validateRollCycle(File metapath) { if (!metapath.exists()) { // no metadata, so we need to check if there're cq4 files and if so try to validate roll cycle // the code is slightly brutal and crude but should work for most cases. It will NOT work if files were created with // the following cycles: LARGE_HOURLY_SPARSE LARGE_HOURLY_XSPARSE LARGE_DAILY XLARGE_DAILY HUGE_DAILY HUGE_DAILY_XSPARSE // for such cases user MUST use correct roll cycle when creating the queue String[] list = path.list((d, name) -> name.endsWith(SingleChronicleQueue.SUFFIX)); if (list != null && list.length > 0) { String filename = list[0]; if (rollCycle().format().length() + 4 != filename.length()) { // probably different roll cycle used overrideRollCycleForFileNameLength(filename.length() - 4); } } } }
protected void initializeMetadata() { File metapath = metapath(); validateRollCycle(metapath); SCQMeta metadata = new SCQMeta(new SCQRoll(rollCycle(), epoch(), rollTime, rollTimeZone), deltaCheckpointInterval(), sourceId()); try { boolean readOnly = readOnly(); metaStore = SingleTableBuilder.binary(metapath, metadata).timeoutMS(timeoutMS()).readOnly(readOnly).build(); // check if metadata was overridden SCQMeta newMeta = metaStore.metadata(); if (sourceId() == 0) sourceId(newMeta.sourceId()); if (!newMeta.roll().format().equals(rollCycle().format())) { // roll cycle changed overrideRollCycleForFileNameLength(newMeta.roll().format().length()); } // if it was overriden - reset rollTime = newMeta.roll().rollTime(); rollTimeZone = newMeta.roll().rollTimeZone(); epoch = newMeta.roll().epoch(); } catch (IORuntimeException ex) { // readonly=true and file doesn't exist if (OS.isWindows()) throw ex; // we cant have a read-only table store on windows so we have no option but to throw the ex. Jvm.warn().on(getClass(), "Failback to readonly tablestore", ex); metaStore = new ReadonlyTableStore<>(metadata); } }