com.xxl.job.admin.core.model.XxlJobRegistry Java Examples

The following examples show how to use com.xxl.job.admin.core.model.XxlJobRegistry. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JobGroupController.java    From microservices-platform with Apache License 2.0 6 votes vote down vote up
private List<String> findRegistryByAppName(String appNameParam){
	HashMap<String, List<String>> appAddressMap = new HashMap<String, List<String>>();
	List<XxlJobRegistry> list = XxlJobAdminConfig.getAdminConfig().getXxlJobRegistryDao().findAll(RegistryConfig.DEAD_TIMEOUT);
	if (list != null) {
		for (XxlJobRegistry item: list) {
			if (RegistryConfig.RegistType.EXECUTOR.name().equals(item.getRegistryGroup())) {
				String appName = item.getRegistryKey();
				List<String> registryList = appAddressMap.get(appName);
				if (registryList == null) {
					registryList = new ArrayList<String>();
				}

				if (!registryList.contains(item.getRegistryValue())) {
					registryList.add(item.getRegistryValue());
				}
				appAddressMap.put(appName, registryList);
			}
		}
	}
	return appAddressMap.get(appNameParam);
}
 
Example #2
Source File: JobGroupController.java    From zuihou-admin-boot with Apache License 2.0 6 votes vote down vote up
private List<String> findRegistryByAppName(String appNameParam) {
    HashMap<String, List<String>> appAddressMap = new HashMap<String, List<String>>();
    List<XxlJobRegistry> list = XxlJobAdminConfig.getAdminConfig().getXxlJobRegistryDao().findAll(RegistryConfig.DEAD_TIMEOUT);
    if (list != null) {
        for (XxlJobRegistry item : list) {
            if (RegistryConfig.RegistType.EXECUTOR.name().equals(item.getRegistryGroup())) {
                String appName = item.getRegistryKey();
                List<String> registryList = appAddressMap.get(appName);
                if (registryList == null) {
                    registryList = new ArrayList<String>();
                }

                if (!registryList.contains(item.getRegistryValue())) {
                    registryList.add(item.getRegistryValue());
                }
                appAddressMap.put(appName, registryList);
            }
        }
    }
    return appAddressMap.get(appNameParam);
}
 
Example #3
Source File: JobGroupController.java    From zuihou-admin-cloud with Apache License 2.0 6 votes vote down vote up
private List<String> findRegistryByAppName(String appNameParam) {
    HashMap<String, List<String>> appAddressMap = new HashMap<String, List<String>>();
    List<XxlJobRegistry> list = XxlJobAdminConfig.getAdminConfig().getXxlJobRegistryDao().findAll(RegistryConfig.DEAD_TIMEOUT);
    if (list != null) {
        for (XxlJobRegistry item : list) {
            if (RegistryConfig.RegistType.EXECUTOR.name().equals(item.getRegistryGroup())) {
                String appName = item.getRegistryKey();
                List<String> registryList = appAddressMap.get(appName);
                if (registryList == null) {
                    registryList = new ArrayList<String>();
                }

                if (!registryList.contains(item.getRegistryValue())) {
                    registryList.add(item.getRegistryValue());
                }
                appAddressMap.put(appName, registryList);
            }
        }
    }
    return appAddressMap.get(appNameParam);
}
 
Example #4
Source File: JobGroupController.java    From xxl-job with GNU General Public License v3.0 6 votes vote down vote up
private List<String> findRegistryByAppName(String appnameParam){
	HashMap<String, List<String>> appAddressMap = new HashMap<String, List<String>>();
	List<XxlJobRegistry> list = xxlJobRegistryDao.findAll(RegistryConfig.DEAD_TIMEOUT, new Date());
	if (list != null) {
		for (XxlJobRegistry item: list) {
			if (RegistryConfig.RegistType.EXECUTOR.name().equals(item.getRegistryGroup())) {
				String appname = item.getRegistryKey();
				List<String> registryList = appAddressMap.get(appname);
				if (registryList == null) {
					registryList = new ArrayList<String>();
				}

				if (!registryList.contains(item.getRegistryValue())) {
					registryList.add(item.getRegistryValue());
				}
				appAddressMap.put(appname, registryList);
			}
		}
	}
	return appAddressMap.get(appnameParam);
}
 
