Package org.qzerver.model.domain.entities.cluster

Examples of org.qzerver.model.domain.entities.cluster.ClusterGroup


        String cron = "0 0 0 * * ?";

        ScheduleGroup scheduleGroup = scheduleJobManagementService.createGroup("test group");
        Assert.assertNotNull(scheduleGroup);

        ClusterGroup clusterGroup = new ClusterGroup();
        clusterGroup.setName("Test cluster group");
        businessEntityDao.save(clusterGroup);

        ClusterNode clusterNode = new ClusterNode();
        clusterNode.setAddress("10.2.0.1");
        clusterNode.setDescription("test node");
        clusterNode.setEnabled(true);
        clusterNode.setGroup(clusterGroup);
        clusterGroup.getNodes().add(clusterNode);

        control.reset();

        quartzManagementService.createJob(
            EasyMock.anyLong(),
            EasyMock.eq(cron),
            EasyMock.eq(DEFAULT_TIMEZONE),
            EasyMock.eq(true)
        );

        control.replay();

        ScheduleJobCreateParameters jobParameters = new ScheduleJobCreateParameters();
        jobParameters.setName("Test Job");
        jobParameters.setDescription("Nothing to do");
        jobParameters.setTimezone(DEFAULT_TIMEZONE);
        jobParameters.setCron(cron);
        jobParameters.setEnabled(true);
        jobParameters.setClusterGroupId(clusterGroup.getId());
        jobParameters.setScheduleGroupId(scheduleGroup.getId());
        jobParameters.setStrategy(ScheduleExecutionStrategy.CIRCULAR);
        jobParameters.setActionIdentifier("action.type");
        jobParameters.setActionDefinition("action.data".getBytes());

View Full Code Here


        Assert.assertNotNull(scheduleGroup1);

        ScheduleGroup scheduleGroup2 = scheduleJobManagementService.createGroup("test group 2");
        Assert.assertNotNull(scheduleGroup2);

        ClusterGroup clusterGroup = new ClusterGroup();
        clusterGroup.setName("Test cluster group");
        businessEntityDao.save(clusterGroup);

        ClusterNode clusterNode = new ClusterNode();
        clusterNode.setAddress("10.2.0.1");
        clusterNode.setDescription("test node");
        clusterNode.setEnabled(true);
        clusterNode.setGroup(clusterGroup);
        clusterGroup.getNodes().add(clusterNode);

        control.reset();

        quartzManagementService.createJob(
            EasyMock.anyLong(),
            EasyMock.eq(cron),
            EasyMock.eq(DEFAULT_TIMEZONE),
            EasyMock.eq(true)
        );

        control.replay();

        ScheduleJobCreateParameters jobParameters = new ScheduleJobCreateParameters();
        jobParameters.setName("Test Job");
        jobParameters.setDescription("Nothing to do");
        jobParameters.setTimezone(DEFAULT_TIMEZONE);
        jobParameters.setCron(cron);
        jobParameters.setEnabled(true);
        jobParameters.setClusterGroupId(clusterGroup.getId());
        jobParameters.setScheduleGroupId(scheduleGroup2.getId());
        jobParameters.setStrategy(ScheduleExecutionStrategy.CIRCULAR);
        jobParameters.setActionIdentifier("action.type");
        jobParameters.setActionDefinition("action.data".getBytes());
View Full Code Here

        String cron2 = "1 0 0 * * ?";

        ScheduleGroup scheduleGroup = scheduleJobManagementService.createGroup("test group");
        Assert.assertNotNull(scheduleGroup);

        ClusterGroup clusterGroup = new ClusterGroup();
        clusterGroup.setName("Test cluster group");
        businessEntityDao.save(clusterGroup);

        ClusterNode clusterNode = new ClusterNode();
        clusterNode.setAddress("10.2.0.1");
        clusterNode.setDescription("test node");
        clusterNode.setEnabled(true);
        clusterNode.setGroup(clusterGroup);
        clusterGroup.getNodes().add(clusterNode);

        Capture<Long> idCapture = new Capture<Long>(CaptureType.ALL);

        control.reset();

        quartzManagementService.createJob(
            EasyMock.anyLong(),
            EasyMock.eq(cron1),
            EasyMock.eq(DEFAULT_TIMEZONE),
            EasyMock.eq(true)
        );

        quartzManagementService.disableJob(
            EasyMock.capture(idCapture)
        );

        control.replay();

        ScheduleJobCreateParameters jobParameters = new ScheduleJobCreateParameters();
        jobParameters.setName("Test Job");
        jobParameters.setDescription("Nothing to do");
        jobParameters.setTimezone(DEFAULT_TIMEZONE);
        jobParameters.setCron(cron1);
        jobParameters.setEnabled(true);
        jobParameters.setClusterGroupId(clusterGroup.getId());
        jobParameters.setScheduleGroupId(scheduleGroup.getId());
        jobParameters.setStrategy(ScheduleExecutionStrategy.CIRCULAR);
        jobParameters.setActionIdentifier("action.type");
        jobParameters.setActionDefinition("action.data".getBytes());

