gpt4 book ai didi

com.spotify.helios.servicescommon.coordination.ZooKeeperClient.setData()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-19 03:33:31 28 4
gpt4 key购买 nike

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

ZooKeeperClient.setData介绍

暂无

代码示例

代码示例来源:origin: spotify/helios

@Override
public void setData(String path, byte[] bytes) throws KeeperException {
 reporter.time(tag, "setData", () -> {
  client.setData(path, bytes);
  return null;
 });
}

代码示例来源:origin: spotify/helios

private void write(final String node, final byte[] data) throws KeeperException {
 final ZooKeeperClient client = client("write");
 final String nodePath = ZKPaths.makePath(path, node);
 if (client.stat(nodePath) != null) {
  log.debug("setting node: {}", nodePath);
  client.setData(nodePath, data);
 } else {
  log.debug("creating node: {}", nodePath);
  client.createAndSetData(nodePath, data);
 }
}

代码示例来源:origin: spotify/helios

client.createAndSetData(path, write.data);
} else {
 client.setData(path, write.data);

代码示例来源:origin: spotify/helios

} else if (!Arrays.equals(remoteData, localData)) {
 log.debug("sync: updating node {}", nodePath);
 client.setData(nodePath, localData);
 remote.put(node, localData);

代码示例来源:origin: spotify/helios

@Override
 public boolean update(final byte[] bytes) {
  final String parent = ZKPaths.getPathAndNode(path).getPath();
  try {
   if (zooKeeperClient.stat(parent) == null) {
    return false;
   }
   if (zooKeeperClient.stat(path) == null) {
    zooKeeperClient.createAndSetData(path, bytes);
   } else {
    zooKeeperClient.setData(path, bytes);
   }
   return true;
  } catch (KeeperException.NodeExistsException ignore) {
   // Conflict due to curator retry or losing a race. We're done here.
   return true;
  } catch (KeeperException.ConnectionLossException e) {
   log.warn("ZooKeeper connection lost while updating node: {}", path);
   return false;
  } catch (KeeperException e) {
   log.error("failed to update node: {}", path, e);
   return false;
  }
 }
}

代码示例来源:origin: spotify/helios

/**
 * Used to update the existing deployment of a job.
 */
@Override
public void updateDeployment(final String host, final Deployment deployment, final String token)
  throws HostNotFoundException, JobNotDeployedException, TokenVerificationException {
 log.info("updating deployment {}: {}", deployment, host);
 final ZooKeeperClient client = provider.get("updateDeployment");
 final JobId jobId = deployment.getJobId();
 final Job job = getJob(client, jobId);
 final Deployment existingDeployment = getDeployment(host, jobId);
 if (job == null) {
  throw new JobNotDeployedException(host, jobId);
 }
 verifyToken(token, job);
 assertHostExists(client, host);
 assertTaskExists(client, host, deployment.getJobId());
 final String path = Paths.configHostJob(host, jobId);
 final Task task = new Task(job, deployment.getGoal(),
   existingDeployment.getDeployerUser(),
   existingDeployment.getDeployerMaster(),
   existingDeployment.getDeploymentGroupName());
 try {
  client.setData(path, task.toJsonBytes());
 } catch (Exception e) {
  throw new HeliosRuntimeException("updating deployment " + deployment
                   + " on host " + host + " failed", e);
 }
}

代码示例来源:origin: at.molindo/helios-services

@Override
public void setData(String path, byte[] bytes) throws KeeperException {
 try {
  client.setData(path, bytes);
 } catch (KeeperException e) {
  reporter.checkException(e, tag, "setData");
  throw e;
 }
}

代码示例来源:origin: at.molindo/helios-services

private void write(final String node, final byte[] data) throws KeeperException {
 final ZooKeeperClient client = client("write");
 final String nodePath = ZKPaths.makePath(path, node);
  if (client.stat(nodePath) != null) {
   log.debug("setting node: {}", nodePath);
   client.setData(nodePath, data);
  } else {
   log.debug("creating node: {}", nodePath);
   client.createAndSetData(nodePath, data);
  }
}

代码示例来源:origin: at.molindo/helios-services

client.createAndSetData(path, write.data);
} else {
 client.setData(path, write.data);

代码示例来源:origin: at.molindo/helios-services

} else if (!Arrays.equals(remoteData, localData)) {
 log.debug("sync: updating node {}", nodePath);
 client.setData(nodePath, localData);
 remote.put(node, localData);

代码示例来源:origin: at.molindo/helios-services

@Override
public void updateDeploymentGroupHosts(String name, List<String> hosts)
  throws DeploymentGroupDoesNotExistException {
 log.debug("updating deployment-group hosts: name={}", name);
 final ZooKeeperClient client = provider.get("updateDeploymentGroupHosts");
 try {
  client.setData(Paths.statusDeploymentGroupHosts(name), Json.asBytes(hosts));
 } catch (NoNodeException e) {
  throw new DeploymentGroupDoesNotExistException(name, e);
 } catch (KeeperException | IOException e) {
  throw new HeliosRuntimeException("updating deployment group hosts failed", e);
 }
}

代码示例来源:origin: at.molindo/helios-services

@Override
 public boolean update(final byte[] bytes) {
  final String parent = ZKPaths.getPathAndNode(path).getPath();
  try {
   if (zooKeeperClient.stat(parent) == null) {
    return false;
   }
   if (zooKeeperClient.stat(path) == null) {
    zooKeeperClient.createAndSetData(path, bytes);
   } else {
    zooKeeperClient.setData(path, bytes);
   }
   return true;
  } catch (KeeperException.NodeExistsException ignore) {
   // Conflict due to curator retry or losing a race. We're done here.
   return true;
  } catch (KeeperException.ConnectionLossException e) {
   log.warn("ZooKeeper connection lost while updating node: {}", path);
   return false;
  } catch (KeeperException e) {
   log.error("failed to update node: {}", path, e);
   return false;
  }
 }
}

代码示例来源:origin: at.molindo/helios-services

/**
 * Used to update the existing deployment of a job.
 */
@Override
public void updateDeployment(final String host, final Deployment deployment, final String token)
  throws HostNotFoundException, JobNotDeployedException, TokenVerificationException {
 log.info("updating deployment {}: {}", deployment, host);
 final ZooKeeperClient client = provider.get("updateDeployment");
 final JobId jobId = deployment.getJobId();
 final Job job = getJob(client, jobId);
 final Deployment existingDeployment = getDeployment(host, jobId);
 if (job == null) {
  throw new JobNotDeployedException(host, jobId);
 }
 verifyToken(token, job);
 assertHostExists(client, host);
 assertTaskExists(client, host, deployment.getJobId());
 final String path = Paths.configHostJob(host, jobId);
 final Task task = new Task(job, deployment.getGoal(),
               existingDeployment.getDeployerUser(),
               existingDeployment.getDeployerMaster(),
               existingDeployment.getDeploymentGroupName());
 try {
  client.setData(path, task.toJsonBytes());
 } catch (Exception e) {
  throw new HeliosRuntimeException("updating deployment " + deployment +
                   " on host " + host + " failed", e);
 }
}

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com