Class InMemoryAliasMap
java.lang.Object
org.apache.hadoop.hdfs.server.aliasmap.InMemoryAliasMap
- All Implemented Interfaces:
Configurable,org.apache.hadoop.hdfs.server.aliasmap.InMemoryAliasMapProtocol
@Public
@Unstable
public class InMemoryAliasMap
extends Object
implements org.apache.hadoop.hdfs.server.aliasmap.InMemoryAliasMapProtocol, Configurable
InMemoryAliasMap is an implementation of the InMemoryAliasMapProtocol for
use with LevelDB.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceorg.apache.hadoop.hdfs.server.aliasmap.InMemoryAliasMap.CheckedFunction2<T1,T2, R> CheckedFunction is akin toFunctionbut specifies an IOException.Nested classes/interfaces inherited from interface org.apache.hadoop.hdfs.server.aliasmap.InMemoryAliasMapProtocol
org.apache.hadoop.hdfs.server.aliasmap.InMemoryAliasMapProtocol.IterationResult -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()static voidcompleteBootstrapTransfer(File aliasMap) Extract the aliasmap archive to complete the bootstrap process.static org.apache.hadoop.hdfs.protocol.BlockfromBlockBytes(byte[] blockDbFormat) static org.apache.hadoop.hdfs.protocol.ProvidedStorageLocationfromProvidedStorageLocationBytes(byte[] providedStorageLocationDbFormat) Get the associated block pool id.getConf()Return the configuration used by this object.static InMemoryAliasMapinit(Configuration conf, String blockPoolID) org.apache.hadoop.hdfs.server.aliasmap.InMemoryAliasMapProtocol.IterationResultList the next batch ofFileRegions in the alias map starting from the givenmarker.Optional<org.apache.hadoop.hdfs.protocol.ProvidedStorageLocation>read(org.apache.hadoop.hdfs.protocol.Block block) Gets theProvidedStorageLocationassociated with the specified block.voidsetConf(Configuration conf) Set the configuration to be used by this object.static byte[]toProtoBufBytes(org.apache.hadoop.hdfs.protocol.Block block) static byte[]toProtoBufBytes(org.apache.hadoop.hdfs.protocol.ProvidedStorageLocation providedStorageLocation) static voidtransferForBootstrap(javax.servlet.http.HttpServletResponse response, Configuration conf, InMemoryAliasMap aliasMap) Transfer this aliasmap for bootstrapping standby Namenodes.voidwrite(org.apache.hadoop.hdfs.protocol.Block block, org.apache.hadoop.hdfs.protocol.ProvidedStorageLocation providedStorageLocation) Stores the block and it's associatedProvidedStorageLocationin the alias map.
-
Method Details
-
setConf
Description copied from interface:ConfigurableSet the configuration to be used by this object.- Specified by:
setConfin interfaceConfigurable- Parameters:
conf- configuration to be used
-
getConf
Description copied from interface:ConfigurableReturn the configuration used by this object.- Specified by:
getConfin interfaceConfigurable- Returns:
- Configuration
-
init
@Nonnull public static InMemoryAliasMap init(Configuration conf, String blockPoolID) throws IOException - Throws:
IOException
-
list
public org.apache.hadoop.hdfs.server.aliasmap.InMemoryAliasMapProtocol.IterationResult list(Optional<org.apache.hadoop.hdfs.protocol.Block> marker) throws IOException Description copied from interface:org.apache.hadoop.hdfs.server.aliasmap.InMemoryAliasMapProtocolList the next batch ofFileRegions in the alias map starting from the givenmarker. To retrieve allFileRegions stored in the alias map, multiple calls to this function might be required.- Specified by:
listin interfaceorg.apache.hadoop.hdfs.server.aliasmap.InMemoryAliasMapProtocol- Parameters:
marker- the next block to get fileregions from.- Returns:
- the
InMemoryAliasMapProtocol.IterationResultwith a set of FileRegions and the next marker. - Throws:
IOException
-
read
@Nonnull public Optional<org.apache.hadoop.hdfs.protocol.ProvidedStorageLocation> read(@Nonnull org.apache.hadoop.hdfs.protocol.Block block) throws IOException Description copied from interface:org.apache.hadoop.hdfs.server.aliasmap.InMemoryAliasMapProtocolGets theProvidedStorageLocationassociated with the specified block.- Specified by:
readin interfaceorg.apache.hadoop.hdfs.server.aliasmap.InMemoryAliasMapProtocol- Parameters:
block- the block to lookup- Returns:
- the associated
ProvidedStorageLocation. - Throws:
IOException
-
write
public void write(@Nonnull org.apache.hadoop.hdfs.protocol.Block block, @Nonnull org.apache.hadoop.hdfs.protocol.ProvidedStorageLocation providedStorageLocation) throws IOException Description copied from interface:org.apache.hadoop.hdfs.server.aliasmap.InMemoryAliasMapProtocolStores the block and it's associatedProvidedStorageLocationin the alias map.- Specified by:
writein interfaceorg.apache.hadoop.hdfs.server.aliasmap.InMemoryAliasMapProtocol- Throws:
IOException
-
getBlockPoolId
Description copied from interface:org.apache.hadoop.hdfs.server.aliasmap.InMemoryAliasMapProtocolGet the associated block pool id.- Specified by:
getBlockPoolIdin interfaceorg.apache.hadoop.hdfs.server.aliasmap.InMemoryAliasMapProtocol- Returns:
- the block pool id associated with the Namenode running the in-memory alias map.
-
close
- Throws:
IOException
-
fromProvidedStorageLocationBytes
@Nonnull public static org.apache.hadoop.hdfs.protocol.ProvidedStorageLocation fromProvidedStorageLocationBytes(@Nonnull byte[] providedStorageLocationDbFormat) throws org.apache.hadoop.thirdparty.protobuf.InvalidProtocolBufferException - Throws:
org.apache.hadoop.thirdparty.protobuf.InvalidProtocolBufferException
-
fromBlockBytes
@Nonnull public static org.apache.hadoop.hdfs.protocol.Block fromBlockBytes(@Nonnull byte[] blockDbFormat) throws org.apache.hadoop.thirdparty.protobuf.InvalidProtocolBufferException - Throws:
org.apache.hadoop.thirdparty.protobuf.InvalidProtocolBufferException
-
toProtoBufBytes
public static byte[] toProtoBufBytes(@Nonnull org.apache.hadoop.hdfs.protocol.ProvidedStorageLocation providedStorageLocation) throws IOException - Throws:
IOException
-
toProtoBufBytes
public static byte[] toProtoBufBytes(@Nonnull org.apache.hadoop.hdfs.protocol.Block block) throws IOException - Throws:
IOException
-
transferForBootstrap
public static void transferForBootstrap(javax.servlet.http.HttpServletResponse response, Configuration conf, InMemoryAliasMap aliasMap) throws IOException Transfer this aliasmap for bootstrapping standby Namenodes. The map is transferred as a tar.gz archive. This archive needs to be extracted on the standby Namenode.- Parameters:
response- http response.conf- configuration to use.aliasMap- aliasmap to transfer.- Throws:
IOException
-
completeBootstrapTransfer
Extract the aliasmap archive to complete the bootstrap process. This method has to be called after the aliasmap archive is transfered from the primary Namenode.- Parameters:
aliasMap- location of the aliasmap.- Throws:
IOException
-