Java Code Examples for org.apache.hadoop.hbase.client.RegionInfo#toDelimitedByteArray()
The following examples show how to use
org.apache.hadoop.hbase.client.RegionInfo#toDelimitedByteArray() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestSerialization.java From hbase with Apache License 2.0 | 6 votes |
/** * Test RegionInfo serialization * @throws Exception */ @Test public void testRegionInfo() throws Exception { RegionInfo hri = createRandomRegion("testRegionInfo"); // test toByteArray() byte[] hrib = RegionInfo.toByteArray(hri); RegionInfo deserializedHri = RegionInfo.parseFrom(hrib); assertEquals(hri.getEncodedName(), deserializedHri.getEncodedName()); assertEquals(hri, deserializedHri); // test toDelimitedByteArray() hrib = RegionInfo.toDelimitedByteArray(hri); DataInputBuffer buf = new DataInputBuffer(); try { buf.reset(hrib, hrib.length); deserializedHri = RegionInfo.parseFrom(buf); assertEquals(hri.getEncodedName(), deserializedHri.getEncodedName()); assertEquals(hri, deserializedHri); } finally { buf.close(); } }
Example 2
Source File: BackupUtils.java From hbase with Apache License 2.0 | 5 votes |
/** * Write the .regioninfo file on-disk. */ public static void writeRegioninfoOnFilesystem(final Configuration conf, final FileSystem fs, final Path regionInfoDir, RegionInfo regionInfo) throws IOException { final byte[] content = RegionInfo.toDelimitedByteArray(regionInfo); Path regionInfoFile = new Path(regionInfoDir, "." + HConstants.REGIONINFO_QUALIFIER_STR); // First check to get the permissions FsPermission perms = CommonFSUtils.getFilePermissions(fs, conf, HConstants.DATA_FILE_UMASK_KEY); // Write the RegionInfo file content FSDataOutputStream out = FSUtils.create(conf, fs, regionInfoFile, perms, null); try { out.write(content); } finally { out.close(); } }
Example 3
Source File: TestSerialization.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testRegionInfos() throws Exception { RegionInfo hri = createRandomRegion("testRegionInfos"); byte[] triple = RegionInfo.toDelimitedByteArray(hri, hri, hri); List<RegionInfo> regions = RegionInfo.parseDelimitedFrom(triple, 0, triple.length); assertTrue(regions.size() == 3); assertTrue(regions.get(0).equals(regions.get(1))); assertTrue(regions.get(0).equals(regions.get(2))); }
Example 4
Source File: TestFsRegionsMetaRecoverer.java From hbase-operator-tools with Apache License 2.0 | 4 votes |
private TestInputStreamSeekable(RegionInfo info) throws Exception { byte[] bytes = RegionInfo.toDelimitedByteArray(info); this.length = bytes.length; this.in = new ByteArrayInputStream(bytes); }
Example 5
Source File: HRegionFileSystem.java From hbase with Apache License 2.0 | 2 votes |
/** * @param hri * @return Content of the file we write out to the filesystem under a region * @throws IOException */ private static byte[] getRegionInfoFileContent(final RegionInfo hri) throws IOException { return RegionInfo.toDelimitedByteArray(hri); }