Example #5
Source File: XxlJobRegistryDaoTest.java    From microservices-platform with Apache License 2.0 5 votes vote down vote up
@Test
public void test(){
    int ret = xxlJobRegistryDao.registryUpdate("g1", "k1", "v1");
    if (ret < 1) {
        ret = xxlJobRegistryDao.registrySave("g1", "k1", "v1");
    }

    List<XxlJobRegistry> list = xxlJobRegistryDao.findAll(1);

    int ret2 = xxlJobRegistryDao.removeDead(1);
}
 
Example #6
Source File: XxlJobRegistryDaoTest.java    From xxl-job with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void test(){
    int ret = xxlJobRegistryDao.registryUpdate("g1", "k1", "v1", new Date());
    if (ret < 1) {
        ret = xxlJobRegistryDao.registrySave("g1", "k1", "v1", new Date());
    }

    List<XxlJobRegistry> list = xxlJobRegistryDao.findAll(1, new Date());

    int ret2 = xxlJobRegistryDao.removeDead(Arrays.asList(1));
}
 
Example #7
Source File: JobRegistryMonitorHelper.java    From open-capacity-platform with Apache License 2.0 4 votes vote down vote up
public void start(){
	//����һ���߳�
	registryThread = new Thread(new Runnable() {
		@Override
		public void run() {
			// ��toStop Ϊfalseʱ�����ѭ����
			while (!toStop) {
				try {
					// auto registry group
					// ��ȡ����Ϊ�Զ�ע���ִ������ַ�б�
					List<XxlJobGroup> groupList = XxlJobDynamicScheduler.xxlJobGroupDao.findByAddressType(0);
					if (CollectionUtils.isNotEmpty(groupList)) {

						// remove dead address (admin/executor)
						// ɾ�� 90��֮��û�и�����Ϣ��ע������� 90��û��������Ϣ���أ���������Ѿ��������⣬���Ƴ�--
						XxlJobDynamicScheduler.xxlJobRegistryDao.removeDead(RegistryConfig.DEAD_TIMEOUT);

						// fresh online address (admin/executor)
						HashMap<String, List<String>> appAddressMap = new HashMap<String, List<String>>();
						// ��ѯ��90��֮���й����µĻ����б�
						List<XxlJobRegistry> list = XxlJobDynamicScheduler.xxlJobRegistryDao.findAll(RegistryConfig.DEAD_TIMEOUT);
						//ѭ��ע������б�  ����ִ������ͬ������Щ�����б������ó���
						if (list != null) {
							for (XxlJobRegistry item: list) {
								// �жϸû���ע����ϢRegistryGroup ��RegistType �Ƿ���EXECUTOR , EXECUTOR ����û�����ע�ᵽִ���������
								// RegistType  ��Ϊ���֣� ADMIN ��EXECUTOR
								if (RegistryConfig.RegistType.EXECUTOR.name().equals(item.getRegistryGroup())) {
									// ��ȡע���ִ���� KEY  ��Ҳ����ִ������
									String appName = item.getRegistryKey();
									List<String> registryList = appAddressMap.get(appName);
									if (registryList == null) {
										registryList = new ArrayList<String>();
									}

									if (!registryList.contains(item.getRegistryValue())) {
										registryList.add(item.getRegistryValue());
									}
									// �ռ� ������Ϣ������ִ����������
									appAddressMap.put(appName, registryList);
								}
							}
						}

						// fresh group address
						//  ����ִ�����б�
						for (XxlJobGroup group: groupList) {
							// ͨ��ִ������APP_NAME  �ó�������ļ�Ⱥ������ַ
							List<String> registryList = appAddressMap.get(group.getAppName());
							String addressListStr = null;
							if (CollectionUtils.isNotEmpty(registryList)) {
								Collections.sort(registryList);
								// תΪΪString����ͨ�����ŷָ�
								addressListStr = StringUtils.join(registryList, ",");
							}
							group.setAddressList(addressListStr);
							// �� ���ִ������ ��Ⱥ������ַ�б�д�뵽���ݿ�
							XxlJobDynamicScheduler.xxlJobGroupDao.update(group);
						}
					}
				} catch (Exception e) {
					logger.error("job registry instance error:{}", e);
				}
				try {
					TimeUnit.SECONDS.sleep(RegistryConfig.BEAT_TIMEOUT);
				} catch (InterruptedException e) {
					logger.error("job registry instance error:{}", e);
				}
			}
		}
	});
	registryThread.setDaemon(true);
	//�����߳�
	registryThread.start();
}
 
