<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    paulwong

    #

    MONGODB常用命令

    啟動:
    mongod --config /usr/local/mongodb/conf/cms.conf

    關閉:
    ps -ef | grep mongo (查PID)
    kill -15 pid

    修復:
    rm /data/mongodb/mongod.lock
    mongod --dbpath /data/mongodb --repair
    mongod --config /usr/local/mongodb/conf/cms.conf

    進入命令模式:
    mongo admin -u root -p cloudDB

    查看服務器連接數:
    db.serverStatus().connections

    查看版本:
    db.runCommand({"buildInfo":1})  

    查看統計:
    mongostat -u root -p cloudDB

    備份數據:
    mongodump -u cms -p cms -d cms -o /data/dump/cms

    恢復數據:
    mongorestore -u cms -p cms -d cms /data/dump/cms

    posted @ 2015-04-15 17:39 paulwong 閱讀(294) | 評論 (0)編輯 收藏

    分布式配置管理平臺Disconf

    http://www.oschina.net/p/disconf

    Disconf 可以為各種業務平臺提供統一的配置管理服務。

    • 支持配置(配置項+配置文件)的分布式化管理

    • 配置發布統一化

    • 極簡的使用方式(注解式編程 或 XML代碼無代碼侵入模式)

    • 低侵入性或無侵入性、強兼容性

    • 需要Spring編程環境

    重要功能特點

    • 支持配置(配置項+配置文件)的分布式化管理

    • 配置發布統一化

      • 配置發布、更新統一化(云端存儲、發布):配置存儲在云端系統,用戶統一在平臺上進行發布、更新配置。

      • 配置更新自動化:用戶在平臺更新配置,使用該配置的系統會自動發現該情況,并應用新配置。特殊地,如果用戶為此配置定義了回調函數類,則此函數類會被自動調用。

    • 配置異構系統管理

      • 異構包部署統一化:這里的異構系統是指一個系統部署多個實例時,由于配置不同,從而需要多個部署包(jar或war)的情況(下同)。使用 Disconf后,異構系統的部署只需要一個部署包,不同實例的配置會自動分配。特別地,在業界大量使用部署虛擬化(如JPAAS系統,SAE,BAE) 的情況下,同一個系統使用同一個部署包的情景會越來越多,Disconf可以很自然地與他天然契合。

      • 異構主備自動切換:如果一個異構系統存在主備機,主機發生掛機時,備機可以自動獲取主機配置從而變成主機。

      • 異構主備機Context共享工具:異構系統下,主備機切換時可能需要共享Context。可以使用Context共享工具來共享主備的Context。

    • 極簡的使用方式(注解式編程 或 XML代碼無代碼侵入模式):我們追求的是極簡的、用戶編程體驗良好的編程方式。目前支持兩種開發模式:基于XML配置或才基于注解,即可完成復雜的配置分布式化。

    • 需要Spring編程環境

    注:配置項是指某個類里的某個Field字段。

    Disconf的功能特點描述圖:

    查看大圖

    其它功能特點

    • 低侵入性或無侵入性、強兼容性

      • 低侵入性:通過極少的注解式代碼撰寫,即可實現分布式配置。

      • 無侵入性:通過XML簡單配置,即可實現分布式配置。

      • 強兼容性:為程序添加了分布式配置注解后,開啟Disconf則使用分布式配置;若關閉Disconf則使用本地配置;若開啟Disconf后disconf-web不能正常Work,則Disconf使用本地配置。

    • 支持配置項多個項目共享,支持批量處理項目配置

    • 配置監控:平臺提供自校驗功能(進一步提高穩定性),可以定時校驗應用系統的配置是否正確。

    模塊架構圖

    posted @ 2015-04-13 16:12 paulwong 閱讀(839) | 評論 (0)編輯 收藏

    消息傳遞平臺 JBoss A-MQ

    JBoss A-MQ 是高性能,靈活的信息平臺,可以安全的傳遞消息,非常可靠,而且支持 Internet of Things (IoT)。JBoss A-MQ 在任意的配置中都可以很容易部署和管理,可以在保證基礎設施的基礎上部署,也可以在云端部署,或者是混合配置下部署。

    JBoss A-MQ 支持多種語言:C,C++ 和 Java;同時還支持多種協議:JMS 1.1, TCP, SSL, STOMP, NMS, MQTT, AMQP 1.0。

    JBoss A-MQ 擴展了 xPaaS 消息功能,提供 OpenShift Platform-as-a-Service (PaaS) 解決方案。

    posted @ 2015-04-07 21:44 paulwong 閱讀(623) | 評論 (0)編輯 收藏

    JBoss 集成管理平臺 Embedded Jopr

    Embedded Jopr 是基于 Web 的應用,可以管理和監控 JBoss Application Server 的實例。 

    Embedded Jopr 是 Jopr 的分支,復用了大量 Jopr 的組件。Embedded Jopr 的最終目標是替代 jmx 和 web 工作臺。可以作為配置和監控 JBoss AS 實例的工具。

    示例視頻: demo video

    posted @ 2015-04-07 21:42 paulwong 閱讀(426) | 評論 (0)編輯 收藏

    LINUX時間同步NTP

    [root@clientlinux ~]# ntpdate time.windows.com
    28 Jul 17:19:33 ntpdate[3432]: step time server time.windows.com offset -2428.396146 sec
    # 最後面會顯示微調的時間有多少 (offset),因為鳥哥這部主機時間差很多,所以秒數

    [root@clientlinux ~]# date; hwclock -r
    四  7月 28 17:20:27 CST 2011
    西元2011年07月28日 (週四) 18時19分26秒  -0.752303 seconds
    # 知道鳥哥想要表達什麼嗎?對啊!還得 hwclock -w 寫入 BIOS 時間才行啊!

    [root@clientlinux ~]# vim /etc/crontab
    # 加入這一行去!
    10 5 * * * root (/usr/sbin/ntpdate time.windows.com && /sbin/hwclock -w) &> /dev/null

    posted @ 2015-03-20 11:21 paulwong 閱讀(421) | 評論 (0)編輯 收藏

    commonrpc 0.1 發布,高性能分布式 RPC 框架

    還在羨慕BAT,京東等公司的大流量的架構嗎?讓你的java系統引用解耦,互相獨立,commonrpc 就可以辦到。commonrpc 是一個以netty為基礎,spring 自定義shcema為基礎標簽的rpc框架,不侵入任何業務代碼,一個高性能分布式rpc框架,支持tcp協議,http協議,同時HTTP協議支持restful 方式訪問.
    http://git.oschina.net/284520459/commonrpc/wikis/home

    posted @ 2015-03-12 19:02 paulwong 閱讀(663) | 評論 (0)編輯 收藏

    NETTY資源

    Netty4.0學習筆記系列之一:Server與Client的通訊

    Netty4.0學習筆記系列之二:Handler的執行順序


    Netty4.0學習筆記系列之三:構建簡單的http服務


    Netty4.0學習筆記系列之四:混合使用coder和handler


    Netty4.0學習筆記系列之五:自定義通訊協議

    Netty4.0學習筆記系列之六:多種通訊協議支持


    NETTY HTTP JAX-RS服務器
    https://github.com/continuuity/netty-http

    netty和tomcat的hello world性能比較
    http://my.oschina.net/u/2302546/blog/368685

    nginx+tomcat與netty優缺點


    NETTY官方EXAMPLE
    https://github.com/netty/netty/tree/4.0/example/src/main/java/io/netty/example


    posted @ 2015-02-26 09:49 paulwong 閱讀(472) | 評論 (0)編輯 收藏

    SPRING CACHE之ConcurrentMapCacheManager改造

    ConcurrentMapCacheManager可以作為一種緩存方案,但不能設置過期,最大緩存條目等,需進行改造。
    1. pom.xml中加入依賴包
              <dependency>
                  <groupId>com.google.guava</groupId>
                  <artifactId>guava</artifactId>
                  <version>18.0</version>
              </dependency>

    2. 改造CacheManager,MyConcurrentMapCacheManager
      package com.paul.common.cache;
      /*
       * Copyright 2002-2014 the original author or authors.
       *
       * Licensed under the Apache License, Version 2.0 (the "License");
       * you may not use this file except in compliance with the License.
       * You may obtain a copy of the License at
       *
       *      
      http://www.apache.org/licenses/LICENSE-2.0
       *
       * Unless required by applicable law or agreed to in writing, software
       * distributed under the License is distributed on an "AS IS" BASIS,
       * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       * See the License for the specific language governing permissions and
       * limitations under the License.
       
      */

      import java.util.Collection;
      import java.util.Collections;
      import java.util.Map;
      import java.util.concurrent.ConcurrentHashMap;
      import java.util.concurrent.ConcurrentMap;
      import java.util.concurrent.TimeUnit;

      import org.springframework.cache.Cache;
      import org.springframework.cache.CacheManager;
      import org.springframework.cache.concurrent.ConcurrentMapCache;

      import com.google.common.cache.CacheBuilder;

      /**
       * {
      @link CacheManager} implementation that lazily builds {@link ConcurrentMapCache}
       * instances for each {
      @link #getCache} request. Also supports a 'static' mode where
       * the set of cache names is pre-defined through {
      @link #setCacheNames}, with no
       * dynamic creation of further cache regions at runtime.
       *
       * <p>Note: This is by no means a sophisticated CacheManager; it comes with no
       * cache configuration options. However, it may be useful for testing or simple
       * caching scenarios. For advanced local caching needs, consider
       * {
      @link org.springframework.cache.guava.GuavaCacheManager} or
       * {
      @link org.springframework.cache.ehcache.EhCacheCacheManager}.
       *
       * 
      @author Juergen Hoeller
       * 
      @since 3.1
       * 
      @see ConcurrentMapCache
       
      */
      public class MyConcurrentMapCacheManager implements CacheManager {

          private final ConcurrentMap<String, Cache> cacheMap = new ConcurrentHashMap<String, Cache>(16);

          private boolean dynamic = true;

          private boolean allowNullValues = true;
          
          private long expireTime = 30;
          
          private long maximumSize = 100;


          /**
           * Construct a dynamic ConcurrentMapCacheManager,
           * lazily creating cache instances as they are being requested.
           
      */
          public MyConcurrentMapCacheManager() {
          }

          /**
           * Construct a static ConcurrentMapCacheManager,
           * managing caches for the specified cache names only.
           
      */
          public MyConcurrentMapCacheManager(long expireTime, long maximumSize) {
              if(expireTime > 0)
                  this.expireTime = expireTime;
              if(maximumSize > 0)
                  this.maximumSize = maximumSize;
          }


          /**
           * Specify the set of cache names for this CacheManager's 'static' mode.
           * <p>The number of caches and their names will be fixed after a call to this method,
           * with no creation of further cache regions at runtime.
           * <p>Calling this with a {
      @code null} collection argument resets the
           * mode to 'dynamic', allowing for further creation of caches again.
           
      */
          public void setCacheNames(Collection<String> cacheNames) {
              if (cacheNames != null) {
                  for (String name : cacheNames) {
                      this.cacheMap.put(name, createConcurrentMapCache(name));
                  }
                  this.dynamic = false;
              }
              else {
                  this.dynamic = true;
              }
          }

          /**
           * Specify whether to accept and convert {
      @code null} values for all caches
           * in this cache manager.
           * <p>Default is "true", despite ConcurrentHashMap itself not supporting {
      @code null}
           * values. An internal holder object will be used to store user-level {
      @code null}s.
           * <p>Note: A change of the null-value setting will reset all existing caches,
           * if any, to reconfigure them with the new null-value requirement.
           
      */
          public void setAllowNullValues(boolean allowNullValues) {
              if (allowNullValues != this.allowNullValues) {
                  this.allowNullValues = allowNullValues;
                  // Need to recreate all Cache instances with the new null-value configuration
                  for (Map.Entry<String, Cache> entry : this.cacheMap.entrySet()) {
                      entry.setValue(createConcurrentMapCache(entry.getKey()));
                  }
              }
          }

          /**
           * Return whether this cache manager accepts and converts {
      @code null} values
           * for all of its caches.
           
      */
          public boolean isAllowNullValues() {
              return this.allowNullValues;
          }


          @Override
          public Collection<String> getCacheNames() {
              return Collections.unmodifiableSet(this.cacheMap.keySet());
          }

          @Override
          public Cache getCache(String name) {
              Cache cache = this.cacheMap.get(name);
              if (cache == null && this.dynamic) {
                  synchronized (this.cacheMap) {
                      cache = this.cacheMap.get(name);
                      if (cache == null) {
                          cache = createConcurrentMapCache(name);
                          this.cacheMap.put(name, cache);
                      }
                  }
              }
              return cache;
          }

          /**
           * Create a new ConcurrentMapCache instance for the specified cache name.
           * 
      @param name the name of the cache
           * 
      @return the ConcurrentMapCache (or a decorator thereof)
           
      */
          protected Cache createConcurrentMapCache(String name) {
              //return new ConcurrentMapCache(name, isAllowNullValues());
              //此處改用GOOGLE GUAVA的構造MANAGER方式
              return new ConcurrentMapCache(name,
                                              CacheBuilder.newBuilder()
                                                          .expireAfterWrite(this.expireTime, TimeUnit.MINUTES)
                                                          .maximumSize(this.maximumSize)
                                                          .build()
                                                          .asMap(), 
                                              isAllowNullValues());
          }

      }


    3. 配置想著bean, cache-concurrentmap-applicationcontext.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <beans xmlns="http://www.springframework.org/schema/beans"
          xmlns:xsi
      ="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
          xmlns:cache
      ="http://www.springframework.org/schema/cache"
          xmlns:p
      ="http://www.springframework.org/schema/p"
          xmlns:c
      ="http://www.springframework.org/schema/c"
          xmlns:jee
      ="http://www.springframework.org/schema/jee"
          xmlns:util
      ="http://www.springframework.org/schema/util"
          xsi:schemaLocation
      ="http://www.springframework.org/schema/context
                http://www.springframework.org/schema/context/spring-context-3.0.xsd
                http://www.springframework.org/schema/beans
                http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                http://www.springframework.org/schema/cache
                http://www.springframework.org/schema/cache/spring-cache.xsd
                http://www.springframework.org/schema/jee 
                http://www.springframework.org/schema/jee/spring-jee.xsd
                http://www.springframework.org/schema/util
                http://www.springframework.org/schema/util/spring-util.xsd"
      >

          <cache:annotation-driven />

          <!-- <bean id="cacheManager"
              class="org.springframework.cache.concurrent.ConcurrentMapCacheManager" >
              <property name="cacheNames">
                  <list>
                      <value>my-local-cache</value>
                  </list>
              </property>
          </bean> 
      -->
          
          <bean id="cacheManager"
              class
      ="com.paul.common.cache.MyConcurrentMapCacheManager">
              <constructor-arg index="0" value="1" />
              <constructor-arg index="1" value="5000" />
          </bean>    
          
      </beans>


    4. 通過注釋進行使用
      /*
       * JBoss, Home of Professional Open Source
       * Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
       * contributors by the @authors tag. See the copyright.txt in the
       * distribution for a full listing of individual contributors.
       *
       * Licensed under the Apache License, Version 2.0 (the "License");
       * you may not use this file except in compliance with the License.
       * You may obtain a copy of the License at
       * 
      http://www.apache.org/licenses/LICENSE-2.0
       * Unless required by applicable law or agreed to in writing, software
       * distributed under the License is distributed on an "AS IS" BASIS,
       * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       * See the License for the specific language governing permissions and
       * limitations under the License.
       
      */
      package com.paul.springmvc.data;

      import java.util.List;

      import javax.persistence.EntityManager;
      import javax.persistence.criteria.CriteriaBuilder;
      import javax.persistence.criteria.CriteriaQuery;
      import javax.persistence.criteria.Root;

      import org.springframework.beans.factory.annotation.Autowired;
      import org.springframework.cache.annotation.CacheEvict;
      import org.springframework.cache.annotation.Cacheable;
      import org.springframework.stereotype.Repository;
      import org.springframework.transaction.annotation.Transactional;

      import com.paul.springmvc.model.Member;

      @Repository
      @Transactional
      public class MemberDaoImpl implements MemberDao {
          @Autowired
          private EntityManager em;

          @Cacheable(value = "my-local-cache", key = "#id")
          public Member findById(Long id) {
              System.out.println("MemberDaoImpl NO CACHE");
              return em.find(Member.class, id);
          }

          public Member findByEmail(String email) {
              CriteriaBuilder cb = em.getCriteriaBuilder();
              CriteriaQuery<Member> criteria = cb.createQuery(Member.class);
              Root<Member> member = criteria.from(Member.class);

              /*
               * Swap criteria statements if you would like to try out type-safe criteria queries, a new
               * feature in JPA 2.0 criteria.select(member).orderBy(cb.asc(member.get(Member_.name)));
               
      */

              criteria.select(member).where(cb.equal(member.get("email"), email));
              return em.createQuery(criteria).getSingleResult();
          }

          public List<Member> findAllOrderedByName() {
              CriteriaBuilder cb = em.getCriteriaBuilder();
              CriteriaQuery<Member> criteria = cb.createQuery(Member.class);
              Root<Member> member = criteria.from(Member.class);

              /*
               * Swap criteria statements if you would like to try out type-safe criteria queries, a new
               * feature in JPA 2.0 criteria.select(member).orderBy(cb.asc(member.get(Member_.name)));
               
      */

              criteria.select(member).orderBy(cb.asc(member.get("name")));
              return em.createQuery(criteria).getResultList();
          }

          @CacheEvict(value="my-local-cache",allEntries=true,beforeInvocation=true)//清空所有緩存
          public void register(Member member) {
              em.persist(member);
              return;
          }
      }

    posted @ 2015-02-25 16:34 paulwong 閱讀(2694) | 評論 (0)編輯 收藏

    SPRING CACHE資源

    SPRING手冊
    http://docs.spring.io/spring/docs/3.2.x/spring-framework-reference/htmlsingle/#cache


    SPRING CONCURRENTMAP MANAGER加過期策略
    http://stackoverflow.com/questions/8181768/can-i-set-a-ttl-for-cacheable

    組合KEY
    http://stackoverflow.com/questions/14072380/cacheable-key-on-multiple-method-arguments

    Spring Cache抽象詳解
    http://www.open-open.com/lib/view/open1389575623336.html

    注釋驅動的 Spring cache 緩存介紹
    https://www.ibm.com/developerworks/cn/opensource/os-cn-spring-cache/

    Spring Cache抽象詳解

    posted @ 2015-02-25 16:04 paulwong 閱讀(503) | 評論 (0)編輯 收藏

    Spring Boot使用redis做數據緩存

    1 添加redis支持

    在pom.xml中添加

    Xml代碼  收藏代碼
    1. <dependency>  
    2.           <groupId>org.springframework.boot</groupId>  
    3.           <artifactId>spring-boot-starter-redis</artifactId>  
    4.       </dependency>  

     

    2 redis配置

    Java代碼  收藏代碼
    1. @Configuration  
    2. @EnableCaching  
    3. public class RedisCacheConfig {  
    4.     @Bean  
    5.     public CacheManager cacheManager(  
    6.             @SuppressWarnings("rawtypes") RedisTemplate redisTemplate) {  
    7.         return new RedisCacheManager(redisTemplate);  
    8.     }  
    9.   
    10.     @Bean  
    11.     public RedisTemplate<String, String> redisTemplate(  
    12.             RedisConnectionFactory factory) {  
    13.         final StringRedisTemplate template = new StringRedisTemplate(factory);  
    14.         template.setValueSerializer(new Jackson2JsonRedisSerializer<SysUser>(  
    15.                 SysUser.class)); //請注意這里  
    16.   
    17.         return template;  
    18.     }  
    19. }  

     

    3 redis服務器配置

    Properties代碼  收藏代碼
    1. # REDIS (RedisProperties)  
    2. spring.redis.database= # database name  
    3. spring.redis.host=localhost # server host  
    4. spring.redis.password= # server password  
    5. spring.redis.port=6379 # connection port  
    6. spring.redis.pool.max-idle=8 # pool settings ...  
    7. spring.redis.pool.min-idle=0  
    8. spring.redis.pool.max-active=8  
    9. spring.redis.pool.max-wait=-1  
    10. spring.redis.sentinel.master= # name of Redis server  
    11. spring.redis.sentinel.nodes= # comma-separated list of host:port pairs  

     

    4 應用

    Java代碼  收藏代碼
    1. /** 
    2. *此處的dao操作使用的是spring data jpa,使用@Cacheable可以在任意方法上,*比如@Service或者@Controller的方法上 
    3. */  
    4. public interface SysUserRepo1 extends CustomRepository<SysUser, Long> {  
    5.     @Cacheable(value = "usercache")  
    6.     public SysUser findByUsername(String username);  
    7. }  

     

    5 檢驗

    Java代碼  收藏代碼
    1. @Controller  
    2. public class TestController {  
    3.       
    4.       
    5.     @Autowired   
    6.     SysUserRepo1 sysUserRepo1;  
    7.     @RequestMapping("/test")  
    8.     public @ResponseBody String test(){  
    9.   
    10.         final SysUser loaded = sysUserRepo1.findByUsername("wyf");  
    11.         final SysUser cached = sysUserRepo1.findByUsername("wyf");  
    12.           
    13.         return "ok";  
    14.     }   
    15. }  

     

    效果如圖:



     

    posted @ 2015-02-25 10:02 paulwong 閱讀(5276) | 評論 (3)編輯 收藏

    僅列出標題
    共115頁: First 上一頁 37 38 39 40 41 42 43 44 45 下一頁 Last 
    主站蜘蛛池模板: 亚洲一区免费观看| 色婷婷亚洲十月十月色天| xxxx日本免费| 久久亚洲国产精品五月天婷| 拍拍拍无挡视频免费观看1000| 亚洲一级毛片免费看| 亚洲av无码不卡| 久久不见久久见中文字幕免费| 免费无码黄网站在线看| 亚洲中文无码av永久| 亚洲av无码乱码国产精品fc2| 亚洲精品人成无码中文毛片| 在线观看免费亚洲| 国产情侣激情在线视频免费看 | 亚洲成人黄色网址| 香蕉视频在线观看免费国产婷婷| 日本亚洲高清乱码中文在线观看| 亚洲另类春色国产精品| 亚洲精品成人在线| 国产成人aaa在线视频免费观看| 日本阿v免费费视频完整版| 亚洲电影免费在线观看| 三上悠亚在线观看免费| 一级毛片一级毛片免费毛片| 老司机午夜精品视频在线观看免费| 精品国产综合成人亚洲区| 中文毛片无遮挡高潮免费| 无码的免费不卡毛片视频| 亚洲精品福利网站| 亚洲AV日韩AV天堂一区二区三区| 亚洲一区二区三区偷拍女厕| 免费无码黄网站在线观看| 最近2019中文字幕mv免费看 | 精品亚洲A∨无码一区二区三区| 亚洲精品乱码久久久久久按摩 | 黄页网站在线免费观看| 在线观看亚洲免费视频| 亚洲日本乱码一区二区在线二产线| 久久精品国产精品亚洲色婷婷| 婷婷亚洲综合五月天小说| 亚洲性天天干天天摸|