org.I0Itec.zkclient.ZkClient.writeData()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(279)

本文整理了Java中org.I0Itec.zkclient.ZkClient.writeData()方法的一些代码示例,展示了ZkClient.writeData()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZkClient.writeData()方法的具体详情如下:
包路径:org.I0Itec.zkclient.ZkClient
类名称:ZkClient
方法名:writeData

ZkClient.writeData介绍

暂无

代码示例

代码示例来源:origin: ltsopensource/light-task-scheduler

@Override
public void setData(String path, Object data) {
  zkClient.writeData(path, data);
}

代码示例来源:origin: ltsopensource/light-task-scheduler

@Override
public void setData(String path, Object data) {
  zkClient.writeData(path, data);
}

代码示例来源:origin: networknt/light-4j

@Override
public void writeData(String path, Object object) {
  zkClient.writeData(path, object);
}

代码示例来源:origin: linkedin/cruise-control

private void persistFailedBrokerList() {
 _zkClient.writeData(_failedBrokersZkPath, failedBrokerString());
}

代码示例来源:origin: killme2008/Metamorphosis

/**
 * Update the value of a persistent node with the given path and data.
 * create parrent directory if necessary. Never throw NodeExistException.
 */
public static void updatePersistentPath(final ZkClient client, final String path, final String data)
    throws Exception {
  try {
    client.writeData(path, data);
  }
  catch (final ZkNoNodeException e) {
    createParentPath(client, path);
    client.createPersistent(path, data);
  }
  catch (final Exception e) {
    throw e;
  }
}

代码示例来源:origin: killme2008/Metamorphosis

/**
 * Update the value of a persistent node with the given path and data.
 * create parrent directory if necessary. Never throw NodeExistException.
 */
public static void updateEphemeralPath(final ZkClient client, final String path, final String data)
    throws Exception {
  try {
    client.writeData(path, data);
  }
  catch (final ZkNoNodeException e) {
    createParentPath(client, path);
    client.createEphemeral(path, data);
  }
  catch (final Exception e) {
    throw e;
  }
}

代码示例来源:origin: weibocom/motan

/**
   * 更新指定group的指令列表
   *
   * @param command
   * @param group
   * @return
   */
  @Override
  public boolean setCommand(String group, RpcCommand command) {
    String path = getCommandPath(group);
    if (!zkClient.exists(path)) {
      zkClient.createPersistent(path, true);
    }
    try {
      zkClient.writeData(path, RpcCommandUtil.commandToString(command));
    } catch (Exception e) {
      return false;
    }
    return true;
  }
}

代码示例来源:origin: apache/incubator-pinot

private void modifyExistingInstanceConfig(ZkClient zkClient)
  throws InterruptedException {
 String instanceName = "Server_localhost_" + new Random().nextInt(NUM_INSTANCES);
 String instanceConfigPath = PropertyPathBuilder.instanceConfig(_helixClusterName, instanceName);
 Assert.assertTrue(zkClient.exists(instanceConfigPath));
 ZNRecord znRecord = zkClient.readData(instanceConfigPath, null);
 InstanceConfig cachedInstanceConfig = _helixResourceManager.getHelixInstanceConfig(instanceName);
 String originalPort = cachedInstanceConfig.getPort();
 Assert.assertNotNull(originalPort);
 String newPort = Long.toString(System.currentTimeMillis());
 Assert.assertTrue(!newPort.equals(originalPort));
 // Set new port to this instance config.
 znRecord.setSimpleField(InstanceConfig.InstanceConfigProperty.HELIX_PORT.toString(), newPort);
 zkClient.writeData(instanceConfigPath, znRecord);
 long maxTime = System.currentTimeMillis() + MAX_TIMEOUT_IN_MILLISECOND;
 InstanceConfig latestCachedInstanceConfig = _helixResourceManager.getHelixInstanceConfig(instanceName);
 String latestPort = latestCachedInstanceConfig.getPort();
 while (!newPort.equals(latestPort) && System.currentTimeMillis() < maxTime) {
  Thread.sleep(100L);
  latestCachedInstanceConfig = _helixResourceManager.getHelixInstanceConfig(instanceName);
  latestPort = latestCachedInstanceConfig.getPort();
 }
 Assert.assertTrue(System.currentTimeMillis() < maxTime, "Timeout when waiting for adding instance config");
 // Set original port back to this instance config.
 znRecord.setSimpleField(InstanceConfig.InstanceConfigProperty.HELIX_PORT.toString(), originalPort);
 zkClient.writeData(instanceConfigPath, znRecord);
}