View Full Code Here

        String cron = "0 0 0 * * ?";

        ScheduleGroup scheduleGroup = scheduleJobManagementService.createGroup("test group");
        Assert.assertNotNull(scheduleGroup);

        ClusterGroup clusterGroup = new ClusterGroup();
        clusterGroup.setName("Test cluster group");
        businessEntityDao.save(clusterGroup);

        ClusterNode clusterNode1 = new ClusterNode();
        clusterNode1.setAddress("10.2.0.1");
        clusterNode1.setDescription("test node");
        clusterNode1.setEnabled(true);
        clusterNode1.setGroup(clusterGroup);
        clusterGroup.getNodes().add(clusterNode1);

        ClusterNode clusterNode2 = new ClusterNode();
        clusterNode2.setAddress("10.2.0.2");
        clusterNode2.setDescription("test node");
        clusterNode2.setEnabled(true);
        clusterNode2.setGroup(clusterGroup);
        clusterGroup.getNodes().add(clusterNode2);

        control.reset();

        quartzManagementService.createJob(
            EasyMock.anyLong(),
            EasyMock.eq(cron),
            EasyMock.eq(DEFAULT_TIMEZONE),
            EasyMock.eq(true)
        );

        control.replay();

        ScheduleJobCreateParameters jobParameters = new ScheduleJobCreateParameters();
        jobParameters.setName("Test Job");
        jobParameters.setDescription("Nothing to do");
        jobParameters.setTimezone(DEFAULT_TIMEZONE);
        jobParameters.setCron(cron);
        jobParameters.setEnabled(true);
        jobParameters.setClusterGroupId(clusterGroup.getId());
        jobParameters.setScheduleGroupId(scheduleGroup.getId());
        jobParameters.setStrategy(ScheduleExecutionStrategy.CIRCULAR);
        jobParameters.setActionIdentifier("action.type");
        jobParameters.setActionDefinition("action.data".getBytes());

View Full Code Here

        String cron = "0 0 0 * * ?";

        ScheduleGroup scheduleGroup = scheduleJobManagementService.createGroup("test group");
        Assert.assertNotNull(scheduleGroup);

        ClusterGroup clusterGroup = new ClusterGroup();
        clusterGroup.setName("Test cluster group");
        businessEntityDao.save(clusterGroup);

        ClusterNode clusterNode = new ClusterNode();
        clusterNode.setAddress("10.2.0.1");
        clusterNode.setDescription("test node");
        clusterNode.setEnabled(true);
        clusterNode.setGroup(clusterGroup);
        clusterGroup.getNodes().add(clusterNode);

        Capture<Long> idCapture1 = new Capture<Long>(CaptureType.ALL);
        Capture<Long> idCapture2 = new Capture<Long>(CaptureType.ALL);

        control.reset();

        quartzManagementService.createJob(
            EasyMock.capture(idCapture1),
            EasyMock.eq(cron),
            EasyMock.eq(DEFAULT_TIMEZONE),
            EasyMock.eq(true)
        );

        quartzManagementService.deleteJob(
            EasyMock.capture(idCapture2)
        );

        control.replay();

        ScheduleJobCreateParameters jobParameters = new ScheduleJobCreateParameters();
        jobParameters.setName("Test Job");
        jobParameters.setDescription("Nothing to do");
        jobParameters.setTimezone(DEFAULT_TIMEZONE);
        jobParameters.setCron(cron);
        jobParameters.setEnabled(true);
        jobParameters.setClusterGroupId(clusterGroup.getId());
        jobParameters.setScheduleGroupId(scheduleGroup.getId());
        jobParameters.setStrategy(ScheduleExecutionStrategy.CIRCULAR);
        jobParameters.setActionIdentifier("action.type");
        jobParameters.setActionDefinition("action.data".getBytes());

