org.apache.hadoop.fs.FsServerDefaults Java Examples

The following examples show how to use org.apache.hadoop.fs.FsServerDefaults. 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: TestFileCreation.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * Test that server default values can be retrieved on the client side
 */
@Test
public void testServerDefaults() throws IOException {
  Configuration conf = new HdfsConfiguration();
  conf.setLong(DFS_BLOCK_SIZE_KEY, DFS_BLOCK_SIZE_DEFAULT);
  conf.setInt(DFS_BYTES_PER_CHECKSUM_KEY, DFS_BYTES_PER_CHECKSUM_DEFAULT);
  conf.setInt(DFS_CLIENT_WRITE_PACKET_SIZE_KEY, DFS_CLIENT_WRITE_PACKET_SIZE_DEFAULT);
  conf.setInt(DFS_REPLICATION_KEY, DFS_REPLICATION_DEFAULT + 1);
  conf.setInt(IO_FILE_BUFFER_SIZE_KEY, IO_FILE_BUFFER_SIZE_DEFAULT);
  MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf)
                   .numDataNodes(DFSConfigKeys.DFS_REPLICATION_DEFAULT + 1)
                   .build();
  cluster.waitActive();
  FileSystem fs = cluster.getFileSystem();
  try {
    FsServerDefaults serverDefaults = fs.getServerDefaults();
    assertEquals(DFS_BLOCK_SIZE_DEFAULT, serverDefaults.getBlockSize());
    assertEquals(DFS_BYTES_PER_CHECKSUM_DEFAULT, serverDefaults.getBytesPerChecksum());
    assertEquals(DFS_CLIENT_WRITE_PACKET_SIZE_DEFAULT, serverDefaults.getWritePacketSize());
    assertEquals(DFS_REPLICATION_DEFAULT + 1, serverDefaults.getReplication());
    assertEquals(IO_FILE_BUFFER_SIZE_DEFAULT, serverDefaults.getFileBufferSize());
  } finally {
    fs.close();
    cluster.shutdown();
  }
}
 
Example #2
Source File: TestFileCreation.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
 * Test that server default values can be retrieved on the client side
 */
@Test
public void testServerDefaults() throws IOException {
  Configuration conf = new HdfsConfiguration();
  conf.setLong(DFS_BLOCK_SIZE_KEY, DFS_BLOCK_SIZE_DEFAULT);
  conf.setInt(DFS_BYTES_PER_CHECKSUM_KEY, DFS_BYTES_PER_CHECKSUM_DEFAULT);
  conf.setInt(DFS_CLIENT_WRITE_PACKET_SIZE_KEY, DFS_CLIENT_WRITE_PACKET_SIZE_DEFAULT);
  conf.setInt(DFS_REPLICATION_KEY, DFS_REPLICATION_DEFAULT + 1);
  conf.setInt(IO_FILE_BUFFER_SIZE_KEY, IO_FILE_BUFFER_SIZE_DEFAULT);
  MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf)
                   .numDataNodes(DFSConfigKeys.DFS_REPLICATION_DEFAULT + 1)
                   .build();
  cluster.waitActive();
  FileSystem fs = cluster.getFileSystem();
  try {
    FsServerDefaults serverDefaults = fs.getServerDefaults();
    assertEquals(DFS_BLOCK_SIZE_DEFAULT, serverDefaults.getBlockSize());
    assertEquals(DFS_BYTES_PER_CHECKSUM_DEFAULT, serverDefaults.getBytesPerChecksum());
    assertEquals(DFS_CLIENT_WRITE_PACKET_SIZE_DEFAULT, serverDefaults.getWritePacketSize());
    assertEquals(DFS_REPLICATION_DEFAULT + 1, serverDefaults.getReplication());
    assertEquals(IO_FILE_BUFFER_SIZE_DEFAULT, serverDefaults.getFileBufferSize());
  } finally {
    fs.close();
    cluster.shutdown();
  }
}
 
