Java Code Examples for org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment#getRegion()

The following examples show how to use org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment#getRegion() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MetaDataEndpointImpl.java    From phoenix with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public MetaDataMutationResult getTable(byte[] tenantId, byte[] schemaName, byte[] tableName, long tableTimeStamp, long clientTimeStamp) throws IOException {
    try {
        byte[] key = SchemaUtil.getTableKey(tenantId, schemaName, tableName);
        
        // get the co-processor environment
        RegionCoprocessorEnvironment env = getEnvironment();
        // TODO: check that key is within region.getStartKey() and region.getEndKey()
        // and return special code to force client to lookup region from meta.
        HRegion region = env.getRegion();
        MetaDataMutationResult result = checkTableKeyInRegion(key, region);
        if (result != null) {
            return result; 
        }
        
        long currentTime = EnvironmentEdgeManager.currentTimeMillis();
        PTable table = doGetTable(key, clientTimeStamp);
        if (table == null) {
            return new MetaDataMutationResult(MutationCode.TABLE_NOT_FOUND, currentTime, null);
        }
        return new MetaDataMutationResult(MutationCode.TABLE_ALREADY_EXISTS, currentTime, table.getTimeStamp() != tableTimeStamp ? table : null);
    } catch (Throwable t) {
        ServerUtil.throwIOException(SchemaUtil.getTableName(schemaName, tableName), t);
        return null; // impossible
    }
}
 
Example 2
Source File: MetaDataEndpointImpl.java    From phoenix with Apache License 2.0 6 votes vote down vote up
private PTable loadTable(RegionCoprocessorEnvironment env, byte[] key,
    ImmutableBytesPtr cacheKey, long clientTimeStamp, long asOfTimeStamp)
    throws IOException, SQLException {
    HRegion region = env.getRegion();
    Cache<ImmutableBytesPtr,PTable> metaDataCache = GlobalCache.getInstance(this.env).getMetaDataCache();
    PTable table = metaDataCache.getIfPresent(cacheKey);
    // We always cache the latest version - fault in if not in cache
    if (table != null || (table = buildTable(key, cacheKey, region, asOfTimeStamp)) != null) {
        return table;
    }
    // if not found then check if newer table already exists and add delete marker for timestamp
    // found
    if (table == null
            && (table = buildDeletedTable(key, cacheKey, region, clientTimeStamp)) != null) {
        return table;
    }
    return null;
}
 
Example 3
Source File: AccessController.java    From hbase with Apache License 2.0 6 votes vote down vote up
@Override
public void postOpen(ObserverContext<RegionCoprocessorEnvironment> c) {
  RegionCoprocessorEnvironment env = c.getEnvironment();
  final Region region = env.getRegion();
  if (region == null) {
    LOG.error("NULL region from RegionCoprocessorEnvironment in postOpen()");
    return;
  }
  if (PermissionStorage.isAclRegion(region)) {
    aclRegion = true;
    try {
      initialize(env);
    } catch (IOException ex) {
      // if we can't obtain permissions, it's better to fail
      // than perform checks incorrectly
      throw new RuntimeException("Failed to initialize permissions cache", ex);
    }
  } else {
    initialized = true;
  }
}
 
Example 4
Source File: AccessController.java    From hbase with Apache License 2.0 6 votes vote down vote up
@Override
public void preOpen(ObserverContext<RegionCoprocessorEnvironment> c)
    throws IOException {
  RegionCoprocessorEnvironment env = c.getEnvironment();
  final Region region = env.getRegion();
  if (region == null) {
    LOG.error("NULL region from RegionCoprocessorEnvironment in preOpen()");
  } else {
    RegionInfo regionInfo = region.getRegionInfo();
    if (regionInfo.getTable().isSystemTable()) {
      checkSystemOrSuperUser(getActiveUser(c));
    } else {
      requirePermission(c, "preOpen", Action.ADMIN);
    }
  }
}
 
Example 5
Source File: AccessController.java    From hbase with Apache License 2.0 5 votes vote down vote up
private TableName getTableName(RegionCoprocessorEnvironment e) {
  Region region = e.getRegion();
  if (region != null) {
    return getTableName(region);
  }
  return null;
}
 
