Java 类org.apache.hadoop.hbase.CompoundConfiguration 实例源码

项目:ditb    文件:ReplicationPeersZKImpl.java   
@Override
public Pair<ReplicationPeerConfig, Configuration> getPeerConf(String peerId)
    throws ReplicationException {
  ReplicationPeerConfig peerConfig = getReplicationPeerConfig(peerId);

  if (peerConfig == null) {
    return null;
  }

  Configuration otherConf;
  try {
    otherConf = HBaseConfiguration.createClusterConf(this.conf, peerConfig.getClusterKey());
  } catch (IOException e) {
    LOG.error("Can't get peer configuration for peerId=" + peerId + " because:", e);
    return null;
  }

  if (!peerConfig.getConfiguration().isEmpty()) {
    CompoundConfiguration compound = new CompoundConfiguration();
    compound.add(otherConf);
    compound.addStringMap(peerConfig.getConfiguration());
    return new Pair<ReplicationPeerConfig, Configuration>(peerConfig, compound);
  }

  return new Pair<ReplicationPeerConfig, Configuration>(peerConfig, otherConf);
}
项目:hbase    文件:ReplicationUtils.java   
public static Configuration getPeerClusterConfiguration(ReplicationPeerConfig peerConfig,
    Configuration baseConf) throws ReplicationException {
  Configuration otherConf;
  try {
    otherConf = HBaseConfiguration.createClusterConf(baseConf, peerConfig.getClusterKey());
  } catch (IOException e) {
    throw new ReplicationException("Can't get peer configuration for peer " + peerConfig, e);
  }

  if (!peerConfig.getConfiguration().isEmpty()) {
    CompoundConfiguration compound = new CompoundConfiguration();
    compound.add(otherConf);
    compound.addStringMap(peerConfig.getConfiguration());
    return compound;
  }

  return otherConf;
}
项目:hbase    文件:ReplicationPeerConfigUtil.java   
/**
 * Returns the configuration needed to talk to the remote slave cluster.
 * @param conf the base configuration
 * @param peer the description of replication peer
 * @return the configuration for the peer cluster, null if it was unable to get the configuration
 * @throws IOException when create peer cluster configuration failed
 */
public static Configuration getPeerClusterConfiguration(Configuration conf,
    ReplicationPeerDescription peer) throws IOException {
  ReplicationPeerConfig peerConfig = peer.getPeerConfig();
  Configuration otherConf;
  try {
    otherConf = HBaseConfiguration.createClusterConf(conf, peerConfig.getClusterKey());
  } catch (IOException e) {
    throw new IOException("Can't get peer configuration for peerId=" + peer.getPeerId(), e);
  }

  if (!peerConfig.getConfiguration().isEmpty()) {
    CompoundConfiguration compound = new CompoundConfiguration();
    compound.add(otherConf);
    compound.addStringMap(peerConfig.getConfiguration());
    return compound;
  }

  return otherConf;
}
项目:pbase    文件:ReplicationPeersZKImpl.java   
@Override
public Pair<ReplicationPeerConfig, Configuration> getPeerConf(String peerId)
    throws ReplicationException {
  ReplicationPeerConfig peerConfig = getReplicationPeerConfig(peerId);

  if (peerConfig == null) {
    return null;
  }

  Configuration otherConf = new Configuration(this.conf);
  try {
    if (peerConfig.getClusterKey() != null && !peerConfig.getClusterKey().isEmpty()) {
      ZKUtil.applyClusterKeyToConf(otherConf, peerConfig.getClusterKey());
    }
  } catch (IOException e) {
    LOG.error("Can't get peer configuration for peerId=" + peerId + " because:", e);
    return null;
  }

  if (!peerConfig.getConfiguration().isEmpty()) {
    CompoundConfiguration compound = new CompoundConfiguration();
    compound.add(otherConf);
    compound.addStringMap(peerConfig.getConfiguration());
    return new Pair<ReplicationPeerConfig, Configuration>(peerConfig, compound);
  }

  return new Pair<ReplicationPeerConfig, Configuration>(peerConfig, otherConf);
}
项目:hbase    文件:HStore.java   
/**
 * {@inheritDoc}
 */