代码示例来源:origin: Dromara/soul

/**
 * create or update plugin.
 *
 * @param pluginDTO {@linkplain PluginDTO}
 * @return rows
 */
@Override
@Transactional(rollbackFor = Exception.class)
public int createOrUpdate(final PluginDTO pluginDTO) {
  int pluginCount;
  PluginDO pluginDO = PluginDO.buildPluginDO(pluginDTO);
  if (StringUtils.isEmpty(pluginDTO.getId())) {
    pluginCount = pluginMapper.insertSelective(pluginDO);
  } else {
    pluginCount = pluginMapper.updateSelective(pluginDO);
  }
  String pluginPath = ZkPathConstants.buildPluginPath(pluginDO.getName());
  if (!zkClient.exists(pluginPath)) {
    zkClient.createPersistent(pluginPath, true);
  }
  zkClient.writeData(pluginPath, new PluginZkDTO(pluginDO.getId(),
      pluginDO.getName(), pluginDO.getEnabled()));
  return pluginCount;
}

代码示例来源:origin: Dromara/soul

/**
 * create or update application authority.
 *
 * @param appAuthDTO {@linkplain AppAuthDTO}
 * @return rows
 */
@Override
public int createOrUpdate(final AppAuthDTO appAuthDTO) {
  int appAuthCount;
  AppAuthDO appAuthDO = AppAuthDO.buildAppAuthDO(appAuthDTO);
  if (StringUtils.isEmpty(appAuthDTO.getId())) {
    appAuthCount = appAuthMapper.insertSelective(appAuthDO);
  } else {
    appAuthCount = appAuthMapper.updateSelective(appAuthDO);
  }
  String appAuthPath = ZkPathConstants.buildAppAuthPath(appAuthDO.getAppKey());
  if (!zkClient.exists(appAuthPath)) {
    zkClient.createPersistent(appAuthPath, true);
  }
  zkClient.writeData(appAuthPath, new AppAuthZkDTO(appAuthDO.getAppKey(), appAuthDO.getAppSecret(), appAuthDO.getEnabled()));
  return appAuthCount;
}

代码示例来源:origin: Dromara/soul

new ConditionZkDTO(selectorConditionDTO.getParamType(), selectorConditionDTO.getOperator(),
        selectorConditionDTO.getParamName(), selectorConditionDTO.getParamValue())).collect(Collectors.toList());
zkClient.writeData(selectorRealPath, new SelectorZkDTO(selectorDO.getId(), selectorDO.getPluginId(), pluginDO.getName(),
    selectorDO.getName(), selectorDO.getMatchMode(), selectorDO.getType(), selectorDO.getSort(), selectorDO.getEnabled(),
    selectorDO.getLoged(), selectorDO.getContinued(), selectorDO.getHandle(), conditionZkDTOs));

代码示例来源:origin: Dromara/soul

new ConditionZkDTO(ruleConditionDTO.getParamType(), ruleConditionDTO.getOperator(),
        ruleConditionDTO.getParamName(), ruleConditionDTO.getParamValue())).collect(Collectors.toList());
zkClient.writeData(ruleRealPath, new RuleZkDTO(ruleDO.getId(), pluginDO.getName(), ruleDO.getSelectorId(),
    ruleDO.getMatchMode(), ruleDO.getSort(), ruleDO.getEnabled(), ruleDO.getLoged(), ruleDO.getHandle(), conditionZkDTOs));