Example 6
Source File: StoreFailuresInCachePolicy.java    From phoenix with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void setup(Stoppable parent, RegionCoprocessorEnvironment env) {
  this.region = env.getRegion();
  this.delegate = new KillServerOnFailurePolicy();
  this.delegate.setup(parent, env);

}
 
Example 7
Source File: StoreFailuresInCachePolicy.java    From phoenix with Apache License 2.0 5 votes vote down vote up
@Override
public void setup(Stoppable parent, RegionCoprocessorEnvironment env) {
  this.region = env.getRegion();
  this.delegate = new KillServerOnFailurePolicy();
  this.delegate.setup(parent, env);

}
 
Example 8
Source File: ExpAsStringVisibilityLabelServiceImpl.java    From hbase with Apache License 2.0 5 votes vote down vote up
@Override
public void init(RegionCoprocessorEnvironment e) throws IOException {
  this.scanLabelGenerators = VisibilityUtils.getScanLabelGenerators(this.conf);
  if (e.getRegion().getRegionInfo().getTable().equals(LABELS_TABLE_NAME)) {
    this.labelsRegion = e.getRegion();
  }
}
 
Example 9
Source File: AccessController.java    From hbase with Apache License 2.0 5 votes vote down vote up
private void initialize(RegionCoprocessorEnvironment e) throws IOException {
  final Region region = e.getRegion();
  Configuration conf = e.getConfiguration();
  Map<byte[], ListMultimap<String, UserPermission>> tables = PermissionStorage.loadAll(region);
  // For each table, write out the table's permissions to the respective
  // znode for that table.
  for (Map.Entry<byte[], ListMultimap<String, UserPermission>> t:
    tables.entrySet()) {
    byte[] entry = t.getKey();
    ListMultimap<String, UserPermission> perms = t.getValue();
    byte[] serialized = PermissionStorage.writePermissionsAsBytes(perms, conf);
    zkPermissionWatcher.writeToZookeeper(entry, serialized);
  }
  initialized = true;
}
 
Example 10
Source File: SIObserver.java    From spliceengine with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void start(CoprocessorEnvironment e) throws IOException {
    try {
        SpliceLogUtils.trace(LOG, "starting %s", SIObserver.class);
        RegionCoprocessorEnvironment rce = (RegionCoprocessorEnvironment) e;
        TableName tableName = rce.getRegion().getTableDescriptor().getTableName();
        doesTableNeedSI(tableName);
        HBaseSIEnvironment env = HBaseSIEnvironment.loadEnvironment(new SystemClock(), ZkUtils.getRecoverableZooKeeper());
        SIDriver driver = env.getSIDriver();
        if (tableEnvMatch) {
            try{
                conglomId=Long.parseLong(tableName.getQualifierAsString());
            }catch(NumberFormatException nfe){
                SpliceLogUtils.warn(LOG,"Unable to parse conglomerate id for table %s",tableName);
                conglomId=-1;
            }
            operationStatusFactory = driver.getOperationStatusLib();
            //noinspection unchecked
            txnOperationFactory = new SimpleTxnOperationFactory(driver.getExceptionFactory(), HOperationFactory.INSTANCE);
            //noinspection unchecked
            Partition regionPartition = new RegionPartition((HRegion) rce.getRegion());
            region = new TxnRegion(regionPartition,
                    driver.getRollForward(),
                    driver.getReadResolver(regionPartition),
                    driver.getTxnSupplier(),
                    driver.getTransactor(),
                    driver.getOperationFactory()
            );
            Tracer.traceRegion(region.getTableName(), rce.getRegion());
        }

        ZKWatcher zk = ((RegionServerServices)((RegionCoprocessorEnvironment)e).getOnlineRegions()).getZooKeeper();
        this.authManager = TableAuthManager.getOrCreate(zk, e.getConfiguration());
        this.authTokenEnabled = driver.getConfiguration().getAuthenticationTokenEnabled();

    } catch (Throwable t) {
        throw CoprocessorUtils.getIOException(t);
    }
}
 
Example 11
Source File: StoreFailuresInCachePolicy.java    From phoenix with Apache License 2.0 5 votes vote down vote up
@Override
public void setup(Stoppable parent, RegionCoprocessorEnvironment env) {
  this.region = env.getRegion();
  this.delegate = new KillServerOnFailurePolicy();
  this.delegate.setup(parent, env);

}
 
