HBASE-22752 Removed the deprecated ImmutableHColumnDescriptor and ImmutableHTableDescriptor (#419)

Signed-off-by: Peter Somogyi <psomogyi@apache.org>
Signed-off-by: stack <stack@apache.org>
This commit is contained in:
Jan Hentschel 2019-07-30 12:32:10 +02:00 committed by Peter Somogyi
parent e3a54e7035
commit f9fd5b65fa
5 changed files with 0 additions and 351 deletions

View File

@ -1,47 +0,0 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.hbase.client;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor;
/**
* Read-only column descriptor.
*/
@Deprecated // deprecated for hbase 2.0, remove for hbase 3.0. see HColumnDescriptor.
@InterfaceAudience.Private
public class ImmutableHColumnDescriptor extends HColumnDescriptor {
/*
* Create an unmodifyable copy of an HColumnDescriptor
* @param desc
*/
ImmutableHColumnDescriptor(final HColumnDescriptor desc) {
super(desc, false);
}
public ImmutableHColumnDescriptor(final ColumnFamilyDescriptor desc) {
super(desc instanceof ModifyableColumnFamilyDescriptor ?
(ModifyableColumnFamilyDescriptor) desc : new ModifyableColumnFamilyDescriptor(desc));
}
@Override
protected ModifyableColumnFamilyDescriptor getDelegateeForModification() {
throw new UnsupportedOperationException("HColumnDescriptor is read-only");
}
}

View File

@ -1,60 +0,0 @@
/**
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.hbase.client;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.client.TableDescriptorBuilder.ModifyableTableDescriptor;
import org.apache.yetus.audience.InterfaceAudience;
/**
* Read-only table descriptor.
*/
@Deprecated // deprecated for hbase 2.0, remove for hbase 3.0. see HTableDescriptor.
@InterfaceAudience.Private
public class ImmutableHTableDescriptor extends HTableDescriptor {
@Override
protected HColumnDescriptor toHColumnDescriptor(ColumnFamilyDescriptor desc) {
if (desc == null) {
return null;
} else if (desc instanceof HColumnDescriptor) {
return new ImmutableHColumnDescriptor((HColumnDescriptor) desc);
} else {
return new ImmutableHColumnDescriptor(desc);
}
}
/*
* Create an unmodifyable copy of an HTableDescriptor
* @param desc
*/
public ImmutableHTableDescriptor(final HTableDescriptor desc) {
super(desc, false);
}
public ImmutableHTableDescriptor(final TableDescriptor desc) {
super(desc instanceof ModifyableTableDescriptor ?
(ModifyableTableDescriptor) desc : new ModifyableTableDescriptor(desc.getTableName(), desc));
}
@Override
protected ModifyableTableDescriptor getDelegateeForModification() {
throw new UnsupportedOperationException("HTableDescriptor is read-only");
}
}

View File

@ -1,103 +0,0 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.hbase.client;
import static org.junit.Assert.fail;
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.KeepDeletedCells;
import org.apache.hadoop.hbase.MemoryCompactionPolicy;
import org.apache.hadoop.hbase.io.compress.Compression;
import org.apache.hadoop.hbase.io.encoding.DataBlockEncoding;
import org.apache.hadoop.hbase.regionserver.BloomType;
import org.apache.hadoop.hbase.testclassification.ClientTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.BuilderStyleTest;
import org.apache.hadoop.hbase.util.Bytes;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.rules.TestName;
@Category({ClientTests.class, SmallTests.class})
public class TestImmutableHColumnDescriptor {
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestImmutableHColumnDescriptor.class);
@Rule
public TestName name = new TestName();
private static final List<Consumer<ImmutableHColumnDescriptor>> TEST_FUNCTION = Arrays.asList(
hcd -> hcd.setValue("a", "a"),
hcd -> hcd.setValue(Bytes.toBytes("a"), Bytes.toBytes("a")),
hcd -> hcd.setConfiguration("aaa", "ccc"),
hcd -> hcd.remove(Bytes.toBytes("aaa")),
hcd -> hcd.removeConfiguration("xxx"),
hcd -> hcd.setBlockCacheEnabled(false),
hcd -> hcd.setBlocksize(10),
hcd -> hcd.setBloomFilterType(BloomType.NONE),
hcd -> hcd.setCacheBloomsOnWrite(false),
hcd -> hcd.setCacheDataOnWrite(true),
hcd -> hcd.setCacheIndexesOnWrite(true),
hcd -> hcd.setCompactionCompressionType(Compression.Algorithm.LZO),
hcd -> hcd.setCompressTags(true),
hcd -> hcd.setCompressionType(Compression.Algorithm.LZO),
hcd -> hcd.setDFSReplication((short) 10),
hcd -> hcd.setDataBlockEncoding(DataBlockEncoding.NONE),
hcd -> hcd.setEncryptionKey(Bytes.toBytes("xxx")),
hcd -> hcd.setEncryptionType("xxx"),
hcd -> hcd.setEvictBlocksOnClose(true),
hcd -> hcd.setInMemory(true),
hcd -> hcd.setInMemoryCompaction(MemoryCompactionPolicy.NONE),
hcd -> hcd.setKeepDeletedCells(KeepDeletedCells.FALSE),
hcd -> hcd.setMaxVersions(1000),
hcd -> hcd.setMinVersions(10),
hcd -> hcd.setMobCompactPartitionPolicy(MobCompactPartitionPolicy.DAILY),
hcd -> hcd.setMobEnabled(true),
hcd -> hcd.setMobThreshold(10),
hcd -> hcd.setPrefetchBlocksOnOpen(true),
hcd -> hcd.setScope(0),
hcd -> hcd.setStoragePolicy("aaa"),
hcd -> hcd.setTimeToLive(100),
hcd -> hcd.setVersions(1, 10)
);
@Test
public void testImmutable() {
ImmutableHColumnDescriptor hcd = new ImmutableHColumnDescriptor(
new HColumnDescriptor(Bytes.toBytes(name.getMethodName())));
for (int i = 0; i != TEST_FUNCTION.size(); ++i) {
try {
TEST_FUNCTION.get(i).accept(hcd);
fail("ImmutableHTableDescriptor can't be modified!!! The index of method is " + i);
} catch (UnsupportedOperationException e) {
}
}
}
@Test
public void testClassMethodsAreBuilderStyle() {
BuilderStyleTest.assertClassesAreBuilderStyle(ImmutableHColumnDescriptor.class);
}
}