View Full Code Here

        String cron = "0 0 0 * * ?";

        ScheduleGroup scheduleGroup = scheduleJobManagementService.createGroup("test group");
        Assert.assertNotNull(scheduleGroup);

        ClusterGroup clusterGroup = new ClusterGroup();
        clusterGroup.setName("Test cluster group");
        businessEntityDao.save(clusterGroup);

        ClusterNode clusterNode = new ClusterNode();
        clusterNode.setAddress("10.2.0.1");
        clusterNode.setDescription("test node");
        clusterNode.setEnabled(true);
        clusterNode.setGroup(clusterGroup);
        clusterGroup.getNodes().add(clusterNode);

        control.reset();

        quartzManagementService.createJob(
            EasyMock.anyLong(),
            EasyMock.eq(cron),
            EasyMock.eq(DEFAULT_TIMEZONE),
            EasyMock.eq(true)
        );

        control.replay();

        ScheduleJobCreateParameters jobParameters = new ScheduleJobCreateParameters();
        jobParameters.setName("Test Job");
        jobParameters.setDescription("Nothing to do");
        jobParameters.setTimezone(DEFAULT_TIMEZONE);
        jobParameters.setCron(cron);
        jobParameters.setEnabled(true);
        jobParameters.setClusterGroupId(clusterGroup.getId());
        jobParameters.setScheduleGroupId(scheduleGroup.getId());
        jobParameters.setStrategy(ScheduleExecutionStrategy.CIRCULAR);
        jobParameters.setActionIdentifier("action.type");
        jobParameters.setActionDefinition("action.data".getBytes());

View Full Code Here

        String cron = "0 0 0 * * ?";

        ScheduleGroup scheduleGroup = scheduleJobManagementService.createGroup("test group");
        Assert.assertNotNull(scheduleGroup);

        ClusterGroup clusterGroup = new ClusterGroup();
        clusterGroup.setName("Test cluster group");
        businessEntityDao.save(clusterGroup);

        ClusterNode clusterNode = new ClusterNode();
        clusterNode.setAddress("10.2.0.1");
        clusterNode.setDescription("test node");
        clusterNode.setEnabled(true);
        clusterNode.setGroup(clusterGroup);
        clusterGroup.getNodes().add(clusterNode);

        Capture<Long> idCapture1 = new Capture<Long>(CaptureType.ALL);
        Capture<Long> idCapture2 = new Capture<Long>(CaptureType.ALL);

        control.reset();

        quartzManagementService.createJob(
            EasyMock.anyLong(),
            EasyMock.eq(cron),
            EasyMock.eq(DEFAULT_TIMEZONE),
            EasyMock.eq(true)
        );

        quartzManagementService.disableJob(
            EasyMock.capture(idCapture1)
        );

        quartzManagementService.enableJob(
            EasyMock.capture(idCapture2),
            EasyMock.eq(cron),
            EasyMock.eq(DEFAULT_TIMEZONE)
        );

        control.replay();

        ScheduleJobCreateParameters jobParameters = new ScheduleJobCreateParameters();
        jobParameters.setName("Test Job");
        jobParameters.setDescription("Nothing to do");
        jobParameters.setTimezone(DEFAULT_TIMEZONE);
        jobParameters.setCron(cron);
        jobParameters.setEnabled(true);
        jobParameters.setClusterGroupId(clusterGroup.getId());
        jobParameters.setScheduleGroupId(scheduleGroup.getId());
        jobParameters.setStrategy(ScheduleExecutionStrategy.CIRCULAR);
        jobParameters.setActionIdentifier("action.type");
        jobParameters.setActionDefinition("action.data".getBytes());