Example #8
Source File: JobRegistryMonitorHelper.java    From microservices-platform with Apache License 2.0 4 votes vote down vote up
public void start(){
	registryThread = new Thread(new Runnable() {
		@Override
		public void run() {
			while (!toStop) {
				try {
					// auto registry group
					List<XxlJobGroup> groupList = XxlJobAdminConfig.getAdminConfig().getXxlJobGroupDao().findByAddressType(0);
					if (groupList!=null && !groupList.isEmpty()) {

						// remove dead address (admin/executor)
						XxlJobAdminConfig.getAdminConfig().getXxlJobRegistryDao().removeDead(RegistryConfig.DEAD_TIMEOUT);

						// fresh online address (admin/executor)
						HashMap<String, List<String>> appAddressMap = new HashMap<String, List<String>>();
						List<XxlJobRegistry> list = XxlJobAdminConfig.getAdminConfig().getXxlJobRegistryDao().findAll(RegistryConfig.DEAD_TIMEOUT);
						if (list != null) {
							for (XxlJobRegistry item: list) {
								if (RegistryConfig.RegistType.EXECUTOR.name().equals(item.getRegistryGroup())) {
									String appName = item.getRegistryKey();
									List<String> registryList = appAddressMap.get(appName);
									if (registryList == null) {
										registryList = new ArrayList<String>();
									}

									if (!registryList.contains(item.getRegistryValue())) {
										registryList.add(item.getRegistryValue());
									}
									appAddressMap.put(appName, registryList);
								}
							}
						}

						// fresh group address
						for (XxlJobGroup group: groupList) {
							List<String> registryList = appAddressMap.get(group.getAppName());
							String addressListStr = null;
							if (registryList!=null && !registryList.isEmpty()) {
								Collections.sort(registryList);
								addressListStr = StringUtils.join(registryList, ",");
							}
							group.setAddressList(addressListStr);
							XxlJobAdminConfig.getAdminConfig().getXxlJobGroupDao().update(group);
						}
					}
				} catch (Exception e) {
					if (!toStop) {
						logger.error(">>>>>>>>>>> xxl-job, job registry monitor thread error:{}", e);
					}
				}
				try {
					TimeUnit.SECONDS.sleep(RegistryConfig.BEAT_TIMEOUT);
				} catch (InterruptedException e) {
					if (!toStop) {
						logger.error(">>>>>>>>>>> xxl-job, job registry monitor thread error:{}", e);
					}
				}
			}
			logger.info(">>>>>>>>>>> xxl-job, job registry monitor thread stop");
		}
	});
	registryThread.setDaemon(true);
	registryThread.start();
}
 