@Override
public void onConfigurationChange(Configuration conf) {
  this.conf = new CompoundConfiguration()
          .add(conf)
          .addBytesMap(family.getValues());
  this.storeEngine.compactionPolicy.setConf(conf);
  this.offPeakHours = OffPeakHours.getInstance(conf);
}
项目:ditb    文件:AccessController.java   
@Override
public void start(CoprocessorEnvironment env) throws IOException {
  CompoundConfiguration conf = new CompoundConfiguration();
  conf.add(env.getConfiguration());

  authorizationEnabled = isAuthorizationSupported(conf);
  if (!authorizationEnabled) {
    LOG.warn("The AccessController has been loaded with authorization checks disabled.");
  }

  shouldCheckExecPermission = conf.getBoolean(AccessControlConstants.EXEC_PERMISSION_CHECKS_KEY,
    AccessControlConstants.DEFAULT_EXEC_PERMISSION_CHECKS);

  cellFeaturesEnabled = (HFile.getFormatVersion(conf) >= HFile.MIN_FORMAT_VERSION_WITH_TAGS);
  if (!cellFeaturesEnabled) {
    LOG.info("A minimum HFile version of " + HFile.MIN_FORMAT_VERSION_WITH_TAGS
        + " is required to persist cell ACLs. Consider setting " + HFile.FORMAT_VERSION_KEY
        + " accordingly.");
  }

  ZooKeeperWatcher zk = null;
  if (env instanceof MasterCoprocessorEnvironment) {
    // if running on HMaster
    MasterCoprocessorEnvironment mEnv = (MasterCoprocessorEnvironment) env;
    zk = mEnv.getMasterServices().getZooKeeper();
  } else if (env instanceof RegionServerCoprocessorEnvironment) {
    RegionServerCoprocessorEnvironment rsEnv = (RegionServerCoprocessorEnvironment) env;
    zk = rsEnv.getRegionServerServices().getZooKeeper();
  } else if (env instanceof RegionCoprocessorEnvironment) {
    // if running at region
    regionEnv = (RegionCoprocessorEnvironment) env;
    conf.addStringMap(regionEnv.getRegion().getTableDesc().getConfiguration());
    zk = regionEnv.getRegionServerServices().getZooKeeper();
    compatibleEarlyTermination = conf.getBoolean(AccessControlConstants.CF_ATTRIBUTE_EARLY_OUT,
      AccessControlConstants.DEFAULT_ATTRIBUTE_EARLY_OUT);
  }

  // set the user-provider.
  this.userProvider = UserProvider.instantiate(env.getConfiguration());

  // If zk is null or IOException while obtaining auth manager,
  // throw RuntimeException so that the coprocessor is unloaded.
  if (zk != null) {
    try {
      this.authManager = TableAuthManager.get(zk, env.getConfiguration());
    } catch (IOException ioe) {
      throw new RuntimeException("Error obtaining TableAuthManager", ioe);
    }
  } else {
    throw new RuntimeException("Error obtaining TableAuthManager, zk found null.");
  }

  tableAcls = new MapMaker().weakValues().makeMap();
}
项目:ditb    文件:HStore.java   
/**
 * {@inheritDoc}
 */
