Agregar datos a hdfs
lt;propertygt;
lt;namegt;dfs.support.appendlt;/namegt
lt;valuegt;truelt;/valuegt; >
lt;/propertygt;
Aquí está el código de prueba al que puede consultar:
paquete com.wyp
import org.apache. hadoop .conf.Configuration;
importar org.*;
importar java.net.URI
clase pública AppendContent {
public static void main(String[] args) {
String hdfs_path = "hdfs://mycluster/home/wyp/wyp.txt" //ruta del archivo
Configuración conf; = nueva Configuración();
conf.setBoolean("dfs.support.append", true);
String inpath = "/home/wyp/append.txt";
p>FileSystem fs = null
prueba {
fs = FileSystem.get(URI.create(hdfs_path),
<); p> // La secuencia del archivo que se agregará, inpath es el archivoInputStream in = new
BufferedInputStream(new FileInputStream(inpath)); out = fs.append (new Path(hdfs_path));
IOUtils.copyBytes(in, out, 4096, true);
} catch (IOException e) {
y .printStackTrace( );
}
}
}