Java 类org.apache.hadoop.hbase.master.TableLockManager.NullTableLockManager 实例源码

项目:HIndex    文件:TestAssignmentManager.java   
/**
 * Test verifies whether all the enabling table regions assigned only once during master startup.
 *
 * @throws KeeperException
 * @throws IOException
 * @throws Exception
 */
@Test
public void testMasterRestartWhenTableInEnabling() throws KeeperException, IOException, Exception {
  enabling = true;
  List<ServerName> destServers = new ArrayList<ServerName>(1);
  destServers.add(SERVERNAME_A);
  Mockito.when(this.serverManager.createDestinationServersList()).thenReturn(destServers);
  Mockito.when(this.serverManager.isServerOnline(SERVERNAME_A)).thenReturn(true);
  HTU.getConfiguration().setInt(HConstants.MASTER_PORT, 0);
  Server server = new HMaster(HTU.getConfiguration());
  Whitebox.setInternalState(server, "serverManager", this.serverManager);
  AssignmentManagerWithExtrasForTesting am = setUpMockedAssignmentManager(server,
      this.serverManager);
  try {
    // set table in enabling state.
    am.getZKTable().setEnablingTable(REGIONINFO.getTable());
    new EnableTableHandler(server, REGIONINFO.getTable(),
        am.getCatalogTracker(), am, new NullTableLockManager(), true).prepare()
        .process();
    assertEquals("Number of assignments should be 1.", 1, assignmentCount);
    assertTrue("Table should be enabled.",
        am.getZKTable().isEnabledTable(REGIONINFO.getTable()));
  } finally {
    enabling = false;
    assignmentCount = 0;
    am.getZKTable().setEnabledTable(REGIONINFO.getTable());
    am.shutdown();
    ZKAssign.deleteAllNodes(this.watcher);
  }
}
项目:PyroDB    文件:TestAssignmentManager.java   
/**
 * Test verifies whether all the enabling table regions assigned only once during master startup.
 *
 * @throws KeeperException
 * @throws IOException
 * @throws Exception
 */
@Test
public void testMasterRestartWhenTableInEnabling() throws KeeperException, IOException, Exception {
  enabling = true;
  List<ServerName> destServers = new ArrayList<ServerName>(1);
  destServers.add(SERVERNAME_A);
  Mockito.when(this.serverManager.createDestinationServersList()).thenReturn(destServers);
  Mockito.when(this.serverManager.isServerOnline(SERVERNAME_A)).thenReturn(true);
  HTU.getConfiguration().setInt(HConstants.MASTER_PORT, 0);
  CoordinatedStateManager csm = CoordinatedStateManagerFactory.getCoordinatedStateManager(
    HTU.getConfiguration());
  Server server = new HMaster(HTU.getConfiguration(), csm);
  Whitebox.setInternalState(server, "serverManager", this.serverManager);
  AssignmentManagerWithExtrasForTesting am = setUpMockedAssignmentManager(server,
      this.serverManager);
  try {
    // set table in enabling state.
    am.getTableStateManager().setTableState(REGIONINFO.getTable(),
      Table.State.ENABLING);
    new EnableTableHandler(server, REGIONINFO.getTable(),
        am.getCatalogTracker(), am, new NullTableLockManager(), true).prepare()
        .process();
    assertEquals("Number of assignments should be 1.", 1, assignmentCount);
    assertTrue("Table should be enabled.",
        am.getTableStateManager().isTableState(REGIONINFO.getTable(),
          Table.State.ENABLED));
  } finally {
    enabling = false;
    assignmentCount = 0;
    am.getTableStateManager().setTableState(REGIONINFO.getTable(),
      Table.State.ENABLED);
    am.shutdown();
    ZKAssign.deleteAllNodes(this.watcher);
  }
}
项目:c5    文件:TestAssignmentManager.java   
/**
 * Test verifies whether all the enabling table regions assigned only once during master startup.
 *
 * @throws KeeperException
 * @throws IOException
 * @throws Exception
 */