return ruleCount;

代码示例来源:origin: Dromara/soul

zkClient.createPersistent(pluginPath, true);
zkClient.writeData(pluginPath, new PluginZkDTO(pluginDO.getId(),
    pluginDO.getName(), pluginDO.getEnabled()));
      .map(selectorConditionDO -> new ConditionZkDTO(selectorConditionDO.getParamType(), selectorConditionDO.getOperator(),
          selectorConditionDO.getParamName(), selectorConditionDO.getParamValue())).collect(Collectors.toList());
  zkClient.writeData(selectorRealPath, new SelectorZkDTO(selectorDO.getId(), selectorDO.getPluginId(), pluginDO.getName(),
      selectorDO.getName(), selectorDO.getMatchMode(), selectorDO.getType(), selectorDO.getSort(), selectorDO.getEnabled(),
      selectorDO.getLoged(), selectorDO.getContinued(), selectorDO.getHandle(), selectorConditionZkDTOs));
        .map(ruleConditionDO -> new ConditionZkDTO(ruleConditionDO.getParamType(), ruleConditionDO.getOperator(),
            ruleConditionDO.getParamName(), ruleConditionDO.getParamValue())).collect(Collectors.toList());
    zkClient.writeData(ruleRealPath, new RuleZkDTO(ruleDO.getId(), pluginDO.getName(), ruleDO.getSelectorId(),
        ruleDO.getMatchMode(), ruleDO.getSort(), ruleDO.getEnabled(), ruleDO.getLoged(), ruleDO.getHandle(), ruleConditionZkDTOs));
  });

代码示例来源:origin: apache/samza

public void writeData(String path, Object object) {
 zkClient.writeData(path, object);
 metrics.writes.inc();
}

代码示例来源:origin: vakinge/jeesuite-libs

private void commitToZK(){
  if(commited.get())return;
  Set<Entry<String, AtomicLong[]>> entrySet = producerStats.entrySet();
  for (Entry<String, AtomicLong[]> entry : entrySet) {
    AtomicLong[] nums = entry.getValue();
    ProducerStat stat = new ProducerStat(entry.getKey(), producerGroup, nums[0], nums[1], nums[2], nums[3]);
    zkClient.writeData(statPaths.get(entry.getKey()), JsonUtils.toJson(stat));
  }
  commited.set(true);
}

代码示例来源:origin: apache/samza

/**
 * {@inheritDoc}
 */
@Override
public void put(String key, byte[] value) {
 String zkPath = getZkPathForKey(key);
 zkClient.createPersistent(zkPath, true);
 zkClient.writeData(zkPath, value);
}

代码示例来源:origin: org.apache.samza/samza-core_2.11

/**
 * {@inheritDoc}
 */
@Override
public void put(byte[] key, byte[] value) {
 String zkPath = getZkPathForKey(key);
 zkClient.createPersistent(zkPath, true);
 zkClient.writeData(zkPath, value);
}

代码示例来源:origin: org.apache.samza/samza-core_2.10

/**
 * {@inheritDoc}
 */
@Override
public void put(byte[] key, byte[] value) {
 String zkPath = getZkPathForKey(key);
 zkClient.createPersistent(zkPath, true);
 zkClient.writeData(zkPath, value);
}

代码示例来源:origin: org.apache.samza/samza-core

/**
 * {@inheritDoc}
 */
@Override
public void put(byte[] key, byte[] value) {
 String zkPath = getZkPathForKey(key);
 zkClient.createPersistent(zkPath, true);
 zkClient.writeData(zkPath, value);
}

代码示例来源:origin: vakinge/jeesuite-libs

@Override
public void updateJobConfig(JobConfig config) {
  config.setModifyTime(Calendar.getInstance().getTimeInMillis());
  zkClient.writeData(getPath(config), JsonUtils.toJson(config));
  schedulerConfgs.put(config.getJobName(), config);
}

相关文章