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

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


          stackName, stackVersion));
        hostComponentDesiredStateDAO.merge(hcd);
      }
    }

    ServiceComponentDesiredStateDAO serviceComponentDesiredStateDAO =
      injector.getInstance(ServiceComponentDesiredStateDAO.class);

    List<ServiceComponentDesiredStateEntity> scdEntities =
      serviceComponentDesiredStateDAO.findAll();

    if (scdEntities != null) {
      for (ServiceComponentDesiredStateEntity scd : scdEntities) {
        String desiredStackVersion = scd.getDesiredStackVersion();
        scd.setDesiredStackVersion(getStackIdString(desiredStackVersion,
          stackName, stackVersion));
        serviceComponentDesiredStateDAO.merge(scd);
      }
    }

    ServiceDesiredStateDAO serviceDesiredStateDAO = injector.getInstance(ServiceDesiredStateDAO.class);
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;
View Full Code Here

      persistComponentEntities(stateEntity, desiredStateEntity, serviceComponentDesiredStateEntity);
    }
  }
   
  private void persistComponentEntities(HostComponentStateEntity stateEntity, HostComponentDesiredStateEntity desiredStateEntity, ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntity) {
    ServiceComponentDesiredStateDAO serviceComponentDesiredStateDAO = injector.getInstance(ServiceComponentDesiredStateDAO.class);
    HostComponentStateDAO hostComponentStateDAO = injector.getInstance(HostComponentStateDAO.class);
    HostComponentDesiredStateDAO hostComponentDesiredStateDAO = injector.getInstance(HostComponentDesiredStateDAO.class);
    HostDAO hostDAO = injector.getInstance(HostDAO.class);
   
    HostEntity hostEntity = hostDAO.findByName(stateEntity.getHostName());
    hostEntity.getHostComponentStateEntities().add(stateEntity);
    hostEntity.getHostComponentDesiredStateEntities().add(desiredStateEntity);

    serviceComponentDesiredStateEntity.getHostComponentDesiredStateEntities().add(desiredStateEntity);

    desiredStateEntity.setServiceComponentDesiredStateEntity(serviceComponentDesiredStateEntity);
    desiredStateEntity.setHostEntity(hostEntity);
    stateEntity.setServiceComponentDesiredStateEntity(serviceComponentDesiredStateEntity);
    stateEntity.setHostEntity(hostEntity);

    hostComponentStateDAO.create(stateEntity);
    hostComponentDesiredStateDAO.create(desiredStateEntity);

    serviceComponentDesiredStateDAO.create(serviceComponentDesiredStateEntity);
    hostDAO.merge(hostEntity);
  }
View Full Code Here

    Assert.assertEquals(State.INSTALLED, sc.getDesiredState());

    sc.setDesiredStackVersion(new StackId("HDP-1.0.0"));
    Assert.assertEquals("HDP-1.0.0", sc.getDesiredStackVersion().getStackId());

    ServiceComponentDesiredStateDAO serviceComponentDesiredStateDAO =
        injector.getInstance(ServiceComponentDesiredStateDAO.class);

    ServiceComponentDesiredStateEntityPK primaryKey =
        new ServiceComponentDesiredStateEntityPK();
    primaryKey.setClusterId(cluster.getClusterId());
    primaryKey.setComponentName(componentName);
    primaryKey.setServiceName(serviceName);

    ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntity =
        serviceComponentDesiredStateDAO.findByPK(primaryKey);

    ServiceComponent sc1 = serviceComponentFactory.createExisting(service,
        serviceComponentDesiredStateEntity);
    Assert.assertNotNull(sc1);
    Assert.assertEquals(State.INSTALLED, sc1.getDesiredState());
View Full Code Here

    Assert.assertEquals(State.INSTALLED, sc.getDesiredState());

    sc.setDesiredStackVersion(new StackId("HDP-1.0.0"));
    Assert.assertEquals("HDP-1.0.0", sc.getDesiredStackVersion().getStackId());

    ServiceComponentDesiredStateDAO serviceComponentDesiredStateDAO =
        injector.getInstance(ServiceComponentDesiredStateDAO.class);

    ServiceComponentDesiredStateEntityPK primaryKey =
        new ServiceComponentDesiredStateEntityPK();
    primaryKey.setClusterId(cluster.getClusterId());
    primaryKey.setComponentName(componentName);
    primaryKey.setServiceName(serviceName);

    ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntity =
        serviceComponentDesiredStateDAO.findByPK(primaryKey);

    ServiceComponent sc1 = serviceComponentFactory.createExisting(service,
        serviceComponentDesiredStateEntity);
    Assert.assertNotNull(sc1);
    Assert.assertEquals(State.INSTALLED, sc1.getDesiredState());
