Remove deprecated code.

Change-Id: Ifd68e4ddfaade2a8dd7de43a83bf222b48b9291b
diff --git a/core/store/dist/src/main/java/org/onosproject/store/intent/impl/DistributedIntentStore.java b/core/store/dist/src/main/java/org/onosproject/store/intent/impl/DistributedIntentStore.java
deleted file mode 100644
index fd76653..0000000
--- a/core/store/dist/src/main/java/org/onosproject/store/intent/impl/DistributedIntentStore.java
+++ /dev/null
@@ -1,364 +0,0 @@
-/*
- * Copyright 2014 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.store.intent.impl;
-
-import com.codahale.metrics.Timer;
-import com.codahale.metrics.Timer.Context;
-import com.google.common.base.Verify;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
-import com.google.common.collect.ImmutableSet;
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.apache.felix.scr.annotations.Service;
-import org.onlab.metrics.MetricsService;
-import org.onlab.util.KryoNamespace;
-import org.onosproject.core.MetricsHelper;
-import org.onosproject.net.intent.Intent;
-import org.onosproject.net.intent.IntentEvent;
-import org.onosproject.net.intent.IntentId;
-import org.onosproject.net.intent.IntentState;
-import org.onosproject.net.intent.IntentStore;
-import org.onosproject.net.intent.IntentStoreDelegate;
-import org.onosproject.net.intent.Key;
-import org.onosproject.store.AbstractStore;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.serializers.KryoSerializer;
-import org.onosproject.store.serializers.StoreSerializer;
-import org.onosproject.store.service.DatabaseAdminService;
-import org.onosproject.store.service.DatabaseService;
-import org.onosproject.store.service.impl.CMap;
-import org.slf4j.Logger;
-
-import java.util.EnumSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-import static org.onlab.metrics.MetricsUtil.startTimer;
-import static org.onlab.metrics.MetricsUtil.stopTimer;
-import static org.onosproject.net.intent.IntentState.FAILED;
-import static org.onosproject.net.intent.IntentState.INSTALLED;
-import static org.onosproject.net.intent.IntentState.INSTALL_REQ;
-import static org.onosproject.net.intent.IntentState.WITHDRAWN;
-import static org.slf4j.LoggerFactory.getLogger;
-
-//TODO Note: this store will be removed
-
-@Component(immediate = true, enabled = false)
-@Service
-public class DistributedIntentStore
-        extends AbstractStore<IntentEvent, IntentStoreDelegate>
-        implements IntentStore, MetricsHelper {
-
-    /** Valid parking state, which can transition to INSTALLED. */
-    private static final Set<IntentState> PRE_INSTALLED = EnumSet.of(INSTALL_REQ, INSTALLED, FAILED);
-
-    /** Valid parking state, which can transition to WITHDRAWN. */
-    private static final Set<IntentState> PRE_WITHDRAWN = EnumSet.of(INSTALLED, FAILED);
-
-    private static final Set<IntentState> PARKING = EnumSet.of(INSTALL_REQ, INSTALLED, WITHDRAWN, FAILED);
-
-    private final Logger log = getLogger(getClass());
-
-    // Assumption: IntentId will not have synonyms
-    private static final String INTENTS_TABLE = "intents";
-    private CMap<IntentId, Intent> intents;
-
-    private static final String STATES_TABLE = "intent-states";
-    private CMap<IntentId, IntentState> states;
-
-    // TODO transient state issue remains for this impl.: ONOS-103
-    // Map to store instance local intermediate state transition
-    private transient Map<IntentId, IntentState> transientStates = new ConcurrentHashMap<>();
-
-    private static final String INSTALLABLE_TABLE = "installable-intents";
-    private CMap<IntentId, List<Intent>> installable;
-
-    private LoadingCache<IntentId, String> keyCache;
-
-    private StoreSerializer serializer;
-
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
-    protected DatabaseAdminService dbAdminService;
-
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
-    protected DatabaseService dbService;
-
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
-    protected MetricsService metricsService;
-
-    // TODO make this configurable
-    private boolean onlyLogTransitionError = true;
-
-    private Timer getInstallableIntentsTimer;
-    private Timer getIntentCountTimer;
-    private Timer getIntentsTimer;
-    private Timer getIntentTimer;
-    private Timer getIntentStateTimer;
-
-
-    private Timer createResponseTimer(String methodName) {
-        return createTimer("IntentStore", methodName, "responseTime");
-    }
-
-    @Activate
-    public void activate() {
-        getInstallableIntentsTimer = createResponseTimer("getInstallableIntents");
-        getIntentCountTimer = createResponseTimer("getIntentCount");
-        getIntentsTimer = createResponseTimer("getIntents");
-        getIntentTimer = createResponseTimer("getIntent");
-        getIntentStateTimer = createResponseTimer("getIntentState");
-
-        // We need a way to add serializer for intents which has been plugged-in.
-        // As a short term workaround, relax Kryo config to
-        // registrationRequired=false
-        serializer = new KryoSerializer() {
-
-            @Override
-            protected void setupKryoPool() {
-                serializerPool = KryoNamespace.newBuilder()
-                        .setRegistrationRequired(false)
-                        .register(KryoNamespaces.API)
-                        .nextId(KryoNamespaces.BEGIN_USER_CUSTOM_ID)
-                        .build();
-            }
-        };
-
-        keyCache = CacheBuilder.newBuilder()
-                .softValues()
-                .build(new CacheLoader<IntentId, String>() {
-
-                    @Override
-                    public String load(IntentId key) {
-                        return key.toString();
-                    }
-                });
-
-        intents = new IntentIdMap<>(dbAdminService, dbService, INTENTS_TABLE, serializer);
-
-        states = new IntentIdMap<>(dbAdminService, dbService, STATES_TABLE, serializer);
-
-        transientStates.clear();
-
-        installable = new IntentIdMap<>(dbAdminService, dbService, INSTALLABLE_TABLE, serializer);
-
-        log.info("Started");
-    }
-
-    @Deactivate
-    public void deactivate() {
-        log.info("Stopped");
-    }
-
-    @Override
-    public MetricsService metricsService() {
-        return metricsService;
-    }
-
-    @Override
-    public long getIntentCount() {
-        Context timer = startTimer(getIntentCountTimer);
-        try {
-            return intents.size();
-        } finally {
-            stopTimer(timer);
-        }
-    }
-
-    @Override
-    public Iterable<Intent> getIntents() {
-        Context timer = startTimer(getIntentsTimer);
-        try {
-            return ImmutableSet.copyOf(intents.values());
-        } finally {
-            stopTimer(timer);
-        }
-    }
-
-    @Override
-    public Intent getIntent(Key intentKey) {
-        return null;
-    }
-
-    public Intent getIntent(IntentId intentId) {
-        Context timer = startTimer(getIntentTimer);
-        try {
-            return intents.get(intentId);
-        } finally {
-            stopTimer(timer);
-        }
-    }
-
-    @Override
-    public IntentState getIntentState(Key key) {
-        // TODO: either implement this or remove the class
-        return IntentState.FAILED;
-        /*
-        Context timer = startTimer(getIntentStateTimer);
-        try {
-            final IntentState localState = transientStates.get(id);
-            if (localState != null) {
-                return localState;
-            }
-            return states.get(id);
-        } finally {
-            stopTimer(timer);
-        }
-        */
-    }
-
-    private void verify(boolean expression, String errorMessageTemplate, Object... errorMessageArgs) {
-        if (onlyLogTransitionError) {
-            if (!expression) {
-                log.error(errorMessageTemplate.replace("%s", "{}"), errorMessageArgs);
-            }
-        } else {
-            Verify.verify(expression, errorMessageTemplate, errorMessageArgs);
-        }
-    }
-
-    @Override
-    public List<Intent> getInstallableIntents(Key intentKey) {
-        // TODO: implement this or delete class
-        return null;
-        /*
-        Context timer = startTimer(getInstallableIntentsTimer);
-        try {
-            return installable.get(intentId);
-        } finally {
-            stopTimer(timer);
-        }
-        */
-    }
-
-    protected String strIntentId(IntentId key) {
-        return keyCache.getUnchecked(key);
-    }
-
-    /**
-     * Distributed Map from IntentId to some value.
-     *
-     * @param <V> Map value type
-     */
-    final class IntentIdMap<V> extends CMap<IntentId, V> {
-
-        /**
-         * Creates a IntentIdMap instance.
-         *
-         * @param dbAdminService DatabaseAdminService to use for this instance
-         * @param dbService DatabaseService to use for this instance
-         * @param tableName table which this Map corresponds to
-         * @param serializer Value serializer
-         */
-        public IntentIdMap(DatabaseAdminService dbAdminService,
-                         DatabaseService dbService,
-                         String tableName,
-                         StoreSerializer serializer) {
-            super(dbAdminService, dbService, tableName, serializer);
-        }
-
-        @Override
-        protected String sK(IntentId key) {
-            return strIntentId(key);
-        }
-    }
-
-    /*@Override
-    public List<Operation> batchWrite(BatchWrite batch) {
-        if (batch.isEmpty()) {
-            return Collections.emptyList();
-        }
-
-        List<Operation> failed = new ArrayList<>();
-        final Builder builder = BatchWriteRequest.newBuilder();
-        List<IntentEvent> events = Lists.newArrayList();
-
-        final Set<IntentId> transitionedToParking = new HashSet<>();
-
-        for (Operation op : batch.operations()) {
-            switch (op.type()) {
-            case CREATE_INTENT:
-                checkArgument(op.args().size() == 1,
-                              "CREATE_INTENT takes 1 argument. %s", op);
-                Intent intent = op.arg(0);
-                builder.putIfAbsent(INTENTS_TABLE, strIntentId(intent.id()), serializer.encode(intent));
-                builder.putIfAbsent(STATES_TABLE, strIntentId(intent.id()), serializer.encode(INSTALL_REQ));
-                events.add(IntentEvent.getEvent(INSTALL_REQ, intent));
-                break;
-
-            case REMOVE_INTENT:
-                checkArgument(op.args().size() == 1,
-                              "REMOVE_INTENT takes 1 argument. %s", op);
-                IntentId intentId = (IntentId) op.arg(0);
-                builder.remove(INTENTS_TABLE, strIntentId(intentId));
-                builder.remove(STATES_TABLE, strIntentId(intentId));
-                builder.remove(INSTALLABLE_TABLE, strIntentId(intentId));
-                break;
-
-            case SET_STATE:
-                checkArgument(op.args().size() == 2,
-                              "SET_STATE takes 2 arguments. %s", op);
-                intent = op.arg(0);
-                IntentState newState = op.arg(1);
-                builder.put(STATES_TABLE, strIntentId(intent.id()), serializer.encode(newState));
-                if (PARKING.contains(newState)) {
-                    transitionedToParking.add(intent.id());
-                    events.add(IntentEvent.getEvent(newState, intent));
-                } else {
-                    transitionedToParking.remove(intent.id());
-                }
-                break;
-
-            case SET_INSTALLABLE:
-                checkArgument(op.args().size() == 2,
-                              "SET_INSTALLABLE takes 2 arguments. %s", op);
-                intentId = op.arg(0);
-                List<Intent> installableIntents = op.arg(1);
-                builder.put(INSTALLABLE_TABLE, strIntentId(intentId), serializer.encode(installableIntents));
-                break;
-
-            case REMOVE_INSTALLED:
-                checkArgument(op.args().size() == 1,
-                              "REMOVE_INSTALLED takes 1 argument. %s", op);
-                intentId = op.arg(0);
-                builder.remove(INSTALLABLE_TABLE, strIntentId(intentId));
-                break;
-
-            default:
-                log.warn("Unknown Operation encountered: {}", op);
-                failed.add(op);
-                break;
-            }
-        }
-
-        BatchWriteResult batchWriteResult = dbService.batchWrite(builder.build());
-        if (batchWriteResult.isSuccessful()) {
-            // no-failure (except for invalid input)
-            transitionedToParking.forEach((intentId) -> transientStates.remove(intentId));
-            notifyDelegate(events);
-            return failed;
-        } else {
-            // everything failed
-            return batch.operations();
-        }
-    }*/
-}
diff --git a/core/store/dist/src/main/java/org/onosproject/store/resource/impl/DistributedLinkResourceStore.java b/core/store/dist/src/main/java/org/onosproject/store/resource/impl/DistributedLinkResourceStore.java
deleted file mode 100644
index 73b053d..0000000
--- a/core/store/dist/src/main/java/org/onosproject/store/resource/impl/DistributedLinkResourceStore.java
+++ /dev/null
@@ -1,639 +0,0 @@
-/*
- * Copyright 2014-2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.store.resource.impl;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.apache.felix.scr.annotations.Service;
-import org.onlab.util.PositionalParameterStringFormatter;
-import org.onosproject.net.AnnotationKeys;
-import org.onosproject.net.Link;
-import org.onosproject.net.LinkKey;
-import org.onosproject.net.intent.IntentId;
-import org.onosproject.net.link.LinkService;
-import org.onosproject.net.resource.Bandwidth;
-import org.onosproject.net.resource.BandwidthResourceAllocation;
-import org.onosproject.net.resource.Lambda;
-import org.onosproject.net.resource.LambdaResourceAllocation;
-import org.onosproject.net.resource.LinkResourceAllocations;
-import org.onosproject.net.resource.LinkResourceEvent;
-import org.onosproject.net.resource.LinkResourceStore;
-import org.onosproject.net.resource.MplsLabel;
-import org.onosproject.net.resource.MplsLabelResourceAllocation;
-import org.onosproject.net.resource.ResourceAllocation;
-import org.onosproject.net.resource.ResourceAllocationException;
-import org.onosproject.net.resource.ResourceType;
-import org.onosproject.store.serializers.KryoSerializer;
-import org.onosproject.store.serializers.StoreSerializer;
-import org.onosproject.store.service.BatchWriteRequest;
-import org.onosproject.store.service.BatchWriteRequest.Builder;
-import org.onosproject.store.service.BatchWriteResult;
-import org.onosproject.store.service.DatabaseAdminService;
-import org.onosproject.store.service.DatabaseException;
-import org.onosproject.store.service.DatabaseService;
-import org.onosproject.store.service.VersionedValue;
-import org.onosproject.store.service.WriteRequest;
-import org.onosproject.store.service.WriteResult;
-import org.slf4j.Logger;
-
-import com.google.common.base.Function;
-import com.google.common.collect.FluentIterable;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Sets;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-import static com.google.common.base.Predicates.notNull;
-import static org.onlab.util.HexString.toHexString;
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Manages link resources using database service.
- */
-@Component(immediate = true, enabled = false)
-@Service
-public class DistributedLinkResourceStore implements LinkResourceStore {
-
-    private final Logger log = getLogger(getClass());
-
-    private static final Bandwidth DEFAULT_BANDWIDTH = Bandwidth.mbps(1_000);
-
-    // table to store current allocations
-    /** LinkKey -> List<LinkResourceAllocations>. */
-    private static final String LINK_RESOURCE_ALLOCATIONS = "LinkResourceAllocations";
-
-    /** IntentId -> LinkResourceAllocations. */
-    private static final String INTENT_ALLOCATIONS = "IntentAllocations";
-
-    private static final Bandwidth EMPTY_BW = Bandwidth.bps(0);
-
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
-    protected DatabaseAdminService databaseAdminService;
-
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
-    protected DatabaseService databaseService;
-
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
-    protected LinkService linkService;
-
-    // Link annotation key name to use as bandwidth in Mbps
-    private String bandwidthAnnotation = AnnotationKeys.BANDWIDTH;
-    // Link annotation key name to use as max lambda
-    private String wavesAnnotation = AnnotationKeys.OPTICAL_WAVES;
-
-    // Max MPLS labels: 2^20 – 1
-    private int maxMplsLabel = 0xFFFFF;
-    private StoreSerializer serializer;
-
-    void createTable(String tableName) {
-        boolean tableReady = false;
-        do {
-            try {
-                if (!databaseAdminService.listTables().contains(tableName)) {
-                    databaseAdminService.createTable(tableName);
-                }
-                tableReady = true;
-            } catch (DatabaseException e) {
-                log.debug("Failed creating table, retrying", e);
-                try {
-                    Thread.sleep(200);
-                } catch (InterruptedException e1) {
-                    throw new DatabaseException(e1);
-                }
-            }
-        } while (!tableReady);
-    }
-
-    @Activate
-    public void activate() {
-
-        serializer = new KryoSerializer();
-
-        createTable(LINK_RESOURCE_ALLOCATIONS);
-        createTable(INTENT_ALLOCATIONS);
-
-        log.info("Started");
-    }
-
-    @Deactivate
-    public void deactivate() {
-        log.info("Stopped");
-    }
-
-    private Set<? extends ResourceAllocation> getResourceCapacity(ResourceType type, Link link) {
-        if (type == ResourceType.BANDWIDTH) {
-            return ImmutableSet.of(getBandwidthResourceCapacity(link));
-        }
-        if (type == ResourceType.LAMBDA) {
-            return getLambdaResourceCapacity(link);
-        }
-        if (type == ResourceType.MPLS_LABEL) {
-            return getMplsResourceCapacity();
-        }
-        return null;
-    }
-
-    private Set<LambdaResourceAllocation> getLambdaResourceCapacity(Link link) {
-        Set<LambdaResourceAllocation> allocations = new HashSet<>();
-        try {
-            final int waves = Integer.parseInt(link.annotations().value(wavesAnnotation));
-            for (int i = 1; i <= waves; i++) {
-                allocations.add(new LambdaResourceAllocation(Lambda.valueOf(i)));
-            }
-        } catch (NumberFormatException e) {
-            log.debug("No {} annotation on link %s", wavesAnnotation, link);
-        }
-        return allocations;
-    }
-
-    private BandwidthResourceAllocation getBandwidthResourceCapacity(Link link) {
-
-        // if Link annotation exist, use them
-        // if all fails, use DEFAULT_BANDWIDTH
-
-        Bandwidth bandwidth = null;
-        String strBw = link.annotations().value(bandwidthAnnotation);
-        if (strBw != null) {
-            try {
-                bandwidth = Bandwidth.mbps(Double.parseDouble(strBw));
-            } catch (NumberFormatException e) {
-                // do nothings
-                bandwidth = null;
-            }
-        }
-
-        if (bandwidth == null) {
-            // fall back, use fixed default
-            bandwidth = DEFAULT_BANDWIDTH;
-        }
-        return new BandwidthResourceAllocation(bandwidth);
-    }
-
-    private Set<MplsLabelResourceAllocation> getMplsResourceCapacity() {
-        Set<MplsLabelResourceAllocation> allocations = new HashSet<>();
-        //Ignoring reserved labels of 0 through 15
-        for (int i = 16; i <= maxMplsLabel; i++) {
-            allocations.add(new MplsLabelResourceAllocation(MplsLabel
-                    .valueOf(i)));
-
-        }
-        return allocations;
-    }
-
-    private Map<ResourceType, Set<? extends ResourceAllocation>> getResourceCapacity(Link link) {
-        Map<ResourceType, Set<? extends ResourceAllocation>> caps = new HashMap<>();
-        for (ResourceType type : ResourceType.values()) {
-            Set<? extends ResourceAllocation> cap = getResourceCapacity(type, link);
-            if (cap != null) {
-                caps.put(type, cap);
-            }
-        }
-        return caps;
-    }
-
-    @Override
-    public Set<ResourceAllocation> getFreeResources(Link link) {
-        Map<ResourceType, Set<? extends ResourceAllocation>> freeResources = getFreeResourcesEx(link);
-        Set<ResourceAllocation> allFree = new HashSet<>();
-        for (Set<? extends ResourceAllocation> r:freeResources.values()) {
-            allFree.addAll(r);
-        }
-        return allFree;
-    }
-
-    private Map<ResourceType, Set<? extends ResourceAllocation>> getFreeResourcesEx(Link link) {
-        // returns capacity - allocated
-
-        checkNotNull(link);
-        Map<ResourceType, Set<? extends ResourceAllocation>> free = new HashMap<>();
-        final Map<ResourceType, Set<? extends ResourceAllocation>> caps = getResourceCapacity(link);
-        final Iterable<LinkResourceAllocations> allocations = getAllocations(link);
-
-        for (ResourceType type : ResourceType.values()) {
-            // there should be class/category of resources
-            switch (type) {
-            case BANDWIDTH:
-            {
-                Set<? extends ResourceAllocation> bw = caps.get(ResourceType.BANDWIDTH);
-                if (bw == null || bw.isEmpty()) {
-                    bw = Sets.newHashSet(new BandwidthResourceAllocation(EMPTY_BW));
-                }
-
-                BandwidthResourceAllocation cap = (BandwidthResourceAllocation) bw.iterator().next();
-                double freeBw = cap.bandwidth().toDouble();
-
-                // enumerate current allocations, subtracting resources
-                for (LinkResourceAllocations alloc : allocations) {
-                    Set<ResourceAllocation> types = alloc.getResourceAllocation(link);
-                    for (ResourceAllocation a : types) {
-                        if (a instanceof BandwidthResourceAllocation) {
-                            BandwidthResourceAllocation bwA = (BandwidthResourceAllocation) a;
-                            freeBw -= bwA.bandwidth().toDouble();
-                        }
-                    }
-                }
-
-                free.put(type, Sets.newHashSet(new BandwidthResourceAllocation(Bandwidth.bps(freeBw))));
-                break;
-            }
-
-            case LAMBDA:
-            {
-                Set<? extends ResourceAllocation> lmd = caps.get(type);
-                if (lmd == null || lmd.isEmpty()) {
-                    // nothing left
-                    break;
-                }
-                Set<LambdaResourceAllocation> freeL = new HashSet<>();
-                for (ResourceAllocation r : lmd) {
-                    if (r instanceof LambdaResourceAllocation) {
-                        freeL.add((LambdaResourceAllocation) r);
-                    }
-                }
-
-                // enumerate current allocations, removing resources
-                for (LinkResourceAllocations alloc : allocations) {
-                    Set<ResourceAllocation> types = alloc.getResourceAllocation(link);
-                    for (ResourceAllocation a : types) {
-                        if (a instanceof LambdaResourceAllocation) {
-                            freeL.remove(a);
-                        }
-                    }
-                }
-
-                free.put(type, freeL);
-                break;
-            }
-            case MPLS_LABEL:
-            {
-                Set<? extends ResourceAllocation> mpls = caps.get(type);
-                if (mpls == null || mpls.isEmpty()) {
-                    // nothing left
-                    break;
-                }
-                Set<MplsLabelResourceAllocation> freeLabel = new HashSet<>();
-                for (ResourceAllocation r : mpls) {
-                    if (r instanceof MplsLabelResourceAllocation) {
-                        freeLabel.add((MplsLabelResourceAllocation) r);
-                    }
-                }
-
-                // enumerate current allocations, removing resources
-                for (LinkResourceAllocations alloc : allocations) {
-                    Set<ResourceAllocation> types = alloc
-                            .getResourceAllocation(link);
-                    for (ResourceAllocation a : types) {
-                        if (a instanceof MplsLabelResourceAllocation) {
-                            freeLabel.remove(a);
-                        }
-                    }
-                }
-
-                free.put(type, freeLabel);
-                break;
-            }
-
-            default:
-                break;
-            }
-        }
-        return free;
-    }
-
-    private LinkResourceAllocations getIntentAllocations(IntentId id) {
-        VersionedValue vv
-            = databaseService.get(INTENT_ALLOCATIONS, toIntentDbKey(checkNotNull(id)));
-        if (vv == null || vv.value() == null) {
-            return null;
-        }
-        return decodeIntentAllocations(vv.value());
-    }
-
-    private Builder putIntentAllocations(Builder ctx,
-                                         IntentId id,
-                                         LinkResourceAllocations alloc) {
-        return ctx.put(INTENT_ALLOCATIONS,
-                       toIntentDbKey(id),
-                       encodeIntentAllocations(alloc));
-    }
-
-    @Override
-    public void allocateResources(LinkResourceAllocations allocations) {
-        checkNotNull(allocations);
-
-        Builder tx = BatchWriteRequest.newBuilder();
-
-        // TODO: Should IntentId -> Allocation be updated conditionally?
-        putIntentAllocations(tx, allocations.intendId(), allocations);
-
-        for (Link link : allocations.links()) {
-            allocateLinkResource(tx, link, allocations);
-        }
-
-        BatchWriteRequest batch = tx.build();
-//         log.info("Intent: {}", databaseService.getAll(INTENT_ALLOCATIONS));
-//         log.info("Link: {}",
-        // databaseService.getAll(LINK_RESOURCE_ALLOCATIONS));
-
-        BatchWriteResult result = databaseService.batchWrite(batch);
-        if (!result.isSuccessful()) {
-            log.error("Allocation Failed.");
-            if (log.isDebugEnabled()) {
-                logFailureDetail(batch, result);
-            }
-            checkState(result.isSuccessful(), "Allocation failed");
-        }
-    }
-
-    private void logFailureDetail(BatchWriteRequest batch,
-                                  BatchWriteResult result) {
-        for (int i = 0; i < batch.batchSize(); ++i) {
-            final WriteRequest req = batch.getAsList().get(i);
-            final WriteResult fail = result.getAsList().get(i);
-            switch (fail.status()) {
-            case ABORTED:
-                log.debug("ABORTED: {}@{}", req.key(), req.tableName());
-                break;
-            case PRECONDITION_VIOLATION:
-                switch (req.type()) {
-                case PUT_IF_ABSENT:
-                    log.debug("{}: {}@{} : {}", req.type(),
-                              req.key(), req.tableName(), fail.previousValue());
-                    break;
-                case PUT_IF_VALUE:
-                case REMOVE_IF_VALUE:
-                    log.debug("{}: {}@{} : was {}, expected {}", req.type(),
-                              req.key(), req.tableName(),
-                              fail.previousValue(),
-                              toHexString(req.oldValue()));
-                    break;
-                case PUT_IF_VERSION:
-                case REMOVE_IF_VERSION:
-                    log.debug("{}: {}@{} : was {}, expected {}", req.type(),
-                              req.key(), req.tableName(),
-                              fail.previousValue().version(),
-                              req.previousVersion());
-                    break;
-                default:
-                    log.error("Should never reach here.");
-                    break;
-                }
-                break;
-            default:
-                log.error("Should never reach here.");
-                break;
-            }
-        }
-    }
-
-    private Builder allocateLinkResource(Builder builder, Link link,
-                                         LinkResourceAllocations allocations) {
-
-        // requested resources
-        Set<ResourceAllocation> reqs = allocations.getResourceAllocation(link);
-
-        Map<ResourceType, Set<? extends ResourceAllocation>> available = getFreeResourcesEx(link);
-        for (ResourceAllocation req : reqs) {
-            Set<? extends ResourceAllocation> avail = available.get(req.type());
-            if (req instanceof BandwidthResourceAllocation) {
-                // check if allocation should be accepted
-                if (avail.isEmpty()) {
-                    checkState(!avail.isEmpty(),
-                               "There's no Bandwidth resource on %s?",
-                               link);
-                }
-                BandwidthResourceAllocation bw = (BandwidthResourceAllocation) avail.iterator().next();
-                double bwLeft = bw.bandwidth().toDouble();
-                bwLeft -= ((BandwidthResourceAllocation) req).bandwidth().toDouble();
-                BandwidthResourceAllocation bwReq = ((BandwidthResourceAllocation) req);
-                if (bwLeft < 0) {
-                    throw new ResourceAllocationException(
-                            PositionalParameterStringFormatter.format(
-                                    "Unable to allocate bandwidth for link {} "
-                                            + " requested amount is {} current allocation is {}",
-                                    link,
-                                    bwReq.bandwidth().toDouble(),
-                                    bw));
-                }
-            } else if (req instanceof LambdaResourceAllocation) {
-                final LambdaResourceAllocation lambdaAllocation = (LambdaResourceAllocation) req;
-                // check if allocation should be accepted
-                if (!avail.contains(req)) {
-                    // requested lambda was not available
-                    throw new ResourceAllocationException(
-                            PositionalParameterStringFormatter.format(
-                                    "Unable to allocate lambda for link {} lambda is {}",
-                                    link,
-                                    lambdaAllocation.lambda().toInt()));
-                }
-            } else if (req instanceof MplsLabelResourceAllocation) {
-
-                final MplsLabelResourceAllocation mplsAllocation = (MplsLabelResourceAllocation) req;
-                // check if allocation should be accepted
-                if (!avail.contains(req)) {
-                    // requested mpls label was not available
-                    throw new ResourceAllocationException(
-                                                          PositionalParameterStringFormatter
-                                                                  .format("Unable to allocate MPLS label for "
-                                                                          + "link {} MPLS label is {}",
-                                                                          link,
-                                                                          mplsAllocation
-                                                                                  .mplsLabel()
-                                                                                  .toString()));
-                }
-            }
-        }
-        // all requests allocatable => add allocation
-        final List<LinkResourceAllocations> before = getAllocations(link);
-        List<LinkResourceAllocations> after = new ArrayList<>(before.size());
-        after.addAll(before);
-        after.add(allocations);
-        replaceLinkAllocations(builder, LinkKey.linkKey(link), before, after);
-        return builder;
-    }
-
-    private Builder replaceLinkAllocations(Builder builder, LinkKey linkKey,
-                                           List<LinkResourceAllocations> before,
-                                           List<LinkResourceAllocations> after) {
-
-        byte[] oldValue = encodeLinkAllocations(before);
-        byte[] newValue = encodeLinkAllocations(after);
-        builder.putIfValueMatches(LINK_RESOURCE_ALLOCATIONS, toLinkDbKey(linkKey), oldValue, newValue);
-        return builder;
-    }
-
-    @Override
-    public LinkResourceEvent releaseResources(LinkResourceAllocations allocations) {
-        checkNotNull(allocations);
-
-        final IntentId intendId = allocations.intendId();
-        final String dbIntentId = toIntentDbKey(intendId);
-        final Collection<Link> links = allocations.links();
-
-        boolean success;
-        do {
-            Builder tx = BatchWriteRequest.newBuilder();
-
-            // TODO: Should IntentId -> Allocation be updated conditionally?
-            tx.remove(INTENT_ALLOCATIONS, dbIntentId);
-
-            for (Link link : links) {
-                final LinkKey linkId = LinkKey.linkKey(link);
-                final String dbLinkId = toLinkDbKey(linkId);
-                VersionedValue vv = databaseService.get(LINK_RESOURCE_ALLOCATIONS, dbLinkId);
-                if (vv == null || vv.value() == null) {
-                    // something is wrong, but it is already freed
-                    log.warn("There was no resource left to release on {}", linkId);
-                    continue;
-                }
-                List<LinkResourceAllocations> before = decodeLinkAllocations(vv.value());
-                List<LinkResourceAllocations> after = new ArrayList<>(before);
-                after.remove(allocations);
-                byte[] oldValue = encodeLinkAllocations(before);
-                byte[] newValue = encodeLinkAllocations(after);
-                tx.putIfValueMatches(LINK_RESOURCE_ALLOCATIONS, dbLinkId, oldValue, newValue);
-            }
-
-            BatchWriteResult batchWrite = databaseService.batchWrite(tx.build());
-            success = batchWrite.isSuccessful();
-        } while (!success);
-
-        // Issue events to force recompilation of intents.
-
-        final List<LinkResourceAllocations> releasedResources = ImmutableList.of(allocations);
-        return new LinkResourceEvent(
-                LinkResourceEvent.Type.ADDITIONAL_RESOURCES_AVAILABLE,
-                releasedResources);
-    }
-
-    @Override
-    public LinkResourceAllocations getAllocations(IntentId intentId) {
-        checkNotNull(intentId);
-        VersionedValue vv = databaseService.get(INTENT_ALLOCATIONS, toIntentDbKey(intentId));
-        if (vv == null) {
-            return null;
-        }
-        LinkResourceAllocations allocations = decodeIntentAllocations(vv.value());
-        return allocations;
-    }
-
-    private String toLinkDbKey(LinkKey linkid) {
-//         introduce cache if necessary
-        return linkid.toString();
-//         Note: Above is irreversible, if we need reverse conversion
-//         we may need something like below, due to String only limitation
-//         byte[] bytes = serializer.encode(linkid);
-//         StringBuilder builder = new StringBuilder(bytes.length * 4);
-//         boolean isFirst = true;
-//         for (byte b : bytes) {
-//         if (!isFirst) {
-//         builder.append(',');
-//         }
-//         builder.append(b);
-//         isFirst = false;
-//         }
-//         return builder.toString();
-    }
-
-//     private LinkKey toLinkKey(String linkKey) {
-//     String[] bytes = linkKey.split(",");
-//     ByteBuffer buf = ByteBuffer.allocate(bytes.length);
-//     for (String bs : bytes) {
-//     buf.put(Byte.parseByte(bs));
-//     }
-//     buf.flip();
-//     return serializer.decode(buf);
-//     }
-
-    private String toIntentDbKey(IntentId intentid) {
-        return intentid.toString();
-    }
-
-    private IntentId toIntentId(String intentid) {
-        checkArgument(intentid.startsWith("0x"));
-        return IntentId.valueOf(Long.parseLong(intentid.substring(2)));
-    }
-
-    private LinkResourceAllocations decodeIntentAllocations(byte[] bytes) {
-        return serializer.decode(bytes);
-    }
-
-    private byte[] encodeIntentAllocations(LinkResourceAllocations alloc) {
-        return serializer.encode(checkNotNull(alloc));
-    }
-
-    private List<LinkResourceAllocations> decodeLinkAllocations(byte[] bytes) {
-        return serializer.decode(bytes);
-    }
-
-    private byte[] encodeLinkAllocations(List<LinkResourceAllocations> alloc) {
-        return serializer.encode(checkNotNull(alloc));
-    }
-
-    @Override
-    public List<LinkResourceAllocations> getAllocations(Link link) {
-        checkNotNull(link);
-        final LinkKey key = LinkKey.linkKey(link);
-        final String dbKey = toLinkDbKey(key);
-        VersionedValue vv = databaseService.get(LINK_RESOURCE_ALLOCATIONS, dbKey);
-        if (vv == null) {
-            // write empty so that all other update can be replace operation
-            byte[] emptyList = encodeLinkAllocations(new ArrayList<>());
-            boolean written = databaseService.putIfAbsent(LINK_RESOURCE_ALLOCATIONS, dbKey, emptyList);
-            log.trace("Empty allocation write success? {}", written);
-            vv = databaseService.get(LINK_RESOURCE_ALLOCATIONS, dbKey);
-            if (vv == null) {
-                log.error("Failed to re-read allocation for {}", dbKey);
-                // note: cannot be Collections.emptyList();
-                return new ArrayList<>();
-            }
-        }
-        List<LinkResourceAllocations> allocations = decodeLinkAllocations(vv.value());
-        return allocations;
-    }
-
-    @Override
-    public Iterable<LinkResourceAllocations> getAllocations() {
-        //IntentId -> LinkResourceAllocations
-        Map<String, VersionedValue> all = databaseService.getAll(INTENT_ALLOCATIONS);
-
-        return FluentIterable.from(all.values())
-                .transform(new Function<VersionedValue, LinkResourceAllocations>() {
-
-                               @Override
-                               public LinkResourceAllocations apply(VersionedValue input) {
-                                   if (input == null || input.value() == null) {
-                                       return null;
-                                   }
-                                   return decodeIntentAllocations(input.value());
-                               }
-                           })
-                           .filter(notNull());
-    }
-}
diff --git a/core/store/dist/src/main/java/org/onosproject/store/service/impl/CMap.java b/core/store/dist/src/main/java/org/onosproject/store/service/impl/CMap.java
deleted file mode 100644
index 36af5b7..0000000
--- a/core/store/dist/src/main/java/org/onosproject/store/service/impl/CMap.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Copyright 2014 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.store.service.impl;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Predicates.notNull;
-
-import java.util.Map;
-
-import org.onosproject.store.serializers.StoreSerializer;
-import org.onosproject.store.service.DatabaseAdminService;
-import org.onosproject.store.service.DatabaseException;
-import org.onosproject.store.service.DatabaseService;
-import org.onosproject.store.service.VersionedValue;
-
-import com.google.common.base.Function;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
-import com.google.common.collect.FluentIterable;
-
-/**
- * Map like interface wrapper around DatabaseService.
- *
- * @param <K> Key type of the map.
- *       The type must have toString(), which can uniquely identify the entry.
- * @param <V> Value type
- */
-public class CMap<K, V> {
-
-    @SuppressWarnings("unused")
-    private final DatabaseAdminService dbAdminService;
-
-    private final DatabaseService dbService;
-
-    private final String tableName;
-    private final StoreSerializer serializer;
-
-    private final LoadingCache<K, String> keyCache;
-
-    /**
-     * Creates a CMap instance.
-     * It will create the table if necessary.
-     *
-     * @param dbAdminService DatabaseAdminService to use for this instance
-     * @param dbService DatabaseService to use for this instance
-     * @param tableName table which this Map corresponds to
-     * @param serializer Value serializer
-     */
-    public CMap(DatabaseAdminService dbAdminService,
-                DatabaseService dbService,
-                String tableName,
-                StoreSerializer serializer) {
-
-        this.dbAdminService = checkNotNull(dbAdminService);
-        this.dbService = checkNotNull(dbService);
-        this.tableName = checkNotNull(tableName);
-        this.serializer = checkNotNull(serializer);
-
-        boolean tableReady = false;
-        do {
-            try {
-                if (!dbAdminService.listTables().contains(tableName)) {
-                    dbAdminService.createTable(tableName);
-                }
-                tableReady = true;
-            } catch (DatabaseException e) {
-                try {
-                    Thread.sleep(200);
-                } catch (InterruptedException e1) {
-                    throw new DatabaseException(e1);
-                }
-            }
-        } while (!tableReady);
-
-        keyCache = CacheBuilder.newBuilder()
-                    .softValues()
-                    .build(new CacheLoader<K, String>() {
-
-                        @Override
-                        public String load(K key) {
-                            return key.toString();
-                        }
-                    });
-    }
-
-    protected String sK(K key) {
-        return keyCache.getUnchecked(key);
-    }
-
-    protected byte[] sV(V val) {
-        return serializer.encode(val);
-    }
-
-    protected V dV(byte[] valBytes) {
-        return serializer.decode(valBytes);
-    }
-
-    /**
-     * Puts an entry to the map, if not already present.
-     *
-     * @param key the key of the value to put if absent
-     * @param value the value to be put if previous value does not exist
-     * @return true if put was successful.
-     */
-    public boolean putIfAbsent(K key, V value) {
-        return dbService.putIfAbsent(tableName, sK(key), sV(value));
-    }
-
-    /**
-     * Removes an entry associated to specified key.
-     *
-     * @param key key of the value to remove
-     * @return previous value in the map for the key
-     */
-    public V remove(K key) {
-        VersionedValue removed = dbService.remove(tableName, sK(key));
-        if (removed == null) {
-            return null;
-        }
-        return dV(removed.value());
-    }
-
-    /**
-     * Returns the size of the map.
-     *
-     * @return size of the map
-     */
-    public long size() {
-        // TODO this is very inefficient
-        return dbService.getAll(tableName).size();
-    }
-
-    /**
-     * Returns all the values contained in the map.
-     *
-     * @return values containd in this map
-     */
-    public Iterable<V> values() {
-        Map<String, VersionedValue> all = dbService.getAll(tableName);
-        return FluentIterable.from(all.values())
-                .transform(new Function<VersionedValue, V>() {
-
-                    @Override
-                    public V apply(VersionedValue input) {
-                        if (input == null) {
-                            return null;
-                        }
-                        return dV(input.value());
-                    }
-                })
-                .filter(notNull());
-    }
-
-    /**
-     * Gets the value in the map.
-     *
-     * @param key to get from the map
-     * @return value associated with the key, null if not such entry
-     */
-    public V get(K key) {
-        VersionedValue vv = dbService.get(tableName, sK(key));
-        if (vv == null) {
-            return null;
-        }
-        return dV(vv.value());
-    }
-
-    /**
-     * Replaces the value in the map if the value matches the expected.
-     *
-     * @param key of the entry to replace
-     * @param oldVal value expected to be in the map
-     * @param newVal value to be replaced with
-     * @return true if successfully replaced
-     */
-    public boolean replace(K key, V oldVal, V newVal) {
-        return dbService.putIfValueMatches(tableName, sK(key), sV(oldVal), sV(newVal));
-    }
-
-    /**
-     * Puts a value int the map.
-     *
-     * @param key key with which the specified value is to be associated
-     * @param value value to be associated with the specified key
-     * @return previous value or null if not such entry
-     */
-    public V put(K key, V value) {
-        VersionedValue vv = dbService.put(tableName, sK(key), sV(value));
-        if (vv == null) {
-            return null;
-        }
-        return dV(vv.value());
-    }
-}
diff --git a/core/store/dist/src/main/java/org/onosproject/store/service/impl/package-info.java b/core/store/dist/src/main/java/org/onosproject/store/service/impl/package-info.java
deleted file mode 100644
index c6013b3..0000000
--- a/core/store/dist/src/main/java/org/onosproject/store/service/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Utility services and backing mechanisms for implementations of distributed stores.
- */
-package org.onosproject.store.service.impl;
\ No newline at end of file
diff --git a/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java b/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java
index 4e9fe4f..b20451e 100644
--- a/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java
+++ b/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java
@@ -18,6 +18,7 @@
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
+
 import org.onlab.packet.ChassisId;
 import org.onlab.packet.Ip4Address;
 import org.onlab.packet.Ip4Prefix;
