org.apache.phoenix.util.QueryUtil.getConnectionOnServer()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(9.7k)|赞(0)|评价(0)|浏览(91)

本文整理了Java中org.apache.phoenix.util.QueryUtil.getConnectionOnServer方法的一些代码示例,展示了QueryUtil.getConnectionOnServer的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。QueryUtil.getConnectionOnServer方法的具体详情如下:
包路径:org.apache.phoenix.util.QueryUtil
类名称:QueryUtil
方法名:getConnectionOnServer

QueryUtil.getConnectionOnServer介绍

暂无

代码示例

代码示例来源:origin: apache/phoenix

public static Connection getConnectionForQueryLog(Configuration config) throws ClassNotFoundException, SQLException {
  //we don't need this connection to upgrade anything or start dispatcher
  return getConnectionOnServer(config);
}

代码示例来源:origin: apache/phoenix

/**
 * @return {@link PhoenixConnection} with {@value UpgradeUtil#RUN_UPGRADE} set so that we don't initiate server upgrade
 */
public static Connection getConnectionOnServer(Configuration conf) throws ClassNotFoundException,
    SQLException {
  return getConnectionOnServer(new Properties(), conf);
}

代码示例来源:origin: apache/phoenix

@Override
protected void setup(Context context) throws IOException, InterruptedException {
  Configuration conf = context.getConfiguration();
  // pass client configuration into driver
  Properties clientInfos = new Properties();
  for (Map.Entry<String, String> entry : conf) {
    clientInfos.setProperty(entry.getKey(), entry.getValue());
  }
  try {
    PhoenixConnection conn = (PhoenixConnection) QueryUtil.getConnectionOnServer(clientInfos, conf);
    builder = conn.getKeyValueBuilder();
    final String tableNamesConf = conf.get(FormatToBytesWritableMapper.TABLE_NAMES_CONFKEY);
    final String logicalNamesConf = conf.get(FormatToBytesWritableMapper.LOGICAL_NAMES_CONFKEY);
    tableNames = TargetTableRefFunctions.NAMES_FROM_JSON.apply(tableNamesConf);
    logicalNames = TargetTableRefFunctions.NAMES_FROM_JSON.apply(logicalNamesConf);
    initColumnsMap(conn);
  } catch (SQLException | ClassNotFoundException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: apache/phoenix

/**
 * Initialize <tt>this</tt> only when we need it
 */
private void lazyInitialize() {
  synchronized (this) {
    if (this.conn != null) {
      return;
    }
    try {
      // create the phoenix connection
      Properties props = new Properties();
      props.setProperty(QueryServices.TRACING_FREQ_ATTRIB,
          Tracing.Frequency.NEVER.getKey());
      org.apache.hadoop.conf.Configuration conf = HBaseConfiguration.create();
      Connection conn = QueryUtil.getConnectionOnServer(props, conf);
      // enable bulk loading when we have enough data
      conn.setAutoCommit(true);
      String tableName =
          conf.get(QueryServices.TRACING_STATS_TABLE_NAME_ATTRIB,
              QueryServicesOptions.DEFAULT_TRACING_STATS_TABLE_NAME);
      initializeInternal(conn, tableName);
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
}

代码示例来源:origin: apache/phoenix

protected Connection getConnection(String tableName) {
  try {
    // create the phoenix connection
    Properties props = new Properties();
    props.setProperty(QueryServices.TRACING_FREQ_ATTRIB, Tracing.Frequency.NEVER.getKey());
    Configuration conf = HBaseConfiguration.create();
    Connection conn = QueryUtil.getConnectionOnServer(props, conf);
    if (!traceTableExists(conn, tableName)) {
      createTable(conn, tableName);
    }
    LOG.info(
      "Created new connection for tracing " + conn.toString() + " Table: " + tableName);
    return conn;
  } catch (Exception e) {
    LOG.error("Tracing will NOT be pursued. New connection failed for tracing Table: "
        + tableName,
      e);
    LOG.error("Restart Phoenix to retry.");
    return null;
  }
}

代码示例来源:origin: apache/phoenix

/**
 * Removes the table from the server side cache
 */
private void clearParentTableFromCache(long clientTimeStamp, byte[] schemaName, byte[] tableName) throws SQLException {
  // remove the parent table from the metadata cache as we just mutated the table
  Properties props = new Properties();
  if (clientTimeStamp != HConstants.LATEST_TIMESTAMP) {
    props.setProperty("CurrentSCN", Long.toString(clientTimeStamp));
  }
  try (PhoenixConnection connection =
      QueryUtil.getConnectionOnServer(props, env.getConfiguration())
          .unwrap(PhoenixConnection.class)) {
    ConnectionQueryServices queryServices = connection.getQueryServices();
    queryServices.clearTableFromCache(ByteUtil.EMPTY_BYTE_ARRAY, schemaName, tableName,
      clientTimeStamp);
  } catch (ClassNotFoundException e) {
  }
}

代码示例来源:origin: apache/phoenix

@Override
protected void setup(Context context) throws IOException, InterruptedException {
  Configuration conf = context.getConfiguration();
  // pass client configuration into driver
  Properties clientInfos = new Properties();
  for (Map.Entry<String, String> entry : conf) {
    clientInfos.setProperty(entry.getKey(), entry.getValue());
  }
  try {
    conn = (PhoenixConnection) QueryUtil.getConnectionOnServer(clientInfos, conf);
    // We are dependent on rolling back before performing commits, so we need to be sure
    // that auto-commit is not turned on
    conn.setAutoCommit(false);
    final String tableNamesConf = conf.get(TABLE_NAMES_CONFKEY);
    final String logicalNamesConf = conf.get(LOGICAL_NAMES_CONFKEY);
    tableNames = TargetTableRefFunctions.NAMES_FROM_JSON.apply(tableNamesConf);
    logicalNames = TargetTableRefFunctions.NAMES_FROM_JSON.apply(logicalNamesConf);
    initColumnIndexes();
  } catch (SQLException | ClassNotFoundException e) {
    throw new RuntimeException(e);
  }
  upsertListener = new MapperUpsertListener<RECORD>(
      context, conf.getBoolean(IGNORE_INVALID_ROW_CONFKEY, true));
  upsertExecutor = buildUpsertExecutor(conf);
  preUpdateProcessor = PhoenixConfigurationUtil.loadPreUpsertProcessor(conf);
}

代码示例来源:origin: apache/phoenix

" WHERE "+ PhoenixDatabaseMetaData.TASK_TYPE + " = " + PTable.TaskType.DROP_CHILD_VIEWS.getSerializedValue();
connForTask = QueryUtil.getConnectionOnServer(env.getConfiguration()).unwrap(PhoenixConnection.class);
PreparedStatement taskStatement = connForTask.prepareStatement(taskQuery);
ResultSet rs = taskStatement.executeQuery();
      Properties tenantProps = new Properties();
      tenantProps.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId);
      pconn = QueryUtil.getConnectionOnServer(tenantProps, env.getConfiguration()).unwrap(PhoenixConnection.class);
      pconn = QueryUtil.getConnectionOnServer(env.getConfiguration()).unwrap(PhoenixConnection.class);

代码示例来源:origin: apache/phoenix

QueryUtil.getConnectionOnServer(compactionConfig).unwrap(PhoenixConnection.class)) {
PTable table = PhoenixRuntime.getTableNoCache(conn, fullTableName);
List<PTable> indexes = PTableType.INDEX.equals(table.getType()) ? Lists.newArrayList(table) : table.getIndexes();

代码示例来源:origin: apache/phoenix

if (viewTenantId != null && viewTenantId.length != 0)
  props.setProperty(PhoenixRuntime.TENANT_ID_ATTRIB, Bytes.toString(viewTenantId));
try (PhoenixConnection connection = QueryUtil.getConnectionOnServer(props, env.getConfiguration())
    .unwrap(PhoenixConnection.class)) {
  MetaDataClient client = new MetaDataClient(connection);

代码示例来源:origin: apache/phoenix

private void handleIndexWriteException(final List<Mutation> localRegionMutations, IOException origIOE,
     MutateCommand mutateCommand) throws IOException {
   long serverTimestamp = ServerUtil.parseTimestampFromRemoteException(origIOE);
   SQLException inferredE = ServerUtil.parseLocalOrRemoteServerException(origIOE);
   if (inferredE != null && inferredE.getErrorCode() == SQLExceptionCode.INDEX_WRITE_FAILURE.getErrorCode()) {
     // For an index write failure, the data table write succeeded,
     // so when we retry we need to set REPLAY_WRITES
     for (Mutation mutation : localRegionMutations) {
       mutation.setAttribute(REPLAY_WRITES, REPLAY_ONLY_INDEX_WRITES);
       // use the server timestamp for index write retries
       PhoenixKeyValueUtil.setTimestamp(mutation, serverTimestamp);
     }
     IndexWriteException iwe = PhoenixIndexFailurePolicy.getIndexWriteException(inferredE);
     try (PhoenixConnection conn =
         QueryUtil.getConnectionOnServer(indexWriteConfig)
             .unwrap(PhoenixConnection.class)) {
       PhoenixIndexFailurePolicy.doBatchWithRetries(mutateCommand, iwe, conn,
         indexWriteProps);
     } catch (Exception e) {
       throw new DoNotRetryIOException(e);
     }
   } else {
     throw origIOE;
   }
 }

代码示例来源:origin: apache/phoenix

PhoenixConnection conn = null;
try {
  conn = QueryUtil.getConnectionOnServer(this.env.getConfiguration()).unwrap(
      PhoenixConnection.class);
  PTable dataTable = PhoenixRuntime.getTableNoCache(conn, ref.getTableName());

代码示例来源:origin: apache/phoenix

connection = table.getIndexes().isEmpty() ? null : QueryUtil.getConnectionOnServer(
    env.getConfiguration()).unwrap(PhoenixConnection.class);
} catch (ClassNotFoundException e) {

代码示例来源:origin: apache/phoenix

PhoenixConnection conn = QueryUtil.getConnectionOnServer(env.getConfiguration())
    .unwrap(PhoenixConnection.class);
PTable dataPTable = IndexUtil.getPDataTable(conn, env.getRegion().getTableDescriptor());

代码示例来源:origin: apache/phoenix

QueryUtil.getConnectionOnServer(props, env.getConfiguration())
      .unwrap(PhoenixConnection.class)) {
ConnectionQueryServices queryServices = connection.getQueryServices();

代码示例来源:origin: apache/phoenix

QueryUtil.getConnectionOnServer(configuration)) {
PTable table = PhoenixRuntime.getTable(conn, tableName);
if (table.getType() == PTableType.INDEX

代码示例来源:origin: apache/phoenix

PhoenixConnection conn = QueryUtil.getConnectionOnServer(env.getConfiguration()).unwrap(PhoenixConnection.class);
TaskRegionObserver.addTask(conn, PTable.TaskType.DROP_CHILD_VIEWS, Bytes.toString(tenantId),
  Bytes.toString(schemaName), Bytes.toString(tableName), this.accessCheckEnabled);

代码示例来源:origin: apache/phoenix

PhoenixConnection conn=null;
try {
  conn = QueryUtil.getConnectionOnServer(env.getConfiguration()).unwrap(
    PhoenixConnection.class);
} catch (ClassNotFoundException e) {

代码示例来源:origin: apache/phoenix

conn = QueryUtil.getConnectionOnServer(ctx.getEnvironment().getConfiguration()).unwrap(
      PhoenixConnection.class);
PTable dataTable =

代码示例来源:origin: apache/phoenix

try (PhoenixConnection connection = QueryUtil.getConnectionOnServer(env.getConfiguration()).unwrap(PhoenixConnection.class);
    Statement stmt = connection.createStatement()) {
    String seqName = parentTable.getAutoPartitionSeqName();
if (request.hasAllocateIndexId() && request.getAllocateIndexId()) {
  String tenantIdStr = tenantIdBytes.length == 0 ? null : Bytes.toString(tenantIdBytes);
  try (PhoenixConnection connection = QueryUtil.getConnectionOnServer(env.getConfiguration()).unwrap(PhoenixConnection.class)) {
    PName physicalName = parentTable.getPhysicalName();
    int nSequenceSaltBuckets = connection.getQueryServices().getSequenceSaltBuckets();

相关文章