Example #3
Source File: FtpConfigKeys.java    From big-c with Apache License 2.0 5 votes vote down vote up
protected static FsServerDefaults getServerDefaults() throws IOException {
  return new FsServerDefaults(
      BLOCK_SIZE_DEFAULT,
      BYTES_PER_CHECKSUM_DEFAULT,
      CLIENT_WRITE_PACKET_SIZE_DEFAULT,
      REPLICATION_DEFAULT,
      STREAM_BUFFER_SIZE_DEFAULT,
      ENCRYPT_DATA_TRANSFER_DEFAULT,
      FS_TRASH_INTERVAL_DEFAULT,
      CHECKSUM_TYPE_DEFAULT);
}
 
Example #4
Source File: PBHelper.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public static FsServerDefaults convert(FsServerDefaultsProto fs) {
  if (fs == null) return null;
  return new FsServerDefaults(
      fs.getBlockSize(), fs.getBytesPerChecksum(), 
      fs.getWritePacketSize(), (short) fs.getReplication(),
      fs.getFileBufferSize(),
      fs.getEncryptDataTransfer(),
      fs.getTrashInterval(),
      PBHelper.convert(fs.getChecksumType()));
}
 
Example #5
Source File: NameNodeConnector.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public NameNodeConnector(String name, URI nameNodeUri, Path idPath,
                         List<Path> targetPaths, Configuration conf,
                         int maxNotChangedIterations)
    throws IOException {
  this.nameNodeUri = nameNodeUri;
  this.idPath = idPath;
  this.targetPaths = targetPaths == null || targetPaths.isEmpty() ? Arrays
      .asList(new Path("/")) : targetPaths;
  this.maxNotChangedIterations = maxNotChangedIterations;

  this.namenode = NameNodeProxies.createProxy(conf, nameNodeUri,
      NamenodeProtocol.class).getProxy();
  this.client = NameNodeProxies.createProxy(conf, nameNodeUri,
      ClientProtocol.class, fallbackToSimpleAuth).getProxy();
  this.fs = (DistributedFileSystem)FileSystem.get(nameNodeUri, conf);

  final NamespaceInfo namespaceinfo = namenode.versionRequest();
  this.blockpoolID = namespaceinfo.getBlockPoolID();

  final FsServerDefaults defaults = fs.getServerDefaults(new Path("/"));
  this.keyManager = new KeyManager(blockpoolID, namenode,
      defaults.getEncryptDataTransfer(), conf);
  // if it is for test, we do not create the id file
  out = checkAndMarkRunning();
  if (out == null) {
    // Exit if there is another one running.
    throw new IOException("Another " + name + " is running.");
  }
}
 
Example #6
Source File: ClientNamenodeProtocolTranslatorPB.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public FsServerDefaults getServerDefaults() throws IOException {
  GetServerDefaultsRequestProto req = VOID_GET_SERVER_DEFAULT_REQUEST;
  try {
    return PBHelper
        .convert(rpcProxy.getServerDefaults(null, req).getServerDefaults());
  } catch (ServiceException e) {
    throw ProtobufHelper.getRemoteException(e);
  }
}
 