View File

@ -1,130 +0,0 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.hbase.client;
import static org.junit.Assert.fail;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.testclassification.ClientTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.BuilderStyleTest;
import org.apache.hadoop.hbase.util.Bytes;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.rules.TestName;
@Category({ClientTests.class, SmallTests.class})
public class TestImmutableHTableDescriptor {
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestImmutableHTableDescriptor.class);
@Rule
public TestName name = new TestName();
private static final List<Consumer<ImmutableHTableDescriptor>> TEST_FUNCTION = Arrays.asList(
htd -> htd.setValue("a", "a"),
htd -> htd.setValue(Bytes.toBytes("a"), Bytes.toBytes("a")),
htd -> htd.setValue(new Bytes(Bytes.toBytes("a")), new Bytes(Bytes.toBytes("a"))),
htd -> htd.setCompactionEnabled(false),
htd -> htd.setConfiguration("aaa", "ccc"),
htd -> htd.setDurability(Durability.USE_DEFAULT),
htd -> htd.setFlushPolicyClassName("class"),
htd -> htd.setMaxFileSize(123),
htd -> htd.setMemStoreFlushSize(123123123),
htd -> htd.setNormalizationEnabled(false),
htd -> htd.setPriority(123),
htd -> htd.setReadOnly(true),
htd -> htd.setRegionMemstoreReplication(true),
htd -> htd.setRegionReplication(123),
htd -> htd.setRegionSplitPolicyClassName("class"),
htd -> htd.addFamily(new HColumnDescriptor(Bytes.toBytes("fm"))),
htd -> htd.remove(new Bytes(Bytes.toBytes("aaa"))),
htd -> htd.remove("aaa"),
htd -> htd.remove(Bytes.toBytes("aaa")),
htd -> htd.removeConfiguration("xxx"),
htd -> htd.removeFamily(Bytes.toBytes("fm")),
htd -> {
try {
htd.addCoprocessor("xxx");
} catch (IOException e) {
throw new RuntimeException(e);
}
}
);
@Test
public void testImmutable() {
HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(name.getMethodName()));
ImmutableHTableDescriptor immutableHtd = new ImmutableHTableDescriptor(htd);
TEST_FUNCTION.forEach(f -> {
try {
f.accept(immutableHtd);
fail("ImmutableHTableDescriptor can't be modified!!!");
} catch (UnsupportedOperationException e) {
}
});
}
@Test
public void testImmutableHColumnDescriptor() {
HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(name.getMethodName()));
htd.addFamily(new HColumnDescriptor(Bytes.toBytes("family")));
ImmutableHTableDescriptor immutableHtd = new ImmutableHTableDescriptor(htd);
for (HColumnDescriptor hcd : immutableHtd.getColumnFamilies()) {
assertReadOnly(hcd);
}
for (HColumnDescriptor hcd : immutableHtd.getFamilies()) {
assertReadOnly(hcd);
}
}
private void assertReadOnly(HColumnDescriptor hcd) {
try {
hcd.setBlocksize(10);
fail("ImmutableHColumnDescriptor can't be modified!!!");
} catch (UnsupportedOperationException e) {
}
}
@Test
public void testClassMethodsAreBuilderStyle() {
/* ImmutableHTableDescriptor should have a builder style setup where setXXX/addXXX methods
* can be chainable together:
* . For example:
* ImmutableHTableDescriptor d
* = new ImmutableHTableDescriptor()
* .setFoo(foo)
* .setBar(bar)
* .setBuz(buz)
*
* This test ensures that all methods starting with "set" returns the declaring object
*/
BuilderStyleTest.assertClassesAreBuilderStyle(ImmutableHTableDescriptor.class);
}
}

View File

@ -76,7 +76,6 @@ import org.apache.hadoop.hbase.client.Durability;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Hbck;
import org.apache.hadoop.hbase.client.ImmutableHRegionInfo;
import org.apache.hadoop.hbase.client.ImmutableHTableDescriptor;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.client.RegionInfoBuilder;
@ -497,16 +496,6 @@ public class HBaseTestingUtility extends HBaseZKTestingUtility {
return new Path(fs.getWorkingDirectory(), "test-data");
}
/**
* @return META table descriptor
* @deprecated since 2.0 version and will be removed in 3.0 version.
* use {@link #getMetaTableDescriptorBuilder()}
*/
@Deprecated
public HTableDescriptor getMetaTableDescriptor() {
return new ImmutableHTableDescriptor(getMetaTableDescriptorBuilder().build());
}
/**
* @return META table descriptor
*/