View Full Code Here

    Assert.assertEquals(State.INSTALLED, sc.getDesiredState());

    sc.setDesiredStackVersion(new StackId("HDP-1.0.0"));
    Assert.assertEquals("HDP-1.0.0", sc.getDesiredStackVersion().getStackId());

    ServiceComponentDesiredStateDAO serviceComponentDesiredStateDAO =
        injector.getInstance(ServiceComponentDesiredStateDAO.class);

    ServiceComponentDesiredStateEntityPK primaryKey =
        new ServiceComponentDesiredStateEntityPK();
    primaryKey.setClusterId(cluster.getClusterId());
    primaryKey.setComponentName(componentName);
    primaryKey.setServiceName(serviceName);

    ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntity =
        serviceComponentDesiredStateDAO.findByPK(primaryKey);

    ServiceComponent sc1 = serviceComponentFactory.createExisting(service,
        serviceComponentDesiredStateEntity);
    Assert.assertNotNull(sc1);
    Assert.assertEquals(State.INSTALLED, sc1.getDesiredState());
View Full Code Here

          stackName, stackVersion));
        hostComponentDesiredStateDAO.merge(hcd);
      }
    }

    ServiceComponentDesiredStateDAO serviceComponentDesiredStateDAO =
      injector.getInstance(ServiceComponentDesiredStateDAO.class);

    List<ServiceComponentDesiredStateEntity> scdEntities =
      serviceComponentDesiredStateDAO.findAll();

    if (scdEntities != null) {
      for (ServiceComponentDesiredStateEntity scd : scdEntities) {
        String desiredStackVersion = scd.getDesiredStackVersion();
        scd.setDesiredStackVersion(getStackIdString(desiredStackVersion,
          stackName, stackVersion));
        serviceComponentDesiredStateDAO.merge(scd);
      }
    }

    ServiceDesiredStateDAO serviceDesiredStateDAO = injector.getInstance(ServiceDesiredStateDAO.class);
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;
View Full Code Here

      persistComponentEntities(stateEntity, desiredStateEntity, serviceComponentDesiredStateEntity);
    }
  }
   
  private void persistComponentEntities(HostComponentStateEntity stateEntity, HostComponentDesiredStateEntity desiredStateEntity, ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntity) {
    ServiceComponentDesiredStateDAO serviceComponentDesiredStateDAO = injector.getInstance(ServiceComponentDesiredStateDAO.class);
    HostComponentStateDAO hostComponentStateDAO = injector.getInstance(HostComponentStateDAO.class);
    HostComponentDesiredStateDAO hostComponentDesiredStateDAO = injector.getInstance(HostComponentDesiredStateDAO.class);
    HostDAO hostDAO = injector.getInstance(HostDAO.class);
   
    HostEntity hostEntity = hostDAO.findByName(stateEntity.getHostName());
    hostEntity.getHostComponentStateEntities().add(stateEntity);
    hostEntity.getHostComponentDesiredStateEntities().add(desiredStateEntity);

    serviceComponentDesiredStateEntity.getHostComponentDesiredStateEntities().add(desiredStateEntity);

    desiredStateEntity.setServiceComponentDesiredStateEntity(serviceComponentDesiredStateEntity);
    desiredStateEntity.setHostEntity(hostEntity);
    stateEntity.setServiceComponentDesiredStateEntity(serviceComponentDesiredStateEntity);
    stateEntity.setHostEntity(hostEntity);

    hostComponentStateDAO.create(stateEntity);
    hostComponentDesiredStateDAO.create(desiredStateEntity);

    serviceComponentDesiredStateDAO.create(serviceComponentDesiredStateEntity);
    hostDAO.merge(hostEntity);
  }
View Full Code Here

    Assert.assertEquals(State.INSTALLED, sc.getDesiredState());

    sc.setDesiredStackVersion(new StackId("HDP-1.0.0"));
    Assert.assertEquals("HDP-1.0.0", sc.getDesiredStackVersion().getStackId());

    ServiceComponentDesiredStateDAO serviceComponentDesiredStateDAO =
        injector.getInstance(ServiceComponentDesiredStateDAO.class);

    ServiceComponentDesiredStateEntityPK primaryKey =
        new ServiceComponentDesiredStateEntityPK();
    primaryKey.setClusterId(cluster.getClusterId());
    primaryKey.setComponentName(componentName);
    primaryKey.setServiceName(serviceName);

    ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntity =
        serviceComponentDesiredStateDAO.findByPK(primaryKey);

    ServiceComponent sc1 = serviceComponentFactory.createExisting(service,
        serviceComponentDesiredStateEntity);
    Assert.assertNotNull(sc1);
    Assert.assertEquals(State.INSTALLED, sc1.getDesiredState());
View Full Code Here

TOP

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

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.