Package com.taobao.zeus.store.mysql.tool

Examples of com.taobao.zeus.store.mysql.tool.Judge


  private Map<String, JobPersistence> cacheJobMap=new HashMap<String,JobPersistence>();
  private Map<String, GroupPersistence> cacheGroupMap=new HashMap<String, GroupPersistence>();
 
  private GroupManager groupManager;
  private Map<String, JobPersistence> getCacheJobs(){
    Judge realtime=(Judge) getHibernateTemplate().execute(new HibernateCallback() {
      @Override
      public Object doInHibernate(Session session) throws HibernateException,
          SQLException {
        Object[] o=(Object[]) session.createSQLQuery("select count(*),max(id),max(gmt_modified) from zeus_job").uniqueResult();
        if(o!=null){
          Judge j=new Judge();
          j.count=((Number) o[0]).intValue();
          j.maxId=((Number)o[1]).intValue();
          j.lastModified=(Date) o[2];
          j.stamp=new Date();
          return j;
View Full Code Here


      jobjudge=realtime;
      return cacheJobMap;
    }
  }
  private Map<String, GroupPersistence> getCacheGroups(){
    Judge realtime=(Judge) getHibernateTemplate().execute(new HibernateCallback() {
      @Override
      public Object doInHibernate(Session session) throws HibernateException,
          SQLException {
        Object[] o=(Object[]) session.createSQLQuery("select count(*),max(id),max(gmt_modified) from zeus_group").uniqueResult();
        if(o!=null){
          Judge j=new Judge();
          j.count=((Number) o[0]).intValue();
          j.maxId=((Number)o[1]).intValue();
          j.lastModified=(Date) o[2];
          j.stamp=new Date();
          return j;
View Full Code Here

   * @return
   */
  @SuppressWarnings("unchecked")
  private boolean isJobsAndGroupsChangedIgnoreContent(){
    //init
    final Judge ignoreContentJobJudge=this.ignoreContentJobJudge;
    final Judge ignoreContentGroupJudge=this.ignoreContentGroupJudge;
    final GroupBean ignoreGlobe=this.ignoreGlobe;
   
    boolean jobChanged;
    Judge jobrealtime=null;
    jobrealtime=(Judge) getHibernateTemplate().execute(new HibernateCallback() {
      @Override
      public Object doInHibernate(Session session) throws HibernateException,
          SQLException {
        Object[] o=(Object[]) session.createSQLQuery("select count(*),max(id),max(gmt_modified) from zeus_job").uniqueResult();
        if(o!=null){
          Judge j=new Judge();
          j.count=((Number) o[0]).intValue();
          j.maxId=o[1]==null?0:((Number)o[1]).intValue();
          j.lastModified=o[2]==null?new Date(0):(Date) o[2];
          j.stamp=new Date();
          return j;
        }
        return null;
      }
    });
   
    List<JobDescriptor> changedJobs;
    changedJobs=(List<JobDescriptor>) getHibernateTemplate().execute(new HibernateCallback() {
      @Override
      public Object doInHibernate(Session session) throws HibernateException,
          SQLException {
        Query query=session.createQuery("select id,groupId from com.taobao.zeus.store.mysql.persistence.JobPersistence where gmt_modified>?");
        query.setDate(0, ignoreContentJobJudge.lastModified);
        List<Object[]> list=query.list();
        List<JobDescriptor> result=new ArrayList<JobDescriptor>();
        for(Object[] o:list){
          JobDescriptor jd=new JobDescriptor();
          jd.setId(String.valueOf(o[0]));
          jd.setGroupId(String.valueOf(o[1]));
          result.add(jd);
        }
        return result;
      }
    });
   
    if(jobrealtime!=null && jobrealtime.count.equals(ignoreContentJobJudge.count) && jobrealtime.maxId.equals(ignoreContentJobJudge.maxId)
        && isAllJobsNotChangeParent(ignoreGlobe, changedJobs)){
      ignoreContentJobJudge.stamp=new Date();
      ignoreContentJobJudge.lastModified=jobrealtime.lastModified;
      jobChanged= false;
    }else{
      this.ignoreContentJobJudge=jobrealtime;
      jobChanged= true;
    }
   
   
    //Group
    boolean groupChanged;
    Judge grouprealtime=null;
    grouprealtime=(Judge) getHibernateTemplate().execute(new HibernateCallback() {
      @Override
      public Object doInHibernate(Session session) throws HibernateException,
          SQLException {
        Object[] o=(Object[]) session.createSQLQuery("select count(*),max(id),max(gmt_modified) from zeus_group").uniqueResult();
        if(o!=null){
          Judge j=new Judge();
          j.count=((Number) o[0]).intValue();
          j.maxId=o[1]==null?0:((Number)o[1]).intValue();
          j.lastModified=o[2]==null?new Date(0):(Date) o[2];
          j.stamp=new Date();
          return j;
View Full Code Here

   * 3.last_modified 一致
   * @return
   */
  private boolean isJobsAndGroupsChanged(){
    //init
    final Judge jobjudge=this.jobjudge;
    final Judge groupjudge=this.groupjudge;
   
    boolean jobChanged;
    Judge jobrealtime=(Judge) getHibernateTemplate().execute(new HibernateCallback() {
      @Override
      public Object doInHibernate(Session session) throws HibernateException,
          SQLException {
        Object[] o=(Object[]) session.createSQLQuery("select count(*),max(id),max(gmt_modified) from zeus_job").uniqueResult();
        if(o!=null){
          Judge j=new Judge();
          j.count=((Number) o[0]).intValue();
          j.maxId=((Number)o[1]).intValue();
          j.lastModified=(Date) o[2];
          j.stamp=new Date();
          return j;
        }
        return null;
      }
    });
   
    if(jobrealtime!=null && jobrealtime.count.equals(jobjudge.count) && jobrealtime.maxId.equals(jobjudge.maxId) && jobrealtime.lastModified.equals(jobjudge.lastModified)){
      jobjudge.stamp=new Date();
      jobChanged= false;
    }else{
      this.jobjudge=jobrealtime;
      jobChanged= true;
    }
   
    boolean groupChanged;
    Judge grouprealtime=(Judge) getHibernateTemplate().execute(new HibernateCallback() {
      @Override
      public Object doInHibernate(Session session) throws HibernateException,
          SQLException {
        Object[] o=(Object[]) session.createSQLQuery("select count(*),max(id),max(gmt_modified) from zeus_group").uniqueResult();
        if(o!=null){
          Judge j=new Judge();
          j.count=((Number) o[0]).intValue();
          j.maxId=((Number)o[1]).intValue();
          j.lastModified=(Date) o[2];
          j.stamp=new Date();
          return j;
View Full Code Here

TOP

Related Classes of com.taobao.zeus.store.mysql.tool.Judge

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.