use of com.chinaunicom.rundocker.service.MesosService in project mesosFramework by zhizuqiu.
the class DockerScheduler method registered.
@Override
public void registered(SchedulerDriver schedulerDriver, FrameworkID frameworkID, MasterInfo masterInfo) {
Long logTime = System.currentTimeMillis();
logger.info("[" + logTime + "]" + "---------------------");
logger.info("[" + logTime + "]" + "Registered:" + frameworkID);
logger.info("[" + logTime + "]" + "masterInfo:" + masterInfo);
// 记录frameworkId
AppDataStore.getInfo().setFrameworkId(frameworkID.getValue());
// 从masterInfo中获取masterUrl
String masterUrl = SchedulerService.getMasterUrl(masterInfo);
logger.info("[" + logTime + "]" + "masterUrl:" + masterUrl);
if (masterUrl != null) {
AppDataStore.getConfig().setMesosMasterUrl(masterUrl);
mesosService = new MesosService(masterUrl);
}
// 记录schedulerDriver到内存
AppDataStore.setSchedulerDriver(schedulerDriver);
// 记录framework id到etcd,用于重新注册
boolean setSuccess = etcdService.setNodeOnly(logTime, AppDataStore.getConfig().getFrameworkName() + WatchStaticStr.FRAMEWORK_ID, frameworkID.getValue());
logger.info("[" + logTime + "]" + "set framework id:" + setSuccess);
// 以file中的配置为准,否则以etcd中的配置为准
if (Config.ConfigStatic.STORE_FILE.equals(AppDataStore.getConfig().getStore())) {
// 从etcd中恢复任务
boolean getSuccess = etcdService.getJobsFromEtcd(logTime);
logger.info("[" + logTime + "]" + "getJobsFromEtcd:" + getSuccess);
// 从file中获取任务
getSuccess = SchedulerService.saveJobsToAppData(SchedulerService.getJobsFromFile());
logger.info("[" + logTime + "]" + "getJobsFromFile:" + getSuccess);
} else if (Config.ConfigStatic.STORE_ETCD.equals(AppDataStore.getConfig().getStore())) {
// 从file中获取任务
boolean getSuccess = SchedulerService.saveJobsToAppData(SchedulerService.getJobsFromFile());
logger.info("[" + logTime + "]" + "getJobsFromFile:" + getSuccess);
// 从etcd中恢复任务
getSuccess = etcdService.getJobsFromEtcd(logTime);
logger.info("[" + logTime + "]" + "getJobsFromEtcd:" + getSuccess);
} else {
// 从mustache中获取任务
boolean getSuccess = SchedulerService.saveJobsToAppData(SchedulerService.getJobsFromMustache());
logger.info("[" + logTime + "]" + "getJobsFromMustache:" + getSuccess);
// 从etcd中恢复任务
getSuccess = etcdService.getJobsFromEtcd(logTime);
logger.info("[" + logTime + "]" + "getJobsFromEtcd:" + getSuccess);
}
// 保存任务到etcd
boolean saveSuccess = SchedulerService.saveJobsToEtcd(etcdService);
logger.info("[" + logTime + "]" + "saveJobsToEtcd:" + saveSuccess);
logger.info("[" + logTime + "]" + "load etcd job , size :" + AppDataStore.jobsSize());
logger.info("[" + logTime + "]" + "load etcd jobStatus , size :" + AppDataStore.statusSize());
// reconcile tasks
logger.info("[" + logTime + "]" + "----------");
List<Protos.TaskStatus> runningTasks = Tools.reconcileTasks();
logger.info("[" + logTime + "]" + "reconcileTasks size:" + runningTasks.size());
// record port
Tools.initPortsUsed();
}
use of com.chinaunicom.rundocker.service.MesosService in project mesosFramework by zhizuqiu.
the class DockerScheduler method reregistered.
/**
* 重新注册时回调
*/
@Override
public void reregistered(SchedulerDriver schedulerDriver, MasterInfo masterInfo) {
// 时间戳
Long logTime = System.currentTimeMillis();
logger.info("[" + logTime + "]" + "---------------------");
logger.info("[" + logTime + "]" + "Re-registered , ");
// 记录schedulerDriver到内存
AppDataStore.setSchedulerDriver(schedulerDriver);
// 要求接受offer
schedulerDriver.reviveOffers();
// 从masterInfo中获取masterUrl
String masterUrl = SchedulerService.getMasterUrl(masterInfo);
logger.info("[" + logTime + "]" + "masterUrl:" + masterUrl);
if (masterUrl != null) {
AppDataStore.getConfig().setMesosMasterUrl(masterUrl);
mesosService = new MesosService(masterUrl);
}
}
Aggregations