@Override public void writeFields(DataOutputStream out) throws IOException { FSImageSerialization.writeString(trg, out); DeprecatedUTF8 info[] = new DeprecatedUTF8[srcs.length]; int idx = 0; for(int i=0; i<srcs.length; i++) { info[idx++] = new DeprecatedUTF8(srcs[i]); } new ArrayWritable(DeprecatedUTF8.class, info).write(out); FSImageSerialization.writeLong(timestamp, out); // rpc ids writeRpcIds(rpcClientId, rpcCallId, out); }
/** * Add open lease record to edit log. * Records the block locations of the last block. */ public void logOpenFile(String path, INodeFileUnderConstruction newNode) { NameNode.LOG.info("In FSEditLog logOpenFile--------------------TONY"); DeprecatedUTF8 nameReplicationPair[] = new DeprecatedUTF8[] { new DeprecatedUTF8(path), FSEditLog.toLogReplication(newNode.getReplication()), FSEditLog.toLogLong(newNode.getModificationTime()), FSEditLog.toLogLong(newNode.getAccessTime()), FSEditLog.toLogLong(newNode.getFileSize())}; logEdit(Ops.OP_ADD, new ArrayWritable(DeprecatedUTF8.class, nameReplicationPair), new ArrayWritable(Block.class, newNode.getBlocks()), newNode.getPermissionStatus(), new DeprecatedUTF8(newNode.getClientName()), new DeprecatedUTF8(newNode.getClientMachine())); }
/**modified by tony 2014/4/3 * Add close lease record to edit log. */ public void logCloseFile(String path, INodeFile newNode) { NameNode.LOG.info("In FSEditLog logCloseFile--------------------TONY"); DeprecatedUTF8 nameReplicationPair[] = new DeprecatedUTF8[] { new DeprecatedUTF8(path), FSEditLog.toLogReplication(newNode.getReplication()), FSEditLog.toLogLong(newNode.getModificationTime()), FSEditLog.toLogLong(newNode.getAccessTime()), FSEditLog.toLogLong(64*1024*1024), FSEditLog.toLogLong(newNode.getFileSize()), FSEditLog.toLogLong((long)(newNode.getType()))}; logEdit(Ops.OP_CLOSE, new ArrayWritable(DeprecatedUTF8.class, nameReplicationPair), new ArrayWritable(Block.class, newNode.getBlocks()), newNode.getPermissionStatus(),newNode.getMatrix(),new LongWritable(newNode.header_offset)); }
@SuppressWarnings("deprecation") public static byte[] readBytes(DataInput in) throws IOException { DeprecatedUTF8 ustr = TL_DATA.get().U_STR; ustr.readFields(in); int len = ustr.getLength(); byte[] bytes = new byte[len]; System.arraycopy(ustr.getBytes(), 0, bytes, 0, len); return bytes; }
/** * Reading the path from the image and converting it to byte[][] directly * this saves us an array copy and conversions to and from String * @param in input to read from * @return the array each element of which is a byte[] representation * of a path component * @throws IOException */ @SuppressWarnings("deprecation") public static byte[][] readPathComponents(DataInput in) throws IOException { DeprecatedUTF8 ustr = TL_DATA.get().U_STR; ustr.readFields(in); return DFSUtil.bytes2byteArray(ustr.getBytes(), ustr.getLength(), (byte) Path.SEPARATOR_CHAR); }
/** * Reading the path from the image and converting it to byte[][] directly * this saves us an array copy and conversions to and from String * @param in * @return the array each element of which is a byte[] representation * of a path component * @throws IOException */ @SuppressWarnings("deprecation") public static byte[][] readPathComponents(DataInput in) throws IOException { DeprecatedUTF8 ustr = TL_DATA.get().U_STR; ustr.readFields(in); return DFSUtil.bytes2byteArray(ustr.getBytes(), ustr.getLength(), (byte) Path.SEPARATOR_CHAR); }
/** {@inheritDoc} */ public void readFields(DataInput in) throws IOException { name = DeprecatedUTF8.readString(in); storageID = DeprecatedUTF8.readString(in); // the infoPort read could be negative, if the port is a large number (more // than 15 bits in storage size (but less than 16 bits). // So chop off the first two bytes (and hence the signed bits) before // setting the field. this.infoPort = in.readShort() & 0x0000ffff; }
@SuppressWarnings("deprecation") public static byte[] readBytes(DataInputStream in) throws IOException { DeprecatedUTF8 ustr = TL_DATA.get().U_STR; ustr.readFields(in); int len = ustr.getLength(); byte[] bytes = new byte[len]; System.arraycopy(ustr.getBytes(), 0, bytes, 0, len); return bytes; }
/** * Reading the path from the image and converting it to byte[][] directly * this saves us an array copy and conversions to and from String * @param in * @return the array each element of which is a byte[] representation * of a path component * @throws IOException */ @SuppressWarnings("deprecation") public static byte[][] readPathComponents(DataInputStream in) throws IOException { DeprecatedUTF8 ustr = TL_DATA.get().U_STR; ustr.readFields(in); return DFSUtil.bytes2byteArray(ustr.getBytes(), ustr.getLength(), (byte) Path.SEPARATOR_CHAR); }
/** Serialization for FSEditLog */ void readFieldsFromFSEditLog(DataInput in) throws IOException { this.name = DeprecatedUTF8.readString(in); this.storageID = DeprecatedUTF8.readString(in); this.infoPort = in.readShort() & 0x0000ffff; this.capacity = in.readLong(); this.dfsUsed = in.readLong(); this.remaining = in.readLong(); /************** add by xianyu *********************/ this.cpuStatus = ServernodeCPUStatus.read(in); this.memStatus = ServernodeMEMStatus.read(in); int cnt = in.readInt(); this.netStatus = new ServernodeNETStatus[cnt]; for(int i = 0; i < cnt; i++) this.netStatus[i] = ServernodeNETStatus.read(in); cnt = in.readInt(); this.ioStatus = new ServernodeIOStatus[cnt]; for(int j = 0; j < cnt; j++) this.ioStatus[j] = ServernodeIOStatus.read(in); /**************************************************/ //removed by xianyu /* this.cpuUsed = in.readLong(); //ww added this.memUsed = in.readLong(); //ww added this.ioUsed = in.readLong(); //ww added */ this.lastUpdate = in.readLong(); this.xceiverCount = in.readInt(); this.location = Text.readString(in); this.hostName = Text.readString(in); setAdminState(WritableUtils.readEnum(in, AdminStates.class)); }
/** * Add create directory record to edit log */ public void logMkDir(String path, INode newNode) { DeprecatedUTF8 info[] = new DeprecatedUTF8[] { new DeprecatedUTF8(path), FSEditLog.toLogLong(newNode.getModificationTime()), FSEditLog.toLogLong(newNode.getAccessTime()) }; logEdit(Ops.OP_MKDIR, new ArrayWritable(DeprecatedUTF8.class, info), newNode.getPermissionStatus()); }
/** * Add rename record to edit log * TODO: use String parameters until just before writing to disk */ void logRename(String src, String dst, long timestamp) { DeprecatedUTF8 info[] = new DeprecatedUTF8[] { new DeprecatedUTF8(src), new DeprecatedUTF8(dst), FSEditLog.toLogLong(timestamp)}; logEdit(Ops.OP_RENAME_OLD, new ArrayWritable(DeprecatedUTF8.class, info)); }
/** * Add rename record to edit log */ void logRename(String src, String dst, long timestamp, Options.Rename... options) { DeprecatedUTF8 info[] = new DeprecatedUTF8[] { new DeprecatedUTF8(src), new DeprecatedUTF8(dst), FSEditLog.toLogLong(timestamp)}; logEdit(Ops.OP_RENAME, new ArrayWritable(DeprecatedUTF8.class, info), toBytesWritable(options)); }
/** * concat(trg,src..) log */ void logConcat(String trg, String [] srcs, long timestamp) { int size = 1 + srcs.length + 1; // trg, srcs, timestamp DeprecatedUTF8 info[] = new DeprecatedUTF8[size]; int idx = 0; info[idx++] = new DeprecatedUTF8(trg); for(int i=0; i<srcs.length; i++) { info[idx++] = new DeprecatedUTF8(srcs[i]); } info[idx] = FSEditLog.toLogLong(timestamp); logEdit(Ops.OP_CONCAT_DELETE, new ArrayWritable(DeprecatedUTF8.class, info)); }
/** * Add delete file record to edit log */ void logDelete(String src, long timestamp) { DeprecatedUTF8 info[] = new DeprecatedUTF8[] { new DeprecatedUTF8(src), FSEditLog.toLogLong(timestamp)}; logEdit(Ops.OP_DELETE, new ArrayWritable(DeprecatedUTF8.class, info)); }
/** * Add access time record to edit log */ void logTimes(String src, long mtime, long atime) { DeprecatedUTF8 info[] = new DeprecatedUTF8[] { new DeprecatedUTF8(src), FSEditLog.toLogLong(mtime), FSEditLog.toLogLong(atime)}; logEdit(Ops.OP_TIMES, new ArrayWritable(DeprecatedUTF8.class, info)); }
/** * Add a create symlink record. */ void logSymlink(String path, String value, long mtime, long atime, INodeSymlink node) { DeprecatedUTF8 info[] = new DeprecatedUTF8[] { new DeprecatedUTF8(path), new DeprecatedUTF8(value), FSEditLog.toLogLong(mtime), FSEditLog.toLogLong(atime)}; logEdit(Ops.OP_SYMLINK, new ArrayWritable(DeprecatedUTF8.class, info), node.getPermissionStatus()); }