Example #7
Source File: ClientNamenodeProtocolServerSideTranslatorPB.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override
public GetServerDefaultsResponseProto getServerDefaults(
    RpcController controller, GetServerDefaultsRequestProto req)
    throws ServiceException {
  try {
    FsServerDefaults result = server.getServerDefaults();
    return GetServerDefaultsResponseProto.newBuilder()
        .setServerDefaults(PBHelper.convert(result))
        .build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
 
Example #8
Source File: LocalConfigKeys.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public static FsServerDefaults getServerDefaults() throws IOException {
  return new FsServerDefaults(
      BLOCK_SIZE_DEFAULT,
      BYTES_PER_CHECKSUM_DEFAULT,
      CLIENT_WRITE_PACKET_SIZE_DEFAULT,
      REPLICATION_DEFAULT,
      STREAM_BUFFER_SIZE_DEFAULT,
      ENCRYPT_DATA_TRANSFER_DEFAULT,
      FS_TRASH_INTERVAL_DEFAULT,
      CHECKSUM_TYPE_DEFAULT);
}
 
Example #9
Source File: DFSClient.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/**
 * Get server default values for a number of configuration params.
 * @see ClientProtocol#getServerDefaults()
 */
public FsServerDefaults getServerDefaults() throws IOException {
  long now = Time.monotonicNow();
  if ((serverDefaults == null) ||
      (now - serverDefaultsLastUpdate > SERVER_DEFAULTS_VALIDITY_PERIOD)) {
    serverDefaults = namenode.getServerDefaults();
    serverDefaultsLastUpdate = now;
  }
  assert serverDefaults != null;
  return serverDefaults;
}
 
Example #10
Source File: PBHelper.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public static FsServerDefaultsProto convert(FsServerDefaults fs) {
  if (fs == null) return null;
  return FsServerDefaultsProto.newBuilder().
    setBlockSize(fs.getBlockSize()).
    setBytesPerChecksum(fs.getBytesPerChecksum()).
    setWritePacketSize(fs.getWritePacketSize())
    .setReplication(fs.getReplication())
    .setFileBufferSize(fs.getFileBufferSize())
    .setEncryptDataTransfer(fs.getEncryptDataTransfer())
    .setTrashInterval(fs.getTrashInterval())
    .setChecksumType(PBHelper.convert(fs.getChecksumType()))
    .build();
}
 
Example #11
Source File: GoogleHadoopFSIntegrationTest.java    From hadoop-connectors with Apache License 2.0 5 votes vote down vote up
@Test
public void getServerDefaults_shouldReturnSpecifiedConfiguration() throws Exception {
  Configuration config = GoogleHadoopFileSystemIntegrationHelper.getTestConfig();
  config.setLong(BLOCK_SIZE.getKey(), 1);
  GoogleHadoopFS ghfs = new GoogleHadoopFS(initUri, config);

  FsServerDefaults defaults = ghfs.getServerDefaults();

  assertThat(defaults.getBlockSize()).isEqualTo(1);
}
 
Example #12
Source File: TestDistributedFileSystem.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Test(timeout=60000)
public void testGetServerDefaults() throws IOException {
  Configuration conf = new HdfsConfiguration();
  MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).build();
  try {
    cluster.waitActive();
    DistributedFileSystem dfs = cluster.getFileSystem();
    FsServerDefaults fsServerDefaults = dfs.getServerDefaults();
    Assert.assertNotNull(fsServerDefaults);
  } finally {
    cluster.shutdown();
  }
}
 
Example #13
Source File: HdfsFileWriter.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
private static final OutputStream getOutputStream(FileSystem fileSystem, Path path) throws IOException {
  Configuration conf = fileSystem.getConf();
  FsServerDefaults fsDefaults = fileSystem.getServerDefaults(path);
  short replication = fileSystem.getDefaultReplication(path);
  EnumSet<CreateFlag> flags = EnumSet.of(CreateFlag.CREATE);
  if (Boolean.getBoolean(HDFS_SYNC_BLOCK)) {
    flags.add(CreateFlag.SYNC_BLOCK);
  }
  return fileSystem.create(path, FsPermission.getDefault()
      .applyUMask(FsPermission.getUMask(conf)), flags, fsDefaults
      .getFileBufferSize(), replication, fsDefaults
      .getBlockSize(), null);
}
 
Example #14
Source File: FtpConfigKeys.java    From hadoop with Apache License 2.0 5 votes vote down vote up
protected static FsServerDefaults getServerDefaults() throws IOException {
  return new FsServerDefaults(
      BLOCK_SIZE_DEFAULT,
      BYTES_PER_CHECKSUM_DEFAULT,
      CLIENT_WRITE_PACKET_SIZE_DEFAULT,
      REPLICATION_DEFAULT,
      STREAM_BUFFER_SIZE_DEFAULT,
      ENCRYPT_DATA_TRANSFER_DEFAULT,
      FS_TRASH_INTERVAL_DEFAULT,
      CHECKSUM_TYPE_DEFAULT);
}
 
Example #15
Source File: HadoopFileSystemWrapper.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
@Override
@Deprecated
public FsServerDefaults getServerDefaults() throws IOException {
  try {
    return underlyingFs.getServerDefaults();
  } catch(FSError e) {
    throw propagateFSError(e);
  }
}
 
Example #16
Source File: HadoopFileSystemWrapper.java    From dremio-oss with Apache License 2.0 5 votes vote down vote up
@Override
public FsServerDefaults getServerDefaults(Path p) throws IOException {
  try {
    return underlyingFs.getServerDefaults(p);
  } catch(FSError e) {
    throw propagateFSError(e);
  }
}
 
Example #17
Source File: DFSClient.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Get server default values for a number of configuration params.
 * @see ClientProtocol#getServerDefaults()
 */
public FsServerDefaults getServerDefaults() throws IOException {
  long now = Time.monotonicNow();
  if ((serverDefaults == null) ||
      (now - serverDefaultsLastUpdate > SERVER_DEFAULTS_VALIDITY_PERIOD)) {
    serverDefaults = namenode.getServerDefaults();
    serverDefaultsLastUpdate = now;
  }
  assert serverDefaults != null;
  return serverDefaults;
}
 
Example #18
Source File: NameNodeConnector.java    From big-c with Apache License 2.0 5 votes vote down vote up
public NameNodeConnector(String name, URI nameNodeUri, Path idPath,
                         List<Path> targetPaths, Configuration conf,
                         int maxNotChangedIterations)
    throws IOException {
  this.nameNodeUri = nameNodeUri;
  this.idPath = idPath;
  this.targetPaths = targetPaths == null || targetPaths.isEmpty() ? Arrays
      .asList(new Path("/")) : targetPaths;
  this.maxNotChangedIterations = maxNotChangedIterations;

  this.namenode = NameNodeProxies.createProxy(conf, nameNodeUri,
      NamenodeProtocol.class).getProxy();
  this.client = NameNodeProxies.createProxy(conf, nameNodeUri,
      ClientProtocol.class, fallbackToSimpleAuth).getProxy();
  this.fs = (DistributedFileSystem)FileSystem.get(nameNodeUri, conf);

  final NamespaceInfo namespaceinfo = namenode.versionRequest();
  this.blockpoolID = namespaceinfo.getBlockPoolID();

  final FsServerDefaults defaults = fs.getServerDefaults(new Path("/"));
  this.keyManager = new KeyManager(blockpoolID, namenode,
      defaults.getEncryptDataTransfer(), conf);
  // if it is for test, we do not create the id file
  out = checkAndMarkRunning();
  if (out == null) {
    // Exit if there is another one running.
    throw new IOException("Another " + name + " is running.");
  }
}
 
Example #19
Source File: PBHelper.java    From big-c with Apache License 2.0 5 votes vote down vote up
public static FsServerDefaults convert(FsServerDefaultsProto fs) {
  if (fs == null) return null;
  return new FsServerDefaults(
      fs.getBlockSize(), fs.getBytesPerChecksum(), 
      fs.getWritePacketSize(), (short) fs.getReplication(),
      fs.getFileBufferSize(),
      fs.getEncryptDataTransfer(),
      fs.getTrashInterval(),
      PBHelper.convert(fs.getChecksumType()));
}
 
Example #20
Source File: PBHelper.java    From big-c with Apache License 2.0 5 votes vote down vote up
public static FsServerDefaultsProto convert(FsServerDefaults fs) {
  if (fs == null) return null;
  return FsServerDefaultsProto.newBuilder().
    setBlockSize(fs.getBlockSize()).
    setBytesPerChecksum(fs.getBytesPerChecksum()).
    setWritePacketSize(fs.getWritePacketSize())
    .setReplication(fs.getReplication())
    .setFileBufferSize(fs.getFileBufferSize())
    .setEncryptDataTransfer(fs.getEncryptDataTransfer())
    .setTrashInterval(fs.getTrashInterval())
    .setChecksumType(PBHelper.convert(fs.getChecksumType()))
    .build();
}
 
Example #21
Source File: ClientNamenodeProtocolServerSideTranslatorPB.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public GetServerDefaultsResponseProto getServerDefaults(
    RpcController controller, GetServerDefaultsRequestProto req)
    throws ServiceException {
  try {
    FsServerDefaults result = server.getServerDefaults();
    return GetServerDefaultsResponseProto.newBuilder()
        .setServerDefaults(PBHelper.convert(result))
        .build();
  } catch (IOException e) {
    throw new ServiceException(e);
  }
}
 
Example #22
Source File: ClientNamenodeProtocolTranslatorPB.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public FsServerDefaults getServerDefaults() throws IOException {
  GetServerDefaultsRequestProto req = VOID_GET_SERVER_DEFAULT_REQUEST;
  try {
    return PBHelper
        .convert(rpcProxy.getServerDefaults(null, req).getServerDefaults());
  } catch (ServiceException e) {
    throw ProtobufHelper.getRemoteException(e);
  }
}
 
Example #23
Source File: TestDistributedFileSystem.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test(timeout=60000)
public void testGetServerDefaults() throws IOException {
  Configuration conf = new HdfsConfiguration();
  MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).build();
  try {
    cluster.waitActive();
    DistributedFileSystem dfs = cluster.getFileSystem();
    FsServerDefaults fsServerDefaults = dfs.getServerDefaults();
    Assert.assertNotNull(fsServerDefaults);
  } finally {
    cluster.shutdown();
  }
}
 
