Package org.playorm.monitor.impl.db

Examples of org.playorm.monitor.impl.db.MonitorDbo


    clusterRunnable.setListener(listener);
  }

  @Override
  public void saveMonitor(PlayOrmMonitor monitor) {
    MonitorDbo m = CopyUtil.copy(monitor);
    NoSqlEntityManager mgr = factory.createEntityManager();
    mgr.put(m);
    mgr.flush();
  }
View Full Code Here


  }

  @Override
  public PlayOrmMonitor getMonitor(String id) {
    NoSqlEntityManager mgr = factory.createEntityManager();
    MonitorDbo mon = mgr.find(MonitorDbo.class, id);
    return CopyUtil.copy(mon);
  }
View Full Code Here

    NoSqlEntityManager mgr = factory.createEntityManager();
    Cursor<KeyValue<MonitorDbo>> cursor = mgr.findAll(MonitorDbo.class, ids);
    List<PlayOrmMonitor> monitors = new ArrayList<PlayOrmMonitor>();
    while(cursor.next()) {
      KeyValue<MonitorDbo> kv = cursor.getCurrent();
      MonitorDbo mon = kv.getValue();
      monitors.add(CopyUtil.copy(mon));
    }
    return monitors;
  }
View Full Code Here

  private void runOurMonitors(NoSqlEntityManager mgr, int numUpWebNodes, int serverNumber) {
    log.info("num up nodes="+numUpWebNodes+" servernum="+serverNumber);
    Cursor<KeyValue<MonitorDbo>> cursor = MonitorDbo.findAll(mgr);
    while(cursor.next()) {
      KeyValue<MonitorDbo> kv = cursor.getCurrent();
      MonitorDbo val = kv.getValue();
      String id = val.getId();
      int hash = id.hashCode();
      int serverNum = hashGen.generate(hash, numUpWebNodes);
      log.info("monitor="+val.getId()+" server num="+serverNum+" our num="+serverNumber);
      if(serverNum == serverNumber)
        processMonitor(mgr, val);
    }
  }
View Full Code Here

public class CopyUtil {

  public static MonitorDbo copy(PlayOrmMonitor monitor) {
    if(monitor == null)
      return null;
    MonitorDbo m = new MonitorDbo();
    m.setId(monitor.getId());
    m.setTimePeriodMillis(monitor.getTimePeriodMillis());
   
    String props = "";
    for(String key : monitor.getProperties().keySet()) {
      String value = monitor.getProperties().get(key);
      props += key+"="+value+"|";
    }
    m.setRawProperties(props);
    return m;
  }
View Full Code Here

    clusterRunnable.setListener(listener);
  }

  @Override
  public void saveMonitor(PlayOrmMonitor monitor) {
    MonitorDbo m = CopyUtil.copy(monitor);
    NoSqlEntityManager mgr = factory.createEntityManager();
    mgr.put(m, false);
    mgr.flush();
  }
View Full Code Here

  }

  @Override
  public PlayOrmMonitor getMonitor(String id) {
    NoSqlEntityManager mgr = factory.createEntityManager();
    MonitorDbo mon = mgr.find(MonitorDbo.class, id);
    return CopyUtil.copy(mon);
  }
View Full Code Here

    NoSqlEntityManager mgr = factory.createEntityManager();
    Cursor<KeyValue<MonitorDbo>> cursor = mgr.findAll(MonitorDbo.class, ids);
    List<PlayOrmMonitor> monitors = new ArrayList<PlayOrmMonitor>();
    while(cursor.next()) {
      KeyValue<MonitorDbo> kv = cursor.getCurrent();
      MonitorDbo mon = kv.getValue();
      monitors.add(CopyUtil.copy(mon));
    }
    return monitors;
  }
View Full Code Here

  private void runOurMonitors(NoSqlEntityManager mgr, int numUpWebNodes, int serverNumber) {
    log.info("num up nodes="+numUpWebNodes+" servernum="+serverNumber);
    Cursor<KeyValue<MonitorDbo>> cursor = MonitorDbo.findAll(mgr);
    while(cursor.next()) {
      KeyValue<MonitorDbo> kv = cursor.getCurrent();
      MonitorDbo val = kv.getValue();
      String id = val.getId();
      int hash = id.hashCode();
      int serverNum = hashGen.generate(hash, numUpWebNodes);
      log.info("monitor="+val.getId()+" target server num="+serverNum+" our servernum="+serverNumber);
      if(serverNum == serverNumber)
        processMonitor(mgr, val);
    }
  }
View Full Code Here

TOP

Related Classes of org.playorm.monitor.impl.db.MonitorDbo

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.