Package org.apache.ambari.server.orm.dao

Examples of org.apache.ambari.server.orm.dao.ClusterServiceDAO


    });
  }

  protected void addHistoryServer() {
    ClusterDAO clusterDAO = injector.getInstance(ClusterDAO.class);
    ClusterServiceDAO clusterServiceDAO = injector.getInstance(ClusterServiceDAO.class);
    ServiceComponentDesiredStateDAO serviceComponentDesiredStateDAO = injector.getInstance(ServiceComponentDesiredStateDAO.class);
   
    List<ClusterEntity> clusterEntities = clusterDAO.findAll();
    for (final ClusterEntity clusterEntity : clusterEntities) {
      ServiceComponentDesiredStateEntityPK pkHS = new ServiceComponentDesiredStateEntityPK();
      pkHS.setComponentName("HISTORYSERVER");
      pkHS.setClusterId(clusterEntity.getClusterId());
      pkHS.setServiceName("MAPREDUCE");
     
      ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntityHS = serviceComponentDesiredStateDAO.findByPK(pkHS);
     
      // already have historyserver
      if(serviceComponentDesiredStateEntityHS != null)
        continue;
     
      ServiceComponentDesiredStateEntityPK pkJT = new ServiceComponentDesiredStateEntityPK();
      pkJT.setComponentName("JOBTRACKER");
      pkJT.setClusterId(clusterEntity.getClusterId());
      pkJT.setServiceName("MAPREDUCE");
     
      ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntityJT = serviceComponentDesiredStateDAO.findByPK(pkJT);
     
      // no jobtracker present probably mapreduce is not installed
      if(serviceComponentDesiredStateEntityJT == null)
        continue;

     
      HostComponentStateEntity jtHostComponentStateEntity = serviceComponentDesiredStateEntityJT.getHostComponentStateEntities().iterator().next();
      HostComponentDesiredStateEntity jtHostComponentDesiredStateEntity = serviceComponentDesiredStateEntityJT.getHostComponentDesiredStateEntities().iterator().next();
      String jtHostname = jtHostComponentStateEntity.getHostName();
      State jtCurrState = jtHostComponentStateEntity.getCurrentState();
      State jtHostComponentDesiredState = jtHostComponentDesiredStateEntity.getDesiredState();
      State jtServiceComponentDesiredState = serviceComponentDesiredStateEntityJT.getDesiredState();
         
      ClusterServiceEntityPK pk = new ClusterServiceEntityPK();
      pk.setClusterId(clusterEntity.getClusterId());
      pk.setServiceName("MAPREDUCE");
     
      ClusterServiceEntity clusterServiceEntity = clusterServiceDAO.findByPK(pk);
     
     
      final ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntity = new ServiceComponentDesiredStateEntity();
      serviceComponentDesiredStateEntity.setComponentName("HISTORYSERVER");
      serviceComponentDesiredStateEntity.setDesiredStackVersion(clusterEntity.getDesiredStackVersion());
View Full Code Here


    final String defaultVersionTag = "version1";
    final String defaultUser = "admin";

    LOG.debug("Adding missing configs into Ambari DB.");
    ClusterDAO clusterDAO = injector.getInstance(ClusterDAO.class);
    ClusterServiceDAO clusterServiceDAO = injector.getInstance(ClusterServiceDAO.class);

    AmbariMetaInfo ambariMetaInfo = injector.getInstance(AmbariMetaInfo.class);
    Gson gson = injector.getInstance(Gson.class);

    List <ClusterEntity> clusterEntities = clusterDAO.findAll();
    for (final ClusterEntity clusterEntity : clusterEntities) {
      Long clusterId = clusterEntity.getClusterId();
      String desiredStackVersion = clusterEntity.getDesiredStackVersion();

      Map<String, String> clusterInfo =
        gson.<Map<String, String>>fromJson(desiredStackVersion, Map.class);

      String stackName = clusterInfo.get("stackName");
      String stackVersion = clusterInfo.get("stackVersion");

      List<ClusterServiceEntity> clusterServiceEntities = clusterServiceDAO.findAll();
      for (final ClusterServiceEntity clusterServiceEntity : clusterServiceEntities) {
        String serviceName = clusterServiceEntity.getServiceName();
        ServiceInfo serviceInfo = null;
        try {
          serviceInfo = ambariMetaInfo.getService(stackName, stackVersion, serviceName);
View Full Code Here

    s.persist();

    Service service = cluster.getService(serviceName);
    Assert.assertNotNull(service);

    ClusterServiceDAO dao = injector.getInstance(ClusterServiceDAO.class);
    ClusterServiceEntity entity = dao.findByClusterAndServiceNames(clusterName, serviceName);
    Assert.assertNotNull(entity);
    Assert.assertEquals(MaintenanceState.OFF, entity.getServiceDesiredStateEntity().getMaintenanceState());
    Assert.assertEquals(MaintenanceState.OFF, service.getMaintenanceState());
   
    service.setMaintenanceState(MaintenanceState.ON);
    Assert.assertEquals(MaintenanceState.ON, service.getMaintenanceState());

    entity = dao.findByClusterAndServiceNames(clusterName, serviceName);
    Assert.assertNotNull(entity);
    Assert.assertEquals(MaintenanceState.ON, entity.getServiceDesiredStateEntity().getMaintenanceState());
   
   
  }
View Full Code Here

    });
  }

  protected void addHistoryServer() {
    ClusterDAO clusterDAO = injector.getInstance(ClusterDAO.class);
    ClusterServiceDAO clusterServiceDAO = injector.getInstance(ClusterServiceDAO.class);
    ServiceComponentDesiredStateDAO serviceComponentDesiredStateDAO = injector.getInstance(ServiceComponentDesiredStateDAO.class);
   
    List<ClusterEntity> clusterEntities = clusterDAO.findAll();
    for (final ClusterEntity clusterEntity : clusterEntities) {
      ServiceComponentDesiredStateEntityPK pkHS = new ServiceComponentDesiredStateEntityPK();
      pkHS.setComponentName("HISTORYSERVER");
      pkHS.setClusterId(clusterEntity.getClusterId());
      pkHS.setServiceName("MAPREDUCE");
     
      ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntityHS = serviceComponentDesiredStateDAO.findByPK(pkHS);
     
      // already have historyserver
      if(serviceComponentDesiredStateEntityHS != null)
        continue;
     
      ServiceComponentDesiredStateEntityPK pkJT = new ServiceComponentDesiredStateEntityPK();
      pkJT.setComponentName("JOBTRACKER");
      pkJT.setClusterId(clusterEntity.getClusterId());
      pkJT.setServiceName("MAPREDUCE");
     
      ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntityJT = serviceComponentDesiredStateDAO.findByPK(pkJT);
     
      // no jobtracker present probably mapreduce is not installed
      if(serviceComponentDesiredStateEntityJT == null)
        continue;

     
      HostComponentStateEntity jtHostComponentStateEntity = serviceComponentDesiredStateEntityJT.getHostComponentStateEntities().iterator().next();
      HostComponentDesiredStateEntity jtHostComponentDesiredStateEntity = serviceComponentDesiredStateEntityJT.getHostComponentDesiredStateEntities().iterator().next();
      String jtHostname = jtHostComponentStateEntity.getHostName();
      State jtCurrState = jtHostComponentStateEntity.getCurrentState();
      State jtHostComponentDesiredState = jtHostComponentDesiredStateEntity.getDesiredState();
      State jtServiceComponentDesiredState = serviceComponentDesiredStateEntityJT.getDesiredState();
         
      ClusterServiceEntityPK pk = new ClusterServiceEntityPK();
      pk.setClusterId(clusterEntity.getClusterId());
      pk.setServiceName("MAPREDUCE");
     
      ClusterServiceEntity clusterServiceEntity = clusterServiceDAO.findByPK(pk);
     
     
      final ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntity = new ServiceComponentDesiredStateEntity();
      serviceComponentDesiredStateEntity.setComponentName("HISTORYSERVER");
      serviceComponentDesiredStateEntity.setDesiredStackVersion(clusterEntity.getDesiredStackVersion());
View Full Code Here

    final String defaultVersionTag = "version1";
    final String defaultUser = "admin";

    LOG.debug("Adding missing configs into Ambari DB.");
    ClusterDAO clusterDAO = injector.getInstance(ClusterDAO.class);
    ClusterServiceDAO clusterServiceDAO = injector.getInstance(ClusterServiceDAO.class);

    AmbariMetaInfo ambariMetaInfo = injector.getInstance(AmbariMetaInfo.class);
    Gson gson = injector.getInstance(Gson.class);

    List <ClusterEntity> clusterEntities = clusterDAO.findAll();
    for (final ClusterEntity clusterEntity : clusterEntities) {
      Long clusterId = clusterEntity.getClusterId();
      String desiredStackVersion = clusterEntity.getDesiredStackVersion();

      Map<String, String> clusterInfo =
        gson.<Map<String, String>>fromJson(desiredStackVersion, Map.class);

      String stackName = clusterInfo.get("stackName");
      String stackVersion = clusterInfo.get("stackVersion");

      List<ClusterServiceEntity> clusterServiceEntities = clusterServiceDAO.findAll();
      for (final ClusterServiceEntity clusterServiceEntity : clusterServiceEntities) {
        String serviceName = clusterServiceEntity.getServiceName();
        ServiceInfo serviceInfo = null;
        try {
          serviceInfo = ambariMetaInfo.getService(stackName, stackVersion, serviceName);
View Full Code Here

    clusterDAO.create(clusterEntity);
    return clusterEntity;
  }

  private ClusterServiceEntity createService(ClusterEntity clusterEntity) {
    ClusterServiceDAO clusterServiceDAO = injector.getInstance(ClusterServiceDAO.class);
    ClusterServiceEntity clusterServiceEntity = new ClusterServiceEntity();
    clusterServiceEntity.setClusterId(1L);
    clusterServiceEntity.setClusterEntity(clusterEntity);
    clusterServiceEntity.setServiceName(SERVICE_NAME);
    clusterServiceDAO.create(clusterServiceEntity);
    return clusterServiceEntity;
  }
View Full Code Here

   
    hostEntity.getHostComponentStateEntities().add(hostComponentStateEntity);
    hostEntity.getHostComponentDesiredStateEntities().add(hostComponentDesiredStateEntity);
    clusterServiceEntity.getServiceComponentDesiredStateEntities().add(componentDesiredStateEntity);
   
    ClusterServiceDAO clusterServiceDAO = injector.getInstance(ClusterServiceDAO.class);
    clusterServiceDAO.merge(clusterServiceEntity);
  }
View Full Code Here

    clusterDAO.create(clusterEntity);
    return clusterEntity;
  }

  private ClusterServiceEntity createService(ClusterEntity clusterEntity) {
    ClusterServiceDAO clusterServiceDAO = injector.getInstance(ClusterServiceDAO.class);
    ClusterServiceEntity clusterServiceEntity = new ClusterServiceEntity();
    clusterServiceEntity.setClusterId(1L);
    clusterServiceEntity.setClusterEntity(clusterEntity);
    clusterServiceEntity.setServiceName(SERVICE_NAME);
    clusterServiceDAO.create(clusterServiceEntity);
    return clusterServiceEntity;
  }
View Full Code Here

   
    hostEntity.getHostComponentStateEntities().add(hostComponentStateEntity);
    hostEntity.getHostComponentDesiredStateEntities().add(hostComponentDesiredStateEntity);
    clusterServiceEntity.getServiceComponentDesiredStateEntities().add(componentDesiredStateEntity);
   
    ClusterServiceDAO clusterServiceDAO = injector.getInstance(ClusterServiceDAO.class);
    clusterServiceDAO.merge(clusterServiceEntity);
  }
View Full Code Here

    });
  }

  protected void addHistoryServer() {
    ClusterDAO clusterDAO = injector.getInstance(ClusterDAO.class);
    ClusterServiceDAO clusterServiceDAO = injector.getInstance(ClusterServiceDAO.class);
    ServiceComponentDesiredStateDAO serviceComponentDesiredStateDAO = injector.getInstance(ServiceComponentDesiredStateDAO.class);
   
    List<ClusterEntity> clusterEntities = clusterDAO.findAll();
    for (final ClusterEntity clusterEntity : clusterEntities) {
      ServiceComponentDesiredStateEntityPK pkHS = new ServiceComponentDesiredStateEntityPK();
      pkHS.setComponentName("HISTORYSERVER");
      pkHS.setClusterId(clusterEntity.getClusterId());
      pkHS.setServiceName("MAPREDUCE");
     
      ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntityHS = serviceComponentDesiredStateDAO.findByPK(pkHS);
     
      // already have historyserver
      if(serviceComponentDesiredStateEntityHS != null)
        continue;
     
      ServiceComponentDesiredStateEntityPK pkJT = new ServiceComponentDesiredStateEntityPK();
      pkJT.setComponentName("JOBTRACKER");
      pkJT.setClusterId(clusterEntity.getClusterId());
      pkJT.setServiceName("MAPREDUCE");
     
      ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntityJT = serviceComponentDesiredStateDAO.findByPK(pkJT);
     
      // no jobtracker present probably mapreduce is not installed
      if(serviceComponentDesiredStateEntityJT == null)
        continue;

     
      HostComponentStateEntity jtHostComponentStateEntity = serviceComponentDesiredStateEntityJT.getHostComponentStateEntities().iterator().next();
      HostComponentDesiredStateEntity jtHostComponentDesiredStateEntity = serviceComponentDesiredStateEntityJT.getHostComponentDesiredStateEntities().iterator().next();
      String jtHostname = jtHostComponentStateEntity.getHostName();
      State jtCurrState = jtHostComponentStateEntity.getCurrentState();
      State jtHostComponentDesiredState = jtHostComponentDesiredStateEntity.getDesiredState();
      State jtServiceComponentDesiredState = serviceComponentDesiredStateEntityJT.getDesiredState();
         
      ClusterServiceEntityPK pk = new ClusterServiceEntityPK();
      pk.setClusterId(clusterEntity.getClusterId());
      pk.setServiceName("MAPREDUCE");
     
      ClusterServiceEntity clusterServiceEntity = clusterServiceDAO.findByPK(pk);
     
     
      final ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntity = new ServiceComponentDesiredStateEntity();
      serviceComponentDesiredStateEntity.setComponentName("HISTORYSERVER");
      serviceComponentDesiredStateEntity.setDesiredStackVersion(clusterEntity.getDesiredStackVersion());
View Full Code Here

TOP

Related Classes of org.apache.ambari.server.orm.dao.ClusterServiceDAO

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.