Example 12
Source File: AccessController.java    From hbase with Apache License 2.0 4 votes vote down vote up
private Region getRegion(RegionCoprocessorEnvironment e) {
  return e.getRegion();
}
 
Example 13
Source File: IndexUtil.java    From phoenix with Apache License 2.0 4 votes vote down vote up
public static HRegion getDataRegion(RegionCoprocessorEnvironment env) throws IOException {
    HRegion indexRegion = env.getRegion();
    return getDataRegion(indexRegion, env.getRegionServerServices());
}
 
Example 14
Source File: MetaDataEndpointImpl.java    From phoenix with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private PTable doGetTable(byte[] key, long clientTimeStamp) throws IOException, SQLException {
    ImmutableBytesPtr cacheKey = new ImmutableBytesPtr(key);
    Map<ImmutableBytesPtr,PTable> metaDataCache = GlobalCache.getInstance(this.getEnvironment()).getMetaDataCache();
    PTable table = metaDataCache.get(cacheKey);
    // We only cache the latest, so we'll end up building the table with every call if the client connection has specified an SCN.
    // TODO: If we indicate to the client that we're returning an older version, but there's a newer version available, the client
    // can safely not call this, since we only allow modifications to the latest.
    if (table != null && table.getTimeStamp() < clientTimeStamp) {
        // Table on client is up-to-date with table on server, so just return
        if (isTableDeleted(table)) {
            return null;
        }
        return table;
    }
    // Ask Lars about the expense of this call - if we don't take the lock, we still won't get partial results
    // get the co-processor environment
    RegionCoprocessorEnvironment env = getEnvironment();
    // TODO: check that key is within region.getStartKey() and region.getEndKey()
    // and return special code to force client to lookup region from meta.
    HRegion region = env.getRegion();
    /*
     * Lock directly on key, though it may be an index table.
     * This will just prevent a table from getting rebuilt
     * too often.
     */
    Integer lid = region.getLock(null, key, true);
    if (lid == null) {
        throw new IOException("Failed to acquire lock on " + Bytes.toStringBinary(key));
    }
    try {
        // Try cache again in case we were waiting on a lock
        table = metaDataCache.get(cacheKey);
        // We only cache the latest, so we'll end up building the table with every call if the client connection has specified an SCN.
        // TODO: If we indicate to the client that we're returning an older version, but there's a newer version available, the client
        // can safely not call this, since we only allow modifications to the latest.
        if (table != null && table.getTimeStamp() < clientTimeStamp) {
            // Table on client is up-to-date with table on server, so just return
            if (isTableDeleted(table)) {
                return null;
            }
            return table;
        }
        // Query for the latest table first, since it's not cached
        table = buildTable(key, cacheKey, region, HConstants.LATEST_TIMESTAMP);
        if (table != null && table.getTimeStamp() < clientTimeStamp) {
            return table;
        }
        // Otherwise, query for an older version of the table - it won't be cached 
        return buildTable(key, cacheKey, region, clientTimeStamp);
    } finally {
        if (lid != null) region.releaseRowLock(lid);
    }
}
 
Example 15
Source File: SpliceIndexObserver.java    From spliceengine with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void postOpen(ObserverContext<RegionCoprocessorEnvironment> c) {
    RegionCoprocessorEnvironment rce = c.getEnvironment();
    try {
        final long cId = conglomId;
        final RegionPartition baseRegion=new RegionPartition((HRegion)rce.getRegion());
        ServerControl sc = new RegionServerControl((HRegion)rce.getRegion(),(RegionServerServices)rce.getOnlineRegions());
        if(service==null){
            service=new PipelineLoadService<TableName>(sc,baseRegion,cId){
                @Override
                public void start() throws Exception{
                    super.start();
                    PipelineDriver pipelineDriver=PipelineDriver.driver();
                    factoryLoader=pipelineDriver.getContextFactoryLoader(cId);
                    ctxFactory = getWritePipeline().getContextFactory();

                    SIDriver siDriver=SIDriver.driver();

                    region=siDriver.transactionalPartition(cId,baseRegion);
                    operationFactory=siDriver.getOperationFactory();
                    exceptionFactory=pipelineDriver.exceptionFactory();
                }

                @Override
                public void shutdown() throws Exception{
                    if(factoryLoader!=null)
                        factoryLoader.close();
                    super.shutdown();
                }

                @Override
                protected Function<TableName, String> getStringParsingFunction(){
                    return new Function<TableName, String>(){
                        @Nullable
                        @Override
                        public String apply(TableName tableName){
                            return tableName.getNameAsString();
                        }
                    };
                }

                @Override
                protected PipelineEnvironment loadPipelineEnvironment(ContextFactoryDriver cfDriver) throws IOException{
                    return HBasePipelineEnvironment.loadEnvironment(new SystemClock(),cfDriver);
                }
            };
        }
        DatabaseLifecycleManager.manager().registerGeneralService(service);
    } catch (Throwable t) {
        ExceptionUtil.throwAsRuntime(CoprocessorUtils.getIOException(t));
    }
}
 
