Exemplo n.º 1
0
 @Test
 public void testGetByStartDateEndDate() {
   Date startDate = DateUtil.createDate("2010-10-01");
   Date endDate = DateUtil.createDate("2010-10-31");
   List<Operation> list = operationService.get(startDate, endDate);
   assertEquals(5, list.size());
 }
Exemplo n.º 2
0
 @Test
 public void testGet() {
   // 平台业务
   Operation opP = operationService.get(1L);
   assertTrue(opP instanceof OperationP);
   assertNotNull(((OperationP) opP).getProgram());
   // 传输业务
   Operation opT = operationService.get(2L);
   assertTrue(opT instanceof OperationT);
   assertNotNull(((OperationT) opT).getCawaveT());
   assertNotNull(((OperationT) opT).getRoute());
   // 卫星业务
   Operation opS = operationService.get(3L);
   assertTrue(opS instanceof OperationS);
   assertEquals(opS.getSchedules().size(), 1);
   assertNotNull(((OperationS) opS).getCawaveS());
   assertNotNull(((OperationS) opS).getTransfer());
 }
Exemplo n.º 3
0
 @Test(expected = CanNotDeleteException.class)
 public void testDeleteS() {
   // 判断有异态的情况,如果有异态,则不能删除
   assertRowsCount(Operation.class, 5); // 业务删除
   assertRowsCount(OperationS.class, 3); // 业务删除
   operationService.delete(3L);
   assertRowsCount(Operation.class, 5); // 业务删除
   assertRowsCount(OperationS.class, 3); // 业务删除
 }
Exemplo n.º 4
0
 @Test(expected = CanNotDeleteException.class)
 public void testDelete() {
   // 其他信息不受影响,运行图级联删除,通路不变
   operationService.delete(2L);
   this.flushSessionAndCloseSessionAndNewASession();
   assertRowsCount(Program.class, 5); // 节目不受影响
   assertRowsCount(Operation.class, 4); // 业务删除
   assertRowsCount(OperationT.class, 0); // 业务删除
   assertRowsCount(Channel.class, 2); // 通路不受影响
   assertRowsCount(Schedule.class, 3);
 }
Exemplo n.º 5
0
  @Test
  public void whenTargetMemberDiesThenOperationAbortedWithMembersLeftException() throws Exception {
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
    HazelcastInstance local = factory.newHazelcastInstance();
    HazelcastInstance remote = factory.newHazelcastInstance();
    warmUpPartitions(local, remote);

    OperationService service = getNode(local).nodeEngine.getOperationService();
    Operation op = new TargetOperation();
    Address address = new Address(remote.getCluster().getLocalMember().getSocketAddress());
    Future f = service.createInvocationBuilder(null, op, address).invoke();
    sleepSeconds(1);

    remote.getLifecycleService().terminate();

    try {
      f.get();
      fail();
    } catch (MemberLeftException expected) {

    }
  }
Exemplo n.º 6
0
  @Override
  public void run() throws Exception {
    if (!valid) {
      return;
    }
    final NodeEngine nodeEngine = getNodeEngine();
    final PartitionServiceImpl partitionService =
        (PartitionServiceImpl) nodeEngine.getPartitionService();
    partitionService.updatePartitionReplicaVersions(
        getPartitionId(), replicaVersions, getReplicaIndex());

    if (backupOp != null) {
      backupOp.setNodeEngine(nodeEngine);
      backupOp.setResponseHandler(ResponseHandlerFactory.createEmptyResponseHandler());
      backupOp.setCallerUuid(getCallerUuid());
      OperationAccessor.setCallerAddress(backupOp, getCallerAddress());
      OperationAccessor.setInvocationTime(backupOp, Clock.currentTimeMillis());

      final OperationService operationService = nodeEngine.getOperationService();
      operationService.runOperation(backupOp);
    }
  }
Exemplo n.º 7
0
  @Test
  public void whenPartitionTargetMemberDiesThenOperationSendToNewPartitionOwner() throws Exception {
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
    HazelcastInstance local = factory.newHazelcastInstance();
    HazelcastInstance remote = factory.newHazelcastInstance();
    warmUpPartitions(local, remote);

    Node localNode = getNode(local);
    OperationService service = localNode.nodeEngine.getOperationService();
    Operation op = new PartitionTargetOperation();
    String partitionKey = generateKeyOwnedBy(remote);
    int partitionId = localNode.nodeEngine.getPartitionService().getPartitionId(partitionKey);
    Future f =
        service.createInvocationBuilder(null, op, partitionId).setCallTimeout(30000).invoke();
    sleepSeconds(1);

    remote.shutdown();

    // the get should work without a problem because the operation should be re-targeted at the
    // newest owner
    // for that given partition
    f.get();
  }
Exemplo n.º 8
0
 @Test
 public void testSaveP() {
   OperationP op =
       new OperationP(
           "a",
           new TransmitDef(17L),
           new TransType(1L),
           1.1,
           1.1,
           new Date(),
           new Date(),
           "wj",
           new Program(1L));
   operationService.save(op);
   this.flushSessionAndCloseSessionAndNewASession();
   assertRowsCount(OperationP.class, 2);
 }
Exemplo n.º 9
0
 @Test
 public void testSaveS() {
   OperationS op =
       new OperationS(
           "a",
           new TransmitDef(17L),
           new TransType(1L),
           1.1,
           1.1,
           new Date(),
           new Date(),
           "wj",
           new Cawave(1L),
           new Transfer(1L));
   operationService.save(op);
   this.flushSessionAndCloseSessionAndNewASession();
   assertRowsCount(OperationS.class, 4);
 }
Exemplo n.º 10
0
 @Test
 public void testGetAll() {
   assertEquals(operationService.getAll().size(), 5);
 }
Exemplo n.º 11
0
 @Test(expected = CanNotDeleteException.class)
 public void testDeleteP2() {
   assertRowsCount(Operation.class, 5); // 业务删除
   operationService.delete(1L);
   assertRowsCount(Operation.class, 5); // 业务删除
 }