You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2021/11/02 15:53:24 UTC

[GitHub] [pinot] walterddr opened a new pull request #7679: add Metadata SPI interfaces and pinot-metadata module

walterddr opened a new pull request #7679:
URL: https://github.com/apache/pinot/pull/7679


   initial commit for the skeleton of system metadata SPI and plugin modules
   see more details in #7652.
   
   This PR adds a system metadata SPI interface to pinot-spi that allows plug-n-play different kind of system metadata registry handlers to handle system metadata into a remote RDBMS. 
   


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] walterddr edited a comment on pull request #7679: add Metadata SPI interfaces and pinot-metadata module

Posted by GitBox <gi...@apache.org>.
walterddr edited a comment on pull request #7679:
URL: https://github.com/apache/pinot/pull/7679#issuecomment-957964708


   > Is it intended that in addition to logging an info/warn/error message, pinot also writes to a database? 
   
   Partially, yes. But currently there's no guarantee that the logs consist of all the metadata information and there's no way to register specific messages to be logged to external metadata service. 
   
   > A blocking write? Instead, why not try one of the following:
   
   For the SPI design, it doesn't necessarily have to be a blocking write. It is up to the SystemMetricsRegistry to spin up execution service to handle the `flush` but it is up to the user to define where to `collect`. (the example in the test might've been a bad one)
   
   
   > * An independent process that pulls messages from log
   
   As I mentioned log might not contain all data needed, also it could contain too much irrelevant info to parse out.
   
   > * A log pipeline that publishes asynchronously (light-weight) to a stream
   
   Yes, this is the basic intend of the SPI. In fact one implementation of the SPI can simply be a logging service (with schema) that writes to a separate file. However in this setting the external (light-weight) process that publish async to a stream will not be part of the SPI itself.
   
   
   
   
   
   


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] walterddr commented on pull request #7679: add Metadata SPI interfaces and pinot-metadata module

Posted by GitBox <gi...@apache.org>.
walterddr commented on pull request #7679:
URL: https://github.com/apache/pinot/pull/7679#issuecomment-957964708


   > Is it intended that in addition to logging an info/warn/error message, pinot also writes to a database? 
   Partially, yes. But currently there's no guarantee that the logs consist of all the metadata information and there's no way to register specific messages to be logged to external metadata service. 
   
   > A blocking write? Instead, why not try one of the following:
   For the SPI design, it doesn't necessarily have to be a blocking write. It is up to the SystemMetricsRegistry to spin up execution service to handle the `flush` but it is up to the user to define where to `collect`. (the example in the test might've been a bad one)
   
   
   > * An independent process that pulls messages from log
   As I mentioned log might not contain all data needed, also it could contain too much irrelevant info to parse out.
   
   > * A log pipeline that publishes asynchronously (light-weight) to a stream
   Yes, this is the basic intend of the SPI. In fact one implementation of the SPI can simply be a logging service (with schema) that writes to a separate file. However in this setting the external (light-weight) process that publish async to a stream will not be part of the SPI itself.
   
   
   
   
   
   


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] richardstartin commented on a change in pull request #7679: add Metadata SPI interfaces and pinot-metadata module

Posted by GitBox <gi...@apache.org>.
richardstartin commented on a change in pull request #7679:
URL: https://github.com/apache/pinot/pull/7679#discussion_r741249156



