com.axibase.tsd.driver.jdbc.strategies.Consumer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of atsd-jdbc Show documentation
Show all versions of atsd-jdbc Show documentation
JDBC driver for SQL API using
/*
* Copyright 2016 Axibase Corporation or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* https://www.axibase.com/atsd/axibase-apache-2.0.pdf
*
* or in the "license" file accompanying this file. This file 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.axibase.tsd.driver.jdbc.strategies;
import com.axibase.tsd.driver.jdbc.content.StatementContext;
import com.axibase.tsd.driver.jdbc.content.json.*;
import com.axibase.tsd.driver.jdbc.enums.OnMissingMetricAction;
import com.axibase.tsd.driver.jdbc.ext.AtsdRuntimeException;
import com.axibase.tsd.driver.jdbc.intf.IConsumer;
import com.axibase.tsd.driver.jdbc.logging.LoggingFacade;
import com.axibase.tsd.driver.jdbc.util.JsonMappingUtil;
import org.apache.calcite.avatica.ColumnMetaData;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
import java.io.InputStream;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import static com.axibase.tsd.driver.jdbc.util.ExceptionsUtil.isMetricNotFoundException;
public class Consumer implements IConsumer {
private static final LoggingFacade logger = LoggingFacade.getLogger(Consumer.class);
protected final StrategyStatus status;
protected final StatementContext context;
protected final OnMissingMetricAction onMissingMetricAction;
protected final String source;
protected RowIterator iterator;
public Consumer(final StatementContext context, final StrategyStatus status, String source, OnMissingMetricAction action) {
this.context = context;
this.status = status;
this.source = source;
this.onMissingMetricAction = action;
}
@Override
public StatementContext getContext() {
return context;
}
@Override
public void close() throws IOException {
if (logger.isTraceEnabled()) {
logger.trace("[close]");
}
if (iterator != null) {
iterator.close();
}
}
@Override
public String[] open(InputStream inputStream, List columnMetadataList) throws IOException {
iterator = RowIterator.newDefaultIterator(inputStream, columnMetadataList, context.getVersion());
return iterator.getHeader();
}
@Override
public Iterator
© 2015 - 2024 Weber Informatics LLC | Privacy Policy