|
@@ -17,9 +17,6 @@
|
|
|
*/
|
|
|
package org.apache.hadoop.hdfs.server.protocol;
|
|
|
|
|
|
-import java.io.DataInput;
|
|
|
-import java.io.DataOutput;
|
|
|
-import java.io.IOException;
|
|
|
import java.util.List;
|
|
|
|
|
|
import org.apache.hadoop.classification.InterfaceAudience;
|
|
@@ -27,11 +24,6 @@ import org.apache.hadoop.classification.InterfaceStability;
|
|
|
import org.apache.hadoop.hdfs.protocol.Block;
|
|
|
import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
|
|
|
import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeDescriptor.BlockTargetPair;
|
|
|
-import org.apache.hadoop.io.Text;
|
|
|
-import org.apache.hadoop.io.Writable;
|
|
|
-import org.apache.hadoop.io.WritableFactories;
|
|
|
-import org.apache.hadoop.io.WritableFactory;
|
|
|
-
|
|
|
|
|
|
/****************************************************
|
|
|
* A BlockCommand is an instruction to a datanode
|
|
@@ -58,8 +50,6 @@ public class BlockCommand extends DatanodeCommand {
|
|
|
Block blocks[];
|
|
|
DatanodeInfo targets[][];
|
|
|
|
|
|
- public BlockCommand() {}
|
|
|
-
|
|
|
/**
|
|
|
* Create BlockCommand for transferring blocks to another datanode
|
|
|
* @param blocktargetlist blocks to be transferred
|
|
@@ -110,50 +100,4 @@ public class BlockCommand extends DatanodeCommand {
|
|
|
public DatanodeInfo[][] getTargets() {
|
|
|
return targets;
|
|
|
}
|
|
|
-
|
|
|
- ///////////////////////////////////////////
|
|
|
- // Writable
|
|
|
- ///////////////////////////////////////////
|
|
|
- static { // register a ctor
|
|
|
- WritableFactories.setFactory
|
|
|
- (BlockCommand.class,
|
|
|
- new WritableFactory() {
|
|
|
- public Writable newInstance() { return new BlockCommand(); }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- public void write(DataOutput out) throws IOException {
|
|
|
- super.write(out);
|
|
|
- Text.writeString(out, poolId);
|
|
|
- out.writeInt(blocks.length);
|
|
|
- for (int i = 0; i < blocks.length; i++) {
|
|
|
- blocks[i].write(out);
|
|
|
- }
|
|
|
- out.writeInt(targets.length);
|
|
|
- for (int i = 0; i < targets.length; i++) {
|
|
|
- out.writeInt(targets[i].length);
|
|
|
- for (int j = 0; j < targets[i].length; j++) {
|
|
|
- targets[i][j].write(out);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public void readFields(DataInput in) throws IOException {
|
|
|
- super.readFields(in);
|
|
|
- this.poolId = Text.readString(in);
|
|
|
- this.blocks = new Block[in.readInt()];
|
|
|
- for (int i = 0; i < blocks.length; i++) {
|
|
|
- blocks[i] = new Block();
|
|
|
- blocks[i].readFields(in);
|
|
|
- }
|
|
|
-
|
|
|
- this.targets = new DatanodeInfo[in.readInt()][];
|
|
|
- for (int i = 0; i < targets.length; i++) {
|
|
|
- this.targets[i] = new DatanodeInfo[in.readInt()];
|
|
|
- for (int j = 0; j < targets[i].length; j++) {
|
|
|
- targets[i][j] = new DatanodeInfo();
|
|
|
- targets[i][j].readFields(in);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
}
|