@Test
public void testMasterRestartWhenTableInEnabling() throws KeeperException, IOException, Exception {
  enabling = true;
  List<ServerName> destServers = new ArrayList<ServerName>(1);
  destServers.add(SERVERNAME_A);
  Mockito.when(this.serverManager.createDestinationServersList()).thenReturn(destServers);
  Mockito.when(this.serverManager.isServerOnline(SERVERNAME_A)).thenReturn(true);
  HTU.getConfiguration().setInt(HConstants.MASTER_PORT, 0);
  Server server = new HMaster(HTU.getConfiguration());
  Whitebox.setInternalState(server, "serverManager", this.serverManager);
  AssignmentManagerWithExtrasForTesting am = setUpMockedAssignmentManager(server,
      this.serverManager);
  try {
    // set table in enabling state.
    am.getZKTable().setEnablingTable(REGIONINFO.getTable());
    new EnableTableHandler(server, REGIONINFO.getTable(),
        am.getCatalogTracker(), am, new NullTableLockManager(), true).prepare()
        .process();
    assertEquals("Number of assignments should be 1.", 1, assignmentCount);
    assertTrue("Table should be enabled.",
        am.getZKTable().isEnabledTable(REGIONINFO.getTable()));
  } finally {
    enabling = false;
    assignmentCount = 0;
    am.getZKTable().setEnabledTable(REGIONINFO.getTable());
    am.shutdown();
    ZKAssign.deleteAllNodes(this.watcher);
  }
}
项目:ditb    文件:MockRegionServer.java   
public TableLockManager getTableLockManager() {
  return new NullTableLockManager();
}
项目:ditb    文件:MockRegionServerServices.java   
@Override
public TableLockManager getTableLockManager() {
  return new NullTableLockManager();
}
项目:pbase    文件:MockRegionServer.java   
public TableLockManager getTableLockManager() {
  return new NullTableLockManager();
}
项目:pbase    文件:TestAssignmentManager.java   
/**
 * Test verifies whether all the enabling table regions assigned only once during master startup.
 *
 * @throws KeeperException
 * @throws IOException
 * @throws Exception
 */
@Test (timeout=180000)
public void testMasterRestartWhenTableInEnabling() throws KeeperException, IOException, Exception {
  enabling = true;
  List<ServerName> destServers = new ArrayList<ServerName>(1);
  destServers.add(SERVERNAME_A);
  Mockito.when(this.serverManager.createDestinationServersList()).thenReturn(destServers);
  Mockito.when(this.serverManager.isServerOnline(SERVERNAME_A)).thenReturn(true);
  HTU.getConfiguration().setInt(HConstants.MASTER_PORT, 0);
  CoordinatedStateManager csm = CoordinatedStateManagerFactory.getCoordinatedStateManager(
    HTU.getConfiguration());
  Server server = new HMaster(HTU.getConfiguration(), csm);
  Whitebox.setInternalState(server, "serverManager", this.serverManager);
  AssignmentManagerWithExtrasForTesting am = setUpMockedAssignmentManager(server,
      this.serverManager);

  Whitebox.setInternalState(server, "metaTableLocator", Mockito.mock(MetaTableLocator.class));

  // Make it so we can get a catalogtracker from servermanager.. .needed
  // down in guts of server shutdown handler.
  Whitebox.setInternalState(server, "clusterConnection", am.getConnection());

  try {
    // set table in enabling state.
    am.getTableStateManager().setTableState(REGIONINFO.getTable(),
      Table.State.ENABLING);
    new EnableTableHandler(server, REGIONINFO.getTable(),
        am, new NullTableLockManager(), true).prepare()
        .process();
    assertEquals("Number of assignments should be 1.", 1, assignmentCount);
    assertTrue("Table should be enabled.",
        am.getTableStateManager().isTableState(REGIONINFO.getTable(),
          Table.State.ENABLED));
  } finally {
    enabling = false;
    assignmentCount = 0;
    am.getTableStateManager().setTableState(REGIONINFO.getTable(),
      Table.State.ENABLED);
    am.shutdown();
    ZKAssign.deleteAllNodes(this.watcher);
  }
}
项目:pbase    文件:TestAssignmentManager.java   
/**
 * Create an {@link AssignmentManagerWithExtrasForTesting} that has mocked
 * {@link CatalogTracker} etc.
 * @param server
 * @param manager
 * @return An AssignmentManagerWithExtras with mock connections, etc.
 * @throws IOException
 * @throws KeeperException
 */
