HBASE-24981 Enable table replication fails from 1.x to 2.x if table already exist at peer

Closes #2353

Signed-off-by: stack <stack@apache.org>
Signed-off-by: Viraj Jasani <vjasani@apache.org>
Signed-off-by: Pankaj Kumar <pankajkumar@apache.org>
This commit is contained in:
Sanjeet Nishad 2020-10-01 13:24:31 +05:30 committed by Viraj Jasani
parent dedb630da0
commit 219b7afd9e
No known key found for this signature in database
GPG Key ID: B3D6C0B41C8ADFD5
2 changed files with 31 additions and 5 deletions

View File

@ -294,11 +294,6 @@ public class ColumnFamilyDescriptorBuilder {
DEFAULT_VALUES.put(BLOCKCACHE, String.valueOf(DEFAULT_BLOCKCACHE));
DEFAULT_VALUES.put(KEEP_DELETED_CELLS, String.valueOf(DEFAULT_KEEP_DELETED));
DEFAULT_VALUES.put(DATA_BLOCK_ENCODING, String.valueOf(DEFAULT_DATA_BLOCK_ENCODING));
DEFAULT_VALUES.put(CACHE_DATA_ON_WRITE, String.valueOf(DEFAULT_CACHE_DATA_ON_WRITE));
DEFAULT_VALUES.put(CACHE_INDEX_ON_WRITE, String.valueOf(DEFAULT_CACHE_INDEX_ON_WRITE));
DEFAULT_VALUES.put(CACHE_BLOOMS_ON_WRITE, String.valueOf(DEFAULT_CACHE_BLOOMS_ON_WRITE));
DEFAULT_VALUES.put(EVICT_BLOCKS_ON_CLOSE, String.valueOf(DEFAULT_EVICT_BLOCKS_ON_CLOSE));
DEFAULT_VALUES.put(PREFETCH_BLOCKS_ON_OPEN, String.valueOf(DEFAULT_PREFETCH_BLOCKS_ON_OPEN));
// Do NOT add this key/value by default. NEW_VERSION_BEHAVIOR is NOT defined in hbase1 so
// it is not possible to make an hbase1 HCD the same as an hbase2 HCD and so the replication
// compare of schemas will fail. It is OK not adding the below to the initial map because of

View File

@ -41,6 +41,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.rules.ExpectedException;
import java.util.Map;
@Category({MiscTests.class, SmallTests.class})
public class TestColumnFamilyDescriptorBuilder {
@ -193,4 +194,34 @@ public class TestColumnFamilyDescriptorBuilder {
builder.setTimeToLive(ttl);
Assert.assertEquals(43282800, builder.build().getTimeToLive());
}
/**
* Test for verifying the ColumnFamilyDescriptorBuilder's default values so that backward
* compatibility with hbase-1.x can be mantained (see HBASE-24981).
*/
@Test
public void testDefaultBuilder() {
final Map<String, String> defaultValueMap = ColumnFamilyDescriptorBuilder.getDefaultValues();
assertEquals(defaultValueMap.size(), 11);
assertEquals(defaultValueMap.get(ColumnFamilyDescriptorBuilder.BLOOMFILTER),
BloomType.ROW.toString());
assertEquals(defaultValueMap.get(ColumnFamilyDescriptorBuilder.REPLICATION_SCOPE), "0");
assertEquals(defaultValueMap.get(ColumnFamilyDescriptorBuilder.MAX_VERSIONS), "1");
assertEquals(defaultValueMap.get(ColumnFamilyDescriptorBuilder.MIN_VERSIONS), "0");
assertEquals(defaultValueMap.get(ColumnFamilyDescriptorBuilder.COMPRESSION),
Compression.Algorithm.NONE.toString());
assertEquals(defaultValueMap.get(ColumnFamilyDescriptorBuilder.TTL),
Integer.toString(Integer.MAX_VALUE));
assertEquals(defaultValueMap.get(ColumnFamilyDescriptorBuilder.BLOCKSIZE),
Integer.toString(64 * 1024));
assertEquals(defaultValueMap.get(ColumnFamilyDescriptorBuilder.IN_MEMORY),
Boolean.toString(false));
assertEquals(defaultValueMap.get(ColumnFamilyDescriptorBuilder.BLOCKCACHE),
Boolean.toString(true));
assertEquals(defaultValueMap.get(ColumnFamilyDescriptorBuilder.KEEP_DELETED_CELLS),
KeepDeletedCells.FALSE.toString());
assertEquals(defaultValueMap.get(ColumnFamilyDescriptorBuilder.DATA_BLOCK_ENCODING),
DataBlockEncoding.NONE.toString());
}
}