Пример #1
0
  @Test
  public void testHandleRequestPartitionClosedSlave() throws Exception {
    final int partition = 1;
    final int opaque = 0;
    final int maxSize = 1024;
    final long offset = 10;

    this.metaConfig.setTopics(Arrays.asList(this.topic));
    this.metaConfig.closePartitions(this.topic, partition, partition);

    final MessageStore store = this.mocksControl.createMock(MessageStore.class);
    EasyMock.expect(this.storeManager.getMessageStore(this.topic, partition)).andReturn(store);
    final MessageSet set = this.mocksControl.createMock(MessageSet.class);
    EasyMock.expect(store.slice(offset, maxSize)).andReturn(set);

    final GetCommand request =
        new GetCommand(
            this.topic, this.metaConfig.getSlaveGroup(), partition, offset, maxSize, opaque);
    // this.conn.response(new BooleanCommand(request.getOpaque(),
    // HttpStatus.Forbidden, "partition["
    // + this.metaConfig.getBrokerId() + "-" + request.getPartition() +
    // "] have been closed"));
    set.write(request, this.sessionContext);
    EasyMock.expectLastCall();

    this.mocksControl.replay();

    this.getProcessor.handleRequest(request, this.conn);
    this.mocksControl.verify();
    assertEquals(0, this.statsManager.getCmdGetMiss());
    assertEquals(1, this.statsManager.getCmdGets());
    assertEquals(0, this.statsManager.getCmdOffsets());
  }
Пример #2
0
  @Test
  public void testHandleRequestNormal() throws Exception {
    final int partition = 1;
    final int opaque = 0;
    final int maxSize = 1024;
    final long offset = 10;
    final MessageStore store = this.mocksControl.createMock(MessageStore.class);
    EasyMock.expect(this.storeManager.getMessageStore(this.topic, partition)).andReturn(store);
    final MessageSet set = this.mocksControl.createMock(MessageSet.class);
    EasyMock.expect(store.slice(offset, maxSize)).andReturn(set);
    final GetCommand request =
        new GetCommand(this.topic, this.group, partition, offset, maxSize, opaque);
    set.write(request, this.sessionContext);
    EasyMock.expectLastCall();
    this.mocksControl.replay();

    this.getProcessor.handleRequest(request, this.conn);
    this.mocksControl.verify();
    assertEquals(0, this.statsManager.getCmdGetMiss());
    assertEquals(1, this.statsManager.getCmdGets());
    assertEquals(0, this.statsManager.getCmdOffsets());
  }