Skip to content

Commit

Permalink
Increase default rollover period (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
frsv authored Jun 22, 2023
1 parent 98d0db2 commit dd29ddc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.google.cloud.bigquery.dwhassessment.hooks.logger;

import static com.google.cloud.bigquery.dwhassessment.hooks.logger.LoggingHookConstants.QUERY_EVENTS_FILE_PREFIX;
import static java.time.format.DateTimeFormatter.ISO_LOCAL_DATE;
import static java.time.format.DateTimeFormatter.ISO_LOCAL_DATE_TIME;
import static java.time.temporal.ChronoField.HOUR_OF_DAY;
Expand Down Expand Up @@ -204,7 +205,7 @@ private LocalDate getCurrentDate() {
}

private String constructFileName() {
return "dwhassessment_"
return QUERY_EVENTS_FILE_PREFIX
+ LOG_TIME_FORMAT.format(clock.instant().atOffset(ZoneOffset.UTC))
+ "_"
+ loggerId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import static com.google.cloud.bigquery.dwhassessment.hooks.logger.LoggerVarsConfig.HIVE_QUERY_EVENTS_QUEUE_CAPACITY;
import static com.google.cloud.bigquery.dwhassessment.hooks.logger.LoggerVarsConfig.HIVE_QUERY_EVENTS_ROLLOVER_ELIGIBILITY_CHECK_INTERVAL;
import static com.google.cloud.bigquery.dwhassessment.hooks.logger.LoggerVarsConfig.HIVE_QUERY_EVENTS_ROLLOVER_INTERVAL;
import static com.google.cloud.bigquery.dwhassessment.hooks.logger.LoggingHookConstants.DEFAULT_ROLLOVER_ELIGIBILITY_CHECK_INTERVAL_DURATION;
import static com.google.cloud.bigquery.dwhassessment.hooks.logger.LoggingHookConstants.DEFAULT_ROLLOVER_INTERVAL_DURATION;
import static com.google.cloud.bigquery.dwhassessment.hooks.logger.LoggingHookConstants.QUERY_EVENT_SCHEMA;
import static java.util.concurrent.TimeUnit.SECONDS;

Expand Down Expand Up @@ -55,9 +57,6 @@ public class EventLogger {
private static final int MAX_RETRIES = 2;
private static final Duration SHUTDOWN_WAIT_TIME = Duration.ofSeconds(5);
private static final int QUERY_EVENTS_QUEUE_DEFAULT_SIZE = 64;
private static final Duration DEFAULT_ROLLOVER_ELIGIBILITY_CHECK_INTERVAL_DURATION =
Duration.ofMinutes(10);
private static final Duration DEFAULT_ROLLOVER_INTERVAL_DURATION = Duration.ofMinutes(10);

private final DatePartitionedRecordsWriterFactory recordsWriterFactory;
private final EventRecordConstructor eventRecordConstructor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,20 @@
package com.google.cloud.bigquery.dwhassessment.hooks.logger;

import com.google.cloud.bigquery.dwhassessment.hooks.avro.AvroSchemaLoader;
import java.time.Duration;
import org.apache.avro.Schema;

public final class LoggingHookConstants {

public static final Schema QUERY_EVENT_SCHEMA = AvroSchemaLoader.loadSchema("QueryEvents.avsc");

public static final String HOOK_VERSION = "1.0";

public static final String QUERY_EVENTS_FILE_PREFIX = "dwhassessment_";

public static final Duration DEFAULT_ROLLOVER_ELIGIBILITY_CHECK_INTERVAL_DURATION =
Duration.ofMinutes(10);
public static final Duration DEFAULT_ROLLOVER_INTERVAL_DURATION = Duration.ofHours(1);

private LoggingHookConstants() {}
}

0 comments on commit dd29ddc

Please sign in to comment.