Example #9
Source File: JobRegistryMonitorHelper.java    From zuihou-admin-boot with Apache License 2.0 4 votes vote down vote up
public void start() {
    registryThread = new Thread(new Runnable() {
        @Override
        public void run() {
            while (!toStop) {
                try {
                    // auto registry group
                    List<XxlJobGroup> groupList = XxlJobAdminConfig.getAdminConfig().getXxlJobGroupDao().findByAddressType(0);
                    if (CollectionUtils.isNotEmpty(groupList)) {

                        // remove dead address (admin/executor)
                        XxlJobAdminConfig.getAdminConfig().getXxlJobRegistryDao().removeDead(RegistryConfig.DEAD_TIMEOUT);

                        // fresh online address (admin/executor)
                        HashMap<String, List<String>> appAddressMap = new HashMap<String, List<String>>();
                        List<XxlJobRegistry> list = XxlJobAdminConfig.getAdminConfig().getXxlJobRegistryDao().findAll(RegistryConfig.DEAD_TIMEOUT);
                        if (list != null) {
                            for (XxlJobRegistry item : list) {
                                if (RegistryConfig.RegistType.EXECUTOR.name().equals(item.getRegistryGroup())) {
                                    String appName = item.getRegistryKey();
                                    List<String> registryList = appAddressMap.get(appName);
                                    if (registryList == null) {
                                        registryList = new ArrayList<String>();
                                    }

                                    if (!registryList.contains(item.getRegistryValue())) {
                                        registryList.add(item.getRegistryValue());
                                    }
                                    appAddressMap.put(appName, registryList);
                                }
                            }
                        }

                        // fresh group address
                        for (XxlJobGroup group : groupList) {
                            List<String> registryList = appAddressMap.get(group.getAppName());
                            String addressListStr = null;
                            if (CollectionUtils.isNotEmpty(registryList)) {
                                Collections.sort(registryList);
                                addressListStr = StringUtils.join(registryList, ",");
                            }
                            group.setAddressList(addressListStr);
                            XxlJobAdminConfig.getAdminConfig().getXxlJobGroupDao().update(group);
                        }
                    }
                } catch (Exception e) {
                    logger.error("job registry instance error:{}", e);
                }
                try {
                    TimeUnit.SECONDS.sleep(RegistryConfig.BEAT_TIMEOUT);
                } catch (InterruptedException e) {
                    logger.error("job registry instance error:{}", e);
                }
            }
        }
    });
    registryThread.setDaemon(true);
    registryThread.start();
}
 
Example #10
Source File: JobRegistryMonitorHelper.java    From zuihou-admin-cloud with Apache License 2.0 4 votes vote down vote up
public void start() {
    registryThread = new Thread(new Runnable() {
        @Override
        public void run() {
            while (!toStop) {
                try {
                    // auto registry group
                    List<XxlJobGroup> groupList = XxlJobAdminConfig.getAdminConfig().getXxlJobGroupDao().findByAddressType(0);
                    if (CollectionUtils.isNotEmpty(groupList)) {

                        // remove dead address (admin/executor)
                        XxlJobAdminConfig.getAdminConfig().getXxlJobRegistryDao().removeDead(RegistryConfig.DEAD_TIMEOUT);

                        // fresh online address (admin/executor)
                        HashMap<String, List<String>> appAddressMap = new HashMap<String, List<String>>();
                        List<XxlJobRegistry> list = XxlJobAdminConfig.getAdminConfig().getXxlJobRegistryDao().findAll(RegistryConfig.DEAD_TIMEOUT);
                        if (list != null) {
                            for (XxlJobRegistry item : list) {
                                if (RegistryConfig.RegistType.EXECUTOR.name().equals(item.getRegistryGroup())) {
                                    String appName = item.getRegistryKey();
                                    List<String> registryList = appAddressMap.get(appName);
                                    if (registryList == null) {
                                        registryList = new ArrayList<String>();
                                    }

                                    if (!registryList.contains(item.getRegistryValue())) {
                                        registryList.add(item.getRegistryValue());
                                    }
                                    appAddressMap.put(appName, registryList);
                                }
                            }
                        }

                        // fresh group address
                        for (XxlJobGroup group : groupList) {
                            List<String> registryList = appAddressMap.get(group.getAppName());
                            String addressListStr = null;
                            if (CollectionUtils.isNotEmpty(registryList)) {
                                Collections.sort(registryList);
                                addressListStr = StringUtils.join(registryList, ",");
                            }
                            group.setAddressList(addressListStr);
                            XxlJobAdminConfig.getAdminConfig().getXxlJobGroupDao().update(group);
                        }
                    }
                } catch (Exception e) {
                    logger.error("job registry instance error:{}", e);
                }
                try {
                    TimeUnit.SECONDS.sleep(RegistryConfig.BEAT_TIMEOUT);
                } catch (InterruptedException e) {
                    logger.error("job registry instance error:{}", e);
                }
            }
        }
    });
    registryThread.setDaemon(true);
    registryThread.start();
}
 