private AssignmentManagerWithExtrasForTesting setUpMockedAssignmentManager(final Server server,
    final ServerManager manager) throws IOException, KeeperException,
      ServiceException, CoordinatedStateException {
  // Make an RS Interface implementation. Make it so a scanner can go against
  // it and a get to return the single region, REGIONINFO, this test is
  // messing with. Needed when "new master" joins cluster. AM will try and
  // rebuild its list of user regions and it will also get the HRI that goes
  // with an encoded name by doing a Get on hbase:meta
  ClientProtos.ClientService.BlockingInterface ri =
    Mockito.mock(ClientProtos.ClientService.BlockingInterface.class);
  // Get a meta row result that has region up on SERVERNAME_A for REGIONINFO
  Result r = MetaMockingUtil.getMetaTableRowResult(REGIONINFO, SERVERNAME_A);
  final ScanResponse.Builder builder = ScanResponse.newBuilder();
  builder.setMoreResults(true);
  builder.addCellsPerResult(r.size());
  final List<CellScannable> rows = new ArrayList<CellScannable>(1);
  rows.add(r);
  Answer<ScanResponse> ans = new Answer<ClientProtos.ScanResponse>() {
    @Override
    public ScanResponse answer(InvocationOnMock invocation) throws Throwable {
      PayloadCarryingRpcController controller = (PayloadCarryingRpcController) invocation
          .getArguments()[0];
      if (controller != null) {
        controller.setCellScanner(CellUtil.createCellScanner(rows));
      }
      return builder.build();
    }
  };
  if (enabling) {
    Mockito.when(ri.scan((RpcController) Mockito.any(), (ScanRequest) Mockito.any()))
        .thenAnswer(ans).thenAnswer(ans).thenAnswer(ans).thenAnswer(ans).thenAnswer(ans)
        .thenReturn(ScanResponse.newBuilder().setMoreResults(false).build());
  } else {
    Mockito.when(ri.scan((RpcController) Mockito.any(), (ScanRequest) Mockito.any())).thenAnswer(
        ans);
  }
  // If a get, return the above result too for REGIONINFO
  GetResponse.Builder getBuilder = GetResponse.newBuilder();
  getBuilder.setResult(ProtobufUtil.toResult(r));
  Mockito.when(ri.get((RpcController)Mockito.any(), (GetRequest) Mockito.any())).
    thenReturn(getBuilder.build());
  // Get a connection w/ mocked up common methods.
  ClusterConnection connection = (ClusterConnection)HConnectionTestingUtility.
    getMockedConnectionAndDecorate(HTU.getConfiguration(), null,
      ri, SERVERNAME_B, REGIONINFO);
  // These mocks were done up when all connections were managed.  World is different now we
  // moved to unmanaged connections.  It messes up the intercepts done in these tests.
  // Just mark connections as marked and then down in MetaTableAccessor, it will go the path
  // that picks up the above mocked up 'implementation' so 'scans' of meta return the expected
  // result.  Redo in new realm of unmanaged connections.
  Mockito.when(connection.isManaged()).thenReturn(true);
  // Make it so we can get the connection from our mocked catalogtracker
  // Create and startup an executor. Used by AM handling zk callbacks.
  ExecutorService executor = startupMasterExecutor("mockedAMExecutor");
  this.balancer = LoadBalancerFactory.getLoadBalancer(server.getConfiguration());
  AssignmentManagerWithExtrasForTesting am = new AssignmentManagerWithExtrasForTesting(
    server, connection, manager, this.balancer, executor, new NullTableLockManager());
  return am;
}
项目:pbase    文件:MockRegionServerServices.java   
@Override
public TableLockManager getTableLockManager() {
  return new NullTableLockManager();
}
项目:HIndex    文件:MockRegionServer.java   
public TableLockManager getTableLockManager() {
  return new NullTableLockManager();
}
项目:HIndex    文件:TestAssignmentManager.java   
/**
 * Create an {@link AssignmentManagerWithExtrasForTesting} that has mocked
 * {@link CatalogTracker} etc.
 * @param server
 * @param manager
 * @return An AssignmentManagerWithExtras with mock connections, etc.
 * @throws IOException
 * @throws KeeperException
 */