View Full Code Here

        String cron2 = "1 0 0 * * ?";

        ScheduleGroup scheduleGroup = scheduleJobManagementService.createGroup("test group");
        Assert.assertNotNull(scheduleGroup);

        ClusterGroup clusterGroup = new ClusterGroup();
        clusterGroup.setName("Test cluster group");
        businessEntityDao.save(clusterGroup);

        ClusterNode clusterNode = new ClusterNode();
        clusterNode.setAddress("10.2.0.1");
        clusterNode.setDescription("test node");
        clusterNode.setEnabled(true);
        clusterNode.setGroup(clusterGroup);
        clusterGroup.getNodes().add(clusterNode);

        Capture<Long> idCapture = new Capture<Long>(CaptureType.ALL);

        control.reset();

        quartzManagementService.createJob(
            EasyMock.anyLong(),
            EasyMock.eq(cron1),
            EasyMock.eq(DEFAULT_TIMEZONE),
            EasyMock.eq(true)
        );

        quartzManagementService.rescheduleJob(
            EasyMock.capture(idCapture),
            EasyMock.eq(cron2),
            EasyMock.eq(DEFAULT_TIMEZONE)
        );

        control.replay();

        ScheduleJobCreateParameters jobParameters = new ScheduleJobCreateParameters();
        jobParameters.setName("Test Job");
        jobParameters.setDescription("Nothing to do");
        jobParameters.setTimezone(DEFAULT_TIMEZONE);
        jobParameters.setCron(cron1);
        jobParameters.setEnabled(true);
        jobParameters.setClusterGroupId(clusterGroup.getId());
        jobParameters.setScheduleGroupId(scheduleGroup.getId());
        jobParameters.setStrategy(ScheduleExecutionStrategy.CIRCULAR);
        jobParameters.setActionIdentifier("action.type");
        jobParameters.setActionDefinition("action.data".getBytes());

