@Test public void testPerformFail() throws Exception{ final Cluster cluster = Mockito.mock(Cluster.class); final LinkedHashSet<String> failedOnExpected = new LinkedHashSet<String>(); Service hive = Mockito.mock(Service.class); ServiceComponent metastore = Mockito.mock(ServiceComponent.class); Map<String, ServiceComponentHost> metastores = new HashMap<String, ServiceComponentHost>(); failedOnExpected.add("HIVE"); Mockito.when(cluster.getClusterId()).thenReturn(1L); Mockito.when(m_clusters.getCluster("cluster")).thenReturn(cluster); Mockito.when(cluster.getService("HIVE")).thenReturn(hive); Mockito.when(hive.getServiceComponent("HIVE_METASTORE")).thenReturn(metastore); Mockito.when(metastore.getServiceComponentHosts()).thenReturn(metastores); PrerequisiteCheck check = new PrerequisiteCheck(null, null); PrereqCheckRequest request = new PrereqCheckRequest("cluster"); request.setRepositoryVersion("2.3.0.0"); m_check.perform(check, request); Assert.assertEquals(PrereqCheckStatus.WARNING, check.getStatus()); check = new PrerequisiteCheck(null, null); m_check.perform(check, request); Assert.assertEquals(failedOnExpected, check.getFailedOn()); Assert.assertEquals(PrereqCheckStatus.WARNING, check.getStatus()); }
@Override public void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request) throws AmbariException { final String clusterName = request.getClusterName(); final Cluster cluster = clustersProvider.get().getCluster(clusterName); try { Service hive = cluster.getService("HIVE"); ServiceComponent metastore = hive.getServiceComponent("HIVE_METASTORE"); Map<String, ServiceComponentHost> metastores = metastore.getServiceComponentHosts(); if (metastores.size() < 2) { prerequisiteCheck.getFailedOn().add("HIVE"); prerequisiteCheck.setStatus(PrereqCheckStatus.WARNING); prerequisiteCheck.setFailReason(getFailReason(prerequisiteCheck, request)); } } catch (ServiceComponentNotFoundException scnfe) { prerequisiteCheck.getFailedOn().add("HIVE"); prerequisiteCheck.setStatus(PrereqCheckStatus.WARNING); prerequisiteCheck.setFailReason(getFailReason(prerequisiteCheck, request)); } }
HiveMultipleMetastoreCheck extends AbstractCheckDescriptor { @Override public void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request) throws AmbariException { final String clusterName = request.getClusterName(); final Cluster cluster = clustersProvider.get().getCluster(clusterName); try { Service hive = cluster.getService("HIVE"); ServiceComponent metastore = hive.getServiceComponent("HIVE_METASTORE"); Map<String, ServiceComponentHost> metastores = metastore.getServiceComponentHosts(); if (metastores.size() < 2) { prerequisiteCheck.getFailedOn().add("HIVE"); prerequisiteCheck.setStatus(PrereqCheckStatus.WARNING); prerequisiteCheck.setFailReason(getFailReason(prerequisiteCheck, request)); } } catch (ServiceComponentNotFoundException scnfe) { prerequisiteCheck.getFailedOn().add("HIVE"); prerequisiteCheck.setStatus(PrereqCheckStatus.WARNING); prerequisiteCheck.setFailReason(getFailReason(prerequisiteCheck, request)); } } }
HiveMultipleMetastoreCheck extends AbstractCheckDescriptor { @Override public void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request) throws AmbariException { final String clusterName = request.getClusterName(); final Cluster cluster = clustersProvider.get().getCluster(clusterName); try { Service hive = cluster.getService("HIVE"); ServiceComponent metastore = hive.getServiceComponent("HIVE_METASTORE"); Map<String, ServiceComponentHost> metastores = metastore.getServiceComponentHosts(); if (metastores.size() < 2) { prerequisiteCheck.getFailedOn().add("HIVE"); prerequisiteCheck.setStatus(PrereqCheckStatus.WARNING); prerequisiteCheck.setFailReason(getFailReason(prerequisiteCheck, request)); } } catch (ServiceComponentNotFoundException scnfe) { prerequisiteCheck.getFailedOn().add("HIVE"); prerequisiteCheck.setStatus(PrereqCheckStatus.WARNING); prerequisiteCheck.setFailReason(getFailReason(prerequisiteCheck, request)); } } HiveMultipleMetastoreCheck(); }
HiveMultipleMetastoreCheck extends AbstractCheckDescriptor { @Override public void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request) throws AmbariException { final String clusterName = request.getClusterName(); final Cluster cluster = clustersProvider.get().getCluster(clusterName); try { Service hive = cluster.getService("HIVE"); ServiceComponent metastore = hive.getServiceComponent("HIVE_METASTORE"); Map<String, ServiceComponentHost> metastores = metastore.getServiceComponentHosts(); if (metastores.size() < 2) { prerequisiteCheck.getFailedOn().add("HIVE"); prerequisiteCheck.setStatus(PrereqCheckStatus.WARNING); prerequisiteCheck.setFailReason(getFailReason(prerequisiteCheck, request)); } } catch (ServiceComponentNotFoundException scnfe) { prerequisiteCheck.getFailedOn().add("HIVE"); prerequisiteCheck.setStatus(PrereqCheckStatus.WARNING); prerequisiteCheck.setFailReason(getFailReason(prerequisiteCheck, request)); } } HiveMultipleMetastoreCheck(); @Override boolean isApplicable(PrereqCheckRequest request); @Override void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request); }
HiveMultipleMetastoreCheck extends AbstractCheckDescriptor { @Override public void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request) throws AmbariException { final String clusterName = request.getClusterName(); final Cluster cluster = clustersProvider.get().getCluster(clusterName); try { Service hive = cluster.getService("HIVE"); ServiceComponent metastore = hive.getServiceComponent("HIVE_METASTORE"); Map<String, ServiceComponentHost> metastores = metastore.getServiceComponentHosts(); if (metastores.size() < 2) { prerequisiteCheck.getFailedOn().add("HIVE"); prerequisiteCheck.setStatus(PrereqCheckStatus.WARNING); prerequisiteCheck.setFailReason(getFailReason(prerequisiteCheck, request)); } } catch (ServiceComponentNotFoundException scnfe) { prerequisiteCheck.getFailedOn().add("HIVE"); prerequisiteCheck.setStatus(PrereqCheckStatus.WARNING); prerequisiteCheck.setFailReason(getFailReason(prerequisiteCheck, request)); } } HiveMultipleMetastoreCheck(); @Override boolean isApplicable(PrereqCheckRequest request); @Override void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request);  }