Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collect execution stats for all JdbcClients #906

Merged
merged 9 commits into from
Jul 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions presto-accumulo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,12 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.openjdk.jol</groupId>
<artifactId>jol-core</artifactId>
<scope>provided</scope>
</dependency>

<!-- for testing -->
<dependency>
<groupId>io.prestosql</groupId>
Expand Down
6 changes: 6 additions & 0 deletions presto-atop/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.openjdk.jol</groupId>
<artifactId>jol-core</artifactId>
<scope>provided</scope>
</dependency>

<!-- for testing -->
<dependency>
<groupId>io.prestosql</groupId>
Expand Down
53 changes: 36 additions & 17 deletions presto-base-jdbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
</properties>

<dependencies>
<dependency>
<groupId>io.prestosql</groupId>
<artifactId>presto-plugin-toolkit</artifactId>
electrum marked this conversation as resolved.
Show resolved Hide resolved
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>bootstrap</artifactId>
Expand All @@ -42,6 +47,11 @@
<artifactId>units</artifactId>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>stats</artifactId>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
Expand Down Expand Up @@ -84,6 +94,25 @@
<artifactId>javax.inject</artifactId>
</dependency>

<dependency>
<groupId>org.weakref</groupId>
<artifactId>jmxutils</artifactId>
</dependency>

<!-- used by tests but also needed transitively -->
<dependency>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs <scope>runtime</scope> otherwise the dependency checker will fail as it's not referenced

<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<scope>runtime</scope>
</dependency>

<!-- used by tests but also needed transitively -->
<dependency>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably needs runtime scope

<groupId>io.airlift</groupId>
<artifactId>json</artifactId>
<scope>runtime</scope>
</dependency>

<!-- Presto SPI -->
<dependency>
<groupId>io.prestosql</groupId>
Expand All @@ -101,6 +130,13 @@
</dependency>

