- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中me.hao0.antares.common.util.ZkPaths
类的一些代码示例,展示了ZkPaths
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZkPaths
类的具体详情如下:
包路径:me.hao0.antares.common.util.ZkPaths
类名称:ZkPaths
[英]Zk paths Author: haolin Email: haolin.h0@gmail.com
[中]Zk路径作者:haolin电子邮件:haolin。h0@gmail.com
代码示例来源:origin: ihaolin/antares
@Override
protected void onDelete(String path) {
String server = ZkPaths.lastNode(path);
if(alives.remove(server)){
notifyListeners(server, false);
Logs.warn("The server ({}) is left.", server);
}
}
});
代码示例来源:origin: ihaolin/antares
/**
* Get the path of the job
* @param appName the app name
* @param jobClass the job class
* @return /jobs/${appName}/${jobClass}
*/
public static String pathOfJob(String appName, String jobClass){
return format(JOBS, appName, jobClass);
}
代码示例来源:origin: ihaolin/antares
@Override
public void doStart() {
// listen app's clients change
watcher = zk.client().newChildWatcher(ZkPaths.pathOfAppClients(appName), new ChildListener() {
@Override
protected void onAdd(String path, byte[] data) {
// not started, or has shutdown
// prevent multiple redundant notifies before started
if (!started || shutdowned) {
return;
}
String client = ZkPaths.lastNode(path);
if (alives.contains(client)){
return;
}
alives.add(client);
onClientChanged(appName, client, true);
Logs.info("The app({})'s client({}) joined.", appName, client);
}
@Override
protected void onDelete(String path) {
String client = ZkPaths.lastNode(path);
alives.remove(client);
onClientChanged(appName, client, false);
Logs.info("The app({})'s client({}) left.", appName, client);
}
});
}
代码示例来源:origin: ihaolin/antares
/**
* Checking the job is scheduling or not
* @param appName the app name
* @param jobClass the job class
* @return return true if the job is scheduling, or false
*/
public Boolean checkJobScheduling(String appName, String jobClass) {
String jobPath = ZkPaths.pathOfJob(appName, jobClass);
if(!zk.client().checkExists(jobPath)){
return Boolean.FALSE;
}
String scheduler = getJobScheduler(appName, jobClass);
if(Strings.isNullOrEmpty(scheduler)){
// The scheduler is empty
return Boolean.FALSE;
}
if(!zk.client().checkExists(ZkPaths.pathOfServer(scheduler))){
// The scheduler server offline
return Boolean.FALSE;
}
return Boolean.TRUE;
}
代码示例来源:origin: ihaolin/antares
/**
* Find the job instance ids of the job
* @param appName the app name
* @param jobClass the job class
* @return the job instance ids
*/
public List<String> findJobInstances(String appName, String jobClass){
String jobInstancesNode = ZkPaths.pathOfJobInstances(appName, jobClass);
return zk.client().gets(jobInstancesNode);
}
代码示例来源:origin: ihaolin/antares
/**
* Delete the job instance from zk
* @param appName the app name
* @param jobClass the job class
* @param jobInstanceId the job instance id
* @return return true if finished the job instance, or false
*/
public Boolean deleteJobInstance(final String appName, final String jobClass, final Long jobInstanceId){
// delete the job instance
String jobInstanceNode = ZkPaths.pathOfJobInstance(appName, jobClass, jobInstanceId);
zk.client().deleteIfExists(jobInstanceNode);
return Boolean.TRUE;
}
代码示例来源:origin: ihaolin/antares
/**
* Try to wait server to start
* @param server the server
* @return return true if server started, or false
*/
private Boolean tryWaitServerStart(String server) {
Sleeps.sleep(serverFailoverWaitTime);
// check server register?
String serverPath = ZkPaths.pathOfServer(server);
return zk.client().checkExists(serverPath);
}
代码示例来源:origin: ihaolin/antares
/**
* Update the job fire time info
* @param appName the app name
* @param jobClass the job class
* @param jobFireTime the job fire time
* @return return true if update successfully, or false
*/
public Boolean updateJobFireTime(String appName, String jobClass, JobFireTime jobFireTime) {
String jobFireTimeNode = ZkPaths.pathOfJobFireTime(appName, jobClass);
zk.client().mkdirs(jobFireTimeNode);
return zk.client().update(jobFireTimeNode, JSON.toJSONString(jobFireTime));
}
代码示例来源:origin: ihaolin/antares
@Override
public void run() {
ZkClient zk = client.getZk();
// register period, prevent client disconnects unexpected
String appClientPath = ZkPaths.pathOfAppClient(client.getAppName(), Systems.hostPid());
if (!zk.checkExists(appClientPath)){
zk.createEphemeral(appClientPath);
}
}
}, 1, 10, TimeUnit.SECONDS);
代码示例来源:origin: ihaolin/antares
/**
* Remove the job from zk
* @param jobDetail the job detail
* @return return true if remove successfully, or false
*/
public Boolean removeJob(JobDetail jobDetail){
String appJobPath = ZkPaths.pathOfJob(jobDetail.getApp().getAppName(), jobDetail.getJob().getClazz());
zk.client().deleteRecursivelyIfExists(appJobPath);
return Boolean.TRUE;
}
代码示例来源:origin: ihaolin/antares
public AppClientCluster(AntaresZkClient zk, String appName){
this.appName = appName;
this.zk = zk;
// get alive clients once
String appClientsPath = ZkPaths.pathOfAppClients(appName);
zk.client().mkdirs(appClientsPath);
List<String> clients = zk.client().gets(appClientsPath);
if (!CollectionUtil.isNullOrEmpty(clients)){
alives.addAll(clients);
}
}
代码示例来源:origin: ihaolin/antares
/**
* Make the job instances node
* @param appName the app name
* @param jobClass the job class
* @return return true if make successfully, or false
*/
public Boolean mkJobInstances(String appName, String jobClass) {
return zk.client().mkdirs(ZkPaths.pathOfJobInstances(appName, jobClass));
}
代码示例来源:origin: ihaolin/antares
/**
* Trigger the job instance
* @param appName the app name
* @param jobClass the job class
* @param instance the instance
*/
public void triggerJobInstance(String appName, String jobClass, JobInstance instance) {
String jobInstancePath = ZkPaths.pathOfJobInstance(appName, jobClass, instance.getId());
zk.client().create(jobInstancePath, instance.getStatus());
}
代码示例来源:origin: ihaolin/antares
@Override
public void run() {
String server = serverHost.get();
// mkdirs /cluster/servers if necessary
zk.client().mkdirs(ZkPaths.SERVERS);
// register the server node
String serverPath = ZkPaths.pathOfServer(server);
if (!zk.client().checkExists(serverPath)){
String result = zk.client().createEphemeral(ZkPaths.pathOfServer(server));
Logs.info("server({}) registered: {}", server, result);
}
}
}, 1, 5, TimeUnit.SECONDS);
代码示例来源:origin: ihaolin/antares
/**
* Get the job fire time info
* @param appName the app name
* @param jobClass the job class
* @return the job fire time info
*/
public JobFireTime getJobFireTime(String appName, String jobClass){
String jobFireTimeNode = ZkPaths.pathOfJobFireTime(appName, jobClass);
if (!zk.client().checkExists(jobFireTimeNode)){
return null;
}
return zk.client().getJson(jobFireTimeNode, JobFireTime.class);
}
代码示例来源:origin: ihaolin/antares
@Override
public void doStart(){
// mk app clients path
zk.mkdirs(ZkPaths.pathOfAppClients(client.getAppName()));
// register client self
clientRegister = new ClientRegister(client);
clientRegister.start();
// get servers once
getServersOnce();
// listen servers
listenOnServerChanged();
}
代码示例来源:origin: ihaolin/antares
@Override
protected void onAdd(String path, byte[] data) {
String server = ZkPaths.lastNode(path);
client.addHttpServer(server);
log.info("The server({}) joined.", server);
}
代码示例来源:origin: ihaolin/antares
/**
* Check the job has one running job instance
* @param appName the app name
* @param jobClass the job class
* @return return true if has one running job instance, or false
*/
public boolean hasJobInstance(String appName, String jobClass) {
String jobInstanceNodePath = ZkPaths.pathOfJobInstances(appName, jobClass);
List<String> instances = zk.client().gets(jobInstanceNodePath);
return !CollectionUtil.isNullOrEmpty(instances);
}
代码示例来源:origin: ihaolin/antares
protected void checkInvalidInstance(Long instanceId, ZkJob zkJob, ShardOperateRespCode code) {
if (code != null){
if (ShardOperateRespCode.needCleanJobInstance(code)){
// clean the dirty zk job instance
String jobInstancePath = ZkPaths.pathOfJobInstance(client.getAppName(), zkJob.getJobClass(), instanceId);
client.getZk().deleteIfExists(jobInstancePath);
}
}
}
代码示例来源:origin: ihaolin/antares
/**
* Get the path of job instance lock
* @param jobInstanceId the job instance id
* @return the path of job instance lock
*/
public static String pathOfJobInstanceLock(Long jobInstanceId) {
return format(JOB_INSTANCES, jobInstanceId);
}
本文整理了Java中me.hao0.antares.common.zk.ZkClient类的一些代码示例,展示了ZkClient类的具体用法。这些代码示例主要来源于Github/Stackoverfl
本文整理了Java中me.hao0.antares.common.util.ZkPaths类的一些代码示例,展示了ZkPaths类的具体用法。这些代码示例主要来源于Github/Stackoverfl
本文整理了Java中me.hao0.antares.common.zk.ZkClient.gets()方法的一些代码示例,展示了ZkClient.gets()的具体用法。这些代码示例主要来源于Gith
本文整理了Java中me.hao0.antares.common.zk.ZkClient.mkdirs()方法的一些代码示例,展示了ZkClient.mkdirs()的具体用法。这些代码示例主要来源于
本文整理了Java中me.hao0.antares.common.zk.ZkClient.createEphemeral()方法的一些代码示例,展示了ZkClient.createEphemeral(
本文整理了Java中me.hao0.antares.common.zk.ZkClient.newClient()方法的一些代码示例,展示了ZkClient.newClient()的具体用法。这些代码示
本文整理了Java中me.hao0.antares.common.zk.ZkClient.checkExists()方法的一些代码示例,展示了ZkClient.checkExists()的具体用法。这
本文整理了Java中me.hao0.antares.common.zk.ZkClient.update()方法的一些代码示例,展示了ZkClient.update()的具体用法。这些代码示例主要来源于
本文整理了Java中me.hao0.antares.common.util.ZkPaths.pathOfServer()方法的一些代码示例,展示了ZkPaths.pathOfServer()的具体用法
本文整理了Java中me.hao0.antares.common.util.ZkPaths.pathOfAppClients()方法的一些代码示例,展示了ZkPaths.pathOfAppClient
本文整理了Java中me.hao0.antares.common.util.ZkPaths.pathOfJobInstances()方法的一些代码示例,展示了ZkPaths.pathOfJobInst
本文整理了Java中me.hao0.antares.common.util.ZkPaths.pathOfJobInstance()方法的一些代码示例,展示了ZkPaths.pathOfJobInsta
本文整理了Java中me.hao0.antares.common.util.ZkPaths.lastNode()方法的一些代码示例,展示了ZkPaths.lastNode()的具体用法。这些代码示例主
本文整理了Java中me.hao0.antares.common.zk.ZkClient.acquireLeader()方法的一些代码示例,展示了ZkClient.acquireLeader()的具体
本文整理了Java中me.hao0.antares.common.zk.ZkClient.create()方法的一些代码示例,展示了ZkClient.create()的具体用法。这些代码示例主要来源于
本文整理了Java中me.hao0.antares.common.zk.ZkClient.newLock()方法的一些代码示例,展示了ZkClient.newLock()的具体用法。这些代码示例主要来
本文整理了Java中me.hao0.antares.common.zk.ZkClient.deleteIfExists()方法的一些代码示例,展示了ZkClient.deleteIfExists()的
本文整理了Java中me.hao0.antares.common.zk.ZkClient.newChildWatcher()方法的一些代码示例,展示了ZkClient.newChildWatcher(
本文整理了Java中me.hao0.antares.common.zk.ZkClient.getString()方法的一些代码示例,展示了ZkClient.getString()的具体用法。这些代码示
本文整理了Java中me.hao0.antares.common.zk.ZkClient.shutdown()方法的一些代码示例,展示了ZkClient.shutdown()的具体用法。这些代码示例主
我是一名优秀的程序员,十分优秀!