org.apache.hadoop.hbase.catalog
Class MetaEditor

java.lang.Object
  extended by org.apache.hadoop.hbase.catalog.MetaEditor

@InterfaceAudience.Private
public class MetaEditor
extends Object

Writes region and assignment information to hbase:meta. TODO: Put MetaReader and MetaEditor together; doesn't make sense having them distinct. see HBASE-3475.


Constructor Summary
MetaEditor()
           
 
Method Summary
static void addDaughter(CatalogTracker catalogTracker, HRegionInfo regionInfo, ServerName sn, long openSeqNum)
          Adds a daughter region entry to meta.
static Put addDaughtersToPut(Put put, HRegionInfo splitA, HRegionInfo splitB)
          Adds split daughters to the Put
static void addRegionsToMeta(CatalogTracker catalogTracker, List<HRegionInfo> regionInfos)
          Adds a hbase:meta row for each of the specified new regions.
static void addRegionsToMeta(CatalogTracker catalogTracker, List<HRegionInfo> regionInfos, long ts)
          Adds a hbase:meta row for each of the specified new regions.
static void addRegionToMeta(CatalogTracker catalogTracker, HRegionInfo regionInfo)
          Adds a hbase:meta row for the specified new region.
static void addRegionToMeta(CatalogTracker catalogTracker, HRegionInfo regionInfo, HRegionInfo splitA, HRegionInfo splitB)
          Adds a (single) hbase:meta row for the specified new region and its daughters.
static void addRegionToMeta(HTable meta, HRegionInfo regionInfo)
          Adds a hbase:meta row for the specified new region to the given catalog table.
static void addRegionToMeta(HTable meta, HRegionInfo regionInfo, HRegionInfo splitA, HRegionInfo splitB)
          Adds a (single) hbase:meta row for the specified new region and its daughters.
static void deleteFromMetaTable(CatalogTracker ct, List<Delete> deletes)
          Delete the passed deletes from the hbase:meta table.
static void deleteMergeQualifiers(CatalogTracker catalogTracker, HRegionInfo mergedRegion)
          Deletes merge qualifiers for the specified merged region.
static void deleteRegion(CatalogTracker catalogTracker, HRegionInfo regionInfo)
          Deletes the specified region from META.
static void deleteRegions(CatalogTracker catalogTracker, List<HRegionInfo> regionsInfo)
          Deletes the specified regions from META.
static void deleteRegions(CatalogTracker catalogTracker, List<HRegionInfo> regionsInfo, long ts)
          Deletes the specified regions from META.
static Delete makeDeleteFromRegionInfo(HRegionInfo regionInfo)
          Generates and returns a Delete containing the region info for the catalog table
static Delete makeDeleteFromRegionInfo(HRegionInfo regionInfo, long ts)
          Generates and returns a Delete containing the region info for the catalog table
static Put makePutFromRegionInfo(HRegionInfo regionInfo)
          Generates and returns a Put containing the region into for the catalog table
static Put makePutFromRegionInfo(HRegionInfo regionInfo, long ts)
          Generates and returns a Put containing the region into for the catalog table
static void mergeRegions(CatalogTracker catalogTracker, HRegionInfo mergedRegion, HRegionInfo regionA, HRegionInfo regionB, ServerName sn, long masterSystemTime)
          Merge the two regions into one in an atomic operation.
static void mutateMetaTable(CatalogTracker ct, List<Mutation> mutations)
          Execute the passed mutations against hbase:meta table.
static void mutateRegions(CatalogTracker catalogTracker, List<HRegionInfo> regionsToRemove, List<HRegionInfo> regionsToAdd)
          Adds and Removes the specified regions from hbase:meta
static void overwriteRegions(CatalogTracker catalogTracker, List<HRegionInfo> regionInfos)
          Overwrites the specified regions from hbase:meta
static void putsToMetaTable(CatalogTracker ct, List<Put> ps)
          Put the passed ps to the hbase:meta table.
static void splitRegion(CatalogTracker catalogTracker, HRegionInfo parent, HRegionInfo splitA, HRegionInfo splitB, ServerName sn)
          Splits the region into two in an atomic operation.
static void updateMetaLocation(CatalogTracker catalogTracker, HRegionInfo regionInfo, ServerName sn, long openSeqNum)
          Updates the location of the specified hbase:meta region in ROOT to be the specified server hostname and startcode.
static void updateRegionLocation(CatalogTracker catalogTracker, HRegionInfo regionInfo, ServerName sn, long openSeqNum)
          Updates the location of the specified region in hbase:meta to be the specified server hostname and startcode.
static void updateRegionLocation(CatalogTracker catalogTracker, HRegionInfo regionInfo, ServerName sn, long openSeqNum, long masterSystemTime)
          Updates the location of the specified region in hbase:meta to be the specified server hostname and startcode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetaEditor

public MetaEditor()
Method Detail

makePutFromRegionInfo

public static Put makePutFromRegionInfo(HRegionInfo regionInfo)
                                 throws IOException
Generates and returns a Put containing the region into for the catalog table

Throws:
IOException

makePutFromRegionInfo

