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

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

                Author: ASF GitHub Bot
            Created on: 13/May/19 22:07
            Start Date: 13/May/19 22:07
    Worklog Time Spent: 10m 
      Work Description: jack-moseley commented on pull request #2631: 
[GOBBLIN-768] Add MySQL implementation of SpecStore
URL: https://github.com/apache/incubator-gobblin/pull/2631#discussion_r283557104
 
 

 ##########
 File path: 
gobblin-runtime/src/main/java/org/apache/gobblin/runtime/spec_store/MysqlSpecStore.java
 ##########
 @@ -0,0 +1,215 @@
+/*
+ * 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.spec_store;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.net.URI;
+import java.sql.Blob;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.Lists;
+import com.typesafe.config.Config;
+
+import javax.sql.DataSource;
+
+import org.apache.gobblin.broker.SharedResourcesBrokerFactory;
+import org.apache.gobblin.configuration.ConfigurationKeys;
+import org.apache.gobblin.metastore.MysqlDataSourceFactory;
+import org.apache.gobblin.runtime.api.Spec;
+import org.apache.gobblin.runtime.api.SpecNotFoundException;
+import org.apache.gobblin.runtime.api.SpecStore;
+
+
+/**
+ * Implementation of {@link SpecStore} that stores specs as serialized java 
objects in MySQL. Note that versions are not
+ * supported, so the version parameter will be ignored in methods that have it.
+ */
+public class MysqlSpecStore implements SpecStore {
+  private static final String CREATE_TABLE_STATEMENT =
+      "CREATE TABLE IF NOT EXISTS %s (spec_uri VARCHAR(128) NOT NULL, spec 
LONGBLOB, PRIMARY KEY (spec_uri))";
+  private static final String EXISTS_STATEMENT = "SELECT EXISTS(SELECT * FROM 
%s WHERE spec_uri = ?)";
+  private static final String INSERT_STATEMENT = "INSERT INTO %s (spec_uri, 
spec) VALUES (?, ?) ON DUPLICATE KEY UPDATE spec = VALUES(spec)";
+  private static final String DELETE_STATEMENT = "DELETE FROM %s WHERE 
spec_uri = ?";
+  private static final String GET_STATEMENT = "SELECT spec FROM %s WHERE 
spec_uri = ?";
+  private static final String GET_ALL_STATEMENT = "SELECT spec_uri, spec FROM 
%s";
+
+  private DataSource dataSource;
+  private String tableName;
+  private URI specStoreURI;
+
+  public MysqlSpecStore(Config config) throws IOException {
+    this.dataSource = MysqlDataSourceFactory.get(config, 
SharedResourcesBrokerFactory.getImplicitBroker());
+    this.tableName = 
config.getString(ConfigurationKeys.STATE_STORE_DB_TABLE_KEY);
 
 Review comment:
   As discussed, right now mysql datasource logic is tied to state store config 
keys, so just using those keys but added a prefix for now.
 
----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

    Worklog Id:     (was: 241352)
    Time Spent: 2h 40m  (was: 2.5h)

> Add MySQL implementation of SpecStore
> -------------------------------------
>
>                 Key: GOBBLIN-768
>                 URL: https://issues.apache.org/jira/browse/GOBBLIN-768
>             Project: Apache Gobblin
>          Issue Type: New Feature
>            Reporter: Jack Moseley
>            Priority: Major
>          Time Spent: 2h 40m
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to