[ 
https://issues.apache.org/jira/browse/GOBBLIN-1457?focusedWorklogId=636197&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-636197
 ]

ASF GitHub Bot logged work on GOBBLIN-1457:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 10/Aug/21 00:42
            Start Date: 10/Aug/21 00:42
    Worklog Time Spent: 10m 
      Work Description: jack-moseley commented on a change in pull request 
#3327:
URL: https://github.com/apache/gobblin/pull/3327#discussion_r674386181



##########
File path: 
gobblin-metastore/src/main/java/org/apache/gobblin/metastore/util/DatabaseJobHistoryStoreSchemaManager.java
##########
@@ -54,9 +55,7 @@
   private final Flyway flyway;
 
   private DatabaseJobHistoryStoreSchemaManager(Properties properties) {
-    flyway = new Flyway();
-    flyway.configure(properties);
-    flyway.setClassLoader(this.getClass().getClassLoader());
+    flyway = 
Flyway.configure(this.getClass().getClassLoader()).configuration(properties).load();

Review comment:
       Are the changes to this and the related class just due to flyway API 
changes?

##########
File path: 
gobblin-runtime/src/main/java/org/apache/gobblin/runtime/troubleshooter/AutoTroubleshooterLogAppender.java
##########
@@ -0,0 +1,169 @@
+/*
+ * 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.runtime.troubleshooter;
+
+import java.time.Instant;
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
+import java.util.Objects;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.apache.log4j.AppenderSkeleton;
+import org.apache.log4j.Level;
+import org.apache.log4j.spi.LocationInfo;
+import org.apache.log4j.spi.LoggingEvent;
+
+import javax.annotation.concurrent.ThreadSafe;
+import lombok.extern.slf4j.Slf4j;
+
+import org.apache.gobblin.runtime.ThrowableWithErrorCode;
+
+
+/**
+ * Collects messages from log4j and converts them into issues that are used in 
{@link AutomaticTroubleshooter}.
+ */
+@Slf4j
+@ThreadSafe
+public class AutoTroubleshooterLogAppender extends AppenderSkeleton {

Review comment:
       This class was added in an earlier PR right? Why's it showing up as a 
new class now?

##########
File path: 
gobblin-service/src/main/java/org/apache/gobblin/service/modules/core/GobblinServiceGuiceModule.java
##########
@@ -205,12 +209,22 @@ public void configure(Binder binder) {
             JOB_STATUS_RETRIEVER_CLASS_KEY, 
FsJobStatusRetriever.class.getName()));
 
     if (serviceConfig.isRestLIServerEnabled()) {
-      
binder.bind(EmbeddedRestliServer.class).toProvider(EmbeddedRestliServerProvider.class).in(Singleton.class);
+      
binder.bind(EmbeddedRestliServer.class).toProvider(EmbeddedRestliServerProvider.class);
     }
 
     binder.bind(GobblinServiceManager.class);
 
-    
binder.bind(MultiContextIssueRepository.class).to(InMemoryMultiContextIssueRepository.class);
+    
binder.bind(ServiceDatabaseProvider.class).to(ServiceDatabaseProviderImpl.class);
+    binder.bind(ServiceDatabaseProviderImpl.Configuration.class);
+
+    binder.bind(ServiceDatabaseManager.class);
+
+    binder.bind(MultiContextIssueRepository.class)
+        .to(getClassByNameOrAlias(MultiContextIssueRepository.class, 
serviceConfig.getInnerConfig(),
+                                  ServiceConfigKeys.ISSUE_REPO_CLASS, 
MySqlMultiContextIssueRepository.class.getName()));

Review comment:
       Should this default to the in-memory one, since the mysql one requires a 
bunch of extra configuration 
   (and a mysql instance) that may not be set up?

##########
File path: 
gobblin-service/src/main/java/org/apache/gobblin/service/modules/db/ServiceDatabaseManager.java
##########
@@ -0,0 +1,60 @@
+/*
+ * 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.modules.db;
+
+import java.util.Objects;
+
+import org.flywaydb.core.Flyway;
+
+import com.google.common.util.concurrent.AbstractIdleService;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import lombok.extern.slf4j.Slf4j;
+
+
+@Singleton
+@Slf4j
+public class ServiceDatabaseManager extends AbstractIdleService {

Review comment:
       Let's add some javadoc for this class, if I understand correctly it's 
purpose is to do table creation (or migration if necessary) on gobblin service 
startup.

##########
File path: 
gobblin-service/src/main/java/org/apache/gobblin/service/modules/db/ServiceDatabaseProviderImpl.java
##########
@@ -0,0 +1,117 @@
+/*
+ * 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.modules.db;
+
+import java.time.Duration;
+import java.util.Objects;
+
+import org.apache.commons.dbcp2.BasicDataSource;
+
+import com.typesafe.config.Config;
+
+import javax.inject.Inject;
+import javax.sql.DataSource;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+
+import org.apache.gobblin.password.PasswordManager;
+import org.apache.gobblin.service.ServiceConfigKeys;
+import org.apache.gobblin.util.ConfigUtils;
+
+
+public class ServiceDatabaseProviderImpl implements ServiceDatabaseProvider {
+
+  private final Configuration configuration;
+  private BasicDataSource dataSource;
+
+  @Inject
+  public ServiceDatabaseProviderImpl(Configuration configuration) {
+    this.configuration = configuration;
+  }
+
+  public DataSource getDatasource() {
+    ensureDataSource();
+    return dataSource;
+  }
+
+  private synchronized void ensureDataSource() {

Review comment:
       For all other usages of mysql in gobblin and gaas code, we use 
`MysqlDataSourceFactory` (which calls `MysqlStateStore.newDataSource`) to 
create the datasource. Is the configuration for this one unique enough that it 
needs to be a separate thing, or that these configurations would not also be 
useful in that place?
   
   If we do want to keep these separate, maybe we could at least reuse the 
validation query (which I just added to `MysqlStateStore.newDataSource`) so 
that we don't have the same query in two places.

##########
File path: 
gobblin-service/src/main/java/org/apache/gobblin/service/modules/db/ServiceDatabaseManager.java
##########
@@ -0,0 +1,60 @@
+/*
+ * 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.modules.db;
+
+import java.util.Objects;
+
+import org.flywaydb.core.Flyway;
+
+import com.google.common.util.concurrent.AbstractIdleService;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import lombok.extern.slf4j.Slf4j;
+
+
+@Singleton
+@Slf4j
+public class ServiceDatabaseManager extends AbstractIdleService {
+
+  private final ServiceDatabaseProvider databaseProvider;
+
+  @Inject
+  public ServiceDatabaseManager(ServiceDatabaseProvider databaseProvider) {
+    this.databaseProvider = Objects.requireNonNull(databaseProvider);
+  }
+
+  @Override
+  protected void startUp()
+      throws Exception {
+
+    Flyway flyway =
+        
Flyway.configure().locations("classpath:org/apache/gobblin/service/db/migration").failOnMissingLocations(true)
+            .dataSource(databaseProvider.getDatasource()).load();
+
+    log.info("Ensuring service database is migrated to latest schema");
+    // Start the migration
+    flyway.migrate();

Review comment:
       Just curious, by using flyway, does this table have to be in a separate 
db from our other tables, or it's fine to have a flyway-managed table in the 
same db as other regular tables?




-- 
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]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 636197)
    Time Spent: 3.5h  (was: 3h 20m)

> Automatic troubleshooter
> ------------------------
>
>                 Key: GOBBLIN-1457
>                 URL: https://issues.apache.org/jira/browse/GOBBLIN-1457
>             Project: Apache Gobblin
>          Issue Type: Improvement
>          Components: gobblin-core
>            Reporter: Alexander Prokofiev
>            Assignee: Abhishek Tiwari
>            Priority: Major
>          Time Spent: 3.5h
>  Remaining Estimate: 0h
>
> Automatic troubleshooter will collect issues from job logs and health checks. 
> Then it will show users the root cause of the problems with action items on 
> how to resolve them.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to