Skip to content

Commit

Permalink
Redshift Connector (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
tgianos authored and ajoymajumdar committed May 11, 2017
1 parent 3c64e5d commit aa6e82c
Show file tree
Hide file tree
Showing 12 changed files with 640 additions and 9 deletions.
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,24 @@
* limitations under the License.
*/



buildscript {
repositories {
jcenter()
}
}

plugins {
id 'nebula.netflixoss' version '3.5.2'
id 'nebula.netflixoss' version '3.6.0'
}

ext.githubProjectName = rootProject.name

allprojects {
repositories {
jcenter()
maven {
url "http:https://redshift-maven-repository.s3-website-us-east-1.amazonaws.com/release"
}
}
}

Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ hive_version=1.2.1
hadoopcore_version=1.2.1
mysql_connector_version=5.1.35
postgresql_driver_version=42.0.0
redshift_driver_version=1.2.1.1001
4 changes: 4 additions & 0 deletions metacat-connector-redshift/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dependencies {
compile project(":metacat-connector-jdbc")
runtime("com.amazon.redshift:redshift-jdbc42:${redshift_driver_version}")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
*
* Copyright 2017 Netflix, Inc.
*
* Licensed 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:https://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 com.netflix.metacat.connector.redshift;

import com.google.common.collect.Lists;
import com.netflix.metacat.connector.jdbc.JdbcConnectorFactory;
import lombok.NonNull;

import javax.annotation.Nonnull;
import java.util.Map;

/**
* Connector Factory for Redshift.
*
* @author tgianos
* @since 0.1.52
*/
class RedshiftConnectorFactory extends JdbcConnectorFactory {

/**
* Constructor.
*
* @param name The catalog name
* @param configuration The catalog configuration
*/
RedshiftConnectorFactory(
@Nonnull @NonNull final String name,
@Nonnull @NonNull final Map<String, String> configuration
) {
super(name, Lists.newArrayList(new RedshiftConnectorModule(name, configuration)));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
*
* Copyright 2017 Netflix, Inc.
*
* Licensed 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:https://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 com.netflix.metacat.connector.redshift;

import com.google.inject.AbstractModule;
import com.google.inject.Scopes;
import com.netflix.metacat.common.server.connectors.ConnectorDatabaseService;
import com.netflix.metacat.common.server.connectors.ConnectorPartitionService;
import com.netflix.metacat.common.server.connectors.ConnectorTableService;
import com.netflix.metacat.common.util.DataSourceManager;
import com.netflix.metacat.connector.jdbc.JdbcTypeConverter;
import com.netflix.metacat.connector.jdbc.services.JdbcConnectorDatabaseService;
import com.netflix.metacat.connector.jdbc.services.JdbcConnectorPartitionService;
import com.netflix.metacat.connector.jdbc.services.JdbcConnectorTableService;
import lombok.NonNull;

import javax.annotation.Nonnull;
import javax.sql.DataSource;
import java.util.Map;

/**
* Guice module for the Redshift Connector.
*
* @author tgianos
* @since 0.1.52
*/
public class RedshiftConnectorModule extends AbstractModule {

private final String name;
private final Map<String, String> configuration;

/**
* Constructor.
*
* @param name The name of the catalog this module is associated will be associated with
* @param configuration The connector configuration
*/
RedshiftConnectorModule(
@Nonnull @NonNull final String name,
@Nonnull @NonNull final Map<String, String> configuration
) {
this.name = name;
this.configuration = configuration;
}

/**
* {@inheritDoc}
*/
@Override
protected void configure() {
this.bind(DataSource.class)
.toInstance(DataSourceManager.get().load(this.name, this.configuration).get(this.name));
this.bind(JdbcTypeConverter.class).to(RedshiftTypeConverter.class).in(Scopes.SINGLETON);
this.bind(ConnectorDatabaseService.class).to(JdbcConnectorDatabaseService.class).in(Scopes.SINGLETON);
this.bind(ConnectorTableService.class).to(JdbcConnectorTableService.class).in(Scopes.SINGLETON);
this.bind(ConnectorPartitionService.class).to(JdbcConnectorPartitionService.class).in(Scopes.SINGLETON);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
*
* Copyright 2017 Netflix, Inc.
*
* Licensed 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:https://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 com.netflix.metacat.connector.redshift;

import com.netflix.metacat.common.server.connectors.ConnectorFactory;
import com.netflix.metacat.common.server.connectors.ConnectorPlugin;
import com.netflix.metacat.common.server.connectors.ConnectorTypeConverter;
import lombok.NonNull;

import javax.annotation.Nonnull;
import java.util.Map;

/**
* Redshift Connector Plugin.
*
* @author tgianos
* @since 0.1.52
*/
public class RedshiftConnectorPlugin implements ConnectorPlugin {

private static final String CONNECTOR_TYPE = "redshift";
private static final RedshiftTypeConverter TYPE_CONVERTER = new RedshiftTypeConverter();

/**
* {@inheritDoc}
*/
@Override
public String getType() {
return CONNECTOR_TYPE;
}

/**
* {@inheritDoc}
*/
@Override
public ConnectorFactory create(
@Nonnull @NonNull final String connectorName,
@Nonnull @NonNull final Map<String, String> configuration
) {
return new RedshiftConnectorFactory(connectorName, configuration);
}

/**
* {@inheritDoc}
*/
@Override
public ConnectorTypeConverter getTypeConverter() {
return TYPE_CONVERTER;
}
}
Loading

0 comments on commit aa6e82c

Please sign in to comment.