executor

Mybaits 源码解析 (九)----- 全网最详细,没有之一:一级缓存和二级缓存源码分析

无人久伴 提交于 2019-12-04 01:20:37
像Mybatis、Hibernate这样的ORM框架,封装了JDBC的大部分操作,极大的简化了我们对 数据库 的操作。 在实际项目中,我们发现在一个事务中查询同样的语句两次的时候,第二次没有进行数据库查询,直接返回了结果,实际这种情况我们就可以称为缓存。 Mybatis的缓存级别 一级缓存 MyBatis的一级查询缓存(也叫作本地缓存)是基于org.apache.ibatis.cache.impl.PerpetualCache 类的 HashMap本地缓存,其作用域是SqlSession,myBatis 默认一级查询缓存是开启状态,且不能关闭。 在同一个SqlSession中两次执行相同的 sql查询语句,第一次执行完毕后,会将查询结果写入到缓存中,第二次会从缓存中直接获取数据,而不再到数据库中进行查询,这样就减少了数据库的访问,从而提高查询效率。 基于PerpetualCache 的 HashMap本地缓存,其存储作用域为 Session,PerpetualCache 对象是在SqlSession中的Executor的localcache属性当中存放,当 Session flush 或 close 之后,该Session中的所有 Cache 就将清空。 二级缓存 二级缓存与一级缓存其机制相同,默认也是采用 PerpetualCache,HashMap存储,不同在于其存储作用域为

Mybaits 源码解析 (九)----- 全网最详细,没有之一:一级缓存和二级缓存源码分析

北城以北 提交于 2019-12-04 00:16:27
像Mybatis、Hibernate这样的ORM框架,封装了JDBC的大部分操作,极大的简化了我们对数据库的操作。 在实际项目中,我们发现在一个事务中查询同样的语句两次的时候,第二次没有进行数据库查询,直接返回了结果,实际这种情况我们就可以称为缓存。 Mybatis的缓存级别 一级缓存 MyBatis的一级查询缓存(也叫作本地缓存)是基于org.apache.ibatis.cache.impl.PerpetualCache 类的 HashMap本地缓存,其作用域是SqlSession,myBatis 默认一级查询缓存是开启状态,且不能关闭。 在同一个SqlSession中两次执行相同的 sql查询语句,第一次执行完毕后,会将查询结果写入到缓存中,第二次会从缓存中直接获取数据,而不再到数据库中进行查询,这样就减少了数据库的访问,从而提高查询效率。 基于PerpetualCache 的 HashMap本地缓存,其存储作用域为 Session,PerpetualCache 对象是在SqlSession中的Executor的localcache属性当中存放,当 Session flush 或 close 之后,该Session中的所有 Cache 就将清空。 二级缓存 二级缓存与一级缓存其机制相同,默认也是采用 PerpetualCache,HashMap存储,不同在于其存储作用域为

MyBatis原理分析

别来无恙 提交于 2019-12-03 23:00:39
https://blog.csdn.net/weixin_43184769/article/details/91126687 MyBatis原理分析MyBatis工作流程简述原生MyBatis原理分析初始化工作解析配置文件配置类方式执行SQLSqlSession API方式接口方式真正掌握一个框架源码分析是少不了的~ 在讲解整合Spring的原理之前理解原生的MyBatis执行原理是非常有必要的 MyBatis工作流程简述传统工作模式: public static void main(String[] args) {InputStream inputStream = Resources.getResourceAsStream("mybatis-config.xml");SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(inputStream);SqlSession sqlSession = factory.openSession();String name = "tom";List<User> list = sqlSession.selectList("com.demo.mapper.UserMapper.getUserByName",params);

spark运维管理

坚强是说给别人听的谎言 提交于 2019-12-03 20:26:36
一:实现HA 1-基于zookeeper实现HA 配置spark-env.sh,master节点挂掉以后,会进行恢复操作。 export SPARK_DAEMON_JAVA_OPTS="-Dspark.deploy.recoveryMode=ZOOKEEPER -Dspark.deploy.zookeeper.url=192.168.114.200:2181,192.168.114.201:2181,192.168.114.202:2181 -Dspark.deploy.zookeeper.dir=/spark" 提交任务脚本(如果spark1这个master挂掉后,会寻找新的master,从而保证任务不会因为spark1挂掉而失败): /opt/module/spark/bin/spark-submit \ --class com.zj.spark.applog.AppLogSpark \ --master spark://spark1:7077,spark2:7077 \ --deploy-mode client \ --num-executors 1 \ --driver-memory 600m \ --executor-memory 600m \ --executor-cores 1 \ --conf spark.cores.max=3 \ /opt/spark-study

Spark 调优

