Skip to content

Commit

Permalink
PHOENIX-5359: Remove (Global-Indexing)new coprocessors in CQSI#addCop…
Browse files Browse the repository at this point in the history
…rocessors with flag(INDEX_REGION_OBSERVER_ENABLED_ATTRIB) disabled (#522)
  • Loading branch information
swaroopak committed Jun 26, 2019
1 parent 33d6b34 commit c4d75dd
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -906,12 +906,14 @@ private void addCoprocessors(byte[] tableName, TableDescriptorBuilder builder, P
TransactionFactory.Provider provider = getTransactionProvider(tableProps); TransactionFactory.Provider provider = getTransactionProvider(tableProps);
boolean isTransactional = (provider != null); boolean isTransactional = (provider != null);


boolean globalIndexerEnabled = config.getBoolean( boolean indexRegionObserverEnabled = config.getBoolean(
QueryServices.INDEX_REGION_OBSERVER_ENABLED_ATTRIB, QueryServices.INDEX_REGION_OBSERVER_ENABLED_ATTRIB,
QueryServicesOptions.DEFAULT_INDEX_REGION_OBSERVER_ENABLED); QueryServicesOptions.DEFAULT_INDEX_REGION_OBSERVER_ENABLED);


if (tableType == PTableType.INDEX && !isTransactional) { if (tableType == PTableType.INDEX && !isTransactional) {
if (globalIndexerEnabled && !newDesc.hasCoprocessor(GlobalIndexChecker.class.getName())) { if (!indexRegionObserverEnabled && newDesc.hasCoprocessor(GlobalIndexChecker.class.getName())) {
builder.removeCoprocessor(GlobalIndexChecker.class.getName());
} else if (indexRegionObserverEnabled && !newDesc.hasCoprocessor(GlobalIndexChecker.class.getName())) {
builder.addCoprocessor(GlobalIndexChecker.class.getName(), null, priority - 1, null); builder.addCoprocessor(GlobalIndexChecker.class.getName(), null, priority - 1, null);
} }
} }
Expand Down Expand Up @@ -952,14 +954,19 @@ private void addCoprocessors(byte[] tableName, TableDescriptorBuilder builder, P
if (newDesc.hasCoprocessor(PhoenixTransactionalIndexer.class.getName())) { if (newDesc.hasCoprocessor(PhoenixTransactionalIndexer.class.getName())) {
builder.removeCoprocessor(PhoenixTransactionalIndexer.class.getName()); builder.removeCoprocessor(PhoenixTransactionalIndexer.class.getName());
} }
if (globalIndexerEnabled) { if (indexRegionObserverEnabled) {
if (newDesc.hasCoprocessor(Indexer.class.getName())) {
builder.removeCoprocessor(Indexer.class.getName());
}
if (!newDesc.hasCoprocessor(IndexRegionObserver.class.getName())) { if (!newDesc.hasCoprocessor(IndexRegionObserver.class.getName())) {
Map<String, String> opts = Maps.newHashMapWithExpectedSize(1); Map<String, String> opts = Maps.newHashMapWithExpectedSize(1);
opts.put(NonTxIndexBuilder.CODEC_CLASS_NAME_KEY, PhoenixIndexCodec.class.getName()); opts.put(NonTxIndexBuilder.CODEC_CLASS_NAME_KEY, PhoenixIndexCodec.class.getName());
IndexRegionObserver.enableIndexing(builder, PhoenixIndexBuilder.class, opts, priority); IndexRegionObserver.enableIndexing(builder, PhoenixIndexBuilder.class, opts, priority);
} }

} else { } else {
if (newDesc.hasCoprocessor(IndexRegionObserver.class.getName())) {
builder.removeCoprocessor(IndexRegionObserver.class.getName());
}
if (!newDesc.hasCoprocessor(Indexer.class.getName())) { if (!newDesc.hasCoprocessor(Indexer.class.getName())) {
Map<String, String> opts = Maps.newHashMapWithExpectedSize(1); Map<String, String> opts = Maps.newHashMapWithExpectedSize(1);
opts.put(NonTxIndexBuilder.CODEC_CLASS_NAME_KEY, PhoenixIndexCodec.class.getName()); opts.put(NonTxIndexBuilder.CODEC_CLASS_NAME_KEY, PhoenixIndexCodec.class.getName());
Expand Down

0 comments on commit c4d75dd

Please sign in to comment.