Example 16
Source File: SpliceIndexEndpoint.java    From spliceengine with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void postOpen(ObserverContext<RegionCoprocessorEnvironment> c) {
    RegionCoprocessorEnvironment rce = c.getEnvironment();
    final ServerControl serverControl=new RegionServerControl((HRegion) rce.getRegion(), (RegionServerServices)rce.getOnlineRegions());

    final long cId = conglomId;
    final RegionPartition baseRegion=new RegionPartition((HRegion)rce.getRegion());
    try{
        service=new PipelineLoadService<TableName>(serverControl,baseRegion,cId){

            @Override
            public void start() throws Exception{
                super.start();
                compressor=getCompressor();
                pipelineWriter=getPipelineWriter();
                writePipeline=getWritePipeline();
            }

            @Override
            public void shutdown() throws Exception{
                super.shutdown();
            }

            @Override
            protected Function<TableName, String> getStringParsingFunction(){
                return new Function<TableName, String>(){
                    @Nullable
                    @Override
                    public String apply(TableName tableName){
                        return tableName.getNameAsString();
                    }
                };
            }

            @Override
            protected PipelineEnvironment loadPipelineEnvironment(ContextFactoryDriver cfDriver) throws IOException{
                return HBasePipelineEnvironment.loadEnvironment(new SystemClock(),cfDriver);
            }
        };
        DatabaseLifecycleManager.manager().registerGeneralService(service);
    }catch(Exception e){
        ExceptionUtil.throwAsRuntime(new IOException(e));
    }
}
 
Example 17
Source File: PhoenixIndexMetaDataBuilder.java    From phoenix with Apache License 2.0 4 votes vote down vote up
private static IndexMetaDataCache getIndexMetaDataCache(RegionCoprocessorEnvironment env, Map<String, byte[]> attributes) throws IOException {
    if (attributes == null) { return IndexMetaDataCache.EMPTY_INDEX_META_DATA_CACHE; }
    byte[] uuid = attributes.get(PhoenixIndexCodec.INDEX_UUID);
    if (uuid == null) { return IndexMetaDataCache.EMPTY_INDEX_META_DATA_CACHE; }
    byte[] md = attributes.get(PhoenixIndexCodec.INDEX_PROTO_MD);
    if (md == null) {
        md = attributes.get(PhoenixIndexCodec.INDEX_MD);
    }
    if (md != null) {
        boolean useProto = md != null;
        byte[] txState = attributes.get(BaseScannerRegionObserver.TX_STATE);
        final List<IndexMaintainer> indexMaintainers = IndexMaintainer.deserialize(md, useProto);
        byte[] clientVersionBytes = attributes.get(BaseScannerRegionObserver.CLIENT_VERSION);
        final int clientVersion = clientVersionBytes == null ? ScanUtil.UNKNOWN_CLIENT_VERSION : Bytes.toInt(clientVersionBytes);
        final PhoenixTransactionContext txnContext = TransactionFactory.getTransactionContext(txState, clientVersion);
        return new IndexMetaDataCache() {

            @Override
            public void close() throws IOException {}

            @Override
            public List<IndexMaintainer> getIndexMaintainers() {
                return indexMaintainers;
            }

            @Override
            public PhoenixTransactionContext getTransactionContext() {
                return txnContext;
            }

            @Override
            public int getClientVersion() {
                return clientVersion;
            }

        };
    } else {
        byte[] tenantIdBytes = attributes.get(PhoenixRuntime.TENANT_ID_ATTRIB);
        ImmutableBytesPtr tenantId = tenantIdBytes == null ? null : new ImmutableBytesPtr(tenantIdBytes);
        TenantCache cache = GlobalCache.getTenantCache(env, tenantId);
        IndexMetaDataCache indexCache = (IndexMetaDataCache)cache.getServerCache(new ImmutableBytesPtr(uuid));
        if (indexCache == null) {
            String msg = "key=" + ServerCacheClient.idToString(uuid) + " region=" + env.getRegion() + "host="
                    + env.getServerName().getServerName();
            SQLException e = new SQLExceptionInfo.Builder(SQLExceptionCode.INDEX_METADATA_NOT_FOUND).setMessage(msg)
                    .build().buildException();
            ServerUtil.throwIOException("Index update failed", e); // will not return
        }
        return indexCache;
    }

}
 