我们两清 提交于 2019-12-03 17:30:39
资源调优 (1). 在部署 spark 集群中指定资源分配的默认参数 在 spark 安装包的 conf 下的 spark-env.sh SPARK_WORKER_CORES SPARK_WORKER_MEMORY SPARK_WORKER_INSTANCES 每台机器启动 worker 数 #### (2). 在提交 Application 的时候给当前的 Application 分配更多的资源 提交命令选项: (在提交 Application 的时候使用选项) --executor-cores --executor-memory --total-executor-cores 配置信息: (Application 的代码设置或在 Spark-default.conf 中设置) spark.executor.cores spark.executor.memory spark.max.cores 动态分配资源 启用 External shuffle Service 服务: spark.shuffle.service.enabled true Shuffle Service 服务端口, 必须和 yarn-site中的一致: spark.shuffle.service.port 7337 开启动态资源分配: spark.dynamicAllocation.enabled true 每个

并发编程71道

不羁岁月 提交于 2019-12-03 16:55:41
转 https://www.cnblogs.com/lfs2640666960/p/11488629.html 金九银十跳槽季已经开始,作为 Java 开发者你开始刷面试题了吗?别急,我整理了71道并发相关的面试题,看这一文就够了! 1、在java中守护线程和本地线程区别? java中的线程分为两种:守护线程(Daemon)和用户线程(User)。 任何线程都可以设置为守护线程和用户线程,通过方法Thread.setDaemon(bool on);true则把该线程设置为守护线程,反之则为用户线程。Thread.setDaemon()必须在Thread.start()之前调用,否则运行时会抛出异常。 两者的区别: 虚拟机(JVM)何时离开,Daemon是为其他线程提供服务,如果全部的User Thread已经撤离,Daemon 没有可服务的线程,JVM撤离。也可以理解为守护线程是JVM自动创建的线程(但不一定),用户线程是程序创建的线程;比如JVM的垃圾回收线程是一个守护线程,当所有线程已经撤离,不再产生垃圾,守护线程自然就没事可干了,当垃圾回收线程是Java虚拟机上仅剩的线程时,Java虚拟机会自动离开。 扩展:Thread Dump打印出来的线程信息,含有daemon字样的线程即为守护进程,可能会有:服务守护进程、编译守护进程、windows下的监听Ctrl

Java scheduled executor accuracy

大兔子大兔子 提交于 2019-12-03 11:52:51
There is a peculiarity that I encountered while using Java scheduled executors and was wondering if what I experienced is normal. I need to schedule tasks that execute at a predefined rate of 5 seconds. It is expected that these tasks will take longer than 5 seconds to execute from time to time, but when the time to run them goes below 5 seconds, the backed up list of tasks should run in quick succession to catch up. When running the tasks, it is important to know what the original scheduled execution time was (think scheduledExecutionTime() in java.util.TimerTask ). Finally, I need to track

Elegantly implementing queue length indicators to ExecutorServices

谁说胖子不能爱 提交于 2019-12-03 10:32:56
问题 Why, oh why doesn't java.util.concurrent provide a queue length indicators for its ExecutorService s? Recently I found myself doing something like this: ExecutorService queue = Executors.newSingleThreadExecutor(); AtomicInteger queueLength = new AtomicInteger(); ... public void addTaskToQueue(Runnable runnable) { if (queueLength.get() < MAX_QUEUE_LENGTH) { queueLength.incrementAndGet(); // Increment queue when submitting task. queue.submit(new Runnable() { public void run() { runnable.run();

Difference between multithreading with and without Executor

萝らか妹 提交于 2019-12-03 09:05:57
I am trying to find out about the performance difference between normal multithreading and multithreading using executor (to maintain a thread pool). The below are code examples for both. Without Executor Code (with multithreading): import java.lang.management.ManagementFactory; import java.lang.management.MemoryPoolMXBean; import java.lang.management.MemoryUsage; import java.lang.management.ThreadMXBean; import java.util.List; public class Demo1 { public static void main(String arg[]) { Demo1 demo = new Demo1(); Thread t5 = new Thread(new Runnable() { public void run() { int count=0; //

Spark 1.3.0: ExecutorLostFailure depending on input file size

匿名 (未验证) 提交于 2019-12-03 09:05:37
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to run a simple python application on a 2-node-cluster I set up in standalone mode. A master and a worker, whereas the master also takes on the role of a worker. In the following code I'm trying to count the number of cakes occurring in a 500MB text file and it fails with a ExecutorLostFailure. Interestingly the application runs through if I take a 100MB input file. I used the package version of CDH5.4.4 with YARN and I'm running Spark 1.3.0. Each node has 8GB of memory and these are some of my configurations: executor memory: 4g