@@ -119,15 +120,7 @@
 import org.onosproject.net.resource.MplsLabelResourceAllocation;
 import org.onosproject.net.resource.MplsLabelResourceRequest;
 import org.onosproject.store.Timestamp;
-import org.onosproject.store.service.BatchReadRequest;
-import org.onosproject.store.service.BatchWriteRequest;
-import org.onosproject.store.service.ReadRequest;
-import org.onosproject.store.service.ReadResult;
-import org.onosproject.store.service.ReadStatus;
-import org.onosproject.store.service.VersionedValue;
-import org.onosproject.store.service.WriteRequest;
-import org.onosproject.store.service.WriteResult;
-import org.onosproject.store.service.WriteStatus;
+import org.onosproject.store.service.Versioned;
 
 import java.net.URI;
 import java.time.Duration;
@@ -339,16 +332,7 @@
             .register(new MastershipTermSerializer(), MastershipTerm.class)
             .register(new HostLocationSerializer(), HostLocation.class)
             .register(new DefaultOutboundPacketSerializer(), DefaultOutboundPacket.class)
-            .register(ReadRequest.class)
-            .register(WriteRequest.class)
-            .register(WriteRequest.Type.class)
-            .register(WriteResult.class)
-            .register(ReadResult.class)
-            .register(BatchReadRequest.class)
-            .register(BatchWriteRequest.class)
-            .register(ReadStatus.class)
-            .register(WriteStatus.class)
-            .register(VersionedValue.class)
+            .register(Versioned.class)
             .register(DefaultGroupId.class)
             .register(
                     MplsIntent.class,