本文整理了Java中com.spotify.helios.master.ZooKeeperMasterModel
类的一些代码示例,展示了ZooKeeperMasterModel
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeperMasterModel
类的具体详情如下:
包路径:com.spotify.helios.master.ZooKeeperMasterModel
类名称:ZooKeeperMasterModel
[英]The Helios Master's view into ZooKeeper.
[中]赫利奥斯大师对动物园管理员的看法。
代码示例来源:origin: spotify/helios
@Before
public void setUp() throws Exception {
// make zookeeper interfaces
curator = zk().curatorWithSuperAuth();
final ZooKeeperClientProvider zkcp = new ZooKeeperClientProvider(
new DefaultZooKeeperClient(curator), ZooKeeperModelReporter.noop());
final List<EventSender> eventSenders = Collections.emptyList();
zkMasterModel = new ZooKeeperMasterModel(zkcp, getClass().getName(), eventSenders, "");
startDefaultMaster();
agent = startDefaultAgent(TEST_HOST);
client = defaultClient();
awaitHostRegistered(client, TEST_HOST, LONG_WAIT_SECONDS, SECONDS);
}
代码示例来源:origin: spotify/helios
final String token)
throws HostNotFoundException, JobNotDeployedException, TokenVerificationException {
assertHostExists(client, host);
final Deployment deployment = getDeployment(host, jobId);
if (deployment == null) {
throw new JobNotDeployedException(host, jobId);
final Job job = getJob(client, jobId);
verifyToken(token, job);
final String configHostJobPath = Paths.configHostJob(host, jobId);
nodes.add(Paths.configJobHost(jobId, host));
final List<Integer> staticPorts = staticPorts(job);
for (final int port : staticPorts) {
nodes.add(Paths.configHostPort(host, port));
代码示例来源: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: spotify/helios
final ZooKeeperClient client = provider.get("getJobStatus");
final Job job = getJob(client, jobId);
if (job == null) {
return null;
hosts = listJobHosts(client, jobId);
} catch (JobDoesNotExistException e) {
return null;
final ImmutableMap.Builder<String, TaskStatus> taskStatuses = ImmutableMap.builder();
for (final String host : hosts) {
final TaskStatus taskStatus = getTaskStatus(client, host, jobId);
if (taskStatus != null) {
taskStatuses.put(host, taskStatus);
final Deployment deployment = getDeployment(host, jobId);
if (deployment != null) {
deployments.put(host, deployment);
代码示例来源:origin: spotify/helios
/**
* Returns the current status of the host named by {@code host}.
*/
@Override
public HostStatus getHostStatus(final String host) {
final ZooKeeperClient client = provider.get("getHostStatus");
if (!ZooKeeperRegistrarUtil.isHostRegistered(client, host)) {
log.warn("Host {} isn't registered in ZooKeeper.", host);
return null;
}
final boolean up = checkHostUp(client, host);
final HostInfo hostInfo = getHostInfo(client, host);
final AgentInfo agentInfo = getAgentInfo(client, host);
final Map<JobId, Deployment> tasks = getTasks(client, host);
final Map<JobId, TaskStatus> statuses = getTaskStatuses(client, host);
final Map<String, String> environment = getEnvironment(client, host);
final Map<String, String> labels = getLabels(client, host);
return HostStatus.newBuilder()
.setJobs(tasks)
.setStatuses(fromNullable(statuses).or(EMPTY_STATUSES))
.setHostInfo(hostInfo)
.setAgentInfo(agentInfo)
.setStatus(up ? UP : DOWN)
.setEnvironment(environment)
.setLabels(labels)
.build();
}
代码示例来源:origin: spotify/helios
final Job job = getJob(id);
verifyToken(token, job);
final String taskCreationPath = Paths.configHostJobCreation(host, id, operationId);
final List<Integer> staticPorts = staticPorts(job);
final Map<String, byte[]> portNodes = Maps.newHashMap();
final byte[] idJson = id.toJsonBytes();
} catch (NoNodeException e) {
assertJobExists(client, id);
assertHostExists(client, host);
deployJobRetry(client, host, deployment, count + 1, token);
} catch (NodeExistsException e) {
checkForPortConflicts(client, host, port, id);
代码示例来源:origin: spotify/helios
final DeploymentGroup deploymentGroup,
final String host) {
final TaskStatus taskStatus = getTaskStatus(client, host, deploymentGroup.getJobId());
final JobId jobId = deploymentGroup.getJobId();
final Deployment deployment = getDeployment(host, jobId);
if (deployment == null) {
return opFactory.error(
if (isRolloutTimedOut(client, deploymentGroup)) {
return opFactory.error("timed out while retrieving job status", host,
RollingUpdateError.TIMED_OUT_RETRIEVING_JOB_STATUS);
if (isRolloutTimedOut(client, deploymentGroup)) {
return rollingUpdateTimedoutError(opFactory, host, jobId, taskStatus);
final Deployment deployment = getDeployment(host, deploymentGroup.getJobId());
if (deployment == null) {
return opFactory.error(
代码示例来源:origin: spotify/helios
@Test
public void testMaster() throws Exception {
final JobId jobId = createAndAwaitJobRunning();
// shut down the agent so it cannot remove the tombstone we make
agent.stopAsync().awaitTerminated();
// make sure things look correct before
assertFalse(zkMasterModel.getJobs().isEmpty());
assertEquals(START, zkMasterModel.getDeployment(TEST_HOST, jobId).getGoal());
// undeploy job
client.undeploy(jobId, TEST_HOST).get();
// These used to be filtered away
assertNull(zkMasterModel.getDeployment(TEST_HOST, jobId));
assertTrue(zkMasterModel.getHostStatus(TEST_HOST).getJobs().isEmpty());
}
代码示例来源:origin: at.molindo/helios-services
private RollingUpdateTaskResult rollingUpdateAwaitRunning(final DeploymentGroup deploymentGroup,
final String host) {
final ZooKeeperClient client = provider.get("rollingUpdateAwaitRunning");
final Map<JobId, TaskStatus> taskStatuses = getTaskStatuses(client, host);
final Deployment deployment = getDeployment(host, deploymentGroup.getJobId());
if (deployment == null) {
return RollingUpdateTaskResult.error(
if (isRolloutTimedOut(deploymentGroup, client)) {
return RollingUpdateTaskResult.error("timed out while retrieving job status", host);
if (isRolloutTimedOut(deploymentGroup, client)) {
final Deployment deployment = getDeployment(host, deploymentGroup.getJobId());
if (deployment == null) {
return RollingUpdateTaskResult.error(
代码示例来源:origin: spotify/helios
.filter(host -> checkHostUp(zooKeeperClient, host))
.collect(Collectors.toList());
final List<String> upHostsToDeploy = updateHostsCopy.stream()
.filter(host -> checkHostUp(zooKeeperClient, host))
.collect(Collectors.toList());
代码示例来源:origin: spotify/helios
/**
* Creates a config entry within the specified agent to un/deploy a job, or more generally, change
* the deployment status according to the {@code Goal} value in {@link Deployment}.
*/
@Override
public void deployJob(final String host, final Deployment deployment, final String token)
throws JobDoesNotExistException, JobAlreadyDeployedException, HostNotFoundException,
JobPortAllocationConflictException, TokenVerificationException {
final ZooKeeperClient client = provider.get("deployJob");
deployJobRetry(client, host, deployment, 0, token);
}
代码示例来源:origin: spotify/helios
@Override
public void deployJob(String host, Deployment job)
throws HostNotFoundException, JobAlreadyDeployedException, JobDoesNotExistException,
JobPortAllocationConflictException {
try {
deployJob(host, job, Job.EMPTY_TOKEN);
} catch (TokenVerificationException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: spotify/helios
private RollingUpdateOp rollingUpdateDeploy(final ZooKeeperClient client,
final RollingUpdateOpFactory opFactory,
final DeploymentGroup deploymentGroup,
final String host) {
final Deployment deployment = Deployment.of(deploymentGroup.getJobId(), Goal.START,
Deployment.EMTPY_DEPLOYER_USER, this.name,
deploymentGroup.getName());
try {
final String token = MoreObjects.firstNonNull(
deploymentGroup.getRolloutOptions().getToken(), Job.EMPTY_TOKEN);
return opFactory.nextTask(getDeployOperations(client, host, deployment, token));
} catch (JobDoesNotExistException e) {
return opFactory.error(e, host, RollingUpdateError.JOB_NOT_FOUND);
} catch (TokenVerificationException e) {
return opFactory.error(e, host, RollingUpdateError.TOKEN_VERIFICATION_ERROR);
} catch (HostNotFoundException e) {
return opFactory.error(e, host, RollingUpdateError.HOST_NOT_FOUND);
} catch (JobPortAllocationConflictException e) {
return opFactory.error(e, host, RollingUpdateError.PORT_CONFLICT);
} catch (JobAlreadyDeployedException e) {
// Nothing to do
return opFactory.nextTask();
}
}
代码示例来源:origin: spotify/helios
@Override
public AgentInfo getAgentInfo(final String host) {
return getAgentInfo(provider.get("getAgentInfo"), host);
}
代码示例来源:origin: spotify/helios
@Override
public boolean isHostUp(final String host) {
final ZooKeeperClient client = provider.get("isHostUp");
return ZooKeeperRegistrarUtil.isHostRegistered(client, host) && checkHostUp(client, host);
}
代码示例来源:origin: at.molindo/helios-services
final boolean up = checkHostUp(client, host);
final HostInfo hostInfo = getHostInfo(client, host);
final AgentInfo agentInfo = getAgentInfo(client, host);
final Map<JobId, Deployment> tasks = getTasks(client, host);
final Map<JobId, TaskStatus> statuses = getTaskStatuses(client, host);
final Map<String, String> environment = getEnvironment(client, host);
final Map<String, String> labels = getLabels(client, host);
代码示例来源:origin: at.molindo/helios-services
final Job job = getJob(id);
verifyToken(token, job);
final String taskCreationPath = Paths.configHostJobCreation(host, id, operationId);
final List<Integer> staticPorts = staticPorts(job);
final Map<String, byte[]> portNodes = Maps.newHashMap();
final byte[] idJson = id.toJsonBytes();
} catch (NoNodeException e) {
assertJobExists(client, id);
assertHostExists(client, host);
deployJobRetry(client, host, deployment, count + 1, token);
} catch (NodeExistsException e) {
代码示例来源:origin: at.molindo/helios-services
final ZooKeeperClient client = provider.get("getJobStatus");
final Job job = getJob(client, jobId);
if (job == null) {
return null;
hosts = listJobHosts(client, jobId);
} catch (JobDoesNotExistException e) {
return null;
final ImmutableMap.Builder<String, TaskStatus> taskStatuses = ImmutableMap.builder();
for (final String host : hosts) {
final TaskStatus taskStatus = getTaskStatus(client, host, jobId);
if (taskStatus != null) {
taskStatuses.put(host, taskStatus);
final Deployment deployment = getDeployment(host, jobId);
if (deployment != null) {
deployments.put(host, deployment);
代码示例来源:origin: at.molindo/helios-services
/**
* Creates a config entry within the specified agent to un/deploy a job, or more generally, change
* the deployment status according to the {@code Goal} value in {@link Deployment}.
*/
@Override
public void deployJob(final String host, final Deployment deployment, final String token)
throws JobDoesNotExistException, JobAlreadyDeployedException, HostNotFoundException,
JobPortAllocationConflictException, TokenVerificationException {
final ZooKeeperClient client = provider.get("deployJob");
deployJobRetry(client, host, deployment, 0, token);
}
代码示例来源:origin: at.molindo/helios-services
@Override
public void deployJob(String host, Deployment job)
throws HostNotFoundException, JobAlreadyDeployedException, JobDoesNotExistException,
JobPortAllocationConflictException {
try {
deployJob(host, job, Job.EMPTY_TOKEN);
} catch (TokenVerificationException e) {
throw Throwables.propagate(e);
}
}
内容来源于网络,如有侵权,请联系作者删除!