From f7d52ac583960d9f93d07235a6a7c6b1b076e927 Mon Sep 17 00:00:00 2001 From: David Phillips Date: Thu, 9 May 2019 17:36:50 -0700 Subject: [PATCH] Remove unused catalog name from system connector --- .../prestosql/connector/ConnectorManager.java | 1 - .../connector/system/SystemConnector.java | 12 +++-------- .../system/SystemTablesMetadata.java | 6 +----- .../system/SystemTransactionHandle.java | 21 +++---------------- .../io/prestosql/testing/TestingSession.java | 2 +- .../security/TestAccessControlManager.java | 1 - .../prestosql/sql/analyzer/TestAnalyzer.java | 1 - .../transaction/TestTransactionManager.java | 1 - 8 files changed, 8 insertions(+), 37 deletions(-) diff --git a/presto-main/src/main/java/io/prestosql/connector/ConnectorManager.java b/presto-main/src/main/java/io/prestosql/connector/ConnectorManager.java index eef35bf76742..262d43ea2654 100644 --- a/presto-main/src/main/java/io/prestosql/connector/ConnectorManager.java +++ b/presto-main/src/main/java/io/prestosql/connector/ConnectorManager.java @@ -211,7 +211,6 @@ private synchronized void addCatalogConnector(CatalogName catalogName, Connector } MaterializedConnector systemConnector = new MaterializedConnector(systemId, new SystemConnector( - systemId, nodeManager, systemTablesProvider, transactionId -> transactionManager.getConnectorTransaction(transactionId, catalogName))); diff --git a/presto-main/src/main/java/io/prestosql/connector/system/SystemConnector.java b/presto-main/src/main/java/io/prestosql/connector/system/SystemConnector.java index 2d5674ef1ff2..07a08de27c7b 100644 --- a/presto-main/src/main/java/io/prestosql/connector/system/SystemConnector.java +++ b/presto-main/src/main/java/io/prestosql/connector/system/SystemConnector.java @@ -13,7 +13,6 @@ */ package io.prestosql.connector.system; -import io.prestosql.connector.CatalogName; import io.prestosql.metadata.InternalNodeManager; import io.prestosql.spi.connector.ConnectorMetadata; import io.prestosql.spi.connector.ConnectorPageSourceProvider; @@ -32,34 +31,29 @@ public class SystemConnector implements InternalConnector { - private final CatalogName catalogName; private final ConnectorMetadata metadata; private final ConnectorSplitManager splitManager; private final ConnectorPageSourceProvider pageSourceProvider; private final Function transactionHandleFunction; public SystemConnector( - CatalogName catalogName, InternalNodeManager nodeManager, Set tables, Function transactionHandleFunction) { - this(catalogName, nodeManager, new StaticSystemTablesProvider(tables), transactionHandleFunction); + this(nodeManager, new StaticSystemTablesProvider(tables), transactionHandleFunction); } public SystemConnector( - CatalogName catalogName, InternalNodeManager nodeManager, SystemTablesProvider tables, Function transactionHandleFunction) { - requireNonNull(catalogName, "catalogName is null"); requireNonNull(nodeManager, "nodeManager is null"); requireNonNull(tables, "tables is null"); requireNonNull(transactionHandleFunction, "transactionHandleFunction is null"); - this.catalogName = catalogName; - this.metadata = new SystemTablesMetadata(catalogName, tables); + this.metadata = new SystemTablesMetadata(tables); this.splitManager = new SystemSplitManager(nodeManager, tables); this.pageSourceProvider = new SystemPageSourceProvider(tables); this.transactionHandleFunction = transactionHandleFunction; @@ -68,7 +62,7 @@ public SystemConnector( @Override public ConnectorTransactionHandle beginTransaction(TransactionId transactionId, IsolationLevel isolationLevel, boolean readOnly) { - return new SystemTransactionHandle(catalogName, transactionId, transactionHandleFunction); + return new SystemTransactionHandle(transactionId, transactionHandleFunction); } @Override diff --git a/presto-main/src/main/java/io/prestosql/connector/system/SystemTablesMetadata.java b/presto-main/src/main/java/io/prestosql/connector/system/SystemTablesMetadata.java index ceeed2852d16..7419c1f4ce55 100644 --- a/presto-main/src/main/java/io/prestosql/connector/system/SystemTablesMetadata.java +++ b/presto-main/src/main/java/io/prestosql/connector/system/SystemTablesMetadata.java @@ -15,7 +15,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import io.prestosql.connector.CatalogName; import io.prestosql.spi.PrestoException; import io.prestosql.spi.connector.ColumnHandle; import io.prestosql.spi.connector.ColumnMetadata; @@ -48,13 +47,10 @@ public class SystemTablesMetadata implements ConnectorMetadata { - private final CatalogName catalogName; - private final SystemTablesProvider tables; - public SystemTablesMetadata(CatalogName catalogName, SystemTablesProvider tables) + public SystemTablesMetadata(SystemTablesProvider tables) { - this.catalogName = requireNonNull(catalogName, "connectorId"); this.tables = requireNonNull(tables, "tables is null"); } diff --git a/presto-main/src/main/java/io/prestosql/connector/system/SystemTransactionHandle.java b/presto-main/src/main/java/io/prestosql/connector/system/SystemTransactionHandle.java index 96432412d038..11419bb473ff 100644 --- a/presto-main/src/main/java/io/prestosql/connector/system/SystemTransactionHandle.java +++ b/presto-main/src/main/java/io/prestosql/connector/system/SystemTransactionHandle.java @@ -17,11 +17,9 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.google.common.base.Supplier; import com.google.common.base.Suppliers; -import io.prestosql.connector.CatalogName; import io.prestosql.spi.connector.ConnectorTransactionHandle; import io.prestosql.transaction.TransactionId; -import java.util.Objects; import java.util.function.Function; import static com.google.common.base.MoreObjects.toStringHelper; @@ -30,16 +28,13 @@ public class SystemTransactionHandle implements ConnectorTransactionHandle { - private final CatalogName catalogName; private final TransactionId transactionId; private final Supplier connectorTransactionHandle; SystemTransactionHandle( - CatalogName catalogName, TransactionId transactionId, Function transactionHandleFunction) { - this.catalogName = requireNonNull(catalogName, "catalogName is null"); this.transactionId = requireNonNull(transactionId, "transactionId is null"); requireNonNull(transactionHandleFunction, "transactionHandleFunction is null"); this.connectorTransactionHandle = Suppliers.memoize(() -> transactionHandleFunction.apply(transactionId)); @@ -47,22 +42,14 @@ public class SystemTransactionHandle @JsonCreator public SystemTransactionHandle( - @JsonProperty("catalogName") CatalogName catalogName, @JsonProperty("transactionId") TransactionId transactionId, @JsonProperty("connectorTransactionHandle") ConnectorTransactionHandle connectorTransactionHandle) { - this.catalogName = requireNonNull(catalogName, "catalogName is null"); this.transactionId = requireNonNull(transactionId, "transactionId is null"); requireNonNull(connectorTransactionHandle, "connectorTransactionHandle is null"); this.connectorTransactionHandle = () -> connectorTransactionHandle; } - @JsonProperty - public CatalogName getCatalogName() - { - return catalogName; - } - @JsonProperty public TransactionId getTransactionId() { @@ -78,7 +65,7 @@ public ConnectorTransactionHandle getConnectorTransactionHandle() @Override public int hashCode() { - return Objects.hash(catalogName, transactionId); + return transactionId.hashCode(); } @Override @@ -90,16 +77,14 @@ public boolean equals(Object obj) if (obj == null || getClass() != obj.getClass()) { return false; } - final SystemTransactionHandle other = (SystemTransactionHandle) obj; - return Objects.equals(this.catalogName, other.catalogName) && - Objects.equals(this.transactionId, other.transactionId); + SystemTransactionHandle other = (SystemTransactionHandle) obj; + return transactionId.equals(other.transactionId); } @Override public String toString() { return toStringHelper(this) - .add("catalogName", catalogName) .add("transactionHandle", transactionId) .toString(); } diff --git a/presto-main/src/main/java/io/prestosql/testing/TestingSession.java b/presto-main/src/main/java/io/prestosql/testing/TestingSession.java index 3494686964fd..9634f0b2d436 100644 --- a/presto-main/src/main/java/io/prestosql/testing/TestingSession.java +++ b/presto-main/src/main/java/io/prestosql/testing/TestingSession.java @@ -99,7 +99,7 @@ public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel @Override public ConnectorMetadata getMetadata(ConnectorTransactionHandle transaction) { - return new SystemTablesMetadata(new CatalogName("test_session_connector"), new StaticSystemTablesProvider(ImmutableSet.of())); + return new SystemTablesMetadata(new StaticSystemTablesProvider(ImmutableSet.of())); } @Override diff --git a/presto-main/src/test/java/io/prestosql/security/TestAccessControlManager.java b/presto-main/src/test/java/io/prestosql/security/TestAccessControlManager.java index 7db48276340f..a64a4b83387f 100644 --- a/presto-main/src/test/java/io/prestosql/security/TestAccessControlManager.java +++ b/presto-main/src/test/java/io/prestosql/security/TestAccessControlManager.java @@ -202,7 +202,6 @@ private static CatalogName registerBogusConnector(CatalogManager catalogManager, new InformationSchemaConnector(catalogName, nodeManager, metadata, accessControl), systemId, new SystemConnector( - systemId, nodeManager, connector.getSystemTables(), transactionId -> transactionManager.getConnectorTransaction(transactionId, catalog)))); diff --git a/presto-main/src/test/java/io/prestosql/sql/analyzer/TestAnalyzer.java b/presto-main/src/test/java/io/prestosql/sql/analyzer/TestAnalyzer.java index 29ce3cc95e20..9a009734618f 100644 --- a/presto-main/src/test/java/io/prestosql/sql/analyzer/TestAnalyzer.java +++ b/presto-main/src/test/java/io/prestosql/sql/analyzer/TestAnalyzer.java @@ -1782,7 +1782,6 @@ private Catalog createTestingCatalog(String catalogName, CatalogName catalog) new InformationSchemaConnector(catalogName, nodeManager, metadata, accessControl), systemId, new SystemConnector( - systemId, nodeManager, connector.getSystemTables(), transactionId -> transactionManager.getConnectorTransaction(transactionId, catalog))); diff --git a/presto-main/src/test/java/io/prestosql/transaction/TestTransactionManager.java b/presto-main/src/test/java/io/prestosql/transaction/TestTransactionManager.java index 9b87e2f763ea..583f471735b3 100644 --- a/presto-main/src/test/java/io/prestosql/transaction/TestTransactionManager.java +++ b/presto-main/src/test/java/io/prestosql/transaction/TestTransactionManager.java @@ -214,7 +214,6 @@ private static void registerConnector( new InformationSchemaConnector(catalogName, nodeManager, metadata, new AllowAllAccessControl()), systemId, new SystemConnector( - systemId, nodeManager, connector.getSystemTables(), transactionId -> transactionManager.getConnectorTransaction(transactionId, catalog))));