Move FIXMEs out to 6.0.0
[mdsal.git] / common / mdsal-common-api / src / main / java / org / opendaylight / mdsal / common / api / LogicalDatastoreType.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.mdsal.common.api;
9
10 import java.io.DataInput;
11 import java.io.DataOutput;
12 import java.io.IOException;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.opendaylight.yangtools.concepts.WritableObject;
15
16 /**
17  * The concept of a logical data store, similar to RFC8342.
18  */
19 // FIXME: 6.0.0: turn this into an interface so it can be externally-defined?
20 // FIXME: 6.0.0: note that mount points can have different types and policies, which can potentially be mapped
21 public enum LogicalDatastoreType implements WritableObject {
22     /**
23      * Logical datastore representing operational state of the system and it's components. This datastore is used
24      * to describe operational state of the system and it's operation related data.
25      *
26      * <p>
27      * It is defined to:
28      * <ul>
29      *   <li>contain both {@code config=true} and {@code config=false} nodes</li>
30      *   <li>be replicated across all nodes by default, individual shards may have different strategies, which need to
31      *       be documented
32      *   </li>
33      * </ul>
34      */
35     OPERATIONAL(1),
36     /**
37      * Logical Datastore representing configuration state of the system and it's components. This datastore is used
38      * to describe intended state of the system and intended operation mode.
39      *
40      * <p>
41      * It is defined to:
42      * <ul>
43      *   <li>contain only {@code config=true} nodes</li>
44      *   <li>be replicated across all nodes by default, individual shards may have different strategies, which need to
45      *       be documented
46      *   </li>
47      *   <li>be persisted on all nodes by default, individual shards may have different strategies, which need to
48      *       be documented
49      *   </li>
50      * </ul>
51      */
52     CONFIGURATION(2);
53
54     private int serialized;
55
56     LogicalDatastoreType(final int serialized) {
57         this.serialized = serialized;
58     }
59
60     @Override
61     public void writeTo(final DataOutput out) throws IOException {
62         out.writeByte(serialized);
63     }
64
65     public static @NonNull LogicalDatastoreType readFrom(final DataInput in) throws IOException {
66         final byte serialized = in.readByte();
67         switch (serialized) {
68             case 1:
69                 return OPERATIONAL;
70             case 2:
71                 return CONFIGURATION;
72             default:
73                 throw new IOException("Unknown type " + serialized);
74         }
75     }
76 }