`
hantao
  • 浏览: 22388 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
文章分类
社区版块
存档分类
最新评论
文章列表
shell脚本可真难写啊,没办法,憋了两小时写了个烂脚本,用来统计我的日志文件中的各种超时数据   #!/bin/shif [ "$1" = "" ] then echo "文件未指定!" exit 1else if [ ! -f $1 ]  then echo "文件$1不存在!"  exit 1 fifi temp="$1"fd=${temp##*.}if [ "$fd" = "proxy" -o "$fd" = "l ...
ThreadLocal故名思意是和线程绑定的变量,作用域在线程内,随着线程的消亡而消亡. 可以实例化多个ThreadLocal,每个实例可存储一个线程变量.   要注意的是在线程池中的使用,当使用线程池时,线程是可以复用的,所以要注意ThreadLocal的及时销毁和重置,不然可能造成OO.   在一些servelet容器中如tomcat中使用了线程池来处理请求,需要特别注意.
依赖org.apache.httpcomponents的httpclient,httpasyncclient,httpcore-nio,httpcore   public class AsyncHttpGetter {  private HttpAsyncClient httpAsyncClient;  private final static Logger logger = Logger.getLogger(AsyncHttpGetter.class);  private String serverUrl;  public void init(){  initHttpClient(); } ...
private static String getLocalIP() throws SocketException {  Enumeration<NetworkInterface> netInterfaces = NetworkInterface.getNetworkInterfaces();  InetAddress rtip = null;  while (netInterfaces.hasMoreElements()) {   NetworkInterface ni = netInterfaces.nextElement();   logger.info("inter ...
/**      * 图片加水印,可设置透明度,默认水印图片放在右下角      * @param iconFile 水印文件      * @param srcImgFile 源文件      * @param alpha 透明度 0-1      * @return 生成的图片字节数组      */     public static byte[] markImageByIcon(File iconFile, File srcImgFile,float alpha) {                 byte[] imgBytes = null;         t ...
//截取len个字节,返回完整的字符串  public static String splide(int len,String str){      String returnStr=null;   int total=str.getBytes().length;   if(len>=total){    returnStr=str;   }else{    char[] ch=str.toCharArray();    StringBuffer sb=new StringBuffer();    int j=0;    for(int i=0;i<ch.l ...
pom中加入 <plugin>                 <groupId>org.apache.maven.plugins</groupId>                 <artifactId>maven-jar-plugin</artifactId>                 <configuration>                     <archive>                         <manifest>                 ...
系统几个重要内核参数: /proc/sys/net/ipv4/tcp_tw_recycle tcp time_wait 快速回收 /proc/sys/net/ipv4/tcp_tw_reuse   tcp time_wait 重用 /proc/sys/net/ipv4/ip_local_port_range 设置tcp或udp可以使用的端口范围 /proc/sys/net/ipv4/tcp_keepalive_time 默认值是7200(2小时) 当keepalive打开的情况下,TCP发送keepalive消息的频率 /proc/sys/kernel/threads-max 内核所能 ...
基本概念 堆/Heap JVM管理的内存叫堆;在32Bit操作系统上有4G的限制,一般来说Windows下为2G,而Linux下为3G;64Bit的就没有这个限制。 JVM初始分配的内存由-Xms指定,默认是物理内存的1/64但小于1G。 JVM最大分配的内存由-Xmx指 ...
dependencyManagement中定义的依赖子module不会共享到 dependencies中定义的依赖子module可以共享到   dependencyManagement的用途主要是管理依赖的版本号,当然在dependencies中也可以直接定义版本号,好处是在父dependencyManagement中定义的版本号可以共享给子module.做到版本统一
定时清理指定日期以前的日志文件,防止磁盘满 这里是如果/home下磁盘使用超过85%,则清除15天以前的,如果仍超过85%,则清除14天前的,直到低于85%   #!/bin/bash clean() {   local interval=$1         find /home/admin/apache/logs \( \( -name "*access_log" -or -name "*error_log" \) -and -ctime +$interval \) -print -type f -exec rm -rf {} \; } ...
最近发生了几次web应用停止响应,最后虽然解决了问题,但应该给应用加上监控   检查apache, ps aux | grep httpd 发现apache进程已经有10个之多, 再通过curl直接检查8080端口的jboss,发现jboss已经停止响应,从而拖垮了apahe   shell掌握有限, 简单用curl进行应用的监控   监控机器列表文件: server.list server1 server2 server3   建立监控脚本: webstatus.sh   #!/bin/sh monitor_dir=/home/admin/monitor/ ...
在多线程大师Doug Lea的贡献下,在JDK1.5中加入了许多对并发特性的支持,例如:线程池。 一、简介 线程池类为 java.util.concurrent.ThreadPoolExecutor,常用构造方法为: ThreadPoolExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, RejectedExecutionHandler handler) corePoolSize: 线程池 ...
  apache 虚拟主机设置有两类 一:基于ip的配置 一台主机绑定了多个ip,每个ip设置一个虚拟主机 如一台主机有10.13.129.163和192.168.1.9两个ip 则配置为: <VirtualHost 10.13.129.163> ServerName localhost  ##这里的ServerName好像没什么用 DocumentRoot D:/apache/htdocs/dir1 </VirtualHost>   <VirtualHost 192.168.1.9> ServerName localhost Doc ...
取: Cookie[] cookies = request.getCookies(); if(cookies!=null){     for(Cookie cookie : cookies){    if(cookie.getName().equals("mid")){     String mid = cookie.getValue();    }   } } 存: String mid = java.net.InetAddress.getLocalHost().getHostName();   Cookie c = new Cookie("mid&qu ...
Global site tag (gtag.js) - Google Analytics