Example #24
Source File: LocalConfigKeys.java    From big-c with Apache License 2.0 5 votes vote down vote up
public static FsServerDefaults getServerDefaults() throws IOException {
  return new FsServerDefaults(
      BLOCK_SIZE_DEFAULT,
      BYTES_PER_CHECKSUM_DEFAULT,
      CLIENT_WRITE_PACKET_SIZE_DEFAULT,
      REPLICATION_DEFAULT,
      STREAM_BUFFER_SIZE_DEFAULT,
      ENCRYPT_DATA_TRANSFER_DEFAULT,
      FS_TRASH_INTERVAL_DEFAULT,
      CHECKSUM_TYPE_DEFAULT);
}
 
Example #25
Source File: GoogleHadoopFS.java    From hadoop-connectors with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public FsServerDefaults getServerDefaults() throws IOException {
  logger.atFinest().log("getServerDefaults()");
  return ghfs.getServerDefaults();
}
 
Example #26
Source File: FtpFs.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public FsServerDefaults getServerDefaults() throws IOException {
  return FtpConfigKeys.getServerDefaults();
}
 
Example #27
Source File: RawSpliceFs.java    From spliceengine with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public FsServerDefaults getServerDefaults() throws IOException {
    return LocalConfigKeys.getServerDefaults();
}
 
Example #28
Source File: FileSystemDecorator.java    From incubator-gobblin with Apache License 2.0 4 votes vote down vote up
public FsServerDefaults getServerDefaults(Path p) throws java.io.IOException {
  return this.underlyingFs.getServerDefaults(replaceScheme(p, this.replacementScheme, this.underlyingScheme));
}
 
Example #29
Source File: ChRootedFileSystem.java    From big-c with Apache License 2.0 4 votes vote down vote up
@Override
public FsServerDefaults getServerDefaults() throws IOException {
  return getServerDefaults(fullPath(rootPath));
}
 
Example #30
Source File: HadoopLocalFileSystemV2.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public FsServerDefaults getServerDefaults() throws IOException {
    return LocalConfigKeys.getServerDefaults();
}