View Full Code Here

    @Test
    public void testSimpleScenario() throws Exception {
        // Create group

        ClusterGroup clusterGroup = clusterManagementService.createGroup("Test group");
        Assert.assertNotNull(clusterGroup);
        Assert.assertEquals("Test group", clusterGroup.getName());
        Assert.assertEquals(0, clusterGroup.getNodes().size());
        Assert.assertEquals(0, clusterGroup.getRollingIndex());

        entityManager.flush();
        entityManager.clear();

        ClusterGroup clusterGroupModified = clusterManagementService.findGroup(clusterGroup.getId());
        Assert.assertNotNull(clusterGroupModified);
        Assert.assertEquals("Test group", clusterGroupModified.getName());
        Assert.assertEquals(0, clusterGroupModified.getNodes().size());

        List<ClusterGroup> allClusterGroups = clusterManagementService.findAllGroups(Extraction.ALL);
        Assert.assertNotNull(allClusterGroups);
        Assert.assertTrue(allClusterGroups.size() > 0);
        Assert.assertTrue(Iterators.contains(allClusterGroups.iterator(), clusterGroup));

        // Modify group

        clusterGroupModified = clusterManagementService.modifyGroup(clusterGroup.getId(), "Test group 2");
        Assert.assertNotNull(clusterGroupModified);
        Assert.assertEquals("Test group 2", clusterGroupModified.getName());

        entityManager.flush();
        entityManager.clear();

        clusterGroupModified = clusterManagementService.findGroup(clusterGroup.getId());
        Assert.assertNotNull(clusterGroupModified);
        Assert.assertEquals("Test group 2", clusterGroupModified.getName());
        Assert.assertEquals(0, clusterGroupModified.getNodes().size());

        // Create nodes

        ClusterNode clusterNode1 = clusterManagementService.createNode(clusterGroup.getId(),
            "10.2.0.1", "Node 1", true);
        Assert.assertNotNull(clusterNode1);

        ClusterNode clusterNode2 = clusterManagementService.createNode(clusterGroup.getId(),
            "10.2.0.2", "Node 2", true);
        Assert.assertNotNull(clusterNode2);

        ClusterNode clusterNode3 = clusterManagementService.createNode(clusterGroup.getId(),
            "10.2.0.3", "Node 3", false);
        Assert.assertNotNull(clusterNode3);

        entityManager.flush();
        entityManager.clear();

        clusterGroupModified = clusterManagementService.findGroup(clusterGroup.getId());
        Assert.assertNotNull(clusterGroupModified);
        Assert.assertEquals(3, clusterGroupModified.getNodes().size());
        Assert.assertEquals(clusterNode1, clusterGroupModified.getNodes().get(0));
        Assert.assertEquals(clusterNode2, clusterGroupModified.getNodes().get(1));
        Assert.assertEquals(clusterNode3, clusterGroupModified.getNodes().get(2));

        // Modify nodes

        ClusterNode clusterNodeModified;

        clusterNodeModified = clusterManagementService.modifyNode(clusterNode2.getId(),
            "10.2.0.2", "Node 2", false);
        Assert.assertNotNull(clusterNodeModified);
        Assert.assertEquals(false, clusterNodeModified.isEnabled());

        clusterNodeModified = clusterManagementService.modifyNode(clusterNode3.getId(),
            "10.2.0.3", "Node 3", true);
        Assert.assertNotNull(clusterNodeModified);
        Assert.assertEquals(true, clusterNodeModified.isEnabled());

        entityManager.flush();
        entityManager.clear();

        clusterGroupModified = clusterManagementService.findGroup(clusterGroup.getId());
        Assert.assertNotNull(clusterGroupModified);
        Assert.assertEquals(3, clusterGroupModified.getNodes().size());

        clusterNodeModified = clusterGroupModified.getNodes().get(0);
        Assert.assertNotNull(clusterNodeModified);
        Assert.assertEquals(0, clusterNodeModified.getOrderIndex());
        Assert.assertEquals("10.2.0.1", clusterNodeModified.getAddress());
        Assert.assertEquals("Node 1", clusterNodeModified.getDescription());
        Assert.assertEquals(true, clusterNodeModified.isEnabled());

        clusterNodeModified = clusterGroupModified.getNodes().get(1);
        Assert.assertNotNull(clusterNodeModified);
        Assert.assertEquals(1, clusterNodeModified.getOrderIndex());
        Assert.assertEquals("10.2.0.2", clusterNodeModified.getAddress());
        Assert.assertEquals("Node 2", clusterNodeModified.getDescription());
        Assert.assertEquals(false, clusterNodeModified.isEnabled());

        clusterNodeModified = clusterGroupModified.getNodes().get(2);
        Assert.assertNotNull(clusterNodeModified);
        Assert.assertEquals(2, clusterNodeModified.getOrderIndex());
        Assert.assertEquals("10.2.0.3", clusterNodeModified.getAddress());
        Assert.assertEquals("Node 3", clusterNodeModified.getDescription());
        Assert.assertEquals(true, clusterNodeModified.isEnabled());

        // Delete node

        clusterManagementService.deleteNode(clusterNode2.getId());

        entityManager.flush();
        entityManager.clear();

        clusterGroupModified = clusterManagementService.findGroup(clusterGroup.getId());
        Assert.assertNotNull(clusterGroupModified);
        Assert.assertEquals(2, clusterGroupModified.getNodes().size());

        clusterNodeModified = clusterGroupModified.getNodes().get(0);
        Assert.assertNotNull(clusterNodeModified);
        Assert.assertEquals(0, clusterNodeModified.getOrderIndex());
        Assert.assertEquals("10.2.0.1", clusterNodeModified.getAddress());
        Assert.assertEquals("Node 1", clusterNodeModified.getDescription());
        Assert.assertEquals(true, clusterNodeModified.isEnabled());

        clusterNodeModified = clusterGroupModified.getNodes().get(1);
        Assert.assertNotNull(clusterNodeModified);
        Assert.assertEquals(1, clusterNodeModified.getOrderIndex());
        Assert.assertEquals("10.2.0.3", clusterNodeModified.getAddress());
        Assert.assertEquals("Node 3", clusterNodeModified.getDescription());
        Assert.assertEquals(true, clusterNodeModified.isEnabled());
View Full Code Here

    @Resource
    private BusinessEntityDao businessEntityDao;

    @Test
    public void testClusterGroupDao() throws Exception {
        ClusterGroup clusterGroup = new ClusterGroup();
        clusterGroup.setName("dgfsrgw");
        clusterGroup.setRollingIndex(2);

        BusinessEntityJpaDaoChecker.checkBusinessEntityDao(entityManager, businessEntityDao,
            ClusterGroup.class, clusterGroup);
    }
View Full Code Here

TOP

Related Classes of org.qzerver.model.domain.entities.cluster.ClusterGroup

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.