/** * Enable constraints on a table. * <p> * Currently, if you attempt to add a constraint to the table, then * Constraints will automatically be turned on. * * @param desc * table description to add the processor * @throws IOException * If the {@link ConstraintProcessor} CP couldn't be added to the * table. */ public static void enable(HTableDescriptor desc) throws IOException { // if the CP has already been loaded, do nothing String clazz = ConstraintProcessor.class.getName(); if (desc.hasCoprocessor(clazz)) { return; } // add the constrain processor CP to the table desc.addCoprocessor(clazz); }
hbaseAdmin.disableTable(TableName.valueOf(tableName)); while (desc.hasCoprocessor(CubeObserverClassOld2)) { desc.removeCoprocessor(CubeObserverClassOld2); while (desc.hasCoprocessor(CubeEndpointClass)) { desc.removeCoprocessor(CubeEndpointClass); while (desc.hasCoprocessor(IIEndpointClass)) { desc.removeCoprocessor(IIEndpointClass); while (desc.hasCoprocessor(CubeObserverClassOld)) { desc.removeCoprocessor(CubeObserverClassOld); while (desc.hasCoprocessor(IIEndpointClassOld)) { desc.removeCoprocessor(IIEndpointClassOld);
/** * Test cps in the table description * @throws Exception */ @Test public void testGetSetRemoveCP() throws Exception { HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(name.getMethodName())); // simple CP String className = "org.apache.hadoop.hbase.coprocessor.SimpleRegionObserver"; // add and check that it is present desc.addCoprocessor(className); assertTrue(desc.hasCoprocessor(className)); // remove it and check that it is gone desc.removeCoprocessor(className); assertFalse(desc.hasCoprocessor(className)); }
/** * Test that Constraints are properly enabled, disabled, and removed * * @throws Exception */ @SuppressWarnings("unchecked") @Test public void testEnableDisableRemove() throws Exception { HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(name.getMethodName())); // check general enabling/disabling of constraints // first add a constraint Constraints.add(desc, AllPassConstraint.class); // make sure everything is enabled assertTrue(Constraints.enabled(desc, AllPassConstraint.class)); assertTrue(desc.hasCoprocessor(ConstraintProcessor.class.getName())); // check disabling Constraints.disable(desc); assertFalse(desc.hasCoprocessor(ConstraintProcessor.class.getName())); // make sure the added constraints are still present assertTrue(Constraints.enabled(desc, AllPassConstraint.class)); // check just removing the single constraint Constraints.remove(desc, AllPassConstraint.class); assertFalse(Constraints.has(desc, AllPassConstraint.class)); // Add back the single constraint Constraints.add(desc, AllPassConstraint.class); // and now check that when we remove constraints, all are gone Constraints.remove(desc); assertFalse(desc.hasCoprocessor(ConstraintProcessor.class.getName())); assertFalse(Constraints.has(desc, AllPassConstraint.class)); }
public static void resetCoprocessor(String tableName, HBaseAdmin hbaseAdmin, Path hdfsCoprocessorJar) throws IOException { logger.info("Disable " + tableName); hbaseAdmin.disableTable(tableName); logger.info("Unset coprocessor on " + tableName); HTableDescriptor desc = hbaseAdmin.getTableDescriptor(TableName.valueOf(tableName)); while (desc.hasCoprocessor(OBSERVER_CLS_NAME)) { desc.removeCoprocessor(OBSERVER_CLS_NAME); } while (desc.hasCoprocessor(ENDPOINT_CLS_NAMAE)) { desc.removeCoprocessor(ENDPOINT_CLS_NAMAE); } addCoprocessorOnHTable(desc, hdfsCoprocessorJar); hbaseAdmin.modifyTable(tableName, desc); logger.info("Enable " + tableName); hbaseAdmin.enableTable(tableName); }
if (!descriptor.hasCoprocessor(ScanRegionObserver.class.getName())) { descriptor.addCoprocessor(ScanRegionObserver.class.getName(), null, 1, null); if (!descriptor.hasCoprocessor(UngroupedAggregateRegionObserver.class.getName())) { descriptor.addCoprocessor(UngroupedAggregateRegionObserver.class.getName(), null, 1, null); if (!descriptor.hasCoprocessor(GroupedAggregateRegionObserver.class.getName())) { descriptor.addCoprocessor(GroupedAggregateRegionObserver.class.getName(), null, 1, null); if (!descriptor.hasCoprocessor(ServerCachingEndpointImpl.class.getName())) { descriptor.addCoprocessor(ServerCachingEndpointImpl.class.getName(), null, 1, null); if (tableType != PTableType.INDEX && !descriptor.hasCoprocessor(Indexer.class.getName()) && !SchemaUtil.isMetaTable(tableName) && !SchemaUtil.isSequenceTable(tableName)) { Map<String, String> opts = Maps.newHashMapWithExpectedSize(1); descriptor.setValue(SchemaUtil.UPGRADE_TO_2_1, Boolean.TRUE.toString()); descriptor.setValue(SchemaUtil.UPGRADE_TO_3_0, Boolean.TRUE.toString()); if (!descriptor.hasCoprocessor(MetaDataEndpointImpl.class.getName())) { descriptor.addCoprocessor(MetaDataEndpointImpl.class.getName(), null, 1, null); if (!descriptor.hasCoprocessor(MetaDataRegionObserver.class.getName())) { descriptor.addCoprocessor(MetaDataRegionObserver.class.getName(), null, 2, null); if (!descriptor.hasCoprocessor(SequenceRegionObserver.class.getName())) { descriptor.addCoprocessor(SequenceRegionObserver.class.getName(), null, 1, null);
/** * Test cps in the table description * @throws Exception */ @Test public void testGetSetRemoveCP() throws Exception { HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(name.getMethodName())); // simple CP String className = "org.apache.hadoop.hbase.coprocessor.SimpleRegionObserver"; // add and check that it is present desc.addCoprocessor(className); assertTrue(desc.hasCoprocessor(className)); // remove it and check that it is gone desc.removeCoprocessor(className); assertFalse(desc.hasCoprocessor(className)); }
@Override protected boolean isTransactionalTable(HTableDescriptor tableDescriptor) { return tableDescriptor.hasCoprocessor(DefaultTransactionProcessor.class.getName()) || tableDescriptor.hasCoprocessor(MessageTableRegionObserver.class.getName()); } }
@Override protected boolean isTransactionalTable(HTableDescriptor tableDescriptor) { return tableDescriptor.hasCoprocessor(DefaultTransactionProcessor.class.getName()) || tableDescriptor.hasCoprocessor(MessageTableRegionObserver.class.getName()); } }
@Override protected boolean isTransactionalTable(HTableDescriptor tableDescriptor) { return tableDescriptor.hasCoprocessor(DefaultTransactionProcessor.class.getName()) || tableDescriptor.hasCoprocessor(MessageTableRegionObserver.class.getName()); } }
/** * Returns whether the table is a transactional table. By default, it is a table is identified as a transactional * table if it has a the coprocessor {@link TransactionProcessor} attached to it. Should be overriden if the users * attach a different coprocessor. * * @param tableDescriptor {@link HTableDescriptor} of the table * @return true if the table is transactional */ protected boolean isTransactionalTable(HTableDescriptor tableDescriptor) { return tableDescriptor.hasCoprocessor(TransactionProcessor.class.getName()); }
private void checkHasCoprocessor(final String className) throws IOException { if (hasCoprocessor(className)) { throw new IOException("Coprocessor " + className + " already exists."); } }
@Override protected boolean isTransactionalTable(HTableDescriptor tableDescriptor) { return tableDescriptor.hasCoprocessor(DefaultTransactionProcessor.class.getName()) || tableDescriptor.hasCoprocessor(MessageTableRegionObserver.class.getName()); } }
@Override protected boolean isTransactionalTable(HTableDescriptor tableDescriptor) { return tableDescriptor.hasCoprocessor(DefaultTransactionProcessor.class.getName()) || tableDescriptor.hasCoprocessor(MessageTableRegionObserver.class.getName()); } }
@Override protected boolean isTransactionalTable(HTableDescriptor tableDescriptor) { return tableDescriptor.hasCoprocessor(DefaultTransactionProcessor.class.getName()) || tableDescriptor.hasCoprocessor(MessageTableRegionObserver.class.getName()); } }
/** * Returns whether the table is a transactional table. By default, it is a table is identified as a transactional * table if it has a the coprocessor {@link TransactionProcessor} attached to it. Should be overriden if the users * attach a different coprocessor. * * @param tableDescriptor {@link HTableDescriptor} of the table * @return true if the table is transactional */ protected boolean isTransactionalTable(HTableDescriptor tableDescriptor) { return tableDescriptor.hasCoprocessor(TransactionProcessor.class.getName()); }
/** * Returns whether the table is a transactional table. By default, it is a table is identified as a transactional * table if it has a the coprocessor {@link TransactionProcessor} attached to it. Should be overriden if the users * attach a different coprocessor. * * @param tableDescriptor {@link HTableDescriptor} of the table * @return true if the table is transactional */ protected boolean isTransactionalTable(HTableDescriptor tableDescriptor) { return tableDescriptor.hasCoprocessor(TransactionProcessor.class.getName()); }
/** * Returns whether the table is a transactional table. By default, it is a table is identified as a transactional * table if it has a the coprocessor {@link TransactionProcessor} attached to it. Should be overriden if the users * attach a different coprocessor. * * @param tableDescriptor {@link HTableDescriptor} of the table * @return true if the table is transactional */ protected boolean isTransactionalTable(HTableDescriptor tableDescriptor) { return tableDescriptor.hasCoprocessor(TransactionProcessor.class.getName()); }
/** * Returns whether the table is a transactional table. By default, it is a table is identified as a transactional * table if it has a the coprocessor {@link TransactionProcessor} attached to it. Should be overriden if the users * attach a different coprocessor. * * @param tableDescriptor {@link HTableDescriptor} of the table * @return true if the table is transactional */ protected boolean isTransactionalTable(HTableDescriptor tableDescriptor) { return tableDescriptor.hasCoprocessor(TransactionProcessor.class.getName()); }
assertFalse(cdC.getKeepDeletedCells()); assertFalse(SchemaUtil.DEFAULT_DATA_BLOCK_ENCODING == cdC.getDataBlockEncoding()); assertTrue(descriptor.hasCoprocessor(UngroupedAggregateRegionObserver.class.getName())); assertTrue(descriptor.hasCoprocessor(GroupedAggregateRegionObserver.class.getName())); assertTrue(descriptor.hasCoprocessor(ServerCachingEndpointImpl.class.getName())); admin.close();