Ejemplo n.º 1
0
 private void checkLocalConfigInfo() {
   for (Entry<String /* dataId */, ConcurrentHashMap<String /* group */, CacheData>>
       cacheDatasEntry : cache.entrySet()) {
     ConcurrentHashMap<String, CacheData> cacheDatas = cacheDatasEntry.getValue();
     if (null == cacheDatas) {
       continue;
     }
     for (Entry<String, CacheData> cacheDataEntry : cacheDatas.entrySet()) {
       final CacheData cacheData = cacheDataEntry.getValue();
       try {
         String configInfo = getLocalConfigureInfomation(cacheData);
         if (null != configInfo) {
           if (log.isInfoEnabled()) {
             log.info(
                 "Read local configure, dataId:"
                     + cacheData.getDataId()
                     + ", group:"
                     + cacheData.getGroup());
           }
           popConfigInfo(cacheData, configInfo);
           continue;
         }
         if (cacheData.isUseLocalConfigInfo()) {
           continue;
         }
       } catch (Exception e) {
         log.error("checkLocalConfigInfo error:", e);
       }
     }
   }
 }
Ejemplo n.º 2
0
 private void checkSnapshot() {
   for (Entry<String, ConcurrentHashMap<String, CacheData>> cacheDatasEntry : cache.entrySet()) {
     ConcurrentHashMap<String, CacheData> cacheDatas = cacheDatasEntry.getValue();
     if (null == cacheDatas) {
       continue;
     }
     for (Entry<String, CacheData> cacheDataEntry : cacheDatas.entrySet()) {
       final CacheData cacheData = cacheDataEntry.getValue();
       if (!cacheData.isUseLocalConfigInfo() && cacheData.getFetchCount() == 0) {
         String configInfo =
             getSnapshotConfigInformation(cacheData.getDataId(), cacheData.getGroup());
         if (configInfo != null) {
           popConfigInfo(cacheData, configInfo);
         }
       }
     }
   }
 }
Ejemplo n.º 3
0
 void popConfigInfo(final CacheData cacheData, final String configInfo) {
   final ConfigureInfomation configureInfomation = new ConfigureInfomation();
   configureInfomation.setConfigureInfomation(configInfo);
   final String dataId = cacheData.getDataId();
   final String group = cacheData.getGroup();
   configureInfomation.setDataId(dataId);
   configureInfomation.setGroup(group);
   cacheData.incrementFetchCountAndGet();
   if (null != this.subscriberListener.getExecutor()) {
     this.subscriberListener
         .getExecutor()
         .execute(
             new Runnable() {
               public void run() {
                 try {
                   subscriberListener.receiveConfigInfo(configureInfomation);
                   saveSnapshot(dataId, group, configInfo);
                 } catch (Throwable t) {
                   log.error(
                       "popConfigInfo listener receiveConfigInfo error: group="
                           + group
                           + ", dataId="
                           + dataId,
                       t);
                 }
               }
             });
   } else {
     try {
       subscriberListener.receiveConfigInfo(configureInfomation);
       saveSnapshot(dataId, group, configInfo);
     } catch (Throwable t) {
       log.error(
           "popConfigInfo listener receiveConfigInfo error: group=" + group + ", dataId=" + dataId,
           t);
     }
   }
 }