use of com.sequenceiq.cloudbreak.cm.polling.ClouderaManagerSyncCommandPollerObject in project cloudbreak by hortonworks.
the class ClouderaManagerSyncApiCommandIdCheckerTaskTest method testCheckStatus.
@Test
public void testCheckStatus() throws ApiException, CloudbreakException {
// GIVEN
ClouderaManagerSyncCommandPollerObject pollerObject = new ClouderaManagerSyncCommandPollerObject(stack, apiClient, new BigDecimal(2L), COMMAND_NAME);
given(commandRetriever.getCommandId(anyString(), any(), any())).willReturn(Optional.of(new BigDecimal(1L)));
// WHEN
boolean result = underTest.checkStatus(pollerObject);
// THEN
assertTrue(result);
}
use of com.sequenceiq.cloudbreak.cm.polling.ClouderaManagerSyncCommandPollerObject in project cloudbreak by hortonworks.
the class ClouderaManagerSyncApiCommandIdCheckerTaskTest method testCheckStatusWithRecentCommandId.
@Test
public void testCheckStatusWithRecentCommandId() throws ApiException, CloudbreakException {
// GIVEN
ClouderaManagerSyncCommandPollerObject pollerObject = new ClouderaManagerSyncCommandPollerObject(stack, apiClient, new BigDecimal(1L), COMMAND_NAME);
given(commandRetriever.getCommandId(anyString(), any(), any())).willReturn(Optional.of(new BigDecimal(2L)));
// WHEN
boolean result = underTest.checkStatus(pollerObject);
// THEN
assertTrue(result);
}
use of com.sequenceiq.cloudbreak.cm.polling.ClouderaManagerSyncCommandPollerObject in project cloudbreak by hortonworks.
the class ClouderaManagerSyncApiCommandIdCheckerTaskTest method testCheckStatusWithSameRecentCommandId.
@Test
public void testCheckStatusWithSameRecentCommandId() throws ApiException, CloudbreakException {
// GIVEN
ClouderaManagerSyncCommandPollerObject pollerObject = new ClouderaManagerSyncCommandPollerObject(stack, apiClient, new BigDecimal(1L), COMMAND_NAME);
given(commandRetriever.getCommandId(anyString(), any(), any())).willReturn(Optional.of(new BigDecimal(1L)));
// WHEN
boolean result = underTest.checkStatus(pollerObject);
// THEN
assertFalse(result);
}
use of com.sequenceiq.cloudbreak.cm.polling.ClouderaManagerSyncCommandPollerObject in project cloudbreak by hortonworks.
the class ClouderaManagerSyncApiCommandIdCheckerTask method checkStatus.
@Override
public boolean checkStatus(ClouderaManagerCommandPollerObject pollerObject) {
ApiClient apiClient = pollerObject.getApiClient();
ClustersResourceApi api = clouderaManagerApiPojoFactory.getClustersResourceApi(apiClient);
boolean result = false;
ClouderaManagerSyncCommandPollerObject castedObj = cast(pollerObject);
try {
Optional<BigDecimal> commandId = syncApiCommandRetriever.getCommandId(castedObj.getCommandName(), api, castedObj.getStack());
if (commandId.isPresent() && !commandId.get().equals(pollerObject.getId())) {
LOGGER.debug("Found a new latest command ID for {} command: {}", castedObj.getCommandName(), commandId);
result = true;
} else if (castedObj.getId() != null && castedObj.getId().equals(commandId.orElse(null))) {
LOGGER.debug("There is a valid command ID found: {}, but that is not the " + "newest command id of {}", castedObj.getId(), castedObj.getCommandName());
} else {
LOGGER.debug("Not found any new commandId yet - [recent_id: {}]", castedObj.getId());
}
} catch (ApiException | CloudbreakException e) {
LOGGER.debug(String.format("Exception during polling the newest %s command.", castedObj.getCommandName()), e);
result = false;
}
return result;
}
Aggregations