@Override public void onConfigurationChange(Configuration conf) {
  this.conf = new CompoundConfiguration().add(conf).addWritableMap(family.getValues());
  this.storeEngine.compactionPolicy.setConf(conf);
  this.offPeakHours = OffPeakHours.getInstance(conf);
}
项目:pbase    文件:AccessController.java   
@Override
public void start(CoprocessorEnvironment env) throws IOException {
  CompoundConfiguration conf = new CompoundConfiguration();
  conf.add(env.getConfiguration());

  shouldCheckExecPermission = conf.getBoolean(AccessControlConstants.EXEC_PERMISSION_CHECKS_KEY,
    AccessControlConstants.DEFAULT_EXEC_PERMISSION_CHECKS);

  cellFeaturesEnabled = HFile.getFormatVersion(conf) >= HFile.MIN_FORMAT_VERSION_WITH_TAGS;
  if (!cellFeaturesEnabled) {
    LOG.info("A minimum HFile version of " + HFile.MIN_FORMAT_VERSION_WITH_TAGS
        + " is required to persist cell ACLs. Consider setting " + HFile.FORMAT_VERSION_KEY
        + " accordingly.");
  }

  ZooKeeperWatcher zk = null;
  if (env instanceof MasterCoprocessorEnvironment) {
    // if running on HMaster
    MasterCoprocessorEnvironment mEnv = (MasterCoprocessorEnvironment) env;
    zk = mEnv.getMasterServices().getZooKeeper();
  } else if (env instanceof RegionServerCoprocessorEnvironment) {
    RegionServerCoprocessorEnvironment rsEnv = (RegionServerCoprocessorEnvironment) env;
    zk = rsEnv.getRegionServerServices().getZooKeeper();
  } else if (env instanceof RegionCoprocessorEnvironment) {
    // if running at region
    regionEnv = (RegionCoprocessorEnvironment) env;
    conf.addStringMap(regionEnv.getRegion().getTableDesc().getConfiguration());
    zk = regionEnv.getRegionServerServices().getZooKeeper();
    compatibleEarlyTermination = conf.getBoolean(AccessControlConstants.CF_ATTRIBUTE_EARLY_OUT,
      AccessControlConstants.DEFAULT_ATTRIBUTE_EARLY_OUT);
  }

  // set the user-provider.
  this.userProvider = UserProvider.instantiate(env.getConfiguration());

  // set up the list of users with superuser privilege
  User user = userProvider.getCurrent();
  superusers = Lists.asList(user.getShortName(),
    conf.getStrings(AccessControlLists.SUPERUSER_CONF_KEY, new String[0]));

  // If zk is null or IOException while obtaining auth manager,
  // throw RuntimeException so that the coprocessor is unloaded.
  if (zk != null) {
    try {
      this.authManager = TableAuthManager.get(zk, env.getConfiguration());
    } catch (IOException ioe) {
      throw new RuntimeException("Error obtaining TableAuthManager", ioe);
    }
  } else {
    throw new RuntimeException("Error obtaining TableAuthManager, zk found null.");
  }

  tableAcls = new MapMaker().weakValues().makeMap();
}
项目:HIndex    文件:AccessController.java   
public void start(CoprocessorEnvironment env) throws IOException {
  CompoundConfiguration conf = new CompoundConfiguration();
  conf.add(env.getConfiguration());

  shouldCheckExecPermission = conf.getBoolean(AccessControlConstants.EXEC_PERMISSION_CHECKS_KEY,
    AccessControlConstants.DEFAULT_EXEC_PERMISSION_CHECKS);

  cellFeaturesEnabled = HFile.getFormatVersion(conf) >= HFile.MIN_FORMAT_VERSION_WITH_TAGS;
  if (!cellFeaturesEnabled) {
    LOG.info("A minimum HFile version of " + HFile.MIN_FORMAT_VERSION_WITH_TAGS
        + " is required to persist cell ACLs. Consider setting " + HFile.FORMAT_VERSION_KEY
        + " accordingly.");
  }

  ZooKeeperWatcher zk = null;
  if (env instanceof MasterCoprocessorEnvironment) {
    // if running on HMaster
    MasterCoprocessorEnvironment mEnv = (MasterCoprocessorEnvironment) env;
    zk = mEnv.getMasterServices().getZooKeeper();
  } else if (env instanceof RegionServerCoprocessorEnvironment) {      
    RegionServerCoprocessorEnvironment rsEnv = (RegionServerCoprocessorEnvironment) env;
    zk = rsEnv.getRegionServerServices().getZooKeeper();      
  } else if (env instanceof RegionCoprocessorEnvironment) {
    // if running at region
    regionEnv = (RegionCoprocessorEnvironment) env;
    conf.addStringMap(regionEnv.getRegion().getTableDesc().getConfiguration());
    zk = regionEnv.getRegionServerServices().getZooKeeper();
    compatibleEarlyTermination = conf.getBoolean(AccessControlConstants.CF_ATTRIBUTE_EARLY_OUT,
      AccessControlConstants.DEFAULT_ATTRIBUTE_EARLY_OUT);
  }

  // set the user-provider.
  this.userProvider = UserProvider.instantiate(env.getConfiguration());

  // If zk is null or IOException while obtaining auth manager,
  // throw RuntimeException so that the coprocessor is unloaded.
  if (zk != null) {
    try {
      this.authManager = TableAuthManager.get(zk, env.getConfiguration());
    } catch (IOException ioe) {
      throw new RuntimeException("Error obtaining TableAuthManager", ioe);
    }
  } else {
    throw new RuntimeException("Error obtaining TableAuthManager, zk found null.");
  }
}
项目:hbase    文件:AccessController.java   
@Override
public void start(CoprocessorEnvironment env) throws IOException {
  CompoundConfiguration conf = new CompoundConfiguration();
  conf.add(env.getConfiguration());

  authorizationEnabled = AccessChecker.isAuthorizationSupported(conf);
  if (!authorizationEnabled) {
    LOG.warn("AccessController has been loaded with authorization checks DISABLED!");
  }

  shouldCheckExecPermission = conf.getBoolean(AccessControlConstants.EXEC_PERMISSION_CHECKS_KEY,
    AccessControlConstants.DEFAULT_EXEC_PERMISSION_CHECKS);

  cellFeaturesEnabled = (HFile.getFormatVersion(conf) >= HFile.MIN_FORMAT_VERSION_WITH_TAGS);
  if (!cellFeaturesEnabled) {
    LOG.info("A minimum HFile version of " + HFile.MIN_FORMAT_VERSION_WITH_TAGS
        + " is required to persist cell ACLs. Consider setting " + HFile.FORMAT_VERSION_KEY
        + " accordingly.");
  }

  ZKWatcher zk = null;
  if (env instanceof MasterCoprocessorEnvironment) {
    // if running on HMaster
    MasterCoprocessorEnvironment mEnv = (MasterCoprocessorEnvironment)env;
    if (mEnv instanceof HasMasterServices) {
      zk = ((HasMasterServices)mEnv).getMasterServices().getZooKeeper();
    }
  } else if (env instanceof RegionServerCoprocessorEnvironment) {
    RegionServerCoprocessorEnvironment rsEnv = (RegionServerCoprocessorEnvironment)env;
    if (rsEnv instanceof HasRegionServerServices) {
      zk = ((HasRegionServerServices)rsEnv).getRegionServerServices().getZooKeeper();
    }
  } else if (env instanceof RegionCoprocessorEnvironment) {
    // if running at region
    regionEnv = (RegionCoprocessorEnvironment) env;
    conf.addBytesMap(regionEnv.getRegion().getTableDescriptor().getValues());
    compatibleEarlyTermination = conf.getBoolean(AccessControlConstants.CF_ATTRIBUTE_EARLY_OUT,
        AccessControlConstants.DEFAULT_ATTRIBUTE_EARLY_OUT);
    if (regionEnv instanceof HasRegionServerServices) {
      zk = ((HasRegionServerServices)regionEnv).getRegionServerServices().getZooKeeper();
    }
  }

  // set the user-provider.
  this.userProvider = UserProvider.instantiate(env.getConfiguration());
  accessChecker = new AccessChecker(env.getConfiguration(), zk);
  tableAcls = new MapMaker().weakValues().makeMap();
}
项目:PyroDB    文件:AccessController.java   
public void start(CoprocessorEnvironment env) throws IOException {
  CompoundConfiguration conf = new CompoundConfiguration();
  conf.add(env.getConfiguration());

  shouldCheckExecPermission = conf.getBoolean(AccessControlConstants.EXEC_PERMISSION_CHECKS_KEY,
    AccessControlConstants.DEFAULT_EXEC_PERMISSION_CHECKS);

  cellFeaturesEnabled = HFile.getFormatVersion(conf) >= HFile.MIN_FORMAT_VERSION_WITH_TAGS;
  if (!cellFeaturesEnabled) {
    LOG.info("A minimum HFile version of " + HFile.MIN_FORMAT_VERSION_WITH_TAGS
        + " is required to persist cell ACLs. Consider setting " + HFile.FORMAT_VERSION_KEY
        + " accordingly.");
  }

  ZooKeeperWatcher zk = null;
  if (env instanceof MasterCoprocessorEnvironment) {
    // if running on HMaster
    MasterCoprocessorEnvironment mEnv = (MasterCoprocessorEnvironment) env;
    zk = mEnv.getMasterServices().getZooKeeper();
  } else if (env instanceof RegionServerCoprocessorEnvironment) {      
    RegionServerCoprocessorEnvironment rsEnv = (RegionServerCoprocessorEnvironment) env;
    zk = rsEnv.getRegionServerServices().getZooKeeper();      
  } else if (env instanceof RegionCoprocessorEnvironment) {
    // if running at region
    regionEnv = (RegionCoprocessorEnvironment) env;
    conf.addStringMap(regionEnv.getRegion().getTableDesc().getConfiguration());
    zk = regionEnv.getRegionServerServices().getZooKeeper();
    compatibleEarlyTermination = conf.getBoolean(AccessControlConstants.CF_ATTRIBUTE_EARLY_OUT,
      AccessControlConstants.DEFAULT_ATTRIBUTE_EARLY_OUT);
  }

  // set the user-provider.
  this.userProvider = UserProvider.instantiate(env.getConfiguration());

  // If zk is null or IOException while obtaining auth manager,
  // throw RuntimeException so that the coprocessor is unloaded.
  if (zk != null) {
    try {
      this.authManager = TableAuthManager.get(zk, env.getConfiguration());
    } catch (IOException ioe) {
      throw new RuntimeException("Error obtaining TableAuthManager", ioe);
    }
  } else {
    throw new RuntimeException("Error obtaining TableAuthManager, zk found null.");
  }
}
项目:c5    文件:HStore.java   
/**
 * Constructor
 * @param region
 * @param family HColumnDescriptor for this column
 * @param confParam configuration object
 * failed.  Can be null.
 * @throws IOException
 */