<!-- for testing -->
<dependency>
<groupId>io.prestosql</groupId>
<artifactId>presto-spi</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
Expand All @@ -119,23 +155,6 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.airlift</groupId>
<artifactId>json</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.prestosql</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
/*
* 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://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 io.prestosql.plugin.jdbc;

import io.prestosql.spi.connector.ColumnHandle;
import io.prestosql.spi.connector.ColumnMetadata;
import io.prestosql.spi.connector.ConnectorSession;
import io.prestosql.spi.connector.ConnectorSplitSource;
import io.prestosql.spi.connector.ConnectorTableMetadata;
import io.prestosql.spi.connector.SchemaTableName;
import io.prestosql.spi.predicate.TupleDomain;
import io.prestosql.spi.statistics.TableStatistics;
import io.prestosql.spi.type.Type;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;
import java.util.Optional;
import java.util.Set;

public abstract class ForwardingJdbcClient
implements JdbcClient
{
protected abstract JdbcClient getDelegate();

@Override
public boolean schemaExists(JdbcIdentity identity, String schema)
{
return getDelegate().schemaExists(identity, schema);
}

@Override
public Set<String> getSchemaNames(JdbcIdentity identity)
{
return getDelegate().getSchemaNames(identity);
}

@Override
public List<SchemaTableName> getTableNames(JdbcIdentity identity, Optional<String> schema)
{
return getDelegate().getTableNames(identity, schema);
}

@Override
public Optional<JdbcTableHandle> getTableHandle(JdbcIdentity identity, SchemaTableName schemaTableName)
{
return getDelegate().getTableHandle(identity, schemaTableName);
}

@Override
public List<JdbcColumnHandle> getColumns(ConnectorSession session, JdbcTableHandle tableHandle)
{
return getDelegate().getColumns(session, tableHandle);
}

@Override
public Optional<ColumnMapping> toPrestoType(ConnectorSession session, Connection connection, JdbcTypeHandle typeHandle)
{
return getDelegate().toPrestoType(session, connection, typeHandle);
}

@Override
public WriteMapping toWriteMapping(ConnectorSession session, Type type)
{
return getDelegate().toWriteMapping(session, type);
}

@Override
public ConnectorSplitSource getSplits(JdbcIdentity identity, JdbcTableHandle layoutHandle)
{
return getDelegate().getSplits(identity, layoutHandle);
}

@Override
public Connection getConnection(JdbcIdentity identity, JdbcSplit split)
throws SQLException
{
return getDelegate().getConnection(identity, split);
}

@Override
public void abortReadConnection(Connection connection)
throws SQLException
{
getDelegate().abortReadConnection(connection);
}

@Override
public PreparedStatement buildSql(ConnectorSession session, Connection connection, JdbcSplit split, JdbcTableHandle tableHandle, List<JdbcColumnHandle> columnHandles)
throws SQLException
{
return getDelegate().buildSql(session, connection, split, tableHandle, columnHandles);
}

@Override
public JdbcOutputTableHandle beginCreateTable(ConnectorSession session, ConnectorTableMetadata tableMetadata)
{
return getDelegate().beginCreateTable(session, tableMetadata);
}

@Override
public void commitCreateTable(JdbcIdentity identity, JdbcOutputTableHandle handle)
{
getDelegate().commitCreateTable(identity, handle);
}

@Override
public JdbcOutputTableHandle beginInsertTable(ConnectorSession session, ConnectorTableMetadata tableMetadata)
{
return getDelegate().beginInsertTable(session, tableMetadata);
}

@Override
public void finishInsertTable(JdbcIdentity identity, JdbcOutputTableHandle handle)
{
getDelegate().finishInsertTable(identity, handle);
}

@Override
public void dropTable(JdbcIdentity identity, JdbcTableHandle jdbcTableHandle)
{
getDelegate().dropTable(identity, jdbcTableHandle);
}

@Override
public void rollbackCreateTable(JdbcIdentity identity, JdbcOutputTableHandle handle)
{
getDelegate().rollbackCreateTable(identity, handle);
}

@Override
public String buildInsertSql(JdbcOutputTableHandle handle)
{
return getDelegate().buildInsertSql(handle);
}

@Override
public Connection getConnection(JdbcIdentity identity, JdbcOutputTableHandle handle)
throws SQLException
{
return getDelegate().getConnection(identity, handle);
}

@Override
public PreparedStatement getPreparedStatement(Connection connection, String sql)
throws SQLException
{
return getDelegate().getPreparedStatement(connection, sql);
}

@Override
public TableStatistics getTableStatistics(ConnectorSession session, JdbcTableHandle handle, TupleDomain<ColumnHandle> tupleDomain)
{
return getDelegate().getTableStatistics(session, handle, tupleDomain);
}

@Override
public boolean supportsLimit()
{
return getDelegate().supportsLimit();
}

@Override
public boolean isLimitGuaranteed()
{
return getDelegate().isLimitGuaranteed();
}

@Override
public void addColumn(ConnectorSession session, JdbcTableHandle handle, ColumnMetadata column)
{
getDelegate().addColumn(session, handle, column);
}

@Override
public void dropColumn(JdbcIdentity identity, JdbcTableHandle handle, JdbcColumnHandle column)
{
getDelegate().dropColumn(identity, handle, column);
}

@Override
public void renameColumn(JdbcIdentity identity, JdbcTableHandle handle, JdbcColumnHandle jdbcColumn, String newColumnName)
{
getDelegate().renameColumn(identity, handle, jdbcColumn, newColumnName);
}

@Override
public void renameTable(JdbcIdentity identity, JdbcTableHandle handle, SchemaTableName newTableName)
{
getDelegate().renameTable(identity, handle, newTableName);
}

@Override
public void createTable(ConnectorSession session, ConnectorTableMetadata tableMetadata)
{
getDelegate().createTable(session, tableMetadata);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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://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 io.prestosql.plugin.jdbc;

import javax.inject.Qualifier;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

@Retention(RUNTIME)
@Target({FIELD, PARAMETER, METHOD})
@Qualifier
public @interface InternalBaseJdbc
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
import com.google.inject.Injector;
import com.google.inject.Module;
import io.airlift.bootstrap.Bootstrap;
import io.prestosql.plugin.base.jmx.MBeanServerModule;
import io.prestosql.spi.classloader.ThreadContextClassLoader;
import io.prestosql.spi.connector.Connector;
import io.prestosql.spi.connector.ConnectorContext;
import io.prestosql.spi.connector.ConnectorFactory;
import io.prestosql.spi.connector.ConnectorHandleResolver;
import io.prestosql.spi.type.TypeManager;
import org.weakref.jmx.guice.MBeanModule;

import java.util.Map;

Expand Down Expand Up @@ -65,7 +67,9 @@ public Connector create(String catalogName, Map<String, String> requiredConfig,
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
Bootstrap app = new Bootstrap(
binder -> binder.bind(TypeManager.class).toInstance(context.getTypeManager()),
new JdbcModule(),
new JdbcModule(catalogName),
new MBeanServerModule(),
new MBeanModule(),
module);

Injector injector = app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class JdbcMetadataFactory
private final boolean allowDropTable;

@Inject
public JdbcMetadataFactory(JdbcClient jdbcClient, JdbcMetadataConfig config)
public JdbcMetadataFactory(@InternalBaseJdbc JdbcClient jdbcClient, JdbcMetadataConfig config)
{
this.jdbcClient = requireNonNull(jdbcClient, "jdbcClient is null");
requireNonNull(config, "config is null");
Expand All @@ -32,6 +32,6 @@ public JdbcMetadataFactory(JdbcClient jdbcClient, JdbcMetadataConfig config)

public JdbcMetadata create()
{
return new JdbcMetadata(jdbcClient, allowDropTable);
return new JdbcMetadata(new TransactionScopeCachingJdbcClient(jdbcClient), allowDropTable);
}
}
Loading