Will-Lo commented on code in PR #3557: URL: https://github.com/apache/gobblin/pull/3557#discussion_r977013672
########## gobblin-service/src/main/java/org/apache/gobblin/service/monitoring/SpecStoreChangeMonitor.java: ########## @@ -0,0 +1,159 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.gobblin.service.monitoring; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.concurrent.TimeUnit; + +import org.apache.commons.text.StringEscapeUtils; + +import com.codahale.metrics.Meter; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.CacheLoader; +import com.google.common.cache.LoadingCache; +import com.google.inject.Inject; +import com.typesafe.config.Config; + +import lombok.extern.slf4j.Slf4j; + +import org.apache.gobblin.kafka.client.DecodeableKafkaRecord; +import org.apache.gobblin.runtime.api.FlowSpec; +import org.apache.gobblin.runtime.api.Spec; +import org.apache.gobblin.runtime.kafka.HighLevelConsumer; +import org.apache.gobblin.runtime.metrics.RuntimeMetrics; +import org.apache.gobblin.runtime.spec_catalog.AddSpecResponse; +import org.apache.gobblin.runtime.spec_catalog.FlowCatalog; +import org.apache.gobblin.service.modules.scheduler.GobblinServiceJobScheduler; + + +/** + * A Flow Spec Store change monitor that uses {@link SpecStoreChangeEvent} schema to process Kafka messages received + * from the consumer service. This monitor responds to changes to flow specs (creations, updates, deletes) and acts as + * a connector between the API and execution layers of GaaS. + */ +@Slf4j +public class SpecStoreChangeMonitor extends HighLevelConsumer { + public static final String SPEC_STORE_CHANGE_MONITOR_PREFIX = "specStoreChangeMonitor"; + static final String SPEC_STORE_CHANGE_MONITOR_TOPIC_KEY = "topic"; + static final String SPEC_STORE_CHANGE_MONITOR_NUM_THREADS_KEY = "numThreads"; + + // Metrics + private Meter successfullyAddedSpecs; + private Meter failedAddedSpecs; + private Meter deletedSpecs; + private Meter unexpectedErrors; + + protected CacheLoader<String, String> cacheLoader = new CacheLoader<String, String>() { + @Override + public String load(String key) throws Exception { + return key; + } + }; + + protected LoadingCache<String, String> + specChangesSeenCache = CacheBuilder.newBuilder().expireAfterWrite(10, TimeUnit.MINUTES).build(cacheLoader); + + @Inject + protected FlowCatalog flowCatalog; + + @Inject + protected GobblinServiceJobScheduler scheduler; + + @Inject + public SpecStoreChangeMonitor(String topic, Config config, int numThreads) { + super(topic, config, numThreads); + } Review Comment: Are we supposed to inject this? I think it should be created by the factory, so only the factory is injected via dependency injection -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