Example 18
Source File: MetaDataEndpointImpl.java    From phoenix with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private MetaDataMutationResult mutateColumn(List<Mutation> tableMetadata, ColumnMutator mutator) throws IOException {
    byte[][] rowKeyMetaData = new byte[5][];
    MetaDataUtil.getTenantIdAndSchemaAndTableName(tableMetadata,rowKeyMetaData);
    byte[] tenantId = rowKeyMetaData[PhoenixDatabaseMetaData.TENANT_ID_INDEX];
    byte[] schemaName = rowKeyMetaData[PhoenixDatabaseMetaData.SCHEMA_NAME_INDEX];
    byte[] tableName = rowKeyMetaData[PhoenixDatabaseMetaData.TABLE_NAME_INDEX];
    try {
        RegionCoprocessorEnvironment env = getEnvironment();
        byte[] key = SchemaUtil.getTableKey(tenantId, schemaName, tableName);
        HRegion region = env.getRegion();
        MetaDataMutationResult result = checkTableKeyInRegion(key, region);
        if (result != null) {
            return result; 
        }
        List<Integer> lids = Lists.newArrayList(5);
        try {
            acquireLock(region, key, lids);
            ImmutableBytesPtr cacheKey = new ImmutableBytesPtr(key);
            List<ImmutableBytesPtr> invalidateList = new ArrayList<ImmutableBytesPtr>();
            invalidateList.add(cacheKey);
            Map<ImmutableBytesPtr,PTable> metaDataCache = GlobalCache.getInstance(this.getEnvironment()).getMetaDataCache();
            PTable table = metaDataCache.get(cacheKey);
            if (logger.isDebugEnabled()) {
                if (table == null) {
                    logger.debug("Table " + Bytes.toStringBinary(key) + " not found in cache. Will build through scan");
                } else {
                    logger.debug("Table " + Bytes.toStringBinary(key) + " found in cache with timestamp " + table.getTimeStamp() + " seqNum " + table.getSequenceNumber());
                }
            }
            // Get client timeStamp from mutations
            long clientTimeStamp = MetaDataUtil.getClientTimeStamp(tableMetadata);
            if (table == null && (table = buildTable(key, cacheKey, region, HConstants.LATEST_TIMESTAMP)) == null) {
                // if not found then call newerTableExists and add delete marker for timestamp found
                if (buildDeletedTable(key, cacheKey, region, clientTimeStamp) != null) {
                    return new MetaDataMutationResult(MutationCode.NEWER_TABLE_FOUND, EnvironmentEdgeManager.currentTimeMillis(), null);
                }
                return new MetaDataMutationResult(MutationCode.TABLE_NOT_FOUND, EnvironmentEdgeManager.currentTimeMillis(), null);
            }
            if (table.getTimeStamp() >= clientTimeStamp) {
                return new MetaDataMutationResult(MutationCode.NEWER_TABLE_FOUND, EnvironmentEdgeManager.currentTimeMillis(), table);
            } else if (isTableDeleted(table)) {
                return new MetaDataMutationResult(MutationCode.TABLE_NOT_FOUND, EnvironmentEdgeManager.currentTimeMillis(), null);
            }
                
            long expectedSeqNum = MetaDataUtil.getSequenceNumber(tableMetadata) - 1; // lookup TABLE_SEQ_NUM in tableMetaData
            if (logger.isDebugEnabled()) {
                logger.debug("For table " + Bytes.toStringBinary(key) + " expecting seqNum " + expectedSeqNum + " and found seqNum " + table.getSequenceNumber() + " with " + table.getColumns().size() + " columns: " + table.getColumns());
            }
            if (expectedSeqNum != table.getSequenceNumber()) {
                if (logger.isDebugEnabled()) {
                    logger.debug("For table " + Bytes.toStringBinary(key) + " returning CONCURRENT_TABLE_MUTATION due to unexpected seqNum");
                }
                return new MetaDataMutationResult(MutationCode.CONCURRENT_TABLE_MUTATION, EnvironmentEdgeManager.currentTimeMillis(), table);
            }
            
            PTableType type = table.getType();
            if (type == PTableType.INDEX) { 
                // Disallow mutation of an index table
                return new MetaDataMutationResult(MutationCode.UNALLOWED_TABLE_MUTATION, EnvironmentEdgeManager.currentTimeMillis(), null);
            } else {
                PTableType expectedType = MetaDataUtil.getTableType(tableMetadata);
                // We said to drop a table, but found a view or visa versa
                if (type != expectedType) {
                    return new MetaDataMutationResult(MutationCode.TABLE_NOT_FOUND, EnvironmentEdgeManager.currentTimeMillis(), null);
                }
                if (hasViews(region, tenantId, table)) {
                    // Disallow any column mutations for parents of tenant tables
                    return new MetaDataMutationResult(MutationCode.UNALLOWED_TABLE_MUTATION, EnvironmentEdgeManager.currentTimeMillis(), null);
                }
            }
            result = mutator.updateMutation(table, rowKeyMetaData, tableMetadata, region, invalidateList, lids);
            if (result != null) {
                return result;
            }
            
            region.mutateRowsWithLocks(tableMetadata, Collections.<byte[]>emptySet());
            // Invalidate from cache
            for (ImmutableBytesPtr invalidateKey : invalidateList) {
                PTable invalidatedTable = metaDataCache.remove(invalidateKey);
                if (logger.isDebugEnabled()) {
                    if (invalidatedTable == null) {
                        logger.debug("Attempted to invalidated table key " + Bytes.toStringBinary(cacheKey.get(),cacheKey.getOffset(),cacheKey.getLength()) + " but found no cached table");
                    } else {
                        logger.debug("Invalidated table key " + Bytes.toStringBinary(cacheKey.get(),cacheKey.getOffset(),cacheKey.getLength()) + " with timestamp " + invalidatedTable.getTimeStamp() + " and seqNum " + invalidatedTable.getSequenceNumber());
                    }
                }
            }
            // Get client timeStamp from mutations, since it may get updated by the mutateRowsWithLocks call
            long currentTime = MetaDataUtil.getClientTimeStamp(tableMetadata);
            return new MetaDataMutationResult(MutationCode.TABLE_ALREADY_EXISTS, currentTime, null);
        } finally {
            releaseLocks(region,lids);
        }
    } catch (Throwable t) {
        ServerUtil.throwIOException(SchemaUtil.getTableName(schemaName, tableName), t);
        return null; // impossible
    }
}
 
Example 19
Source File: MetaDataEndpointImpl.java    From phoenix with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private PTable loadTable(RegionCoprocessorEnvironment env, byte[] key, ImmutableBytesPtr cacheKey, long clientTimeStamp, long asOfTimeStamp) throws IOException, SQLException {
    HRegion region = env.getRegion();
    Map<ImmutableBytesPtr,PTable> metaDataCache = GlobalCache.getInstance(this.getEnvironment()).getMetaDataCache();
    PTable table = metaDataCache.get(cacheKey);
    // We always cache the latest version - fault in if not in cache
    if (table != null || (table = buildTable(key, cacheKey, region, asOfTimeStamp)) != null) {
        return table;
    }
    // if not found then check if newer table already exists and add delete marker for timestamp found
    if (table == null && (table=buildDeletedTable(key, cacheKey, region, clientTimeStamp)) != null) {
        return table;
    }
    return null;
}
 
Example 20
Source File: HBaseShims.java    From phoenix-omid with Apache License 2.0 2 votes vote down vote up
static public Region getRegionCoprocessorRegion(RegionCoprocessorEnvironment env) {

        return env.getRegion();

    }