@Test public void testIsApplicable() throws Exception { final Cluster cluster = Mockito.mock(Cluster.class); final Map<String, Service> services = new HashMap<>(); final Service service = Mockito.mock(Service.class); services.put("HDFS", service); Mockito.when(cluster.getClusterId()).thenReturn(1L); Mockito.when(cluster.getServices()).thenReturn(services); Mockito.when(clusters.getCluster("cluster")).thenReturn(cluster); Assert.assertTrue(secondaryNamenodeDeletedCheck.isApplicable(new PrereqCheckRequest("cluster"))); PrereqCheckRequest req = new PrereqCheckRequest("cluster"); req.addResult(CheckDescription.SERVICES_NAMENODE_HA, PrereqCheckStatus.FAIL); Assert.assertFalse(secondaryNamenodeDeletedCheck.isApplicable(req)); req.addResult(CheckDescription.SERVICES_NAMENODE_HA, PrereqCheckStatus.PASS); Assert.assertTrue(secondaryNamenodeDeletedCheck.isApplicable(req)); services.remove("HDFS"); Assert.assertFalse(secondaryNamenodeDeletedCheck.isApplicable(new PrereqCheckRequest("cluster"))); }
@Override public boolean isApplicable(PrereqCheckRequest request) throws AmbariException { if (!super.isApplicable(request, Arrays.asList(HDFS_SERVICE_NAME), true)) { return false; } PrereqCheckStatus ha = request.getResult(CheckDescription.SERVICES_NAMENODE_HA); if (null != ha && ha == PrereqCheckStatus.FAIL) { return false; } return true; }
SecondaryNamenodeDeletedCheck extends AbstractCheckDescriptor { @Override public boolean isApplicable(PrereqCheckRequest request) throws AmbariException { if (!super.isApplicable(request, Arrays.asList(HDFS_SERVICE_NAME), true)) { return false; } PrereqCheckStatus ha = request.getResult(CheckDescription.SERVICES_NAMENODE_HA); if (null != ha && ha == PrereqCheckStatus.FAIL) { return false; } return true; } }
SecondaryNamenodeDeletedCheck extends AbstractCheckDescriptor { @Override public boolean isApplicable(PrereqCheckRequest request) throws AmbariException { if (!super.isApplicable(request, Arrays.asList(HDFS_SERVICE_NAME), true)) { return false; } PrereqCheckStatus ha = request.getResult(CheckDescription.SERVICES_NAMENODE_HA); if (null != ha && ha == PrereqCheckStatus.FAIL) { return false; } return true; } SecondaryNamenodeDeletedCheck(); }
SecondaryNamenodeDeletedCheck extends AbstractCheckDescriptor { @Override public boolean isApplicable(PrereqCheckRequest request) throws AmbariException { if (!super.isApplicable(request, Arrays.asList(HDFS_SERVICE_NAME), true)) { return false; } PrereqCheckStatus ha = request.getResult(CheckDescription.SERVICES_NAMENODE_HA); if (null != ha && ha == PrereqCheckStatus.FAIL) { return false; } return true; } SecondaryNamenodeDeletedCheck(); @Override boolean isApplicable(PrereqCheckRequest request); @Override void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request); }
SecondaryNamenodeDeletedCheck extends AbstractCheckDescriptor { @Override public boolean isApplicable(PrereqCheckRequest request) throws AmbariException { if (!super.isApplicable(request, Arrays.asList(HDFS_SERVICE_NAME), true)) { return false; } PrereqCheckStatus ha = request.getResult(CheckDescription.SERVICES_NAMENODE_HA); if (null != ha && ha == PrereqCheckStatus.FAIL) { return false; } return true; } SecondaryNamenodeDeletedCheck(); @Override boolean isApplicable(PrereqCheckRequest request); @Override void perform(PrerequisiteCheck prerequisiteCheck, PrereqCheckRequest request);  }