Java Code Examples for org.apache.hadoop.hbase.Server#getConfiguration()

The following examples show how to use org.apache.hadoop.hbase.Server#getConfiguration() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MasterRegionFactory.java    From hbase with Apache License 2.0 6 votes vote down vote up
public static MasterRegion create(Server server) throws IOException {
  MasterRegionParams params = new MasterRegionParams().server(server)
    .regionDirName(MASTER_STORE_DIR).tableDescriptor(TABLE_DESC);
  Configuration conf = server.getConfiguration();
  long flushSize = conf.getLong(FLUSH_SIZE_KEY, DEFAULT_FLUSH_SIZE);
  long flushPerChanges = conf.getLong(FLUSH_PER_CHANGES_KEY, DEFAULT_FLUSH_PER_CHANGES);
  long flushIntervalMs = conf.getLong(FLUSH_INTERVAL_MS_KEY, DEFAULT_FLUSH_INTERVAL_MS);
  int compactMin = conf.getInt(COMPACT_MIN_KEY, DEFAULT_COMPACT_MIN);
  params.flushSize(flushSize).flushPerChanges(flushPerChanges).flushIntervalMs(flushIntervalMs)
    .compactMin(compactMin);
  int maxWals = conf.getInt(MAX_WALS_KEY, DEFAULT_MAX_WALS);
  params.maxWals(maxWals);
  if (conf.get(USE_HSYNC_KEY) != null) {
    params.useHsync(conf.getBoolean(USE_HSYNC_KEY, false));
  }
  params.ringBufferSlotCount(conf.getInt(RING_BUFFER_SLOT_COUNT, DEFAULT_RING_BUFFER_SLOT_COUNT));
  long rollPeriodMs = conf.getLong(ROLL_PERIOD_MS_KEY, DEFAULT_ROLL_PERIOD_MS);
  params.rollPeriodMs(rollPeriodMs).archivedWalSuffix(ARCHIVED_WAL_SUFFIX)
    .archivedHFileSuffix(ARCHIVED_HFILE_SUFFIX);
  return MasterRegion.create(params);
}
 
Example 2
Source File: RSRpcServices.java    From hbase with Apache License 2.0 6 votes vote down vote up
protected RpcServerInterface createRpcServer(
    final Server server,
    final RpcSchedulerFactory rpcSchedulerFactory,
    final InetSocketAddress bindAddress,
    final String name
) throws IOException {
  final Configuration conf = server.getConfiguration();
  boolean reservoirEnabled = conf.getBoolean(ByteBuffAllocator.ALLOCATOR_POOL_ENABLED_KEY, true);
  try {
    return RpcServerFactory.createRpcServer(server, name, getServices(),
        bindAddress, // use final bindAddress for this server.
        conf, rpcSchedulerFactory.create(conf, this, server), reservoirEnabled);
  } catch (BindException be) {
    throw new IOException(be.getMessage() + ". To switch ports use the '"
        + HConstants.REGIONSERVER_PORT + "' configuration property.",
        be.getCause() != null ? be.getCause() : be);
  }
}
 
Example 3
Source File: HeapMemoryManager.java    From hbase with Apache License 2.0 5 votes vote down vote up
@VisibleForTesting
HeapMemoryManager(BlockCache blockCache, FlushRequester memStoreFlusher,
              Server server, RegionServerAccounting regionServerAccounting) {
  Configuration conf = server.getConfiguration();
  this.blockCache = toResizableBlockCache(blockCache);
  this.memStoreFlusher = memStoreFlusher;
  this.server = server;
  this.regionServerAccounting = regionServerAccounting;
  this.tunerOn = doInit(conf);
  this.defaultChorePeriod = conf.getInt(HBASE_RS_HEAP_MEMORY_TUNER_PERIOD,
    HBASE_RS_HEAP_MEMORY_TUNER_DEFAULT_PERIOD);
  this.heapOccupancyLowWatermark = conf.getFloat(HConstants.HEAP_OCCUPANCY_LOW_WATERMARK_KEY,
    HConstants.DEFAULT_HEAP_OCCUPANCY_LOW_WATERMARK);
  metricsHeapMemoryManager = new MetricsHeapMemoryManager();
}
 