protected HStore(final HRegion region, final HColumnDescriptor family,
    final Configuration confParam) throws IOException {

  HRegionInfo info = region.getRegionInfo();
  this.fs = region.getRegionFileSystem();

  // Assemble the store's home directory and Ensure it exists.
  fs.createStoreDir(family.getNameAsString());
  this.region = region;
  this.family = family;
  // 'conf' renamed to 'confParam' b/c we use this.conf in the constructor
  // CompoundConfiguration will look for keys in reverse order of addition, so we'd
  // add global config first, then table and cf overrides, then cf metadata.
  this.conf = new CompoundConfiguration()
    .add(confParam)
    .addStringMap(region.getTableDesc().getConfiguration())
    .addStringMap(family.getConfiguration())
    .addWritableMap(family.getValues());
  this.blocksize = family.getBlocksize();

  this.dataBlockEncoder =
      new HFileDataBlockEncoderImpl(family.getDataBlockEncoding());

  this.comparator = info.getComparator();
  // used by ScanQueryMatcher
  long timeToPurgeDeletes =
      Math.max(conf.getLong("hbase.hstore.time.to.purge.deletes", 0), 0);
  LOG.trace("Time to purge deletes set to " + timeToPurgeDeletes +
      "ms in store " + this);
  // Get TTL
  long ttl = determineTTLFromFamily(family);
  // Why not just pass a HColumnDescriptor in here altogether?  Even if have
  // to clone it?
  scanInfo = new ScanInfo(family, ttl, timeToPurgeDeletes, this.comparator);
  this.memstore = new MemStore(conf, this.comparator);
  this.offPeakHours = OffPeakHours.getInstance(conf);

  // Setting up cache configuration for this family
  this.cacheConf = new CacheConfig(conf, family);

  this.verifyBulkLoads = conf.getBoolean("hbase.hstore.bulkload.verify", false);

  this.blockingFileCount =
      conf.getInt(BLOCKING_STOREFILES_KEY, DEFAULT_BLOCKING_STOREFILE_COUNT);
  this.compactionCheckMultiplier = conf.getInt(
      COMPACTCHECKER_INTERVAL_MULTIPLIER_KEY, DEFAULT_COMPACTCHECKER_INTERVAL_MULTIPLIER);
  if (this.compactionCheckMultiplier <= 0) {
    LOG.error("Compaction check period multiplier must be positive, setting default: "
        + DEFAULT_COMPACTCHECKER_INTERVAL_MULTIPLIER);
    this.compactionCheckMultiplier = DEFAULT_COMPACTCHECKER_INTERVAL_MULTIPLIER;
  }

  if (HStore.closeCheckInterval == 0) {
    HStore.closeCheckInterval = conf.getInt(
        "hbase.hstore.close.check.interval", 10*1000*1000 /* 10 MB */);
  }

  this.storeEngine = StoreEngine.create(this, this.conf, this.comparator);
  this.storeEngine.getStoreFileManager().loadFiles(loadStoreFiles());

  // Initialize checksum type from name. The names are CRC32, CRC32C, etc.
  this.checksumType = getChecksumType(conf);
  // initilize bytes per checksum
  this.bytesPerChecksum = getBytesPerChecksum(conf);
  flushRetriesNumber = conf.getInt(
      "hbase.hstore.flush.retries.number", DEFAULT_FLUSH_RETRIES_NUMBER);
  pauseTime = conf.getInt(HConstants.HBASE_SERVER_PAUSE, HConstants.DEFAULT_HBASE_SERVER_PAUSE);
  if (flushRetriesNumber <= 0) {
    throw new IllegalArgumentException(
        "hbase.hstore.flush.retries.number must be > 0, not "
            + flushRetriesNumber);
  }
}