Search in sources :

Example 1 with Ehcache

use of com.actiontech.dble.config.loader.zkprocess.entity.cache.Ehcache in project dble by actiontech.

the class EcacheszkToxmlLoader method zktoEhcacheWrite.

/**
 * zktoEhcacheWrite
 *
 * @param zkDirectory
 * @return
 * @Created 2016/9/17
 */
private void zktoEhcacheWrite(ZkDirectoryImpl zkDirectory) {
    DataInf ehcacheZkDirectory = this.getZkData(zkDirectory, KVPathUtil.EHCACHE_NAME);
    Ehcache ehcache = parseJsonEhcacheService.parseJsonToBean(ehcacheZkDirectory.getDataValue());
    String outputPath = ResourceUtil.getResourcePathFromRoot(ZookeeperPath.ZK_LOCAL_WRITE_PATH.getKey());
    outputPath = new File(outputPath).getPath() + File.separator;
    outputPath += KVPathUtil.EHCACHE_NAME;
    parseEcacheXMl.parseToXmlWrite(ehcache, outputPath, null);
    this.zookeeperListen.addWatch(KVPathUtil.getEhcacheNamePath(), this);
    DataInf cacheserZkDirectory = this.getZkData(zkDirectory, KVPathUtil.CACHESERVER_NAME);
    if (null != cacheserZkDirectory) {
        ZkDataImpl cacheData = (ZkDataImpl) cacheserZkDirectory;
        try {
            ConfFileRWUtils.writeFile(cacheData.getName(), cacheData.getValue());
        } catch (IOException e) {
            LOGGER.warn(AlarmCode.CORE_ZK_WARN + "EcacheszkToxmlLoader wirteMapFile IOException", e);
        }
        this.zookeeperListen.addWatch(KVPathUtil.getCacheServerNamePath(), this);
    }
}
Also used : Ehcache(com.actiontech.dble.config.loader.zkprocess.entity.cache.Ehcache) DataInf(com.actiontech.dble.config.loader.zkprocess.zookeeper.DataInf) IOException(java.io.IOException) File(java.io.File) ZkDataImpl(com.actiontech.dble.config.loader.zkprocess.zookeeper.process.ZkDataImpl)

Example 2 with Ehcache

use of com.actiontech.dble.config.loader.zkprocess.entity.cache.Ehcache in project dble by actiontech.

the class UXmlEhcachesLoader method notifyProcess.

@Override
public void notifyProcess(UKvBean configValue) throws Exception {
    UKvBean lock = ClusterUcoreSender.getKey(UcorePathUtil.getConfChangeLockPath());
    if (UcoreConfig.getInstance().getValue(ClusterParamCfg.CLUSTER_CFG_MYID).equals(lock.getValue())) {
        return;
    }
    JSONObject jsonObj = JSONObject.parseObject(configValue.getValue());
    if (jsonObj.get(UcorePathUtil.EHCACHE) != null) {
        Ehcache ehcache = parseJsonEhcacheService.parseJsonToBean(jsonObj.getJSONObject(UcorePathUtil.EHCACHE).toJSONString());
        String path = ResourceUtil.getResourcePathFromRoot(UcorePathUtil.UCORE_LOCAL_WRITE_PATH);
        path = new File(path).getPath() + File.separator + WRITEPATH;
        this.parseEcacheXMl.parseToXmlWrite(ehcache, path, null);
    }
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) Ehcache(com.actiontech.dble.config.loader.zkprocess.entity.cache.Ehcache) UKvBean(com.actiontech.dble.config.loader.ucoreprocess.bean.UKvBean) File(java.io.File)

Example 3 with Ehcache

use of com.actiontech.dble.config.loader.zkprocess.entity.cache.Ehcache in project dble by actiontech.

the class UXmlEhcachesLoader method notifyCluster.

@Override
public void notifyCluster() throws Exception {
    Ehcache ehcache = this.parseEcacheXMl.parseXmlToBean(UcorePathUtil.UCORE_LOCAL_WRITE_PATH + WRITEPATH);
    JSONObject ehcacheObj = new JSONObject();
    ehcacheObj.put(UcorePathUtil.EHCACHE, ehcache);
    ClusterUcoreSender.sendDataToUcore(CONFIG_PATH, ehcacheObj.toJSONString());
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) Ehcache(com.actiontech.dble.config.loader.zkprocess.entity.cache.Ehcache)

Example 4 with Ehcache

use of com.actiontech.dble.config.loader.zkprocess.entity.cache.Ehcache in project dble by actiontech.

the class EcachesxmlTozkLoader method notifyProcess.

@Override
public boolean notifyProcess() throws Exception {
    Ehcache ehcache = this.parseEcacheXMl.parseXmlToBean(ZookeeperPath.ZK_LOCAL_WRITE_PATH.getKey() + KVPathUtil.EHCACHE_NAME);
    LOGGER.info("EhcachexmlTozkLoader notifyProcess xml to zk Ehcache Object  :" + ehcache);
    this.xmlTozkEhcacheJson(currZkPath, ehcache);
    LOGGER.info("EhcachexmlTozkLoader notifyProcess xml to zk is success");
    return true;
}
Also used : Ehcache(com.actiontech.dble.config.loader.zkprocess.entity.cache.Ehcache)

Aggregations

Ehcache (com.actiontech.dble.config.loader.zkprocess.entity.cache.Ehcache)4 JSONObject (com.alibaba.fastjson.JSONObject)2 File (java.io.File)2 UKvBean (com.actiontech.dble.config.loader.ucoreprocess.bean.UKvBean)1 DataInf (com.actiontech.dble.config.loader.zkprocess.zookeeper.DataInf)1 ZkDataImpl (com.actiontech.dble.config.loader.zkprocess.zookeeper.process.ZkDataImpl)1 IOException (java.io.IOException)1