diff --git a/apps/l2lb/src/main/java/org/onosproject/l2lb/api/L2Lb.java b/apps/l2lb/src/main/java/org/onosproject/l2lb/api/L2Lb.java
deleted file mode 100644
index 633af1e..0000000
--- a/apps/l2lb/src/main/java/org/onosproject/l2lb/api/L2Lb.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright 2018-present Open Networking Foundation
- *
- * 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.l2lb.api;
-
-import org.onosproject.net.PortNumber;
-
-import java.util.Objects;
-import java.util.Set;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-/**
- * Represents L2 load balancer information.
- */
-public class L2Lb {
-    private L2LbId l2LbId;
-    private Set<PortNumber> ports;
-    private L2LbMode mode;
-
-    /**
-     * Constructs a L2 load balancer.
-     *
-     * @param l2LbId L2 load balancer ID
-     * @param ports Set of member ports
-     * @param mode L2 load balancer mode
-     */
-    public L2Lb(L2LbId l2LbId, Set<PortNumber> ports, L2LbMode mode) {
-        this.l2LbId = l2LbId;
-        this.ports = ports;
-        this.mode = mode;
-    }
-
-    /**
-     * Gets L2 load balancer ID.
-     *
-     * @return L2 load balancer ID
-     */
-    public L2LbId l2LbId() {
-        return l2LbId;
-    }
-
-    /**
-     * Gets set of member ports.
-     *
-     * @return Set of member ports
-     */
-    public Set<PortNumber> ports() {
-        return ports;
-    }
-
-    /**
-     * Gets L2 load balancer mode.
-     *
-     * @return L2 load balancer mode.
-     */
-    public L2LbMode mode() {
-        return mode;
-    }
-
-    /**
-     * Gets L2 load balancer data.
-     *
-     * @return L2 load balancer data
-     */
-    public L2LbData data() {
-        return new L2LbData(l2LbId);
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(l2LbId, ports, mode);
-    }
-
-    @Override
-    public boolean equals(final Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (!(obj instanceof L2Lb)) {
-            return false;
-        }
-        final L2Lb other = (L2Lb) obj;
-
-        return Objects.equals(this.l2LbId, other.l2LbId) &&
-                Objects.equals(this.ports, other.ports) &&
-                this.mode == other.mode;
-    }
-
-    @Override
-    public String toString() {
-        return toStringHelper(getClass())
-                .add("l2LbId", l2LbId)
-                .add("ports", ports)
-                .add("mode", mode)
-                .toString();
-    }
-}
diff --git a/apps/l2lb/src/main/java/org/onosproject/l2lb/api/L2LbAdminService.java b/apps/l2lb/src/main/java/org/onosproject/l2lb/api/L2LbAdminService.java
deleted file mode 100644
index d5042d0..0000000
--- a/apps/l2lb/src/main/java/org/onosproject/l2lb/api/L2LbAdminService.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright 2018-present Open Networking Foundation
- *
- * 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.l2lb.api;
-
-import org.onosproject.net.PortNumber;
-
-import java.util.Set;
-
-/**
- * L2 load balancer admin service.
- */
-public interface L2LbAdminService {
-    /**
-     * Creates or updates a L2 load balancer.
-     *
-     * @param l2LbId L2 load balancer id
-     * @param ports physical ports in the L2 load balancer
-     * @param mode L2 load balancer mode
-     * @return L2 load balancer that is created or updated
-     */
-    L2Lb createOrUpdate(L2LbId l2LbId, Set<PortNumber> ports, L2LbMode mode);
-
-    /**
-     * Removes a L2 load balancer.
-     *
-     * @param l2LbId L2 load balancer id
-     * @return L2 load balancer that is removed or null if it was not possible
-     */
-    L2Lb remove(L2LbId l2LbId);
-
-}
diff --git a/apps/l2lb/src/main/java/org/onosproject/l2lb/api/L2LbData.java b/apps/l2lb/src/main/java/org/onosproject/l2lb/api/L2LbData.java
deleted file mode 100644
index d50dbbd..0000000
--- a/apps/l2lb/src/main/java/org/onosproject/l2lb/api/L2LbData.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright 2018-present Open Networking Foundation
- *
- * 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.l2lb.api;
-
-
-import java.util.Objects;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-/**
- * Represents L2 load balancer event data.
- */
-public class L2LbData {
-
-    // We exchange only id and nextid in the events
-    private L2LbId l2LbId;
-    private int nextId;
-
-    /**
-     * Constructs a L2 load balancer data.
-     *
-     * @param l2LbId L2 load balancer ID
-     */
-    public L2LbData(L2LbId l2LbId) {
-        this.l2LbId = l2LbId;
-        this.nextId = -1;
-    }
-
-    /**
-     * Constructs a L2 load balancer data.
-     *
-     * @param l2LbId L2 load balancer ID
-     * @param nextId L2 load balancer next id
-     */
-    public L2LbData(L2LbId l2LbId, int nextId) {
-        this.l2LbId = l2LbId;
-        this.nextId = nextId;
-    }
-
-    /**
-     * Gets L2 load balancer ID.
-     *
-     * @return L2 load balancer ID
-     */
-    public L2LbId l2LbId() {
-        return l2LbId;
-    }
-
-    /**
-     * Gets L2 load balancer next id.
-     *
-     * @return L2 load balancer next id
-     */
-    public int nextId() {
-        return nextId;
-    }
-
-    /**
-     * Sets L2 load balancer next id.
-     *
-     * @param nextId L2 load balancer next id
-     */
-    public void setNextId(int nextId) {
-        this.nextId = nextId;
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(l2LbId, nextId);
-    }
-
-    @Override
-    public boolean equals(final Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (!(obj instanceof L2LbData)) {
-            return false;
-        }
-        final L2LbData other = (L2LbData) obj;
-
-        return Objects.equals(this.l2LbId, other.l2LbId) &&
-                this.nextId == other.nextId;
-    }
-
-    @Override
-    public String toString() {
-        return toStringHelper(getClass())
-                .add("l2LbId", l2LbId)
-                .add("nextId", nextId)
-                .toString();
-    }
-}
diff --git a/apps/l2lb/src/main/java/org/onosproject/l2lb/api/L2LbEvent.java b/apps/l2lb/src/main/java/org/onosproject/l2lb/api/L2LbEvent.java
deleted file mode 100644
index 96cb3b8..0000000
--- a/apps/l2lb/src/main/java/org/onosproject/l2lb/api/L2LbEvent.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright 2018-present Open Networking Foundation
- *
- * 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.l2lb.api;
-
-import org.onlab.util.Tools;
-import org.onosproject.event.AbstractEvent;
-import java.util.Objects;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-/**
- * L2 load balancer event.
- */
-public class L2LbEvent extends AbstractEvent<L2LbEvent.Type, L2LbData> {
-
-    private L2LbData prevSubject;
-
-    /**
-     * L2 load balancer event type.
-     */
-    public enum Type {
-        ADDED,
-        REMOVED,
-        UPDATED,
-        INSTALLED,
-        UNINSTALLED,
-        FAILED
-    }
-
-    /**
-     * Constructs a L2 load balancer event.
-     *
-     * @param type event type
-     * @param subject current L2 load balancer information
-     * @param prevSubject previous L2 load balancer information
-     */
-    public L2LbEvent(Type type, L2LbData subject, L2LbData prevSubject) {
-        super(type, subject);
-        this.prevSubject = prevSubject;
-    }
-
-    /**
-     * Gets previous L2 load balancer information.
-     *
-     * @return previous subject
-     */
-    public L2LbData prevSubject() {
-        return prevSubject;
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(subject(), time(), prevSubject);
-    }
-
-    @Override
-    public boolean equals(Object other) {
-        if (this == other) {
-            return true;
-        }
-
-        if (!(other instanceof L2LbEvent)) {
-            return false;
-        }
-
-        L2LbEvent that = (L2LbEvent) other;
-        return Objects.equals(this.subject(), that.subject()) &&
-                Objects.equals(this.type(), that.type()) &&
-                Objects.equals(this.prevSubject, that.prevSubject);
-    }
-
-    @Override
-    public String toString() {
-        return toStringHelper(this)
-                .add("type", type())
-                .add("subject", subject())
-                .add("prevSubject", prevSubject)
-                .add("time", Tools.defaultOffsetDataTime(time()))
-                .toString();
-    }
-}
diff --git a/apps/l2lb/src/main/java/org/onosproject/l2lb/api/L2LbService.java b/apps/l2lb/src/main/java/org/onosproject/l2lb/api/L2LbService.java
deleted file mode 100644
index 50a6c79..0000000
--- a/apps/l2lb/src/main/java/org/onosproject/l2lb/api/L2LbService.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright 2018-present Open Networking Foundation
- *
- * 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.l2lb.api;
-
-import org.onosproject.core.ApplicationId;
-import org.onosproject.event.ListenerService;
-
-import java.util.Map;
-
-/**
- * L2 load balance service.
- */
-public interface L2LbService extends ListenerService<L2LbEvent, L2LbListener> {
-    /**
-     * Gets all L2 load balancers from the store.
-     *
-     * @return L2 load balancer ID and L2 load balancer information mapping
-     */
-    Map<L2LbId, L2Lb> getL2Lbs();
-
-    /**
-     * Gets L2 load balancer that matches given device ID and key, or null if not found.
-     *
-     * @param l2LbId L2 load balancer id
-     * @return L2 load balancer information
-     */
-    L2Lb getL2Lb(L2LbId l2LbId);
-
-    /**
-     * Gets the mapping between L2 load balancer id and
-     * the next objective id that represents the L2 load balancer.
-     *
-     * @return L2 load balancer id and next id mapping
-     */
-    Map<L2LbId, Integer> getL2LbNexts();
-
-    /**
-     * Gets L2 load balancer next id that matches given device Id and key, or null if not found.
-     *
-     * @param l2LbId L2 load balancer id
-     * @return next ID
-     */
-    int getL2LbNext(L2LbId l2LbId);
-
-    /**
-     * Reserves a l2 load balancer. Only one application
-     * at time can reserve a given l2 load balancer.
-     *
-     * @param l2LbId the l2 load balancer id
-     * @param appId the application id
-     * @return true if reservation was successful false otherwise
-     */
-    boolean reserve(L2LbId l2LbId, ApplicationId appId);
-
-    /**
-     * Releases a l2 load balancer. Once released
-     * by the owner the l2 load balancer is eligible
-     * for removal.
-     *
-     * @param l2LbId the l2 load balancer id
-     * @param appId the application id
-     * @return true if release was successful false otherwise
-     */
-    boolean release(L2LbId l2LbId, ApplicationId appId);
-
-    /**
-     * Gets reservation of a l2 load balancer. Only one application
-     * at time can reserve a given l2 load balancer.
-     *
-     * @param l2LbId the l2 load balancer id
-     * @return the id of the application using the l2 load balancer
-     */
-    ApplicationId getReservation(L2LbId l2LbId);
-
-    /**
-     * Gets l2 load balancer reservations. Only one application
-     * at time can reserve a given l2 load balancer.
-     *
-     * @return reservations of the l2 load balancer resources
-     */
-    Map<L2LbId, ApplicationId> getReservations();
-
-}
diff --git a/apps/l2lb/src/main/java/org/onosproject/l2lb/api/package-info.java b/apps/l2lb/src/main/java/org/onosproject/l2lb/api/package-info.java
deleted file mode 100644
index 862428b..0000000
--- a/apps/l2lb/src/main/java/org/onosproject/l2lb/api/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2018-present Open Networking Foundation
- *
- * 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.
- */
-
-/**
- * L2 load balancer API.
- */
-package org.onosproject.l2lb.api;
\ No newline at end of file
diff --git a/apps/l2lb/src/main/java/org/onosproject/l2lb/app/L2LbManager.java b/apps/l2lb/src/main/java/org/onosproject/l2lb/app/L2LbManager.java
deleted file mode 100644
index 9ce540d..0000000
--- a/apps/l2lb/src/main/java/org/onosproject/l2lb/app/L2LbManager.java
+++ /dev/null
@@ -1,597 +0,0 @@
-/*
- * Copyright 2018-present Open Networking Foundation
- *
- * 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.l2lb.app;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Sets;
-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.KryoNamespace;
-import org.onosproject.cluster.ClusterService;
-import org.onosproject.cluster.LeadershipService;
-import org.onosproject.cluster.NodeId;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.l2lb.api.L2Lb;
-import org.onosproject.l2lb.api.L2LbData;
-import org.onosproject.l2lb.api.L2LbEvent;
-import org.onosproject.l2lb.api.L2LbAdminService;
-import org.onosproject.l2lb.api.L2LbId;
-import org.onosproject.l2lb.api.L2LbListener;
-import org.onosproject.l2lb.api.L2LbMode;
-import org.onosproject.l2lb.api.L2LbService;
-import org.onosproject.mastership.MastershipService;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.device.DeviceEvent;
-import org.onosproject.net.device.DeviceListener;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.flow.DefaultTrafficSelector;
-import org.onosproject.net.flow.DefaultTrafficTreatment;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.flow.instructions.Instruction;
-import org.onosproject.net.flow.instructions.Instructions;
-import org.onosproject.net.flowobjective.DefaultNextObjective;
-import org.onosproject.net.flowobjective.DefaultNextTreatment;
-import org.onosproject.net.flowobjective.FlowObjectiveService;
-import org.onosproject.net.flowobjective.NextObjective;
-import org.onosproject.net.flowobjective.Objective;
-import org.onosproject.net.flowobjective.ObjectiveContext;
-import org.onosproject.net.flowobjective.ObjectiveError;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.ConsistentMap;
-import org.onosproject.store.service.MapEvent;
-import org.onosproject.store.service.MapEventListener;
-import org.onosproject.store.service.Serializer;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.store.service.Versioned;
-import org.slf4j.Logger;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.stream.Collectors;
-
-import static org.onlab.util.Tools.groupedThreads;
-import static org.slf4j.LoggerFactory.getLogger;
-
-@Component(immediate = true)
-@Service
-public class L2LbManager implements L2LbService, L2LbAdminService {
-
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
-    private CoreService coreService;
-
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
-    private StorageService storageService;
-
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
-    private FlowObjectiveService flowObjService;
-
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
-    private MastershipService mastershipService;
-
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
-    private LeadershipService leadershipService;
-
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
-    private ClusterService clusterService;
-
-    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
-    private DeviceService deviceService;
-
-    private static final Logger log = getLogger(L2LbManager.class);
-    private static final String APP_NAME = "org.onosproject.l2lb";
-
-    private ApplicationId appId;
-    private ConsistentMap<L2LbId, L2Lb> l2LbStore;
-    private ConsistentMap<L2LbId, Integer> l2LbNextStore;
-    // TODO Evaluate if ResourceService is a better option
-    private ConsistentMap<L2LbId, ApplicationId> l2LbResStore;
-    private Set<L2LbListener> listeners = Sets.newConcurrentHashSet();
-
-    private ExecutorService l2LbEventExecutor;
-    private ExecutorService l2LbProvExecutor;
-    private ExecutorService deviceEventExecutor;
-
-    private MapEventListener<L2LbId, L2Lb> l2LbStoreListener;
-    // TODO build CLI to view and clear the next store
-    private MapEventListener<L2LbId, Integer> l2LbNextStoreListener;
-    private MapEventListener<L2LbId, ApplicationId> l2LbResStoreListener;
-    private final DeviceListener deviceListener = new InternalDeviceListener();
-
-    @Activate
-    public void activate() {
-        appId = coreService.registerApplication(APP_NAME);
-
-        l2LbEventExecutor = Executors.newSingleThreadExecutor(
-                groupedThreads("l2lb-event", "%d", log));
-        l2LbProvExecutor = Executors.newSingleThreadExecutor(
-                groupedThreads("l2lb-prov", "%d", log));
-        deviceEventExecutor = Executors.newSingleThreadScheduledExecutor(
-                groupedThreads("l2lb-dev-event", "%d", log));
-        l2LbStoreListener = new L2LbStoreListener();
-        l2LbNextStoreListener = new L2LbNextStoreListener();
-        l2LbResStoreListener = new L2LbResStoreListener();
-
-        KryoNamespace serializer = KryoNamespace.newBuilder()
-                .register(KryoNamespaces.API)
-                .register(L2Lb.class)
-                .register(L2LbId.class)
-                .register(L2LbMode.class)
-                .build();
-        l2LbStore = storageService.<L2LbId, L2Lb>consistentMapBuilder()
-                .withName("onos-l2lb-store")
-                .withRelaxedReadConsistency()
-                .withSerializer(Serializer.using(serializer))
-                .build();
-        l2LbStore.addListener(l2LbStoreListener);
-        l2LbNextStore = storageService.<L2LbId, Integer>consistentMapBuilder()
-                .withName("onos-l2lb-next-store")
-                .withRelaxedReadConsistency()
-                .withSerializer(Serializer.using(serializer))
-                .build();
-        l2LbNextStore.addListener(l2LbNextStoreListener);
-        l2LbResStore = storageService.<L2LbId, ApplicationId>consistentMapBuilder()
-                .withName("onos-l2lb-res-store")
-                .withRelaxedReadConsistency()
-                .withSerializer(Serializer.using(serializer))
-                .build();
-        l2LbResStore.addListener(l2LbResStoreListener);
-
-        deviceService.addListener(deviceListener);
-
-        log.info("Started");
-    }
-
-    @Deactivate
-    public void deactivate() {
-        l2LbStore.removeListener(l2LbStoreListener);
-        l2LbNextStore.removeListener(l2LbNextStoreListener);
-
-        l2LbEventExecutor.shutdown();
-        l2LbProvExecutor.shutdown();
-        deviceEventExecutor.shutdown();
-
-        log.info("Stopped");
-    }
-
-    @Override
-    public void addListener(L2LbListener listener) {
-        listeners.add(listener);
-    }
-
-    @Override
-    public void removeListener(L2LbListener listener) {
-        listeners.remove(listener);
-    }
-
-    @Override
-    public L2Lb createOrUpdate(L2LbId l2LbId, Set<PortNumber> ports, L2LbMode mode) {
-        log.debug("Putting {} -> {} {} into L2 load balancer store", l2LbId, mode, ports);
-        return Versioned.valueOrNull(l2LbStore.put(l2LbId, new L2Lb(l2LbId, ports, mode)));
-    }
-
-    @Override
-    public L2Lb remove(L2LbId l2LbId) {
-        ApplicationId reservation = Versioned.valueOrNull(l2LbResStore.get(l2LbId));
-        // Remove only if it is not used - otherwise it is necessary to release first
-        if (reservation == null) {
-            log.debug("Removing {} from L2 load balancer store", l2LbId);
-            return Versioned.valueOrNull(l2LbStore.remove(l2LbId));
-        }
-        log.warn("Removal {} from L2 load balancer store was not possible " +
-                          "due to a previous reservation", l2LbId);
-        return null;
-    }
-
-    @Override
-    public Map<L2LbId, L2Lb> getL2Lbs() {
-        return ImmutableMap.copyOf(l2LbStore.asJavaMap());
-    }
-
-    @Override
-    public L2Lb getL2Lb(L2LbId l2LbId) {
-        return Versioned.valueOrNull(l2LbStore.get(l2LbId));
-    }
-
-    @Override
-    public Map<L2LbId, Integer> getL2LbNexts() {
-        return ImmutableMap.copyOf(l2LbNextStore.asJavaMap());
-    }
-
-    @Override
-    public int getL2LbNext(L2LbId l2LbId) {
-        return Versioned.valueOrNull(l2LbNextStore.get(l2LbId));
-    }
-
-    @Override
-    public boolean reserve(L2LbId l2LbId, ApplicationId appId) {
-        // Check if the resource is available
-        ApplicationId reservation = Versioned.valueOrNull(l2LbResStore.get(l2LbId));
-        L2Lb l2Lb = Versioned.valueOrNull(l2LbStore.get(l2LbId));
-        if (reservation == null && l2Lb != null) {
-            log.debug("Reserving {} -> {} into L2 load balancer reservation store", l2LbId, appId);
-            return l2LbResStore.put(l2LbId, appId) == null;
-        } else if (reservation != null && reservation.equals(appId)) {
-            // App try to reserve the resource a second time
-            log.debug("Already reserved {} -> {} skip reservation", l2LbId, appId);
-            return true;
-        }
-        log.warn("Reservation failed {} -> {}", l2LbId, appId);
-        return false;
-    }
-
-    @Override
-    public boolean release(L2LbId l2LbId, ApplicationId appId) {
-        // Check if the resource is reserved
-        ApplicationId reservation = Versioned.valueOrNull(l2LbResStore.get(l2LbId));
-        if (reservation != null && reservation.equals(appId)) {
-            log.debug("Removing {} -> {} from L2 load balancer reservation store", l2LbId, appId);
-            return l2LbResStore.remove(l2LbId) != null;
-        }
-        log.warn("Release failed {} -> {}", l2LbId, appId);
-        return false;
-    }
-
-    @Override
-    public ApplicationId getReservation(L2LbId l2LbId) {
-        return Versioned.valueOrNull(l2LbResStore.get(l2LbId));
-    }
-
-    @Override
-    public Map<L2LbId, ApplicationId> getReservations() {
-        return l2LbResStore.asJavaMap();
-    }
-
-    private class L2LbStoreListener implements MapEventListener<L2LbId, L2Lb> {
-        public void event(MapEvent<L2LbId, L2Lb> event) {
-            switch (event.type()) {
-                case INSERT:
-                    log.debug("L2Lb {} insert new={}, old={}", event.key(), event.newValue(), event.oldValue());
-                    post(new L2LbEvent(L2LbEvent.Type.ADDED, event.newValue().value().data(), null));
-                    populateL2Lb(event.newValue().value());
-                    break;
-                case REMOVE:
-                    log.debug("L2Lb {} remove new={}, old={}", event.key(), event.newValue(), event.oldValue());
-                    post(new L2LbEvent(L2LbEvent.Type.REMOVED, null, event.oldValue().value().data()));
-                    revokeL2Lb(event.oldValue().value());
-                    break;
-                case UPDATE:
-                    log.debug("L2Lb {} update new={}, old={}", event.key(), event.newValue(), event.oldValue());
-                    post(new L2LbEvent(L2LbEvent.Type.UPDATED, event.newValue().value().data(),
-                            event.oldValue().value().data()));
-                    updateL2Lb(event.newValue().value(), event.oldValue().value());
-                    break;
-                default:
-                    break;
-            }
-        }
-    }
-
-    private class L2LbNextStoreListener implements MapEventListener<L2LbId, Integer> {
-        public void event(MapEvent<L2LbId, Integer> event) {
-            switch (event.type()) {
-                case INSERT:
-                    log.debug("L2Lb next {} insert new={}, old={}", event.key(), event.newValue(), event.oldValue());
-                    break;
-                case REMOVE:
-                    log.debug("L2Lb next {} remove new={}, old={}", event.key(), event.newValue(), event.oldValue());
-                    break;
-                case UPDATE:
-                    log.debug("L2Lb next {} update new={}, old={}", event.key(), event.newValue(), event.oldValue());
-                    break;
-                default:
-                    break;
-            }
-        }
-    }
-
-    private class L2LbResStoreListener implements MapEventListener<L2LbId, ApplicationId> {
-        public void event(MapEvent<L2LbId, ApplicationId> event) {
-            switch (event.type()) {
-                case INSERT:
-                    log.debug("L2Lb reservation {} insert new={}, old={}", event.key(), event.newValue(),
-                              event.oldValue());
-                    break;
-                case REMOVE:
-                    log.debug("L2Lb reservation {} remove new={}, old={}", event.key(), event.newValue(),
-                              event.oldValue());
-                    break;
-                case UPDATE:
-                    log.debug("L2Lb reservation {} update new={}, old={}", event.key(), event.newValue(),
-                              event.oldValue());
-                    break;
-                default:
-                    break;
-            }
-        }
-    }
-
-    private class InternalDeviceListener implements DeviceListener {
-        // We want to manage only a subset of events and if we are the leader
-        @Override
-        public void event(DeviceEvent event) {
-            deviceEventExecutor.execute(() -> {
-                DeviceId deviceId = event.subject().id();
-                if (!isLocalLeader(deviceId)) {
-                    log.debug("Not the leader of {}. Skip event {}", deviceId, event);
-                    return;
-                }
-                // Populate or revoke according to the device availability
-                if (deviceService.isAvailable(deviceId)) {
-                    init(deviceId);
-                } else {
-                    cleanup(deviceId);
-                }
-            });
-        }
-        // Some events related to the devices are skipped
-        @Override
-        public boolean isRelevant(DeviceEvent event) {
-            return event.type() == DeviceEvent.Type.DEVICE_ADDED ||
-                    event.type() == DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED ||
-                    event.type() == DeviceEvent.Type.DEVICE_UPDATED;
-        }
-    }
-
-    private void post(L2LbEvent l2LbEvent) {
-        l2LbEventExecutor.execute(() -> {
-            for (L2LbListener l : listeners) {
-                if (l.isRelevant(l2LbEvent)) {
-                    l.event(l2LbEvent);
-                }
-            }
-        });
-    }
-
-    private void init(DeviceId deviceId) {
-        l2LbStore.entrySet().stream()
-                .filter(l2lbentry -> l2lbentry.getKey().deviceId().equals(deviceId))
-                .forEach(l2lbentry -> populateL2Lb(l2lbentry.getValue().value()));
-    }
-
-    private void cleanup(DeviceId deviceId) {
-        l2LbStore.entrySet().stream()
-                .filter(entry -> entry.getKey().deviceId().equals(deviceId))
-                .forEach(entry -> l2LbNextStore.remove(entry.getKey()));
-        log.debug("{} is removed from l2LbNextObjStore", deviceId);
-    }
-
-    private void populateL2Lb(L2Lb l2Lb) {
-        DeviceId deviceId = l2Lb.l2LbId().deviceId();
-        if (!isLocalLeader(deviceId)) {
-            log.debug("Not the leader of {}. Skip populateL2Lb {}", deviceId, l2Lb.l2LbId());
-            return;
-        }
-
-        l2LbProvExecutor.execute(() -> {
-            Integer nextid = Versioned.valueOrNull(l2LbNextStore.get(l2Lb.l2LbId()));
-            if (nextid == null) {
-                // Build a new context and new next objective
-                L2LbObjectiveContext context = new L2LbObjectiveContext(l2Lb.l2LbId());
-                NextObjective nextObj = nextObjBuilder(l2Lb.l2LbId(), l2Lb.ports(), nextid).add(context);
-                // Finally submit, store, and register the resource
-                flowObjService.next(deviceId, nextObj);
-                l2LbNextStore.put(l2Lb.l2LbId(), nextObj.id());
-            } else {
-                log.info("NextObj for {} already exists. Skip populateL2Lb", l2Lb.l2LbId());
-            }
-        });
-    }
-
-    private void revokeL2Lb(L2Lb l2Lb) {
-        DeviceId deviceId = l2Lb.l2LbId().deviceId();
-        if (!isLocalLeader(deviceId)) {
-            log.debug("Not the leader of {}. Skip revokeL2Lb {}", deviceId, l2Lb.l2LbId());
-            return;
-        }
-
-        l2LbProvExecutor.execute(() -> {
-            Integer nextid = Versioned.valueOrNull(l2LbNextStore.get(l2Lb.l2LbId()));
-            if (nextid != null) {
-                // Build a new context and remove old next objective
-                L2LbObjectiveContext context = new L2LbObjectiveContext(l2Lb.l2LbId());
-                NextObjective nextObj = nextObjBuilder(l2Lb.l2LbId(), l2Lb.ports(), nextid).remove(context);
-                // Finally submit and invalidate the store
-                flowObjService.next(deviceId, nextObj);
-                l2LbNextStore.remove(l2Lb.l2LbId());
-            } else {
-                log.info("NextObj for {} does not exist. Skip revokeL2Lb", l2Lb.l2LbId());
-            }
-        });
-    }
-
-    private void updateL2Lb(L2Lb newL2Lb, L2Lb oldL2Lb) {
-        DeviceId deviceId = newL2Lb.l2LbId().deviceId();
-        if (!isLocalLeader(deviceId)) {
-            log.debug("Not the leader of {}. Skip updateL2Lb {}", deviceId, newL2Lb.l2LbId());
-            return;
-        }
-
-        l2LbProvExecutor.execute(() -> {
-            Integer nextid = Versioned.valueOrNull(l2LbNextStore.get(newL2Lb.l2LbId()));
-            if (nextid != null) {
-                // Compute modifications and context
-                L2LbObjectiveContext context = new L2LbObjectiveContext(newL2Lb.l2LbId());
-                Set<PortNumber> portsToBeAdded = Sets.difference(newL2Lb.ports(), oldL2Lb.ports());
-                Set<PortNumber> portsToBeRemoved = Sets.difference(oldL2Lb.ports(), newL2Lb.ports());
-                // and send them to the flowobj subsystem
-                if (!portsToBeAdded.isEmpty()) {
-                    flowObjService.next(deviceId, nextObjBuilder(newL2Lb.l2LbId(), portsToBeAdded, nextid)
-                            .addToExisting(context));
-                } else {
-                    log.debug("NextObj for {} nothing to add", newL2Lb.l2LbId());
-
-                }
-                if (!portsToBeRemoved.isEmpty()) {
-                    flowObjService.next(deviceId, nextObjBuilder(newL2Lb.l2LbId(), portsToBeRemoved, nextid)
-                            .removeFromExisting(context));
-                } else {
-                    log.debug("NextObj for {} nothing to remove", newL2Lb.l2LbId());
-                }
-            } else {
-                log.info("NextObj for {} does not exist. Skip updateL2Lb", newL2Lb.l2LbId());
-            }
-        });
-    }
-
-    private NextObjective.Builder nextObjBuilder(L2LbId l2LbId, Set<PortNumber> ports, Integer nextId) {
-        if (nextId == null) {
-            nextId = flowObjService.allocateNextId();
-        }
-        // This metadata is used to pass the key to the driver.
-        // Some driver, e.g. OF-DPA, will use that information while creating load balancing group.
-        // TODO This is not an actual LAG port. In the future, we should extend metadata structure to carry
-        //      generic information. We should avoid using in_port in the metadata once generic metadata is available.
-        TrafficSelector meta = DefaultTrafficSelector.builder()
-                .matchInPort(PortNumber.portNumber(l2LbId.key())).build();
-        NextObjective.Builder nextObjBuilder = DefaultNextObjective.builder()
-                .withId(nextId)
-                .withMeta(meta)
-                .withType(NextObjective.Type.HASHED)
-                .fromApp(appId);
-        ports.forEach(port -> {
-            TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(port).build();
-            nextObjBuilder.addTreatment(DefaultNextTreatment.of(treatment));
-        });
-        return nextObjBuilder;
-    }
-
-    // Custom-built function, when the device is not available we need a fallback mechanism
-    private boolean isLocalLeader(DeviceId deviceId) {
-        if (!mastershipService.isLocalMaster(deviceId)) {
-            // When the device is available we just check the mastership
-            if (deviceService.isAvailable(deviceId)) {
-                return false;
-            }
-            // Fallback with Leadership service - device id is used as topic
-            NodeId leader = leadershipService.runForLeadership(
-                    deviceId.toString()).leaderNodeId();
-            // Verify if this node is the leader
-            return clusterService.getLocalNode().id().equals(leader);
-        }
-        return true;
-    }
-
-    private final class L2LbObjectiveContext implements ObjectiveContext {
-        private final L2LbId l2LbId;
-
-        private L2LbObjectiveContext(L2LbId l2LbId) {
-            this.l2LbId = l2LbId;
-        }
-
-        @Override
-        public void onSuccess(Objective objective) {
-            NextObjective nextObj = (NextObjective) objective;
-            log.debug("Successfully {} nextobj {} for L2 load balancer {}. NextObj={}",
-                    nextObj.op(), nextObj.id(), l2LbId, nextObj);
-            l2LbProvExecutor.execute(() -> onSuccessHandler(nextObj, l2LbId));
-        }
-
-        @Override
-        public void onError(Objective objective, ObjectiveError error) {
-            NextObjective nextObj = (NextObjective) objective;
-            log.warn("Failed to {} nextobj {} for L2 load balancer {} due to {}. NextObj={}",
-                    nextObj.op(), nextObj.id(), l2LbId, error, nextObj);
-            l2LbProvExecutor.execute(() -> onErrorHandler(nextObj, l2LbId));
-        }
-    }
-
-    private void onSuccessHandler(NextObjective nextObjective, L2LbId l2LbId) {
-        // Operation done
-        L2LbData oldl2LbData = new L2LbData(l2LbId);
-        L2LbData newl2LbData = new L2LbData(l2LbId);
-        // Other operations will not lead to a generation of an event
-        switch (nextObjective.op()) {
-            case ADD:
-                newl2LbData.setNextId(nextObjective.id());
-                post(new L2LbEvent(L2LbEvent.Type.INSTALLED, newl2LbData, oldl2LbData));
-                break;
-            case REMOVE:
-                oldl2LbData.setNextId(nextObjective.id());
-                post(new L2LbEvent(L2LbEvent.Type.UNINSTALLED, newl2LbData, oldl2LbData));
-                break;
-            default:
-                break;
-        }
-    }
-
-    private void onErrorHandler(NextObjective nextObjective, L2LbId l2LbId) {
-        // There was a failure
-        L2LbData l2LbData = new L2LbData(l2LbId);
-        // send FAILED event;
-        switch (nextObjective.op()) {
-            case ADD:
-                // If ADD is failing apps do not know the next id; let's update the store
-                l2LbNextStore.remove(l2LbId);
-                l2LbResStore.remove(l2LbId);
-                l2LbStore.remove(l2LbId);
-                post(new L2LbEvent(L2LbEvent.Type.FAILED, l2LbData, l2LbData));
-                break;
-            case ADD_TO_EXISTING:
-                // If ADD_TO_EXISTING is failing let's remove the failed ports
-                Collection<PortNumber> addedPorts = nextObjective.next().stream()
-                        .flatMap(t -> t.allInstructions().stream())
-                        .filter(i -> i.type() == Instruction.Type.OUTPUT)
-                        .map(i -> ((Instructions.OutputInstruction) i).port())
-                        .collect(Collectors.toList());
-                l2LbStore.compute(l2LbId, (key, value) -> {
-                    if (value != null && value.ports() != null && !value.ports().isEmpty()) {
-                        value.ports().removeAll(addedPorts);
-                    }
-                    return value;
-                });
-                l2LbData.setNextId(nextObjective.id());
-                post(new L2LbEvent(L2LbEvent.Type.FAILED, l2LbData, l2LbData));
-                break;
-            case REMOVE_FROM_EXISTING:
-                // If REMOVE_TO_EXISTING is failing let's re-add the failed ports
-                Collection<PortNumber> removedPorts = nextObjective.next().stream()
-                        .flatMap(t -> t.allInstructions().stream())
-                        .filter(i -> i.type() == Instruction.Type.OUTPUT)
-                        .map(i -> ((Instructions.OutputInstruction) i).port())
-                        .collect(Collectors.toList());
-                l2LbStore.compute(l2LbId, (key, value) -> {
-                    if (value != null && value.ports() != null) {
-                        value.ports().addAll(removedPorts);
-                    }
-                    return value;
-                });
-                l2LbData.setNextId(nextObjective.id());
-                post(new L2LbEvent(L2LbEvent.Type.FAILED, l2LbData, l2LbData));
-                break;
-            case VERIFY:
-            case REMOVE:
-                // If ADD/REMOVE_TO_EXISTING, REMOVE and VERIFY are failing let's send
-                // also the info about the next id
-                l2LbData.setNextId(nextObjective.id());
-                post(new L2LbEvent(L2LbEvent.Type.FAILED, l2LbData, l2LbData));
-                break;
-            default:
-                break;
-        }
-
-    }
-}
\ No newline at end of file
diff --git a/apps/l2lb/src/main/java/org/onosproject/l2lb/app/package-info.java b/apps/l2lb/src/main/java/org/onosproject/l2lb/app/package-info.java
deleted file mode 100644
index 6e155f6..0000000
--- a/apps/l2lb/src/main/java/org/onosproject/l2lb/app/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2018-present Open Networking Foundation
- *
- * 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.
- */
-
-/**
- * L2 load balancer app.
- */
-package org.onosproject.l2lb.app;
\ No newline at end of file
diff --git a/apps/l2lb/src/main/java/org/onosproject/l2lb/cli/L2LbAddCommand.java b/apps/l2lb/src/main/java/org/onosproject/l2lb/cli/L2LbAddCommand.java
deleted file mode 100644
index 92dc677..0000000
--- a/apps/l2lb/src/main/java/org/onosproject/l2lb/cli/L2LbAddCommand.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2018-present Open Networking Foundation
- *
- * 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.l2lb.cli;
-
-import com.google.common.collect.Sets;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.l2lb.api.L2Lb;
-import org.onosproject.l2lb.api.L2LbAdminService;
-import org.onosproject.l2lb.api.L2LbId;
-import org.onosproject.l2lb.api.L2LbMode;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-
-import java.util.Set;
-import java.util.stream.Collectors;
-
-/**
- * Command to add a L2 load balancer.
- */
-@Command(scope = "onos", name = "l2lb-add", description = "Create or update L2 load balancer ")
-public class L2LbAddCommand extends AbstractShellCommand {
-    @Argument(index = 0, name = "deviceId",
-            description = "Device ID",
-            required = true, multiValued = false)
-    private String deviceIdStr;
-
-    @Argument(index = 1, name = "key",
-            description = "L2 load balancer key",
-            required = true, multiValued = false)
-    private String keyStr;
-
-    @Argument(index = 2, name = "mode",
-            description = "L2 load balancer mode. STATIC or LACP",
-            required = true, multiValued = false)
-    private String modeStr;
-
-    @Argument(index = 3, name = "ports",
-            description = "L2 load balancer physical ports",
-            required = true, multiValued = true)
-    private String[] portsStr;
-
-    // Operation constants
-    private static final String CREATE = "Create";
-    private static final String UPDATE = "Update";
-
-    @Override
-    protected void execute() {
-        DeviceId deviceId = DeviceId.deviceId(deviceIdStr);
-        int l2LbKey = Integer.parseInt(keyStr);
-
-        L2LbMode mode = L2LbMode.valueOf(modeStr.toUpperCase());
-        Set<PortNumber> ports = Sets.newHashSet(portsStr).stream()
-                .map(PortNumber::fromString).collect(Collectors.toSet());
-
-        L2LbAdminService l2LbAdminService = get(L2LbAdminService.class);
-        L2LbId l2LbId = new L2LbId(deviceId, l2LbKey);
-        L2Lb l2Lb = l2LbAdminService.createOrUpdate(l2LbId, ports, mode);
-        print("%s of %s executed", l2Lb == null ? CREATE : UPDATE, l2LbId);
-
-    }
-}
diff --git a/apps/l2lb/src/main/java/org/onosproject/l2lb/cli/L2LbListCommand.java b/apps/l2lb/src/main/java/org/onosproject/l2lb/cli/L2LbListCommand.java
deleted file mode 100644
index da4b2c1..0000000
--- a/apps/l2lb/src/main/java/org/onosproject/l2lb/cli/L2LbListCommand.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2018-present Open Networking Foundation
- *
- * 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.l2lb.cli;
-
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.l2lb.api.L2Lb;
-import org.onosproject.l2lb.api.L2LbId;
-import org.onosproject.l2lb.api.L2LbService;
-
-import java.util.Map;
-
-/**
- * Command to show all L2 load balancers.
- */
-@Command(scope = "onos", name = "l2lbs", description = "Lists L2 load balancers")
-public class L2LbListCommand extends AbstractShellCommand {
-
-    // Operation constant
-    private static final String AVAILABLE = "Available";
-
-    @Override
-    public void execute() {
-        L2LbService service = get(L2LbService.class);
-        // Get l2 load balancers and reservations
-        Map<L2LbId, L2Lb> l2LbStore = service.getL2Lbs();
-        Map<L2LbId, ApplicationId> l2LbResStore = service.getReservations();
-        // Print id -> ports, mode, reservation
-        l2LbStore.forEach((l2LbId, l2Lb) -> print("%s -> %s, %s, %s", l2LbId, l2Lb.ports(), l2Lb.mode(),
-                                                  l2LbResStore.get(l2LbId) == null ?
-                                                          AVAILABLE : l2LbResStore.get(l2LbId).name()));
-    }
-}
\ No newline at end of file
diff --git a/apps/l2lb/src/main/java/org/onosproject/l2lb/cli/L2LbRemoveCommand.java b/apps/l2lb/src/main/java/org/onosproject/l2lb/cli/L2LbRemoveCommand.java
deleted file mode 100644
index 6a2a65e..0000000
--- a/apps/l2lb/src/main/java/org/onosproject/l2lb/cli/L2LbRemoveCommand.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2018-present Open Networking Foundation
- *
- * 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.l2lb.cli;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.l2lb.api.L2Lb;
-import org.onosproject.l2lb.api.L2LbAdminService;
-import org.onosproject.l2lb.api.L2LbId;
-import org.onosproject.net.DeviceId;
-
-/**
- * Command to remove a L2 load balancer.
- */
-@Command(scope = "onos", name = "l2lb-remove", description = "Remove L2 load balancers ")
-public class L2LbRemoveCommand extends AbstractShellCommand {
-    @Argument(index = 0, name = "deviceId",
-            description = "Device ID",
-            required = true, multiValued = false)
-    private String deviceIdStr;
-
-    @Argument(index = 1, name = "key",
-            description = "L2 load balancer key",
-            required = true, multiValued = false)
-    private String keyStr;
-
-    // Operation constants
-    private static final String EXECUTED = "Executed";
-    private static final String FAILED = "Failed";
-
-    @Override
-    protected void execute() {
-        DeviceId deviceId = DeviceId.deviceId(deviceIdStr);
-        int l2LbKey = Integer.parseInt(keyStr);
-
-        L2LbAdminService l2LbAdminService = get(L2LbAdminService.class);
-        L2LbId l2LbId = new L2LbId(deviceId, l2LbKey);
-        L2Lb l2Lb = l2LbAdminService.remove(l2LbId);
-        print("Removal of %s %s", l2LbId, l2Lb != null ? EXECUTED : FAILED);
-    }
-}
diff --git a/apps/l2lb/BUCK b/apps/portloadbalancer/BUCK
similarity index 70%
rename from apps/l2lb/BUCK
rename to apps/portloadbalancer/BUCK
index d293b2d..bdd5efd 100644
--- a/apps/l2lb/BUCK
+++ b/apps/portloadbalancer/BUCK
@@ -15,9 +15,9 @@
 )
 
 onos_app (
-    app_name = 'org.onosproject.l2lb',
+    app_name = 'org.onosproject.portloadbalancer',
     category = 'Utilities',
-    description = 'L2 Load Balance Service',
-    title = 'L2 Load Balance Service',
+    description = 'Port Load Balance Service',
+    title = 'Port Load Balance Service',
     url = 'http://onosproject.org',
 )
