{"record":{"id":"883f0d6f17be12ee","repo":"apache/hadoop","slug":"har-setreplication-not-allowed","errorCode":null,"errorMessage":"Har: setReplication not allowed","messagePattern":"Har: setReplication not allowed","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java","lineNumber":751,"sourceCode":"  @Override\n  public void close() throws IOException {\n    super.close();\n    if (fs != null) {\n      try {\n        fs.close();\n      } catch(IOException ie) {\n        //this might already be closed\n        // ignore\n      }\n    }\n  }\n  \n  /**\n   * Not implemented.\n   */\n  @Override\n  public boolean setReplication(Path src, short replication) throws IOException{\n    throw new IOException(\"Har: setReplication not allowed\");\n  }\n\n  @Override\n  public boolean rename(Path src, Path dst) throws IOException {\n    throw new IOException(\"Har: rename not allowed\");\n  }\n\n  @Override\n  public FSDataOutputStream append(Path f) throws IOException {\n    throw new IOException(\"Har: append not allowed\");\n  }\n\n  /**\n   * Not implemented.\n   */\n  @Override\n  public boolean truncate(Path f, long newLength) throws IOException {\n    throw new IOException(\"Har: truncate not allowed\");","sourceCodeStart":733,"sourceCodeEnd":769,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/HarFileSystem.java#L733-L769","documentation":"setReplication is a mutation of physical file layout, and a har exposes only index metadata over immutable part files, so the override throws 'Har: setReplication not allowed'. Replication is a property of the underlying part files, not of archive members.","triggerScenarios":"fs.setReplication(harPath, (short)N) on any har:// path — typically batch scripts that tune replication across many trees and sweep har URIs along with regular HDFS paths.","commonSituations":"Cluster-wide replication-policy scripts iterating over stored URIs; operators trying to shrink Namenode memory by adjusting replication of archived data via its har:// address.","solutions":["Apply setReplication to the physical .har files via the underlying filesystem, e.g. hdfs.setReplication(new Path(\"hdfs://nn:8020/a/data.har/part-0\"), (short)3)","Exclude har:// URIs from replication-tuning scripts (filter on scheme)","Set the desired replication at archive creation time so the part files inherit it"],"exampleFix":"// before\nharFs.setReplication(new Path(\"har://hdfs-nn:8020/a/data.har/f.txt\"), (short)3);\n\n// after\nhdfs.setReplication(new Path(\"hdfs://nn:8020/a/data.har/part-0\"), (short)3);","handlingStrategy":"validation","validationCode":"if (\"har\".equals(p.toUri().getScheme())) {\n  // tune replication of the physical part files instead\n  hdfs.setReplication(new Path(underlyingArchiveDir, \"part-0\"), replication);\n} else {\n  fs.setReplication(p, replication);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Filter har:// URIs out of replication-policy scripts","Apply replication settings on the underlying filesystem that hosts the .har directory"],"tags":["hadoop","har-filesystem","read-only","replication"],"backgroundTag":"read-only-filesystem-write","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}