170 |
--------------------------------------------------------------------------------
/10~KV 存储/配置方式对比/基础配置方式.md:
--------------------------------------------------------------------------------
1 | # 基础配置方式
2 |
3 | # 硬编码
4 |
5 | 硬编码是最基础的配置方案,其简单易用:
6 |
7 | ```java
8 | public class AppConfig {
9 | private int connectTimeoutInMills = 5000;
10 |
11 | public int getConnectTimeoutInMills() {
12 | return connectTimeoutInMills;
13 | }
14 |
15 | public void setConnectTimeoutInMills(int connectTimeoutInMills) {
16 | this.connectTimeoutInMills = connectTimeoutInMills;
17 | }
18 | }
19 | ```
20 |
21 | 这种形式主要有三个问题:
22 |
23 | - 难以动态修改,如果配置是需要动态修改的话,需要当前应用去暴露管理该配置项的接口,至于是 Controller 的 API 接口,还是 JMX,都是可以做到。
24 |
25 | - 难以持久化与恢复,配置变更都是发生在内存中,并没有持久化。因此,在修改配置之后重启应用,配置又会变回代码中的默认值了。
26 |
27 | - 难以分布式多机器同步,当你有多台机器的时候,要修改一个配置,每一台都得去操作一遍,运维成本可想而知。
28 |
29 | # 配置文件
30 |
31 | Spring 中常见的 properties、yml 文件,或其他自定义的,如,“conf”后缀等:
32 |
33 | ```yaml
34 | # application.properties
35 | connectTimeoutInMills=5000
36 | ```
37 |
38 | 相比“硬编码”的形式,它解决了第二个问题,持久化了配置。但是,另外两个问题并没有解决,运维成本依旧还是很高的。
39 |
40 | 配置动态变更,可以是通过类似“硬编码”暴露管理接口的方式,这时,代码中会多一步持久化新配置到文件的逻辑。或者,简单粗暴点,直接登录机器上去修改配置文件,再重启应用,让配置生效。当然,你也可以在代码中增加一个定时任务,如每隔 10s 读取配置文件内容,让最新的配置能够及时在应用中生效,这样也就免去了重启应用这个“较重”的运维操作。
41 |
42 | # DB 配置表
43 |
44 | 这里的 DB 可以是 MySQL 等的关系型数据库,也可以是 Redis 等的非关系型数据库。数据表如:
45 |
46 | ```sql
47 | CREATE TABLE `config` (
48 | `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
49 | `key` varchar(50) NOT NULL DEFAULT '' COMMENT '配置项',
50 | `value` varchar(50) NOT NULL DEFAULT '' COMMENT '配置内容',
51 | `updated_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
52 | `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
53 | PRIMARY KEY (`id`),
54 | UNIQUE KEY `idx_key` (`key`)
55 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='配置信息';
56 |
57 | INSERT INTO `config` (`key`, `value`, `updated_time`, `created_time`) VALUES ('connectTimeoutInMills', '5000', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
58 | ```
59 |
60 | 它相对于前两者,更进一步,将配置从应用中抽离出来,集中管理,能较大的降低运维成本。
61 |
62 | 那么,它能怎么解决动态更新配置的问题呢?据我所知,有两种方式。
63 |
64 | 其一,如同之前一样,通过暴露管理接口去解决,当然,也一样得增加持久化的逻辑,只不过,之前是写文件,现在是将最新配置写入数据库。不过,程序中还需要有定时从数据库读取最新配置的任务,这样,才能做到只需调用其中一台机器的管理配置接口,就能把最新的配置下发到整个应用集群所有的机器上,真正达到降低运维成本的目的。
65 |
66 | 其二,直接修改数据库,程序中通过定时任务从数据库读取最新的配置内容。
67 |
68 | “DB 配置表”的形式解决了主要的问题,但是它不够优雅,带来了一些“累赘”。
69 |
--------------------------------------------------------------------------------
/20~分布式文件系统/HDFS/HDFS 源代码分析.md:
--------------------------------------------------------------------------------
1 | 1. 基础包(包括工具包和安全包)
2 |
3 | 包括工具和安全包。其中,hdfs.util 包含了一些 HDFS 实现需要的辅助数据结构;hdfs.security.token.block 和 hdfs.security.token.delegation 结合 Hadoop 的安全框架,提供了安全访问 HDFS 的机制。
4 |
5 | hdfs.util (一些 HDFS 实现需要的辅助数据结构)
6 |
7 | AtomicFileOutputStream.java---- 继承实现类:原子文件输出流类;DataTransferThrottler.java---- 独立内存类:数据传送时的调节参数配置表;这个类是线程安全的,能够被多个线程所共享;LightWeightGSet.java---- 继承实现类:一个低内存占用的实现类;
8 |
9 | hdfs.security.token.block (安全访问 HDFS 机制)
10 |
11 | BlockKey.java---- 继承实现类:Key 用于生成和校验块的令牌;BlockTokenIdentifier.java---- 继承实现类:块令牌的标识符;BlockTokenSecretManager.java---- 继承实现类:块令牌管理类;BlockTokenSecretManager 能够被实例化为两种模式,主模式和从模式。主节点能够生成新的块 key,并导出块 key 到从节点。从节点只能导入并且使用从主节点接收的块 key。主机和从机都可以生成和验证块令牌。BlockTokenSelector.java---- 继承实现类:为 HDFS 的块令牌选择;ExportedBlockKeys.java---- 继承实现类:传递块 key 对象;InvalidBlockTokenException.java---- 继承实现类:访问令牌验证失败;
12 |
13 | hdfs.security.token.delegation (安全访问 HDFS 机制)
14 |
15 | DelegationTokenIdentifier.java---- 继承实现类:特定针对 HDFS 的代表令牌的标识符;DelegationTokenRenewer.java---- 继承实现类:这是一个守护进程,实现等待下一个文件系统的接续;DelegationTokenSecretManager.java---- 继承实现类:这个类实现了 HDFS 特定授权的令牌的管理;这个管理类实现了生成并接受每一个令牌的密码;DelegationTokenSelector.java---- 继承实现类:专门针对 HDFS 的令牌;
16 |
17 | 2.HDFS 实体实现包
18 |
19 | 这是代码分析的重点,包含 8 个包:
20 |
21 | hdfs.server.common 包含了一些名字节点和数据节点共享的功能,如系统升级、存储空间信息等。
22 |
23 | hdfs.protocol 和 hdfs.server.protocol 提供了 HDFS 各个实体间通过 IPC 交互的接口的定义和实现。
24 |
25 | hdfs.server.namenode、hdfs.server.datanode 和 hdfs 分别包含了名字节点、数据节点和客户端的实现。上述代码是 HDFS 代码分析的重点。
26 |
27 | hdfs.server.namenode.metrics 和 hdfs.server.datanode.metrics 实现了名字节点和数据节点上度量数据的收集功能。度量数据包括名字节点进程和数据节点进程上事件的计数,例如数据节点上就可以收集到写入字节数、被复制的块的数量等信息。
28 |
29 | hdfs.server.common (一些名字节点和数据节点共享的功能)
30 |
31 | GenerationStamp.java---- 继承实现类:生成时间戳的功能及读写访问类;HdfsConstants.java---- 接口类:一些 HDFS 内部的常数;Hdfs 常量字段及取值的定义;InconsistentFSStateException.java---- 继承实现类:不一致的文件系统状态异常;文件状态检查出错提示信息;IncorrectVersionException.java---- 继承实现类:不正确的版本异常;版本不正确检查时提示信息;Storage.java---- 继承实现类:存储信息文件;本地存储信息存储在一个单独的文件版本中;它包含了节点类型、存储布局版本、命名空间 ID 以及文件系统状态创建时间;内存中以扩展表记录方式记录当前 namenode 索引信息及状态信息(文件是否在打开);StorageInfo.java---- 独立内存类:存储信息的通用类;内存中文件索引信息基本表;基本作用是保存地储上的文件系统元信息;Upgradeable.java---- 接口类:分布式升级对象的通用接口;对象升级接口方法集定义;UpgradeManager.java---- 独立内存类、抽象:通用升级管理;UpgradeObject.java---- 继承实现类:抽象升级对象;包含常用接口方法的实现;可升级对象的接口方法实现;UpgradeObjectCollection.java---- 独立内存类:可升级对象的集合容器实现;升级对象在使用前应该先进行注册,才能使用;UpgradeStatusReport.java---- 继承实现类:系统升级基类;升级过程状态信息表定义;Util.java---- 独立内存类:获取当前系统时间;
32 |
33 | hdfs.protocol ( HDFS 各个实体间通过 IPC 交互的接口)
34 |
35 | AlreadyBeingCreatedException.java---- 继承实现类:文件已经建立异常;Block.java---- 继承实现类:数据块在 HDFS 中的抽象;Bolck 内存基本块结构定义与读写访问;这个类是大量和数据块相关的类的基础,在客户端接口上,这样的类有 LocatedBlock、LocateBlocks 和 BlockLocalPathInfo。BlockListAsLongs.java---- 独立内存类:这个类提供了一个访问块列表的接口;Bolck 块的索引构成数组;该类的作用,就是将块数组 blcokArray 中的数据,“ 原封不动 ” 的转换成一个 long 类型的数组 blockList;BlockLocalPathInfo.java---- 继承实现类:应用于 ClientDatanodeProtocol 接口中,用于 HDFS 读文件的数据节点本地读优化。当客户端发现它和它要读取的数据块正好位于同一台主机上的时候,它可以不通过数据节点读数据块,而是直接读取本地文件,以获取数据块的内容。这大大降低了对应数据节点的负载。ClientDatanodeProtocol.java---- 接口类:客户端与数据节点间的接口。用于客户端和数据节点进行交互,这个接口用得比较少,客户端和数据节点间的主要交互是通过流接口进行读 / 写文件数据的操作。错误发生时,客户端需要数据节点配合进行恢复,或当客户端进行本地文件读优化时,需要通过 IPC 接口获取一些信息。ClientProtocol.java---- 接口类:客户端与 namenode 之间的接口;是 HDFS 客户访问文件系统的入口;客户端通过这个接口访问名字节点,操作文件或目录的元数据信息;读写文件也必须先访问名字节点,接下来再和数据节点进行交互,操作文件数据;另外,从名字节点能获取分布式文件系统的一些整体运行状态信息,也是通过这个接口进行的;用于访问 NameNode。它包含了文件角度上的 HDFS 功能。和 GFS 一样,HDFS 不提供 POSIX 形式的接口,而是使用了一个私有接口。一般来说,程序员通过 org.apache.hadoop.fs.FileSystem 来和 HDFS 打交道,不需要直接使用该接口。DatanodeID.java---- 继承实现类:用于在 HDFS 集群中确定一个数据节点;DatanodeInfo.java---- 继承实现类:继承自 DatanodeID,在 DatanodeID 的基础上,提供了数据节点上的一些度量信息;Datanode 状态信息结构定义及访问读写类;DataTransferProtocol.java---- 接口类:客户端与数据节点之间应用流协议传输数据的实现;DirectoryListing.java---- 继承实现类:用于一次返回一个目录下的多个文件 / 子目录的属性;DSQuotaExceededException.java---- 继承实现类:磁盘空间超出配额异常类;FSConstants.java---- 接口类:一些有用的常量;HdfsFileStatus.java---- 继承实现类:保存了 HDFS 文件 / 目录的属性;LayoutVersion.java---- 独立内存类:这个类跟踪了 HDFS 布局版本中的改变信息;LocatedBlock.java---- 继承实现类:已经确认了存储位置的数据块;可以用于一次定位多个数据块;LocatedBlocks.java---- 继承实现类:块的位置和文件长度集合;一组数据块及文件长度说明信息表的定义及读写;NSQuotaExceededException.java---- 继承实现类:命名空间超出配额异常类;QuotaExceededException.java---- 继承实现类:超出配额异常;UnregisteredDatanodeException.java---- 继承实现类:未注册的数据节点异常;
36 |
37 | hdfs.server.protocol ( HDFS 各个实体间接口的实现)
38 |
39 | BalancerBandwidthCommand.java---- 继承实现类:管理员通过调用 "dfsadmin -setBalanacerBandwidth newbandwidth" 实现动态的调整 balancer 的带宽参数;BlockCommand.java---- 继承实现类:BlockCommand 类实现的是数据节点控制下的块的指令;数据块命令定义及实现类;BlockMetaDataInfo.java---- 继承实现类:一个块的元数据信息;数据块的元数据信息定义及实现;BlockRecoveryInfo.java---- 继承实现类:块恢复操作信息;BlocksWithLocations.java---- 继承实现类:BlockLocations 序列的实现类;带位置的块信息的读写;DatanodeCommand.java---- 抽象类:数据节点命令;数据节点基本信息定义及实现;DatanodeProtocol.java---- 接口类:服务器间接口:数据节点与名字节点间的接口。在 HDFS 的主从体系结构中,数据节点作为从节点,不断的通过这个接口主节点名字节点报告一些信息,同步信息到名字节点;同时,该接口的一些方法,方法的返回值会带回名字节点指令,根据这些指令,数据节点或移动、或删除,或恢复本地磁盘上的数据块,或者执行其他的操作。DatanodeRegistration.java---- 继承实现类:DatanodeRegistration 类包含名字节点识别和验证数据节点的所有信息;数据节点的注册信息读写方法定义及实现;DisallowedDatanodeException.java---- 继承实现类:不允许的数据节点异常;InterDatanodeProtocol.java---- 接口类:服务器间的接口:数据节点与数据节点间的接口。数据节点通过这个接口,和其他数据节点进行通信,恢复数据块,保证数据的一致性。KeyUpdateCommand.java---- 继承实现类:key 升级命令;NamenodeProtocol.java---- 接口类:服务期间接口:第二名字节点、HDFS 均衡器与名字节点间的接口。第二名字节点会不停的获取名字节点上某一个时间点的命名空间镜像和镜像的变化日志,然后会合并得到一个新的镜像,并将该结果发送回名字节点,在这个过程中,名字节点会通过这个接口,配合第二名字节点完成元数据的合并。该接口也为 HDFS 均衡器 balancer 的正常工作提供一些信息。NamespaceInfo.java---- 继承实现类:NamespaceInfo 类实现了返回名字节点针对数据节点的握手;UpgradeCommand.java---- 继承实现类:这是一个通用的分布式升级命令类;升级数据块命名实现;
40 |
41 | hdfs.server.namenode (名字节点的实现)
42 |
43 | BlockPlacementPolicy.java---- 抽象类:这个接口用于选择放置块副本的目标磁盘的所需的数目;BlockPlacementPolicyDefault.java---- 继承实现类:这个类实现了选择放置块副本的目标磁盘的所需的数目;BlockPlacementPolicyWithNodeGroup.java---- 继承实现类:这个类实现了在 node-group 层上选择放置块副本的目标磁盘的所需的数目;BlockInfo.java---- 独立内存类:这个类维护了块到它元数据的映射;CancelDelegationTokenServlet.java---- 继承实现类:取消代表令牌服务;CheckpointSignature.java---- 继承实现类:检查点签名类;存贮信息的签名信息表定义;ContentSummaryServlet.java---- 继承实现类:文件校验服务;CorruptReplicasMap.java---- 独立内存类:存储文件系统中所有损坏的块的信息;DatanodeDescriptor.java---- 继承实现类:DatanodeDescriptor 类跟踪并统计了给定的数据节点上的信息,比如可用存储空间,上次更新时间等等;数据节点的状态信息定义及实现;DecommissionManager.java---- 独立内存类:管理节点的解除;DfsServlet.java---- 抽象类:DFS 服务的基类;Web 方式操作 DFS 的代理接口;EditLogInputStream.java---- 抽象类:一个通用的抽象类用来支持从持久型存储读取编辑日志数据;读取日志数据的类方法定义及实现;EditLogOutputStream.java---- 继承实现类:一个通用的抽象类用来支持从持久型存储记录编辑日志数据;写日志数据的类方法定义及实现;FileChecksumServlets.java---- 独立内存类:文件校验服务;文件较验 web 操作命令的代理实现;FileDataServlet.java---- 继承实现类:文件数据 web 操作命令的代理实现;FsckServlet.java---- 继承实现类:名字节点上 fsck 的 web 服务;文件系统检查 web 操作命令的代理实现;FSClusterStats.java---- 接口类:这个接口用于检索集群相关的统计;FSDirectory.java---- 继承实现类:类 FSDirectory 实现了存储文件系统的目录状态;文件目录结构的定义及实现;FSEditLog.java---- 独立内存类:FSEditLog 类实现了维护命名空间改动的日志记录;文件系统日志表的定义;FSImage.java---- 继承实现类:FSImage 实现对命名空间的编辑进行检查点操作和日志记录操作;文件系统的目录、文件、数据的索引及关系信息定义;FSInodeInfo.java---- 接口类:文件系统相关信息;FSNamesystem.java---- 继承实现类:FSNamesystem 类实现了为数据节点进行实际的记账工作;为数据节点命名的信息结构定义;FSPermissionChecker.java---- 独立内存类:实现用于检测文件系统权限的类;GetDelegationTokenServlet.java---- 继承实现类:获取委托令牌服务;GetImageServlet.java---- 继承实现类:这个类用于在命名系统中检索文件;通常用于第二名字节点来检索镜像以及为周期性的检测点进行编辑文件;Host2NodesMap.java---- 独立内存类:主机到节点的映射;INode.java---- 继承实现类:这个抽象类包含了文件和目录索引节点的通用字段;节点基础信息结构定义;INodeDirectory.java---- 继承实现类:表示目录的索引节点的类;INodeDirectoryWithQuota.java---- 继承实现类:有配额限制的目录索引节点类;INodeFile.java---- 继承实现类:目录索引节点文件;文件节点信息结构定义;INodeFileUnderConstruction.java---- 继承实现类:建立目录索引节点文件;在创建之下的文件节点信息结构定义;JspHelper.java---- 独立内存类:JSP 实现辅助类;LeaseExpiredException.java---- 继承实现类:创建的文件已过期异常;LeaseManager.java---- 独立内存类:LeaseManager 实现了写文件的租赁管理;这个类还提供了租赁恢复的有用的静态方法;契约信息结构定义及实现;ListPathsServlet.java---- 继承实现类:获取一个文件系统的元信息;MetaRecoveryContext.java---- 独立内存类:正在进行的名字节点恢复进程的上下文数据;NameCache.java---- 独立内存类:缓存经常使用的名称以便再用;NameNode.java---- 继承实现类:名字节点功能管理和实现类;名称节点的核心服务器类;NamenodeFsck.java---- 独立内存类:这个类提供了 DFS 卷基本的检测;名称节点的系统检测类;NameNodeMXBean.java---- 接口类:这个类是名字节点信息的 JMX 管理接口;NotReplicatedYetException.java---- 继承实现类:文件还未赋值异常类;PendingReplicationBlocks.java---- 独立内存类:这个类 PendingReplicationBlocks 实现了所有快复制的记录;正在复制数据块的信息表定义;PermissionChecker.java---- 独立内存类:这个类实现了执行权限检查操作;权限检查表结构定义及实现;RenewDelegationTokenServlet.java---- 继承实现类:续订令牌服务;SafeModeException.java---- 继承实现类:当名字节点处于安全模式的时候抛出这个异常;客户端不能够修改名字空间直到安全模式关闭;SecondaryNameNode.java---- 继承实现类:第二名字节点功能的管理和实现类;SerialNumberManager.java---- 独立内存类:为用户和组管理名称到序列号的映射;StreamFile.java---- 继承实现类:流文件类的实现;TransferFsImage.java---- 继承实现类:这个类实现了从名字节点获取一个指定的文件的功能;通过 http 方式来获取文件的镜像信息;UnderReplicatedBlocks.java---- 继承实现类:复制块的类的实现;复制完成后的块信息表定义;UnsupportedActionException.java---- 继承实现类:操作不支持的异常;UpgradeManagerNamenode.java---- 继承实现类:名字节点升级的管理;UpgradeObjectNamenode.java---- 抽象类:名字节点对象更新类;数据节点的更新运行在单独的线程上;升级名称节点的对象信息;
44 |
45 | hdfs.server.datanode (数据节点的实现)
46 |
47 | BlockAlreadyExistsException.java---- 继承实现类:目标块已经存在异常;BlockMetadataHeader.java---- 独立内存类:数据块头部结构定义及实现;BlockReceiver.java---- 继承实现类:这个类实现了接收一个块并写到自己的磁盘的功能,同时也可以复制它到另外一个磁盘;数据块接收容器信息结构及实现写入到盘中;接收一个数据块,并写到本地的磁盘,同时可能会拷贝到其他的节点上;BlockSender.java---- 继承实现类:从磁盘读取块,并发送它到接收的目的地;从磁盘中读数据块并发送到相应接收者;BlockTransferThrottler.java---- 独立内存类:调节数据块的传输;块传送时的调节参数配置表;DataBlockScanner.java---- 继承实现类:数据块的扫描工具实现;DataBlockScanner 拥有它单独的线程,能定时地从目前 DataNode 管理的数据块文件进行校验;其实最重要的方法就是 verifyBlock;DataBlockScanner 其他的辅助方法用于对 DataBlockScanner 管理的数据块文件信息进行增加 / 删除,排序操作;DataNode.java---- 继承实现类:数据节点的功能的管理和实现;数据块的核心管理器;DatanodeBlockInfo.java---- 独立内存类:这个类用于数据节点保持从数据块到它的元数据的映射的功能;建立块文件和其属于哪个 FSVolume 之间的映射关系;DataNodeMXBean.java---- 接口类:数据节点信息的 JMX 管理接口的实现;DataStorage.java---- 继承实现类:数据存储信息文件;DataXceiver.java---- 继承实现类:用于处理输入 / 输出数据流的线程;DataXceiverServer.java---- 继承实现类:用于接收和发送数据块的服务;FSDataset.java---- 继承实现类:FSDataset 类实现管理数据块集合的功能;FSDatasetAsyncDiskService.java---- 独立内存类:这个类实现了每个卷上多个线程池的容器,所以我们能够轻松地调度异步磁盘操作;为每个数据块目录创建一个线程池,并用作为一个线程组,池的最小值为 1,最大值为 4;当前版本,只有 delete 操作会将任务经过线程池调度来进行异步处理,读写操作都是调文件操作同步去执行的;FSDatasetInterface.java---- 接口类:这是一个接口,这个接口实现了一个数据节点存储块的底层存储;FSDatasetInterface 是 DataNode 对底局存储的抽象;SecureDataNodeStarter.java---- 继承实现类:这个类实现在一个安全的集群中启动一个数据节点,在启动前需要获得特权资源,并把它们递交给数据节点;UpgradeManagerDatanode.java---- 继承实现类:这个类实现了数据节点的升级管理;UpgradeObjectDatanode.java---- 抽象类:这个类是数据节点升级对象的基类;数据节点升级运行在一个单独的线程中;
48 |
49 | hdfs (客户端的实现)
50 |
51 | BlockReader.java---- 接口类:这个接口供本地和远程块读取共享;BlockReaderLocal.java---- 继承实现类:本地块读取;ByteRangeInputStream.java---- 抽象类:为了支持 HTTP 字节流,每次都需要建立一个针对 HTTP 服务的新的连接;ChecksumDistributedFileSystem.java---- 继承实现类:分布式文件系统检测;DFSClient.java---- 独立内存类:DFSClient 类能够连接到 Hadoop 文件系统并执行基本的文件操作;DFSConfigKeys.java---- 继承实现类:这个类包含了 HDFS 中使用的常数;DFSUtil.java---- 独立内存类:DFS 实用工具;DistributedFileSystem.java---- 继承实现类:DFS 系统的抽象文件系统实现;分布式文件系统功能的实现;HftpFileSystem.java---- 继承实现类:通过 HTTP 访问文件系统的协议的执行;采用 HTTP 协议来访问 HDFS 文件;HsftpFileSystem.java---- 继承实现类:通过 HTTPs 访问文件系统的协议的执行;采用 HTTPs 协议来访问 HDFS 文件;LeaseRenewer.java---- 独立内存类:更新租赁;
52 |
53 | hdfs.server.namenode.metrics (名字节点上度量数据的收集功能)
54 |
55 | FSNamesystemMBean.java---- 接口类:这个接口定义了获取一个名字节点的 FSNamesystem 状态的方法;取名称节点的文件状态信息;NameNodeInstrumentation.java---- 继承实现类:名字节点规范类;
56 |
57 | hdfs.server.datanode.metrics (数据节点上度量数据的收集功能)
58 |
59 | DataNodeInstrumentation.java---- 继承实现类:数据节点的一些规范;FSDatasetMBean.java---- 接口类:这个接口中定义了方法来获取一个数据节点的 FSDataset 的状态;数据集的职能定义;
60 |
61 | 3. 应用包
62 |
63 | 包括 hdfs.tools 和 hdfs.server.balancer,这两个包提供查询 HDFS 状态信息工具 dfsadmin、文件系统检查工具 fsck 和 HDFS 均衡器 balancer(通过 start-balancer.sh 启动)的实现。
64 |
65 | hdfs.tools (查询 HDFS 状态信息工具 dfsadmin、文件系统检查工具 fsck 的实现)
66 |
67 | DelegationTokenFetcher.java---- 独立内存类:这个类实现了从当前的名字节点获取 DelegationToken,并存储它到指定的文件当中;DFSAdmin.java---- 继承实现类:这个类实现了提供一些 DFS 访问管理;管理员命令的实现;DFSck.java---- 继承实现类:这个类实现了对 DFS 卷进行基本的检查;文件系统检查命令的实现;HDFSConcat.java---- 独立内存类:HDFS 串接;
68 |
69 | hdfs.server.balancer ( HDFS 均衡器 balancer 的实现)
70 |
71 | Balancer.java---- 继承实现类:负载均衡进程,各节点基于他来进行任务量的平衡;balance 是一个工具,用于当一些数据节点全部使用或者有新的节点加入集群的时候,来平衡 HDFS 集群上的磁盘空间使用率;
72 |
73 | 4.WebHDFS 相关包
74 |
75 | 包括 hdfs.web.resources、hdfs.server.namenode.metrics.web.resources、hdfs.server.datanode.web.resources 和 hdfs.web 共 4 个包。
76 |
77 | WebHDFS 是 HDFS 1.0 中引入的新功能,它提供了一个完整的、通过 HTTP 访问 HDFS 的机制。对比只读的 hftp 文件系统,WebHDFS 提供了 HTTP 上读写 HDFS 的能力,并在此基础上实现了访问 HDFS 的 C 客户端和用户空间文件系统(FUSE )。
78 |
--------------------------------------------------------------------------------
/20~分布式文件系统/HDFS/HDFS 编程.md:
--------------------------------------------------------------------------------
1 | ```java
2 | public class TestHDFSFile {
3 | private String localPath = "C:/D/JavaWorkSpace/bigdata/temp/";
4 | private String hdfsPath = "hdfs://192.168.2.6:9000/user/hadoop/temp/";
5 |
6 | public static void main(String[] args) throws Exception {
7 | // new TestHDFSFile().testUpload();
8 | // new TestHDFSFile().testCreate();
9 | //new TestHDFSFile().testRename();
10 | //new TestHDFSFile().testDel();
11 | //new TestHDFSFile().testgetModifyTime();
12 | //new TestHDFSFile().testExists();
13 | //new TestHDFSFile().testFileBlockLocation();
14 | new TestHDFSFile().testGetHostName();
15 | }
16 |
17 | // 上传本地文件到HDFS
18 | public void testUpload() throws Exception {
19 | Configuration conf = new Configuration();
20 |
21 | // conf.addResource(new Path(localPath + "core-site.xml"));
22 | FileSystem hdfs = FileSystem.get(conf);
23 | Path src = new Path(localPath + "file01.txt");
24 | Path dst = new Path(hdfsPath);
25 | hdfs.copyFromLocalFile(src, dst);
26 |
27 | System.out.println("Upload to " + conf.get("fs.default.name"));
28 | FileStatus files[] = hdfs.listStatus(dst);
29 | for (FileStatus file : files) {
30 | System.out.println(file.getPath());
31 | }
32 | }
33 |
34 | // 创建HDFS文件
35 | public void testCreate() throws Exception {
36 | Configuration conf = new Configuration();
37 | byte[] buff = "hello world!".getBytes();
38 |
39 | FileSystem hdfs = FileSystem.get(conf);
40 | Path dst = new Path(hdfsPath + "hello.txt");
41 | FSDataOutputStream outputStream = null;
42 | try {
43 | outputStream = hdfs.create(dst);
44 | outputStream.write(buff, 0, buff.length);
45 | } catch (Exception e) {
46 | e.printStackTrace();
47 | } finally {
48 | if (outputStream != null) {
49 | outputStream.close();
50 | }
51 | }
52 |
53 | FileStatus files[] = hdfs.listStatus(dst);
54 | for (FileStatus file : files) {
55 | System.out.println(file.getPath());
56 | }
57 | }
58 |
59 | // 重命名HDFS文件
60 | public void testRename() throws Exception {
61 | Configuration conf = new Configuration();
62 |
63 | FileSystem hdfs = FileSystem.get(conf);
64 | Path dst = new Path(hdfsPath);
65 |
66 | Path frpath = new Path(hdfsPath + "hello.txt");
67 | Path topath = new Path(hdfsPath + "hello2.txt");
68 |
69 | hdfs.rename(frpath, topath);
70 |
71 | FileStatus files[] = hdfs.listStatus(dst);
72 | for (FileStatus file : files) {
73 | System.out.println(file.getPath());
74 | }
75 | }
76 |
77 | // 刪除HDFS文件
78 | public void testDel() throws Exception {
79 | Configuration conf = new Configuration();
80 |
81 | FileSystem hdfs = FileSystem.get(conf);
82 | Path dst = new Path(hdfsPath);
83 |
84 | Path topath = new Path(hdfsPath + "hello2.txt");
85 |
86 | boolean ok = hdfs.delete(topath, false);
87 | System.out.println(ok ? "删除成功" : "删除失败");
88 |
89 | FileStatus files[] = hdfs.listStatus(dst);
90 | for (FileStatus file : files) {
91 | System.out.println(file.getPath());
92 | }
93 | }
94 |
95 | // 查看HDFS文件的最后修改时间
96 | public void testgetModifyTime() throws Exception {
97 | Configuration conf = new Configuration();
98 |
99 | FileSystem hdfs = FileSystem.get(conf);
100 | Path dst = new Path(hdfsPath);
101 |
102 | FileStatus files[] = hdfs.listStatus(dst);
103 | for (FileStatus file : files) {
104 | System.out.println(file.getPath() + "\t" + file.getModificationTime());
105 |
106 | System.out.println(
107 | file.getPath() + "\t" + new Date(file.getModificationTime())
108 | );
109 | }
110 | }
111 |
112 | // 查看HDFS文件是否存在
113 | public void testExists() throws Exception {
114 | Configuration conf = new Configuration();
115 |
116 | FileSystem hdfs = FileSystem.get(conf);
117 | Path dst = new Path(hdfsPath + "file01.txt");
118 |
119 | boolean ok = hdfs.exists(dst);
120 | System.out.println(ok ? "文件存在" : "文件不存在");
121 | }
122 |
123 | // 查看某个文件在HDFS集群的位置
124 | public void testFileBlockLocation() throws Exception {
125 | Configuration conf = new Configuration();
126 |
127 | FileSystem hdfs = FileSystem.get(conf);
128 | Path dst = new Path(hdfsPath + "file01.txt");
129 |
130 | FileStatus fileStatus = hdfs.getFileStatus(dst);
131 | BlockLocation[] blockLocations = hdfs.getFileBlockLocations(
132 | fileStatus,
133 | 0,
134 | fileStatus.getLen()
135 | );
136 | for (BlockLocation block : blockLocations) {
137 | System.out.println(
138 | Arrays.toString(block.getHosts()) +
139 | "\t" +
140 | Arrays.toString(block.getNames())
141 | );
142 | }
143 | }
144 |
145 | // 获取HDFS集群上所有节点名称
146 | public void testGetHostName() throws Exception {
147 | Configuration conf = new Configuration();
148 |
149 | DistributedFileSystem hdfs = (DistributedFileSystem) FileSystem.get(conf);
150 | DatanodeInfo[] dataNodeStats = hdfs.getDataNodeStats();
151 |
152 | for (DatanodeInfo dataNode : dataNodeStats) {
153 | System.out.println(dataNode.getHostName() + "\t" + dataNode.getName());
154 | }
155 | }
156 | }
157 | ```
158 |
--------------------------------------------------------------------------------
/20~分布式文件系统/HDFS/HDFS 读取原理.md:
--------------------------------------------------------------------------------
1 | # Introduction
2 |
3 | HDFS 开创性地设计出一套文件存储方式,即对文件分割后分别存放;HDFS 将要存储的大文件进行分割,分割后存放在既定的存储块(Block )中,并通过预先设定的优化处理,模式对存储的数据进行预处理,从而解决了大文件储存与计算的需求;一个 HDFS 集群包括两大部分,即 NameNode 与 DataNode。一般来说,一个集群中会有一个 NameNode 和多个 DataNode 共同工作;NameNode 是集群的主服务器,主要是用于对 HDFS 中所有的文件及内容数据进行维护,并不断读取记录集群中 DataNode 主机情况与工作状态,并通过读取与写入镜像日志文件的方式进行存储;DataNode 在 HDFS 集群中担任任务具体执行角色,是集群的工作节点。文件被分成若干个相同大小的数据块,分别存储在若干个 DataNode 上,DataNode 会定期向集群内 NameNode 发送自己的运行状态与存储内容,并根据 NameNode 发送的指令进行工作;NameNode 负责接受客户端发送过来的信息,然后将文件存储位置信息发送给提交请求的客户端,由客户端直接与 DataNode 进行联系,从而进行部分文件的运算与操作。Block 是 HDFS 的基本存储单元,默认大小是 64M;HDFS 还可以对已经存储的 Block 进行多副本备份,将每个 Block 至少复制到 3 个相互独立的硬件上,这样可以快速恢复损坏的数据;用户可以使用既定的 API 接口对 HDFS 中的文件进行操作;当客户端的读取操作发生错误的时候,客户端会向 NameNode 报告错误,并请求 NameNode 排除错误的 DataNode 后后重新根据距离排序,从而获得一个新的 DataNode 的读取路径。如果所有的 DataNode 都报告读取失败,那么整个任务就读取失败;对于写出操作过程中出现的问题,FSDataOutputStream 并不会立即关闭。客户端向 NameNode 报告错误信息,并直接向提供备份的 DataNode 中写入数据。备份 DataNode 被升级为首选 DataNode,并在其余 2 个 DataNode 中备份复制数据。NameNode 对错误的 DataNode 进行标记以便后续对其进行处理
4 |
5 | # Quick Start
6 |
7 | HDFS 基本命令
8 |
9 | hadoop fs -cmd
10 |
11 | cmd: 具体的操作,基本上与 UNIX 的命令行相同
12 |
13 | args: 参数
14 |
15 | HDFS 资源 URI 格式:
16 |
17 | scheme://authority/path
18 |
19 | scheme:协议名,file 或 hdfs
20 |
21 | authority:namenode 主机名
22 |
23 | path:路径
24 |
25 | 示例:hdfs://localhost:9000/user/chunk/test.txt
26 |
27 | 假设已经在 core-site.xml 里配置了 fs.default.name=hdfs://localhost:9000,则仅使用 /user/chunk/test.txt 即可。
28 |
29 | hdfs 默认工作目录为 /user/$USER,$USER 是当前的登录用户名。
30 |
31 | HDFS 命令示例:
32 |
33 | hadoop fs -mkdir /user/trunk
34 |
35 | hadoop fs -ls /user
36 |
37 | hadoop fs -lsr /user ( 递归的 )
38 |
39 | hadoop fs -put test.txt /user/trunk
40 |
41 | hadoop fs -put test.txt . ( 复制到 hdfs 当前目录下,首先要创建当前目录 )
42 |
43 | hadoop fs -get /user/trunk/test.txt . ( 复制到本地当前目录下 )
44 |
45 | hadoop fs -cat /user/trunk/test.txt
46 |
47 | hadoop fs -tail /user/trunk/test.txt ( 查看最后 1000 字节 )
48 |
49 | hadoop fs -rm /user/trunk/test.txt
50 |
51 | hadoop fs -help ls ( 查看 ls 命令的帮助文档 )
52 |
53 | 图中的 2:文件备份数量,因为采用了两台机器的全分布模式,所以此处为 2. 对于目录,使用 -。
54 |
55 | 在 put 的时候遇到问题:
56 |
57 | ## Configuration
58 |
59 | ## Read File
60 |
61 | # 存储结构
62 |
63 | ## 行存储
64 |
65 | HDFS 块内行存储的例子: 
66 |
67 | 基于 Hadoop 系统行存储结构的优点在于快速数据加载和动态负载的高适应能力,这是因为行存储保证了相同记录的所有域都在同一个集群节点,即同一个 HDFS 块。不过,行存储的缺点也是显而易见的,例如它不能支持快速查询处理,因为当查询仅仅针对多列表中的少数几列时,它不能跳过不必要的列读取;此 外,由于混合着不同数据值的列,行存储不易获得一个极高的压缩比,即空间利用率不易大幅提高。
68 |
69 | ## 列存储
70 |
71 |  在 HDFS 上按照列组存储表格的例子。在这个例子中,列 A 和列 B 存储在同一列组,而列 C 和列 D 分别存储在单独的列组。查询时列存储能够避免读不必要的列,并且压缩一个列中的相似数据能够达到较高的压缩比。然而,由于元组重构的较高开销,它并不能提供基于 Hadoop 系统的快速查询处理。列存储不能保证同一 记录的所有域都存储在同一集群节点,行存储的例子中,记录的 4 个域存储在位于不同节点的 3 个 HDFS 块中。因此,记录的重构将导致通过集群节点网络的大 量数据传输。尽管预先分组后,多个列在一起能够减少开销,但是对于高度动态的负载模式,它并不具备很好的适应性。
72 |
73 | # 数据读取
74 |
75 | hdfs 读取数据流程图:  1、首先调用 FileSystem 对象的 open 方法,其实获取的是一个 DistributedFileSystem 的实例。2、DistributedFileSystem 通过 RPC( 远程过程调用 ) 获得文件的第一批 block 的 locations,同一 block 按照重复数会返回多个 locations,这些 locations 按照 hadoop 拓扑结构排序,距离客户端近的排在前面。3、前两步会返回一个 FSDataInputStream 对象,该对象会被封装成 DFSInputStream 对象,DFSInputStream 可以方便的管理 datanode 和 namenode 数据流。客户端调用 read 方 法,DFSInputStream 就会找出离客户端最近的 datanode 并连接 datanode。4、数据从 datanode 源源不断的流向客户端。5、如果第一个 block 块的数据读完了,就会关闭指向第一个 block 块的 datanode 连接,接着读取下一个 block 块。这些操作对客户端来说是透明的,从客户端的角度来看只是读一个持续不断的流。6、如果第一批 block 都读完了,DFSInputStream 就会去 namenode 拿下一批 blocks 的 location,然后继续读,如果所有的 block 块都读完,这时就会关闭掉所有的流。
76 |
77 | # 数据写入
78 |
79 | hdfs 写数据流程:  1. 客户端通过调用 DistributedFileSystem 的 create 方法,创建一个新的文件。2.DistributedFileSystem 通过 RPC(远程过程调用)调用 NameNode,去创建一个没有 blocks 关联的新文件。创建前,NameNode 会做各种校验,比如文件是否存在,客户端有无权限去创建等。如果校验通过,NameNode 就会记录下新文件,否则就会抛出 IO 异常。3. 前两步结束后会返回 FSDataOutputStream 的对象,和读文件的时候相似,FSDataOutputStream 被封装成 DFSOutputStream,DFSOutputStream 可以协调 NameNode 和 DataNode。客户端开始写数据到 DFSOutputStream,DFSOutputStream 会把数据切成一个个小 packet,然后排成队列 data queue。4.DataStreamer 会去处理接受 data queue,它先问询 NameNode 这个新的 block 最适合存储的在哪几个 DataNode 里,比如重复数是 3,那么就找到 3 个最适合的 DataNode,把它们排成一个 pipeline。DataStreamer 把 packet 按队列输出到管道的第一个 DataNode 中,第一个 DataNode 又把 packet 输出到第二个 DataNode 中,以此类推。5.DFSOutputStream 还有一个队列叫 ack queue,也是由 packet 组成,等待 DataNode 的收到响应,当 pipeline 中的所有 DataNode 都表示已经收到的时候,这时 akc queue 才会把对应的 packet 包移除掉。6. 客户端完成写数据后,调用 close 方法关闭写入流。7.DataStreamer 把剩余的包都刷到 pipeline 里,然后等待 ack 信息,收到最后一个 ack 后,通知 DataNode 把文件标示为已完成。
80 |
81 | 
82 |
83 | # NameNode HA
84 |
85 | NameNode HA 架构如下: 
86 |
87 | - Active NameNode 和 Standby NameNode:
88 |
89 | 两台 NameNode 形成互备,一台处于 Active 状态,为主 NameNode,另外一台处于 Standby 状态,为备 NameNode,只有主 NameNode 才能对外提供读写服务。
90 |
91 | - 主备切换控制器 ZKFailoverController:
92 |
93 | ZKFailoverController 作为独立的进程运行,对 NameNode 的主备切换进行总体控制。ZKFailoverController 能及时检测到 NameNode 的健康状况,在主 NameNode 故障时借助 Zookeeper 实现自动的主备选举和切换。
94 |
95 | - Zookeeper 集群:
96 |
97 | 为主备切换控制器提供主备选举支持。
98 |
99 | - 共享存储系统:
100 |
101 | 共享存储系统是实现 NameNode 的高可用最为关键的部分,共享存储系统保存了 NameNode 在运行过程中所产生的 HDFS 的元数据。主 NameNode 和备用 NameNode 通过共享存储系统实现元数据同步。在进行主备切换的时候,新的主 NameNode 在确认元数据完全同步之后才能继续对外提供服务。
102 |
--------------------------------------------------------------------------------
/20~分布式文件系统/HDFS/README.md:
--------------------------------------------------------------------------------
1 | # HDFS
2 |
3 | 
4 |
--------------------------------------------------------------------------------
/20~分布式文件系统/README.md:
--------------------------------------------------------------------------------
1 | # 分布式文件系统
2 |
--------------------------------------------------------------------------------
/30~对象存储/Haystack.md:
--------------------------------------------------------------------------------
1 | # Haystack
2 |
3 | # Links
4 |
5 | - https://studygolang.com/articles/4256
6 |
--------------------------------------------------------------------------------
/30~对象存储/README.md:
--------------------------------------------------------------------------------
1 | # 对象存储
2 |
--------------------------------------------------------------------------------
/30~对象存储/元数据管理.md:
--------------------------------------------------------------------------------
1 | # 元数据管理
2 |
3 | 元数据的目录树结构转化成基于 LSMT 的 KV,核心思想是把树的父子节点关系转变成 parentInode+currentPath 到 Inode 的映射。分布式的 KV 是由多个 partition 组成,单个文件系统的所有元数据放在某个 partition 内。架构上支持动态分裂,如果某个文件成为热点,按照目录动态分裂,并调度到不同机器的 partition 上。
4 |
5 | 
6 |
--------------------------------------------------------------------------------
/40~区块链/README.link:
--------------------------------------------------------------------------------
1 | https://github.com/wx-chevalier/Blockchain-Notes
--------------------------------------------------------------------------------
/INTRODUCTION.md:
--------------------------------------------------------------------------------
1 | # 本篇导读
2 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
2 | Public License
3 |
4 | By exercising the Licensed Rights (defined below), You accept and agree
5 | to be bound by the terms and conditions of this Creative Commons
6 | Attribution-NonCommercial-ShareAlike 4.0 International Public License
7 | ("Public License"). To the extent this Public License may be
8 | interpreted as a contract, You are granted the Licensed Rights in
9 | consideration of Your acceptance of these terms and conditions, and the
10 | Licensor grants You such rights in consideration of benefits the
11 | Licensor receives from making the Licensed Material available under
12 | these terms and conditions.
13 |
14 |
15 | Section 1 -- Definitions.
16 |
17 | a. Adapted Material means material subject to Copyright and Similar
18 | Rights that is derived from or based upon the Licensed Material
19 | and in which the Licensed Material is translated, altered,
20 | arranged, transformed, or otherwise modified in a manner requiring
21 | permission under the Copyright and Similar Rights held by the
22 | Licensor. For purposes of this Public License, where the Licensed
23 | Material is a musical work, performance, or sound recording,
24 | Adapted Material is always produced where the Licensed Material is
25 | synched in timed relation with a moving image.
26 |
27 | b. Adapter's License means the license You apply to Your Copyright
28 | and Similar Rights in Your contributions to Adapted Material in
29 | accordance with the terms and conditions of this Public License.
30 |
31 | c. BY-NC-SA Compatible License means a license listed at
32 | creativecommons.org/compatiblelicenses, approved by Creative
33 | Commons as essentially the equivalent of this Public License.
34 |
35 | d. Copyright and Similar Rights means copyright and/or similar rights
36 | closely related to copyright including, without limitation,
37 | performance, broadcast, sound recording, and Sui Generis Database
38 | Rights, without regard to how the rights are labeled or
39 | categorized. For purposes of this Public License, the rights
40 | specified in Section 2(b)(1)-(2) are not Copyright and Similar
41 | Rights.
42 |
43 | e. Effective Technological Measures means those measures that, in the
44 | absence of proper authority, may not be circumvented under laws
45 | fulfilling obligations under Article 11 of the WIPO Copyright
46 | Treaty adopted on December 20, 1996, and/or similar international
47 | agreements.
48 |
49 | f. Exceptions and Limitations means fair use, fair dealing, and/or
50 | any other exception or limitation to Copyright and Similar Rights
51 | that applies to Your use of the Licensed Material.
52 |
53 | g. License Elements means the license attributes listed in the name
54 | of a Creative Commons Public License. The License Elements of this
55 | Public License are Attribution, NonCommercial, and ShareAlike.
56 |
57 | h. Licensed Material means the artistic or literary work, database,
58 | or other material to which the Licensor applied this Public
59 | License.
60 |
61 | i. Licensed Rights means the rights granted to You subject to the
62 | terms and conditions of this Public License, which are limited to
63 | all Copyright and Similar Rights that apply to Your use of the
64 | Licensed Material and that the Licensor has authority to license.
65 |
66 | j. Licensor means the individual(s) or entity(ies) granting rights
67 | under this Public License.
68 |
69 | k. NonCommercial means not primarily intended for or directed towards
70 | commercial advantage or monetary compensation. For purposes of
71 | this Public License, the exchange of the Licensed Material for
72 | other material subject to Copyright and Similar Rights by digital
73 | file-sharing or similar means is NonCommercial provided there is
74 | no payment of monetary compensation in connection with the
75 | exchange.
76 |
77 | l. Share means to provide material to the public by any means or
78 | process that requires permission under the Licensed Rights, such
79 | as reproduction, public display, public performance, distribution,
80 | dissemination, communication, or importation, and to make material
81 | available to the public including in ways that members of the
82 | public may access the material from a place and at a time
83 | individually chosen by them.
84 |
85 | m. Sui Generis Database Rights means rights other than copyright
86 | resulting from Directive 96/9/EC of the European Parliament and of
87 | the Council of 11 March 1996 on the legal protection of databases,
88 | as amended and/or succeeded, as well as other essentially
89 | equivalent rights anywhere in the world.
90 |
91 | n. You means the individual or entity exercising the Licensed Rights
92 | under this Public License. Your has a corresponding meaning.
93 |
94 |
95 | Section 2 -- Scope.
96 |
97 | a. License grant.
98 |
99 | 1. Subject to the terms and conditions of this Public License,
100 | the Licensor hereby grants You a worldwide, royalty-free,
101 | non-sublicensable, non-exclusive, irrevocable license to
102 | exercise the Licensed Rights in the Licensed Material to:
103 |
104 | a. reproduce and Share the Licensed Material, in whole or
105 | in part, for NonCommercial purposes only; and
106 |
107 | b. produce, reproduce, and Share Adapted Material for
108 | NonCommercial purposes only.
109 |
110 | 2. Exceptions and Limitations. For the avoidance of doubt, where
111 | Exceptions and Limitations apply to Your use, this Public
112 | License does not apply, and You do not need to comply with
113 | its terms and conditions.
114 |
115 | 3. Term. The term of this Public License is specified in Section
116 | 6(a).
117 |
118 | 4. Media and formats; technical modifications allowed. The
119 | Licensor authorizes You to exercise the Licensed Rights in
120 | all media and formats whether now known or hereafter created,
121 | and to make technical modifications necessary to do so. The
122 | Licensor waives and/or agrees not to assert any right or
123 | authority to forbid You from making technical modifications
124 | necessary to exercise the Licensed Rights, including
125 | technical modifications necessary to circumvent Effective
126 | Technological Measures. For purposes of this Public License,
127 | simply making modifications authorized by this Section 2(a)
128 | (4) never produces Adapted Material.
129 |
130 | 5. Downstream recipients.
131 |
132 | a. Offer from the Licensor -- Licensed Material. Every
133 | recipient of the Licensed Material automatically
134 | receives an offer from the Licensor to exercise the
135 | Licensed Rights under the terms and conditions of this
136 | Public License.
137 |
138 | b. Additional offer from the Licensor -- Adapted Material.
139 | Every recipient of Adapted Material from You
140 | automatically receives an offer from the Licensor to
141 | exercise the Licensed Rights in the Adapted Material
142 | under the conditions of the Adapter's License You apply.
143 |
144 | c. No downstream restrictions. You may not offer or impose
145 | any additional or different terms or conditions on, or
146 | apply any Effective Technological Measures to, the
147 | Licensed Material if doing so restricts exercise of the
148 | Licensed Rights by any recipient of the Licensed
149 | Material.
150 |
151 | 6. No endorsement. Nothing in this Public License constitutes or
152 | may be construed as permission to assert or imply that You
153 | are, or that Your use of the Licensed Material is, connected
154 | with, or sponsored, endorsed, or granted official status by,
155 | the Licensor or others designated to receive attribution as
156 | provided in Section 3(a)(1)(A)(i).
157 |
158 | b. Other rights.
159 |
160 | 1. Moral rights, such as the right of integrity, are not
161 | licensed under this Public License, nor are publicity,
162 | privacy, and/or other similar personality rights; however, to
163 | the extent possible, the Licensor waives and/or agrees not to
164 | assert any such rights held by the Licensor to the limited
165 | extent necessary to allow You to exercise the Licensed
166 | Rights, but not otherwise.
167 |
168 | 2. Patent and trademark rights are not licensed under this
169 | Public License.
170 |
171 | 3. To the extent possible, the Licensor waives any right to
172 | collect royalties from You for the exercise of the Licensed
173 | Rights, whether directly or through a collecting society
174 | under any voluntary or waivable statutory or compulsory
175 | licensing scheme. In all other cases the Licensor expressly
176 | reserves any right to collect such royalties, including when
177 | the Licensed Material is used other than for NonCommercial
178 | purposes.
179 |
180 |
181 | Section 3 -- License Conditions.
182 |
183 | Your exercise of the Licensed Rights is expressly made subject to the
184 | following conditions.
185 |
186 | a. Attribution.
187 |
188 | 1. If You Share the Licensed Material (including in modified
189 | form), You must:
190 |
191 | a. retain the following if it is supplied by the Licensor
192 | with the Licensed Material:
193 |
194 | i. identification of the creator(s) of the Licensed
195 | Material and any others designated to receive
196 | attribution, in any reasonable manner requested by
197 | the Licensor (including by pseudonym if
198 | designated);
199 |
200 | ii. a copyright notice;
201 |
202 | iii. a notice that refers to this Public License;
203 |
204 | iv. a notice that refers to the disclaimer of
205 | warranties;
206 |
207 | v. a URI or hyperlink to the Licensed Material to the
208 | extent reasonably practicable;
209 |
210 | b. indicate if You modified the Licensed Material and
211 | retain an indication of any previous modifications; and
212 |
213 | c. indicate the Licensed Material is licensed under this
214 | Public License, and include the text of, or the URI or
215 | hyperlink to, this Public License.
216 |
217 | 2. You may satisfy the conditions in Section 3(a)(1) in any
218 | reasonable manner based on the medium, means, and context in
219 | which You Share the Licensed Material. For example, it may be
220 | reasonable to satisfy the conditions by providing a URI or
221 | hyperlink to a resource that includes the required
222 | information.
223 | 3. If requested by the Licensor, You must remove any of the
224 | information required by Section 3(a)(1)(A) to the extent
225 | reasonably practicable.
226 |
227 | b. ShareAlike.
228 |
229 | In addition to the conditions in Section 3(a), if You Share
230 | Adapted Material You produce, the following conditions also apply.
231 |
232 | 1. The Adapter's License You apply must be a Creative Commons
233 | license with the same License Elements, this version or
234 | later, or a BY-NC-SA Compatible License.
235 |
236 | 2. You must include the text of, or the URI or hyperlink to, the
237 | Adapter's License You apply. You may satisfy this condition
238 | in any reasonable manner based on the medium, means, and
239 | context in which You Share Adapted Material.
240 |
241 | 3. You may not offer or impose any additional or different terms
242 | or conditions on, or apply any Effective Technological
243 | Measures to, Adapted Material that restrict exercise of the
244 | rights granted under the Adapter's License You apply.
245 |
246 |
247 | Section 4 -- Sui Generis Database Rights.
248 |
249 | Where the Licensed Rights include Sui Generis Database Rights that
250 | apply to Your use of the Licensed Material:
251 |
252 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right
253 | to extract, reuse, reproduce, and Share all or a substantial
254 | portion of the contents of the database for NonCommercial purposes
255 | only;
256 |
257 | b. if You include all or a substantial portion of the database
258 | contents in a database in which You have Sui Generis Database
259 | Rights, then the database in which You have Sui Generis Database
260 | Rights (but not its individual contents) is Adapted Material,
261 | including for purposes of Section 3(b); and
262 |
263 | c. You must comply with the conditions in Section 3(a) if You Share
264 | all or a substantial portion of the contents of the database.
265 |
266 | For the avoidance of doubt, this Section 4 supplements and does not
267 | replace Your obligations under this Public License where the Licensed
268 | Rights include other Copyright and Similar Rights.
269 |
270 |
271 | Section 5 -- Disclaimer of Warranties and Limitation of Liability.
272 |
273 | a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
274 | EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
275 | AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
276 | ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
277 | IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
278 | WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
279 | PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
280 | ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
281 | KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
282 | ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
283 |
284 | b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
285 | TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
286 | NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
287 | INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
288 | COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
289 | USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
290 | ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
291 | DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
292 | IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
293 |
294 | c. The disclaimer of warranties and limitation of liability provided
295 | above shall be interpreted in a manner that, to the extent
296 | possible, most closely approximates an absolute disclaimer and
297 | waiver of all liability.
298 |
299 |
300 | Section 6 -- Term and Termination.
301 |
302 | a. This Public License applies for the term of the Copyright and
303 | Similar Rights licensed here. However, if You fail to comply with
304 | this Public License, then Your rights under this Public License
305 | terminate automatically.
306 |
307 | b. Where Your right to use the Licensed Material has terminated under
308 | Section 6(a), it reinstates:
309 |
310 | 1. automatically as of the date the violation is cured, provided
311 | it is cured within 30 days of Your discovery of the
312 | violation; or
313 |
314 | 2. upon express reinstatement by the Licensor.
315 |
316 | For the avoidance of doubt, this Section 6(b) does not affect any
317 | right the Licensor may have to seek remedies for Your violations
318 | of this Public License.
319 |
320 | c. For the avoidance of doubt, the Licensor may also offer the
321 | Licensed Material under separate terms or conditions or stop
322 | distributing the Licensed Material at any time; however, doing so
323 | will not terminate this Public License.
324 |
325 | d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
326 | License.
327 |
328 |
329 | Section 7 -- Other Terms and Conditions.
330 |
331 | a. The Licensor shall not be bound by any additional or different
332 | terms or conditions communicated by You unless expressly agreed.
333 |
334 | b. Any arrangements, understandings, or agreements regarding the
335 | Licensed Material not stated herein are separate from and
336 | independent of the terms and conditions of this Public License.
337 |
338 |
339 | Section 8 -- Interpretation.
340 |
341 | a. For the avoidance of doubt, this Public License does not, and
342 | shall not be interpreted to, reduce, limit, restrict, or impose
343 | conditions on any use of the Licensed Material that could lawfully
344 | be made without permission under this Public License.
345 |
346 | b. To the extent possible, if any provision of this Public License is
347 | deemed unenforceable, it shall be automatically reformed to the
348 | minimum extent necessary to make it enforceable. If the provision
349 | cannot be reformed, it shall be severed from this Public License
350 | without affecting the enforceability of the remaining terms and
351 | conditions.
352 |
353 | c. No term or condition of this Public License will be waived and no
354 | failure to comply consented to unless expressly agreed to by the
355 | Licensor.
356 |
357 | d. Nothing in this Public License constitutes or may be interpreted
358 | as a limitation upon, or waiver of, any privileges and immunities
359 | that apply to the Licensor or You, including from the legal
360 | processes of any jurisdiction or authority.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [![Contributors][contributors-shield]][contributors-url]
2 | [![Forks][forks-shield]][forks-url]
3 | [![Stargazers][stars-shield]][stars-url]
4 | [![Issues][issues-shield]][issues-url]
5 | [][license-url]
6 |
7 |
8 |
9 |