- 浏览: 83673 次
- 性别:
- 来自: 郑州
文章分类
- 全部博客 (69)
- java (28)
- linux (6)
- redis (4)
- C# (3)
- 架构 (10)
- java ee (1)
- web (1)
- 操作系统 (7)
- sqlserver (1)
- android (2)
- Hadoop (12)
- 大数据 (21)
- 分布式 事务 消息 (10)
- linux mysql (1)
- 数据库 (3)
- 关于hadoop之bootshell使用 (2)
- 关于hbase---HTableInterfaceFactory (1)
- Spring (3)
- Hbase (5)
- jstorm (10)
- nginx (1)
- 分布式 (1)
- 区块链 (3)
- dubbo (1)
- nacos (1)
- 阿里 (1)
- go (3)
- 缓存 (1)
- memcached (1)
- ssdb (1)
- 源码 (1)
最新评论
-
想个可以用的名字:
楼主,能不能给发一份源代码,1300246542@qqq.co ...
spring+websocket的使用 -
wahahachuang5:
web实时推送技术使用越来越广泛,但是自己开发又太麻烦了,我觉 ...
websocket -
dalan_123:
前提是你用的是spring mvc 才需要加的1、在web.x ...
spring+websocket的使用 -
string2020:
CharacterEncodingFilter这个filter ...
spring+websocket的使用
一、源码如下
/**
* Synchronization manager handling the tracking of Hbase resources (specifically tables). Used either manually or through {@link HbaseInterceptor} to bind a table to the thread.
* Each subsequent call made through {@link HbaseTemplate} is aware of the table bound and will use it instead of retrieving a new instance.
* HbaseSynchronizationManager是作为hbase资源同步管理跟踪(特别是表);可以通过手动管理;也可以结合HbaseInterceptor将table绑定thread
* 随后的操作可以通过表绑定,而不是再重新创建新的对象
* @author Costin Leau
*/
public abstract class HbaseSynchronizationManager {
private static final Log logger = LogFactory.getLog(HbaseSynchronizationManager.class);
// 创建ThreadLocal 用来存放tableName与Hbase table之间的映射内容
private static final ThreadLocal<Map<String, HTableInterface>> resources = new NamedThreadLocal<Map<String, HTableInterface>>("Bound resources");
/**
* Checks whether any resource is bound for the given key.
* 检查指定的table name 判断与其对应的hbase table resource 是否存在
* @param key key to check
* @return whether or not a resource is bound for the given key
*/
public static boolean hasResource(Object key) {
Object value = doGetResource(key);
return (value != null);
}
/**
* Returns the resource (table) associated with the given key.
* 根据指定的table name 返回对应的hbase table 内容
* @param key association key
* @return associated resource (table)
*/
public static HTableInterface getResource(Object key) {
return doGetResource(key);
}
/**
* Actually checks the value of the resource that is bound for the given key.
* 根据table name 返回对应的hbase table 内容
*/
private static HTableInterface doGetResource(Object actualKey) {
Map<String, HTableInterface> tables = resources.get();
if (tables == null) {
return null;
}
return tables.get(actualKey);
}
/**
* Binds the given resource for the given key to the current thread.
* 将key对应的resources添加到map中,并绑定到当前线程
* @param key the key to bind the value to (usually the resource factory)
* @param value the value to bind (usually the active resource object)
* @throws IllegalStateException if there is already a value bound to the thread
* @see ResourceTransactionManager#getResourceFactory()
*/
public static void bindResource(String key, HTableInterface value) throws IllegalStateException {
Assert.notNull(value, "Value must not be null");
// 判断当前线程中是否包含映射内容
// 若是存在 直接添加新内容
// 若不存在 则先创建map 再将对应的东西 再将map绑定到当前的线程 添加具体内容
Map<String, HTableInterface> map = resources.get();
// set ThreadLocal Map if none found
if (map == null) {
map = new LinkedHashMap<String, HTableInterface>();
resources.set(map);
}
HTableInterface oldValue = map.put(key, value);
if (oldValue != null) {
throw new IllegalStateException("Already value [" + oldValue + "] for key [" + key
+ "] bound to thread [" + Thread.currentThread().getName() + "]");
}
if (logger.isTraceEnabled()) {
logger.trace("Bound value [" + value + "] for key [" + key + "] to thread ["
+ Thread.currentThread().getName() + "]");
}
}
/**
* Unbinds a resource for the given key from the current thread.
* @param key the key to unbind (usually the resource factory)
* @return the previously bound value (usually the active resource object)
* @throws IllegalStateException if there is no value bound to the thread
* @see ResourceTransactionManager#getResourceFactory()
*/
public static HTableInterface unbindResource(String key) throws IllegalStateException {
HTableInterface value = doUnbindResource(key);
if (value == null) {
throw new IllegalStateException("No value for key [" + key + "] bound to thread ["
+ Thread.currentThread().getName() + "]");
}
return value;
}
/**
* Unbinds a resource for the given key from the current thread.
*
* @param key the key to unbind (usually the resource factory)
* @return the previously bound value, or <code>null</code> if none bound
*/
public static Object unbindResourceIfPossible(Object key) {
return doUnbindResource(key);
}
/**
* Actually remove the value of the resource that is bound for the given key.
* 根据指定key(table name) 完成将指定的资源 移除当前线程
*/
private static HTableInterface doUnbindResource(Object actualKey) {
Map<String, HTableInterface> map = resources.get();
if (map == null) {
return null;
}
HTableInterface value = map.remove(actualKey);
// 在解除指定的table name所关联的资源后,防止对应的map不能为空 进行map判断
// Remove entire ThreadLocal if empty...
if (map.isEmpty()) {
resources.remove();
}
if (value != null && logger.isTraceEnabled()) {
logger.trace("Removed value [" + value + "] for key [" + actualKey + "] from thread ["
+ Thread.currentThread().getName() + "]");
}
return value;
}
/**
* Returns the bound tables (by name).
*
* @return names of bound tables
*
*/
public static Set<String> getTableNames() {
Map<String, HTableInterface> map = resources.get();
if (map != null && !map.isEmpty()) {
return Collections.unmodifiableSet(map.keySet());
}
return Collections.emptySet();
}
}
/**
* Synchronization manager handling the tracking of Hbase resources (specifically tables). Used either manually or through {@link HbaseInterceptor} to bind a table to the thread.
* Each subsequent call made through {@link HbaseTemplate} is aware of the table bound and will use it instead of retrieving a new instance.
* HbaseSynchronizationManager是作为hbase资源同步管理跟踪(特别是表);可以通过手动管理;也可以结合HbaseInterceptor将table绑定thread
* 随后的操作可以通过表绑定,而不是再重新创建新的对象
* @author Costin Leau
*/
public abstract class HbaseSynchronizationManager {
private static final Log logger = LogFactory.getLog(HbaseSynchronizationManager.class);
// 创建ThreadLocal 用来存放tableName与Hbase table之间的映射内容
private static final ThreadLocal<Map<String, HTableInterface>> resources = new NamedThreadLocal<Map<String, HTableInterface>>("Bound resources");
/**
* Checks whether any resource is bound for the given key.
* 检查指定的table name 判断与其对应的hbase table resource 是否存在
* @param key key to check
* @return whether or not a resource is bound for the given key
*/
public static boolean hasResource(Object key) {
Object value = doGetResource(key);
return (value != null);
}
/**
* Returns the resource (table) associated with the given key.
* 根据指定的table name 返回对应的hbase table 内容
* @param key association key
* @return associated resource (table)
*/
public static HTableInterface getResource(Object key) {
return doGetResource(key);
}
/**
* Actually checks the value of the resource that is bound for the given key.
* 根据table name 返回对应的hbase table 内容
*/
private static HTableInterface doGetResource(Object actualKey) {
Map<String, HTableInterface> tables = resources.get();
if (tables == null) {
return null;
}
return tables.get(actualKey);
}
/**
* Binds the given resource for the given key to the current thread.
* 将key对应的resources添加到map中,并绑定到当前线程
* @param key the key to bind the value to (usually the resource factory)
* @param value the value to bind (usually the active resource object)
* @throws IllegalStateException if there is already a value bound to the thread
* @see ResourceTransactionManager#getResourceFactory()
*/
public static void bindResource(String key, HTableInterface value) throws IllegalStateException {
Assert.notNull(value, "Value must not be null");
// 判断当前线程中是否包含映射内容
// 若是存在 直接添加新内容
// 若不存在 则先创建map 再将对应的东西 再将map绑定到当前的线程 添加具体内容
Map<String, HTableInterface> map = resources.get();
// set ThreadLocal Map if none found
if (map == null) {
map = new LinkedHashMap<String, HTableInterface>();
resources.set(map);
}
HTableInterface oldValue = map.put(key, value);
if (oldValue != null) {
throw new IllegalStateException("Already value [" + oldValue + "] for key [" + key
+ "] bound to thread [" + Thread.currentThread().getName() + "]");
}
if (logger.isTraceEnabled()) {
logger.trace("Bound value [" + value + "] for key [" + key + "] to thread ["
+ Thread.currentThread().getName() + "]");
}
}
/**
* Unbinds a resource for the given key from the current thread.
* @param key the key to unbind (usually the resource factory)
* @return the previously bound value (usually the active resource object)
* @throws IllegalStateException if there is no value bound to the thread
* @see ResourceTransactionManager#getResourceFactory()
*/
public static HTableInterface unbindResource(String key) throws IllegalStateException {
HTableInterface value = doUnbindResource(key);
if (value == null) {
throw new IllegalStateException("No value for key [" + key + "] bound to thread ["
+ Thread.currentThread().getName() + "]");
}
return value;
}
/**
* Unbinds a resource for the given key from the current thread.
*
* @param key the key to unbind (usually the resource factory)
* @return the previously bound value, or <code>null</code> if none bound
*/
public static Object unbindResourceIfPossible(Object key) {
return doUnbindResource(key);
}
/**
* Actually remove the value of the resource that is bound for the given key.
* 根据指定key(table name) 完成将指定的资源 移除当前线程
*/
private static HTableInterface doUnbindResource(Object actualKey) {
Map<String, HTableInterface> map = resources.get();
if (map == null) {
return null;
}
HTableInterface value = map.remove(actualKey);
// 在解除指定的table name所关联的资源后,防止对应的map不能为空 进行map判断
// Remove entire ThreadLocal if empty...
if (map.isEmpty()) {
resources.remove();
}
if (value != null && logger.isTraceEnabled()) {
logger.trace("Removed value [" + value + "] for key [" + actualKey + "] from thread ["
+ Thread.currentThread().getName() + "]");
}
return value;
}
/**
* Returns the bound tables (by name).
*
* @return names of bound tables
*
*/
public static Set<String> getTableNames() {
Map<String, HTableInterface> map = resources.get();
if (map != null && !map.isEmpty()) {
return Collections.unmodifiableSet(map.keySet());
}
return Collections.emptySet();
}
}
发表评论
-
nacos单机源码调试
2018-12-17 11:35 1167首先从github上获取对应的源码Nacos源码git cl ... -
jstorm源码之TransactionalState
2016-03-21 19:31 841一、作用 主要是通过结合zookeeper,在zookee ... -
jstorm源码之RotatingTransactionalState
2016-03-21 19:29 525一、作用 构建一个Rotationg transacti ... -
jstorm源码之PartitionedTridentSpoutExecutor
2016-03-21 19:28 842一、作用 Partition Spout对应的exec ... -
jstorm源码之 RichSpoutBatchExecutor
2016-03-21 19:28 0一、作用 RichSpoutBatchExecutor是IRi ... -
jstorm源码之RotatingMap
2016-03-21 19:27 831一、作用 基于LinkedList + HashM ... -
jstorm源码之 RichSpoutBatchExecutor
2016-03-21 19:24 562一、作用 RichSpoutBatchExecutor是IRi ... -
jstorm源码之TridentTopology
2016-03-16 18:12 2315在jstorm中对应TridentTopology的源码如下, ... -
jstorm操作命令
2016-03-15 18:04 2680启动ZOOPKEEPER zkServer.sh start ... -
JStorm之Supervisor简介
2016-03-15 18:02 1180一、简介Supervisor是JStorm中的工作节点,类似 ... -
JStorm介绍
2016-03-15 17:56 880一、简介Storm是开源的 ... -
mycat的使用---sqlserver和mysql
2016-01-11 14:33 8544数据库中间件mycat的使 ... -
jstorm安装
2015-12-03 19:43 1685关于jstorm单机安装可以 ... -
HBase系列一
2015-11-30 16:17 672关于hbase 一、客户端类 HTable 和 HTabl ... -
spring hadoop系列(六)---HbaseSystemException
2015-11-30 09:13 408一、源码 /** * HBase Data Access e ... -
spring hadoop 系列(三)--spring hadoop hbase HbaseConfigurationFactoryBean
2015-11-27 16:28 1497一、源码分析 /** * 设定Hbase指定Configu ... -
spring hadoop 系列(二)
2015-11-27 15:26 556一、源码分析 /** * * HbaseAccesso ... -
spring hadoop之batch处理(二)
2015-11-24 18:10 1468一、测试 public class MrBatchApp { ... -
spring hadoop之mapreduce batch
2015-11-24 15:51 581一、测试 // 定义hadoop configuration ... -
centos6.7 64位 伪分布 安装 cdh5.4.8 + jdk 8
2015-11-09 00:37 2267一、安装JAVA # 创建JAVA的目录 mkdir -p / ...
相关推荐
Java操作hbase完成hbase数据文件下载
spring boot 对 hbase 客户端2.2.2 连接的支持,包含客户端的配置,及map直接操作数据库,极大的方便对大数据的管理!!!
phoenix +hbase+spring 整合技术 phoenix +hbase+spring 整合技术 phoenix +hbase+spring 整合技术 根据需要 下载 集成的jar phoenix-core-4.13.0-HBase-0.98.jar
Spring-Boot-HBase-RESTful Spring-Boot-HBase-RESTful ##安装 brew install hadoop hbase zookeeper## HBase入门 start-hbase.sh start sudo /usr/local/Cellar/zookeeper/3.4.8/bin/zkServer start参考示例代码: ...
基于SpringMVC+Spring+HBase+Maven搭建的Hadoop分布式云盘系统.zip 语言:Java 框架:springMVC 数据库:HBASE 可以作为毕业设计
Spring for Apache Hadoop 提供了 Spring 框架用于创建和运行 Hadoop MapReduce、Hive 和 Pig 作业的功能,包括 HDFS 和 HBase。如果你需要简单的基于 Hadoop 进行作业调度,你可添加 Spring for Apache Hadoop 命名...
基于hadoop+hbase+springboot实现的分布式网盘系统,适合本科毕业设计 资源包含的整个demo在Hadoop,和Hbase环境搭建好了,可以启动起来。 技术选型 1.Hadoop 2.Hbase 3.SpringBoot ...... 系统实现的功能 1.用户...
大数据hbase测试项目, String boot + hadoop + hbase 的一个测试项目 1.jdk路径不能有空格,中文 2.spring 示例官方xml配置中需有调整,避免 delete xxx 异常。 3.maven本地版本不能小于cm上hadoop、hbase版本。
2-1 HBase简介及其在大数据生态圈的位置 2-2 HBase数据存储模型及与关系型数据库的区别 2-3 Hadoop伪分布式集群安装 2-4 HBase伪分布式集群安装 2-5 HBase基础架构 2-6 HBase阶段小结 第3章 HBase原理与实战 介绍...
使用Hadoop HDFS作为文件存储系统、HBase作为数据存储仓库,采用SpringMVC+Spring框架实现,包括用户注册与登录、我的网盘、关注用户、我的分享、我收到的分享等五大功能模块。其中我的网盘包括查看文件列表,多文件...
web端用spring mvc4.0.5 hadoop+hbase 伪分布实验环境 已实现用户注册 登陆 网盘管理:上传文件 创建文件夹 修改文件及文件夹 分享文件及文件夹 删除文件及文件夹 仿百度文库浏览文档 和下载文件功能
基于Hadoop分布式云盘系统使用Hadoop HDFS作为文件存储系统、HBase作为数据存储仓库,采用SpringMVC+Spring框架实现,包括用户注册与登录、我的网盘、关注用户、我的分享、我收到的分享等五大功能模块。其中我的网盘...
使用Hadoop HDFS作为文件存储系统、HBase作为数据存储仓库,采用SpringMVC+Spring框架实现,包括用户注册与登录、我的网盘、关注用户、我的分享、我收到的分享等五大功能模块。其中我的网盘包括查看文件列表,多文件...
Hadoop_and_Hbase_搭建_云存储_概述
源码主要用于学习:1. Spring Boot+Hadoop+Hive+Hbase实现数据基本操作,Hive数据源使
基于SpringMVC+Spring+HBase+Maven搭建的Hadoop分布式云盘系统。使用Hadoop HDFS作为文件存储系统、HBase作为数据存储仓库,采用SpringMVC+Spring框架实现,包括用户注册与登录、我的网盘、关注用户 毕业设计是高等...
课时18:搭建分布式HBase集群之Hadoop部署 课时19:搭建分布式HBase集群之HBase部署 课时20:sqoop2部署 课时21:使用sqoop2将mysql数据导入到HBase 课时22:集群管理之节点管理与数据任务 课时23:Rowkey设计与...
毕业设计,基于hadoop的云盘系统,技术选型springboot+mysql+layui+hdfs+hbase(未完成)