##########
File path: pinot-plugins/pinot-system-metadata/pinot-system-metadata-common/src/test/java/org/apache/pinot/plugin/system/sqlite/SqliteMetadataStore.java
##########
@@ -0,0 +1,200 @@
+/**
+ * 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.pinot.plugin.system.sqlite;
+
+import com.google.common.base.Preconditions;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.pinot.spi.data.FieldSpec;
+import org.apache.pinot.spi.data.Schema;
+import org.apache.pinot.spi.env.PinotConfiguration;
+import org.apache.pinot.spi.system.SystemMetadata;
+import org.apache.pinot.spi.system.SystemMetadataStore;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * A basic sqlite system metadata store that connects to a sqlite metadata store.
+ */
+public class SqliteMetadataStore implements SystemMetadataStore {
+  private static final Logger LOGGER = LoggerFactory.getLogger(SqliteMetadataStore.class);
+  private static final String SQLITE_METADATA_STORE_CONN_URL = "sqlite.conn";
+
+  private final PinotConfiguration _pinotConfiguration;
+
+  private Connection _connection;
+
+  public SqliteMetadataStore(PinotConfiguration pinotConfiguration) {
+    _pinotConfiguration = pinotConfiguration;
+  }
+
+  @Override
+  public void connect()
+      throws Exception {
+    _connection = DriverManager.getConnection(_pinotConfiguration.getProperty(SQLITE_METADATA_STORE_CONN_URL));
+  }
+
+  @Override
+  public void shutdown()
+      throws Exception {
+    _connection.close();
+  }
+
+  @Override
+  public boolean accepts(SystemMetadata systemMetadata) {
+    try {
+      Statement stat = _connection.createStatement();
+      int status = stat.executeUpdate(String.format("CREATE TABLE %s(%s)", systemMetadata.getSystemMetadataName(),
+          getColumnList(systemMetadata.getColumnName())));
+      return status == 0;
+    } catch (Exception e) {
+      LOGGER.error(String.format("Unable to accept SystemMetadata %s", systemMetadata.getSystemMetadataName()), e);
+      return false;
+    }
+  }
+
+  @Override
+  public void collect(SystemMetadata systemMetadata, long timestamp, Object[] row)
+      throws Exception {
+    PreparedStatement stat = _connection.prepareStatement(String.format("INSERT INTO %s VALUES(%s)",
+        systemMetadata.getSystemMetadataName(), getPrepareStatementPlaceholders(systemMetadata.getColumnName())));
+    executeStatement(stat, systemMetadata.getColumnDataType(), row);
+  }
+
+  @Override
+  public List<Object[]> inspect(SystemMetadata systemMetadata)
+      throws Exception {
+    Statement stat = _connection.createStatement();
+    ResultSet rs = stat.executeQuery(String.format("SELECT * FROM %s", systemMetadata.getSystemMetadataName()));
+    List<Object[]> result = new ArrayList<>();
+    while (rs.next()) {
+      result.add(constructRow(rs, systemMetadata));
+    }
+    return result;
+  }
+
+  @Override
+  public void flush()
+      throws Exception {
+    // no-op
+  }
+
+  private String getColumnList(String[] columnNames) {
+    return StringUtils.join(columnNames, ", ");
+  }
+
+  private String getPrepareStatementPlaceholders(String[] columnNames) {
+    int placeholderLength = columnNames.length;
+    String[] placeHolders = new String[placeholderLength];
+    Arrays.fill(placeHolders, "?");
+    return StringUtils.join(placeHolders, ", ");
+  }
+
+  private void executeStatement(PreparedStatement stat, FieldSpec.DataType[] dataTypes, Object[] row)
+      throws Exception {
+    Preconditions.checkState(dataTypes.length == row.length,
+        "schema and data size much match!");
+    int index = 0;
+    for (FieldSpec.DataType dataType : dataTypes) {
+      switch (dataType) {
+        case INT:
+          stat.setInt(index + 1, (int) row[index]);

Review comment:
       preincrement? 😛 




-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] mcvsubbu commented on pull request #7679: add Metadata SPI interfaces and pinot-metadata module

Posted by GitBox <gi...@apache.org>.
mcvsubbu commented on pull request #7679:
URL: https://github.com/apache/pinot/pull/7679#issuecomment-957906641


   Is it intended that in addition to logging an info/warn/error message, pinot also writes to a database? A blocking write? Instead, why not try one of the following:
   - An independent process that pulls messages from log
   - A log pipeline that publishes asynchronously (light-weight) to a stream


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] mcvsubbu commented on pull request #7679: add Metadata SPI interfaces and pinot-metadata module

Posted by GitBox <gi...@apache.org>.
mcvsubbu commented on pull request #7679:
URL: https://github.com/apache/pinot/pull/7679#issuecomment-957906641






-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] richardstartin commented on a change in pull request #7679: add Metadata SPI interfaces and pinot-metadata module

Posted by GitBox <gi...@apache.org>.
richardstartin commented on a change in pull request #7679:
URL: https://github.com/apache/pinot/pull/7679#discussion_r741249156



##########
File path: pinot-plugins/pinot-system-metadata/pinot-system-metadata-common/src/test/java/org/apache/pinot/plugin/system/sqlite/SqliteMetadataStore.java
##########
@@ -0,0 +1,200 @@
+/**
+ * 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.pinot.plugin.system.sqlite;
+
+import com.google.common.base.Preconditions;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.pinot.spi.data.FieldSpec;
+import org.apache.pinot.spi.data.Schema;
+import org.apache.pinot.spi.env.PinotConfiguration;
+import org.apache.pinot.spi.system.SystemMetadata;
+import org.apache.pinot.spi.system.SystemMetadataStore;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * A basic sqlite system metadata store that connects to a sqlite metadata store.
+ */
+public class SqliteMetadataStore implements SystemMetadataStore {
+  private static final Logger LOGGER = LoggerFactory.getLogger(SqliteMetadataStore.class);
+  private static final String SQLITE_METADATA_STORE_CONN_URL = "sqlite.conn";
+
+  private final PinotConfiguration _pinotConfiguration;
+
+  private Connection _connection;
+
+  public SqliteMetadataStore(PinotConfiguration pinotConfiguration) {
+    _pinotConfiguration = pinotConfiguration;
+  }
+
+  @Override
+  public void connect()
+      throws Exception {
+    _connection = DriverManager.getConnection(_pinotConfiguration.getProperty(SQLITE_METADATA_STORE_CONN_URL));
+  }
+
+  @Override
+  public void shutdown()
+      throws Exception {
+    _connection.close();
+  }
+
+  @Override
+  public boolean accepts(SystemMetadata systemMetadata) {
+    try {
+      Statement stat = _connection.createStatement();
+      int status = stat.executeUpdate(String.format("CREATE TABLE %s(%s)", systemMetadata.getSystemMetadataName(),
+          getColumnList(systemMetadata.getColumnName())));
+      return status == 0;
+    } catch (Exception e) {
+      LOGGER.error(String.format("Unable to accept SystemMetadata %s", systemMetadata.getSystemMetadataName()), e);
+      return false;
+    }
+  }
+
+  @Override
+  public void collect(SystemMetadata systemMetadata, long timestamp, Object[] row)
+      throws Exception {
+    PreparedStatement stat = _connection.prepareStatement(String.format("INSERT INTO %s VALUES(%s)",
+        systemMetadata.getSystemMetadataName(), getPrepareStatementPlaceholders(systemMetadata.getColumnName())));
+    executeStatement(stat, systemMetadata.getColumnDataType(), row);
+  }
+
+  @Override
+  public List<Object[]> inspect(SystemMetadata systemMetadata)
+      throws Exception {
+    Statement stat = _connection.createStatement();
+    ResultSet rs = stat.executeQuery(String.format("SELECT * FROM %s", systemMetadata.getSystemMetadataName()));
+    List<Object[]> result = new ArrayList<>();
+    while (rs.next()) {
+      result.add(constructRow(rs, systemMetadata));
+    }
+    return result;
+  }
+
+  @Override
+  public void flush()
+      throws Exception {
+    // no-op
+  }
+
+  private String getColumnList(String[] columnNames) {
+    return StringUtils.join(columnNames, ", ");
+  }
+
+  private String getPrepareStatementPlaceholders(String[] columnNames) {
+    int placeholderLength = columnNames.length;
+    String[] placeHolders = new String[placeholderLength];
+    Arrays.fill(placeHolders, "?");
+    return StringUtils.join(placeHolders, ", ");
+  }
+
+  private void executeStatement(PreparedStatement stat, FieldSpec.DataType[] dataTypes, Object[] row)
+      throws Exception {
+    Preconditions.checkState(dataTypes.length == row.length,
+        "schema and data size much match!");
+    int index = 0;
+    for (FieldSpec.DataType dataType : dataTypes) {
+      switch (dataType) {
+        case INT:
+          stat.setInt(index + 1, (int) row[index]);

Review comment:
       preincrement? 😛 




-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] mcvsubbu commented on pull request #7679: add Metadata SPI interfaces and pinot-metadata module

Posted by GitBox <gi...@apache.org>.
mcvsubbu commented on pull request #7679:
URL: https://github.com/apache/pinot/pull/7679#issuecomment-958005827


   Requested a design doc in Issue #7652, thanks.


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] walterddr edited a comment on pull request #7679: add Metadata SPI interfaces and pinot-metadata module

Posted by GitBox <gi...@apache.org>.
walterddr edited a comment on pull request #7679:
URL: https://github.com/apache/pinot/pull/7679#issuecomment-957964708


   > Is it intended that in addition to logging an info/warn/error message, pinot also writes to a database? 
   
   Partially, yes. But currently there's no guarantee that the logs consist of all the metadata information and there's no way to register specific messages to be logged to external metadata service. 
   
   > A blocking write? Instead, why not try one of the following:
   
   For the SPI design, it doesn't necessarily have to be a blocking write. It is up to the SystemMetricsRegistry to spin up execution service to handle the `flush` but it is up to the user to define where to `collect`. (the example in the test might've been a bad one)
   
   
   > * An independent process that pulls messages from log
   
   As I mentioned log might not contain all data needed, also it could contain too much irrelevant info to parse out.
   
   > * A log pipeline that publishes asynchronously (light-weight) to a stream
   
   Yes, this is the basic intend of the SPI. In fact one implementation of the SPI can simply be a logging service (with schema) that writes to a separate file. However in this setting the external (light-weight) process that publish async to a stream will not be part of the SPI itself.
   
   
   
   
   
   


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] richardstartin commented on a change in pull request #7679: add Metadata SPI interfaces and pinot-metadata module

Posted by GitBox <gi...@apache.org>.
richardstartin commented on a change in pull request #7679:
URL: https://github.com/apache/pinot/pull/7679#discussion_r741249156



##########
File path: pinot-plugins/pinot-system-metadata/pinot-system-metadata-common/src/test/java/org/apache/pinot/plugin/system/sqlite/SqliteMetadataStore.java
##########
@@ -0,0 +1,200 @@
+/**
+ * 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.pinot.plugin.system.sqlite;
+
+import com.google.common.base.Preconditions;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.pinot.spi.data.FieldSpec;
+import org.apache.pinot.spi.data.Schema;
+import org.apache.pinot.spi.env.PinotConfiguration;
+import org.apache.pinot.spi.system.SystemMetadata;
+import org.apache.pinot.spi.system.SystemMetadataStore;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * A basic sqlite system metadata store that connects to a sqlite metadata store.
+ */
+public class SqliteMetadataStore implements SystemMetadataStore {
+  private static final Logger LOGGER = LoggerFactory.getLogger(SqliteMetadataStore.class);
+  private static final String SQLITE_METADATA_STORE_CONN_URL = "sqlite.conn";
+
+  private final PinotConfiguration _pinotConfiguration;
+
+  private Connection _connection;
+
+  public SqliteMetadataStore(PinotConfiguration pinotConfiguration) {
+    _pinotConfiguration = pinotConfiguration;
+  }
+
+  @Override
+  public void connect()
+      throws Exception {
+    _connection = DriverManager.getConnection(_pinotConfiguration.getProperty(SQLITE_METADATA_STORE_CONN_URL));
+  }
+
+  @Override
+  public void shutdown()
+      throws Exception {
+    _connection.close();
+  }
+
+  @Override
+  public boolean accepts(SystemMetadata systemMetadata) {
+    try {
+      Statement stat = _connection.createStatement();
+      int status = stat.executeUpdate(String.format("CREATE TABLE %s(%s)", systemMetadata.getSystemMetadataName(),
+          getColumnList(systemMetadata.getColumnName())));
+      return status == 0;
+    } catch (Exception e) {
+      LOGGER.error(String.format("Unable to accept SystemMetadata %s", systemMetadata.getSystemMetadataName()), e);
+      return false;
+    }
+  }
+
+  @Override
+  public void collect(SystemMetadata systemMetadata, long timestamp, Object[] row)
+      throws Exception {
+    PreparedStatement stat = _connection.prepareStatement(String.format("INSERT INTO %s VALUES(%s)",
+        systemMetadata.getSystemMetadataName(), getPrepareStatementPlaceholders(systemMetadata.getColumnName())));
+    executeStatement(stat, systemMetadata.getColumnDataType(), row);
+  }
+
+  @Override
+  public List<Object[]> inspect(SystemMetadata systemMetadata)
+      throws Exception {
+    Statement stat = _connection.createStatement();
+    ResultSet rs = stat.executeQuery(String.format("SELECT * FROM %s", systemMetadata.getSystemMetadataName()));
+    List<Object[]> result = new ArrayList<>();
+    while (rs.next()) {
+      result.add(constructRow(rs, systemMetadata));
+    }
+    return result;
+  }
+
+  @Override
+  public void flush()
+      throws Exception {
+    // no-op
+  }
+
+  private String getColumnList(String[] columnNames) {
+    return StringUtils.join(columnNames, ", ");
+  }
+
+  private String getPrepareStatementPlaceholders(String[] columnNames) {
+    int placeholderLength = columnNames.length;
+    String[] placeHolders = new String[placeholderLength];
+    Arrays.fill(placeHolders, "?");
+    return StringUtils.join(placeHolders, ", ");
+  }
+
+  private void executeStatement(PreparedStatement stat, FieldSpec.DataType[] dataTypes, Object[] row)
+      throws Exception {
+    Preconditions.checkState(dataTypes.length == row.length,
+        "schema and data size much match!");
+    int index = 0;
+    for (FieldSpec.DataType dataType : dataTypes) {
+      switch (dataType) {
+        case INT:
+          stat.setInt(index + 1, (int) row[index]);

Review comment:
       preincrement? 😛 




-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] walterddr commented on pull request #7679: add Metadata SPI interfaces and pinot-metadata module

Posted by GitBox <gi...@apache.org>.
walterddr commented on pull request #7679:
URL: https://github.com/apache/pinot/pull/7679#issuecomment-957964708


   > Is it intended that in addition to logging an info/warn/error message, pinot also writes to a database? 
   Partially, yes. But currently there's no guarantee that the logs consist of all the metadata information and there's no way to register specific messages to be logged to external metadata service. 
   
   > A blocking write? Instead, why not try one of the following:
   For the SPI design, it doesn't necessarily have to be a blocking write. It is up to the SystemMetricsRegistry to spin up execution service to handle the `flush` but it is up to the user to define where to `collect`. (the example in the test might've been a bad one)
   
   
   > * An independent process that pulls messages from log
   As I mentioned log might not contain all data needed, also it could contain too much irrelevant info to parse out.
   
   > * A log pipeline that publishes asynchronously (light-weight) to a stream
   Yes, this is the basic intend of the SPI. In fact one implementation of the SPI can simply be a logging service (with schema) that writes to a separate file. However in this setting the external (light-weight) process that publish async to a stream will not be part of the SPI itself.
   
   
   
   
   
   


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] walterddr edited a comment on pull request #7679: add Metadata SPI interfaces and pinot-metadata module

Posted by GitBox <gi...@apache.org>.
walterddr edited a comment on pull request #7679:
URL: https://github.com/apache/pinot/pull/7679#issuecomment-957964708


   > Is it intended that in addition to logging an info/warn/error message, pinot also writes to a database? 
   
   Partially, yes. But currently there's no guarantee that the logs consist of all the metadata information and there's no way to register specific messages to be logged to external metadata service. 
   
   > A blocking write? Instead, why not try one of the following:
   
   For the SPI design, it doesn't necessarily have to be a blocking write. It is up to the SystemMetricsRegistry to spin up execution service to handle the `flush` but it is up to the user to define where to `collect`. (the example in the test might've been a bad one)
   
   
   > * An independent process that pulls messages from log
   
   As I mentioned log might not contain all data needed, also it could contain too much irrelevant info to parse out.
   
   > * A log pipeline that publishes asynchronously (light-weight) to a stream
   
   Yes, this is the basic intend of the SPI. In fact one implementation of the SPI can simply be a logging service (with schema) that writes to a separate file. However in this setting the external (light-weight) process that publish async to a stream will not be part of the SPI itself.
   
   
   
   
   
   


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] mcvsubbu commented on pull request #7679: add Metadata SPI interfaces and pinot-metadata module