diff --git a/apps/l2lb/BUILD b/apps/portloadbalancer/BUILD
similarity index 66%
rename from apps/l2lb/BUILD
rename to apps/portloadbalancer/BUILD
index 7209251..a19a4a1 100644
--- a/apps/l2lb/BUILD
+++ b/apps/portloadbalancer/BUILD
@@ -10,9 +10,9 @@
 )
 
 onos_app(
-    app_name = "org.onosproject.l2lb",
+    app_name = "org.onosproject.portloadbalancer",
     category = "Utilities",
-    description = "L2 Load Balance Service",
-    title = "L2 Load Balance Service",
+    description = "Port Load Balance Service",
+    title = "Port Load Balance Service",
     url = "http://onosproject.org",
 )
diff --git a/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/api/PortLoadBalancer.java b/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/api/PortLoadBalancer.java
new file mode 100644
index 0000000..6cd8df1
--- /dev/null
+++ b/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/api/PortLoadBalancer.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.portloadbalancer.api;
+
+import org.onosproject.net.PortNumber;
+
+import java.util.Objects;
+import java.util.Set;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+/**
+ * Represents port load balancer information.
+ */
+public class PortLoadBalancer {
+    private PortLoadBalancerId portLoadBalancerId;
+    private Set<PortNumber> ports;
+    private PortLoadBalancerMode mode;
+
+    /**
+     * Constructs a port load balancer.
+     *
+     * @param portLoadBalancerId port load balancer ID
+     * @param ports Set of member ports
+     * @param mode port load balancer mode
+     */
+    public PortLoadBalancer(PortLoadBalancerId portLoadBalancerId, Set<PortNumber> ports, PortLoadBalancerMode mode) {
+        this.portLoadBalancerId = portLoadBalancerId;
+        this.ports = ports;
+        this.mode = mode;
+    }
+
+    /**
+     * Gets port load balancer ID.
+     *
+     * @return port load balancer ID
+     */
+    public PortLoadBalancerId portLoadBalancerId() {
+        return portLoadBalancerId;
+    }
+
+    /**
+     * Gets set of member ports.
+     *
+     * @return Set of member ports
+     */
+    public Set<PortNumber> ports() {
+        return ports;
+    }
+
+    /**
+     * Gets port load balancer mode.
+     *
+     * @return port load balancer mode.
+     */
+    public PortLoadBalancerMode mode() {
+        return mode;
+    }
+
+    /**
+     * Gets port load balancer data.
+     *
+     * @return port load balancer data
+     */
+    public PortLoadBalancerData data() {
+        return new PortLoadBalancerData(portLoadBalancerId);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(portLoadBalancerId, ports, mode);
+    }
+
+    @Override
+    public boolean equals(final Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (!(obj instanceof PortLoadBalancer)) {
+            return false;
+        }
+        final PortLoadBalancer other = (PortLoadBalancer) obj;
+
+        return Objects.equals(this.portLoadBalancerId, other.portLoadBalancerId) &&
+                Objects.equals(this.ports, other.ports) &&
+                this.mode == other.mode;
+    }
+
+    @Override
+    public String toString() {
+        return toStringHelper(getClass())
+                .add("id", portLoadBalancerId)
+                .add("ports", ports)
+                .add("mode", mode)
+                .toString();
+    }
+}
diff --git a/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/api/PortLoadBalancerAdminService.java b/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/api/PortLoadBalancerAdminService.java
new file mode 100644
index 0000000..2a2ef20
--- /dev/null
+++ b/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/api/PortLoadBalancerAdminService.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.portloadbalancer.api;
+
+import org.onosproject.net.PortNumber;
+
+import java.util.Set;
+
+/**
+ * Port load balancer admin service.
+ */
+public interface PortLoadBalancerAdminService {
+    /**
+     * Creates or updates a port load balancer.
+     *
+     * @param portLoadBalancerId port load balancer id
+     * @param ports physical ports in the port load balancer
+     * @param mode port load balancer mode
+     * @return port load balancer that is created or updated
+     */
+    PortLoadBalancer createOrUpdate(PortLoadBalancerId portLoadBalancerId, Set<PortNumber> ports,
+                                    PortLoadBalancerMode mode);
+
+    /**
+     * Removes a port load balancer.
+     *
+     * @param portLoadBalancerId port load balancer id
+     * @return port load balancer that is removed or null if it was not possible
+     */
+    PortLoadBalancer remove(PortLoadBalancerId portLoadBalancerId);
+
+}
diff --git a/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/api/PortLoadBalancerData.java b/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/api/PortLoadBalancerData.java
new file mode 100644
index 0000000..7d1e93d
--- /dev/null
+++ b/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/api/PortLoadBalancerData.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.portloadbalancer.api;
+
+
+import java.util.Objects;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+/**
+ * Represents port load balancer event data.
+ */
+public class PortLoadBalancerData {
+
+    // We exchange only id and nextid in the events
+    private PortLoadBalancerId portLoadBalancerId;
+    private int nextId;
+
+    /**
+     * Constructs a port load balancer data.
+     *
+     * @param portLoadBalancerId port load balancer ID
+     */
+    public PortLoadBalancerData(PortLoadBalancerId portLoadBalancerId) {
+        this.portLoadBalancerId = portLoadBalancerId;
+        this.nextId = -1;
+    }
+
+    /**
+     * Constructs a port load balancer data.
+     *
+     * @param portLoadBalancerId port load balancer ID
+     * @param nextId port load balancer next id
+     */
+    public PortLoadBalancerData(PortLoadBalancerId portLoadBalancerId, int nextId) {
+        this.portLoadBalancerId = portLoadBalancerId;
+        this.nextId = nextId;
+    }
+
+    /**
+     * Gets port load balancer ID.
+     *
+     * @return port load balancer ID
+     */
+    public PortLoadBalancerId portLoadBalancerId() {
+        return portLoadBalancerId;
+    }
+
+    /**
+     * Gets port load balancer next id.
+     *
+     * @return port load balancer next id
+     */
+    public int nextId() {
+        return nextId;
+    }
+
+    /**
+     * Sets port load balancer next id.
+     *
+     * @param nextId port load balancer next id
+     */
+    public void setNextId(int nextId) {
+        this.nextId = nextId;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(portLoadBalancerId, nextId);
+    }
+
+    @Override
+    public boolean equals(final Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (!(obj instanceof PortLoadBalancerData)) {
+            return false;
+        }
+        final PortLoadBalancerData other = (PortLoadBalancerData) obj;
+
+        return Objects.equals(this.portLoadBalancerId, other.portLoadBalancerId) &&
+                this.nextId == other.nextId;
+    }
+
+    @Override
+    public String toString() {
+        return toStringHelper(getClass())
+                .add("portLoadBalancerId", portLoadBalancerId)
+                .add("nextId", nextId)
+                .toString();
+    }
+}
diff --git a/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/api/PortLoadBalancerEvent.java b/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/api/PortLoadBalancerEvent.java
new file mode 100644
index 0000000..bd9c234
--- /dev/null
+++ b/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/api/PortLoadBalancerEvent.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.portloadbalancer.api;
+
+import org.onlab.util.Tools;
+import org.onosproject.event.AbstractEvent;
+import java.util.Objects;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+/**
+ * Port load balancer event.
+ */
+public class PortLoadBalancerEvent extends AbstractEvent<PortLoadBalancerEvent.Type, PortLoadBalancerData> {
+
+    private PortLoadBalancerData prevSubject;
+
+    /**
+     * Port load balancer event type.
+     */
+    public enum Type {
+        /**
+         * Port load balancer creation is requested.
+         */
+        ADDED,
+
+        /**
+         * Port load balancer deletion is requested.
+         */
+        REMOVED,
+
+        /**
+         * Port load balancer update is requested.
+         * E.g. member change.
+         */
+        UPDATED,
+
+        /**
+         * Port load balancer creation/update is completed successfully.
+         */
+        INSTALLED,
+
+        /**
+         * Port load balancer deletion is completed successfully.
+         */
+        UNINSTALLED,
+
+        /**
+         * Error occurs during creation/update/deletion of a port load balancer.
+         */
+        FAILED
+    }
+
+    /**
+     * Constructs a port load balancer event.
+     *
+     * @param type event type
+     * @param subject current port load balancer information
+     * @param prevSubject previous port load balancer information
+     */
+    public PortLoadBalancerEvent(Type type, PortLoadBalancerData subject, PortLoadBalancerData prevSubject) {
+        super(type, subject);
+        this.prevSubject = prevSubject;
+    }
+
+    /**
+     * Gets previous port load balancer information.
+     *
+     * @return previous subject
+     */
+    public PortLoadBalancerData prevSubject() {
+        return prevSubject;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(subject(), time(), prevSubject);
+    }
+
+    @Override
+    public boolean equals(Object other) {
+        if (this == other) {
+            return true;
+        }
+
+        if (!(other instanceof PortLoadBalancerEvent)) {
+            return false;
+        }
+
+        PortLoadBalancerEvent that = (PortLoadBalancerEvent) other;
+        return Objects.equals(this.subject(), that.subject()) &&
+                Objects.equals(this.type(), that.type()) &&
+                Objects.equals(this.prevSubject, that.prevSubject);
+    }
+
+    @Override
+    public String toString() {
+        return toStringHelper(this)
+                .add("type", type())
+                .add("subject", subject())
+                .add("prevSubject", prevSubject)
+                .add("time", Tools.defaultOffsetDataTime(time()))
+                .toString();
+    }
+}
diff --git a/apps/l2lb/src/main/java/org/onosproject/l2lb/api/L2LbId.java b/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/api/PortLoadBalancerId.java
similarity index 74%
rename from apps/l2lb/src/main/java/org/onosproject/l2lb/api/L2LbId.java
rename to apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/api/PortLoadBalancerId.java
index 68bcc47..a102dd5 100644
--- a/apps/l2lb/src/main/java/org/onosproject/l2lb/api/L2LbId.java
+++ b/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/api/PortLoadBalancerId.java
@@ -13,49 +13,49 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.onosproject.l2lb.api;
+package org.onosproject.portloadbalancer.api;
 
 import org.onosproject.net.DeviceId;
 
 import java.util.Objects;
 
 /**
- * L2 load balancer identifier.
+ * Port load balancer identifier.
  * It is used to identify a load balancer across the entire system and therefore has to be unique system-wide.
  */
