for (HTableInterfaceReference ref : refs) {
// Disable the index by using the updateIndexState method of MetaDataProtocol end point coprocessor.
String indexTableName = ref.getTableName();
byte[] indexTableKey = SchemaUtil.getTableKeyFromFullName(indexTableName);
HTableInterface systemTable = env.getTable(PhoenixDatabaseMetaData.TYPE_TABLE_NAME_BYTES);
MetaDataProtocol mdProxy = systemTable.coprocessorProxy(MetaDataProtocol.class, indexTableKey);
// Mimic the Put that gets generated by the client on an update of the index state
Put put = new Put(indexTableKey);
put.add(PhoenixDatabaseMetaData.TABLE_FAMILY_BYTES, PhoenixDatabaseMetaData.INDEX_STATE_BYTES, PIndexState.DISABLE.getSerializedBytes());
List<Mutation> tableMetadata = Collections.<Mutation>singletonList(put);
MetaDataMutationResult result = mdProxy.updateIndexState(tableMetadata);
if (result.getMutationCode() != MutationCode.TABLE_ALREADY_EXISTS) {
LOG.warn("Attempt to disable index " + indexTableName + " failed with code = " + result.getMutationCode() + ". Will use default failure policy instead.");
super.handleFailure(attempted, cause);
}
LOG.info("Successfully disabled index " + indexTableName);