Example #11
Source File: XxlJobRegistryDao.java    From xxl-job with GNU General Public License v3.0 4 votes vote down vote up
public List<XxlJobRegistry> findAll(@Param("timeout") int timeout,
@Param("nowTime") Date nowTime);
 
Example #12
Source File: JobRegistryMonitorHelper.java    From xxl-job with GNU General Public License v3.0 4 votes vote down vote up
public void start(){
	registryThread = new Thread(new Runnable() {
		@Override
		public void run() {
			while (!toStop) {
				try {
					// auto registry group
					List<XxlJobGroup> groupList = XxlJobAdminConfig.getAdminConfig().getXxlJobGroupDao().findByAddressType(0);
					if (groupList!=null && !groupList.isEmpty()) {

						// remove dead address (admin/executor)
						List<Integer> ids = XxlJobAdminConfig.getAdminConfig().getXxlJobRegistryDao().findDead(RegistryConfig.DEAD_TIMEOUT, new Date());
						if (ids!=null && ids.size()>0) {
							XxlJobAdminConfig.getAdminConfig().getXxlJobRegistryDao().removeDead(ids);
						}

						// fresh online address (admin/executor)
						HashMap<String, List<String>> appAddressMap = new HashMap<String, List<String>>();
						List<XxlJobRegistry> list = XxlJobAdminConfig.getAdminConfig().getXxlJobRegistryDao().findAll(RegistryConfig.DEAD_TIMEOUT, new Date());
						if (list != null) {
							for (XxlJobRegistry item: list) {
								if (RegistryConfig.RegistType.EXECUTOR.name().equals(item.getRegistryGroup())) {
									String appname = item.getRegistryKey();
									List<String> registryList = appAddressMap.get(appname);
									if (registryList == null) {
										registryList = new ArrayList<String>();
									}

									if (!registryList.contains(item.getRegistryValue())) {
										registryList.add(item.getRegistryValue());
									}
									appAddressMap.put(appname, registryList);
								}
							}
						}

						// fresh group address
						for (XxlJobGroup group: groupList) {
							List<String> registryList = appAddressMap.get(group.getAppname());
							String addressListStr = null;
							if (registryList!=null && !registryList.isEmpty()) {
								Collections.sort(registryList);
								addressListStr = "";
								for (String item:registryList) {
									addressListStr += item + ",";
								}
								addressListStr = addressListStr.substring(0, addressListStr.length()-1);
							}
							group.setAddressList(addressListStr);
							XxlJobAdminConfig.getAdminConfig().getXxlJobGroupDao().update(group);
						}
					}
				} catch (Exception e) {
					if (!toStop) {
						logger.error(">>>>>>>>>>> xxl-job, job registry monitor thread error:{}", e);
					}
				}
				try {
					TimeUnit.SECONDS.sleep(RegistryConfig.BEAT_TIMEOUT);
				} catch (InterruptedException e) {
					if (!toStop) {
						logger.error(">>>>>>>>>>> xxl-job, job registry monitor thread error:{}", e);
					}
				}
			}
			logger.info(">>>>>>>>>>> xxl-job, job registry monitor thread stop");
		}
	});
	registryThread.setDaemon(true);
	registryThread.setName("xxl-job, admin JobRegistryMonitorHelper");
	registryThread.start();
}
 
Example #13
Source File: XxlJobRegistryDao.java    From open-capacity-platform with Apache License 2.0 votes vote down vote up
public List<XxlJobRegistry> findAll(@Param("timeout") int timeout); 
Example #14
Source File: XxlJobRegistryDao.java    From microservices-platform with Apache License 2.0 votes vote down vote up
public List<XxlJobRegistry> findAll(@Param("timeout") int timeout); 
Example #15
Source File: XxlJobRegistryDao.java    From zuihou-admin-boot with Apache License 2.0 votes vote down vote up
List<XxlJobRegistry> findAll(@Param("timeout") Integer timeout); 
Example #16
Source File: XxlJobRegistryDao.java    From zuihou-admin-cloud with Apache License 2.0 votes vote down vote up
List<XxlJobRegistry> findAll(@Param("timeout") Integer timeout);