예제 #1
0
  @Test
  public void testSlaveToMaster() throws Exception {
    _clusterSchedulerEngine = _getClusterSchedulerEngine(false, 2, 0);

    Assert.assertFalse(_isMaster(_clusterSchedulerEngine));

    Map<String, SchedulerResponse> schedulerResponseMap =
        _getMemoryClusteredJobs(_clusterSchedulerEngine);

    Assert.assertEquals(2, schedulerResponseMap.size());

    String newMaster =
        AddressSerializerUtil.serialize(ClusterExecutorUtil.getLocalClusterNodeAddress());

    MockLockLocalService.setLock(newMaster);

    Assert.assertTrue(_isMaster(_clusterSchedulerEngine));

    _clusterSchedulerEngine.pause(_TEST_JOB_NAME_0, _MEMORY_CLUSTER_TEST_GROUP_NAME);

    _clusterSchedulerEngine.getScheduledJobs();

    schedulerResponseMap = _getMemoryClusteredJobs(_clusterSchedulerEngine);

    Assert.assertTrue(schedulerResponseMap.isEmpty());
  }
예제 #2
0
  private ClusterSchedulerEngine _getClusterSchedulerEngine(
      boolean master, int memoryClusterJobs, int persistentJobs) throws Exception {

    MockSchedulerEngine mockSchedulerEngine =
        new MockSchedulerEngine(memoryClusterJobs, persistentJobs);

    MockClusterExecutor mockClusterExecutor = new MockClusterExecutor(true, mockSchedulerEngine);

    ClusterExecutorUtil clusterExecutorUtil = new ClusterExecutorUtil();

    clusterExecutorUtil.setClusterExecutor(mockClusterExecutor);

    ClusterSchedulerEngine clusterSchedulerEngine = new ClusterSchedulerEngine(mockSchedulerEngine);

    Address masterAddress = null;

    if (master) {
      masterAddress = ClusterExecutorUtil.getLocalClusterNodeAddress();
    } else {
      masterAddress = MockClusterExecutor._anotherAddress;
    }

    MockLockLocalService.setLock(AddressSerializerUtil.serialize(masterAddress));

    SchedulerEngineHelperImpl schedulerEngineHelperImpl = new SchedulerEngineHelperImpl();

    schedulerEngineHelperImpl.setSchedulerEngine(clusterSchedulerEngine);

    SchedulerEngineHelperUtil schedulerEngineHelperUtil = new SchedulerEngineHelperUtil();

    schedulerEngineHelperUtil.setSchedulerEngineHelper(schedulerEngineHelperImpl);

    clusterSchedulerEngine.initialize();

    clusterSchedulerEngine.start();

    return clusterSchedulerEngine;
  }
예제 #3
0
  @Test
  public void testMasterToSlave2() throws Exception {
    _clusterSchedulerEngine = _getClusterSchedulerEngine(true, 2, 2);

    Assert.assertTrue(_isMaster(_clusterSchedulerEngine));

    Map<String, SchedulerResponse> schedulerResponseMap =
        _getMemoryClusteredJobs(_clusterSchedulerEngine);

    Assert.assertTrue(schedulerResponseMap.isEmpty());

    String newMaster = AddressSerializerUtil.serialize(MockClusterExecutor._anotherAddress);

    MockLockLocalService.setLock(newMaster);

    Assert.assertFalse(_isMaster(_clusterSchedulerEngine));

    MockClusterExecutor.fireClusterEventListener();

    schedulerResponseMap = _getMemoryClusteredJobs(_clusterSchedulerEngine);

    Assert.assertEquals(2, schedulerResponseMap.size());
  }