@Test public void testTimeOutWithHostNull() throws AmbariException { Stage s = getStageWithServerAction(1, 977, null, "test", 2, false, false); s.setHostRoleStatus(null, Role.AMBARI_SERVER_ACTION.toString(), HostRoleStatus.IN_PROGRESS); ActionScheduler scheduler = EasyMock.createMockBuilder(ActionScheduler.class) .withConstructor(long.class, long.class, ActionDBAccessor.class, ActionQueue.class, Clusters.class, int.class, HostsMap.class, UnitOfWork.class, AmbariEventPublisher.class, Configuration.class, Provider.class, HostRoleCommandDAO.class, HostRoleCommandFactory.class) .withArgs(100L, 50L, null, null, null, -1, null, null, null, null, entityManagerProviderMock, mock(HostRoleCommandDAO.class), mock(HostRoleCommandFactory.class)) .createNiceMock(); EasyMock.replay(scheduler); Assert.assertEquals(false, scheduler.timeOutActionNeeded(HostRoleStatus.IN_PROGRESS, s, null, Role.AMBARI_SERVER_ACTION.toString(), -1L, 1L)); EasyMock.verify(scheduler); }
protected boolean timeOutActionNeeded(HostRoleStatus status, Stage stage, Host host, String role, long currentTime, long taskTimeout) throws AmbariException { if (( !status.equals(HostRoleStatus.QUEUED) ) && ( ! status.equals(HostRoleStatus.IN_PROGRESS) )) { return false; } String hostName = (null == host) ? null : host.getHostName(); if (hasCommandInProgress(stage, hostName) && !status.equals(HostRoleStatus.IN_PROGRESS)) { return false; } if (currentTime >= stage.getLastAttemptTime(hostName, role) + taskTimeout) { return true; } return false; }
ActionScheduler implements Runnable { protected boolean timeOutActionNeeded(HostRoleStatus status, Stage stage, Host host, String role, long currentTime, long taskTimeout) throws AmbariException { if (( !status.equals(HostRoleStatus.QUEUED) ) && ( ! status.equals(HostRoleStatus.IN_PROGRESS) )) { return false; } String hostName = (null == host) ? null : host.getHostName(); if (hasCommandInProgress(stage, hostName) && !status.equals(HostRoleStatus.IN_PROGRESS)) { return false; } if (currentTime >= stage.getLastAttemptTime(hostName, role) + taskTimeout) { return true; } return false; } }
ActionScheduler implements Runnable { protected boolean timeOutActionNeeded(HostRoleStatus status, Stage stage, Host host, String role, long currentTime, long taskTimeout) throws AmbariException { if (( !status.equals(HostRoleStatus.QUEUED) ) && ( ! status.equals(HostRoleStatus.IN_PROGRESS) )) { return false; } String hostName = (null == host) ? null : host.getHostName(); if (hasCommandInProgress(stage, hostName) && !status.equals(HostRoleStatus.IN_PROGRESS)) { return false; } if (currentTime >= stage.getLastAttemptTime(hostName, role) + taskTimeout) { return true; } return false; } @Inject  ActionScheduler(@Named("schedulerSleeptime") long sleepTime,
                         @Named("actionTimeout") long actionTimeout, ActionDBAccessor db,
                         JPAEventPublisher jpaPublisher); protected  ActionScheduler(long sleepTimeMilliSec, long actionTimeoutMilliSec, ActionDBAccessor db,
                            ActionQueue actionQueue, Clusters fsmObject, int maxAttempts, HostsMap hostsMap,
                            UnitOfWork unitOfWork, AmbariEventPublisher ambariEventPublisher,
                            Configuration configuration, Provider<EntityManager> entityManagerProvider,
                            HostRoleCommandDAO hostRoleCommandDAO, HostRoleCommandFactory hostRoleCommandFactory); }
ActionScheduler implements Runnable { protected boolean timeOutActionNeeded(HostRoleStatus status, Stage stage, Host host, String role, long currentTime, long taskTimeout) throws AmbariException { if (( !status.equals(HostRoleStatus.QUEUED) ) && ( ! status.equals(HostRoleStatus.IN_PROGRESS) )) { return false; } String hostName = (null == host) ? null : host.getHostName(); if (hasCommandInProgress(stage, hostName) && !status.equals(HostRoleStatus.IN_PROGRESS)) { return false; } if (currentTime >= stage.getLastAttemptTime(hostName, role) + taskTimeout) { return true; } return false; } @Inject  ActionScheduler(@Named("schedulerSleeptime") long sleepTime,
                         @Named("actionTimeout") long actionTimeout, ActionDBAccessor db,
                         JPAEventPublisher jpaPublisher); protected  ActionScheduler(long sleepTimeMilliSec, long actionTimeoutMilliSec, ActionDBAccessor db,
                            ActionQueue actionQueue, Clusters fsmObject, int maxAttempts, HostsMap hostsMap,
                            UnitOfWork unitOfWork, AmbariEventPublisher ambariEventPublisher,
                            Configuration configuration, Provider<EntityManager> entityManagerProvider,
                            HostRoleCommandDAO hostRoleCommandDAO, HostRoleCommandFactory hostRoleCommandFactory); void start(); void stop(); void awake(); @Override void run(); void doWork(); void scheduleCancellingRequest(long requestId, String reason); void setTaskTimeoutAdjustment(boolean val); @Subscribe void onEvent(EntityManagerCacheInvalidationEvent event); }
ActionScheduler implements Runnable { protected boolean timeOutActionNeeded(HostRoleStatus status, Stage stage, Host host, String role, long currentTime, long taskTimeout) throws AmbariException { if (( !status.equals(HostRoleStatus.QUEUED) ) && ( ! status.equals(HostRoleStatus.IN_PROGRESS) )) { return false; } String hostName = (null == host) ? null : host.getHostName(); if (hasCommandInProgress(stage, hostName) && !status.equals(HostRoleStatus.IN_PROGRESS)) { return false; } if (currentTime >= stage.getLastAttemptTime(hostName, role) + taskTimeout) { return true; } return false; } @Inject  ActionScheduler(@Named("schedulerSleeptime") long sleepTime,
                         @Named("actionTimeout") long actionTimeout, ActionDBAccessor db,
                         JPAEventPublisher jpaPublisher); protected  ActionScheduler(long sleepTimeMilliSec, long actionTimeoutMilliSec, ActionDBAccessor db,
                            ActionQueue actionQueue, Clusters fsmObject, int maxAttempts, HostsMap hostsMap,
                            UnitOfWork unitOfWork, AmbariEventPublisher ambariEventPublisher,
                            Configuration configuration, Provider<EntityManager> entityManagerProvider,
                            HostRoleCommandDAO hostRoleCommandDAO, HostRoleCommandFactory hostRoleCommandFactory); void start(); void stop(); void awake(); @Override void run(); void doWork(); void scheduleCancellingRequest(long requestId, String reason); void setTaskTimeoutAdjustment(boolean val); @Subscribe void onEvent(EntityManagerCacheInvalidationEvent event); static final String FAILED_TASK_ABORT_REASONING; }