Posted by GitBox <gi...@apache.org>.
mcvsubbu commented on pull request #7679:
URL: https://github.com/apache/pinot/pull/7679#issuecomment-957906641


   Is it intended that in addition to logging an info/warn/error message, pinot also writes to a database? A blocking write? Instead, why not try one of the following:
   - An independent process that pulls messages from log
   - A log pipeline that publishes asynchronously (light-weight) to a stream


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [pinot] walterddr commented on pull request #7679: add Metadata SPI interfaces and pinot-metadata module

Posted by GitBox <gi...@apache.org>.
walterddr commented on pull request #7679:
URL: https://github.com/apache/pinot/pull/7679#issuecomment-957964708


   > Is it intended that in addition to logging an info/warn/error message, pinot also writes to a database? 
   Partially, yes. But currently there's no guarantee that the logs consist of all the metadata information and there's no way to register specific messages to be logged to external metadata service. 
   
   > A blocking write? Instead, why not try one of the following:
   For the SPI design, it doesn't necessarily have to be a blocking write. It is up to the SystemMetricsRegistry to spin up execution service to handle the `flush` but it is up to the user to define where to `collect`. (the example in the test might've been a bad one)
   
   
   > * An independent process that pulls messages from log
   As I mentioned log might not contain all data needed, also it could contain too much irrelevant info to parse out.
   
   > * A log pipeline that publishes asynchronously (light-weight) to a stream
   Yes, this is the basic intend of the SPI. In fact one implementation of the SPI can simply be a logging service (with schema) that writes to a separate file. However in this setting the external (light-weight) process that publish async to a stream will not be part of the SPI itself.
   
   
   
   
   
   


-- 
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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org