private AssignmentManagerWithExtrasForTesting setUpMockedAssignmentManager(final Server server,
    final ServerManager manager) throws IOException, KeeperException, ServiceException {
  // We need a mocked catalog tracker. Its used by our AM instance.
  CatalogTracker ct = Mockito.mock(CatalogTracker.class);
  // Make an RS Interface implementation. Make it so a scanner can go against
  // it and a get to return the single region, REGIONINFO, this test is
  // messing with. Needed when "new master" joins cluster. AM will try and
  // rebuild its list of user regions and it will also get the HRI that goes
  // with an encoded name by doing a Get on hbase:meta
  ClientProtos.ClientService.BlockingInterface ri =
    Mockito.mock(ClientProtos.ClientService.BlockingInterface.class);
  // Get a meta row result that has region up on SERVERNAME_A for REGIONINFO
  Result r = MetaMockingUtil.getMetaTableRowResult(REGIONINFO, SERVERNAME_A);
  final ScanResponse.Builder builder = ScanResponse.newBuilder();
  builder.setMoreResults(true);
  builder.addCellsPerResult(r.size());
  final List<CellScannable> rows = new ArrayList<CellScannable>(1);
  rows.add(r);
  Answer<ScanResponse> ans = new Answer<ClientProtos.ScanResponse>() {
    @Override
    public ScanResponse answer(InvocationOnMock invocation) throws Throwable {
      PayloadCarryingRpcController controller = (PayloadCarryingRpcController) invocation
          .getArguments()[0];
      if (controller != null) {
        controller.setCellScanner(CellUtil.createCellScanner(rows));
      }
      return builder.build();
    }
  };
  if (enabling) {
    Mockito.when(ri.scan((RpcController) Mockito.any(), (ScanRequest) Mockito.any()))
        .thenAnswer(ans).thenAnswer(ans).thenAnswer(ans).thenAnswer(ans).thenAnswer(ans)
        .thenReturn(ScanResponse.newBuilder().setMoreResults(false).build());
  } else {
    Mockito.when(ri.scan((RpcController) Mockito.any(), (ScanRequest) Mockito.any())).thenAnswer(
        ans);
  }
  // If a get, return the above result too for REGIONINFO
  GetResponse.Builder getBuilder = GetResponse.newBuilder();
  getBuilder.setResult(ProtobufUtil.toResult(r));
  Mockito.when(ri.get((RpcController)Mockito.any(), (GetRequest) Mockito.any())).
    thenReturn(getBuilder.build());
  // Get a connection w/ mocked up common methods.
  HConnection connection = HConnectionTestingUtility.
    getMockedConnectionAndDecorate(HTU.getConfiguration(), null,
      ri, SERVERNAME_B, REGIONINFO);
  // Make it so we can get the connection from our mocked catalogtracker
  Mockito.when(ct.getConnection()).thenReturn(connection);
  // Create and startup an executor. Used by AM handling zk callbacks.
  ExecutorService executor = startupMasterExecutor("mockedAMExecutor");
  this.balancer = LoadBalancerFactory.getLoadBalancer(server.getConfiguration());
  AssignmentManagerWithExtrasForTesting am = new AssignmentManagerWithExtrasForTesting(
    server, manager, ct, this.balancer, executor, new NullTableLockManager());
  return am;
}
项目:HIndex    文件:MockRegionServerServices.java   
@Override
public TableLockManager getTableLockManager() {
  return new NullTableLockManager();
}
项目:PyroDB    文件:MockRegionServer.java   
public TableLockManager getTableLockManager() {
  return new NullTableLockManager();
}
项目:PyroDB    文件:TestAssignmentManager.java   
/**
 * Create an {@link AssignmentManagerWithExtrasForTesting} that has mocked
 * {@link CatalogTracker} etc.
 * @param server
 * @param manager
 * @return An AssignmentManagerWithExtras with mock connections, etc.
 * @throws IOException
 * @throws KeeperException
 */