-public class L2LbId {
+public class PortLoadBalancerId {
     private final DeviceId deviceId;
 
     /**
-     * L2 load balancer key.
+     * Port load balancer key.
      * It is used to identify a load balancer on a specific device and therefore has to be unique device-wide.
      */
     private final int key;
 
     /**
-     * Constructs L2 load balancer ID.
+     * Constructs port load balancer ID.
      *
      * @param deviceId device ID
-     * @param key L2 load balancer key
+     * @param key port load balancer key
      */
-    public L2LbId(DeviceId deviceId, int key) {
+    public PortLoadBalancerId(DeviceId deviceId, int key) {
         this.deviceId = deviceId;
         this.key = key;
     }
 
     /**
-     * Returns L2 load balancer device ID.
+     * Returns port load balancer device ID.
      *
-     * @return L2 load balancer device ID
+     * @return port load balancer device ID
      */
     public DeviceId deviceId() {
         return deviceId;
     }
 
     /**
-     * Returns L2 load balancer key.
+     * Returns port load balancer key.
      *
-     * @return L2 load balancer key
+     * @return port load balancer key
      */
     public int key() {
         return key;
@@ -71,10 +71,10 @@
         if (this == obj) {
             return true;
         }
-        if (!(obj instanceof L2LbId)) {
+        if (!(obj instanceof PortLoadBalancerId)) {
             return false;
         }
-        final L2LbId other = (L2LbId) obj;
+        final PortLoadBalancerId other = (PortLoadBalancerId) obj;
 
         return Objects.equals(this.deviceId, other.deviceId) &&
                 Objects.equals(this.key, other.key);
diff --git a/apps/l2lb/src/main/java/org/onosproject/l2lb/api/L2LbListener.java b/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/api/PortLoadBalancerListener.java
similarity index 79%
rename from apps/l2lb/src/main/java/org/onosproject/l2lb/api/L2LbListener.java
rename to apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/api/PortLoadBalancerListener.java
index f04ca47..de4efa8 100644
--- a/apps/l2lb/src/main/java/org/onosproject/l2lb/api/L2LbListener.java
+++ b/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/api/PortLoadBalancerListener.java
@@ -14,12 +14,12 @@
  * limitations under the License.
  */
 
-package org.onosproject.l2lb.api;
+package org.onosproject.portloadbalancer.api;
 
 import org.onosproject.event.EventListener;
 
 /**
- * L2 load balancer event listener.
+ * Port load balancer event listener.
  */
-public interface L2LbListener extends EventListener<L2LbEvent> {
+public interface PortLoadBalancerListener extends EventListener<PortLoadBalancerEvent> {
 }
diff --git a/apps/l2lb/src/main/java/org/onosproject/l2lb/api/L2LbMode.java b/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/api/PortLoadBalancerMode.java
similarity index 83%
rename from apps/l2lb/src/main/java/org/onosproject/l2lb/api/L2LbMode.java
rename to apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/api/PortLoadBalancerMode.java
index cec6168..233c116 100644
--- a/apps/l2lb/src/main/java/org/onosproject/l2lb/api/L2LbMode.java
+++ b/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/api/PortLoadBalancerMode.java
@@ -13,21 +13,21 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.onosproject.l2lb.api;
+package org.onosproject.portloadbalancer.api;
 
 /**
- * L2 load balancer mode.
+ * Port load balancer mode.
  */
-public enum L2LbMode {
+public enum PortLoadBalancerMode {
     /**
-     * Static L2 load balancer.
+     * Static port load balancer.
      *
      * In STATIC mode, all member ports of this load balancer will be used to transmit data as long as it is enabled.
      */
     STATIC,
 
     /**
-     * L2 load balancer based on LACP.
+     * Port load balancer based on LACP.
      *
      * In LACP mode, we decide whether to use a member port to transmit data or not according to
      * the LACP negotiation result.
diff --git a/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/api/PortLoadBalancerService.java b/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/api/PortLoadBalancerService.java
new file mode 100644
index 0000000..5c7f1d3
--- /dev/null
+++ b/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/api/PortLoadBalancerService.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.portloadbalancer.api;
+
+import org.onosproject.core.ApplicationId;
+import org.onosproject.event.ListenerService;
+
+import java.util.Map;
+
+/**
+ * Port load balance service.
+ */
+public interface PortLoadBalancerService extends ListenerService<PortLoadBalancerEvent, PortLoadBalancerListener> {
+    /**
+     * Gets all port load balancers from the store.
+     *
+     * @return port load balancer ID and port load balancer information mapping
+     */
+    Map<PortLoadBalancerId, PortLoadBalancer> getPortLoadBalancers();
+
+    /**
+     * Gets port load balancer that matches given device ID and key, or null if not found.
+     *
+     * @param portLoadBalancerId port load balancer id
+     * @return port load balancer information
+     */
+    PortLoadBalancer getPortLoadBalancer(PortLoadBalancerId portLoadBalancerId);
+
+    /**
+     * Gets the mapping between port load balancer id and
+     * the next objective id that represents the port load balancer.
+     *
+     * @return port load balancer id and next id mapping
+     */
+    Map<PortLoadBalancerId, Integer> getPortLoadBalancerNexts();
+
+    /**
+     * Gets port load balancer next id that matches given device Id and key, or null if not found.
+     *
+     * @param portLoadBalancerId port load balancer id
+     * @return next ID
+     */
+    int getPortLoadBalancerNext(PortLoadBalancerId portLoadBalancerId);
+
+    /**
+     * Reserves a port load balancer. Only one application
+     * at time can reserve a given port load balancer.
+     *
+     * @param portLoadBalancerId the port load balancer id
+     * @param appId the application id
+     * @return true if reservation was successful false otherwise
+     */
+    boolean reserve(PortLoadBalancerId portLoadBalancerId, ApplicationId appId);
+
+    /**
+     * Releases a port load balancer. Once released
+     * by the owner the port load balancer is eligible
+     * for removal.
+     *
+     * @param portLoadBalancerId the port load balancer id
+     * @param appId the application id
+     * @return true if release was successful false otherwise
+     */
+    boolean release(PortLoadBalancerId portLoadBalancerId, ApplicationId appId);
+
+    /**
+     * Gets reservation of a port load balancer. Only one application
+     * at time can reserve a given port load balancer.
+     *
+     * @param portLoadBalancerId the port load balancer id
+     * @return the id of the application using the port load balancer
+     */
+    ApplicationId getReservation(PortLoadBalancerId portLoadBalancerId);
+
+    /**
+     * Gets port load balancer reservations. Only one application
+     * at time can reserve a given port load balancer.
+     *
+     * @return reservations of the port load balancer resources
+     */
+    Map<PortLoadBalancerId, ApplicationId> getReservations();
+
+}
diff --git a/apps/l2lb/src/main/java/org/onosproject/l2lb/cli/package-info.java b/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/api/package-info.java
similarity index 89%
copy from apps/l2lb/src/main/java/org/onosproject/l2lb/cli/package-info.java
copy to apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/api/package-info.java
index 4e157c1..63a0bf0 100644
--- a/apps/l2lb/src/main/java/org/onosproject/l2lb/cli/package-info.java
+++ b/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/api/package-info.java
@@ -15,6 +15,6 @@
  */
 
 /**
- * L2 load balancer CLI.
+ * Port load balancer API.
  */
-package org.onosproject.l2lb.cli;
\ No newline at end of file
+package org.onosproject.portloadbalancer.api;
\ No newline at end of file
diff --git a/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/app/PortLoadBalancerManager.java b/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/app/PortLoadBalancerManager.java
new file mode 100644
index 0000000..26fffde
--- /dev/null
+++ b/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/app/PortLoadBalancerManager.java
@@ -0,0 +1,632 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.portloadbalancer.app;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Sets;
+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.KryoNamespace;
+import org.onosproject.cluster.ClusterService;
+import org.onosproject.cluster.LeadershipService;
+import org.onosproject.cluster.NodeId;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.core.CoreService;
+import org.onosproject.portloadbalancer.api.PortLoadBalancer;
+import org.onosproject.portloadbalancer.api.PortLoadBalancerData;
+import org.onosproject.portloadbalancer.api.PortLoadBalancerEvent;
+import org.onosproject.portloadbalancer.api.PortLoadBalancerAdminService;
+import org.onosproject.portloadbalancer.api.PortLoadBalancerId;
+import org.onosproject.portloadbalancer.api.PortLoadBalancerListener;
+import org.onosproject.portloadbalancer.api.PortLoadBalancerMode;
+import org.onosproject.portloadbalancer.api.PortLoadBalancerService;
+import org.onosproject.mastership.MastershipService;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.device.DeviceEvent;
+import org.onosproject.net.device.DeviceListener;
+import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.flow.DefaultTrafficSelector;
+import org.onosproject.net.flow.DefaultTrafficTreatment;
+import org.onosproject.net.flow.TrafficSelector;
+import org.onosproject.net.flow.TrafficTreatment;
+import org.onosproject.net.flow.instructions.Instruction;
+import org.onosproject.net.flow.instructions.Instructions;
+import org.onosproject.net.flowobjective.DefaultNextObjective;
+import org.onosproject.net.flowobjective.DefaultNextTreatment;
+import org.onosproject.net.flowobjective.FlowObjectiveService;
+import org.onosproject.net.flowobjective.NextObjective;
+import org.onosproject.net.flowobjective.Objective;
+import org.onosproject.net.flowobjective.ObjectiveContext;
+import org.onosproject.net.flowobjective.ObjectiveError;
+import org.onosproject.store.serializers.KryoNamespaces;
+import org.onosproject.store.service.ConsistentMap;
+import org.onosproject.store.service.MapEvent;
+import org.onosproject.store.service.MapEventListener;
+import org.onosproject.store.service.Serializer;
+import org.onosproject.store.service.StorageService;
+import org.onosproject.store.service.Versioned;
+import org.slf4j.Logger;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.stream.Collectors;
+
+import static org.onlab.util.Tools.groupedThreads;
+import static org.slf4j.LoggerFactory.getLogger;
+
+@Component(immediate = true)
+@Service
+public class PortLoadBalancerManager implements PortLoadBalancerService, PortLoadBalancerAdminService {
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    private CoreService coreService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    private StorageService storageService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    private FlowObjectiveService flowObjService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    private MastershipService mastershipService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    private LeadershipService leadershipService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    private ClusterService clusterService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    private DeviceService deviceService;
+
+    private static final Logger log = getLogger(PortLoadBalancerManager.class);
+    private static final String APP_NAME = "org.onosproject.portloadbalancer";
+
+    private ApplicationId appId;
+    private ConsistentMap<PortLoadBalancerId, PortLoadBalancer> portLoadBalancerStore;
+    private ConsistentMap<PortLoadBalancerId, Integer> portLoadBalancerNextStore;
+    // TODO Evaluate if ResourceService is a better option
+    private ConsistentMap<PortLoadBalancerId, ApplicationId> portLoadBalancerResStore;
+    private Set<PortLoadBalancerListener> listeners = Sets.newConcurrentHashSet();
+
+    private ExecutorService portLoadBalancerEventExecutor;
+    private ExecutorService portLoadBalancerProvExecutor;
+    private ExecutorService deviceEventExecutor;
+
+    private MapEventListener<PortLoadBalancerId, PortLoadBalancer> portLoadBalancerStoreListener;
+    // TODO build CLI to view and clear the next store
+    private MapEventListener<PortLoadBalancerId, Integer> portLoadBalancerNextStoreListener;
+    private MapEventListener<PortLoadBalancerId, ApplicationId> portLoadBalancerResStoreListener;
+    private final DeviceListener deviceListener = new InternalDeviceListener();
+
+    @Activate
+    public void activate() {
+        appId = coreService.registerApplication(APP_NAME);
+
+        portLoadBalancerEventExecutor = Executors.newSingleThreadExecutor(
+                groupedThreads("portloadbalancer-event", "%d", log));
+        portLoadBalancerProvExecutor = Executors.newSingleThreadExecutor(
+                groupedThreads("portloadbalancer-prov", "%d", log));
+        deviceEventExecutor = Executors.newSingleThreadScheduledExecutor(
+                groupedThreads("portloadbalancer-dev-event", "%d", log));
+        portLoadBalancerStoreListener = new PortLoadBalancerStoreListener();
+        portLoadBalancerNextStoreListener = new PortLoadBalancerNextStoreListener();
+        portLoadBalancerResStoreListener = new PortLoadBalancerResStoreListener();
+
+        KryoNamespace serializer = KryoNamespace.newBuilder()
+                .register(KryoNamespaces.API)
+                .register(PortLoadBalancer.class)
+                .register(PortLoadBalancerId.class)
+                .register(PortLoadBalancerMode.class)
+                .build();
+        portLoadBalancerStore = storageService.<PortLoadBalancerId, PortLoadBalancer>consistentMapBuilder()
+                .withName("onos-portloadbalancer-store")
+                .withRelaxedReadConsistency()
+                .withSerializer(Serializer.using(serializer))
+                .build();
+        portLoadBalancerStore.addListener(portLoadBalancerStoreListener);
+        portLoadBalancerNextStore = storageService.<PortLoadBalancerId, Integer>consistentMapBuilder()
+                .withName("onos-portloadbalancer-next-store")
+                .withRelaxedReadConsistency()
+                .withSerializer(Serializer.using(serializer))
+                .build();
+        portLoadBalancerNextStore.addListener(portLoadBalancerNextStoreListener);
+        portLoadBalancerResStore = storageService.<PortLoadBalancerId, ApplicationId>consistentMapBuilder()
+                .withName("onos-portloadbalancer-res-store")
+                .withRelaxedReadConsistency()
+                .withSerializer(Serializer.using(serializer))
+                .build();
+        portLoadBalancerResStore.addListener(portLoadBalancerResStoreListener);
+
+        deviceService.addListener(deviceListener);
+
+        log.info("Started");
+    }
+
+    @Deactivate
+    public void deactivate() {
+        portLoadBalancerStore.removeListener(portLoadBalancerStoreListener);
+        portLoadBalancerNextStore.removeListener(portLoadBalancerNextStoreListener);
+
+        portLoadBalancerEventExecutor.shutdown();
+        portLoadBalancerProvExecutor.shutdown();
+        deviceEventExecutor.shutdown();
+
+        log.info("Stopped");
+    }
+
+    @Override
+    public void addListener(PortLoadBalancerListener listener) {
+        listeners.add(listener);
+    }
+
+    @Override
+    public void removeListener(PortLoadBalancerListener listener) {
+        listeners.remove(listener);
+    }
+
+    @Override
+    public PortLoadBalancer createOrUpdate(PortLoadBalancerId portLoadBalancerId, Set<PortNumber> ports,
+                                           PortLoadBalancerMode mode) {
+        log.debug("Putting {} -> {} {} into port load balancer store", portLoadBalancerId, mode, ports);
+        return Versioned.valueOrNull(portLoadBalancerStore.put(portLoadBalancerId,
+                new PortLoadBalancer(portLoadBalancerId, ports, mode)));
+    }
+
+    @Override
+    public PortLoadBalancer remove(PortLoadBalancerId portLoadBalancerId) {
+        ApplicationId reservation = Versioned.valueOrNull(portLoadBalancerResStore.get(portLoadBalancerId));
+        // Remove only if it is not used - otherwise it is necessary to release first
+        if (reservation == null) {
+            log.debug("Removing {} from port load balancer store", portLoadBalancerId);
+            return Versioned.valueOrNull(portLoadBalancerStore.remove(portLoadBalancerId));
+        }
+        log.warn("Removal {} from port load balancer store was not possible " +
+                          "due to a previous reservation", portLoadBalancerId);
+        return null;
+    }
+
+    @Override
+    public Map<PortLoadBalancerId, PortLoadBalancer> getPortLoadBalancers() {
+        return ImmutableMap.copyOf(portLoadBalancerStore.asJavaMap());
+    }
+
+    @Override
+    public PortLoadBalancer getPortLoadBalancer(PortLoadBalancerId portLoadBalancerId) {
+        return Versioned.valueOrNull(portLoadBalancerStore.get(portLoadBalancerId));
+    }
+
+    @Override
+    public Map<PortLoadBalancerId, Integer> getPortLoadBalancerNexts() {
+        return ImmutableMap.copyOf(portLoadBalancerNextStore.asJavaMap());
+    }
+
+    @Override
+    public int getPortLoadBalancerNext(PortLoadBalancerId portLoadBalancerId) {
+        return Versioned.valueOrNull(portLoadBalancerNextStore.get(portLoadBalancerId));
+    }
+
+    @Override
+    public boolean reserve(PortLoadBalancerId portLoadBalancerId, ApplicationId appId) {
+        // Check if the resource is available
+        ApplicationId reservation = Versioned.valueOrNull(portLoadBalancerResStore.get(portLoadBalancerId));
+        PortLoadBalancer portLoadBalancer = Versioned.valueOrNull(portLoadBalancerStore.get(portLoadBalancerId));
+        if (reservation == null && portLoadBalancer != null) {
+            log.debug("Reserving {} -> {} into port load balancer reservation store", portLoadBalancerId, appId);
+            return portLoadBalancerResStore.put(portLoadBalancerId, appId) == null;
+        } else if (reservation != null && reservation.equals(appId)) {
+            // App try to reserve the resource a second time
+            log.debug("Already reserved {} -> {} skip reservation", portLoadBalancerId, appId);
+            return true;
+        }
+        log.warn("Reservation failed {} -> {}", portLoadBalancerId, appId);
+        return false;
+    }
+
+    @Override
+    public boolean release(PortLoadBalancerId portLoadBalancerId, ApplicationId appId) {
+        // Check if the resource is reserved
+        ApplicationId reservation = Versioned.valueOrNull(portLoadBalancerResStore.get(portLoadBalancerId));
+        if (reservation != null && reservation.equals(appId)) {
+            log.debug("Removing {} -> {} from port load balancer reservation store", portLoadBalancerId, appId);
+            return portLoadBalancerResStore.remove(portLoadBalancerId) != null;
+        }
+        log.warn("Release failed {} -> {}", portLoadBalancerId, appId);
+        return false;
+    }
+
+    @Override
+    public ApplicationId getReservation(PortLoadBalancerId portLoadBalancerId) {
+        return Versioned.valueOrNull(portLoadBalancerResStore.get(portLoadBalancerId));
+    }
+
+    @Override
+    public Map<PortLoadBalancerId, ApplicationId> getReservations() {
+        return portLoadBalancerResStore.asJavaMap();
+    }
+
+    private class PortLoadBalancerStoreListener implements MapEventListener<PortLoadBalancerId, PortLoadBalancer> {
+        public void event(MapEvent<PortLoadBalancerId, PortLoadBalancer> event) {
+            switch (event.type()) {
+                case INSERT:
+                    log.debug("PortLoadBalancer {} insert new={}, old={}", event.key(), event.newValue(),
+                            event.oldValue());
+                    post(new PortLoadBalancerEvent(PortLoadBalancerEvent.Type.ADDED, event.newValue().value().data(),
+                            null));
+                    populatePortLoadBalancer(event.newValue().value());
+                    break;
+                case REMOVE:
+                    log.debug("PortLoadBalancer {} remove new={}, old={}", event.key(), event.newValue(),
+                            event.oldValue());
+                    post(new PortLoadBalancerEvent(PortLoadBalancerEvent.Type.REMOVED, null,
+                            event.oldValue().value().data()));
+                    revokePortLoadBalancer(event.oldValue().value());
+                    break;
+                case UPDATE:
+                    log.debug("PortLoadBalancer {} update new={}, old={}", event.key(), event.newValue(),
+                            event.oldValue());
+                    post(new PortLoadBalancerEvent(PortLoadBalancerEvent.Type.UPDATED, event.newValue().value().data(),
+                            event.oldValue().value().data()));
+                    updatePortLoadBalancer(event.newValue().value(), event.oldValue().value());
+                    break;
+                default:
+                    break;
+            }
+        }
+    }
+
+    private class PortLoadBalancerNextStoreListener implements MapEventListener<PortLoadBalancerId, Integer> {
+        public void event(MapEvent<PortLoadBalancerId, Integer> event) {
+            switch (event.type()) {
+                case INSERT:
+                    log.debug("PortLoadBalancer next {} insert new={}, old={}", event.key(), event.newValue(),
+                            event.oldValue());
+                    break;
+                case REMOVE:
+                    log.debug("PortLoadBalancer next {} remove new={}, old={}", event.key(), event.newValue(),
+                            event.oldValue());
+                    break;
+                case UPDATE:
+                    log.debug("PortLoadBalancer next {} update new={}, old={}", event.key(), event.newValue(),
+                            event.oldValue());
+                    break;
+                default:
+                    break;
+            }
+        }
+    }
+
+    private class PortLoadBalancerResStoreListener implements MapEventListener<PortLoadBalancerId, ApplicationId> {
+        public void event(MapEvent<PortLoadBalancerId, ApplicationId> event) {
+            switch (event.type()) {
+                case INSERT:
+                    log.debug("PortLoadBalancer reservation {} insert new={}, old={}", event.key(), event.newValue(),
+                              event.oldValue());
+                    break;
+                case REMOVE:
+                    log.debug("PortLoadBalancer reservation {} remove new={}, old={}", event.key(), event.newValue(),
+                              event.oldValue());
+                    break;
+                case UPDATE:
+                    log.debug("PortLoadBalancer reservation {} update new={}, old={}", event.key(), event.newValue(),
+                              event.oldValue());
+                    break;
+                default:
+                    break;
+            }
+        }
+    }
+
+    private class InternalDeviceListener implements DeviceListener {
+        // We want to manage only a subset of events and if we are the leader
+        @Override
+        public void event(DeviceEvent event) {
+            deviceEventExecutor.execute(() -> {
+                DeviceId deviceId = event.subject().id();
+                if (!isLocalLeader(deviceId)) {
+                    log.debug("Not the leader of {}. Skip event {}", deviceId, event);
+                    return;
+                }
+                // Populate or revoke according to the device availability
+                if (deviceService.isAvailable(deviceId)) {
+                    init(deviceId);
+                } else {
+                    cleanup(deviceId);
+                }
+            });
+        }
+        // Some events related to the devices are skipped
+        @Override
+        public boolean isRelevant(DeviceEvent event) {
+            return event.type() == DeviceEvent.Type.DEVICE_ADDED ||
+                    event.type() == DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED ||
+                    event.type() == DeviceEvent.Type.DEVICE_UPDATED;
+        }
+    }
+
+    private void post(PortLoadBalancerEvent portLoadBalancerEvent) {
+        portLoadBalancerEventExecutor.execute(() -> {
+            for (PortLoadBalancerListener l : listeners) {
+                if (l.isRelevant(portLoadBalancerEvent)) {
+                    l.event(portLoadBalancerEvent);
+                }
+            }
+        });
+    }
+
+    private void init(DeviceId deviceId) {
+        portLoadBalancerStore.entrySet().stream()
+                .filter(portLoadBalancerEntry -> portLoadBalancerEntry.getKey().deviceId().equals(deviceId))
+                .forEach(portLoadBalancerEntry -> populatePortLoadBalancer(portLoadBalancerEntry.getValue().value()));
+    }
+
+    private void cleanup(DeviceId deviceId) {
+        portLoadBalancerStore.entrySet().stream()
+                .filter(entry -> entry.getKey().deviceId().equals(deviceId))
+                .forEach(entry -> portLoadBalancerNextStore.remove(entry.getKey()));
+        log.debug("{} is removed from portLoadBalancerNextStore", deviceId);
+    }
+
+    private void populatePortLoadBalancer(PortLoadBalancer portLoadBalancer) {
+        DeviceId deviceId = portLoadBalancer.portLoadBalancerId().deviceId();
+        if (!isLocalLeader(deviceId)) {
+            log.debug("Not the leader of {}. Skip populatePortLoadBalancer {}", deviceId,
+                    portLoadBalancer.portLoadBalancerId());
+            return;
+        }
+
+        portLoadBalancerProvExecutor.execute(() -> {
+            Integer nextid = Versioned.valueOrNull(portLoadBalancerNextStore
+                    .get(portLoadBalancer.portLoadBalancerId()));
+            if (nextid == null) {
+                // Build a new context and new next objective
+                PortLoadBalancerObjectiveContext context =
+                        new PortLoadBalancerObjectiveContext(portLoadBalancer.portLoadBalancerId());
+                NextObjective nextObj = nextObjBuilder(portLoadBalancer.portLoadBalancerId(),
+                        portLoadBalancer.ports(), nextid).add(context);
+                // Finally submit, store, and register the resource
+                flowObjService.next(deviceId, nextObj);
+                portLoadBalancerNextStore.put(portLoadBalancer.portLoadBalancerId(), nextObj.id());
+            } else {
+                log.info("NextObj for {} already exists. Skip populatePortLoadBalancer",
+                        portLoadBalancer.portLoadBalancerId());
+            }
+        });
+    }
+
+    private void revokePortLoadBalancer(PortLoadBalancer portLoadBalancer) {
+        DeviceId deviceId = portLoadBalancer.portLoadBalancerId().deviceId();
+        if (!isLocalLeader(deviceId)) {
+            log.debug("Not the leader of {}. Skip revokePortLoadBalancer {}", deviceId,
+                    portLoadBalancer.portLoadBalancerId());
+            return;
+        }
+
+        portLoadBalancerProvExecutor.execute(() -> {
+            Integer nextid = Versioned.valueOrNull(portLoadBalancerNextStore.get(portLoadBalancer
+                    .portLoadBalancerId()));
+            if (nextid != null) {
+                // Build a new context and remove old next objective
+                PortLoadBalancerObjectiveContext context =
+                        new PortLoadBalancerObjectiveContext(portLoadBalancer.portLoadBalancerId());
+                NextObjective nextObj = nextObjBuilder(portLoadBalancer.portLoadBalancerId(), portLoadBalancer.ports(),
+                        nextid).remove(context);
+                // Finally submit and invalidate the store
+                flowObjService.next(deviceId, nextObj);
+                portLoadBalancerNextStore.remove(portLoadBalancer.portLoadBalancerId());
+            } else {
+                log.info("NextObj for {} does not exist. Skip revokePortLoadBalancer",
+                        portLoadBalancer.portLoadBalancerId());
+            }
+        });
+    }
+
+    private void updatePortLoadBalancer(PortLoadBalancer newPortLoadBalancer, PortLoadBalancer oldPortLoadBalancer) {
+        DeviceId deviceId = newPortLoadBalancer.portLoadBalancerId().deviceId();
+        if (!isLocalLeader(deviceId)) {
+            log.debug("Not the leader of {}. Skip updatePortLoadBalancer {}", deviceId,
+                    newPortLoadBalancer.portLoadBalancerId());
+            return;
+        }
+
+        portLoadBalancerProvExecutor.execute(() -> {
+            Integer nextid = Versioned.valueOrNull(portLoadBalancerNextStore
+                    .get(newPortLoadBalancer.portLoadBalancerId()));
+            if (nextid != null) {
+                // Compute modifications and context
+                PortLoadBalancerObjectiveContext context =
+                        new PortLoadBalancerObjectiveContext(newPortLoadBalancer.portLoadBalancerId());
+                Set<PortNumber> portsToBeAdded =
+                        Sets.difference(newPortLoadBalancer.ports(), oldPortLoadBalancer.ports());
+                Set<PortNumber> portsToBeRemoved =
+                        Sets.difference(oldPortLoadBalancer.ports(), newPortLoadBalancer.ports());
+                // and send them to the flowobj subsystem
+                if (!portsToBeAdded.isEmpty()) {
+                    flowObjService.next(deviceId, nextObjBuilder(newPortLoadBalancer.portLoadBalancerId(),
+                            portsToBeAdded, nextid)
+                            .addToExisting(context));
+                } else {
+                    log.debug("NextObj for {} nothing to add", newPortLoadBalancer.portLoadBalancerId());
+
+                }
+                if (!portsToBeRemoved.isEmpty()) {
+                    flowObjService.next(deviceId, nextObjBuilder(newPortLoadBalancer.portLoadBalancerId(),
+                            portsToBeRemoved, nextid)
+                            .removeFromExisting(context));
+                } else {
+                    log.debug("NextObj for {} nothing to remove", newPortLoadBalancer.portLoadBalancerId());
+                }
+            } else {
+                log.info("NextObj for {} does not exist. Skip updatePortLoadBalancer",
+                        newPortLoadBalancer.portLoadBalancerId());
+            }
+        });
+    }
+
+    private NextObjective.Builder nextObjBuilder(PortLoadBalancerId portLoadBalancerId, Set<PortNumber> ports,
+                                                 Integer nextId) {
+        if (nextId == null) {
+            nextId = flowObjService.allocateNextId();
+        }
+        // This metadata is used to pass the key to the driver.
+        // Some driver, e.g. OF-DPA, will use that information while creating load balancing group.
+        // TODO This is not an actual LAG port. In the future, we should extend metadata structure to carry
+        //      generic information. We should avoid using in_port in the metadata once generic metadata is available.
+        TrafficSelector meta = DefaultTrafficSelector.builder()
+                .matchInPort(PortNumber.portNumber(portLoadBalancerId.key())).build();
+        NextObjective.Builder nextObjBuilder = DefaultNextObjective.builder()
+                .withId(nextId)
+                .withMeta(meta)
+                .withType(NextObjective.Type.HASHED)
+                .fromApp(appId);
+        ports.forEach(port -> {
+            TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(port).build();
+            nextObjBuilder.addTreatment(DefaultNextTreatment.of(treatment));
+        });
+        return nextObjBuilder;
+    }
+
+    // Custom-built function, when the device is not available we need a fallback mechanism
+    private boolean isLocalLeader(DeviceId deviceId) {
+        if (!mastershipService.isLocalMaster(deviceId)) {
+            // When the device is available we just check the mastership
+            if (deviceService.isAvailable(deviceId)) {
+                return false;
+            }
+            // Fallback with Leadership service - device id is used as topic
+            NodeId leader = leadershipService.runForLeadership(
+                    deviceId.toString()).leaderNodeId();
+            // Verify if this node is the leader
+            return clusterService.getLocalNode().id().equals(leader);
+        }
+        return true;
+    }
+
+    private final class PortLoadBalancerObjectiveContext implements ObjectiveContext {
+        private final PortLoadBalancerId portLoadBalancerId;
+
+        private PortLoadBalancerObjectiveContext(PortLoadBalancerId portLoadBalancerId) {
+            this.portLoadBalancerId = portLoadBalancerId;
+        }
+
+        @Override
+        public void onSuccess(Objective objective) {
+            NextObjective nextObj = (NextObjective) objective;
+            log.debug("Successfully {} nextobj {} for port load balancer {}. NextObj={}",
+                    nextObj.op(), nextObj.id(), portLoadBalancerId, nextObj);
+            portLoadBalancerProvExecutor.execute(() -> onSuccessHandler(nextObj, portLoadBalancerId));
+        }
+
+        @Override
+        public void onError(Objective objective, ObjectiveError error) {
+            NextObjective nextObj = (NextObjective) objective;
+            log.warn("Failed to {} nextobj {} for port load balancer {} due to {}. NextObj={}",
+                    nextObj.op(), nextObj.id(), portLoadBalancerId, error, nextObj);
+            portLoadBalancerProvExecutor.execute(() -> onErrorHandler(nextObj, portLoadBalancerId));
+        }
+    }
+
+    private void onSuccessHandler(NextObjective nextObjective, PortLoadBalancerId portLoadBalancerId) {
+        // Operation done
+        PortLoadBalancerData oldPortLoadBalancerData = new PortLoadBalancerData(portLoadBalancerId);
+        PortLoadBalancerData newPortLoadBalancerData = new PortLoadBalancerData(portLoadBalancerId);
+        // Other operations will not lead to a generation of an event
+        switch (nextObjective.op()) {
+            case ADD:
+                newPortLoadBalancerData.setNextId(nextObjective.id());
+                post(new PortLoadBalancerEvent(PortLoadBalancerEvent.Type.INSTALLED, newPortLoadBalancerData,
+                        oldPortLoadBalancerData));
+                break;
+            case REMOVE:
+                oldPortLoadBalancerData.setNextId(nextObjective.id());
+                post(new PortLoadBalancerEvent(PortLoadBalancerEvent.Type.UNINSTALLED, newPortLoadBalancerData,
+                        oldPortLoadBalancerData));
+                break;
+            default:
+                break;
+        }
+    }
+
+    private void onErrorHandler(NextObjective nextObjective, PortLoadBalancerId portLoadBalancerId) {
+        // There was a failure
+        PortLoadBalancerData portLoadBalancerData = new PortLoadBalancerData(portLoadBalancerId);
+        // send FAILED event;
+        switch (nextObjective.op()) {
+            case ADD:
+                // If ADD is failing apps do not know the next id; let's update the store
+                portLoadBalancerNextStore.remove(portLoadBalancerId);
+                portLoadBalancerResStore.remove(portLoadBalancerId);
+                portLoadBalancerStore.remove(portLoadBalancerId);
+                post(new PortLoadBalancerEvent(PortLoadBalancerEvent.Type.FAILED, portLoadBalancerData,
+                        portLoadBalancerData));
+                break;
+            case ADD_TO_EXISTING:
+                // If ADD_TO_EXISTING is failing let's remove the failed ports
+                Collection<PortNumber> addedPorts = nextObjective.next().stream()
+                        .flatMap(t -> t.allInstructions().stream())
+                        .filter(i -> i.type() == Instruction.Type.OUTPUT)
+                        .map(i -> ((Instructions.OutputInstruction) i).port())
+                        .collect(Collectors.toList());
+                portLoadBalancerStore.compute(portLoadBalancerId, (key, value) -> {
+                    if (value != null && value.ports() != null && !value.ports().isEmpty()) {
+                        value.ports().removeAll(addedPorts);
+                    }
+                    return value;
+                });
+                portLoadBalancerData.setNextId(nextObjective.id());
+                post(new PortLoadBalancerEvent(PortLoadBalancerEvent.Type.FAILED, portLoadBalancerData,
+                        portLoadBalancerData));
+                break;
+            case REMOVE_FROM_EXISTING:
+                // If REMOVE_TO_EXISTING is failing let's re-add the failed ports
+                Collection<PortNumber> removedPorts = nextObjective.next().stream()
+                        .flatMap(t -> t.allInstructions().stream())
+                        .filter(i -> i.type() == Instruction.Type.OUTPUT)
+                        .map(i -> ((Instructions.OutputInstruction) i).port())
+                        .collect(Collectors.toList());
+                portLoadBalancerStore.compute(portLoadBalancerId, (key, value) -> {
+                    if (value != null && value.ports() != null) {
+                        value.ports().addAll(removedPorts);
+                    }
+                    return value;
+                });
+                portLoadBalancerData.setNextId(nextObjective.id());
+                post(new PortLoadBalancerEvent(PortLoadBalancerEvent.Type.FAILED, portLoadBalancerData,
+                        portLoadBalancerData));
+                break;
+            case VERIFY:
+            case REMOVE:
+                // If ADD/REMOVE_TO_EXISTING, REMOVE and VERIFY are failing let's send
+                // also the info about the next id
+                portLoadBalancerData.setNextId(nextObjective.id());
+                post(new PortLoadBalancerEvent(PortLoadBalancerEvent.Type.FAILED, portLoadBalancerData,
+                        portLoadBalancerData));
+                break;
+            default:
+                break;
+        }
+
+    }
+}
\ No newline at end of file
diff --git a/apps/l2lb/src/main/java/org/onosproject/l2lb/cli/package-info.java b/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/app/package-info.java
similarity index 89%
copy from apps/l2lb/src/main/java/org/onosproject/l2lb/cli/package-info.java
copy to apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/app/package-info.java
index 4e157c1..a92eee5 100644
--- a/apps/l2lb/src/main/java/org/onosproject/l2lb/cli/package-info.java
+++ b/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/app/package-info.java
@@ -15,6 +15,6 @@
  */
 
 /**
- * L2 load balancer CLI.
+ * Port load balancer app.
  */
-package org.onosproject.l2lb.cli;
\ No newline at end of file
+package org.onosproject.portloadbalancer.app;
\ No newline at end of file
diff --git a/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/cli/PortLoadBalancerAddCommand.java b/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/cli/PortLoadBalancerAddCommand.java
new file mode 100644
index 0000000..d7e2e50
--- /dev/null
+++ b/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/cli/PortLoadBalancerAddCommand.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.portloadbalancer.cli;
+
+import com.google.common.collect.Sets;
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.portloadbalancer.api.PortLoadBalancer;
+import org.onosproject.portloadbalancer.api.PortLoadBalancerAdminService;
+import org.onosproject.portloadbalancer.api.PortLoadBalancerId;
+import org.onosproject.portloadbalancer.api.PortLoadBalancerMode;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.PortNumber;
+
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * Command to add a port load balancer.
+ */
+@Command(scope = "onos", name = "plb-add", description = "Create or update port load balancer ")
+public class PortLoadBalancerAddCommand extends AbstractShellCommand {
+    @Argument(index = 0, name = "deviceId",
+            description = "Device ID",
+            required = true, multiValued = false)
+    private String deviceIdStr;
+
+    @Argument(index = 1, name = "key",
+            description = "port load balancer key",
+            required = true, multiValued = false)
+    private String keyStr;
+
+    @Argument(index = 2, name = "mode",
+            description = "port load balancer mode. STATIC or LACP",
+            required = true, multiValued = false)
+    private String modeStr;
+
+    @Argument(index = 3, name = "ports",
+            description = "port load balancer physical ports",
+            required = true, multiValued = true)
+    private String[] portsStr;
+
+    // Operation constants
+    private static final String CREATE = "Create";
+    private static final String UPDATE = "Update";
+
+    @Override
+    protected void execute() {
+        DeviceId deviceId = DeviceId.deviceId(deviceIdStr);
+        int portLoadBalancerKey = Integer.parseInt(keyStr);
+
+        PortLoadBalancerMode mode = PortLoadBalancerMode.valueOf(modeStr.toUpperCase());
+        Set<PortNumber> ports = Sets.newHashSet(portsStr).stream()
+                .map(PortNumber::fromString).collect(Collectors.toSet());
+
+        PortLoadBalancerAdminService portLoadBalancerAdminService = get(PortLoadBalancerAdminService.class);
+        PortLoadBalancerId portLoadBalancerId = new PortLoadBalancerId(deviceId, portLoadBalancerKey);
+        PortLoadBalancer portLoadBalancer = portLoadBalancerAdminService
+                .createOrUpdate(portLoadBalancerId, ports, mode);
+        print("%s of %s executed", portLoadBalancer == null ? CREATE : UPDATE, portLoadBalancerId);
+
+    }
+}
diff --git a/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/cli/PortLoadBalancerListCommand.java b/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/cli/PortLoadBalancerListCommand.java
new file mode 100644
index 0000000..8c9beaf
--- /dev/null
+++ b/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/cli/PortLoadBalancerListCommand.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.portloadbalancer.cli;
+
+import org.apache.karaf.shell.commands.Command;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.portloadbalancer.api.PortLoadBalancer;
+import org.onosproject.portloadbalancer.api.PortLoadBalancerId;
+import org.onosproject.portloadbalancer.api.PortLoadBalancerService;
+
+import java.util.Map;
+
+/**
+ * Command to show all port load balancers.
+ */
+@Command(scope = "onos", name = "plbs", description = "Lists port load balancers")
+public class PortLoadBalancerListCommand extends AbstractShellCommand {
+
+    // Operation constant
+    private static final String AVAILABLE = "Available";
+
+    @Override
+    public void execute() {
+        PortLoadBalancerService service = get(PortLoadBalancerService.class);
+        // Get port load balancers and reservations
+        Map<PortLoadBalancerId, PortLoadBalancer> portLoadBalancerStore = service.getPortLoadBalancers();
+        Map<PortLoadBalancerId, ApplicationId> portLoadBalancerResStore = service.getReservations();
+        // Print id -> ports, mode, reservation
+        portLoadBalancerStore.forEach((portLoadBalancerId, portLoadBalancer) ->
+                print("%s -> %s, %s, %s", portLoadBalancerId, portLoadBalancer.ports(), portLoadBalancer.mode(),
+                        portLoadBalancerResStore.get(portLoadBalancerId) == null ? AVAILABLE :
+                                portLoadBalancerResStore.get(portLoadBalancerId).name()));
+    }
+}
\ No newline at end of file
diff --git a/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/cli/PortLoadBalancerRemoveCommand.java b/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/cli/PortLoadBalancerRemoveCommand.java
new file mode 100644
index 0000000..1ec9751
--- /dev/null
+++ b/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/cli/PortLoadBalancerRemoveCommand.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.portloadbalancer.cli;
+
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.portloadbalancer.api.PortLoadBalancer;
+import org.onosproject.portloadbalancer.api.PortLoadBalancerAdminService;
+import org.onosproject.portloadbalancer.api.PortLoadBalancerId;
+import org.onosproject.net.DeviceId;
+
+/**
+ * Command to remove a port load balancer.
+ */
+@Command(scope = "onos", name = "plb-remove", description = "Remove port load balancers ")
+public class PortLoadBalancerRemoveCommand extends AbstractShellCommand {
+    @Argument(index = 0, name = "deviceId",
+            description = "Device ID",
+            required = true, multiValued = false)
+    private String deviceIdStr;
+
+    @Argument(index = 1, name = "key",
+            description = "port load balancer key",
+            required = true, multiValued = false)
+    private String keyStr;
+
+    // Operation constants
+    private static final String EXECUTED = "Executed";
+    private static final String FAILED = "Failed";
+
+    @Override
+    protected void execute() {
+        DeviceId deviceId = DeviceId.deviceId(deviceIdStr);
+        int portLoadBalancerKey = Integer.parseInt(keyStr);
+
+        PortLoadBalancerAdminService portLoadBalancerAdminService = get(PortLoadBalancerAdminService.class);
+        PortLoadBalancerId portLoadBalancerId = new PortLoadBalancerId(deviceId, portLoadBalancerKey);
+        PortLoadBalancer portLoadBalancer = portLoadBalancerAdminService.remove(portLoadBalancerId);
+        print("Removal of %s %s", portLoadBalancerId, portLoadBalancer != null ? EXECUTED : FAILED);
+    }
+}
diff --git a/apps/l2lb/src/main/java/org/onosproject/l2lb/cli/package-info.java b/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/cli/package-info.java
similarity index 89%
rename from apps/l2lb/src/main/java/org/onosproject/l2lb/cli/package-info.java
rename to apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/cli/package-info.java
index 4e157c1..7e448ce 100644
--- a/apps/l2lb/src/main/java/org/onosproject/l2lb/cli/package-info.java
+++ b/apps/portloadbalancer/src/main/java/org/onosproject/portloadbalancer/cli/package-info.java
@@ -15,6 +15,6 @@
  */
 
 /**
- * L2 load balancer CLI.
+ * Port load balancer CLI.
  */
-package org.onosproject.l2lb.cli;
\ No newline at end of file
+package org.onosproject.portloadbalancer.cli;
\ No newline at end of file
diff --git a/apps/l2lb/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/apps/portloadbalancer/src/main/resources/OSGI-INF/blueprint/shell-config.xml
similarity index 76%
rename from apps/l2lb/src/main/resources/OSGI-INF/blueprint/shell-config.xml
rename to apps/portloadbalancer/src/main/resources/OSGI-INF/blueprint/shell-config.xml
index 1a6faf1e..dbbdebd 100644
--- a/apps/l2lb/src/main/resources/OSGI-INF/blueprint/shell-config.xml
+++ b/apps/portloadbalancer/src/main/resources/OSGI-INF/blueprint/shell-config.xml
@@ -18,13 +18,13 @@
     <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
 
         <command>
-            <action class="org.onosproject.l2lb.cli.L2LbListCommand"/>
+            <action class="org.onosproject.portloadbalancer.cli.PortLoadBalancerListCommand"/>
         </command>
         <command>
-            <action class="org.onosproject.l2lb.cli.L2LbAddCommand"/>
+            <action class="org.onosproject.portloadbalancer.cli.PortLoadBalancerAddCommand"/>
         </command>
         <command>
-            <action class="org.onosproject.l2lb.cli.L2LbRemoveCommand"/>
+            <action class="org.onosproject.portloadbalancer.cli.PortLoadBalancerRemoveCommand"/>
         </command>
 
     </command-bundle>
diff --git a/apps/segmentrouting/BUCK b/apps/segmentrouting/BUCK
index f56834e..fbe7b812 100644
--- a/apps/segmentrouting/BUCK
+++ b/apps/segmentrouting/BUCK
@@ -12,6 +12,6 @@
     required_apps = [
         'org.onosproject.route-service',
         'org.onosproject.mcast',
-        'org.onosproject.l2lb',
+        'org.onosproject.portloadbalancer',
     ],
 )
diff --git a/apps/segmentrouting/BUILD b/apps/segmentrouting/BUILD
index d3846f3..1304a5e 100644
--- a/apps/segmentrouting/BUILD
+++ b/apps/segmentrouting/BUILD
@@ -10,7 +10,7 @@
     required_apps = [
         "org.onosproject.route-service",
         "org.onosproject.mcast",
-        "org.onosproject.l2lb",
+        "org.onosproject.portloadbalancer",
     ],
     title = "Segment Routing",
     url = "http://onosproject.org",
diff --git a/apps/segmentrouting/app/BUILD b/apps/segmentrouting/app/BUILD
index 081c645..24212b6 100644
--- a/apps/segmentrouting/app/BUILD
+++ b/apps/segmentrouting/app/BUILD
@@ -5,7 +5,7 @@
     "//apps/route-service/api:onos-apps-route-service-api",
     "//apps/mcast/api:onos-apps-mcast-api",
     "//apps/mcast/cli:onos-apps-mcast-cli",
-    "//apps/l2lb:onos-apps-l2lb",
+    "//apps/portloadbalancer:onos-apps-portloadbalancer",
 ]
 
 TEST_DEPS = TEST_ADAPTERS + [
diff --git a/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/xconnect/impl/XconnectManager.java b/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/xconnect/impl/XconnectManager.java
index 91a03f3..b33c62d 100644
--- a/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/xconnect/impl/XconnectManager.java
+++ b/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/xconnect/impl/XconnectManager.java
@@ -37,10 +37,10 @@
 import org.onosproject.codec.CodecService;
 import org.onosproject.core.ApplicationId;
 import org.onosproject.core.CoreService;
-import org.onosproject.l2lb.api.L2LbEvent;
-import org.onosproject.l2lb.api.L2LbId;
-import org.onosproject.l2lb.api.L2LbListener;
-import org.onosproject.l2lb.api.L2LbService;
+import org.onosproject.portloadbalancer.api.PortLoadBalancerEvent;
+import org.onosproject.portloadbalancer.api.PortLoadBalancerId;
+import org.onosproject.portloadbalancer.api.PortLoadBalancerListener;
+import org.onosproject.portloadbalancer.api.PortLoadBalancerService;
 import org.onosproject.mastership.MastershipService;
 import org.onosproject.net.ConnectPoint;
 import org.onosproject.net.DeviceId;
@@ -152,7 +152,7 @@
     private HostService hostService;
 
     @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
-    private L2LbService l2LbService;
+    private PortLoadBalancerService portLoadBalancerService;
 
     private static final String APP_NAME = "org.onosproject.xconnect";
     private static final String ERROR_NOT_LEADER = "Not leader controller";
@@ -178,12 +178,12 @@
 
     // Wait time for the cache
     private static final int WAIT_TIME_MS = 15000;
-    //The cache is implemented as buffer for waiting the installation of L2Lb when present
-    private Cache<L2LbId, XconnectKey> l2LbCache;
+    //The cache is implemented as buffer for waiting the installation of PortLoadBalancer when present
+    private Cache<PortLoadBalancerId, XconnectKey> portLoadBalancerCache;
     // Executor for the cache
-    private ScheduledExecutorService l2lbExecutor;
-    // We need to listen for some events to properly installed the xconnect with l2lb
-    private final L2LbListener l2LbListener = new InternalL2LbListener();
+    private ScheduledExecutorService portLoadBalancerExecutor;
+    // We need to listen for some events to properly installed the xconnect with portloadbalancer
+    private final PortLoadBalancerListener portLoadBalancerListener = new InternalPortLoadBalancerListener();
 
     @Activate
     void activate() {
@@ -229,17 +229,17 @@
                 groupedThreads("sr-xconnect-host-event", "%d", log));
         hostService.addListener(hostListener);
 
-        l2LbCache = CacheBuilder.newBuilder()
+        portLoadBalancerCache = CacheBuilder.newBuilder()
                 .expireAfterWrite(WAIT_TIME_MS, TimeUnit.MILLISECONDS)
-                .removalListener((RemovalNotification<L2LbId, XconnectKey> notification) ->
-                                         log.debug("L2Lb cache removal event. l2LbId={}, xConnectKey={}",
+                .removalListener((RemovalNotification<PortLoadBalancerId, XconnectKey> notification) ->
+                        log.debug("PortLoadBalancer cache removal event. portLoadBalancerId={}, xConnectKey={}",
                                                    notification.getKey(), notification.getValue())).build();
-        l2lbExecutor = newScheduledThreadPool(1,
-                                              groupedThreads("l2LbCacheWorker", "l2LbCacheWorker-%d", log));
+        portLoadBalancerExecutor = newScheduledThreadPool(1,
+                                              groupedThreads("portLoadBalancerCacheWorker", "-%d", log));
         // Let's schedule the cleanup of the cache
-        l2lbExecutor.scheduleAtFixedRate(l2LbCache::cleanUp, 0,
+        portLoadBalancerExecutor.scheduleAtFixedRate(portLoadBalancerCache::cleanUp, 0,
                                          WAIT_TIME_MS, TimeUnit.MILLISECONDS);
-        l2LbService.addListener(l2LbListener);
+        portLoadBalancerService.addListener(portLoadBalancerListener);
 
         log.info("Started");
     }
@@ -253,7 +253,7 @@
 
         deviceEventExecutor.shutdown();
         hostEventExecutor.shutdown();
-        l2lbExecutor.shutdown();
+        portLoadBalancerExecutor.shutdown();
 
         log.info("Stopped");
     }
@@ -524,7 +524,7 @@
      */
     private void populateFilter(XconnectKey key, Set<XconnectEndpoint> endpoints) {
         // FIXME Improve the logic
-        //       If L2 load balancer is not involved, use filtered port. Otherwise, use unfiltered port.
+        //       If port load balancer is not involved, use filtered port. Otherwise, use unfiltered port.
         //       The purpose is to make sure existing XConnect logic can still work on a configured port.
         boolean filtered = endpoints.stream()
                 .map(ep -> getNextTreatment(key.deviceId(), ep, false))
@@ -638,7 +638,7 @@
      */
     private void revokeFilter(XconnectKey key, Set<XconnectEndpoint> endpoints) {
         // FIXME Improve the logic
-        //       If L2 load balancer is not involved, use filtered port. Otherwise, use unfiltered port.
+        //       If port load balancer is not involved, use filtered port. Otherwise, use unfiltered port.
         //       The purpose is to make sure existing XConnect logic can still work on a configured port.
         boolean filtered = endpoints.stream()
                 .map(ep -> getNextTreatment(key.deviceId(), ep, false))
@@ -692,12 +692,13 @@
             log.warn("Fail to revokeNext {}: {}", key, ERROR_NEXT_OBJ_BUILDER);
             return;
         }
-        // Release the L2Lbs if present
+        // Release the port load balancer if present
         endpoints.stream()
                 .filter(endpoint -> endpoint.type() == XconnectEndpoint.Type.LOAD_BALANCER)
                 .forEach(endpoint -> {
-                    String l2LbKey = String.valueOf(((XconnectLoadBalancerEndpoint) endpoint).key());
-                    l2LbService.release(new L2LbId(key.deviceId(), Integer.parseInt(l2LbKey)), appId);
+                    String portLoadBalancerKey = String.valueOf(((XconnectLoadBalancerEndpoint) endpoint).key());
+                    portLoadBalancerService.release(new PortLoadBalancerId(key.deviceId(),
+                            Integer.parseInt(portLoadBalancerKey)), appId);
                 });
         flowObjectiveService.next(key.deviceId(), nextObjBuilder.remove(context));
         xconnectNextObjStore.remove(key);
@@ -818,12 +819,12 @@
         for (XconnectEndpoint endpoint : endpoints) {
             NextTreatment nextTreatment = getNextTreatment(key.deviceId(), endpoint, true);
             if (nextTreatment == null) {
-                // If a L2Lb is used in the XConnect - putting on hold
+                // If a PortLoadBalancer is used in the XConnect - putting on hold
                 if (endpoint.type() == XconnectEndpoint.Type.LOAD_BALANCER) {
-                    log.warn("Unable to create nextObj. L2Lb not ready");
-                    String l2LbKey = String.valueOf(((XconnectLoadBalancerEndpoint) endpoint).key());
-                    l2LbCache.asMap().putIfAbsent(new L2LbId(key.deviceId(), Integer.parseInt(l2LbKey)),
-                                                  key);
+                    log.warn("Unable to create nextObj. PortLoadBalancer not ready");
+                    String portLoadBalancerKey = String.valueOf(((XconnectLoadBalancerEndpoint) endpoint).key());
+                    portLoadBalancerCache.asMap().putIfAbsent(new PortLoadBalancerId(key.deviceId(),
+                                    Integer.parseInt(portLoadBalancerKey)), key);
                 } else {
                     log.warn("Unable to create nextObj. Null NextTreatment");
                 }
@@ -1240,8 +1241,9 @@
             return Sets.newHashSet(port);
         }
         if (endpoint.type() == XconnectEndpoint.Type.LOAD_BALANCER) {
-            L2LbId l2LbId = new L2LbId(deviceId, ((XconnectLoadBalancerEndpoint) endpoint).key());
-            Set<PortNumber> ports = l2LbService.getL2Lb(l2LbId).ports();
+            PortLoadBalancerId portLoadBalancerId = new PortLoadBalancerId(deviceId,
+                    ((XconnectLoadBalancerEndpoint) endpoint).key());
+            Set<PortNumber> ports = portLoadBalancerService.getPortLoadBalancer(portLoadBalancerId).ports();
             return Sets.newHashSet(ports);
         }
         return Sets.newHashSet();
@@ -1253,12 +1255,14 @@
             return DefaultNextTreatment.of(DefaultTrafficTreatment.builder().setOutput(port).build());
         }
         if (endpoint.type() == XconnectEndpoint.Type.LOAD_BALANCER) {
-            L2LbId l2LbId = new L2LbId(deviceId, ((XconnectLoadBalancerEndpoint) endpoint).key());
-            NextTreatment idNextTreatment =  IdNextTreatment.of(l2LbService.getL2LbNext(l2LbId));
+            PortLoadBalancerId portLoadBalancerId = new PortLoadBalancerId(deviceId,
+                    ((XconnectLoadBalancerEndpoint) endpoint).key());
+            NextTreatment idNextTreatment =  IdNextTreatment.of(portLoadBalancerService
+                    .getPortLoadBalancerNext(portLoadBalancerId));
             // Reserve only one time during next objective creation
             if (reserve) {
-                if (!l2LbService.reserve(l2LbId, appId)) {
-                    log.warn("Reservation failed for {}", l2LbId);
+                if (!portLoadBalancerService.reserve(portLoadBalancerId, appId)) {
+                    log.warn("Reservation failed for {}", portLoadBalancerId);
                     idNextTreatment = null;
                 }
             }
@@ -1283,35 +1287,35 @@
         return true;
     }
 
-    private class InternalL2LbListener implements L2LbListener {
-        // Populate xconnect once l2lb is available
+    private class InternalPortLoadBalancerListener implements PortLoadBalancerListener {
+        // Populate xconnect once portloadbalancer is available
         @Override
-        public void event(L2LbEvent event) {
-            l2lbExecutor.execute(() -> dequeue(event.subject().l2LbId()));
+        public void event(PortLoadBalancerEvent event) {
+            portLoadBalancerExecutor.execute(() -> dequeue(event.subject().portLoadBalancerId()));
         }
-        // When we receive INSTALLED l2 load balancing is ready
+        // When we receive INSTALLED port load balancing is ready
         @Override
-        public boolean isRelevant(L2LbEvent event) {
-            return event.type() == L2LbEvent.Type.INSTALLED;
+        public boolean isRelevant(PortLoadBalancerEvent event) {
+            return event.type() == PortLoadBalancerEvent.Type.INSTALLED;
         }
     }
 
     // Invalidate the cache and re-start the xconnect installation
-    private void dequeue(L2LbId l2LbId) {
-        XconnectKey xconnectKey = l2LbCache.getIfPresent(l2LbId);
+    private void dequeue(PortLoadBalancerId portLoadBalancerId) {
+        XconnectKey xconnectKey = portLoadBalancerCache.getIfPresent(portLoadBalancerId);
         if (xconnectKey == null) {
-            log.trace("{} not present in the cache", l2LbId);
+            log.trace("{} not present in the cache", portLoadBalancerId);
             return;
         }
-        log.debug("Dequeue {}", l2LbId);
-        l2LbCache.invalidate(l2LbId);
+        log.debug("Dequeue {}", portLoadBalancerId);
+        portLoadBalancerCache.invalidate(portLoadBalancerId);
         Set<XconnectEndpoint> endpoints = Versioned.valueOrNull(xconnectStore.get(xconnectKey));
         if (endpoints == null || endpoints.isEmpty()) {
             log.warn("Endpoints not found for XConnect {}", xconnectKey);
             return;
         }
         populateXConnect(xconnectKey, endpoints);
-        log.trace("L2Lb cache size {}", l2LbCache.size());
+        log.trace("PortLoadBalancer cache size {}", portLoadBalancerCache.size());
     }
 
 }
diff --git a/modules.bzl b/modules.bzl
index fa2e82d..a8cad7f 100644
--- a/modules.bzl
+++ b/modules.bzl
@@ -164,7 +164,7 @@
     "//apps/flowanalyzer:onos-apps-flowanalyzer-oar",
     "//apps/intentsync:onos-apps-intentsync-oar",
     "//apps/influxdbmetrics:onos-apps-influxdbmetrics-oar",
-    "//apps/l2lb:onos-apps-l2lb-oar",
+    "//apps/portloadbalancer:onos-apps-portloadbalancer-oar",
     "//apps/metrics:onos-apps-metrics-oar",
     "//apps/mfwd:onos-apps-mfwd-oar",
     "//apps/mlb:onos-apps-mlb-oar",