public static Put makePutFromRegionInfo(HRegionInfo regionInfo,
                                        long ts)
                                 throws IOException
Generates and returns a Put containing the region into for the catalog table

Throws:
IOException

makeDeleteFromRegionInfo

public static Delete makeDeleteFromRegionInfo(HRegionInfo regionInfo)
Generates and returns a Delete containing the region info for the catalog table


makeDeleteFromRegionInfo

public static Delete makeDeleteFromRegionInfo(HRegionInfo regionInfo,
                                              long ts)
Generates and returns a Delete containing the region info for the catalog table


addDaughtersToPut

public static Put addDaughtersToPut(Put put,
                                    HRegionInfo splitA,
                                    HRegionInfo splitB)
Adds split daughters to the Put


putsToMetaTable

public static void putsToMetaTable(CatalogTracker ct,
                                   List<Put> ps)
                            throws IOException
Put the passed ps to the hbase:meta table.

Parameters:
ct - CatalogTracker on whose back we will ride the edit.
ps - Put to add to hbase:meta
Throws:
IOException

deleteFromMetaTable

public static void deleteFromMetaTable(CatalogTracker ct,
                                       List<Delete> deletes)
                                throws IOException
Delete the passed deletes from the hbase:meta table.

Parameters:
ct - CatalogTracker on whose back we will ride the edit.
deletes - Deletes to add to hbase:meta This list should support #remove.
Throws:
IOException

mutateMetaTable

public static void mutateMetaTable(CatalogTracker ct,
                                   List<Mutation> mutations)
                            throws IOException
Execute the passed mutations against hbase:meta table.

Parameters:
ct - CatalogTracker on whose back we will ride the edit.
mutations - Puts and Deletes to execute on hbase:meta
Throws:
IOException

addRegionToMeta

public static void addRegionToMeta(CatalogTracker catalogTracker,
                                   HRegionInfo regionInfo)
                            throws IOException
Adds a hbase:meta row for the specified new region.

Parameters:
regionInfo - region information
Throws:
IOException - if problem connecting or updating meta

addRegionToMeta

public static void addRegionToMeta(HTable meta,
                                   HRegionInfo regionInfo)
                            throws IOException
Adds a hbase:meta row for the specified new region to the given catalog table. The HTable is not flushed or closed.

Parameters:
meta - the HTable for META
regionInfo - region information
Throws:
IOException - if problem connecting or updating meta

addRegionToMeta

public static void addRegionToMeta(HTable meta,
                                   HRegionInfo regionInfo,
                                   HRegionInfo splitA,
                                   HRegionInfo splitB)
                            throws IOException
Adds a (single) hbase:meta row for the specified new region and its daughters. Note that this does not add its daughter's as different rows, but adds information about the daughters in the same row as the parent. Use splitRegion(CatalogTracker, HRegionInfo, HRegionInfo, HRegionInfo, ServerName) if you want to do that.

Parameters:
meta - the HTable for META
regionInfo - region information
splitA - first split daughter of the parent regionInfo
splitB - second split daughter of the parent regionInfo
Throws:
IOException - if problem connecting or updating meta

addRegionToMeta

public static void addRegionToMeta(CatalogTracker catalogTracker,
                                   HRegionInfo regionInfo,
                                   HRegionInfo splitA,
                                   HRegionInfo splitB)
                            throws IOException
Adds a (single) hbase:meta row for the specified new region and its daughters. Note that this does not add its daughter's as different rows, but adds information about the daughters in the same row as the parent. Use splitRegion(CatalogTracker, HRegionInfo, HRegionInfo, HRegionInfo, ServerName) if you want to do that.

Parameters:
catalogTracker - CatalogTracker on whose back we will ride the edit.
regionInfo - region information
splitA - first split daughter of the parent regionInfo
splitB - second split daughter of the parent regionInfo
Throws:
IOException - if problem connecting or updating meta

addRegionsToMeta

public static void addRegionsToMeta(CatalogTracker catalogTracker,
                                    List<HRegionInfo> regionInfos)
                             throws IOException
Adds a hbase:meta row for each of the specified new regions.

Parameters:
catalogTracker - CatalogTracker
regionInfos - region information list
Throws:
IOException - if problem connecting or updating meta

addRegionsToMeta

public static void addRegionsToMeta(CatalogTracker catalogTracker,
                                    List<HRegionInfo> regionInfos,
                                    long ts)
                             throws IOException
Adds a hbase:meta row for each of the specified new regions.

Parameters:
catalogTracker - CatalogTracker
regionInfos - region information list
ts - desired timestamp
Throws:
IOException - if problem connecting or updating meta

addDaughter

public static void addDaughter(CatalogTracker catalogTracker,
                               HRegionInfo regionInfo,
                               ServerName sn,
                               long openSeqNum)
                        throws NotAllMetaRegionsOnlineException,
                               IOException
Adds a daughter region entry to meta.

Parameters:
regionInfo - the region to put
sn - the location of the region
openSeqNum - the latest sequence number obtained when the region was open
Throws:
NotAllMetaRegionsOnlineException
IOException

mergeRegions

