/** * Update the cache with the latest as of the connection scn. * @param schemaName * @param tableName * @return the timestamp from the server, negative if the table was added to the cache and positive otherwise * @throws SQLException */ public MetaDataMutationResult updateCache(String schemaName, String tableName) throws SQLException { return updateCache(schemaName, tableName, false); }
/** * Update the cache with the latest as of the connection scn. * @param functioNames * @return the timestamp from the server, negative if the function was added to the cache and positive otherwise * @throws SQLException */ public MetaDataMutationResult updateCache(List<String> functionNames) throws SQLException { return updateCache(functionNames, false); }
public MetaDataMutationResult updateCache(PName tenantId, List<String> functionNames) throws SQLException { return updateCache(tenantId, functionNames, false); }
public MetaDataMutationResult updateCache(String schemaName) throws SQLException { return updateCache(schemaName, false); }
public MetaDataMutationResult updateCache(PName tenantId, String schemaName, String tableName, boolean alwaysHitServer) throws SQLException { return updateCache(tenantId, schemaName, tableName, alwaysHitServer, null); }
public MetaDataMutationResult updateCache(PName tenantId, String schemaName, String tableName) throws SQLException { return updateCache(tenantId, schemaName, tableName, false); }
public long getCurrentTime(String schemaName, String tableName) throws SQLException { MetaDataMutationResult result = updateCache(schemaName, tableName, true); return result.getMutationTime(); }
private MetaDataMutationResult updateCache(String schemaName, String tableName, boolean alwaysHitServer) throws SQLException { return updateCache(connection.getTenantId(), schemaName, tableName, alwaysHitServer); }
private MetaDataMutationResult updateCache(List<String> functionNames, boolean alwaysHitServer) throws SQLException { return updateCache(connection.getTenantId(), functionNames, alwaysHitServer); }
public static boolean isDisabledWal(MetaDataClient metaDataClient, String tableName) throws SQLException { String[] schemaInfo = getTableSchema(tableName.toUpperCase()); MetaDataMutationResult result = metaDataClient.updateCache(schemaInfo[0], schemaInfo[1]); PTable dataTable = result.getTable(); return dataTable.isWALDisabled(); }
return functionsFound; MetaDataMutationResult result = client.updateCache(functionNames); timeStamp = result.getMutationTime(); functionsFound = result.getFunctions(); result = client.updateCache(functionNames);
MetaDataProtocol.MetaDataMutationResult result = new MetaDataClient(pconn).updateCache(pconn.getTenantId(), schemaName, tableName, true); if (result.getMutationCode() != MetaDataProtocol.MutationCode.TABLE_ALREADY_EXISTS) {
public static PTable getTableNoCache(Connection conn, String name) throws SQLException { String schemaName = SchemaUtil.getSchemaNameFromFullName(name); String tableName = SchemaUtil.getTableNameFromFullName(name); PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); MetaDataMutationResult result = new MetaDataClient(pconn).updateCache(pconn.getTenantId(), schemaName, tableName, true); if(result.getMutationCode() != MutationCode.TABLE_ALREADY_EXISTS) { throw new TableNotFoundException(schemaName, tableName); } return result.getTable(); }
protected PSchema createSchemaRef(String schemaName, boolean updateCacheImmediately) throws SQLException { long timeStamp = QueryConstants.UNSET_TIMESTAMP; PSchema theSchema = null; MetaDataClient client = new MetaDataClient(connection); if (updateCacheImmediately) { MetaDataMutationResult result = client.updateCache(schemaName, true); timeStamp = TransactionUtil.getResolvedTimestamp(connection, result); theSchema = result.getSchema(); if (theSchema == null) { throw new SchemaNotFoundException(schemaName, timeStamp); } } else { try { theSchema = connection.getSchema(new PTableKey(null, schemaName)); } catch (SchemaNotFoundException e1) {} // We always attempt to update the cache in the event of a // SchemaNotFoundException if (theSchema == null) { MetaDataMutationResult result = client.updateCache(schemaName, true); if (result.wasUpdated()) { timeStamp = TransactionUtil.getResolvedTimestamp(connection, result); theSchema = result.getSchema(); } } if (theSchema == null) { throw new SchemaNotFoundException(schemaName, timeStamp); } } return theSchema; }
/** * Returns the table if it is found in the connection metadata cache. If the metadata of this * table has changed since it was put in the cache these changes will not necessarily be * reflected in the returned table. If the table is not found, makes a call to the server to * fetch the latest metadata of the table. This is different than how a table is resolved when * it is referenced from a query (a call is made to the server to fetch the latest metadata of the table * depending on the UPDATE_CACHE_FREQUENCY property) * See https://issues.apache.org/jira/browse/PHOENIX-4475 * @param conn * @param name requires a pre-normalized table name or a pre-normalized schema and table name * @return * @throws SQLException */ public static PTable getTable(Connection conn, String name) throws SQLException { PTable table = null; PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class); try { table = pconn.getTable(new PTableKey(pconn.getTenantId(), name)); } catch (TableNotFoundException e) { String schemaName = SchemaUtil.getSchemaNameFromFullName(name); String tableName = SchemaUtil.getTableNameFromFullName(name); MetaDataMutationResult result = new MetaDataClient(pconn).updateCache(schemaName, tableName); if (result.getMutationCode() != MutationCode.TABLE_ALREADY_EXISTS) { throw e; } table = result.getTable(); } return table; }
MetaDataMutationResult result = client.updateCache(dataTable.getTenantId(), dataTable.getSchemaName() .getString(), dataTable.getTableName().getString(), true); long timestamp = TransactionUtil.getResolvedTime(connection, result);
alwaysHitServer = true; MetaDataMutationResult result = client.updateCache(tenantId, schemaName, tableName, alwaysHitServer); timeStamp = TransactionUtil.getResolvedTimestamp(connection, result); theTable = result.getTable(); MetaDataMutationResult result = client.updateCache(schemaName, tableName); if (result.wasUpdated()) { timeStamp = TransactionUtil.getResolvedTimestamp(connection, result);
MetaDataMutationResult result = client.updateCache(table.getSchemaName().getString(), table.getTableName() .getString()); PTable resolvedTable = result.getTable();
String schemaName = SchemaUtil.getSchemaNameFromFullName(parentName); String tableName = SchemaUtil.getTableNameFromFullName(parentName); MetaDataMutationResult parentResult = updateCache(connection.getTenantId(), schemaName, tableName, false, resolvedTimestamp); PTable parentTable = parentResult.getTable(); if (parentTable == null) {
MetaDataMutationResult result = updateCache(tableName.getSchemaName(), tableName.getTableName()); if (result.getMutationCode()==MutationCode.TABLE_ALREADY_EXISTS) { table = result.getTable();