upgradeCatalog150.addHistoryServer();
}
@Test
public void testProcessDecommissionedDatanodes() throws Exception {
ClusterEntity clusterEntity = createCluster();
ClusterServiceEntity clusterServiceEntity = createService(clusterEntity);
HostEntity hostEntity = createHost(clusterEntity);
ServiceComponentDesiredStateEntity componentDesiredStateEntity =
new ServiceComponentDesiredStateEntity();
componentDesiredStateEntity.setClusterId(clusterEntity.getClusterId());
componentDesiredStateEntity.setServiceName(clusterServiceEntity.getServiceName());
componentDesiredStateEntity.setClusterServiceEntity(clusterServiceEntity);
componentDesiredStateEntity.setComponentName("DATANODE");
//componentDesiredStateDAO.create(componentDesiredStateEntity);
HostComponentDesiredStateDAO hostComponentDesiredStateDAO =
injector.getInstance(HostComponentDesiredStateDAO.class);
HostComponentDesiredStateEntity hostComponentDesiredStateEntity =
new HostComponentDesiredStateEntity();
hostComponentDesiredStateEntity.setClusterId(clusterEntity.getClusterId());
hostComponentDesiredStateEntity.setComponentName("DATANODE");
hostComponentDesiredStateEntity.setAdminState(HostComponentAdminState.INSERVICE);
hostComponentDesiredStateEntity.setServiceName(clusterServiceEntity.getServiceName());
hostComponentDesiredStateEntity.setServiceComponentDesiredStateEntity(componentDesiredStateEntity);
hostComponentDesiredStateEntity.setHostEntity(hostEntity);
hostComponentDesiredStateEntity.setHostName(hostEntity.getHostName());
hostComponentDesiredStateDAO.create(hostComponentDesiredStateEntity);
HostComponentDesiredStateEntity entity = hostComponentDesiredStateDAO.findAll().get(0);
Assert.assertEquals(HostComponentAdminState.INSERVICE.name(), entity.getAdminState().name());
KeyValueDAO keyValueDAO = injector.getInstance(KeyValueDAO.class);
KeyValueEntity keyValueEntity = new KeyValueEntity();
keyValueEntity.setKey("decommissionDataNodesTag");
keyValueEntity.setValue("1394147791230");
keyValueDAO.create(keyValueEntity);
ClusterDAO clusterDAO = injector.getInstance(ClusterDAO.class);
ClusterConfigEntity configEntity = new ClusterConfigEntity();
configEntity.setClusterEntity(clusterEntity);
configEntity.setClusterId(clusterEntity.getClusterId());
configEntity.setType("hdfs-exclude-file");
configEntity.setTag("1394147791230");
configEntity.setData("{\"datanodes\":\"" + HOST_NAME + "\"}");
configEntity.setTimestamp(System.currentTimeMillis());
clusterDAO.createConfig(configEntity);