use of com.sequenceiq.periscope.model.RejectedThread in project cloudbreak by hortonworks.
the class RejectedThreadServiceTest method testCreateWhenClusterId.
@Test
public void testCreateWhenClusterId() {
Long data = 1L;
EvaluatorExecutor task = new TestEvaluatorExecutor(getContext(data));
underTest.create(task);
List<RejectedThread> allRejectedCluster = underTest.getAllRejectedCluster();
Assert.assertFalse(allRejectedCluster.isEmpty());
Assert.assertEquals(1L, allRejectedCluster.get(0).getId());
}
use of com.sequenceiq.periscope.model.RejectedThread in project cloudbreak by hortonworks.
the class RejectedThreadServiceTest method testCreateWhenClusterIdCountEqualsTwo.
@Test
public void testCreateWhenClusterIdCountEqualsTwo() {
Long data = 1L;
EvaluatorExecutor task = new TestEvaluatorExecutor(getContext(data));
underTest.create(task);
underTest.create(task);
List<RejectedThread> allRejectedCluster = underTest.getAllRejectedCluster();
Assert.assertFalse(allRejectedCluster.isEmpty());
Assert.assertEquals(1L, allRejectedCluster.get(0).getId());
Assert.assertEquals(2L, allRejectedCluster.get(0).getRejectedCount());
}
use of com.sequenceiq.periscope.model.RejectedThread in project cloudbreak by hortonworks.
the class RejectedThreadServiceTest method testCreateWhenAutoscaleStackResponse.
@Test
public void testCreateWhenAutoscaleStackResponse() {
AutoscaleStackV4Response response = new AutoscaleStackV4Response();
response.setStackId(1L);
EvaluatorExecutor task = new TestEvaluatorExecutor(getContext(response));
underTest.create(task);
List<RejectedThread> allRejectedCluster = underTest.getAllRejectedCluster();
Assert.assertFalse(allRejectedCluster.isEmpty());
Assert.assertEquals(1L, allRejectedCluster.get(0).getId());
}
use of com.sequenceiq.periscope.model.RejectedThread in project cloudbreak by hortonworks.
the class RejectedThreadService method createOrUpdateRejectedThread.
private RejectedThread createOrUpdateRejectedThread(Object data, Long id) {
RejectedThread rejectedThread = findById(id);
if (rejectedThread == null) {
rejectedThread = new RejectedThread();
rejectedThread.setRejectedCount(1L);
rejectedThread.setId(id);
rejectedThread.setJson(writeValueAsStringSilent(data));
} else {
rejectedThread.setRejectedCount(rejectedThread.getRejectedCount() + 1L);
}
return rejectedThread;
}
use of com.sequenceiq.periscope.model.RejectedThread in project cloudbreak by hortonworks.
the class RejectedThreadService method create.
public void create(EvaluatorExecutor task) {
Object data = task.getContext().getData();
RejectedThread rejectedThread;
if (data instanceof AutoscaleStackV4Response) {
Long stackId = ((AutoscaleStackV4Response) data).getStackId();
rejectedThread = createOrUpdateRejectedThread(data, stackId);
} else if (data instanceof Long) {
rejectedThread = createOrUpdateRejectedThread(Collections.singletonMap("id", data), (Long) data);
} else {
throw new IllegalArgumentException("The given data is not match to AutoscaleStackResponse or Long, not possible to create");
}
LOGGER.debug("Rejected task: {}, count: {}", rejectedThread.getJson(), rejectedThread.getRejectedCount());
rejectedThread.setType(task.getClass().getName());
save(rejectedThread);
}
Aggregations