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 .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 META row for each of the specified new regions.
static void addRegionToMeta(CatalogTracker catalogTracker, HRegionInfo regionInfo)
          Adds a META row for the specified new region.
static void addRegionToMeta(HTable meta, HRegionInfo regionInfo)
          Adds a 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) META row for the specified new region and its daughters.
static void deleteFromMetaTable(CatalogTracker ct, List<Delete> deletes)
          Delete the passed deletes from the .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 Delete makeDeleteFromRegionInfo(HRegionInfo regionInfo)
          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 void mergeRegions(CatalogTracker catalogTracker, HRegionInfo mergedRegion, HRegionInfo regionA, HRegionInfo regionB, ServerName sn)
          Merge the two regions into one in an atomic operation.
static void mutateRegions(CatalogTracker catalogTracker, List<HRegionInfo> regionsToRemove, List<HRegionInfo> regionsToAdd)
          Adds and Removes the specified regions from .META.
static void putsToMetaTable(CatalogTracker ct, List<Put> ps)
          Put the passed ps to the .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 META region in ROOT to be the specified server hostname and startcode.
static void updateRegionLocation(CatalogTracker catalogTracker, HRegionInfo regionInfo, ServerName sn, long updateSeqNum)
          Updates the location of the specified region in 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

makeDeleteFromRegionInfo

public static Delete makeDeleteFromRegionInfo(HRegionInfo regionInfo)
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 .META. table.

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

deleteFromMetaTable

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

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

addRegionToMeta

public static void addRegionToMeta(CatalogTracker catalogTracker,
                                   HRegionInfo regionInfo)
                            throws IOException
Adds a 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 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) 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

addRegionsToMeta

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

Parameters:
catalogTracker - CatalogTracker
regionInfos - region information list
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)
                         throws IOException
Merge the two regions into one in an atomic operation. Deletes the two merging regions in 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
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 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 .META. is down.
NullPointerException - Because no -ROOT- server connection

updateRegionLocation

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

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

Parameters:
catalogTracker - catalog tracker
regionInfo - region to update location of
sn - Server name
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

mutateRegions

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

Parameters:
catalogTracker -
regionsToRemove - list of regions to be deleted from META
regionsToAdd - 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 © 2013 The Apache Software Foundation. All Rights Reserved.