Example 4
Source File: ZkCoordinatedStateManager.java    From hbase with Apache License 2.0 4 votes vote down vote up
public ZkCoordinatedStateManager(Server server) {
  this.watcher = server.getZooKeeper();
  splitLogWorkerCoordination = new ZkSplitLogWorkerCoordination(server.getServerName(), watcher);
  splitLogManagerCoordination = new ZKSplitLogManagerCoordination(server.getConfiguration(),
      watcher);
}
 
Example 5
Source File: MasterRegion.java    From hbase with Apache License 2.0 4 votes vote down vote up
public static MasterRegion create(MasterRegionParams params) throws IOException {
  TableDescriptor td = params.tableDescriptor();
  LOG.info("Create or load local region for table " + td);
  Server server = params.server();
  Configuration baseConf = server.getConfiguration();
  FileSystem fs = CommonFSUtils.getRootDirFileSystem(baseConf);
  FileSystem walFs = CommonFSUtils.getWALFileSystem(baseConf);
  Path globalRootDir = CommonFSUtils.getRootDir(baseConf);
  Path globalWALRootDir = CommonFSUtils.getWALRootDir(baseConf);
  Path rootDir = new Path(globalRootDir, params.regionDirName());
  Path walRootDir = new Path(globalWALRootDir, params.regionDirName());
  // we will override some configurations so create a new one.
  Configuration conf = new Configuration(baseConf);
  CommonFSUtils.setRootDir(conf, rootDir);
  CommonFSUtils.setWALRootDir(conf, walRootDir);
  MasterRegionFlusherAndCompactor.setupConf(conf, params.flushSize(), params.flushPerChanges(),
    params.flushIntervalMs());
  conf.setInt(AbstractFSWAL.MAX_LOGS, params.maxWals());
  if (params.useHsync() != null) {
    conf.setBoolean(HRegion.WAL_HSYNC_CONF_KEY, params.useHsync());
  }
  if (params.useMetaCellComparator() != null) {
    conf.setBoolean(HRegion.USE_META_CELL_COMPARATOR, params.useMetaCellComparator());
  }
  conf.setInt(AbstractFSWAL.RING_BUFFER_SLOT_COUNT,
    IntMath.ceilingPowerOfTwo(params.ringBufferSlotCount()));

  MasterRegionWALRoller walRoller = MasterRegionWALRoller.create(
    td.getTableName() + "-WAL-Roller", conf, server, walFs, walRootDir, globalWALRootDir,
    params.archivedWalSuffix(), params.rollPeriodMs(), params.flushSize());
  walRoller.start();

  WALFactory walFactory = new WALFactory(conf, server.getServerName().toString(), false);
  Path tableDir = CommonFSUtils.getTableDir(rootDir, td.getTableName());
  HRegion region;
  if (fs.exists(tableDir)) {
    // load the existing region.
    region = open(conf, td, fs, rootDir, walFs, walRootDir, walFactory, walRoller,
      server.getServerName().toString());
  } else {
    // bootstrapping...
    region = bootstrap(conf, td, fs, rootDir, walFs, walRootDir, walFactory, walRoller,
      server.getServerName().toString());
  }
  Path globalArchiveDir = HFileArchiveUtil.getArchivePath(baseConf);
  MasterRegionFlusherAndCompactor flusherAndCompactor = new MasterRegionFlusherAndCompactor(conf,
    server, region, params.flushSize(), params.flushPerChanges(), params.flushIntervalMs(),
    params.compactMin(), globalArchiveDir, params.archivedHFileSuffix());
  walRoller.setFlusherAndCompactor(flusherAndCompactor);
  Path archiveDir = HFileArchiveUtil.getArchivePath(conf);
  if (!fs.mkdirs(archiveDir)) {
    LOG.warn("Failed to create archive directory {}. Usually this should not happen but it will" +
      " be created again when we actually archive the hfiles later, so continue", archiveDir);
  }
  return new MasterRegion(region, walFactory, flusherAndCompactor, walRoller);
}