|
21 | 21 | import java.util.regex.Matcher; |
22 | 22 | import java.util.regex.Pattern; |
23 | 23 | import org.apache.hadoop.conf.Configuration; |
24 | | -import org.apache.hadoop.fs.FileSystem; |
25 | 24 | import org.apache.hadoop.fs.Path; |
26 | 25 | import org.apache.hadoop.hbase.HConstants; |
27 | 26 | import org.apache.hadoop.hbase.TableName; |
@@ -290,175 +289,6 @@ public static String createHFileLinkName(final TableName tableName, final String |
290 | 289 | return s; |
291 | 290 | } |
292 | 291 |
|
293 | | - /** |
294 | | - * Create a new HFileLink |
295 | | - * <p> |
296 | | - * It also adds a back-reference to the hfile back-reference directory to simplify the |
297 | | - * reference-count and the cleaning process. |
298 | | - * @param conf {@link Configuration} to read for the archive directory name |
299 | | - * @param fs {@link FileSystem} on which to write the HFileLink |
300 | | - * @param dstFamilyPath - Destination path (table/region/cf/) |
301 | | - * @param hfileRegionInfo - Linked HFile Region Info |
302 | | - * @param hfileName - Linked HFile name |
303 | | - * @return the file link name. |
304 | | - * @throws IOException on file or parent directory creation failure. |
305 | | - */ |
306 | | - public static String create(final Configuration conf, final FileSystem fs, |
307 | | - final Path dstFamilyPath, final RegionInfo hfileRegionInfo, final String hfileName) |
308 | | - throws IOException { |
309 | | - return create(conf, fs, dstFamilyPath, hfileRegionInfo, hfileName, true); |
310 | | - } |
311 | | - |
312 | | - /** |
313 | | - * Create a new HFileLink |
314 | | - * <p> |
315 | | - * It also adds a back-reference to the hfile back-reference directory to simplify the |
316 | | - * reference-count and the cleaning process. |
317 | | - * @param conf {@link Configuration} to read for the archive directory name |
318 | | - * @param fs {@link FileSystem} on which to write the HFileLink |
319 | | - * @param dstFamilyPath - Destination path (table/region/cf/) |
320 | | - * @param hfileRegionInfo - Linked HFile Region Info |
321 | | - * @param hfileName - Linked HFile name |
322 | | - * @param createBackRef - Whether back reference should be created. Defaults to true. |
323 | | - * @return the file link name. |
324 | | - * @throws IOException on file or parent directory creation failure. |
325 | | - */ |
326 | | - public static String create(final Configuration conf, final FileSystem fs, |
327 | | - final Path dstFamilyPath, final RegionInfo hfileRegionInfo, final String hfileName, |
328 | | - final boolean createBackRef) throws IOException { |
329 | | - TableName linkedTable = hfileRegionInfo.getTable(); |
330 | | - String linkedRegion = hfileRegionInfo.getEncodedName(); |
331 | | - return create(conf, fs, dstFamilyPath, linkedTable, linkedRegion, hfileName, createBackRef); |
332 | | - } |
333 | | - |
334 | | - /** |
335 | | - * Create a new HFileLink |
336 | | - * <p> |
337 | | - * It also adds a back-reference to the hfile back-reference directory to simplify the |
338 | | - * reference-count and the cleaning process. |
339 | | - * @param conf {@link Configuration} to read for the archive directory name |
340 | | - * @param fs {@link FileSystem} on which to write the HFileLink |
341 | | - * @param dstFamilyPath - Destination path (table/region/cf/) |
342 | | - * @param linkedTable - Linked Table Name |
343 | | - * @param linkedRegion - Linked Region Name |
344 | | - * @param hfileName - Linked HFile name |
345 | | - * @return the file link name. |
346 | | - * @throws IOException on file or parent directory creation failure. |
347 | | - */ |
348 | | - public static String create(final Configuration conf, final FileSystem fs, |
349 | | - final Path dstFamilyPath, final TableName linkedTable, final String linkedRegion, |
350 | | - final String hfileName) throws IOException { |
351 | | - return create(conf, fs, dstFamilyPath, linkedTable, linkedRegion, hfileName, true); |
352 | | - } |
353 | | - |
354 | | - /** |
355 | | - * Create a new HFileLink. In the event of link creation failure, this method throws an |
356 | | - * IOException, so that the calling upper laying can decide on how to proceed with this. |
357 | | - * <p> |
358 | | - * It also adds a back-reference to the hfile back-reference directory to simplify the |
359 | | - * reference-count and the cleaning process. |
360 | | - * @param conf {@link Configuration} to read for the archive directory name |
361 | | - * @param fs {@link FileSystem} on which to write the HFileLink |
362 | | - * @param dstFamilyPath - Destination path (table/region/cf/) |
363 | | - * @param linkedTable - Linked Table Name |
364 | | - * @param linkedRegion - Linked Region Name |
365 | | - * @param hfileName - Linked HFile name |
366 | | - * @param createBackRef - Whether back reference should be created. Defaults to true. |
367 | | - * @return the file link name. |
368 | | - * @throws IOException on file or parent directory creation failure. |
369 | | - */ |
370 | | - public static String create(final Configuration conf, final FileSystem fs, |
371 | | - final Path dstFamilyPath, final TableName linkedTable, final String linkedRegion, |
372 | | - final String hfileName, final boolean createBackRef) throws IOException { |
373 | | - String familyName = dstFamilyPath.getName(); |
374 | | - String regionName = dstFamilyPath.getParent().getName(); |
375 | | - String tableName = |
376 | | - CommonFSUtils.getTableName(dstFamilyPath.getParent().getParent()).getNameAsString(); |
377 | | - |
378 | | - return create(conf, fs, dstFamilyPath, familyName, tableName, regionName, linkedTable, |
379 | | - linkedRegion, hfileName, createBackRef); |
380 | | - } |
381 | | - |
382 | | - /** |
383 | | - * Create a new HFileLink |
384 | | - * <p> |
385 | | - * It also adds a back-reference to the hfile back-reference directory to simplify the |
386 | | - * reference-count and the cleaning process. |
387 | | - * @param conf {@link Configuration} to read for the archive directory name |
388 | | - * @param fs {@link FileSystem} on which to write the HFileLink |
389 | | - * @param dstFamilyPath - Destination path (table/region/cf/) |
390 | | - * @param dstTableName - Destination table name |
391 | | - * @param dstRegionName - Destination region name |
392 | | - * @param linkedTable - Linked Table Name |
393 | | - * @param linkedRegion - Linked Region Name |
394 | | - * @param hfileName - Linked HFile name |
395 | | - * @param createBackRef - Whether back reference should be created. Defaults to true. |
396 | | - * @return the file link name. |
397 | | - * @throws IOException on file or parent directory creation failure |
398 | | - */ |
399 | | - public static String create(final Configuration conf, final FileSystem fs, |
400 | | - final Path dstFamilyPath, final String familyName, final String dstTableName, |
401 | | - final String dstRegionName, final TableName linkedTable, final String linkedRegion, |
402 | | - final String hfileName, final boolean createBackRef) throws IOException { |
403 | | - String name = createHFileLinkName(linkedTable, linkedRegion, hfileName); |
404 | | - String refName = createBackReferenceName(dstTableName, dstRegionName); |
405 | | - |
406 | | - // Make sure the destination directory exists |
407 | | - fs.mkdirs(dstFamilyPath); |
408 | | - |
409 | | - // Make sure the FileLink reference directory exists |
410 | | - Path archiveStoreDir = |
411 | | - HFileArchiveUtil.getStoreArchivePath(conf, linkedTable, linkedRegion, familyName); |
412 | | - Path backRefPath = null; |
413 | | - if (createBackRef) { |
414 | | - Path backRefssDir = getBackReferencesDir(archiveStoreDir, hfileName); |
415 | | - fs.mkdirs(backRefssDir); |
416 | | - |
417 | | - // Create the reference for the link |
418 | | - backRefPath = new Path(backRefssDir, refName); |
419 | | - fs.createNewFile(backRefPath); |
420 | | - } |
421 | | - try { |
422 | | - // Create the link |
423 | | - if (fs.createNewFile(new Path(dstFamilyPath, name))) { |
424 | | - return name; |
425 | | - } |
426 | | - } catch (IOException e) { |
427 | | - LOG.error("couldn't create the link=" + name + " for " + dstFamilyPath, e); |
428 | | - // Revert the reference if the link creation failed |
429 | | - if (createBackRef) { |
430 | | - fs.delete(backRefPath, false); |
431 | | - } |
432 | | - throw e; |
433 | | - } |
434 | | - throw new IOException( |
435 | | - "File link=" + name + " already exists under " + dstFamilyPath + " folder."); |
436 | | - } |
437 | | - |
438 | | - /** |
439 | | - * Create a new HFileLink starting from a hfileLink name |
440 | | - * <p> |
441 | | - * It also adds a back-reference to the hfile back-reference directory to simplify the |
442 | | - * reference-count and the cleaning process. |
443 | | - * @param conf {@link Configuration} to read for the archive directory name |
444 | | - * @param fs {@link FileSystem} on which to write the HFileLink |
445 | | - * @param dstFamilyPath - Destination path (table/region/cf/) |
446 | | - * @param hfileLinkName - HFileLink name (it contains hfile-region-table) |
447 | | - * @param createBackRef - Whether back reference should be created. Defaults to true. |
448 | | - * @return the file link name. |
449 | | - * @throws IOException on file or parent directory creation failure. |
450 | | - */ |
451 | | - public static String createFromHFileLink(final Configuration conf, final FileSystem fs, |
452 | | - final Path dstFamilyPath, final String hfileLinkName, final boolean createBackRef) |
453 | | - throws IOException { |
454 | | - Matcher m = LINK_NAME_PATTERN.matcher(hfileLinkName); |
455 | | - if (!m.matches()) { |
456 | | - throw new IllegalArgumentException(hfileLinkName + " is not a valid HFileLink name!"); |
457 | | - } |
458 | | - return create(conf, fs, dstFamilyPath, TableName.valueOf(m.group(1), m.group(2)), m.group(3), |
459 | | - m.group(4), createBackRef); |
460 | | - } |
461 | | - |
462 | 292 | /** |
463 | 293 | * Create the back reference name |
464 | 294 | */ |
|
0 commit comments