public static void mergeRegions(CatalogTracker catalogTracker,
                                HRegionInfo mergedRegion,
                                HRegionInfo regionA,
                                HRegionInfo regionB,
                                ServerName sn,
                                long masterSystemTime)
                         throws IOException
Merge the two regions into one in an atomic operation. Deletes the two merging regions in hbase:meta and adds the merged region with the information of two merging regions.

Parameters:
catalogTracker - the catalog tracker
mergedRegion - the merged region
regionA -
regionB -
sn - the location of the region
masterSystemTime - wall clock time from master if passed in the open region RPC or -1
Throws:
IOException

splitRegion

public static void splitRegion(CatalogTracker catalogTracker,
                               HRegionInfo parent,
                               HRegionInfo splitA,
                               HRegionInfo splitB,
                               ServerName sn)
                        throws IOException
Splits the region into two in an atomic operation. Offlines the parent region with the information that it is split into two, and also adds the daughter regions. Does not add the location information to the daughter regions since they are not open yet.

Parameters:
catalogTracker - the catalog tracker
parent - the parent region which is split
splitA - Split daughter region A
splitB - Split daughter region A
sn - the location of the region
Throws:
IOException

updateMetaLocation

public static void updateMetaLocation(CatalogTracker catalogTracker,
                                      HRegionInfo regionInfo,
                                      ServerName sn,
                                      long openSeqNum)
                               throws IOException,
                                      ConnectException
Updates the location of the specified hbase:meta region in ROOT to be the specified server hostname and startcode.

Uses passed catalog tracker to get a connection to the server hosting ROOT and makes edits to that region.

Parameters:
catalogTracker - catalog tracker
regionInfo - region to update location of
sn - Server name
openSeqNum - the latest sequence number obtained when the region was open
Throws:
IOException
ConnectException - Usually because the regionserver carrying hbase:meta is down.
NullPointerException - Because no -ROOT- server connection

updateRegionLocation

public static void updateRegionLocation(CatalogTracker catalogTracker,
                                        HRegionInfo regionInfo,
                                        ServerName sn,
                                        long openSeqNum)
                                 throws IOException
Updates the location of the specified region in hbase:meta to be the specified server hostname and startcode.

Uses passed catalog tracker to get a connection to the server hosting hbase:meta and makes edits to that region.

Parameters:
catalogTracker - catalog tracker
regionInfo - region to update location of
sn - Server name
openSeqNum - the latest sequence number obtained when the region was open
Throws:
IOException

updateRegionLocation

public static void updateRegionLocation(CatalogTracker catalogTracker,
                                        HRegionInfo regionInfo,
                                        ServerName sn,
                                        long openSeqNum,
                                        long masterSystemTime)
                                 throws IOException
Updates the location of the specified region in hbase:meta to be the specified server hostname and startcode.

Uses passed catalog tracker to get a connection to the server hosting hbase:meta and makes edits to that region.

Parameters:
catalogTracker - catalog tracker
regionInfo - region to update location of
sn - Server name
openSeqNum - the latest sequence number obtained when the region was open
masterSystemTime - wall clock time from master if passed in the open region RPC or -1
Throws:
IOException

deleteRegion

public static void deleteRegion(CatalogTracker catalogTracker,
                                HRegionInfo regionInfo)
                         throws IOException
Deletes the specified region from META.

Parameters:
catalogTracker -
regionInfo - region to be deleted from META
Throws:
IOException

deleteRegions

public static void deleteRegions(CatalogTracker catalogTracker,
                                 List<HRegionInfo> regionsInfo)
                          throws IOException
Deletes the specified regions from META.

Parameters:
catalogTracker -
regionsInfo - list of regions to be deleted from META
Throws:
IOException

deleteRegions

public static void deleteRegions(CatalogTracker catalogTracker,
                                 List<HRegionInfo> regionsInfo,
                                 long ts)
                          throws IOException
Deletes the specified regions from META.

Parameters:
catalogTracker -
regionsInfo - list of regions to be deleted from META
ts - desired timestamp
Throws:
IOException

mutateRegions

public static void mutateRegions(CatalogTracker catalogTracker,
                                 List<HRegionInfo> regionsToRemove,
                                 List<HRegionInfo> regionsToAdd)
                          throws IOException
Adds and Removes the specified regions from hbase:meta

Parameters:
catalogTracker -
regionsToRemove - list of regions to be deleted from META
regionsToAdd - list of regions to be added to META
Throws:
IOException

overwriteRegions

public static void overwriteRegions(CatalogTracker catalogTracker,
                                    List<HRegionInfo> regionInfos)
                             throws IOException
Overwrites the specified regions from hbase:meta

Parameters:
catalogTracker -
regionInfos - list of regions to be added to META
Throws:
IOException

deleteMergeQualifiers

public static void deleteMergeQualifiers(CatalogTracker catalogTracker,
                                         HRegionInfo mergedRegion)
                                  throws IOException
Deletes merge qualifiers for the specified merged region.

Parameters:
catalogTracker -
mergedRegion -
Throws:
IOException


Copyright © 2007–2016 The Apache Software Foundation. All rights reserved.