view src/main/java/alice/datasegment/CommandType.java @ 523:145c425db88d dispose

add CompressedLDSM
author Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
date Thu, 09 Apr 2015 18:36:26 +0900
parents 6e304a7a60e7
children 0832af83583f
line wrap: on
line source

package alice.datasegment;

import java.util.HashMap;

public enum CommandType {
    PUT,
    UPDATE, // remove a DataSegment value and put
    PEEK,
    TAKE,
    REMOVE,//keyごと消すかもしれない
    REPLY,//PEEK/TAKEに対応
    CLOSE,
    FINISH,
    PING,//heart beat 用
    RESPONSE;//heart beat 用

    public int id;//コマンドのid
    public static HashMap<Integer, CommandType> hash = new HashMap<Integer, CommandType>();//コマンド対応表
    private static int lastId = 0;//コマンドの総数

    private CommandType(int id) {
        this.id = id;
        setLastId(id);
    }

    private CommandType() {
        this.id = incrementLastId();
    }

    private void setLastId(int id) {
        lastId =id;
    }

    private int incrementLastId() {
        return ++lastId;
    }

    public static CommandType getCommandTypeFromId(int id) {
        return hash.get(id);
    }

    static {
        for (CommandType type : CommandType.values()) {
            hash.put(type.id, type);
        }
    }

}