private AssignmentManagerWithExtrasForTesting setUpMockedAssignmentManager(final Server server,
    final ServerManager manager) throws IOException, KeeperException,
      ServiceException, CoordinatedStateException {
  // We need a mocked catalog tracker. Its used by our AM instance.
  CatalogTracker ct = Mockito.mock(CatalogTracker.class);
  // Make an RS Interface implementation. Make it so a scanner can go against
  // it and a get to return the single region, REGIONINFO, this test is
  // messing with. Needed when "new master" joins cluster. AM will try and
  // rebuild its list of user regions and it will also get the HRI that goes
  // with an encoded name by doing a Get on hbase:meta
  ClientProtos.ClientService.BlockingInterface ri =
    Mockito.mock(ClientProtos.ClientService.BlockingInterface.class);
  // Get a meta row result that has region up on SERVERNAME_A for REGIONINFO
  Result r = MetaMockingUtil.getMetaTableRowResult(REGIONINFO, SERVERNAME_A);
  final ScanResponse.Builder builder = ScanResponse.newBuilder();
  builder.setMoreResults(true);
  builder.addCellsPerResult(r.size());
  final List<CellScannable> rows = new ArrayList<CellScannable>(1);
  rows.add(r);
  Answer<ScanResponse> ans = new Answer<ClientProtos.ScanResponse>() {
    @Override
    public ScanResponse answer(InvocationOnMock invocation) throws Throwable {
      PayloadCarryingRpcController controller = (PayloadCarryingRpcController) invocation
          .getArguments()[0];
      if (controller != null) {
        controller.setCellScanner(CellUtil.createCellScanner(rows));
      }
      return builder.build();
    }
  };
  if (enabling) {
    Mockito.when(ri.scan((RpcController) Mockito.any(), (ScanRequest) Mockito.any()))
        .thenAnswer(ans).thenAnswer(ans).thenAnswer(ans).thenAnswer(ans).thenAnswer(ans)
        .thenReturn(ScanResponse.newBuilder().setMoreResults(false).build());
  } else {
    Mockito.when(ri.scan((RpcController) Mockito.any(), (ScanRequest) Mockito.any())).thenAnswer(
        ans);
  }
  // If a get, return the above result too for REGIONINFO
  GetResponse.Builder getBuilder = GetResponse.newBuilder();
  getBuilder.setResult(ProtobufUtil.toResult(r));
  Mockito.when(ri.get((RpcController)Mockito.any(), (GetRequest) Mockito.any())).
    thenReturn(getBuilder.build());
  // Get a connection w/ mocked up common methods.
  HConnection connection = HConnectionTestingUtility.
    getMockedConnectionAndDecorate(HTU.getConfiguration(), null,
      ri, SERVERNAME_B, REGIONINFO);
  // Make it so we can get the connection from our mocked catalogtracker
  Mockito.when(ct.getConnection()).thenReturn(connection);
  // Create and startup an executor. Used by AM handling zk callbacks.
  ExecutorService executor = startupMasterExecutor("mockedAMExecutor");
  this.balancer = LoadBalancerFactory.getLoadBalancer(server.getConfiguration());
  AssignmentManagerWithExtrasForTesting am = new AssignmentManagerWithExtrasForTesting(
    server, manager, ct, this.balancer, executor, new NullTableLockManager());
  return am;
}
项目:PyroDB    文件:MockRegionServerServices.java   
@Override
public TableLockManager getTableLockManager() {
  return new NullTableLockManager();
}
项目:c5    文件:MockRegionServer.java   
public TableLockManager getTableLockManager() {
  return new NullTableLockManager();
}
项目:c5    文件:TestAssignmentManager.java   
/**
 * Create an {@link AssignmentManagerWithExtrasForTesting} that has mocked
 * {@link CatalogTracker} etc.
 * @param server
 * @param manager
 * @return An AssignmentManagerWithExtras with mock connections, etc.
 * @throws IOException
 * @throws KeeperException
 */
