source: proiecte/HadoopJUnit/hadoop-0.20.1/src/hdfs/org/apache/hadoop/hdfs/server/protocol/DatanodeCommand.java @ 120

Last change on this file since 120 was 120, checked in by (none), 14 years ago

Added the mail files for the Hadoop JUNit Project

  • Property svn:executable set to *
File size: 2.4 KB
Line 
1/**
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements.  See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership.  The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License.  You may obtain a copy of the License at
9 *
10 *     http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18package org.apache.hadoop.hdfs.server.protocol;
19
20import java.io.*;
21
22import org.apache.hadoop.io.*;
23
24public abstract class DatanodeCommand implements Writable {
25  static class Register extends DatanodeCommand {
26    private Register() {super(DatanodeProtocol.DNA_REGISTER);}
27    public void readFields(DataInput in) {}
28    public void write(DataOutput out) {}
29  }
30
31  static class Finalize extends DatanodeCommand {
32    private Finalize() {super(DatanodeProtocol.DNA_FINALIZE);}
33    public void readFields(DataInput in) {}
34    public void write(DataOutput out) {}
35  }
36
37  static {                                      // register a ctor
38    WritableFactories.setFactory(Register.class,
39        new WritableFactory() {
40          public Writable newInstance() {return new Register();}
41        });
42    WritableFactories.setFactory(Finalize.class,
43        new WritableFactory() {
44          public Writable newInstance() {return new Finalize();}
45        });
46  }
47
48  public static final DatanodeCommand REGISTER = new Register();
49  public static final DatanodeCommand FINALIZE = new Finalize();
50
51  private int action;
52 
53  public DatanodeCommand() {
54    this(DatanodeProtocol.DNA_UNKNOWN);
55  }
56 
57  DatanodeCommand(int action) {
58    this.action = action;
59  }
60
61  public int getAction() {
62    return this.action;
63  }
64 
65  ///////////////////////////////////////////
66  // Writable
67  ///////////////////////////////////////////
68  public void write(DataOutput out) throws IOException {
69    out.writeInt(this.action);
70  }
71 
72  public void readFields(DataInput in) throws IOException {
73    this.action = in.readInt();
74  }
75}
Note: See TracBrowser for help on using the repository browser.