Java 类org.apache.hadoop.hbase.protobuf.generated.WALProtos.WALHeader 实例源码

项目:ditb    文件:SecureProtobufLogWriter.java   
@Override
protected WALHeader buildWALHeader(Configuration conf, WALHeader.Builder builder)
    throws IOException {
  builder.setWriterClsName(SecureProtobufLogWriter.class.getSimpleName());
  if (conf.getBoolean(HConstants.ENABLE_WAL_ENCRYPTION, false)) {
    EncryptionTest.testKeyProvider(conf);
    EncryptionTest.testCipherProvider(conf);

    // Get an instance of our cipher
    final String cipherName =
        conf.get(HConstants.CRYPTO_WAL_ALGORITHM_CONF_KEY, HConstants.CIPHER_AES);
    Cipher cipher = Encryption.getCipher(conf, cipherName);
    if (cipher == null) {
      throw new RuntimeException("Cipher '" + cipherName + "' is not available");
    }

    // Generate an encryption key for this WAL
    SecureRandom rng = new SecureRandom();
    byte[] keyBytes = new byte[cipher.getKeyLength()];
    rng.nextBytes(keyBytes);
    Key key = new SecretKeySpec(keyBytes, cipher.getName());
    builder.setEncryptionKey(ByteStringer.wrap(EncryptionUtil.wrapKey(conf,
        conf.get(HConstants.CRYPTO_WAL_KEY_NAME_CONF_KEY,
            conf.get(HConstants.CRYPTO_MASTERKEY_NAME_CONF_KEY,
                User.getCurrent().getShortName())),
        key)));

    // Set up the encryptor
    encryptor = cipher.getEncryptor();
    encryptor.setKey(key);

    if (LOG.isTraceEnabled()) {
      LOG.trace("Initialized secure protobuf WAL: cipher=" + cipher.getName());
    }
  }
  builder.setCellCodecClsName(SecureWALCellCodec.class.getName());
  return super.buildWALHeader(conf, builder);
}
项目:ditb    文件:ProtobufLogWriter.java   
protected WALHeader buildWALHeader(Configuration conf, WALHeader.Builder builder)
    throws IOException {
  if (!builder.hasWriterClsName()) {
    builder.setWriterClsName(ProtobufLogWriter.class.getSimpleName());
  }
  if (!builder.hasCellCodecClsName()) {
    builder.setCellCodecClsName(WALCellCodec.getWALCellCodecClass(conf));
  }
  return builder.build();
}
项目:pbase    文件:SecureProtobufLogWriter.java   
@Override
protected WALHeader buildWALHeader(Configuration conf, WALHeader.Builder builder)
    throws IOException {
  builder.setWriterClsName(SecureProtobufLogWriter.class.getSimpleName());
  if (conf.getBoolean(HConstants.ENABLE_WAL_ENCRYPTION, false)) {
    EncryptionTest.testKeyProvider(conf);
    EncryptionTest.testCipherProvider(conf);

    // Get an instance of our cipher
    final String cipherName = conf.get(HConstants.CRYPTO_WAL_ALGORITHM_CONF_KEY, DEFAULT_CIPHER);
    Cipher cipher = Encryption.getCipher(conf, cipherName);
    if (cipher == null) {
      throw new RuntimeException("Cipher '" + cipherName + "' is not available");
    }

    // Generate an encryption key for this WAL
    SecureRandom rng = new SecureRandom();
    byte[] keyBytes = new byte[cipher.getKeyLength()];
    rng.nextBytes(keyBytes);
    Key key = new SecretKeySpec(keyBytes, cipher.getName());
    builder.setEncryptionKey(ByteStringer.wrap(EncryptionUtil.wrapKey(conf,
        conf.get(HConstants.CRYPTO_WAL_KEY_NAME_CONF_KEY,
            conf.get(HConstants.CRYPTO_MASTERKEY_NAME_CONF_KEY,
                User.getCurrent().getShortName())),
        key)));

    // Set up the encryptor
    encryptor = cipher.getEncryptor();
    encryptor.setKey(key);

    if (LOG.isTraceEnabled()) {
      LOG.trace("Initialized secure protobuf WAL: cipher=" + cipher.getName());
    }
  }
  builder.setCellCodecClsName(SecureWALCellCodec.class.getName());
  return super.buildWALHeader(conf, builder);
}
项目:pbase    文件:ProtobufLogWriter.java   
protected WALHeader buildWALHeader(Configuration conf, WALHeader.Builder builder)
    throws IOException {
  if (!builder.hasWriterClsName()) {
    builder.setWriterClsName(ProtobufLogWriter.class.getSimpleName());
  }
  if (!builder.hasCellCodecClsName()) {
    builder.setCellCodecClsName(WALCellCodec.getWALCellCodecClass(conf));
  }
  return builder.build();
}
项目:HIndex    文件:SecureProtobufLogWriter.java   
@Override
protected WALHeader buildWALHeader(WALHeader.Builder builder) throws IOException {
  if (conf.getBoolean(HConstants.ENABLE_WAL_ENCRYPTION, false)) {
    // Get an instance of our cipher
    Cipher cipher = Encryption.getCipher(conf,
      conf.get(HConstants.CRYPTO_WAL_ALGORITHM_CONF_KEY, DEFAULT_CIPHER));
    if (cipher == null) {
      throw new RuntimeException("Cipher '" + cipher + "' is not available");
    }

    // Generate an encryption key for this WAL
    SecureRandom rng = new SecureRandom();
    byte[] keyBytes = new byte[cipher.getKeyLength()];
    rng.nextBytes(keyBytes);
    Key key = new SecretKeySpec(keyBytes, cipher.getName());
    builder.setEncryptionKey(HBaseZeroCopyByteString.wrap(EncryptionUtil.wrapKey(conf,
        conf.get(HConstants.CRYPTO_WAL_KEY_NAME_CONF_KEY,
            conf.get(HConstants.CRYPTO_MASTERKEY_NAME_CONF_KEY,
                User.getCurrent().getShortName())),
        key)));

    // Set up the encryptor
    encryptor = cipher.getEncryptor();
    encryptor.setKey(key);

    if (LOG.isTraceEnabled()) {
      LOG.trace("Initialized secure protobuf WAL: cipher=" + cipher.getName());
    }
  }

  return super.buildWALHeader(builder);
}
项目:PyroDB    文件:SecureProtobufLogWriter.java   
@Override
protected WALHeader buildWALHeader(WALHeader.Builder builder) throws IOException {
  if (conf.getBoolean(HConstants.ENABLE_WAL_ENCRYPTION, false)) {
    // Get an instance of our cipher
    Cipher cipher = Encryption.getCipher(conf,
      conf.get(HConstants.CRYPTO_WAL_ALGORITHM_CONF_KEY, DEFAULT_CIPHER));
    if (cipher == null) {
      throw new RuntimeException("Cipher '" + cipher + "' is not available");
    }

    // Generate an encryption key for this WAL
    SecureRandom rng = new SecureRandom();
    byte[] keyBytes = new byte[cipher.getKeyLength()];
    rng.nextBytes(keyBytes);
    Key key = new SecretKeySpec(keyBytes, cipher.getName());
    builder.setEncryptionKey(HBaseZeroCopyByteString.wrap(EncryptionUtil.wrapKey(conf,
        conf.get(HConstants.CRYPTO_WAL_KEY_NAME_CONF_KEY,
            conf.get(HConstants.CRYPTO_MASTERKEY_NAME_CONF_KEY,
                User.getCurrent().getShortName())),
        key)));

    // Set up the encryptor
    encryptor = cipher.getEncryptor();
    encryptor.setKey(key);

    if (LOG.isTraceEnabled()) {
      LOG.trace("Initialized secure protobuf WAL: cipher=" + cipher.getName());
    }
  }

  return super.buildWALHeader(builder);
}
项目:HIndex    文件:ProtobufLogWriter.java   
protected WALHeader buildWALHeader(WALHeader.Builder builder) throws IOException {
  return builder.build();
}
项目:PyroDB    文件:ProtobufLogWriter.java   
protected WALHeader buildWALHeader(WALHeader.Builder builder) throws IOException {
  return builder.build();
}