private AssignmentManagerWithExtrasForTesting setUpMockedAssignmentManager(final Server server,
    final ServerManager manager) throws IOException, KeeperException, ServiceException {
  // We need a mocked catalog tracker. Its used by our AM instance.
  CatalogTracker ct = Mockito.mock(CatalogTracker.class);
  // Make an RS Interface implementation. Make it so a scanner can go against
  // it and a get to return the single region, REGIONINFO, this test is
  // messing with. Needed when "new master" joins cluster. AM will try and
  // rebuild its list of user regions and it will also get the HRI that goes
  // with an encoded name by doing a Get on hbase:meta
  ClientProtos.ClientService.BlockingInterface ri =
    Mockito.mock(ClientProtos.ClientService.BlockingInterface.class);
  // Get a meta row result that has region up on SERVERNAME_A for REGIONINFO
  Result r = MetaMockingUtil.getMetaTableRowResult(REGIONINFO, SERVERNAME_A);
  final ScanResponse.Builder builder = ScanResponse.newBuilder();
  builder.setMoreResults(true);
  builder.addCellsPerResult(r.size());
  final List<CellScannable> rows = new ArrayList<CellScannable>(1);
  rows.add(r);
  Answer<ScanResponse> ans = new Answer<ClientProtos.ScanResponse>() {
    public ScanResponse answer(InvocationOnMock invocation) throws Throwable {
      PayloadCarryingRpcController controller = (PayloadCarryingRpcController) invocation
          .getArguments()[0];
      if (controller != null) {
        controller.setCellScanner(CellUtil.createCellScanner(rows));
      }
      return builder.build();
    }
  };
  if (enabling) {
    Mockito.when(ri.scan((RpcController) Mockito.any(), (ScanRequest) Mockito.any()))
        .thenAnswer(ans).thenAnswer(ans).thenAnswer(ans).thenAnswer(ans).thenAnswer(ans)
        .thenReturn(ScanResponse.newBuilder().setMoreResults(false).build());
  } else {
    Mockito.when(ri.scan((RpcController) Mockito.any(), (ScanRequest) Mockito.any())).thenAnswer(
        ans);
  }
  // If a get, return the above result too for REGIONINFO
  GetResponse.Builder getBuilder = GetResponse.newBuilder();
  getBuilder.setResult(ProtobufUtil.toResult(r));
  Mockito.when(ri.get((RpcController)Mockito.any(), (GetRequest) Mockito.any())).
    thenReturn(getBuilder.build());
  // Get a connection w/ mocked up common methods.
  HConnection connection = HConnectionTestingUtility.
    getMockedConnectionAndDecorate(HTU.getConfiguration(), null,
      ri, SERVERNAME_B, REGIONINFO);
  // Make it so we can get the connection from our mocked catalogtracker
  Mockito.when(ct.getConnection()).thenReturn(connection);
  // Create and startup an executor. Used by AM handling zk callbacks.
  ExecutorService executor = startupMasterExecutor("mockedAMExecutor");
  this.balancer = LoadBalancerFactory.getLoadBalancer(server.getConfiguration());
  AssignmentManagerWithExtrasForTesting am = new AssignmentManagerWithExtrasForTesting(
    server, manager, ct, this.balancer, executor, new NullTableLockManager());
  return am;
}
项目:c5    文件:MockRegionServerServices.java   
@Override
public TableLockManager getTableLockManager() {
  return new NullTableLockManager();
}